OSDN Git Service

3f3f28ac015398f365d4e6763de15687ba53e343
[pf3gnuchains/gcc-fork.git] / gcc / config / s390 / s390.md
1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;;  Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
3 ;;  Free Software Foundation, Inc.
4 ;;  Contributed by Hartmut Penner (hpenner@de.ibm.com) and
5 ;;                 Ulrich Weigand (uweigand@de.ibm.com).
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify it under
10 ;; the terms of the GNU General Public License as published by the Free
11 ;; Software Foundation; either version 2, or (at your option) any later
12 ;; version.
13
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 ;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 ;; for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING.  If not, write to the Free
21 ;; Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 ;; 02111-1307, USA.
23
24 ;;
25 ;; Special constraints for s/390 machine description:
26 ;;
27 ;;    a -- Any address register from 1 to 15.
28 ;;    c -- Condition code register 33.
29 ;;    d -- Any register from 0 to 15.
30 ;;    I -- An 8-bit constant (0..255).
31 ;;    J -- A 12-bit constant (0..4095).
32 ;;    K -- A 16-bit constant (-32768..32767).
33 ;;    L -- Value appropriate as displacement.
34 ;;         (0..4095) for short displacement
35 ;;         (-524288..524287) for long displacement
36 ;;    M -- Constant integer with a value of 0x7fffffff.
37 ;;    N -- Multiple letter constraint followed by 4 parameter letters.
38 ;;         0..9,x:  number of the part counting from most to least significant
39 ;;         H,Q:     mode of the part
40 ;;         D,S,H:   mode of the containing operand
41 ;;         0,F:     value of the other parts (F - all bits set)
42 ;;
43 ;;         The constraint matches if the specified part of a constant
44 ;;         has a value different from its other parts.  If the letter x
45 ;;         is specified instead of a part number, the constraint matches
46 ;;         if there is any single part with non-default value.
47 ;;    Q -- Memory reference without index register and with short displacement.
48 ;;    R -- Memory reference with index register and short displacement.
49 ;;    S -- Memory reference without index register but with long displacement.
50 ;;    T -- Memory reference with index register and long displacement.
51 ;;    A -- Multiple letter constraint followed by Q, R, S, or T:
52 ;;         Offsettable memory reference of type specified by second letter.
53 ;;    U -- Pointer with short displacement.
54 ;;    W -- Pointer with long displacement.
55 ;;    Y -- Shift count operand.
56 ;;
57 ;; Special formats used for outputting 390 instructions.
58 ;;
59 ;;     %C: print opcode suffix for branch condition.
60 ;;     %D: print opcode suffix for inverse branch condition.
61 ;;     %J: print tls_load/tls_gdcall/tls_ldcall suffix
62 ;;     %O: print only the displacement of a memory reference.
63 ;;     %R: print only the base register of a memory reference.
64 ;;     %S: print S-type memory reference (base+displacement).
65 ;;     %N: print the second word of a DImode operand.
66 ;;     %M: print the second word of a TImode operand.
67
68 ;;     %b: print integer X as if it's an unsigned byte.
69 ;;     %x: print integer X as if it's an unsigned word.
70 ;;     %h: print integer X as if it's a signed word.
71 ;;     %i: print the first nonzero HImode part of X
72 ;;     %j: print the first HImode part unequal to 0xffff of X
73
74 ;;
75 ;; We have a special constraint for pattern matching.
76 ;;
77 ;;   s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
78 ;;
79
80 ;;
81 ;; UNSPEC usage
82 ;;
83
84 (define_constants
85   [; Miscellaneous
86    (UNSPEC_ROUND                1)
87    (UNSPEC_CMPINT               2)
88    (UNSPEC_SETHIGH              10)
89
90    ; GOT/PLT and lt-relative accesses
91    (UNSPEC_LTREL_OFFSET         100)
92    (UNSPEC_LTREL_BASE           101)
93    (UNSPEC_GOTENT               110)
94    (UNSPEC_GOT                  111)
95    (UNSPEC_GOTOFF               112)
96    (UNSPEC_PLT                  113)
97    (UNSPEC_PLTOFF               114)
98
99    ; Literal pool
100    (UNSPEC_RELOAD_BASE          210)
101    (UNSPEC_MAIN_BASE            211)
102    (UNSPEC_LTREF                212)
103    (UNSPEC_INSN                 213)
104    (UNSPEC_EXECUTE              214)
105
106    ; TLS relocation specifiers
107    (UNSPEC_TLSGD                500)
108    (UNSPEC_TLSLDM               501)
109    (UNSPEC_NTPOFF               502)
110    (UNSPEC_DTPOFF               503)
111    (UNSPEC_GOTNTPOFF            504)
112    (UNSPEC_INDNTPOFF            505)
113
114    ; TLS support
115    (UNSPEC_TLSLDM_NTPOFF        511)
116    (UNSPEC_TLS_LOAD             512)
117
118    ; String Functions
119    (UNSPEC_SRST         600)
120  ])
121
122 ;;
123 ;; UNSPEC_VOLATILE usage
124 ;;
125
126 (define_constants
127   [; Blockage
128    (UNSPECV_BLOCKAGE            0)
129
130    ; TPF Support
131    (UNSPECV_TPF_PROLOGUE        20)
132    (UNSPECV_TPF_EPILOGUE        21)
133
134    ; Literal pool
135    (UNSPECV_POOL                200)
136    (UNSPECV_POOL_SECTION        201)
137    (UNSPECV_POOL_ALIGN          202)
138    (UNSPECV_POOL_ENTRY          203)
139    (UNSPECV_MAIN_POOL           300)
140
141    ; TLS support
142    (UNSPECV_SET_TP              500)
143   ])
144
145
146 ;; Instruction operand type as used in the Principles of Operation.
147 ;; Used to determine defaults for length and other attribute values.
148
149 (define_attr "op_type"
150   "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY"
151   (const_string "NN"))
152
153 ;; Instruction type attribute used for scheduling.
154
155 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
156                      cs,vs,store,imul,idiv,
157                      branch,jsr,fsimpd,fsimps,
158                      floadd,floads,fstored, fstores,
159                      fmuld,fmuls,fdivd,fdivs,
160                      ftoi,itof,fsqrtd,fsqrts,
161                      other"
162   (cond [(eq_attr "op_type" "NN")  (const_string "other")
163          (eq_attr "op_type" "SS")  (const_string "cs")]
164     (const_string "integer")))
165
166 ;; Another attribute used for scheduling purposes:
167 ;;   agen: Instruction uses the address generation unit
168 ;;   reg: Instruction does not use the agen unit
169
170 (define_attr "atype" "agen,reg"
171   (cond [(eq_attr "op_type" "E")   (const_string "reg")
172          (eq_attr "op_type" "RR")  (const_string "reg")
173          (eq_attr "op_type" "RX")  (const_string "agen")
174          (eq_attr "op_type" "RI")  (const_string "reg")
175          (eq_attr "op_type" "RRE") (const_string "reg")
176          (eq_attr "op_type" "RS")  (const_string "agen")
177          (eq_attr "op_type" "RSI") (const_string "agen")
178          (eq_attr "op_type" "S")   (const_string "agen")
179          (eq_attr "op_type" "SI")  (const_string "agen")
180          (eq_attr "op_type" "SS")  (const_string "agen")
181          (eq_attr "op_type" "SSE") (const_string "agen")
182          (eq_attr "op_type" "RXE") (const_string "agen")
183          (eq_attr "op_type" "RSE") (const_string "agen")
184          (eq_attr "op_type" "RIL") (const_string "agen")
185          (eq_attr "op_type" "RXY") (const_string "agen")
186          (eq_attr "op_type" "RSY") (const_string "agen")
187          (eq_attr "op_type" "SIY") (const_string "agen")]
188     (const_string "agen")))
189
190 ;; Length in bytes.
191
192 (define_attr "length" ""
193   (cond [(eq_attr "op_type" "E")   (const_int 2)
194          (eq_attr "op_type" "RR")  (const_int 2)
195          (eq_attr "op_type" "RX")  (const_int 4)
196          (eq_attr "op_type" "RI")  (const_int 4)
197          (eq_attr "op_type" "RRE") (const_int 4)
198          (eq_attr "op_type" "RS")  (const_int 4)
199          (eq_attr "op_type" "RSI") (const_int 4)
200          (eq_attr "op_type" "S")   (const_int 4)
201          (eq_attr "op_type" "SI")  (const_int 4)
202          (eq_attr "op_type" "SS")  (const_int 6)
203          (eq_attr "op_type" "SSE") (const_int 6)
204          (eq_attr "op_type" "RXE") (const_int 6)
205          (eq_attr "op_type" "RSE") (const_int 6)
206          (eq_attr "op_type" "RIL") (const_int 6)
207          (eq_attr "op_type" "RXY") (const_int 6)
208          (eq_attr "op_type" "RSY") (const_int 6)
209          (eq_attr "op_type" "SIY") (const_int 6)]
210     (const_int 6)))
211
212
213 ;; Processor type.  This attribute must exactly match the processor_type
214 ;; enumeration in s390.h.  The current machine description does not
215 ;; distinguish between g5 and g6, but there are differences between the two
216 ;; CPUs could in theory be modeled.
217
218 (define_attr "cpu" "g5,g6,z900,z990"
219   (const (symbol_ref "s390_tune")))
220
221 ;; Pipeline description for z900.  For lack of anything better,
222 ;; this description is also used for the g5 and g6.
223 (include "2064.md")
224
225 ;; Pipeline description for z990. 
226 (include "2084.md")
227
228
229 ;;
230 ;;  Condition Codes
231 ;;
232 ;
233 ;   CCL:  Zero     Nonzero   Zero      Nonzero      (AL, ALR, SL, SLR, N, NC, NI, NR, O, OC, OI, OR, X, XC, XI, XR)
234 ;   CCA:  Zero     <Zero     >Zero     Overflow     (A, AR, AH, AHI, S, SR, SH, SHI, LTR, LCR, LNR, LPR, SLA, SLDA, SLA, SRDA)
235 ;   CCU:  Equal    ULess     UGreater  --           (CL, CLR, CLI, CLM)
236 ;   CCS:  Equal    SLess     SGreater  --           (C, CR, CH, CHI, ICM)
237 ;   CCT:  Zero     Mixed     Mixed     Ones         (TM, TMH, TML)
238
239 ;   CCZ  -> CCL / CCZ1
240 ;   CCZ1 -> CCA/CCU/CCS/CCT
241 ;   CCS  -> CCA
242
243 ;   String:    CLC, CLCL, CLCLE, CLST, CUSE, MVCL, MVCLE, MVPG, MVST, SRST
244 ;   Clobber:   CKSM, CFC, CS, CDS, CUUTF, CUTFU, PLO, SPM, STCK, STCKE, TS, TRT, TRE, UPT
245
246
247 ;;
248 ;;- Compare instructions.
249 ;;
250
251 (define_expand "cmpdi"
252   [(set (reg:CC 33)
253         (compare:CC (match_operand:DI 0 "register_operand" "")
254                     (match_operand:DI 1 "general_operand" "")))]
255   "TARGET_64BIT"
256 {
257   s390_compare_op0 = operands[0];
258   s390_compare_op1 = operands[1];
259   DONE;
260 })
261
262 (define_expand "cmpsi"
263   [(set (reg:CC 33)
264         (compare:CC (match_operand:SI 0 "register_operand" "")
265                     (match_operand:SI 1 "general_operand" "")))]
266   ""
267 {
268   s390_compare_op0 = operands[0];
269   s390_compare_op1 = operands[1];
270   DONE;
271 })
272
273 (define_expand "cmpdf"
274   [(set (reg:CC 33)
275         (compare:CC (match_operand:DF 0 "register_operand" "")
276                     (match_operand:DF 1 "general_operand" "")))]
277   "TARGET_HARD_FLOAT"
278 {
279   s390_compare_op0 = operands[0];
280   s390_compare_op1 = operands[1];
281   DONE;
282 })
283
284 (define_expand "cmpsf"
285   [(set (reg:CC 33)
286         (compare:CC (match_operand:SF 0 "register_operand" "")
287                     (match_operand:SF 1 "general_operand" "")))]
288   "TARGET_HARD_FLOAT"
289 {
290   s390_compare_op0 = operands[0];
291   s390_compare_op1 = operands[1];
292   DONE;
293 })
294
295
296 ; Test-under-Mask instructions
297
298 (define_insn "*tmqi_mem"
299   [(set (reg 33)
300         (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
301                          (match_operand:QI 1 "immediate_operand" "n,n"))
302                  (match_operand:QI 2 "immediate_operand" "n,n")))]
303   "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 0))"
304   "@
305    tm\t%S0,%b1
306    tmy\t%S0,%b1"
307   [(set_attr "op_type" "SI,SIY")])
308
309 (define_insn "*tmdi_reg"
310   [(set (reg 33)
311         (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
312                          (match_operand:DI 1 "immediate_operand"
313                                              "N0HD0,N1HD0,N2HD0,N3HD0"))
314                  (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
315   "TARGET_64BIT
316    && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 1))
317    && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
318   "@
319    tmhh\t%0,%i1
320    tmhl\t%0,%i1
321    tmlh\t%0,%i1
322    tmll\t%0,%i1"
323   [(set_attr "op_type" "RI")])
324
325 (define_insn "*tmsi_reg"
326   [(set (reg 33)
327         (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
328                          (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
329                  (match_operand:SI 2 "immediate_operand" "n,n")))]
330   "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], 1))
331    && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
332   "@
333    tmh\t%0,%i1
334    tml\t%0,%i1"
335   [(set_attr "op_type" "RI")])
336
337 (define_insn "*tmhi_full"
338   [(set (reg 33)
339         (compare (match_operand:HI 0 "register_operand" "d")
340                  (match_operand:HI 1 "immediate_operand" "n")))]
341   "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], 1))"
342   "tml\t%0,65535"
343   [(set_attr "op_type" "RI")])
344
345 (define_insn "*tmqi_full"
346   [(set (reg 33)
347         (compare (match_operand:QI 0 "register_operand" "d")
348                  (match_operand:QI 1 "immediate_operand" "n")))]
349   "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], 1))"
350   "tml\t%0,255"
351   [(set_attr "op_type" "RI")])
352
353
354 ; Load-and-Test instructions
355
356 (define_insn "*tstdi_sign"
357   [(set (reg 33)
358         (compare (ashiftrt:DI (ashift:DI (subreg:DI (match_operand:SI 0 "register_operand" "d") 0)
359                                          (const_int 32)) (const_int 32))
360                  (match_operand:DI 1 "const0_operand" "")))
361    (set (match_operand:DI 2 "register_operand" "=d")
362         (sign_extend:DI (match_dup 0)))]
363   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
364   "ltgfr\t%2,%0"
365   [(set_attr "op_type" "RRE")])
366
367 (define_insn "*tstdi"
368   [(set (reg 33)
369         (compare (match_operand:DI 0 "register_operand" "d")
370                  (match_operand:DI 1 "const0_operand" "")))
371    (set (match_operand:DI 2 "register_operand" "=d")
372         (match_dup 0))]
373   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
374   "ltgr\t%2,%0"
375   [(set_attr "op_type" "RRE")])
376
377 (define_insn "*tstdi_cconly"
378   [(set (reg 33)
379         (compare (match_operand:DI 0 "register_operand" "d")
380                  (match_operand:DI 1 "const0_operand" "")))]
381   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
382   "ltgr\t%0,%0"
383   [(set_attr "op_type" "RRE")])
384
385 (define_insn "*tstdi_cconly_31"
386   [(set (reg 33)
387         (compare (match_operand:DI 0 "register_operand" "d")
388                  (match_operand:DI 1 "const0_operand" "")))]
389   "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
390   "srda\t%0,0"
391   [(set_attr "op_type" "RS")
392    (set_attr "atype"   "reg")])
393
394
395 (define_insn "*tstsi"
396   [(set (reg 33)
397         (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
398                  (match_operand:SI 1 "const0_operand" "")))
399    (set (match_operand:SI 2 "register_operand" "=d,d,d")
400         (match_dup 0))]
401   "s390_match_ccmode(insn, CCSmode)"
402   "@
403    ltr\t%2,%0
404    icm\t%2,15,%S0
405    icmy\t%2,15,%S0"
406   [(set_attr "op_type" "RR,RS,RSY")])
407
408 (define_insn "*tstsi_cconly"
409   [(set (reg 33)
410         (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
411                  (match_operand:SI 1 "const0_operand" "")))
412    (clobber (match_scratch:SI 2 "=X,d,d"))]
413   "s390_match_ccmode(insn, CCSmode)"
414   "@
415    ltr\t%0,%0
416    icm\t%2,15,%S0
417    icmy\t%2,15,%S0"
418   [(set_attr "op_type" "RR,RS,RSY")])
419
420 (define_insn "*tstsi_cconly2"
421   [(set (reg 33)
422         (compare (match_operand:SI 0 "register_operand" "d")
423                  (match_operand:SI 1 "const0_operand" "")))]
424   "s390_match_ccmode(insn, CCSmode)"
425   "ltr\t%0,%0"
426   [(set_attr "op_type" "RR")])
427
428 (define_insn "*tsthiCCT"
429   [(set (reg 33)
430         (compare (match_operand:HI 0 "nonimmediate_operand" "?Q,?S,d")
431                  (match_operand:HI 1 "const0_operand" "")))
432    (set (match_operand:HI 2 "register_operand" "=d,d,0")
433         (match_dup 0))]
434   "s390_match_ccmode(insn, CCTmode)"
435   "@
436    icm\t%2,3,%S0
437    icmy\t%2,3,%S0
438    tml\t%0,65535"
439   [(set_attr "op_type" "RS,RSY,RI")])
440
441 (define_insn "*tsthiCCT_cconly"
442   [(set (reg 33)
443         (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
444                  (match_operand:HI 1 "const0_operand" "")))
445    (clobber (match_scratch:HI 2 "=d,d,X"))]
446   "s390_match_ccmode(insn, CCTmode)"
447   "@
448    icm\t%2,3,%S0
449    icmy\t%2,3,%S0
450    tml\t%0,65535"
451   [(set_attr "op_type" "RS,RSY,RI")])
452
453 (define_insn "*tsthi"
454   [(set (reg 33)
455         (compare (match_operand:HI 0 "s_operand" "Q,S")
456                  (match_operand:HI 1 "const0_operand" "")))
457    (set (match_operand:HI 2 "register_operand" "=d,d")
458         (match_dup 0))]
459   "s390_match_ccmode(insn, CCSmode)"
460   "@
461    icm\t%2,3,%S0
462    icmy\t%2,3,%S0"
463   [(set_attr "op_type" "RS,RSY")])
464
465 (define_insn "*tsthi_cconly"
466   [(set (reg 33)
467         (compare (match_operand:HI 0 "s_operand" "Q,S")
468                  (match_operand:HI 1 "const0_operand" "")))
469    (clobber (match_scratch:HI 2 "=d,d"))]
470   "s390_match_ccmode(insn, CCSmode)"
471   "@
472    icm\t%2,3,%S0
473    icmy\t%2,3,%S0"
474   [(set_attr "op_type" "RS,RSY")])
475
476 (define_insn "*tstqiCCT"
477   [(set (reg 33)
478         (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
479                  (match_operand:QI 1 "const0_operand" "")))
480    (set (match_operand:QI 2 "register_operand" "=d,d,0")
481         (match_dup 0))]
482   "s390_match_ccmode(insn, CCTmode)"
483   "@
484    icm\t%2,1,%S0
485    icmy\t%2,1,%S0
486    tml\t%0,255"
487   [(set_attr "op_type" "RS,RSY,RI")])
488
489 (define_insn "*tstqiCCT_cconly"
490   [(set (reg 33)
491         (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
492                  (match_operand:QI 1 "const0_operand" "")))]
493   "s390_match_ccmode(insn, CCTmode)"
494   "@
495    cli\t%S0,0
496    cliy\t%S0,0
497    tml\t%0,255"
498   [(set_attr "op_type" "SI,SIY,RI")])
499
500 (define_insn "*tstqi"
501   [(set (reg 33)
502         (compare (match_operand:QI 0 "s_operand" "Q,S")
503                  (match_operand:QI 1 "const0_operand" "")))
504    (set (match_operand:QI 2 "register_operand" "=d,d")
505         (match_dup 0))]
506   "s390_match_ccmode(insn, CCSmode)"
507   "@
508    icm\t%2,1,%S0
509    icmy\t%2,1,%S0"
510   [(set_attr "op_type" "RS,RSY")])
511
512 (define_insn "*tstqi_cconly"
513   [(set (reg 33)
514         (compare (match_operand:QI 0 "s_operand" "Q,S")
515                  (match_operand:QI 1 "const0_operand" "")))
516    (clobber (match_scratch:QI 2 "=d,d"))]
517   "s390_match_ccmode(insn, CCSmode)"
518   "@
519    icm\t%2,1,%S0
520    icmy\t%2,1,%S0"
521   [(set_attr "op_type" "RS,RSY")])
522
523
524 ; Compare (equality) instructions
525
526 (define_insn "*cmpdi_cct"
527   [(set (reg 33)
528         (compare (match_operand:DI 0 "nonimmediate_operand" "d,d,d,m,Q")
529                  (match_operand:DI 1 "general_operand" "d,K,m,d,Q")))]
530   "s390_match_ccmode (insn, CCTmode) && TARGET_64BIT
531    && (!s390_pool_operand (operands[0]) || !s390_pool_operand (operands[1]))"
532   "@
533    cgr\t%0,%1
534    cghi\t%0,%c1
535    cg\t%0,%1
536    cg\t%1,%0
537    #"
538   [(set_attr "op_type" "RRE,RI,RXY,RXY,SS")])
539
540 (define_insn "*cmpsi_cct"
541   [(set (reg 33)
542         (compare (match_operand:SI 0 "nonimmediate_operand" "d,d,d,d,R,T,Q")
543                  (match_operand:SI 1 "general_operand" "d,K,R,T,d,d,Q")))]
544   "s390_match_ccmode (insn, CCTmode)
545    && (!s390_pool_operand (operands[0]) || !s390_pool_operand (operands[1]))"
546   "@
547    cr\t%0,%1
548    chi\t%0,%c1
549    c\t%0,%1
550    cy\t%0,%1
551    c\t%1,%0
552    cy\t%1,%0
553    #"
554   [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SS")])
555
556
557 ; Compare (signed) instructions
558
559 (define_insn "*cmpdi_ccs_sign"
560   [(set (reg 33)
561         (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
562                  (match_operand:DI 0 "register_operand" "d,d")))]
563   "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
564   "@
565    cgfr\t%0,%1
566    cgf\t%0,%1"
567   [(set_attr "op_type" "RRE,RXY")])
568
569 (define_insn "*cmpdi_ccs"
570   [(set (reg 33)
571         (compare (match_operand:DI 0 "register_operand" "d,d,d")
572                  (match_operand:DI 1 "general_operand" "d,K,m")))]
573   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
574   "@
575    cgr\t%0,%1
576    cghi\t%0,%c1
577    cg\t%0,%1"
578   [(set_attr "op_type" "RRE,RI,RXY")])
579
580 (define_insn "*cmpsi_ccs_sign"
581   [(set (reg 33)
582         (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T"))
583                  (match_operand:SI 0 "register_operand" "d,d")))]
584   "s390_match_ccmode(insn, CCSRmode)"
585   "@
586    ch\t%0,%1
587    chy\t%0,%1"
588   [(set_attr "op_type" "RX,RXY")])
589
590 (define_insn "*cmpsi_ccs"
591   [(set (reg 33)
592         (compare (match_operand:SI 0 "register_operand" "d,d,d,d")
593                  (match_operand:SI 1 "general_operand" "d,K,R,T")))]
594   "s390_match_ccmode(insn, CCSmode)"
595   "@
596    cr\t%0,%1
597    chi\t%0,%c1
598    c\t%0,%1
599    cy\t%0,%1"
600   [(set_attr "op_type" "RR,RI,RX,RXY")])
601
602
603 ; Compare (unsigned) instructions
604
605 (define_insn "*cmpdi_ccu_zero"
606   [(set (reg 33)
607         (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m"))
608                  (match_operand:DI 0 "register_operand" "d,d")))]
609   "s390_match_ccmode (insn, CCURmode) && TARGET_64BIT"
610   "@
611    clgfr\t%0,%1
612    clgf\t%0,%1"
613   [(set_attr "op_type" "RRE,RXY")])
614
615 (define_insn "*cmpdi_ccu"
616   [(set (reg 33)
617         (compare (match_operand:DI 0 "nonimmediate_operand" "d,d,Q")
618                  (match_operand:DI 1 "general_operand" "d,m,Q")))]
619   "s390_match_ccmode (insn, CCUmode) && TARGET_64BIT
620    && (!s390_pool_operand (operands[0]) || !s390_pool_operand (operands[1]))"
621   "@
622    clgr\t%0,%1
623    clg\t%0,%1
624    #"
625   [(set_attr "op_type" "RRE,RXY,SS")])
626
627 (define_insn "*cmpsi_ccu"
628   [(set (reg 33)
629         (compare (match_operand:SI 0 "nonimmediate_operand" "d,d,d,Q")
630                  (match_operand:SI 1 "general_operand" "d,R,T,Q")))]
631   "s390_match_ccmode (insn, CCUmode)
632    && (!s390_pool_operand (operands[0]) || !s390_pool_operand (operands[1]))"
633   "@
634    clr\t%0,%1
635    cl\t%0,%1
636    cly\t%0,%1
637    #"
638   [(set_attr "op_type" "RR,RX,RXY,SS")])
639
640 (define_insn "*cmphi_ccu"
641   [(set (reg 33)
642         (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q")
643                  (match_operand:HI 1 "general_operand" "Q,S,Q")))]
644   "s390_match_ccmode (insn, CCUmode)
645    && (!s390_pool_operand (operands[0]) || !s390_pool_operand (operands[1]))
646    && !register_operand (operands[1], HImode)"
647   "@
648    clm\t%0,3,%S1
649    clmy\t%0,3,%S1
650    #"
651   [(set_attr "op_type" "RS,RSY,SS")])
652
653 (define_insn "*cmpqi_ccu"
654   [(set (reg 33)
655         (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q")
656                  (match_operand:QI 1 "general_operand" "Q,S,n,n,Q")))]
657   "s390_match_ccmode (insn, CCUmode)
658    && (!s390_pool_operand (operands[0]) || !s390_pool_operand (operands[1]))
659    && !register_operand (operands[1], QImode)"
660   "@
661    clm\t%0,1,%S1
662    clmy\t%0,1,%S1
663    cli\t%S0,%b1
664    cliy\t%S0,%b1
665    #"
666   [(set_attr "op_type" "RS,RSY,SI,SIY,SS")])
667
668
669 ; Block compare (CLC) instruction patterns.
670
671 (define_insn "*clc"
672   [(set (reg 33)
673         (compare (match_operand:BLK 0 "memory_operand" "=Q")
674                  (match_operand:BLK 1 "memory_operand" "Q")))
675    (use (match_operand 2 "const_int_operand" "n"))]
676   "s390_match_ccmode (insn, CCUmode)
677    && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
678   "clc\t%O0(%2,%R0),%S1"
679   [(set_attr "op_type" "SS")])
680
681 (define_split
682   [(set (reg 33)
683         (compare (match_operand 0 "memory_operand" "")
684                  (match_operand 1 "memory_operand" "")))]
685   "reload_completed
686    && s390_match_ccmode (insn, CCUmode)
687    && GET_MODE (operands[0]) == GET_MODE (operands[1])
688    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
689   [(parallel
690     [(set (match_dup 0) (match_dup 1))
691      (use (match_dup 2))])]
692 {
693   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
694   operands[0] = adjust_address (operands[0], BLKmode, 0);
695   operands[1] = adjust_address (operands[1], BLKmode, 0);
696
697   operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
698                                  operands[0], operands[1]);
699   operands[0] = SET_DEST (PATTERN (curr_insn));
700 })
701
702
703 ; DF instructions
704
705 (define_insn "*cmpdf_ccs_0"
706   [(set (reg 33)
707         (compare (match_operand:DF 0 "register_operand" "f")
708                  (match_operand:DF 1 "const0_operand" "")))]
709   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
710   "ltdbr\t%0,%0"
711    [(set_attr "op_type" "RRE")
712     (set_attr "type"  "fsimpd")])
713
714 (define_insn "*cmpdf_ccs_0_ibm"
715   [(set (reg 33)
716         (compare (match_operand:DF 0 "register_operand" "f")
717                  (match_operand:DF 1 "const0_operand" "")))]
718   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
719   "ltdr\t%0,%0"
720    [(set_attr "op_type" "RR")
721     (set_attr "type"  "fsimpd")])
722
723 (define_insn "*cmpdf_ccs"
724   [(set (reg 33)
725         (compare (match_operand:DF 0 "register_operand" "f,f")
726                  (match_operand:DF 1 "general_operand" "f,R")))]
727   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
728   "@
729    cdbr\t%0,%1
730    cdb\t%0,%1"
731    [(set_attr "op_type" "RRE,RXE")
732     (set_attr "type"  "fsimpd")])
733
734 (define_insn "*cmpdf_ccs_ibm"
735   [(set (reg 33)
736         (compare (match_operand:DF 0 "register_operand" "f,f")
737                  (match_operand:DF 1 "general_operand" "f,R")))]
738   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
739   "@
740    cdr\t%0,%1
741    cd\t%0,%1"
742    [(set_attr "op_type" "RR,RX")
743     (set_attr "type"  "fsimpd")])
744
745
746 ; SF instructions
747
748 (define_insn "*cmpsf_ccs_0"
749   [(set (reg 33)
750         (compare (match_operand:SF 0 "register_operand" "f")
751                  (match_operand:SF 1 "const0_operand" "")))]
752   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
753   "ltebr\t%0,%0"
754    [(set_attr "op_type" "RRE")
755     (set_attr "type"  "fsimps")])
756
757 (define_insn "*cmpsf_ccs_0_ibm"
758   [(set (reg 33)
759         (compare (match_operand:SF 0 "register_operand" "f")
760                  (match_operand:SF 1 "const0_operand" "")))]
761   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
762   "lter\t%0,%0"
763    [(set_attr "op_type" "RR")
764     (set_attr "type"  "fsimps")])
765
766 (define_insn "*cmpsf_ccs"
767   [(set (reg 33)
768         (compare (match_operand:SF 0 "register_operand" "f,f")
769                  (match_operand:SF 1 "general_operand" "f,R")))]
770   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
771   "@
772    cebr\t%0,%1
773    ceb\t%0,%1"
774    [(set_attr "op_type" "RRE,RXE")
775     (set_attr "type"  "fsimps")])
776
777 (define_insn "*cmpsf_ccs"
778   [(set (reg 33)
779         (compare (match_operand:SF 0 "register_operand" "f,f")
780                  (match_operand:SF 1 "general_operand" "f,R")))]
781   "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
782   "@
783    cer\t%0,%1
784    ce\t%0,%1"
785    [(set_attr "op_type" "RR,RX")
786     (set_attr "type"  "fsimps")])
787
788
789 ;;
790 ;;- Move instructions.
791 ;;
792
793 ;
794 ; movti instruction pattern(s).
795 ;
796
797 (define_insn "movti"
798   [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o,Q")
799         (match_operand:TI 1 "general_operand" "QS,d,dKm,d,Q"))]
800   "TARGET_64BIT"
801   "@
802    lmg\t%0,%N0,%S1
803    stmg\t%1,%N1,%S0
804    #
805    #
806    #"
807   [(set_attr "op_type" "RSY,RSY,*,*,SS")
808    (set_attr "type" "lm,stm,*,*,*")])
809
810 (define_split
811   [(set (match_operand:TI 0 "nonimmediate_operand" "")
812         (match_operand:TI 1 "general_operand" ""))]
813   "TARGET_64BIT && reload_completed
814    && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
815   [(set (match_dup 2) (match_dup 4))
816    (set (match_dup 3) (match_dup 5))]
817 {
818   operands[2] = operand_subword (operands[0], 0, 0, TImode);
819   operands[3] = operand_subword (operands[0], 1, 0, TImode);
820   operands[4] = operand_subword (operands[1], 0, 0, TImode);
821   operands[5] = operand_subword (operands[1], 1, 0, TImode);
822 })
823
824 (define_split
825   [(set (match_operand:TI 0 "nonimmediate_operand" "")
826         (match_operand:TI 1 "general_operand" ""))]
827   "TARGET_64BIT && reload_completed
828    && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
829   [(set (match_dup 2) (match_dup 4))
830    (set (match_dup 3) (match_dup 5))]
831 {
832   operands[2] = operand_subword (operands[0], 1, 0, TImode);
833   operands[3] = operand_subword (operands[0], 0, 0, TImode);
834   operands[4] = operand_subword (operands[1], 1, 0, TImode);
835   operands[5] = operand_subword (operands[1], 0, 0, TImode);
836 })
837
838 (define_split
839   [(set (match_operand:TI 0 "register_operand" "")
840         (match_operand:TI 1 "memory_operand" ""))]
841   "TARGET_64BIT && reload_completed
842    && !s_operand (operands[1], VOIDmode)"
843   [(set (match_dup 0) (match_dup 1))]
844 {
845   rtx addr = operand_subword (operands[0], 1, 0, TImode);
846   s390_load_address (addr, XEXP (operands[1], 0));
847   operands[1] = replace_equiv_address (operands[1], addr);
848 })
849
850 (define_expand "reload_outti"
851   [(parallel [(match_operand:TI 0 "memory_operand" "")
852               (match_operand:TI 1 "register_operand" "d")
853               (match_operand:DI 2 "register_operand" "=&a")])]
854   "TARGET_64BIT"
855 {
856   s390_load_address (operands[2], XEXP (operands[0], 0));
857   operands[0] = replace_equiv_address (operands[0], operands[2]);
858   emit_move_insn (operands[0], operands[1]);
859   DONE;
860 })
861
862 ;
863 ; movdi instruction pattern(s).
864 ;
865
866 (define_expand "movdi"
867   [(set (match_operand:DI 0 "general_operand" "")
868         (match_operand:DI 1 "general_operand" ""))]
869   ""
870 {
871   /* Handle symbolic constants.  */
872   if (TARGET_64BIT && SYMBOLIC_CONST (operands[1]))
873     emit_symbolic_move (operands);
874 })
875
876 (define_insn "*movdi_larl"
877   [(set (match_operand:DI 0 "register_operand" "=d")
878         (match_operand:DI 1 "larl_operand" "X"))]
879   "TARGET_64BIT
880    && !FP_REG_P (operands[0])"
881   "larl\t%0,%1"
882    [(set_attr "op_type" "RIL")
883     (set_attr "type"    "larl")])
884
885 (define_insn "*movdi_64"
886   [(set (match_operand:DI 0 "nonimmediate_operand"
887                             "=d,d,d,d,d,d,d,d,m,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
888         (match_operand:DI 1 "general_operand"
889                             "K,N0HD0,N1HD0,N2HD0,N3HD0,L,d,m,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
890   "TARGET_64BIT"
891   "@
892    lghi\t%0,%h1
893    llihh\t%0,%i1
894    llihl\t%0,%i1
895    llilh\t%0,%i1
896    llill\t%0,%i1
897    lay\t%0,%a1
898    lgr\t%0,%1
899    lg\t%0,%1
900    stg\t%1,%0
901    ldr\t%0,%1
902    ld\t%0,%1
903    ldy\t%0,%1
904    std\t%1,%0
905    stdy\t%1,%0
906    #
907    #
908    stam\t%1,%N1,%S0
909    lam\t%0,%N0,%S1
910    #"
911   [(set_attr "op_type" "RI,RI,RI,RI,RI,RXY,RRE,RXY,RXY,
912                         RR,RX,RXY,RX,RXY,*,*,RS,RS,SS")
913    (set_attr "type" "*,*,*,*,*,la,lr,load,store,
914                      floadd,floadd,floadd,fstored,fstored,*,*,*,*,*")])
915
916 (define_split
917   [(set (match_operand:DI 0 "register_operand" "")
918         (match_operand:DI 1 "register_operand" ""))]
919   "TARGET_64BIT && ACCESS_REG_P (operands[1])"
920   [(set (match_dup 2) (match_dup 3))
921    (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
922    (set (strict_low_part (match_dup 2)) (match_dup 4))]
923   "operands[2] = gen_lowpart (SImode, operands[0]);
924    s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
925
926 (define_split
927   [(set (match_operand:DI 0 "register_operand" "")
928         (match_operand:DI 1 "register_operand" ""))]
929   "TARGET_64BIT && ACCESS_REG_P (operands[0])
930    && dead_or_set_p (insn, operands[1])"
931   [(set (match_dup 3) (match_dup 2))
932    (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
933    (set (match_dup 4) (match_dup 2))]
934   "operands[2] = gen_lowpart (SImode, operands[1]);
935    s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
936
937 (define_split
938   [(set (match_operand:DI 0 "register_operand" "")
939         (match_operand:DI 1 "register_operand" ""))]
940   "TARGET_64BIT && ACCESS_REG_P (operands[0])
941    && !dead_or_set_p (insn, operands[1])"
942   [(set (match_dup 3) (match_dup 2))
943    (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
944    (set (match_dup 4) (match_dup 2))
945    (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
946   "operands[2] = gen_lowpart (SImode, operands[1]);
947    s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
948
949 (define_insn "*movdi_31"
950   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,Q,d,o,!*f,!*f,!*f,!R,!T,Q")
951         (match_operand:DI 1 "general_operand" "Q,d,dKm,d,*f,R,T,*f,*f,Q"))]
952   "!TARGET_64BIT"
953   "@
954    lm\t%0,%N0,%S1
955    stm\t%1,%N1,%S0
956    #
957    #
958    ldr\t%0,%1
959    ld\t%0,%1
960    ldy\t%0,%1
961    std\t%1,%0
962    stdy\t%1,%0
963    #"
964   [(set_attr "op_type" "RS,RS,*,*,RR,RX,RXY,RX,RXY,SS")
965    (set_attr "type" "lm,stm,*,*,floadd,floadd,floadd,fstored,fstored,*")])
966
967 (define_split
968   [(set (match_operand:DI 0 "nonimmediate_operand" "")
969         (match_operand:DI 1 "general_operand" ""))]
970   "!TARGET_64BIT && reload_completed
971    && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
972   [(set (match_dup 2) (match_dup 4))
973    (set (match_dup 3) (match_dup 5))]
974 {
975   operands[2] = operand_subword (operands[0], 0, 0, DImode);
976   operands[3] = operand_subword (operands[0], 1, 0, DImode);
977   operands[4] = operand_subword (operands[1], 0, 0, DImode);
978   operands[5] = operand_subword (operands[1], 1, 0, DImode);
979 })
980
981 (define_split
982   [(set (match_operand:DI 0 "nonimmediate_operand" "")
983         (match_operand:DI 1 "general_operand" ""))]
984   "!TARGET_64BIT && reload_completed
985    && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
986   [(set (match_dup 2) (match_dup 4))
987    (set (match_dup 3) (match_dup 5))]
988 {
989   operands[2] = operand_subword (operands[0], 1, 0, DImode);
990   operands[3] = operand_subword (operands[0], 0, 0, DImode);
991   operands[4] = operand_subword (operands[1], 1, 0, DImode);
992   operands[5] = operand_subword (operands[1], 0, 0, DImode);
993 })
994
995 (define_split
996   [(set (match_operand:DI 0 "register_operand" "")
997         (match_operand:DI 1 "memory_operand" ""))]
998   "!TARGET_64BIT && reload_completed
999    && !FP_REG_P (operands[0])
1000    && !s_operand (operands[1], VOIDmode)"
1001   [(set (match_dup 0) (match_dup 1))]
1002 {
1003   rtx addr = operand_subword (operands[0], 1, 0, DImode);
1004   s390_load_address (addr, XEXP (operands[1], 0));
1005   operands[1] = replace_equiv_address (operands[1], addr);
1006 })
1007
1008 (define_expand "reload_outdi"
1009   [(parallel [(match_operand:DI 0 "memory_operand" "")
1010               (match_operand:DI 1 "register_operand" "d")
1011               (match_operand:SI 2 "register_operand" "=&a")])]
1012   "!TARGET_64BIT"
1013 {
1014   s390_load_address (operands[2], XEXP (operands[0], 0));
1015   operands[0] = replace_equiv_address (operands[0], operands[2]);
1016   emit_move_insn (operands[0], operands[1]);
1017   DONE;
1018 })
1019
1020 (define_peephole2
1021   [(set (match_operand:DI 0 "register_operand" "")
1022         (mem:DI (match_operand 1 "address_operand" "")))]
1023   "TARGET_64BIT
1024    && !FP_REG_P (operands[0])
1025    && GET_CODE (operands[1]) == SYMBOL_REF
1026    && CONSTANT_POOL_ADDRESS_P (operands[1])
1027    && get_pool_mode (operands[1]) == DImode
1028    && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1029   [(set (match_dup 0) (match_dup 2))]
1030   "operands[2] = get_pool_constant (operands[1]);")
1031
1032 (define_insn "*la_64"
1033   [(set (match_operand:DI 0 "register_operand" "=d,d")
1034         (match_operand:QI 1 "address_operand" "U,W"))]
1035   "TARGET_64BIT"
1036   "@
1037    la\t%0,%a1
1038    lay\t%0,%a1"
1039   [(set_attr "op_type" "RX,RXY")
1040    (set_attr "type"    "la")])
1041
1042 (define_peephole2
1043   [(parallel
1044     [(set (match_operand:DI 0 "register_operand" "")
1045           (match_operand:QI 1 "address_operand" ""))
1046      (clobber (reg:CC 33))])]
1047   "TARGET_64BIT
1048    && preferred_la_operand_p (operands[1], const0_rtx)"
1049   [(set (match_dup 0) (match_dup 1))]
1050   "")
1051
1052 (define_peephole2
1053   [(set (match_operand:DI 0 "register_operand" "")
1054         (match_operand:DI 1 "register_operand" ""))
1055    (parallel
1056     [(set (match_dup 0)
1057           (plus:DI (match_dup 0)
1058                    (match_operand:DI 2 "nonmemory_operand" "")))
1059      (clobber (reg:CC 33))])]
1060   "TARGET_64BIT
1061    && !reg_overlap_mentioned_p (operands[0], operands[2])
1062    && preferred_la_operand_p (operands[1], operands[2])"
1063   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1064   "")
1065
1066 (define_expand "reload_indi"
1067   [(parallel [(match_operand:DI 0 "register_operand" "=a")
1068               (match_operand:DI 1 "s390_plus_operand" "")
1069               (match_operand:DI 2 "register_operand" "=&a")])]
1070   "TARGET_64BIT"
1071 {
1072   s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1073   DONE;
1074 })
1075
1076 ;
1077 ; movsi instruction pattern(s).
1078 ;
1079
1080 (define_expand "movsi"
1081   [(set (match_operand:SI 0 "general_operand" "")
1082         (match_operand:SI 1 "general_operand" ""))]
1083   ""
1084 {
1085   /* Handle symbolic constants.  */
1086   if (!TARGET_64BIT && SYMBOLIC_CONST (operands[1]))
1087     emit_symbolic_move (operands);
1088 })
1089
1090 (define_insn "*movsi_larl"
1091   [(set (match_operand:SI 0 "register_operand" "=d")
1092         (match_operand:SI 1 "larl_operand" "X"))]
1093   "!TARGET_64BIT && TARGET_CPU_ZARCH
1094    && !FP_REG_P (operands[0])"
1095   "larl\t%0,%1"
1096    [(set_attr "op_type" "RIL")
1097     (set_attr "type"    "larl")])
1098
1099 (define_insn "*movsi_zarch"
1100   [(set (match_operand:SI 0 "nonimmediate_operand"
1101                             "=d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,t,?Q")
1102         (match_operand:SI 1 "general_operand"
1103                             "K,N0HS0,N1HS0,L,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,Q,?Q"))]
1104   "TARGET_ZARCH"
1105   "@
1106    lhi\t%0,%h1
1107    llilh\t%0,%i1
1108    llill\t%0,%i1
1109    lay\t%0,%a1
1110    lr\t%0,%1
1111    l\t%0,%1
1112    ly\t%0,%1
1113    st\t%1,%0
1114    sty\t%1,%0
1115    ler\t%0,%1
1116    le\t%0,%1
1117    ley\t%0,%1
1118    ste\t%1,%0
1119    stey\t%1,%0
1120    ear\t%0,%1
1121    sar\t%0,%1
1122    stam\t%1,%1,%S0
1123    lam\t%0,%0,%S1
1124    #"
1125   [(set_attr "op_type" "RI,RI,RI,RXY,RR,RX,RXY,RX,RXY,
1126                         RR,RX,RXY,RX,RXY,RRE,RRE,RS,RS,SS")
1127    (set_attr "type" "*,*,*,la,lr,load,load,store,store,
1128                      floads,floads,floads,fstores,fstores,*,*,*,*,*")])
1129
1130 (define_insn "*movsi_esa"
1131   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t,?Q")
1132         (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q,?Q"))]
1133   "!TARGET_ZARCH"
1134   "@
1135    lhi\t%0,%h1
1136    lr\t%0,%1
1137    l\t%0,%1
1138    st\t%1,%0
1139    ler\t%0,%1
1140    le\t%0,%1
1141    ste\t%1,%0
1142    ear\t%0,%1
1143    sar\t%0,%1
1144    stam\t%1,%1,%S0
1145    lam\t%0,%0,%S1
1146    #"
1147   [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS,SS")
1148    (set_attr "type" "*,lr,load,store,floads,floads,fstores,*,*,*,*,*")])
1149
1150 (define_peephole2
1151   [(set (match_operand:SI 0 "register_operand" "")
1152         (mem:SI (match_operand 1 "address_operand" "")))]
1153   "!FP_REG_P (operands[0])
1154    && GET_CODE (operands[1]) == SYMBOL_REF
1155    && CONSTANT_POOL_ADDRESS_P (operands[1])
1156    && get_pool_mode (operands[1]) == SImode
1157    && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1158   [(set (match_dup 0) (match_dup 2))]
1159   "operands[2] = get_pool_constant (operands[1]);")
1160
1161 (define_insn "*la_31"
1162   [(set (match_operand:SI 0 "register_operand" "=d,d")
1163         (match_operand:QI 1 "address_operand" "U,W"))]
1164   "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1165   "@
1166    la\t%0,%a1
1167    lay\t%0,%a1"
1168   [(set_attr "op_type"  "RX,RXY")
1169    (set_attr "type"     "la")])
1170
1171 (define_peephole2
1172   [(parallel
1173     [(set (match_operand:SI 0 "register_operand" "")
1174           (match_operand:QI 1 "address_operand" ""))
1175      (clobber (reg:CC 33))])]
1176   "!TARGET_64BIT
1177    && preferred_la_operand_p (operands[1], const0_rtx)"
1178   [(set (match_dup 0) (match_dup 1))]
1179   "")
1180
1181 (define_peephole2
1182   [(set (match_operand:SI 0 "register_operand" "")
1183         (match_operand:SI 1 "register_operand" ""))
1184    (parallel
1185     [(set (match_dup 0)
1186           (plus:SI (match_dup 0)
1187                    (match_operand:SI 2 "nonmemory_operand" "")))
1188      (clobber (reg:CC 33))])]
1189   "!TARGET_64BIT
1190    && !reg_overlap_mentioned_p (operands[0], operands[2])
1191    && preferred_la_operand_p (operands[1], operands[2])"
1192   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1193   "")
1194
1195 (define_insn "*la_31_and"
1196   [(set (match_operand:SI 0 "register_operand" "=d,d")
1197         (and:SI (match_operand:QI 1 "address_operand" "U,W")
1198                 (const_int 2147483647)))]
1199   "!TARGET_64BIT"
1200   "@
1201    la\t%0,%a1
1202    lay\t%0,%a1"
1203   [(set_attr "op_type"  "RX,RXY")
1204    (set_attr "type"     "la")])
1205
1206 (define_insn_and_split "*la_31_and_cc"
1207   [(set (match_operand:SI 0 "register_operand" "=d")
1208         (and:SI (match_operand:QI 1 "address_operand" "p")
1209                 (const_int 2147483647)))
1210    (clobber (reg:CC 33))]
1211   "!TARGET_64BIT"
1212   "#"
1213   "&& reload_completed"
1214   [(set (match_dup 0)
1215         (and:SI (match_dup 1) (const_int 2147483647)))]
1216   ""
1217   [(set_attr "op_type"  "RX")
1218    (set_attr "type"     "la")])
1219
1220 (define_insn "force_la_31"
1221   [(set (match_operand:SI 0 "register_operand" "=d,d")
1222         (match_operand:QI 1 "address_operand" "U,W"))
1223    (use (const_int 0))]
1224   "!TARGET_64BIT"
1225   "@
1226    la\t%0,%a1
1227    lay\t%0,%a1"
1228   [(set_attr "op_type"  "RX")
1229    (set_attr "type"     "la")])
1230
1231 (define_expand "reload_insi"
1232   [(parallel [(match_operand:SI 0 "register_operand" "=a")
1233               (match_operand:SI 1 "s390_plus_operand" "")
1234               (match_operand:SI 2 "register_operand" "=&a")])]
1235   "!TARGET_64BIT"
1236 {
1237   s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1238   DONE;
1239 })
1240
1241 ;
1242 ; movhi instruction pattern(s).
1243 ;
1244
1245 (define_expand "movhi"
1246   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1247         (match_operand:HI 1 "general_operand" ""))]
1248   ""
1249 {
1250   /* Make it explicit that loading a register from memory
1251      always sign-extends (at least) to SImode.  */
1252   if (optimize && !no_new_pseudos
1253       && register_operand (operands[0], VOIDmode)
1254       && GET_CODE (operands[1]) == MEM)
1255     {
1256       rtx tmp = gen_reg_rtx (SImode);
1257       rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1258       emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1259       operands[1] = gen_lowpart (HImode, tmp);
1260     }
1261 })
1262
1263 (define_insn "*movhi"
1264   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,R,T,?Q")
1265         (match_operand:HI 1 "general_operand" "d,n,R,T,d,d,?Q"))]
1266   ""
1267   "@
1268    lr\t%0,%1
1269    lhi\t%0,%h1
1270    lh\t%0,%1
1271    lhy\t%0,%1
1272    sth\t%1,%0
1273    sthy\t%1,%0
1274    #"
1275   [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SS")
1276    (set_attr "type" "lr,*,*,*,store,store,*")])
1277
1278 (define_peephole2
1279   [(set (match_operand:HI 0 "register_operand" "")
1280         (mem:HI (match_operand 1 "address_operand" "")))]
1281   "GET_CODE (operands[1]) == SYMBOL_REF
1282    && CONSTANT_POOL_ADDRESS_P (operands[1])
1283    && get_pool_mode (operands[1]) == HImode
1284    && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1285   [(set (match_dup 0) (match_dup 2))]
1286   "operands[2] = get_pool_constant (operands[1]);")
1287
1288 ;
1289 ; movqi instruction pattern(s).
1290 ;
1291
1292 (define_expand "movqi"
1293   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1294         (match_operand:QI 1 "general_operand" ""))]
1295   ""
1296 {
1297   /* On z/Architecture, zero-extending from memory to register
1298      is just as fast as a QImode load.  */
1299   if (TARGET_ZARCH && optimize && !no_new_pseudos
1300       && register_operand (operands[0], VOIDmode)
1301       && GET_CODE (operands[1]) == MEM)
1302     {
1303       rtx tmp = gen_reg_rtx (word_mode);
1304       rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
1305       emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1306       operands[1] = gen_lowpart (QImode, tmp);
1307     }
1308 })
1309
1310 (define_insn "*movqi"
1311   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1312         (match_operand:QI 1 "general_operand" "d,n,R,T,d,d,n,n,?Q"))]
1313   ""
1314   "@
1315    lr\t%0,%1
1316    lhi\t%0,%b1
1317    ic\t%0,%1
1318    icy\t%0,%1
1319    stc\t%1,%0
1320    stcy\t%1,%0
1321    mvi\t%S0,%b1
1322    mviy\t%S0,%b1
1323    #"
1324   [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1325    (set_attr "type" "lr,*,*,*,store,store,store,store,*")])
1326
1327 (define_peephole2
1328   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1329         (mem:QI (match_operand 1 "address_operand" "")))]
1330   "GET_CODE (operands[1]) == SYMBOL_REF
1331    && CONSTANT_POOL_ADDRESS_P (operands[1])
1332    && get_pool_mode (operands[1]) == QImode
1333    && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1334   [(set (match_dup 0) (match_dup 2))]
1335   "operands[2] = get_pool_constant (operands[1]);")
1336
1337 ;
1338 ; movstrictqi instruction pattern(s).
1339 ;
1340
1341 (define_insn "*movstrictqi"
1342   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1343                          (match_operand:QI 1 "memory_operand" "R,T"))]
1344   ""
1345   "@
1346    ic\t%0,%1
1347    icy\t%0,%1"
1348   [(set_attr "op_type"  "RX,RXY")])
1349
1350 ;
1351 ; movstricthi instruction pattern(s).
1352 ;
1353
1354 (define_insn "*movstricthi"
1355   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1356                          (match_operand:HI 1 "memory_operand" "Q,S"))
1357    (clobber (reg:CC 33))]
1358   ""
1359   "@
1360    icm\t%0,3,%S1
1361    icmy\t%0,3,%S1"
1362   [(set_attr "op_type" "RS,RSY")])
1363
1364 ;
1365 ; movstrictsi instruction pattern(s).
1366 ;
1367
1368 (define_insn "movstrictsi"
1369   [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1370                          (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1371   "TARGET_64BIT"
1372   "@
1373    lr\t%0,%1
1374    l\t%0,%1
1375    ly\t%0,%1
1376    ear\t%0,%1"
1377   [(set_attr "op_type" "RR,RX,RXY,RRE")
1378    (set_attr "type" "lr,load,load,*")])
1379
1380 ;
1381 ; movdf instruction pattern(s).
1382 ;
1383
1384 (define_expand "movdf"
1385   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1386         (match_operand:DF 1 "general_operand"  ""))]
1387   ""
1388   "")
1389
1390 (define_insn "*movdf_64"
1391   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,T,d,d,m,?Q")
1392         (match_operand:DF 1 "general_operand" "f,R,T,f,f,d,m,d,?Q"))]
1393   "TARGET_64BIT"
1394   "@
1395    ldr\t%0,%1
1396    ld\t%0,%1
1397    ldy\t%0,%1
1398    std\t%1,%0
1399    stdy\t%1,%0
1400    lgr\t%0,%1
1401    lg\t%0,%1
1402    stg\t%1,%0
1403    #"
1404   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RRE,RXY,RXY,SS")
1405    (set_attr "type" "floadd,floadd,floadd,fstored,fstored,lr,load,store,*")])
1406
1407 (define_insn "*movdf_31"
1408   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,R,T,d,Q,d,o,Q")
1409         (match_operand:DF 1 "general_operand" "f,R,T,f,f,Q,d,dKm,d,Q"))]
1410   "!TARGET_64BIT"
1411   "@
1412    ldr\t%0,%1
1413    ld\t%0,%1
1414    ldy\t%0,%1
1415    std\t%1,%0
1416    stdy\t%1,%0
1417    lm\t%0,%N0,%S1
1418    stm\t%1,%N1,%S0
1419    #
1420    #
1421    #"
1422   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RS,RS,*,*,SS")
1423    (set_attr "type" "floadd,floadd,floadd,fstored,fstored,lm,stm,*,*,*")])
1424
1425 (define_split
1426   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1427         (match_operand:DF 1 "general_operand" ""))]
1428   "!TARGET_64BIT && reload_completed
1429    && s390_split_ok_p (operands[0], operands[1], DFmode, 0)"
1430   [(set (match_dup 2) (match_dup 4))
1431    (set (match_dup 3) (match_dup 5))]
1432 {
1433   operands[2] = operand_subword (operands[0], 0, 0, DFmode);
1434   operands[3] = operand_subword (operands[0], 1, 0, DFmode);
1435   operands[4] = operand_subword (operands[1], 0, 0, DFmode);
1436   operands[5] = operand_subword (operands[1], 1, 0, DFmode);
1437 })
1438
1439 (define_split
1440   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1441         (match_operand:DF 1 "general_operand" ""))]
1442   "!TARGET_64BIT && reload_completed
1443    && s390_split_ok_p (operands[0], operands[1], DFmode, 1)"
1444   [(set (match_dup 2) (match_dup 4))
1445    (set (match_dup 3) (match_dup 5))]
1446 {
1447   operands[2] = operand_subword (operands[0], 1, 0, DFmode);
1448   operands[3] = operand_subword (operands[0], 0, 0, DFmode);
1449   operands[4] = operand_subword (operands[1], 1, 0, DFmode);
1450   operands[5] = operand_subword (operands[1], 0, 0, DFmode);
1451 })
1452
1453 (define_split
1454   [(set (match_operand:DF 0 "register_operand" "")
1455         (match_operand:DF 1 "memory_operand" ""))]
1456   "!TARGET_64BIT && reload_completed
1457    && !FP_REG_P (operands[0])
1458    && !s_operand (operands[1], VOIDmode)"
1459   [(set (match_dup 0) (match_dup 1))]
1460 {
1461   rtx addr = operand_subword (operands[0], 1, 0, DFmode);
1462   s390_load_address (addr, XEXP (operands[1], 0));
1463   operands[1] = replace_equiv_address (operands[1], addr);
1464 })
1465
1466 (define_expand "reload_outdf"
1467   [(parallel [(match_operand:DF 0 "memory_operand" "")
1468               (match_operand:DF 1 "register_operand" "d")
1469               (match_operand:SI 2 "register_operand" "=&a")])]
1470   "!TARGET_64BIT"
1471 {
1472   s390_load_address (operands[2], XEXP (operands[0], 0));
1473   operands[0] = replace_equiv_address (operands[0], operands[2]);
1474   emit_move_insn (operands[0], operands[1]);
1475   DONE;
1476 })
1477
1478 ;
1479 ; movsf instruction pattern(s).
1480 ;
1481
1482 (define_insn "movsf"
1483   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,R,T,d,d,d,R,T,?Q")
1484         (match_operand:SF 1 "general_operand" "f,R,T,f,f,d,R,T,d,d,?Q"))]
1485   ""
1486   "@
1487    ler\t%0,%1
1488    le\t%0,%1
1489    ley\t%0,%1
1490    ste\t%1,%0
1491    stey\t%1,%0
1492    lr\t%0,%1
1493    l\t%0,%1
1494    ly\t%0,%1
1495    st\t%1,%0
1496    sty\t%1,%0
1497    #"
1498   [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY,SS")
1499    (set_attr "type" "floads,floads,floads,fstores,fstores,
1500                      lr,load,load,store,store,*")])
1501
1502 ;
1503 ; movcc instruction pattern
1504 ;
1505
1506 (define_insn "movcc"
1507   [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
1508         (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
1509   ""
1510   "@
1511    lr\t%0,%1
1512    tmh\t%1,12288
1513    ipm\t%0
1514    st\t%0,%1
1515    sty\t%0,%1
1516    l\t%1,%0
1517    ly\t%1,%0"
1518   [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
1519    (set_attr "type" "lr,*,*,store,store,load,load")])
1520
1521 ;
1522 ; Block move (MVC) patterns.
1523 ;
1524
1525 (define_insn "*mvc"
1526   [(set (match_operand:BLK 0 "memory_operand" "=Q")
1527         (match_operand:BLK 1 "memory_operand" "Q"))
1528    (use (match_operand 2 "const_int_operand" "n"))]
1529   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1530   "mvc\t%O0(%2,%R0),%S1"
1531   [(set_attr "op_type" "SS")])
1532
1533 (define_split
1534   [(set (match_operand 0 "memory_operand" "")
1535         (match_operand 1 "memory_operand" ""))]
1536   "reload_completed
1537    && GET_MODE (operands[0]) == GET_MODE (operands[1])
1538    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1539   [(parallel
1540     [(set (match_dup 0) (match_dup 1))
1541      (use (match_dup 2))])]
1542 {
1543   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1544   operands[0] = adjust_address (operands[0], BLKmode, 0);
1545   operands[1] = adjust_address (operands[1], BLKmode, 0);
1546 })
1547
1548 (define_peephole2
1549   [(parallel
1550     [(set (match_operand:BLK 0 "memory_operand" "")
1551           (match_operand:BLK 1 "memory_operand" ""))
1552      (use (match_operand 2 "const_int_operand" ""))])
1553    (parallel
1554     [(set (match_operand:BLK 3 "memory_operand" "")
1555           (match_operand:BLK 4 "memory_operand" ""))
1556      (use (match_operand 5 "const_int_operand" ""))])]
1557   "s390_offset_p (operands[0], operands[3], operands[2])
1558    && s390_offset_p (operands[1], operands[4], operands[2])
1559    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
1560   [(parallel
1561     [(set (match_dup 6) (match_dup 7))
1562      (use (match_dup 8))])]
1563   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
1564    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
1565    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
1566
1567
1568 ;
1569 ; load_multiple pattern(s).
1570 ;
1571 ; ??? Due to reload problems with replacing registers inside match_parallel
1572 ; we currently support load_multiple/store_multiple only after reload.
1573 ;
1574
1575 (define_expand "load_multiple"
1576   [(match_par_dup 3 [(set (match_operand 0 "" "")
1577                           (match_operand 1 "" ""))
1578                      (use (match_operand 2 "" ""))])]
1579   "reload_completed"
1580 {
1581   enum machine_mode mode;
1582   int regno;
1583   int count;
1584   rtx from;
1585   int i, off;
1586
1587   /* Support only loading a constant number of fixed-point registers from
1588      memory and only bother with this if more than two */
1589   if (GET_CODE (operands[2]) != CONST_INT
1590       || INTVAL (operands[2]) < 2
1591       || INTVAL (operands[2]) > 16
1592       || GET_CODE (operands[1]) != MEM
1593       || GET_CODE (operands[0]) != REG
1594       || REGNO (operands[0]) >= 16)
1595     FAIL;
1596
1597   count = INTVAL (operands[2]);
1598   regno = REGNO (operands[0]);
1599   mode = GET_MODE (operands[0]);
1600   if (mode != SImode && mode != word_mode)
1601     FAIL;
1602
1603   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1604   if (no_new_pseudos)
1605     {
1606       if (GET_CODE (XEXP (operands[1], 0)) == REG)
1607         {
1608           from = XEXP (operands[1], 0);
1609           off = 0;
1610         }
1611       else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
1612                && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
1613                && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
1614         {
1615           from = XEXP (XEXP (operands[1], 0), 0);
1616           off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
1617         }
1618       else
1619         FAIL;
1620     }
1621   else
1622     {
1623       from = force_reg (Pmode, XEXP (operands[1], 0));
1624       off = 0;
1625     }
1626
1627   for (i = 0; i < count; i++)
1628     XVECEXP (operands[3], 0, i)
1629       = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
1630                      change_address (operands[1], mode,
1631                        plus_constant (from, off + i * GET_MODE_SIZE (mode))));
1632 })
1633
1634 (define_insn "*load_multiple_di"
1635   [(match_parallel 0 "load_multiple_operation"
1636                    [(set (match_operand:DI 1 "register_operand" "=r")
1637                          (match_operand:DI 2 "s_operand" "QS"))])]
1638   "reload_completed && word_mode == DImode"
1639 {
1640   int words = XVECLEN (operands[0], 0);
1641   operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
1642   return "lmg\t%1,%0,%S2";
1643 }
1644    [(set_attr "op_type" "RSY")
1645     (set_attr "type"    "lm")])
1646
1647 (define_insn "*load_multiple_si"
1648   [(match_parallel 0 "load_multiple_operation"
1649                    [(set (match_operand:SI 1 "register_operand" "=r,r")
1650                          (match_operand:SI 2 "s_operand" "Q,S"))])]
1651   "reload_completed"
1652 {
1653   int words = XVECLEN (operands[0], 0);
1654   operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
1655   return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
1656 }
1657    [(set_attr "op_type" "RS,RSY")
1658     (set_attr "type"    "lm")])
1659
1660 ;
1661 ; store multiple pattern(s).
1662 ;
1663
1664 (define_expand "store_multiple"
1665   [(match_par_dup 3 [(set (match_operand 0 "" "")
1666                           (match_operand 1 "" ""))
1667                      (use (match_operand 2 "" ""))])]
1668   "reload_completed"
1669 {
1670   enum machine_mode mode;
1671   int regno;
1672   int count;
1673   rtx to;
1674   int i, off;
1675
1676   /* Support only storing a constant number of fixed-point registers to
1677      memory and only bother with this if more than two.  */
1678   if (GET_CODE (operands[2]) != CONST_INT
1679       || INTVAL (operands[2]) < 2
1680       || INTVAL (operands[2]) > 16
1681       || GET_CODE (operands[0]) != MEM
1682       || GET_CODE (operands[1]) != REG
1683       || REGNO (operands[1]) >= 16)
1684     FAIL;
1685
1686   count = INTVAL (operands[2]);
1687   regno = REGNO (operands[1]);
1688   mode = GET_MODE (operands[1]);
1689   if (mode != SImode && mode != word_mode)
1690     FAIL;
1691
1692   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1693
1694   if (no_new_pseudos)
1695     {
1696       if (GET_CODE (XEXP (operands[0], 0)) == REG)
1697         {
1698           to = XEXP (operands[0], 0);
1699           off = 0;
1700         }
1701       else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
1702                && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
1703                && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
1704         {
1705           to = XEXP (XEXP (operands[0], 0), 0);
1706           off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
1707         }
1708       else
1709         FAIL;
1710     }
1711   else
1712     {
1713       to = force_reg (Pmode, XEXP (operands[0], 0));
1714       off = 0;
1715     }
1716
1717   for (i = 0; i < count; i++)
1718     XVECEXP (operands[3], 0, i)
1719       = gen_rtx_SET (VOIDmode,
1720                      change_address (operands[0], mode,
1721                        plus_constant (to, off + i * GET_MODE_SIZE (mode))),
1722                      gen_rtx_REG (mode, regno + i));
1723 })
1724
1725 (define_insn "*store_multiple_di"
1726   [(match_parallel 0 "store_multiple_operation"
1727                    [(set (match_operand:DI 1 "s_operand" "=QS")
1728                          (match_operand:DI 2 "register_operand" "r"))])]
1729   "reload_completed && word_mode == DImode"
1730 {
1731   int words = XVECLEN (operands[0], 0);
1732   operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
1733   return "stmg\t%2,%0,%S1";
1734 }
1735    [(set_attr "op_type" "RSY")
1736     (set_attr "type"    "stm")])
1737
1738
1739 (define_insn "*store_multiple_si"
1740   [(match_parallel 0 "store_multiple_operation"
1741                    [(set (match_operand:SI 1 "s_operand" "=Q,S")
1742                          (match_operand:SI 2 "register_operand" "r,r"))])]
1743   "reload_completed"
1744 {
1745   int words = XVECLEN (operands[0], 0);
1746   operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
1747   return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
1748 }
1749    [(set_attr "op_type" "RS,RSY")
1750     (set_attr "type"    "stm")])
1751
1752 ;;
1753 ;; String instructions.
1754 ;;
1755
1756 (define_insn "*execute"
1757   [(match_parallel 0 ""
1758     [(unspec [(match_operand 1 "register_operand" "a")
1759               (match_operand:BLK 2 "memory_operand" "R")
1760               (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
1761   "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
1762    && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
1763   "ex\t%1,%2"
1764   [(set_attr "op_type" "RX")
1765    (set_attr "type" "cs")])
1766
1767
1768 ;
1769 ; strlenM instruction pattern(s).
1770 ;
1771
1772 (define_expand "strlendi"
1773   [(set (reg:QI 0) (match_operand:QI 2 "immediate_operand" ""))
1774    (parallel
1775     [(set (match_dup 4)
1776           (unspec:DI [(const_int 0)
1777                       (match_operand:BLK 1 "memory_operand" "")
1778                       (reg:QI 0)
1779                       (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
1780      (clobber (scratch:DI))
1781      (clobber (reg:CC 33))])
1782    (parallel
1783     [(set (match_operand:DI 0 "register_operand" "")
1784           (minus:DI (match_dup 4) (match_dup 5)))
1785      (clobber (reg:CC 33))])]
1786   "TARGET_64BIT"
1787 {
1788   operands[4] = gen_reg_rtx (DImode);
1789   operands[5] = gen_reg_rtx (DImode);
1790   emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
1791   operands[1] = replace_equiv_address (operands[1], operands[5]);
1792 })
1793
1794 (define_insn "*strlendi"
1795   [(set (match_operand:DI 0 "register_operand" "=a")
1796         (unspec:DI [(match_operand:DI 2 "general_operand" "0")
1797                     (mem:BLK (match_operand:DI 3 "register_operand" "1"))
1798                     (reg:QI 0)
1799                     (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
1800    (clobber (match_scratch:DI 1 "=a"))
1801    (clobber (reg:CC 33))]
1802   "TARGET_64BIT"
1803   "srst\t%0,%1\;jo\t.-4"
1804   [(set_attr "length" "8")
1805    (set_attr "type" "vs")])
1806
1807 (define_expand "strlensi"
1808   [(set (reg:QI 0) (match_operand:QI 2 "immediate_operand" ""))
1809    (parallel
1810     [(set (match_dup 4)
1811           (unspec:SI [(const_int 0)
1812                       (match_operand:BLK 1 "memory_operand" "")
1813                       (reg:QI 0)
1814                       (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
1815      (clobber (scratch:SI))
1816      (clobber (reg:CC 33))])
1817    (parallel
1818     [(set (match_operand:SI 0 "register_operand" "")
1819           (minus:SI (match_dup 4) (match_dup 5)))
1820      (clobber (reg:CC 33))])]
1821   "!TARGET_64BIT"
1822 {
1823   operands[4] = gen_reg_rtx (SImode);
1824   operands[5] = gen_reg_rtx (SImode);
1825   emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
1826   operands[1] = replace_equiv_address (operands[1], operands[5]);
1827 })
1828
1829 (define_insn "*strlensi"
1830   [(set (match_operand:SI 0 "register_operand" "=a")
1831         (unspec:SI [(match_operand:SI 2 "general_operand" "0")
1832                     (mem:BLK (match_operand:SI 3 "register_operand" "1"))
1833                     (reg:QI 0)
1834                     (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
1835    (clobber (match_scratch:SI 1 "=a"))
1836    (clobber (reg:CC 33))]
1837   "!TARGET_64BIT"
1838   "srst\t%0,%1\;jo\t.-4"
1839   [(set_attr "length" "8")
1840    (set_attr "type" "vs")])
1841
1842 ;
1843 ; movmemM instruction pattern(s).
1844 ;
1845
1846 (define_expand "movmemdi"
1847   [(set (match_operand:BLK 0 "memory_operand" "")
1848         (match_operand:BLK 1 "memory_operand" ""))
1849    (use (match_operand:DI 2 "general_operand" ""))
1850    (match_operand 3 "" "")]
1851   "TARGET_64BIT"
1852   "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
1853
1854 (define_expand "movmemsi"
1855   [(set (match_operand:BLK 0 "memory_operand" "")
1856         (match_operand:BLK 1 "memory_operand" ""))
1857    (use (match_operand:SI 2 "general_operand" ""))
1858    (match_operand 3 "" "")]
1859   ""
1860   "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
1861
1862 ; Move a block that is up to 256 bytes in length.
1863 ; The block length is taken as (operands[2] % 256) + 1.
1864
1865 (define_expand "movmem_short"
1866   [(parallel
1867     [(set (match_operand:BLK 0 "memory_operand" "")
1868           (match_operand:BLK 1 "memory_operand" ""))
1869      (use (match_operand 2 "nonmemory_operand" ""))
1870      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1871      (clobber (match_dup 3))])]
1872   ""
1873   "operands[3] = gen_rtx_SCRATCH (Pmode);")
1874
1875 (define_insn "*movmem_short"
1876   [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
1877         (match_operand:BLK 1 "memory_operand" "Q,Q,Q"))
1878    (use (match_operand 2 "nonmemory_operand" "n,a,a"))
1879    (use (match_operand 3 "immediate_operand" "X,R,X"))
1880    (clobber (match_scratch 4 "=X,X,&a"))]
1881   "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
1882    && GET_MODE (operands[4]) == Pmode"
1883   "#"
1884   [(set_attr "type" "cs")])
1885
1886 (define_split
1887   [(set (match_operand:BLK 0 "memory_operand" "")
1888         (match_operand:BLK 1 "memory_operand" ""))
1889    (use (match_operand 2 "const_int_operand" ""))
1890    (use (match_operand 3 "immediate_operand" ""))
1891    (clobber (scratch))]
1892   "reload_completed"
1893   [(parallel
1894     [(set (match_dup 0) (match_dup 1))
1895      (use (match_dup 2))])]
1896   "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
1897
1898 (define_split
1899   [(set (match_operand:BLK 0 "memory_operand" "")
1900         (match_operand:BLK 1 "memory_operand" ""))
1901    (use (match_operand 2 "register_operand" ""))
1902    (use (match_operand 3 "memory_operand" ""))
1903    (clobber (scratch))]
1904   "reload_completed"
1905   [(parallel
1906     [(unspec [(match_dup 2) (match_dup 3)
1907               (const_int 0)] UNSPEC_EXECUTE)
1908      (set (match_dup 0) (match_dup 1))
1909      (use (const_int 1))])]
1910   "")
1911
1912 (define_split
1913   [(set (match_operand:BLK 0 "memory_operand" "")
1914         (match_operand:BLK 1 "memory_operand" ""))
1915    (use (match_operand 2 "register_operand" ""))
1916    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
1917    (clobber (match_operand 3 "register_operand" ""))]
1918   "reload_completed && TARGET_CPU_ZARCH"
1919   [(set (match_dup 3) (label_ref (match_dup 4)))
1920    (parallel
1921     [(unspec [(match_dup 2) (mem:BLK (match_dup 3)) 
1922               (label_ref (match_dup 4))] UNSPEC_EXECUTE)
1923      (set (match_dup 0) (match_dup 1))
1924      (use (const_int 1))])]
1925   "operands[4] = gen_label_rtx ();")
1926
1927 ; Move a block of arbitrary length.
1928
1929 (define_expand "movmem_long"
1930   [(parallel
1931     [(clobber (match_dup 2))
1932      (clobber (match_dup 3))
1933      (set (match_operand:BLK 0 "memory_operand" "")
1934           (match_operand:BLK 1 "memory_operand" ""))
1935      (use (match_operand 2 "general_operand" ""))
1936      (use (match_dup 3))
1937      (clobber (reg:CC 33))])]
1938   ""
1939 {
1940   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
1941   rtx reg0 = gen_reg_rtx (dword_mode);
1942   rtx reg1 = gen_reg_rtx (dword_mode);
1943   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
1944   rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
1945   rtx len0 = gen_lowpart (Pmode, reg0);
1946   rtx len1 = gen_lowpart (Pmode, reg1);
1947
1948   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
1949   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
1950   emit_move_insn (len0, operands[2]);
1951
1952   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
1953   emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
1954   emit_move_insn (len1, operands[2]);
1955
1956   operands[0] = replace_equiv_address_nv (operands[0], addr0);
1957   operands[1] = replace_equiv_address_nv (operands[1], addr1);
1958   operands[2] = reg0;
1959   operands[3] = reg1;
1960 })
1961
1962 (define_insn "*movmem_long_64"
1963   [(clobber (match_operand:TI 0 "register_operand" "=d"))
1964    (clobber (match_operand:TI 1 "register_operand" "=d"))
1965    (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
1966         (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0)))
1967    (use (match_dup 2))
1968    (use (match_dup 3))
1969    (clobber (reg:CC 33))]
1970   "TARGET_64BIT"
1971   "mvcle\t%0,%1,0\;jo\t.-4"
1972   [(set_attr "length" "8")
1973    (set_attr "type" "vs")])
1974
1975 (define_insn "*movmem_long_31"
1976   [(clobber (match_operand:DI 0 "register_operand" "=d"))
1977    (clobber (match_operand:DI 1 "register_operand" "=d"))
1978    (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
1979         (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0)))
1980    (use (match_dup 2))
1981    (use (match_dup 3))
1982    (clobber (reg:CC 33))]
1983   "!TARGET_64BIT"
1984   "mvcle\t%0,%1,0\;jo\t.-4"
1985   [(set_attr "length" "8")
1986    (set_attr "type" "vs")])
1987
1988 ;
1989 ; clrmemM instruction pattern(s).
1990 ;
1991
1992 (define_expand "clrmemdi"
1993   [(set (match_operand:BLK 0 "memory_operand" "")
1994         (const_int 0))
1995    (use (match_operand:DI 1 "general_operand" ""))
1996    (match_operand 2 "" "")]
1997   "TARGET_64BIT"
1998   "s390_expand_clrmem (operands[0], operands[1]); DONE;")
1999
2000 (define_expand "clrmemsi"
2001   [(set (match_operand:BLK 0 "memory_operand" "")
2002         (const_int 0))
2003    (use (match_operand:SI 1 "general_operand" ""))
2004    (match_operand 2 "" "")]
2005   ""
2006   "s390_expand_clrmem (operands[0], operands[1]); DONE;")
2007
2008 ; Clear a block that is up to 256 bytes in length.
2009 ; The block length is taken as (operands[1] % 256) + 1.
2010
2011 (define_expand "clrmem_short"
2012   [(parallel
2013     [(set (match_operand:BLK 0 "memory_operand" "")
2014           (const_int 0))
2015      (use (match_operand 1 "nonmemory_operand" ""))
2016      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2017      (clobber (match_dup 2))
2018      (clobber (reg:CC 33))])]
2019   ""
2020   "operands[2] = gen_rtx_SCRATCH (Pmode);")
2021
2022 (define_insn "*clrmem_short"
2023   [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
2024         (const_int 0))
2025    (use (match_operand 1 "nonmemory_operand" "n,a,a"))
2026    (use (match_operand 2 "immediate_operand" "X,R,X"))
2027    (clobber (match_scratch 3 "=X,X,&a"))
2028    (clobber (reg:CC 33))]
2029   "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
2030    && GET_MODE (operands[3]) == Pmode"
2031   "#"
2032   [(set_attr "type" "cs")])
2033
2034 (define_split
2035   [(set (match_operand:BLK 0 "memory_operand" "")
2036         (const_int 0))
2037    (use (match_operand 1 "const_int_operand" ""))
2038    (use (match_operand 2 "immediate_operand" ""))
2039    (clobber (scratch))
2040    (clobber (reg:CC 33))]
2041   "reload_completed"
2042   [(parallel
2043     [(set (match_dup 0) (const_int 0))
2044      (use (match_dup 1))
2045      (clobber (reg:CC 33))])]
2046   "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
2047
2048 (define_split
2049   [(set (match_operand:BLK 0 "memory_operand" "")
2050         (const_int 0))
2051    (use (match_operand 1 "register_operand" ""))
2052    (use (match_operand 2 "memory_operand" ""))
2053    (clobber (scratch))
2054    (clobber (reg:CC 33))]
2055   "reload_completed"
2056   [(parallel
2057     [(unspec [(match_dup 1) (match_dup 2)
2058               (const_int 0)] UNSPEC_EXECUTE)
2059      (set (match_dup 0) (const_int 0))
2060      (use (const_int 1))
2061      (clobber (reg:CC 33))])]
2062   "")
2063
2064 (define_split
2065   [(set (match_operand:BLK 0 "memory_operand" "")
2066         (const_int 0))
2067    (use (match_operand 1 "register_operand" ""))
2068    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2069    (clobber (match_operand 2 "register_operand" ""))
2070    (clobber (reg:CC 33))]
2071   "reload_completed && TARGET_CPU_ZARCH"
2072   [(set (match_dup 2) (label_ref (match_dup 3)))
2073    (parallel
2074     [(unspec [(match_dup 1) (mem:BLK (match_dup 2)) 
2075               (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2076      (set (match_dup 0) (const_int 0))
2077      (use (const_int 1))
2078      (clobber (reg:CC 33))])]
2079   "operands[3] = gen_label_rtx ();")
2080
2081 ; Clear a block of arbitrary length.
2082
2083 (define_expand "clrmem_long"
2084   [(parallel
2085     [(clobber (match_dup 1))
2086      (set (match_operand:BLK 0 "memory_operand" "")
2087           (const_int 0))
2088      (use (match_operand 1 "general_operand" ""))
2089      (use (match_dup 2))
2090      (clobber (reg:CC 33))])]
2091   ""
2092 {
2093   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2094   rtx reg0 = gen_reg_rtx (dword_mode);
2095   rtx reg1 = gen_reg_rtx (dword_mode);
2096   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2097   rtx len0 = gen_lowpart (Pmode, reg0);
2098
2099   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2100   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2101   emit_move_insn (len0, operands[1]);
2102
2103   emit_move_insn (reg1, const0_rtx);
2104
2105   operands[0] = replace_equiv_address_nv (operands[0], addr0);
2106   operands[1] = reg0;
2107   operands[2] = reg1;
2108 })
2109
2110 (define_insn "*clrmem_long_64"
2111   [(clobber (match_operand:TI 0 "register_operand" "=d"))
2112    (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
2113         (const_int 0))
2114    (use (match_dup 2))
2115    (use (match_operand:TI 1 "register_operand" "d"))
2116    (clobber (reg:CC 33))]
2117   "TARGET_64BIT"
2118   "mvcle\t%0,%1,0\;jo\t.-4"
2119   [(set_attr "length" "8")
2120    (set_attr "type" "vs")])
2121
2122 (define_insn "*clrmem_long_31"
2123   [(clobber (match_operand:DI 0 "register_operand" "=d"))
2124    (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
2125         (const_int 0))
2126    (use (match_dup 2))
2127    (use (match_operand:DI 1 "register_operand" "d"))
2128    (clobber (reg:CC 33))]
2129   "!TARGET_64BIT"
2130   "mvcle\t%0,%1,0\;jo\t.-4"
2131   [(set_attr "length" "8")
2132    (set_attr "type" "vs")])
2133
2134 ;
2135 ; cmpmemM instruction pattern(s).
2136 ;
2137
2138 (define_expand "cmpmemsi"
2139   [(set (match_operand:SI 0 "register_operand" "")
2140         (compare:SI (match_operand:BLK 1 "memory_operand" "")
2141                     (match_operand:BLK 2 "memory_operand" "") ) )
2142    (use (match_operand:SI 3 "general_operand" ""))
2143    (use (match_operand:SI 4 "" ""))]
2144   ""
2145   "s390_expand_cmpmem (operands[0], operands[1],
2146                        operands[2], operands[3]); DONE;")
2147
2148 ; Compare a block that is up to 256 bytes in length.
2149 ; The block length is taken as (operands[2] % 256) + 1.
2150
2151 (define_expand "cmpmem_short"
2152   [(parallel
2153     [(set (reg:CCU 33)
2154           (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2155                        (match_operand:BLK 1 "memory_operand" "")))
2156      (use (match_operand 2 "nonmemory_operand" ""))
2157      (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2158      (clobber (match_dup 3))])]
2159   ""
2160   "operands[3] = gen_rtx_SCRATCH (Pmode);")
2161
2162 (define_insn "*cmpmem_short"
2163   [(set (reg:CCU 33)
2164         (compare:CCU (match_operand:BLK 0 "memory_operand" "=Q,Q,Q")
2165                      (match_operand:BLK 1 "memory_operand" "Q,Q,Q")))
2166    (use (match_operand 2 "nonmemory_operand" "n,a,a"))
2167    (use (match_operand 3 "immediate_operand" "X,R,X"))
2168    (clobber (match_scratch 4 "=X,X,&a"))]
2169   "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2170    && GET_MODE (operands[4]) == Pmode"
2171   "#"
2172   [(set_attr "type" "cs")])
2173
2174 (define_split
2175   [(set (reg:CCU 33)
2176         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2177                      (match_operand:BLK 1 "memory_operand" "")))
2178    (use (match_operand 2 "const_int_operand" ""))
2179    (use (match_operand 3 "immediate_operand" ""))
2180    (clobber (scratch))]
2181   "reload_completed"
2182   [(parallel
2183     [(set (reg:CCU 33) (compare:CCU (match_dup 0) (match_dup 1)))
2184      (use (match_dup 2))])]
2185   "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2186
2187 (define_split
2188   [(set (reg:CCU 33)
2189         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2190                      (match_operand:BLK 1 "memory_operand" "")))
2191    (use (match_operand 2 "register_operand" ""))
2192    (use (match_operand 3 "memory_operand" ""))
2193    (clobber (scratch))]
2194   "reload_completed"
2195   [(parallel
2196     [(unspec [(match_dup 2) (match_dup 3)
2197               (const_int 0)] UNSPEC_EXECUTE)
2198      (set (reg:CCU 33) (compare:CCU (match_dup 0) (match_dup 1)))
2199      (use (const_int 1))])]
2200   "")
2201
2202 (define_split
2203   [(set (reg:CCU 33)
2204         (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2205                      (match_operand:BLK 1 "memory_operand" "")))
2206    (use (match_operand 2 "register_operand" ""))
2207    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2208    (clobber (match_operand 3 "register_operand" ""))]
2209   "reload_completed && TARGET_CPU_ZARCH"
2210   [(set (match_dup 3) (label_ref (match_dup 4)))
2211    (parallel
2212     [(unspec [(match_dup 2) (mem:BLK (match_dup 3)) 
2213               (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2214      (set (reg:CCU 33) (compare:CCU (match_dup 0) (match_dup 1)))
2215      (use (const_int 1))])]
2216   "operands[4] = gen_label_rtx ();")
2217
2218 ; Compare a block of arbitrary length.
2219
2220 (define_expand "cmpmem_long"
2221   [(parallel
2222     [(clobber (match_dup 2))
2223      (clobber (match_dup 3))
2224      (set (reg:CCU 33)
2225           (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2226                        (match_operand:BLK 1 "memory_operand" "")))
2227      (use (match_operand 2 "general_operand" ""))
2228      (use (match_dup 3))])]
2229   ""
2230 {
2231   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2232   rtx reg0 = gen_reg_rtx (dword_mode);
2233   rtx reg1 = gen_reg_rtx (dword_mode);
2234   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2235   rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2236   rtx len0 = gen_lowpart (Pmode, reg0);
2237   rtx len1 = gen_lowpart (Pmode, reg1);
2238
2239   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2240   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2241   emit_move_insn (len0, operands[2]);
2242
2243   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2244   emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2245   emit_move_insn (len1, operands[2]);
2246
2247   operands[0] = replace_equiv_address_nv (operands[0], addr0);
2248   operands[1] = replace_equiv_address_nv (operands[1], addr1);
2249   operands[2] = reg0;
2250   operands[3] = reg1;
2251 })
2252
2253 (define_insn "*cmpmem_long_64"
2254   [(clobber (match_operand:TI 0 "register_operand" "=d"))
2255    (clobber (match_operand:TI 1 "register_operand" "=d"))
2256    (set (reg:CCU 33)
2257         (compare:CCU (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
2258                      (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0))))
2259    (use (match_dup 2))
2260    (use (match_dup 3))]
2261   "TARGET_64BIT"
2262   "clcle\t%0,%1,0\;jo\t.-4"
2263   [(set_attr "length" "8")
2264    (set_attr "type" "vs")])
2265
2266 (define_insn "*cmpmem_long_31"
2267   [(clobber (match_operand:DI 0 "register_operand" "=d"))
2268    (clobber (match_operand:DI 1 "register_operand" "=d"))
2269    (set (reg:CCU 33)
2270         (compare:CCU (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
2271                      (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0))))
2272    (use (match_dup 2))
2273    (use (match_dup 3))]
2274   "!TARGET_64BIT"
2275   "clcle\t%0,%1,0\;jo\t.-4"
2276   [(set_attr "length" "8")
2277    (set_attr "type" "vs")])
2278
2279 ; Convert CCUmode condition code to integer.
2280 ; Result is zero if EQ, positive if LTU, negative if GTU.
2281
2282 (define_insn_and_split "cmpint"
2283   [(set (match_operand:SI 0 "register_operand" "=d")
2284         (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2285                    UNSPEC_CMPINT))
2286    (clobber (reg:CC 33))]
2287   ""
2288   "#"
2289   "reload_completed"
2290   [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2291    (parallel
2292     [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
2293      (clobber (reg:CC 33))])])
2294
2295 (define_insn_and_split "*cmpint_cc"
2296   [(set (reg 33)
2297         (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2298                             UNSPEC_CMPINT)
2299                  (const_int 0)))
2300    (set (match_operand:SI 0 "register_operand" "=d")
2301         (unspec:SI [(match_dup 1)] UNSPEC_CMPINT))]
2302   "s390_match_ccmode (insn, CCSmode)"
2303   "#"
2304   "&& reload_completed"
2305   [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
2306    (parallel
2307     [(set (match_dup 2) (match_dup 3))
2308      (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
2309 {
2310   rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
2311   operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2312   operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2313 })
2314
2315 (define_insn_and_split "*cmpint_sign"
2316   [(set (match_operand:DI 0 "register_operand" "=d")
2317         (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2318                                    UNSPEC_CMPINT)))
2319    (clobber (reg:CC 33))]
2320   "TARGET_64BIT"
2321   "#"
2322   "&& reload_completed"
2323   [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2324    (parallel
2325     [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
2326      (clobber (reg:CC 33))])])
2327
2328 (define_insn_and_split "*cmpint_sign_cc"
2329   [(set (reg 33)
2330         (compare (ashiftrt:DI (ashift:DI (subreg:DI 
2331                    (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
2332                               UNSPEC_CMPINT) 0)
2333                    (const_int 32)) (const_int 32))
2334                  (const_int 0)))
2335    (set (match_operand:DI 0 "register_operand" "=d")
2336         (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CMPINT)))]
2337   "s390_match_ccmode (insn, CCSmode) && TARGET_64BIT"
2338   "#"
2339   "&& reload_completed"
2340   [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
2341    (parallel
2342     [(set (match_dup 2) (match_dup 3))
2343      (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
2344 {
2345   rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
2346   operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
2347   operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
2348 })
2349
2350
2351 ;;
2352 ;;- Conversion instructions.
2353 ;;
2354
2355 (define_insn "*sethighqisi"
2356   [(set (match_operand:SI 0 "register_operand" "=d,d")
2357         (unspec:SI [(match_operand:QI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2358    (clobber (reg:CC 33))]
2359   ""
2360   "@
2361    icm\t%0,8,%S1
2362    icmy\t%0,8,%S1"
2363   [(set_attr "op_type" "RS,RSY")])
2364
2365 (define_insn "*sethighhisi"
2366   [(set (match_operand:SI 0 "register_operand" "=d,d")
2367         (unspec:SI [(match_operand:HI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2368    (clobber (reg:CC 33))]
2369   ""
2370   "@
2371    icm\t%0,12,%S1
2372    icmy\t%0,12,%S1"
2373   [(set_attr "op_type" "RS,RSY")])
2374
2375 (define_insn "*sethighqidi_64"
2376   [(set (match_operand:DI 0 "register_operand" "=d")
2377         (unspec:DI [(match_operand:QI 1 "s_operand" "QS")] UNSPEC_SETHIGH))
2378    (clobber (reg:CC 33))]
2379   "TARGET_64BIT"
2380   "icmh\t%0,8,%S1"
2381   [(set_attr "op_type" "RSY")])
2382
2383 (define_insn "*sethighqidi_31"
2384   [(set (match_operand:DI 0 "register_operand" "=d,d")
2385         (unspec:DI [(match_operand:QI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2386    (clobber (reg:CC 33))]
2387   "!TARGET_64BIT"
2388   "@
2389    icm\t%0,8,%S1
2390    icmy\t%0,8,%S1"
2391   [(set_attr "op_type" "RS,RSY")])
2392
2393 (define_insn_and_split "*extractqi"
2394   [(set (match_operand:SI 0 "register_operand" "=d")
2395         (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2396                          (match_operand 2 "const_int_operand" "n")
2397                          (const_int 0)))
2398    (clobber (reg:CC 33))]
2399   "!TARGET_64BIT
2400    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 8"
2401   "#"
2402   "&& reload_completed"
2403   [(parallel
2404     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2405      (clobber (reg:CC 33))])
2406     (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
2407 {
2408   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2409   operands[1] = change_address (operands[1], QImode, 0);
2410 })
2411
2412 (define_insn_and_split "*extracthi"
2413   [(set (match_operand:SI 0 "register_operand" "=d")
2414         (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2415                          (match_operand 2 "const_int_operand" "n")
2416                          (const_int 0)))
2417    (clobber (reg:CC 33))]
2418   "!TARGET_64BIT
2419    && INTVAL (operands[2]) >= 8 && INTVAL (operands[2]) < 16"
2420   "#"
2421   "&& reload_completed"
2422   [(parallel
2423     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2424      (clobber (reg:CC 33))])
2425     (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
2426 {
2427   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2428   operands[1] = change_address (operands[1], HImode, 0);
2429 })
2430
2431 ;
2432 ; extendsidi2 instruction pattern(s).
2433 ;
2434
2435 (define_expand "extendsidi2"
2436   [(set (match_operand:DI 0 "register_operand" "")
2437         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2438   ""
2439   "
2440 {
2441   if (!TARGET_64BIT)
2442     {
2443       emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2444       emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
2445       emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
2446       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
2447       DONE;
2448     }
2449 }
2450 ")
2451
2452 (define_insn "*extendsidi2"
2453   [(set (match_operand:DI 0 "register_operand" "=d,d")
2454         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2455   "TARGET_64BIT"
2456   "@
2457    lgfr\t%0,%1
2458    lgf\t%0,%1"
2459   [(set_attr "op_type" "RRE,RXY")])
2460
2461 ;
2462 ; extendhidi2 instruction pattern(s).
2463 ;
2464
2465 (define_expand "extendhidi2"
2466   [(set (match_operand:DI 0 "register_operand" "")
2467         (sign_extend:DI (match_operand:HI 1 "register_operand" "")))]
2468   ""
2469   "
2470 {
2471   if (!TARGET_64BIT)
2472     {
2473       rtx tmp = gen_reg_rtx (SImode);
2474       emit_insn (gen_extendhisi2 (tmp, operands[1]));
2475       emit_insn (gen_extendsidi2 (operands[0], tmp));
2476       DONE;
2477     }
2478   else
2479     {
2480       operands[1] = gen_lowpart (DImode, operands[1]);
2481       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (48)));
2482       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (48)));
2483       DONE;
2484     }
2485 }
2486 ")
2487
2488 (define_insn "*extendhidi2"
2489   [(set (match_operand:DI 0 "register_operand" "=d")
2490         (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2491   "TARGET_64BIT"
2492   "lgh\t%0,%1"
2493   [(set_attr "op_type" "RXY")])
2494
2495 ;
2496 ; extendqidi2 instruction pattern(s).
2497 ;
2498
2499 (define_expand "extendqidi2"
2500   [(set (match_operand:DI 0 "register_operand" "")
2501         (sign_extend:DI (match_operand:QI 1 "register_operand" "")))]
2502   ""
2503   "
2504 {
2505   if (!TARGET_64BIT)
2506     {
2507       rtx tmp = gen_reg_rtx (SImode);
2508       emit_insn (gen_extendqisi2 (tmp, operands[1]));
2509       emit_insn (gen_extendsidi2 (operands[0], tmp));
2510       DONE;
2511     }
2512   else
2513     {
2514       operands[1] = gen_lowpart (DImode, operands[1]);
2515       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (56)));
2516       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (56)));
2517       DONE;
2518     }
2519 }
2520 ")
2521
2522 (define_insn "*extendqidi2"
2523   [(set (match_operand:DI 0 "register_operand" "=d")
2524         (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
2525   "TARGET_64BIT && TARGET_LONG_DISPLACEMENT"
2526   "lgb\t%0,%1"
2527   [(set_attr "op_type" "RXY")])
2528
2529 (define_insn_and_split "*extendqidi2_short_displ"
2530   [(set (match_operand:DI 0 "register_operand" "=d")
2531         (sign_extend:DI (match_operand:QI 1 "s_operand" "Q")))
2532    (clobber (reg:CC 33))]
2533   "TARGET_64BIT && !TARGET_LONG_DISPLACEMENT"
2534   "#"
2535   "&& reload_completed"
2536   [(parallel
2537     [(set (match_dup 0) (unspec:DI [(match_dup 1)] UNSPEC_SETHIGH))
2538      (clobber (reg:CC 33))])
2539    (parallel
2540     [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 56)))
2541      (clobber (reg:CC 33))])]
2542   "")
2543
2544 ;
2545 ; extendhisi2 instruction pattern(s).
2546 ;
2547
2548 (define_expand "extendhisi2"
2549   [(set (match_operand:SI 0 "register_operand" "")
2550         (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
2551   ""
2552   "
2553 {
2554   operands[1] = gen_lowpart (SImode, operands[1]);
2555   emit_insn (gen_ashlsi3 (operands[0], operands[1], GEN_INT (16)));
2556   emit_insn (gen_ashrsi3 (operands[0], operands[0], GEN_INT (16)));
2557   DONE;
2558 }
2559 ")
2560
2561 (define_insn "*extendhisi2"
2562   [(set (match_operand:SI 0 "register_operand" "=d,d")
2563         (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
2564   ""
2565   "@
2566    lh\t%0,%1
2567    lhy\t%0,%1"
2568   [(set_attr "op_type" "RX,RXY")])
2569
2570 ;
2571 ; extendqisi2 instruction pattern(s).
2572 ;
2573
2574 (define_expand "extendqisi2"
2575   [(set (match_operand:SI 0 "register_operand" "")
2576         (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
2577   ""
2578   "
2579 {
2580   operands[1] = gen_lowpart (SImode, operands[1]);
2581   emit_insn (gen_ashlsi3 (operands[0], operands[1], GEN_INT (24)));
2582   emit_insn (gen_ashrsi3 (operands[0], operands[0], GEN_INT (24)));
2583   DONE;
2584 }
2585 ")
2586
2587 (define_insn "*extendqisi2"
2588   [(set (match_operand:SI 0 "register_operand" "=d")
2589         (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2590   "TARGET_LONG_DISPLACEMENT"
2591   "lb\t%0,%1"
2592   [(set_attr "op_type" "RXY")])
2593
2594 (define_insn_and_split "*extendqisi2_short_displ"
2595   [(set (match_operand:SI 0 "register_operand" "=d")
2596         (sign_extend:SI (match_operand:QI 1 "s_operand" "Q")))
2597    (clobber (reg:CC 33))]
2598   "!TARGET_LONG_DISPLACEMENT"
2599   "#"
2600   "&& reload_completed"
2601   [(parallel
2602     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2603      (clobber (reg:CC 33))])
2604    (parallel
2605     [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 24)))
2606      (clobber (reg:CC 33))])]
2607   "")
2608
2609 ;
2610 ; extendqihi2 instruction pattern(s).
2611 ;
2612
2613
2614 ;
2615 ; zero_extendsidi2 instruction pattern(s).
2616 ;
2617
2618 (define_expand "zero_extendsidi2"
2619   [(set (match_operand:DI 0 "register_operand" "")
2620         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2621   ""
2622   "
2623 {
2624   if (!TARGET_64BIT)
2625     {
2626       emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2627       emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
2628       emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
2629       DONE;
2630     }
2631 }
2632 ")
2633
2634 (define_insn "*zero_extendsidi2"
2635   [(set (match_operand:DI 0 "register_operand" "=d,d")
2636         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2637   "TARGET_64BIT"
2638   "@
2639    llgfr\t%0,%1
2640    llgf\t%0,%1"
2641   [(set_attr "op_type" "RRE,RXY")])
2642
2643 ;
2644 ; zero_extendhidi2 instruction pattern(s).
2645 ;
2646
2647 (define_expand "zero_extendhidi2"
2648   [(set (match_operand:DI 0 "register_operand" "")
2649         (zero_extend:DI (match_operand:HI 1 "register_operand" "")))]
2650   ""
2651   "
2652 {
2653   if (!TARGET_64BIT)
2654     {
2655       rtx tmp = gen_reg_rtx (SImode);
2656       emit_insn (gen_zero_extendhisi2 (tmp, operands[1]));
2657       emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
2658       DONE;
2659     }
2660   else
2661     {
2662       operands[1] = gen_lowpart (DImode, operands[1]);
2663       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (48)));
2664       emit_insn (gen_lshrdi3 (operands[0], operands[0], GEN_INT (48)));
2665       DONE;
2666     }
2667 }
2668 ")
2669
2670 (define_insn "*zero_extendhidi2"
2671   [(set (match_operand:DI 0 "register_operand" "=d")
2672         (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2673   "TARGET_64BIT"
2674   "llgh\t%0,%1"
2675   [(set_attr "op_type" "RXY")])
2676
2677 ;
2678 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
2679 ;
2680
2681 (define_insn "*llgt_sisi"
2682   [(set (match_operand:SI 0 "register_operand" "=d,d")
2683         (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,m")
2684                 (const_int 2147483647)))]
2685   "TARGET_64BIT"
2686   "@
2687    llgtr\t%0,%1
2688    llgt\t%0,%1"
2689   [(set_attr "op_type"  "RRE,RXE")])
2690
2691 (define_split
2692   [(set (match_operand:SI 0 "register_operand" "")
2693         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
2694                 (const_int 2147483647)))
2695    (clobber (reg:CC 33))]
2696   "TARGET_64BIT && reload_completed"
2697   [(set (match_dup 0)
2698         (and:SI (match_dup 1)
2699                 (const_int 2147483647)))]
2700   "")
2701
2702 (define_insn "*llgt_didi"
2703   [(set (match_operand:DI 0 "register_operand" "=d,d")
2704         (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
2705                 (const_int 2147483647)))]
2706   "TARGET_64BIT"
2707   "@
2708    llgtr\t%0,%1
2709    llgt\t%0,%N1"
2710   [(set_attr "op_type"  "RRE,RXE")])
2711
2712 (define_split
2713   [(set (match_operand:DI 0 "register_operand" "")
2714         (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
2715                 (const_int 2147483647)))
2716    (clobber (reg:CC 33))]
2717   "TARGET_64BIT && reload_completed"
2718   [(set (match_dup 0)
2719         (and:DI (match_dup 1)
2720                 (const_int 2147483647)))]
2721   "")
2722
2723 (define_insn "*llgt_sidi"
2724   [(set (match_operand:DI 0 "register_operand" "=d")
2725         (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2726                 (const_int 2147483647)))]
2727   "TARGET_64BIT"
2728   "llgt\t%0,%1"
2729   [(set_attr "op_type"  "RXE")])
2730
2731 (define_insn_and_split "*llgt_sidi_split"
2732   [(set (match_operand:DI 0 "register_operand" "=d")
2733         (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2734                 (const_int 2147483647)))
2735    (clobber (reg:CC 33))]
2736   "TARGET_64BIT"
2737   "#"
2738   "&& reload_completed"
2739   [(set (match_dup 0)
2740         (and:DI (subreg:DI (match_dup 1) 0)
2741                 (const_int 2147483647)))]
2742   "")
2743
2744 ;
2745 ; zero_extendqidi2 instruction pattern(s)
2746 ;
2747
2748 (define_expand "zero_extendqidi2"
2749   [(set (match_operand:DI 0 "register_operand" "")
2750         (zero_extend:DI (match_operand:QI 1 "register_operand" "")))]
2751   ""
2752   "
2753 {
2754   if (!TARGET_64BIT)
2755     {
2756       rtx tmp = gen_reg_rtx (SImode);
2757       emit_insn (gen_zero_extendqisi2 (tmp, operands[1]));
2758       emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
2759       DONE;
2760     }
2761   else
2762     {
2763       operands[1] = gen_lowpart (DImode, operands[1]);
2764       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (56)));
2765       emit_insn (gen_lshrdi3 (operands[0], operands[0], GEN_INT (56)));
2766       DONE;
2767     }
2768 }
2769 ")
2770
2771 (define_insn "*zero_extendqidi2"
2772   [(set (match_operand:DI 0 "register_operand" "=d")
2773         (zero_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
2774   "TARGET_64BIT"
2775   "llgc\t%0,%1"
2776   [(set_attr "op_type" "RXY")])
2777
2778 ;
2779 ; zero_extendhisi2 instruction pattern(s).
2780 ;
2781
2782 (define_expand "zero_extendhisi2"
2783   [(set (match_operand:SI 0 "register_operand" "")
2784         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
2785   ""
2786   "
2787 {
2788   operands[1] = gen_lowpart (SImode, operands[1]);
2789   emit_insn (gen_andsi3 (operands[0], operands[1], GEN_INT (0xffff)));
2790   DONE;
2791 }
2792 ")
2793
2794 (define_insn "*zero_extendhisi2_64"
2795   [(set (match_operand:SI 0 "register_operand" "=d")
2796         (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
2797   "TARGET_64BIT"
2798   "llgh\t%0,%1"
2799   [(set_attr "op_type" "RXY")])
2800
2801 (define_insn_and_split "*zero_extendhisi2_31"
2802   [(set (match_operand:SI 0 "register_operand" "=&d")
2803         (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
2804    (clobber (reg:CC 33))]
2805   "!TARGET_64BIT"
2806   "#"
2807   "&& reload_completed"
2808   [(set (match_dup 0) (const_int 0))
2809    (parallel
2810     [(set (strict_low_part (match_dup 2)) (match_dup 1))
2811      (clobber (reg:CC 33))])]
2812   "operands[2] = gen_lowpart (HImode, operands[0]);")
2813
2814 ;
2815 ; zero_extendqisi2 instruction pattern(s).
2816 ;
2817
2818 (define_expand "zero_extendqisi2"
2819   [(set (match_operand:SI 0 "register_operand" "")
2820         (zero_extend:SI (match_operand:QI 1 "register_operand" "")))]
2821   ""
2822   "
2823 {
2824   operands[1] = gen_lowpart (SImode, operands[1]);
2825   emit_insn (gen_andsi3 (operands[0], operands[1], GEN_INT (0xff)));
2826   DONE;
2827 }
2828 ")
2829
2830 (define_insn "*zero_extendqisi2_64"
2831   [(set (match_operand:SI 0 "register_operand" "=d")
2832         (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2833   "TARGET_ZARCH"
2834   "llgc\t%0,%1"
2835   [(set_attr "op_type" "RXY")])
2836
2837 (define_insn_and_split "*zero_extendqisi2_31"
2838   [(set (match_operand:SI 0 "register_operand" "=&d")
2839         (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2840   "!TARGET_ZARCH"
2841   "#"
2842   "&& reload_completed"
2843   [(set (match_dup 0) (const_int 0))
2844    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2845   "operands[2] = gen_lowpart (QImode, operands[0]);")
2846
2847 ;
2848 ; zero_extendqihi2 instruction pattern(s).
2849 ;
2850
2851 (define_expand "zero_extendqihi2"
2852   [(set (match_operand:HI 0 "register_operand" "")
2853         (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
2854   "TARGET_ZARCH"
2855   "
2856 {
2857   operands[1] = gen_lowpart (HImode, operands[1]);
2858   emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
2859   DONE;
2860 }
2861 ")
2862
2863 (define_insn "*zero_extendqihi2_64"
2864   [(set (match_operand:HI 0 "register_operand" "=d")
2865         (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2866   "TARGET_ZARCH"
2867   "llgc\t%0,%1"
2868   [(set_attr "op_type" "RXY")])
2869
2870 (define_insn_and_split "*zero_extendqihi2_31"
2871   [(set (match_operand:HI 0 "register_operand" "=&d")
2872         (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2873   "!TARGET_ZARCH"
2874   "#"
2875   "&& reload_completed"
2876   [(set (match_dup 0) (const_int 0))
2877    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2878   "operands[2] = gen_lowpart (QImode, operands[0]);")
2879
2880
2881 ;
2882 ; fixuns_truncdfdi2 and fix_truncdfsi2 instruction pattern(s).
2883 ;
2884
2885 (define_expand "fixuns_truncdfdi2"
2886   [(set (match_operand:DI 0 "register_operand" "")
2887         (unsigned_fix:DI (match_operand:DF 1 "register_operand" "")))]
2888   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2889 {
2890   rtx label1 = gen_label_rtx ();
2891   rtx label2 = gen_label_rtx ();
2892   rtx temp = gen_reg_rtx (DFmode);
2893   operands[1] = force_reg (DFmode, operands[1]);
2894
2895   emit_insn (gen_cmpdf (operands[1],
2896         CONST_DOUBLE_FROM_REAL_VALUE (
2897           REAL_VALUE_ATOF ("9223372036854775808.0", DFmode), DFmode)));
2898   emit_jump_insn (gen_blt (label1));
2899   emit_insn (gen_subdf3 (temp, operands[1],
2900         CONST_DOUBLE_FROM_REAL_VALUE (
2901           REAL_VALUE_ATOF ("18446744073709551616.0", DFmode), DFmode)));
2902   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], temp, GEN_INT(7)));
2903   emit_jump (label2);
2904
2905   emit_label (label1);
2906   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2907   emit_label (label2);
2908   DONE;
2909 })
2910
2911 (define_expand "fix_truncdfdi2"
2912   [(set (match_operand:DI 0 "register_operand" "")
2913         (fix:DI (match_operand:DF 1 "nonimmediate_operand" "")))]
2914   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2915 {
2916   operands[1] = force_reg (DFmode, operands[1]);
2917   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2918   DONE;
2919 })
2920
2921 (define_insn "fix_truncdfdi2_ieee"
2922   [(set (match_operand:DI 0 "register_operand" "=d")
2923         (fix:DI (match_operand:DF 1 "register_operand" "f")))
2924    (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2925    (clobber (reg:CC 33))]
2926   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2927   "cgdbr\t%0,%h2,%1"
2928   [(set_attr "op_type" "RRE")
2929    (set_attr "type"    "ftoi")])
2930
2931 ;
2932 ; fixuns_truncdfsi2 and fix_truncdfsi2 instruction pattern(s).
2933 ;
2934
2935 (define_expand "fixuns_truncdfsi2"
2936   [(set (match_operand:SI 0 "register_operand" "")
2937         (unsigned_fix:SI (match_operand:DF 1 "register_operand" "")))]
2938   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2939 {
2940   rtx label1 = gen_label_rtx ();
2941   rtx label2 = gen_label_rtx ();
2942   rtx temp = gen_reg_rtx (DFmode);
2943
2944   operands[1] = force_reg (DFmode,operands[1]);
2945   emit_insn (gen_cmpdf (operands[1],
2946         CONST_DOUBLE_FROM_REAL_VALUE (
2947           REAL_VALUE_ATOF ("2147483648.0", DFmode), DFmode)));
2948   emit_jump_insn (gen_blt (label1));
2949   emit_insn (gen_subdf3 (temp, operands[1],
2950         CONST_DOUBLE_FROM_REAL_VALUE (
2951           REAL_VALUE_ATOF ("4294967296.0", DFmode), DFmode)));
2952   emit_insn (gen_fix_truncdfsi2_ieee (operands[0], temp, GEN_INT (7)));
2953   emit_jump (label2);
2954
2955   emit_label (label1);
2956   emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2957   emit_label (label2);
2958   DONE;
2959 })
2960
2961 (define_expand "fix_truncdfsi2"
2962   [(set (match_operand:SI 0 "register_operand" "")
2963         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "")))]
2964   "TARGET_HARD_FLOAT"
2965 {
2966   if (TARGET_IBM_FLOAT)
2967     {
2968       /* This is the algorithm from POP chapter A.5.7.2.  */
2969
2970       rtx temp   = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
2971       rtx two31r = s390_gen_rtx_const_DI (0x4f000000, 0x08000000);
2972       rtx two32  = s390_gen_rtx_const_DI (0x4e000001, 0x00000000);
2973
2974       operands[1] = force_reg (DFmode, operands[1]);
2975       emit_insn (gen_fix_truncdfsi2_ibm (operands[0], operands[1],
2976                                          two31r, two32, temp));
2977     }
2978   else
2979     {
2980       operands[1] = force_reg (DFmode, operands[1]);
2981       emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2982     }
2983
2984   DONE;
2985 })
2986
2987 (define_insn "fix_truncdfsi2_ieee"
2988   [(set (match_operand:SI 0 "register_operand" "=d")
2989         (fix:SI (match_operand:DF 1 "register_operand" "f")))
2990     (unspec:SI [(match_operand:SI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2991     (clobber (reg:CC 33))]
2992   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2993   "cfdbr\t%0,%h2,%1"
2994    [(set_attr "op_type" "RRE")
2995     (set_attr "type"    "ftoi")])
2996
2997 (define_insn "fix_truncdfsi2_ibm"
2998   [(set (match_operand:SI 0 "register_operand" "=d")
2999         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "+f")))
3000    (use (match_operand:DI 2 "immediate_operand" "m"))
3001    (use (match_operand:DI 3 "immediate_operand" "m"))
3002    (use (match_operand:BLK 4 "memory_operand" "m"))
3003    (clobber (reg:CC 33))]
3004   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3005 {
3006    output_asm_insn ("sd\t%1,%2", operands);
3007    output_asm_insn ("aw\t%1,%3", operands);
3008    output_asm_insn ("std\t%1,%4", operands);
3009    output_asm_insn ("xi\t%N4,128", operands);
3010    return "l\t%0,%N4";
3011 }
3012   [(set_attr "length" "20")])
3013
3014 ;
3015 ; fixuns_truncsfdi2 and fix_truncsfdi2 instruction pattern(s).
3016 ;
3017
3018 (define_expand "fixuns_truncsfdi2"
3019   [(set (match_operand:DI 0 "register_operand" "")
3020         (unsigned_fix:DI (match_operand:SF 1 "register_operand" "")))]
3021   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3022 {
3023   rtx label1 = gen_label_rtx ();
3024   rtx label2 = gen_label_rtx ();
3025   rtx temp = gen_reg_rtx (SFmode);
3026
3027   operands[1] = force_reg (SFmode, operands[1]);
3028   emit_insn (gen_cmpsf (operands[1],
3029         CONST_DOUBLE_FROM_REAL_VALUE (
3030           REAL_VALUE_ATOF ("9223372036854775808.0", SFmode), SFmode)));
3031   emit_jump_insn (gen_blt (label1));
3032
3033   emit_insn (gen_subsf3 (temp, operands[1],
3034         CONST_DOUBLE_FROM_REAL_VALUE (
3035           REAL_VALUE_ATOF ("18446744073709551616.0", SFmode), SFmode)));
3036   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], temp, GEN_INT(7)));
3037   emit_jump (label2);
3038
3039   emit_label (label1);
3040   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
3041   emit_label (label2);
3042   DONE;
3043 })
3044
3045 (define_expand "fix_truncsfdi2"
3046   [(set (match_operand:DI 0 "register_operand" "")
3047         (fix:DI (match_operand:SF 1 "nonimmediate_operand" "")))]
3048   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3049 {
3050   operands[1] = force_reg (SFmode, operands[1]);
3051   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
3052   DONE;
3053 })
3054
3055 (define_insn "fix_truncsfdi2_ieee"
3056   [(set (match_operand:DI 0 "register_operand" "=d")
3057         (fix:DI (match_operand:SF 1 "register_operand"  "f")))
3058    (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
3059    (clobber (reg:CC 33))]
3060   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3061   "cgebr\t%0,%h2,%1"
3062   [(set_attr "op_type" "RRE")
3063    (set_attr "type"    "ftoi")])
3064
3065 ;
3066 ; fixuns_truncsfsi2 and fix_truncsfsi2 instruction pattern(s).
3067 ;
3068
3069 (define_expand "fixuns_truncsfsi2"
3070   [(set (match_operand:SI 0 "register_operand" "")
3071         (unsigned_fix:SI (match_operand:SF 1 "register_operand" "")))]
3072   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3073 {
3074   rtx label1 = gen_label_rtx ();
3075   rtx label2 = gen_label_rtx ();
3076   rtx temp = gen_reg_rtx (SFmode);
3077
3078   operands[1] = force_reg (SFmode, operands[1]);
3079   emit_insn (gen_cmpsf (operands[1],
3080         CONST_DOUBLE_FROM_REAL_VALUE (
3081           REAL_VALUE_ATOF ("2147483648.0", SFmode), SFmode)));
3082   emit_jump_insn (gen_blt (label1));
3083   emit_insn (gen_subsf3 (temp, operands[1],
3084         CONST_DOUBLE_FROM_REAL_VALUE (
3085           REAL_VALUE_ATOF ("4294967296.0", SFmode), SFmode)));
3086   emit_insn (gen_fix_truncsfsi2_ieee (operands[0], temp, GEN_INT (7)));
3087   emit_jump (label2);
3088
3089   emit_label (label1);
3090   emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
3091   emit_label (label2);
3092   DONE;
3093 })
3094
3095 (define_expand "fix_truncsfsi2"
3096   [(set (match_operand:SI 0 "register_operand" "")
3097         (fix:SI (match_operand:SF 1 "nonimmediate_operand" "")))]
3098   "TARGET_HARD_FLOAT"
3099 {
3100   if (TARGET_IBM_FLOAT)
3101     {
3102       /* Convert to DFmode and then use the POP algorithm.  */
3103       rtx temp = gen_reg_rtx (DFmode);
3104       emit_insn (gen_extendsfdf2 (temp, operands[1]));
3105       emit_insn (gen_fix_truncdfsi2 (operands[0], temp));
3106     }
3107   else
3108     {
3109       operands[1] = force_reg (SFmode, operands[1]);
3110       emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
3111     }
3112
3113   DONE;
3114 })
3115
3116 (define_insn "fix_truncsfsi2_ieee"
3117   [(set (match_operand:SI 0 "register_operand" "=d")
3118         (fix:SI (match_operand:SF 1 "register_operand" "f")))
3119     (unspec:SI [(match_operand:SI 2 "immediate_operand" "K")] UNSPEC_ROUND)
3120     (clobber (reg:CC 33))]
3121   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3122   "cfebr\t%0,%h2,%1"
3123   [(set_attr "op_type" "RRE")
3124    (set_attr "type"    "ftoi")])
3125
3126 ;
3127 ; floatdidf2 instruction pattern(s).
3128 ;
3129
3130 (define_insn "floatdidf2"
3131   [(set (match_operand:DF 0 "register_operand" "=f")
3132         (float:DF (match_operand:DI 1 "register_operand" "d")))]
3133   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3134   "cdgbr\t%0,%1"
3135   [(set_attr "op_type" "RRE")
3136    (set_attr "type"    "itof" )])
3137
3138 ;
3139 ; floatdisf2 instruction pattern(s).
3140 ;
3141
3142 (define_insn "floatdisf2"
3143   [(set (match_operand:SF 0 "register_operand" "=f")
3144         (float:SF (match_operand:DI 1 "register_operand" "d")))]
3145   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3146   "cegbr\t%0,%1"
3147   [(set_attr "op_type" "RRE")
3148    (set_attr "type"    "itof" )])
3149
3150 ;
3151 ; floatsidf2 instruction pattern(s).
3152 ;
3153
3154 (define_expand "floatsidf2"
3155   [(set (match_operand:DF 0 "register_operand" "")
3156         (float:DF (match_operand:SI 1 "register_operand" "")))]
3157   "TARGET_HARD_FLOAT"
3158 {
3159   if (TARGET_IBM_FLOAT)
3160     {
3161       /* This is the algorithm from POP chapter A.5.7.1.  */
3162
3163       rtx temp  = assign_stack_local (BLKmode, 8, BITS_PER_WORD);
3164       rtx two31 = s390_gen_rtx_const_DI (0x4e000000, 0x80000000);
3165
3166       emit_insn (gen_floatsidf2_ibm (operands[0], operands[1], two31, temp));
3167       DONE;
3168     }
3169 })
3170
3171 (define_insn "floatsidf2_ieee"
3172   [(set (match_operand:DF 0 "register_operand" "=f")
3173         (float:DF (match_operand:SI 1 "register_operand" "d")))]
3174   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3175   "cdfbr\t%0,%1"
3176   [(set_attr "op_type" "RRE")
3177    (set_attr "type"   "itof" )])
3178
3179 (define_insn "floatsidf2_ibm"
3180   [(set (match_operand:DF 0 "register_operand" "=f")
3181         (float:DF (match_operand:SI 1 "register_operand" "d")))
3182    (use (match_operand:DI 2 "immediate_operand" "m"))
3183    (use (match_operand:BLK 3 "memory_operand" "m"))
3184    (clobber (reg:CC 33))]
3185   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3186 {
3187    output_asm_insn ("st\t%1,%N3", operands);
3188    output_asm_insn ("xi\t%N3,128", operands);
3189    output_asm_insn ("mvc\t%O3(4,%R3),%2", operands);
3190    output_asm_insn ("ld\t%0,%3", operands);
3191    return "sd\t%0,%2";
3192 }
3193   [(set_attr "length" "20")])
3194
3195 ;
3196 ; floatsisf2 instruction pattern(s).
3197 ;
3198
3199 (define_expand "floatsisf2"
3200   [(set (match_operand:SF 0 "register_operand" "")
3201         (float:SF (match_operand:SI 1 "register_operand" "")))]
3202   "TARGET_HARD_FLOAT"
3203 {
3204   if (TARGET_IBM_FLOAT)
3205     {
3206       /* Use the POP algorithm to convert to DFmode and then truncate.  */
3207       rtx temp = gen_reg_rtx (DFmode);
3208       emit_insn (gen_floatsidf2 (temp, operands[1]));
3209       emit_insn (gen_truncdfsf2 (operands[0], temp));
3210       DONE;
3211     }
3212 })
3213
3214 (define_insn "floatsisf2_ieee"
3215   [(set (match_operand:SF 0 "register_operand" "=f")
3216         (float:SF (match_operand:SI 1 "register_operand" "d")))]
3217   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3218   "cefbr\t%0,%1"
3219   [(set_attr "op_type" "RRE")
3220    (set_attr "type"    "itof" )])
3221
3222 ;
3223 ; truncdfsf2 instruction pattern(s).
3224 ;
3225
3226 (define_expand "truncdfsf2"
3227   [(set (match_operand:SF 0 "register_operand" "")
3228         (float_truncate:SF (match_operand:DF 1 "register_operand" "")))]
3229   "TARGET_HARD_FLOAT"
3230   "")
3231
3232 (define_insn "truncdfsf2_ieee"
3233   [(set (match_operand:SF 0 "register_operand" "=f")
3234         (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3235   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3236   "ledbr\t%0,%1"
3237   [(set_attr "op_type"  "RRE")])
3238
3239 (define_insn "truncdfsf2_ibm"
3240   [(set (match_operand:SF 0 "register_operand" "=f,f")
3241         (float_truncate:SF (match_operand:DF 1 "nonimmediate_operand" "f,R")))]
3242   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3243   "@
3244    ler\t%0,%1
3245    le\t%0,%1"
3246   [(set_attr "op_type"  "RR,RX")
3247    (set_attr "type"   "floads,floads")])
3248
3249 ;
3250 ; extendsfdf2 instruction pattern(s).
3251 ;
3252
3253 (define_expand "extendsfdf2"
3254   [(set (match_operand:DF 0 "register_operand" "")
3255         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
3256   "TARGET_HARD_FLOAT"
3257 {
3258   if (TARGET_IBM_FLOAT)
3259     {
3260       emit_insn (gen_extendsfdf2_ibm (operands[0], operands[1]));
3261       DONE;
3262     }
3263 })
3264
3265 (define_insn "extendsfdf2_ieee"
3266   [(set (match_operand:DF 0 "register_operand" "=f,f")
3267         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand"  "f,R")))]
3268   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3269   "@
3270    ldebr\t%0,%1
3271    ldeb\t%0,%1"
3272   [(set_attr "op_type"  "RRE,RXE")
3273    (set_attr "type"   "floads,floads")])
3274
3275 (define_insn "extendsfdf2_ibm"
3276   [(set (match_operand:DF 0 "register_operand" "=f,f")
3277         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R")))
3278    (clobber (reg:CC 33))]
3279   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3280   "@
3281    sdr\t%0,%0\;ler\t%0,%1
3282    sdr\t%0,%0\;le\t%0,%1"
3283   [(set_attr "length"   "4,6")
3284    (set_attr "type"     "floads,floads")])
3285
3286
3287 ;;
3288 ;; ARITHMETIC OPERATIONS
3289 ;;
3290 ;  arithmetic operations set the ConditionCode,
3291 ;  because of unpredictable Bits in Register for Halfword and Byte
3292 ;  the ConditionCode can be set wrong in operations for Halfword and Byte
3293
3294 ;;
3295 ;;- Add instructions.
3296 ;;
3297
3298 ;
3299 ; addti3 instruction pattern(s).
3300 ;
3301
3302 (define_insn_and_split "addti3"
3303   [(set (match_operand:TI 0 "register_operand" "=&d")
3304         (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
3305                  (match_operand:TI 2 "general_operand" "do") ) )
3306    (clobber (reg:CC 33))]
3307   "TARGET_64BIT"
3308   "#"
3309   "&& reload_completed"
3310   [(parallel
3311     [(set (reg:CCL1 33)
3312           (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
3313                         (match_dup 7)))
3314      (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
3315    (parallel
3316     [(set (match_dup 3) (plus:DI (plus:DI (match_dup 4) (match_dup 5))
3317                                  (ltu:DI (reg:CCL1 33) (const_int 0))))
3318      (clobber (reg:CC 33))])]
3319   "operands[3] = operand_subword (operands[0], 0, 0, TImode);
3320    operands[4] = operand_subword (operands[1], 0, 0, TImode);
3321    operands[5] = operand_subword (operands[2], 0, 0, TImode);
3322    operands[6] = operand_subword (operands[0], 1, 0, TImode);
3323    operands[7] = operand_subword (operands[1], 1, 0, TImode);
3324    operands[8] = operand_subword (operands[2], 1, 0, TImode);")
3325
3326 ;
3327 ; adddi3 instruction pattern(s).
3328 ;
3329
3330 (define_insn "*adddi3_sign"
3331   [(set (match_operand:DI 0 "register_operand" "=d,d")
3332         (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3333                  (match_operand:DI 1 "register_operand" "0,0")))
3334    (clobber (reg:CC 33))]
3335   "TARGET_64BIT"
3336   "@
3337    agfr\t%0,%2
3338    agf\t%0,%2"
3339   [(set_attr "op_type"  "RRE,RXY")])
3340
3341 (define_insn "*adddi3_zero_cc"
3342   [(set (reg 33)
3343         (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3344                           (match_operand:DI 1 "register_operand" "0,0"))
3345                  (const_int 0)))
3346    (set (match_operand:DI 0 "register_operand" "=d,d")
3347         (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
3348   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3349   "@
3350    algfr\t%0,%2
3351    algf\t%0,%2"
3352   [(set_attr "op_type"  "RRE,RXY")])
3353
3354 (define_insn "*adddi3_zero_cconly"
3355   [(set (reg 33)
3356         (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3357                           (match_operand:DI 1 "register_operand" "0,0"))
3358                  (const_int 0)))
3359    (clobber (match_scratch:DI 0 "=d,d"))]
3360   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3361   "@
3362    algfr\t%0,%2
3363    algf\t%0,%2"
3364   [(set_attr "op_type"  "RRE,RXY")])
3365
3366 (define_insn "*adddi3_zero"
3367   [(set (match_operand:DI 0 "register_operand" "=d,d")
3368         (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3369                  (match_operand:DI 1 "register_operand" "0,0")))
3370    (clobber (reg:CC 33))]
3371   "TARGET_64BIT"
3372   "@
3373    algfr\t%0,%2
3374    algf\t%0,%2"
3375   [(set_attr "op_type"  "RRE,RXY")])
3376
3377 (define_insn "*adddi3_imm_cc"
3378   [(set (reg 33)
3379         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "0")
3380                           (match_operand:DI 2 "const_int_operand" "K"))
3381                  (const_int 0)))
3382    (set (match_operand:DI 0 "register_operand" "=d")
3383         (plus:DI (match_dup 1) (match_dup 2)))]
3384   "TARGET_64BIT
3385    && s390_match_ccmode (insn, CCAmode)
3386    && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")"
3387   "aghi\t%0,%h2"
3388   [(set_attr "op_type"  "RI")])
3389
3390 (define_insn "*adddi3_carry1_cc"
3391   [(set (reg 33)
3392         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3393                           (match_operand:DI 2 "general_operand" "d,m"))
3394                  (match_dup 1)))
3395    (set (match_operand:DI 0 "register_operand" "=d,d")
3396         (plus:DI (match_dup 1) (match_dup 2)))]
3397   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3398   "@
3399    algr\t%0,%2
3400    alg\t%0,%2"
3401   [(set_attr "op_type"  "RRE,RXY")])
3402
3403 (define_insn "*adddi3_carry1_cconly"
3404   [(set (reg 33)
3405         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3406                           (match_operand:DI 2 "general_operand" "d,m"))
3407                  (match_dup 1)))
3408    (clobber (match_scratch:DI 0 "=d,d"))]
3409   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3410   "@
3411    algr\t%0,%2
3412    alg\t%0,%2"
3413   [(set_attr "op_type"  "RRE,RXY")])
3414
3415 (define_insn "*adddi3_carry2_cc"
3416   [(set (reg 33)
3417         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3418                           (match_operand:DI 2 "general_operand" "d,m"))
3419                  (match_dup 2)))
3420    (set (match_operand:DI 0 "register_operand" "=d,d")
3421         (plus:DI (match_dup 1) (match_dup 2)))]
3422   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3423   "@
3424    algr\t%0,%2
3425    alg\t%0,%2"
3426   [(set_attr "op_type"  "RRE,RXY")])
3427
3428 (define_insn "*adddi3_carry2_cconly"
3429   [(set (reg 33)
3430         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3431                           (match_operand:DI 2 "general_operand" "d,m"))
3432                  (match_dup 2)))
3433    (clobber (match_scratch:DI 0 "=d,d"))]
3434   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3435   "@
3436    algr\t%0,%2
3437    alg\t%0,%2"
3438   [(set_attr "op_type"  "RRE,RXY")])
3439
3440 (define_insn "*adddi3_cc"
3441   [(set (reg 33)
3442         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3443                           (match_operand:DI 2 "general_operand" "d,m"))
3444                  (const_int 0)))
3445    (set (match_operand:DI 0 "register_operand" "=d,d")
3446         (plus:DI (match_dup 1) (match_dup 2)))]
3447   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3448   "@
3449    algr\t%0,%2
3450    alg\t%0,%2"
3451   [(set_attr "op_type"  "RRE,RXY")])
3452
3453 (define_insn "*adddi3_cconly"
3454   [(set (reg 33)
3455         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3456                           (match_operand:DI 2 "general_operand" "d,m"))
3457                  (const_int 0)))
3458    (clobber (match_scratch:DI 0 "=d,d"))]
3459   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3460   "@
3461    algr\t%0,%2
3462    alg\t%0,%2"
3463   [(set_attr "op_type"  "RRE,RXY")])
3464
3465 (define_insn "*adddi3_cconly2"
3466   [(set (reg 33)
3467         (compare (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3468                  (neg:SI (match_operand:DI 2 "general_operand" "d,m"))))
3469    (clobber (match_scratch:DI 0 "=d,d"))]
3470   "s390_match_ccmode(insn, CCLmode) && TARGET_64BIT"
3471   "@
3472    algr\t%0,%2
3473    alg\t%0,%2"
3474   [(set_attr "op_type"  "RRE,RXY")])
3475
3476 (define_insn "*adddi3_64"
3477   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3478         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
3479                  (match_operand:DI 2 "general_operand" "d,K,m") ) )
3480    (clobber (reg:CC 33))]
3481   "TARGET_64BIT"
3482   "@
3483    agr\t%0,%2
3484    aghi\t%0,%h2
3485    ag\t%0,%2"
3486   [(set_attr "op_type"  "RRE,RI,RXY")])
3487
3488 (define_insn_and_split "*adddi3_31z"
3489   [(set (match_operand:DI 0 "register_operand" "=&d")
3490         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3491                  (match_operand:DI 2 "general_operand" "do") ) )
3492    (clobber (reg:CC 33))]
3493   "!TARGET_64BIT && TARGET_CPU_ZARCH"
3494   "#"
3495   "&& reload_completed"
3496   [(parallel
3497     [(set (reg:CCL1 33)
3498           (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3499                         (match_dup 7)))
3500      (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3501    (parallel
3502     [(set (match_dup 3) (plus:SI (plus:SI (match_dup 4) (match_dup 5))
3503                                  (ltu:SI (reg:CCL1 33) (const_int 0))))
3504      (clobber (reg:CC 33))])]
3505   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3506    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3507    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3508    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3509    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3510    operands[8] = operand_subword (operands[2], 1, 0, DImode);")
3511
3512 (define_insn_and_split "*adddi3_31"
3513   [(set (match_operand:DI 0 "register_operand" "=&d")
3514         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3515                  (match_operand:DI 2 "general_operand" "do") ) )
3516    (clobber (reg:CC 33))]
3517   "!TARGET_CPU_ZARCH"
3518   "#"
3519   "&& reload_completed"
3520   [(parallel
3521     [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
3522      (clobber (reg:CC 33))])
3523    (parallel
3524     [(set (reg:CCL1 33)
3525           (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3526                         (match_dup 7)))
3527      (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3528    (set (pc)
3529         (if_then_else (ltu (reg:CCL1 33) (const_int 0))
3530                       (pc)
3531                       (label_ref (match_dup 9))))
3532    (parallel
3533     [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
3534      (clobber (reg:CC 33))])
3535    (match_dup 9)]
3536   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3537    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3538    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3539    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3540    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3541    operands[8] = operand_subword (operands[2], 1, 0, DImode);
3542    operands[9] = gen_label_rtx ();")
3543
3544 (define_expand "adddi3"
3545   [(parallel
3546     [(set (match_operand:DI 0 "register_operand" "")
3547           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
3548                    (match_operand:DI 2 "general_operand" "")))
3549      (clobber (reg:CC 33))])]
3550   ""
3551   "")
3552
3553 ;
3554 ; addsi3 instruction pattern(s).
3555 ;
3556
3557 (define_insn "*addsi3_imm_cc"
3558   [(set (reg 33)
3559         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "0")
3560                           (match_operand:SI 2 "const_int_operand" "K"))
3561                  (const_int 0)))
3562    (set (match_operand:SI 0 "register_operand" "=d")
3563         (plus:SI (match_dup 1) (match_dup 2)))]
3564   "s390_match_ccmode (insn, CCAmode)
3565    && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")"
3566   "ahi\t%0,%h2"
3567   [(set_attr "op_type"  "RI")])
3568
3569 (define_insn "*addsi3_carry1_cc"
3570   [(set (reg 33)
3571         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3572                           (match_operand:SI 2 "general_operand" "d,R,T"))
3573                  (match_dup 1)))
3574    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3575         (plus:SI (match_dup 1) (match_dup 2)))]
3576   "s390_match_ccmode (insn, CCL1mode)"
3577   "@
3578    alr\t%0,%2
3579    al\t%0,%2
3580    aly\t%0,%2"
3581   [(set_attr "op_type"  "RR,RX,RXY")])
3582
3583 (define_insn "*addsi3_carry1_cconly"
3584   [(set (reg 33)
3585         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3586                           (match_operand:SI 2 "general_operand" "d,R,T"))
3587                  (match_dup 1)))
3588    (clobber (match_scratch:SI 0 "=d,d,d"))]
3589   "s390_match_ccmode (insn, CCL1mode)"
3590   "@
3591    alr\t%0,%2
3592    al\t%0,%2
3593    aly\t%0,%2"
3594   [(set_attr "op_type"  "RR,RX,RXY")])
3595
3596 (define_insn "*addsi3_carry2_cc"
3597   [(set (reg 33)
3598         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3599                           (match_operand:SI 2 "general_operand" "d,R,T"))
3600                  (match_dup 2)))
3601    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3602         (plus:SI (match_dup 1) (match_dup 2)))]
3603   "s390_match_ccmode (insn, CCL1mode)"
3604   "@
3605    alr\t%0,%2
3606    al\t%0,%2
3607    aly\t%0,%2"
3608   [(set_attr "op_type"  "RR,RX,RXY")])
3609
3610 (define_insn "*addsi3_carry2_cconly"
3611   [(set (reg 33)
3612         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3613                           (match_operand:SI 2 "general_operand" "d,R,T"))
3614                  (match_dup 2)))
3615    (clobber (match_scratch:SI 0 "=d,d,d"))]
3616   "s390_match_ccmode (insn, CCL1mode)"
3617   "@
3618    alr\t%0,%2
3619    al\t%0,%2
3620    aly\t%0,%2"
3621   [(set_attr "op_type"  "RR,RX,RXY")])
3622
3623 (define_insn "*addsi3_cc"
3624   [(set (reg 33)
3625         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3626                           (match_operand:SI 2 "general_operand" "d,R,T"))
3627                  (const_int 0)))
3628    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3629         (plus:SI (match_dup 1) (match_dup 2)))]
3630   "s390_match_ccmode (insn, CCLmode)"
3631   "@
3632    alr\t%0,%2
3633    al\t%0,%2
3634    aly\t%0,%2"
3635   [(set_attr "op_type"  "RR,RX,RXY")])
3636
3637 (define_insn "*addsi3_cconly"
3638   [(set (reg 33)
3639         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3640                           (match_operand:SI 2 "general_operand" "d,R,T"))
3641                  (const_int 0)))
3642    (clobber (match_scratch:SI 0 "=d,d,d"))]
3643   "s390_match_ccmode (insn, CCLmode)"
3644   "@
3645    alr\t%0,%2
3646    al\t%0,%2
3647    aly\t%0,%2"
3648   [(set_attr "op_type"  "RR,RX,RXY")])
3649
3650 (define_insn "*addsi3_cconly2"
3651   [(set (reg 33)
3652         (compare (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3653                  (neg:SI (match_operand:SI 2 "general_operand" "d,R,T"))))
3654    (clobber (match_scratch:SI 0 "=d,d,d"))]
3655   "s390_match_ccmode (insn, CCLmode)"
3656   "@
3657    alr\t%0,%2
3658    al\t%0,%2
3659    aly\t%0,%2"
3660   [(set_attr "op_type"  "RR,RX,RXY")])
3661
3662 (define_insn "*addsi3_sign"
3663   [(set (match_operand:SI 0 "register_operand" "=d,d")
3664         (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
3665                  (match_operand:SI 1 "register_operand" "0,0")))
3666    (clobber (reg:CC 33))]
3667   ""
3668   "@
3669    ah\t%0,%2
3670    ahy\t%0,%2"
3671   [(set_attr "op_type"  "RX,RXY")])
3672
3673 (define_insn "addsi3"
3674   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3675         (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
3676                  (match_operand:SI 2 "general_operand" "d,K,R,T")))
3677    (clobber (reg:CC 33))]
3678   ""
3679   "@
3680    ar\t%0,%2
3681    ahi\t%0,%h2
3682    a\t%0,%2
3683    ay\t%0,%2"
3684   [(set_attr "op_type"  "RR,RI,RX,RXY")])
3685
3686 ;
3687 ; adddf3 instruction pattern(s).
3688 ;
3689
3690 (define_expand "adddf3"
3691   [(parallel
3692     [(set (match_operand:DF 0 "register_operand" "=f,f")
3693           (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3694                    (match_operand:DF 2 "general_operand" "f,R")))
3695      (clobber (reg:CC 33))])]
3696   "TARGET_HARD_FLOAT"
3697   "")
3698
3699 (define_insn "*adddf3"
3700   [(set (match_operand:DF 0 "register_operand" "=f,f")
3701         (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3702                  (match_operand:DF 2 "general_operand" "f,R")))
3703    (clobber (reg:CC 33))]
3704   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3705   "@
3706    adbr\t%0,%2
3707    adb\t%0,%2"
3708   [(set_attr "op_type"  "RRE,RXE")
3709    (set_attr "type"     "fsimpd,fsimpd")])
3710
3711 (define_insn "*adddf3_cc"
3712   [(set (reg 33)
3713         (compare (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3714                           (match_operand:DF 2 "general_operand" "f,R"))
3715                  (match_operand:DF 3 "const0_operand" "")))
3716    (set (match_operand:DF 0 "register_operand" "=f,f")
3717         (plus:DF (match_dup 1) (match_dup 2)))]
3718   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3719   "@
3720    adbr\t%0,%2
3721    adb\t%0,%2"
3722   [(set_attr "op_type"  "RRE,RXE")
3723    (set_attr "type"     "fsimpd,fsimpd")])
3724
3725 (define_insn "*adddf3_cconly"
3726   [(set (reg 33)
3727         (compare (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3728                           (match_operand:DF 2 "general_operand" "f,R"))
3729                  (match_operand:DF 3 "const0_operand" "")))
3730    (clobber (match_scratch:DF 0 "=f,f"))]
3731   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3732   "@
3733   adbr\t%0,%2
3734   adb\t%0,%2"
3735   [(set_attr "op_type"  "RRE,RXE")
3736    (set_attr "type"     "fsimpd,fsimpd")])
3737
3738 (define_insn "*adddf3_ibm"
3739   [(set (match_operand:DF 0 "register_operand" "=f,f")
3740         (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3741                  (match_operand:DF 2 "general_operand" "f,R")))
3742    (clobber (reg:CC 33))]
3743   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3744   "@
3745    adr\t%0,%2
3746    ad\t%0,%2"
3747   [(set_attr "op_type"  "RR,RX")
3748    (set_attr "type"     "fsimpd,fsimpd")])
3749
3750 ;
3751 ; addsf3 instruction pattern(s).
3752 ;
3753
3754 (define_expand "addsf3"
3755   [(parallel
3756     [(set (match_operand:SF 0 "register_operand" "=f,f")
3757           (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3758                    (match_operand:SF 2 "general_operand" "f,R")))
3759      (clobber (reg:CC 33))])]
3760   "TARGET_HARD_FLOAT"
3761   "")
3762
3763 (define_insn "*addsf3"
3764   [(set (match_operand:SF 0 "register_operand" "=f,f")
3765         (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3766                  (match_operand:SF 2 "general_operand" "f,R")))
3767    (clobber (reg:CC 33))]
3768   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3769   "@
3770    aebr\t%0,%2
3771    aeb\t%0,%2"
3772   [(set_attr "op_type"  "RRE,RXE")
3773    (set_attr "type"     "fsimps,fsimps")])
3774
3775 (define_insn "*addsf3_cc"
3776   [(set (reg 33)
3777         (compare (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3778                           (match_operand:SF 2 "general_operand" "f,R"))
3779                  (match_operand:SF 3 "const0_operand" "")))
3780    (set (match_operand:SF 0 "register_operand" "=f,f")
3781         (plus:SF (match_dup 1) (match_dup 2)))]
3782   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3783   "@
3784    aebr\t%0,%2
3785    aeb\t%0,%2"
3786   [(set_attr "op_type"  "RRE,RXE")
3787    (set_attr "type"     "fsimps,fsimps")])
3788
3789 (define_insn "*addsf3_cconly"
3790   [(set (reg 33)
3791         (compare (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3792                           (match_operand:SF 2 "general_operand" "f,R"))
3793                  (match_operand:SF 3 "const0_operand" "")))
3794    (clobber (match_scratch:SF 0 "=f,f"))]
3795   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3796   "@
3797    aebr\t%0,%2
3798    aeb\t%0,%2"
3799   [(set_attr "op_type"  "RRE,RXE")
3800    (set_attr "type"     "fsimps,fsimps")])
3801
3802 (define_insn "*addsf3"
3803   [(set (match_operand:SF 0 "register_operand" "=f,f")
3804         (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3805                  (match_operand:SF 2 "general_operand" "f,R")))
3806    (clobber (reg:CC 33))]
3807   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3808   "@
3809    aer\t%0,%2
3810    ae\t%0,%2"
3811   [(set_attr "op_type"  "RR,RX")
3812    (set_attr "type"     "fsimps,fsimps")])
3813
3814
3815 ;;
3816 ;;- Subtract instructions.
3817 ;;
3818
3819 ;
3820 ; subti3 instruction pattern(s).
3821 ;
3822
3823 (define_insn_and_split "subti3"
3824   [(set (match_operand:TI 0 "register_operand" "=&d")
3825         (minus:TI (match_operand:TI 1 "register_operand" "0")
3826                   (match_operand:TI 2 "general_operand" "do") ) )
3827    (clobber (reg:CC 33))]
3828   "TARGET_64BIT"
3829   "#"
3830   "&& reload_completed"
3831   [(parallel
3832     [(set (reg:CCL2 33)
3833           (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
3834                         (match_dup 7)))
3835      (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
3836    (parallel
3837     [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
3838                                   (gtu:DI (reg:CCL2 33) (const_int 0))))
3839      (clobber (reg:CC 33))])]
3840   "operands[3] = operand_subword (operands[0], 0, 0, TImode);
3841    operands[4] = operand_subword (operands[1], 0, 0, TImode);
3842    operands[5] = operand_subword (operands[2], 0, 0, TImode);
3843    operands[6] = operand_subword (operands[0], 1, 0, TImode);
3844    operands[7] = operand_subword (operands[1], 1, 0, TImode);
3845    operands[8] = operand_subword (operands[2], 1, 0, TImode);")
3846
3847 ;
3848 ; subdi3 instruction pattern(s).
3849 ;
3850
3851 (define_insn "*subdi3_sign"
3852   [(set (match_operand:DI 0 "register_operand" "=d,d")
3853         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3854                   (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3855    (clobber (reg:CC 33))]
3856   "TARGET_64BIT"
3857   "@
3858    sgfr\t%0,%2
3859    sgf\t%0,%2"
3860   [(set_attr "op_type"  "RRE,RXY")])
3861
3862 (define_insn "*subdi3_zero_cc"
3863   [(set (reg 33)
3864         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3865                            (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3866                  (const_int 0)))
3867    (set (match_operand:DI 0 "register_operand" "=d,d")
3868         (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
3869   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3870   "@
3871    slgfr\t%0,%2
3872    slgf\t%0,%2"
3873   [(set_attr "op_type"  "RRE,RXY")])
3874
3875 (define_insn "*subdi3_zero_cconly"
3876   [(set (reg 33)
3877         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3878                            (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3879                  (const_int 0)))
3880    (clobber (match_scratch:DI 0 "=d,d"))]
3881   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3882   "@
3883    slgfr\t%0,%2
3884    slgf\t%0,%2"
3885   [(set_attr "op_type"  "RRE,RXY")])
3886
3887 (define_insn "*subdi3_zero"
3888   [(set (match_operand:DI 0 "register_operand" "=d,d")
3889         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3890                   (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3891    (clobber (reg:CC 33))]
3892   "TARGET_64BIT"
3893   "@
3894    slgfr\t%0,%2
3895    slgf\t%0,%2"
3896   [(set_attr "op_type"  "RRE,RXY")])
3897
3898 (define_insn "*subdi3_borrow_cc"
3899   [(set (reg 33)
3900         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3901                            (match_operand:DI 2 "general_operand" "d,m"))
3902                  (match_dup 1)))
3903    (set (match_operand:DI 0 "register_operand" "=d,d")
3904         (minus:DI (match_dup 1) (match_dup 2)))]
3905   "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3906   "@
3907    slgr\t%0,%2
3908    slg\t%0,%2"
3909   [(set_attr "op_type"  "RRE,RXY")])
3910
3911 (define_insn "*subdi3_borrow_cconly"
3912   [(set (reg 33)
3913         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3914                            (match_operand:DI 2 "general_operand" "d,m"))
3915                  (match_dup 1)))
3916    (clobber (match_scratch:DI 0 "=d,d"))]
3917   "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3918   "@
3919    slgr\t%0,%2
3920    slg\t%0,%2"
3921   [(set_attr "op_type"  "RRE,RXY")])
3922
3923 (define_insn "*subdi3_cc"
3924   [(set (reg 33)
3925         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3926                            (match_operand:DI 2 "general_operand" "d,m"))
3927                  (const_int 0)))
3928    (set (match_operand:DI 0 "register_operand" "=d,d")
3929         (minus:DI (match_dup 1) (match_dup 2)))]
3930   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3931   "@
3932    slgr\t%0,%2
3933    slg\t%0,%2"
3934   [(set_attr "op_type"  "RRE,RXY")])
3935
3936 (define_insn "*subdi3_cc2"
3937   [(set (reg 33)
3938         (compare (match_operand:DI 1 "register_operand" "0,0")
3939                  (match_operand:DI 2 "general_operand" "d,m")))
3940    (set (match_operand:DI 0 "register_operand" "=d,d")
3941         (minus:DI (match_dup 1) (match_dup 2)))]
3942   "s390_match_ccmode (insn, CCL3mode) && TARGET_64BIT"
3943   "@
3944    slgr\t%0,%2
3945    slg\t%0,%2"
3946   [(set_attr "op_type"  "RRE,RXY")])
3947
3948 (define_insn "*subdi3_cconly"
3949   [(set (reg 33)
3950         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3951                            (match_operand:DI 2 "general_operand" "d,m"))
3952                  (const_int 0)))
3953    (clobber (match_scratch:DI 0 "=d,d"))]
3954   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3955   "@
3956    slgr\t%0,%2
3957    slg\t%0,%2"
3958   [(set_attr "op_type"  "RRE,RXY")])
3959
3960 (define_insn "*subdi3_cconly2"
3961   [(set (reg 33)
3962         (compare (match_operand:DI 1 "register_operand" "0,0")
3963                  (match_operand:DI 2 "general_operand" "d,m")))
3964    (clobber (match_scratch:DI 0 "=d,d"))]
3965   "s390_match_ccmode (insn, CCL3mode) && TARGET_64BIT"
3966   "@
3967    slgr\t%0,%2
3968    slg\t%0,%2"
3969   [(set_attr "op_type"  "RRE,RXY")])
3970
3971 (define_insn "*subdi3_64"
3972   [(set (match_operand:DI 0 "register_operand" "=d,d")
3973         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3974                   (match_operand:DI 2 "general_operand" "d,m") ) )
3975    (clobber (reg:CC 33))]
3976   "TARGET_64BIT"
3977   "@
3978    sgr\t%0,%2
3979    sg\t%0,%2"
3980   [(set_attr "op_type"  "RRE,RRE")])
3981
3982 (define_insn_and_split "*subdi3_31z"
3983   [(set (match_operand:DI 0 "register_operand" "=&d")
3984         (minus:DI (match_operand:DI 1 "register_operand" "0")
3985                   (match_operand:DI 2 "general_operand" "do") ) )
3986    (clobber (reg:CC 33))]
3987   "!TARGET_64BIT && TARGET_CPU_ZARCH"
3988   "#"
3989   "&& reload_completed"
3990   [(parallel
3991     [(set (reg:CCL2 33)
3992           (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
3993                         (match_dup 7)))
3994      (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
3995    (parallel
3996     [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
3997                                   (gtu:SI (reg:CCL2 33) (const_int 0))))
3998      (clobber (reg:CC 33))])]
3999   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4000    operands[4] = operand_subword (operands[1], 0, 0, DImode);
4001    operands[5] = operand_subword (operands[2], 0, 0, DImode);
4002    operands[6] = operand_subword (operands[0], 1, 0, DImode);
4003    operands[7] = operand_subword (operands[1], 1, 0, DImode);
4004    operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4005
4006 (define_insn_and_split "*subdi3_31"
4007   [(set (match_operand:DI 0 "register_operand" "=&d")
4008         (minus:DI (match_operand:DI 1 "register_operand" "0")
4009                   (match_operand:DI 2 "general_operand" "do") ) )
4010    (clobber (reg:CC 33))]
4011   "!TARGET_CPU_ZARCH"
4012   "#"
4013   "&& reload_completed"
4014   [(parallel
4015     [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
4016      (clobber (reg:CC 33))])
4017    (parallel
4018     [(set (reg:CCL2 33)
4019           (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4020                         (match_dup 7)))
4021      (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4022    (set (pc)
4023         (if_then_else (gtu (reg:CCL2 33) (const_int 0))
4024                       (pc)
4025                       (label_ref (match_dup 9))))
4026    (parallel
4027     [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
4028      (clobber (reg:CC 33))])
4029    (match_dup 9)]
4030   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4031    operands[4] = operand_subword (operands[1], 0, 0, DImode);
4032    operands[5] = operand_subword (operands[2], 0, 0, DImode);
4033    operands[6] = operand_subword (operands[0], 1, 0, DImode);
4034    operands[7] = operand_subword (operands[1], 1, 0, DImode);
4035    operands[8] = operand_subword (operands[2], 1, 0, DImode);
4036    operands[9] = gen_label_rtx ();")
4037
4038 (define_expand "subdi3"
4039   [(parallel
4040     [(set (match_operand:DI 0 "register_operand" "")
4041           (minus:DI (match_operand:DI 1 "register_operand" "")
4042                     (match_operand:DI 2 "general_operand" "")))
4043      (clobber (reg:CC 33))])]
4044   ""
4045   "")
4046
4047 ;
4048 ; subsi3 instruction pattern(s).
4049 ;
4050
4051 (define_insn "*subsi3_borrow_cc"
4052   [(set (reg 33)
4053         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4054                            (match_operand:SI 2 "general_operand" "d,R,T"))
4055                  (match_dup 1)))
4056    (set (match_operand:SI 0 "register_operand" "=d,d,d")
4057         (minus:SI (match_dup 1) (match_dup 2)))]
4058   "s390_match_ccmode (insn, CCL2mode)"
4059   "@
4060    slr\t%0,%2
4061    sl\t%0,%2
4062    sly\t%0,%2"
4063   [(set_attr "op_type"  "RR,RX,RXY")])
4064
4065 (define_insn "*subsi3_borrow_cconly"
4066   [(set (reg 33)
4067         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4068                            (match_operand:SI 2 "general_operand" "d,R,T"))
4069                  (match_dup 1)))
4070    (clobber (match_scratch:SI 0 "=d,d,d"))]
4071   "s390_match_ccmode (insn, CCL2mode)"
4072   "@
4073    slr\t%0,%2
4074    sl\t%0,%2
4075    sly\t%0,%2"
4076   [(set_attr "op_type"  "RR,RX,RXY")])
4077
4078 (define_insn "*subsi3_cc"
4079   [(set (reg 33)
4080         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4081                            (match_operand:SI 2 "general_operand" "d,R,T"))
4082                  (const_int 0)))
4083    (set (match_operand:SI 0 "register_operand" "=d,d,d")
4084         (minus:SI (match_dup 1) (match_dup 2)))]
4085   "s390_match_ccmode (insn, CCLmode)"
4086   "@
4087    slr\t%0,%2
4088    sl\t%0,%2
4089    sly\t%0,%2"
4090   [(set_attr "op_type"  "RR,RX,RXY")])
4091
4092 (define_insn "*subsi3_cc2"
4093   [(set (reg 33)
4094         (compare (match_operand:SI 1 "register_operand" "0,0,0")
4095                  (match_operand:SI 2 "general_operand" "d,R,T")))
4096    (set (match_operand:SI 0 "register_operand" "=d,d,d")
4097         (minus:SI (match_dup 1) (match_dup 2)))]
4098   "s390_match_ccmode (insn, CCL3mode)"
4099   "@
4100    slr\t%0,%2
4101    sl\t%0,%2
4102    sly\t%0,%2"
4103   [(set_attr "op_type"  "RR,RX,RXY")])
4104
4105 (define_insn "*subsi3_cconly"
4106   [(set (reg 33)
4107         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4108                            (match_operand:SI 2 "general_operand" "d,R,T"))
4109                  (const_int 0)))
4110    (clobber (match_scratch:SI 0 "=d,d,d"))]
4111   "s390_match_ccmode (insn, CCLmode)"
4112   "@
4113    slr\t%0,%2
4114    sl\t%0,%2
4115    sly\t%0,%2"
4116   [(set_attr "op_type"  "RR,RX,RXY")])
4117
4118 (define_insn "*subsi3_cconly2"
4119   [(set (reg 33)
4120         (compare (match_operand:SI 1 "register_operand" "0,0,0")
4121                  (match_operand:SI 2 "general_operand" "d,R,T")))
4122    (clobber (match_scratch:SI 0 "=d,d,d"))]
4123   "s390_match_ccmode (insn, CCL3mode)"
4124   "@
4125    slr\t%0,%2
4126    sl\t%0,%2
4127    sly\t%0,%2"
4128   [(set_attr "op_type"  "RR,RX,RXY")])
4129
4130 (define_insn "*subsi3_sign"
4131   [(set (match_operand:SI 0 "register_operand" "=d,d")
4132         (minus:SI (match_operand:SI 1 "register_operand" "0,0")
4133                   (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
4134    (clobber (reg:CC 33))]
4135   ""
4136   "@
4137    sh\t%0,%2
4138    shy\t%0,%2"
4139   [(set_attr "op_type"  "RX,RXY")])
4140
4141 (define_insn "subsi3"
4142   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
4143         (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4144                   (match_operand:SI 2 "general_operand" "d,R,T")))
4145    (clobber (reg:CC 33))]
4146   ""
4147   "@
4148    sr\t%0,%2
4149    s\t%0,%2
4150    sy\t%0,%2"
4151   [(set_attr "op_type"  "RR,RX,RXY")])
4152
4153
4154 ;
4155 ; subdf3 instruction pattern(s).
4156 ;
4157
4158 (define_expand "subdf3"
4159   [(parallel
4160     [(set (match_operand:DF 0 "register_operand" "=f,f")
4161           (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4162                     (match_operand:DF 2 "general_operand" "f,R")))
4163      (clobber (reg:CC 33))])]
4164   "TARGET_HARD_FLOAT"
4165   "")
4166
4167 (define_insn "*subdf3"
4168   [(set (match_operand:DF 0 "register_operand" "=f,f")
4169         (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4170                   (match_operand:DF 2 "general_operand" "f,R")))
4171    (clobber (reg:CC 33))]
4172   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4173   "@
4174    sdbr\t%0,%2
4175    sdb\t%0,%2"
4176   [(set_attr "op_type"  "RRE,RXE")
4177    (set_attr "type"     "fsimpd,fsimpd")])
4178
4179 (define_insn "*subdf3_cc"
4180   [(set (reg 33)
4181         (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")
4182                            (match_operand:DF 2 "general_operand" "f,R"))
4183                  (match_operand:DF 3 "const0_operand" "")))
4184    (set (match_operand:DF 0 "register_operand" "=f,f")
4185         (minus:DF (match_dup 1) (match_dup 2)))]
4186   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4187   "@
4188    sdbr\t%0,%2
4189    sdb\t%0,%2"
4190   [(set_attr "op_type"  "RRE,RXE")
4191    (set_attr "type"     "fsimpd,fsimpd")])
4192
4193 (define_insn "*subdf3_cconly"
4194   [(set (reg 33)
4195         (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "0,0")
4196                            (match_operand:DF 2 "general_operand" "f,R"))
4197                  (match_operand:DF 3 "const0_operand" "")))
4198    (clobber (match_scratch:DF 0 "=f,f"))]
4199   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4200   "@
4201    sdbr\t%0,%2
4202    sdb\t%0,%2"
4203   [(set_attr "op_type"  "RRE,RXE")
4204    (set_attr "type"     "fsimpd,fsimpd")])
4205
4206 (define_insn "*subdf3_ibm"
4207   [(set (match_operand:DF 0 "register_operand" "=f,f")
4208         (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4209                   (match_operand:DF 2 "general_operand" "f,R")))
4210    (clobber (reg:CC 33))]
4211   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4212   "@
4213    sdr\t%0,%2
4214    sd\t%0,%2"
4215   [(set_attr "op_type"  "RR,RX")
4216    (set_attr "type"     "fsimpd,fsimpd")])
4217
4218 ;
4219 ; subsf3 instruction pattern(s).
4220 ;
4221
4222 (define_expand "subsf3"
4223   [(parallel
4224     [(set (match_operand:SF 0 "register_operand" "=f,f")
4225           (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4226                     (match_operand:SF 2 "general_operand" "f,R")))
4227      (clobber (reg:CC 33))])]
4228   "TARGET_HARD_FLOAT"
4229   "")
4230
4231 (define_insn "*subsf3"
4232   [(set (match_operand:SF 0 "register_operand" "=f,f")
4233         (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4234                   (match_operand:SF 2 "general_operand" "f,R")))
4235    (clobber (reg:CC 33))]
4236   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4237   "@
4238    sebr\t%0,%2
4239    seb\t%0,%2"
4240   [(set_attr "op_type"  "RRE,RXE")
4241    (set_attr "type"     "fsimps,fsimps")])
4242
4243 (define_insn "*subsf3_cc"
4244   [(set (reg 33)
4245         (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")
4246                            (match_operand:SF 2 "general_operand" "f,R"))
4247                  (match_operand:SF 3 "const0_operand" "")))
4248    (set (match_operand:SF 0 "register_operand" "=f,f")
4249         (minus:SF (match_dup 1) (match_dup 2)))]
4250   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4251   "@
4252    sebr\t%0,%2
4253    seb\t%0,%2"
4254   [(set_attr "op_type"  "RRE,RXE")
4255    (set_attr "type"     "fsimps,fsimps")])
4256
4257 (define_insn "*subsf3_cconly"
4258   [(set (reg 33)
4259         (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "0,0")
4260                            (match_operand:SF 2 "general_operand" "f,R"))
4261                  (match_operand:SF 3 "const0_operand" "")))
4262    (clobber (match_scratch:SF 0 "=f,f"))]
4263   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4264   "@
4265    sebr\t%0,%2
4266    seb\t%0,%2"
4267   [(set_attr "op_type"  "RRE,RXE")
4268    (set_attr "type"     "fsimps,fsimps")])
4269
4270 (define_insn "*subsf3_ibm"
4271   [(set (match_operand:SF 0 "register_operand" "=f,f")
4272         (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4273                   (match_operand:SF 2 "general_operand" "f,R")))
4274    (clobber (reg:CC 33))]
4275   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4276   "@
4277    ser\t%0,%2
4278    se\t%0,%2"
4279   [(set_attr "op_type"  "RR,RX")
4280    (set_attr "type"     "fsimps,fsimps")])
4281
4282
4283 ;;
4284 ;;- Conditional add/subtract instructions.
4285 ;;
4286
4287 ;
4288 ; adddicc instruction pattern(s).
4289 ;
4290
4291 (define_insn "*adddi3_alc_cc"
4292   [(set (reg 33)
4293         (compare
4294           (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4295                             (match_operand:DI 2 "general_operand" "d,m"))
4296                    (match_operand:DI 3 "s390_alc_comparison" ""))
4297           (const_int 0)))
4298    (set (match_operand:DI 0 "register_operand" "=d,d")
4299         (plus:DI (plus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4300   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4301   "@
4302    alcgr\t%0,%2
4303    alcg\t%0,%2"
4304   [(set_attr "op_type"  "RRE,RXY")])
4305
4306 (define_insn "*adddi3_alc"
4307   [(set (match_operand:DI 0 "register_operand" "=d,d")
4308         (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4309                           (match_operand:DI 2 "general_operand" "d,m"))
4310                  (match_operand:DI 3 "s390_alc_comparison" "")))
4311    (clobber (reg:CC 33))]
4312   "TARGET_64BIT"
4313   "@
4314    alcgr\t%0,%2
4315    alcg\t%0,%2"
4316   [(set_attr "op_type"  "RRE,RXY")])
4317
4318 (define_insn "*subdi3_slb_cc"
4319   [(set (reg 33)
4320         (compare
4321           (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4322                               (match_operand:DI 2 "general_operand" "d,m"))
4323                     (match_operand:DI 3 "s390_slb_comparison" ""))
4324           (const_int 0)))
4325    (set (match_operand:DI 0 "register_operand" "=d,d")
4326         (minus:DI (minus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4327   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4328   "@
4329    slbgr\t%0,%2
4330    slbg\t%0,%2"
4331   [(set_attr "op_type"  "RRE,RXY")])
4332
4333 (define_insn "*subdi3_slb"
4334   [(set (match_operand:DI 0 "register_operand" "=d,d")
4335         (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4336                             (match_operand:DI 2 "general_operand" "d,m"))
4337                   (match_operand:DI 3 "s390_slb_comparison" "")))
4338    (clobber (reg:CC 33))]
4339   "TARGET_64BIT"
4340   "@
4341    slbgr\t%0,%2
4342    slbg\t%0,%2"
4343   [(set_attr "op_type"  "RRE,RXY")])
4344
4345 (define_expand "adddicc"
4346   [(match_operand:DI 0 "register_operand" "")
4347    (match_operand 1 "comparison_operator" "")
4348    (match_operand:DI 2 "register_operand" "")
4349    (match_operand:DI 3 "const_int_operand" "")]
4350   "TARGET_64BIT"
4351   "if (!s390_expand_addcc (GET_CODE (operands[1]), 
4352                            s390_compare_op0, s390_compare_op1, 
4353                            operands[0], operands[2], 
4354                            operands[3])) FAIL; DONE;")
4355
4356 ;
4357 ; addsicc instruction pattern(s).
4358 ;
4359
4360 (define_insn "*addsi3_alc_cc"
4361   [(set (reg 33)
4362         (compare
4363           (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4364                             (match_operand:SI 2 "general_operand" "d,m"))
4365                    (match_operand:SI 3 "s390_alc_comparison" ""))
4366           (const_int 0)))
4367    (set (match_operand:SI 0 "register_operand" "=d,d")
4368         (plus:SI (plus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4369   "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4370   "@
4371    alcr\t%0,%2
4372    alc\t%0,%2"
4373   [(set_attr "op_type"  "RRE,RXY")])
4374
4375 (define_insn "*addsi3_alc"
4376   [(set (match_operand:SI 0 "register_operand" "=d,d")
4377         (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4378                           (match_operand:SI 2 "general_operand" "d,m"))
4379                  (match_operand:SI 3 "s390_alc_comparison" "")))
4380    (clobber (reg:CC 33))]
4381   "TARGET_CPU_ZARCH"
4382   "@
4383    alcr\t%0,%2
4384    alc\t%0,%2"
4385   [(set_attr "op_type"  "RRE,RXY")])
4386
4387 (define_insn "*subsi3_slb_cc"
4388   [(set (reg 33)
4389         (compare
4390           (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4391                               (match_operand:SI 2 "general_operand" "d,m"))
4392                     (match_operand:SI 3 "s390_slb_comparison" ""))
4393           (const_int 0)))
4394    (set (match_operand:SI 0 "register_operand" "=d,d")
4395         (minus:SI (minus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4396   "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
4397   "@
4398    slbr\t%0,%2
4399    slb\t%0,%2"
4400   [(set_attr "op_type"  "RRE,RXY")])
4401
4402 (define_insn "*subsi3_slb"
4403   [(set (match_operand:SI 0 "register_operand" "=d,d")
4404         (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4405                             (match_operand:SI 2 "general_operand" "d,m"))
4406                   (match_operand:SI 3 "s390_slb_comparison" "")))
4407    (clobber (reg:CC 33))]
4408   "TARGET_CPU_ZARCH"
4409   "@
4410    slbr\t%0,%2
4411    slb\t%0,%2"
4412   [(set_attr "op_type"  "RRE,RXY")])
4413
4414 (define_expand "addsicc"
4415   [(match_operand:SI 0 "register_operand" "")
4416    (match_operand 1 "comparison_operator" "")
4417    (match_operand:SI 2 "register_operand" "")
4418    (match_operand:SI 3 "const_int_operand" "")]
4419   "TARGET_CPU_ZARCH"
4420   "if (!s390_expand_addcc (GET_CODE (operands[1]), 
4421                            s390_compare_op0, s390_compare_op1, 
4422                            operands[0], operands[2], 
4423                            operands[3])) FAIL; DONE;")
4424
4425 ;
4426 ; scond instruction pattern(s).
4427 ;
4428
4429 (define_insn_and_split "*sconddi"
4430   [(set (match_operand:DI 0 "register_operand" "=&d")
4431         (match_operand:DI 1 "s390_alc_comparison" ""))
4432    (clobber (reg:CC 33))]
4433   "TARGET_64BIT"
4434   "#"
4435   "&& reload_completed"
4436   [(set (match_dup 0) (const_int 0))
4437    (parallel
4438     [(set (match_dup 0) (plus:DI (plus:DI (match_dup 0) (match_dup 0))
4439                                  (match_dup 1)))
4440      (clobber (reg:CC 33))])]
4441   "")
4442
4443 (define_insn_and_split "*scondsi"
4444   [(set (match_operand:SI 0 "register_operand" "=&d")
4445         (match_operand:SI 1 "s390_alc_comparison" ""))
4446    (clobber (reg:CC 33))]
4447   "TARGET_CPU_ZARCH"
4448   "#"
4449   "&& reload_completed"
4450   [(set (match_dup 0) (const_int 0))
4451    (parallel
4452     [(set (match_dup 0) (plus:SI (plus:SI (match_dup 0) (match_dup 0))
4453                                  (match_dup 1)))
4454      (clobber (reg:CC 33))])]
4455   "")
4456
4457 (define_insn_and_split "*sconddi_neg"
4458   [(set (match_operand:DI 0 "register_operand" "=&d")
4459         (match_operand:DI 1 "s390_slb_comparison" ""))
4460    (clobber (reg:CC 33))]
4461   "TARGET_64BIT"
4462   "#"
4463   "&& reload_completed"
4464   [(set (match_dup 0) (const_int 0))
4465    (parallel
4466     [(set (match_dup 0) (minus:DI (minus:DI (match_dup 0) (match_dup 0))
4467                                   (match_dup 1)))
4468      (clobber (reg:CC 33))])
4469    (parallel
4470     [(set (match_dup 0) (neg:DI (match_dup 0)))
4471      (clobber (reg:CC 33))])]
4472   "")
4473
4474 (define_insn_and_split "*scondsi_neg"
4475   [(set (match_operand:SI 0 "register_operand" "=&d")
4476         (match_operand:SI 1 "s390_slb_comparison" ""))
4477    (clobber (reg:CC 33))]
4478   "TARGET_CPU_ZARCH"
4479   "#"
4480   "&& reload_completed"
4481   [(set (match_dup 0) (const_int 0))
4482    (parallel
4483     [(set (match_dup 0) (minus:SI (minus:SI (match_dup 0) (match_dup 0))
4484                                   (match_dup 1)))
4485      (clobber (reg:CC 33))])
4486    (parallel
4487     [(set (match_dup 0) (neg:SI (match_dup 0)))
4488      (clobber (reg:CC 33))])]
4489   "")
4490
4491 (define_expand "sltu"
4492   [(match_operand:SI 0 "register_operand" "")]
4493   "TARGET_CPU_ZARCH"
4494   "if (!s390_expand_addcc (LTU, s390_compare_op0, s390_compare_op1,
4495                            operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4496
4497 (define_expand "sgtu"
4498   [(match_operand:SI 0 "register_operand" "")]
4499   "TARGET_CPU_ZARCH"
4500   "if (!s390_expand_addcc (GTU, s390_compare_op0, s390_compare_op1,
4501                            operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4502
4503 (define_expand "sleu"
4504   [(match_operand:SI 0 "register_operand" "")]
4505   "TARGET_CPU_ZARCH"
4506   "if (!s390_expand_addcc (LEU, s390_compare_op0, s390_compare_op1,
4507                            operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4508
4509 (define_expand "sgeu"
4510   [(match_operand:SI 0 "register_operand" "")]
4511   "TARGET_CPU_ZARCH"
4512   "if (!s390_expand_addcc (GEU, s390_compare_op0, s390_compare_op1,
4513                            operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
4514
4515
4516 ;;
4517 ;;- Multiply instructions.
4518 ;;
4519
4520 ;
4521 ; muldi3 instruction pattern(s).
4522 ;
4523
4524 (define_insn "*muldi3_sign"
4525   [(set (match_operand:DI 0 "register_operand" "=d,d")
4526         (mult:DI (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m"))
4527                  (match_operand:DI 1 "register_operand" "0,0")))]
4528   "TARGET_64BIT"
4529   "@
4530    msgfr\t%0,%2
4531    msgf\t%0,%2"
4532   [(set_attr "op_type"  "RRE,RXY")
4533    (set_attr "type"     "imul")])
4534
4535 (define_insn "muldi3"
4536   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4537         (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
4538                  (match_operand:DI 2 "general_operand" "d,K,m")))]
4539   "TARGET_64BIT"
4540   "@
4541    msgr\t%0,%2
4542    mghi\t%0,%h2
4543    msg\t%0,%2"
4544   [(set_attr "op_type"  "RRE,RI,RXY")
4545    (set_attr "type"     "imul")])
4546
4547 ;
4548 ; mulsi3 instruction pattern(s).
4549 ;
4550
4551 (define_insn "*mulsi3_sign"
4552   [(set (match_operand:SI 0 "register_operand" "=d")
4553         (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R"))
4554                  (match_operand:SI 1 "register_operand" "0")))]
4555   ""
4556   "mh\t%0,%2"
4557   [(set_attr "op_type"  "RX")
4558    (set_attr "type"     "imul")])
4559
4560 (define_insn "mulsi3"
4561   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4562         (mult:SI  (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
4563                   (match_operand:SI 2 "general_operand" "d,K,R,T")))]
4564   ""
4565   "@
4566    msr\t%0,%2
4567    mhi\t%0,%h2
4568    ms\t%0,%2
4569    msy\t%0,%2"
4570   [(set_attr "op_type"  "RRE,RI,RX,RXY")
4571    (set_attr "type"     "imul")])
4572
4573 ;
4574 ; mulsidi3 instruction pattern(s).
4575 ;
4576
4577 (define_insn "mulsidi3"
4578   [(set (match_operand:DI 0 "register_operand" "=d,d")
4579         (mult:DI (sign_extend:DI
4580                    (match_operand:SI 1 "register_operand" "%0,0"))
4581                  (sign_extend:DI
4582                    (match_operand:SI 2 "nonimmediate_operand" "d,R"))))]
4583   "!TARGET_64BIT"
4584   "@
4585    mr\t%0,%2
4586    m\t%0,%2"
4587   [(set_attr "op_type"  "RR,RX")
4588    (set_attr "type"     "imul")])
4589
4590 ;
4591 ; umulsidi3 instruction pattern(s).
4592 ;
4593
4594 (define_insn "umulsidi3"
4595   [(set (match_operand:DI 0 "register_operand" "=d,d")
4596         (mult:DI (zero_extend:DI
4597                    (match_operand:SI 1 "register_operand" "%0,0"))
4598                  (zero_extend:DI
4599                    (match_operand:SI 2 "nonimmediate_operand" "d,m"))))]
4600   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4601   "@
4602    mlr\t%0,%2
4603    ml\t%0,%2"
4604   [(set_attr "op_type"  "RRE,RXY")
4605    (set_attr "type"     "imul")])
4606
4607 ;
4608 ; muldf3 instruction pattern(s).
4609 ;
4610
4611 (define_expand "muldf3"
4612   [(set (match_operand:DF 0 "register_operand" "=f,f")
4613         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4614                  (match_operand:DF 2 "general_operand" "f,R")))]
4615   "TARGET_HARD_FLOAT"
4616   "")
4617
4618 (define_insn "*muldf3"
4619   [(set (match_operand:DF 0 "register_operand" "=f,f")
4620         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4621                  (match_operand:DF 2 "general_operand" "f,R")))]
4622   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4623   "@
4624    mdbr\t%0,%2
4625    mdb\t%0,%2"
4626   [(set_attr "op_type"  "RRE,RXE")
4627    (set_attr "type"     "fmuld")])
4628
4629 (define_insn "*muldf3_ibm"
4630   [(set (match_operand:DF 0 "register_operand" "=f,f")
4631         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4632                  (match_operand:DF 2 "general_operand" "f,R")))]
4633   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4634   "@
4635    mdr\t%0,%2
4636    md\t%0,%2"
4637   [(set_attr "op_type"  "RR,RX")
4638    (set_attr "type"    "fmuld")])
4639
4640 (define_insn "*fmadddf"
4641   [(set (match_operand:DF 0 "register_operand" "=f,f")
4642         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "%f,f")
4643                           (match_operand:DF 2 "nonimmediate_operand"  "f,R"))
4644                  (match_operand:DF 3 "register_operand" "0,0")))]
4645   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4646   "@
4647    madbr\t%0,%1,%2
4648    madb\t%0,%1,%2"
4649   [(set_attr "op_type"  "RRE,RXE")
4650    (set_attr "type" "fmuld")])
4651
4652 (define_insn "*fmsubdf"
4653   [(set (match_operand:DF 0 "register_operand" "=f,f")
4654         (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "f,f")
4655                            (match_operand:DF 2 "nonimmediate_operand"  "f,R"))
4656                  (match_operand:DF 3 "register_operand" "0,0")))]
4657   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4658   "@
4659    msdbr\t%0,%1,%2
4660    msdb\t%0,%1,%2"
4661   [(set_attr "op_type"  "RRE,RXE")
4662    (set_attr "type" "fmuld")])
4663
4664 ;
4665 ; mulsf3 instruction pattern(s).
4666 ;
4667
4668 (define_expand "mulsf3"
4669   [(set (match_operand:SF 0 "register_operand" "=f,f")
4670         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4671                  (match_operand:SF 2 "general_operand" "f,R")))]
4672   "TARGET_HARD_FLOAT"
4673   "")
4674
4675 (define_insn "*mulsf3"
4676   [(set (match_operand:SF 0 "register_operand" "=f,f")
4677         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4678                  (match_operand:SF 2 "general_operand" "f,R")))]
4679   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4680   "@
4681    meebr\t%0,%2
4682    meeb\t%0,%2"
4683   [(set_attr "op_type"  "RRE,RXE")
4684    (set_attr "type"     "fmuls")])
4685
4686 (define_insn "*mulsf3_ibm"
4687   [(set (match_operand:SF 0 "register_operand" "=f,f")
4688         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4689                  (match_operand:SF 2 "general_operand" "f,R")))]
4690   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4691   "@
4692    mer\t%0,%2
4693    me\t%0,%2"
4694   [(set_attr "op_type"  "RR,RX")
4695    (set_attr "type"     "fmuls")])
4696
4697 (define_insn "*fmaddsf"
4698   [(set (match_operand:SF 0 "register_operand" "=f,f")
4699         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f,f")
4700                           (match_operand:SF 2 "nonimmediate_operand"  "f,R"))
4701                  (match_operand:SF 3 "register_operand" "0,0")))]
4702   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4703   "@
4704    maebr\t%0,%1,%2
4705    maeb\t%0,%1,%2"
4706   [(set_attr "op_type"  "RRE,RXE")
4707    (set_attr "type" "fmuls")])
4708
4709 (define_insn "*fmsubsf"
4710   [(set (match_operand:SF 0 "register_operand" "=f,f")
4711         (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "f,f")
4712                            (match_operand:SF 2 "nonimmediate_operand"  "f,R"))
4713                   (match_operand:SF 3 "register_operand" "0,0")))]
4714   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4715   "@
4716    msebr\t%0,%1,%2
4717    mseb\t%0,%1,%2"
4718   [(set_attr "op_type"  "RRE,RXE")
4719    (set_attr "type" "fmuls")])
4720
4721 ;;
4722 ;;- Divide and modulo instructions.
4723 ;;
4724
4725 ;
4726 ; divmoddi4 instruction pattern(s).
4727 ;
4728
4729 (define_expand "divmoddi4"
4730   [(parallel [(set (match_operand:DI 0 "general_operand" "")
4731                    (div:DI (match_operand:DI 1 "register_operand" "")
4732                            (match_operand:DI 2 "general_operand" "")))
4733               (set (match_operand:DI 3 "general_operand" "")
4734                    (mod:DI (match_dup 1) (match_dup 2)))])
4735    (clobber (match_dup 4))]
4736   "TARGET_64BIT"
4737 {
4738   rtx insn, div_equal, mod_equal;
4739
4740   div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
4741   mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4742
4743   operands[4] = gen_reg_rtx(TImode);
4744   emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4745
4746   insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4747   REG_NOTES (insn) =
4748         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4749
4750   insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4751   REG_NOTES (insn) =
4752         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4753
4754   DONE;
4755 })
4756
4757 (define_insn "divmodtidi3"
4758   [(set (match_operand:TI 0 "register_operand" "=d,d")
4759         (ior:TI
4760           (ashift:TI
4761             (zero_extend:TI
4762               (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4763                       (match_operand:DI 2 "general_operand" "d,m")))
4764             (const_int 64))
4765           (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
4766   "TARGET_64BIT"
4767   "@
4768    dsgr\t%0,%2
4769    dsg\t%0,%2"
4770   [(set_attr "op_type"  "RRE,RXY")
4771    (set_attr "type"     "idiv")])
4772
4773 (define_insn "divmodtisi3"
4774   [(set (match_operand:TI 0 "register_operand" "=d,d")
4775         (ior:TI
4776           (ashift:TI
4777             (zero_extend:TI
4778               (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4779                       (sign_extend:DI
4780                         (match_operand:SI 2 "nonimmediate_operand" "d,m"))))
4781             (const_int 64))
4782           (zero_extend:TI
4783             (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
4784   "TARGET_64BIT"
4785   "@
4786    dsgfr\t%0,%2
4787    dsgf\t%0,%2"
4788   [(set_attr "op_type"  "RRE,RXY")
4789    (set_attr "type"     "idiv")])
4790
4791 ;
4792 ; udivmoddi4 instruction pattern(s).
4793 ;
4794
4795 (define_expand "udivmoddi4"
4796   [(parallel [(set (match_operand:DI 0 "general_operand" "")
4797                    (udiv:DI (match_operand:DI 1 "general_operand" "")
4798                             (match_operand:DI 2 "nonimmediate_operand" "")))
4799               (set (match_operand:DI 3 "general_operand" "")
4800                    (umod:DI (match_dup 1) (match_dup 2)))])
4801    (clobber (match_dup 4))]
4802   "TARGET_64BIT"
4803 {
4804   rtx insn, div_equal, mod_equal, equal;
4805
4806   div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
4807   mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
4808   equal = gen_rtx_IOR (TImode,
4809                        gen_rtx_ASHIFT (TImode,
4810                                        gen_rtx_ZERO_EXTEND (TImode, mod_equal),
4811                                        GEN_INT (64)),
4812                        gen_rtx_ZERO_EXTEND (TImode, div_equal));
4813
4814   operands[4] = gen_reg_rtx(TImode);
4815   emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4816   emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
4817   emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
4818   insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
4819   REG_NOTES (insn) =
4820         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4821
4822   insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4823   REG_NOTES (insn) =
4824         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4825
4826   insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4827   REG_NOTES (insn) =
4828         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4829
4830   DONE;
4831 })
4832
4833 (define_insn "udivmodtidi3"
4834   [(set (match_operand:TI 0 "register_operand" "=d,d")
4835         (ior:TI
4836           (ashift:TI
4837             (zero_extend:TI
4838               (truncate:DI
4839                 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
4840                          (zero_extend:TI
4841                            (match_operand:DI 2 "nonimmediate_operand" "d,m")))))
4842             (const_int 64))
4843           (zero_extend:TI
4844             (truncate:DI
4845               (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
4846   "TARGET_64BIT"
4847   "@
4848    dlgr\t%0,%2
4849    dlg\t%0,%2"
4850   [(set_attr "op_type"  "RRE,RXY")
4851    (set_attr "type"     "idiv")])
4852
4853 ;
4854 ; divmodsi4 instruction pattern(s).
4855 ;
4856
4857 (define_expand "divmodsi4"
4858   [(parallel [(set (match_operand:SI 0 "general_operand" "")
4859                    (div:SI (match_operand:SI 1 "general_operand" "")
4860                            (match_operand:SI 2 "nonimmediate_operand" "")))
4861               (set (match_operand:SI 3 "general_operand" "")
4862                    (mod:SI (match_dup 1) (match_dup 2)))])
4863    (clobber (match_dup 4))]
4864   "!TARGET_64BIT"
4865 {
4866   rtx insn, div_equal, mod_equal, equal;
4867
4868   div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
4869   mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
4870   equal = gen_rtx_IOR (DImode,
4871                        gen_rtx_ASHIFT (DImode,
4872                                        gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4873                                        GEN_INT (32)),
4874                        gen_rtx_ZERO_EXTEND (DImode, div_equal));
4875
4876   operands[4] = gen_reg_rtx(DImode);
4877   emit_insn (gen_extendsidi2 (operands[4], operands[1]));
4878   insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
4879   REG_NOTES (insn) =
4880         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4881
4882   insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4883   REG_NOTES (insn) =
4884         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4885
4886   insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4887   REG_NOTES (insn) =
4888         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4889
4890   DONE;
4891 })
4892
4893 (define_insn "divmoddisi3"
4894   [(set (match_operand:DI 0 "register_operand" "=d,d")
4895         (ior:DI
4896           (ashift:DI
4897             (zero_extend:DI
4898               (truncate:SI
4899                 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
4900                         (sign_extend:DI
4901                           (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
4902             (const_int 32))
4903           (zero_extend:DI
4904             (truncate:SI
4905               (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
4906   "!TARGET_64BIT"
4907   "@
4908    dr\t%0,%2
4909    d\t%0,%2"
4910   [(set_attr "op_type"  "RR,RX")
4911    (set_attr "type"     "idiv")])
4912
4913 ;
4914 ; udivsi3 and umodsi3 instruction pattern(s).
4915 ;
4916
4917 (define_expand "udivmodsi4"
4918   [(parallel [(set (match_operand:SI 0 "general_operand" "")
4919                    (udiv:SI (match_operand:SI 1 "general_operand" "")
4920                             (match_operand:SI 2 "nonimmediate_operand" "")))
4921               (set (match_operand:SI 3 "general_operand" "")
4922                    (umod:SI (match_dup 1) (match_dup 2)))])
4923    (clobber (match_dup 4))]
4924   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4925 {
4926   rtx insn, div_equal, mod_equal, equal;
4927
4928   div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4929   mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4930   equal = gen_rtx_IOR (DImode,
4931                        gen_rtx_ASHIFT (DImode,
4932                                        gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4933                                        GEN_INT (32)),
4934                        gen_rtx_ZERO_EXTEND (DImode, div_equal));
4935
4936   operands[4] = gen_reg_rtx(DImode);
4937   emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4938   emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
4939   emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
4940   insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
4941   REG_NOTES (insn) =
4942         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4943
4944   insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4945   REG_NOTES (insn) =
4946         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4947
4948   insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4949   REG_NOTES (insn) =
4950         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4951
4952   DONE;
4953 })
4954
4955 (define_insn "udivmoddisi3"
4956   [(set (match_operand:DI 0 "register_operand" "=d,d")
4957         (ior:DI
4958           (ashift:DI
4959             (zero_extend:DI
4960               (truncate:SI
4961                 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
4962                          (zero_extend:DI
4963                            (match_operand:SI 2 "nonimmediate_operand" "d,m")))))
4964             (const_int 32))
4965           (zero_extend:DI
4966             (truncate:SI
4967               (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
4968   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4969   "@
4970    dlr\t%0,%2
4971    dl\t%0,%2"
4972   [(set_attr "op_type"  "RRE,RXY")
4973    (set_attr "type"     "idiv")])
4974
4975 (define_expand "udivsi3"
4976   [(set (match_operand:SI 0 "register_operand" "=d")
4977         (udiv:SI (match_operand:SI 1 "general_operand" "")
4978                  (match_operand:SI 2 "general_operand" "")))
4979    (clobber (match_dup 3))]
4980   "!TARGET_64BIT && !TARGET_CPU_ZARCH"
4981 {
4982   rtx insn, udiv_equal, umod_equal, equal;
4983
4984   udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4985   umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4986   equal = gen_rtx_IOR (DImode,
4987                        gen_rtx_ASHIFT (DImode,
4988                                        gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4989                                        GEN_INT (32)),
4990                        gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
4991
4992   operands[3] = gen_reg_rtx (DImode);
4993
4994   if (CONSTANT_P (operands[2]))
4995     {
4996       if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
4997         {
4998           rtx label1 = gen_label_rtx ();
4999
5000           operands[1] = make_safe_from (operands[1], operands[0]);
5001           emit_move_insn (operands[0], const0_rtx);
5002           emit_insn (gen_cmpsi (operands[1], operands[2]));
5003           emit_jump_insn (gen_bltu (label1));
5004           emit_move_insn (operands[0], const1_rtx);
5005           emit_label (label1);
5006         }
5007       else
5008         {
5009           operands[2] = force_reg (SImode, operands[2]);
5010           operands[2] = make_safe_from (operands[2], operands[0]);
5011
5012           emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5013           insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5014                                              operands[2]));
5015           REG_NOTES (insn) =
5016             gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
5017
5018           insn = emit_move_insn (operands[0],
5019                                  gen_lowpart (SImode, operands[3]));
5020           REG_NOTES (insn) =
5021             gen_rtx_EXPR_LIST (REG_EQUAL,
5022                                udiv_equal, REG_NOTES (insn));
5023         }
5024     }
5025   else
5026     {
5027       rtx label1 = gen_label_rtx ();
5028       rtx label2 = gen_label_rtx ();
5029       rtx label3 = gen_label_rtx ();
5030
5031       operands[1] = force_reg (SImode, operands[1]);
5032       operands[1] = make_safe_from (operands[1], operands[0]);
5033       operands[2] = force_reg (SImode, operands[2]);
5034       operands[2] = make_safe_from (operands[2], operands[0]);
5035
5036       emit_move_insn (operands[0], const0_rtx);
5037       emit_insn (gen_cmpsi (operands[2], operands[1]));
5038       emit_jump_insn (gen_bgtu (label3));
5039       emit_insn (gen_cmpsi (operands[2], const0_rtx));
5040       emit_jump_insn (gen_blt (label2));
5041       emit_insn (gen_cmpsi (operands[2], const1_rtx));
5042       emit_jump_insn (gen_beq (label1));
5043       emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5044       insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5045                                          operands[2]));
5046       REG_NOTES (insn) =
5047       gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
5048
5049       insn = emit_move_insn (operands[0],
5050                              gen_lowpart (SImode, operands[3]));
5051       REG_NOTES (insn) =
5052       gen_rtx_EXPR_LIST (REG_EQUAL,
5053                                udiv_equal, REG_NOTES (insn));
5054       emit_jump (label3);
5055       emit_label (label1);
5056       emit_move_insn (operands[0], operands[1]);
5057       emit_jump (label3);
5058       emit_label (label2);
5059       emit_move_insn (operands[0], const1_rtx);
5060       emit_label (label3);
5061     }
5062   emit_move_insn (operands[0], operands[0]);
5063   DONE;
5064 })
5065
5066 (define_expand "umodsi3"
5067   [(set (match_operand:SI 0 "register_operand" "=d")
5068         (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
5069                  (match_operand:SI 2 "nonimmediate_operand" "")))
5070    (clobber (match_dup 3))]
5071   "!TARGET_64BIT && !TARGET_CPU_ZARCH"
5072 {
5073   rtx insn, udiv_equal, umod_equal, equal;
5074
5075   udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5076   umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5077   equal = gen_rtx_IOR (DImode,
5078                        gen_rtx_ASHIFT (DImode,
5079                                        gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5080                                        GEN_INT (32)),
5081                        gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5082
5083   operands[3] = gen_reg_rtx (DImode);
5084
5085   if (CONSTANT_P (operands[2]))
5086     {
5087       if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
5088         {
5089           rtx label1 = gen_label_rtx ();
5090
5091           operands[1] = make_safe_from (operands[1], operands[0]);
5092           emit_move_insn (operands[0], operands[1]);
5093           emit_insn (gen_cmpsi (operands[0], operands[2]));
5094           emit_jump_insn (gen_bltu (label1));
5095           emit_insn (gen_abssi2 (operands[0], operands[2]));
5096           emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
5097           emit_label (label1);
5098         }
5099       else
5100         {
5101           operands[2] = force_reg (SImode, operands[2]);
5102           operands[2] = make_safe_from (operands[2], operands[0]);
5103
5104           emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5105           insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5106                                              operands[2]));
5107           REG_NOTES (insn) =
5108             gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
5109
5110           insn = emit_move_insn (operands[0],
5111                                  gen_highpart (SImode, operands[3]));
5112           REG_NOTES (insn) =
5113             gen_rtx_EXPR_LIST (REG_EQUAL,
5114                                umod_equal, REG_NOTES (insn));
5115         }
5116     }
5117   else
5118     {
5119       rtx label1 = gen_label_rtx ();
5120       rtx label2 = gen_label_rtx ();
5121       rtx label3 = gen_label_rtx ();
5122
5123       operands[1] = force_reg (SImode, operands[1]);
5124       operands[1] = make_safe_from (operands[1], operands[0]);
5125       operands[2] = force_reg (SImode, operands[2]);
5126       operands[2] = make_safe_from (operands[2], operands[0]);
5127
5128       emit_move_insn(operands[0], operands[1]);
5129       emit_insn (gen_cmpsi (operands[2], operands[1]));
5130       emit_jump_insn (gen_bgtu (label3));
5131       emit_insn (gen_cmpsi (operands[2], const0_rtx));
5132       emit_jump_insn (gen_blt (label2));
5133       emit_insn (gen_cmpsi (operands[2], const1_rtx));
5134       emit_jump_insn (gen_beq (label1));
5135       emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5136       insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5137                                          operands[2]));
5138       REG_NOTES (insn) =
5139       gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
5140
5141       insn = emit_move_insn (operands[0],
5142                              gen_highpart (SImode, operands[3]));
5143       REG_NOTES (insn) =
5144       gen_rtx_EXPR_LIST (REG_EQUAL,
5145                          umod_equal, REG_NOTES (insn));
5146       emit_jump (label3);
5147       emit_label (label1);
5148       emit_move_insn (operands[0], const0_rtx);
5149       emit_jump (label3);
5150       emit_label (label2);
5151       emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
5152       emit_label (label3);
5153     }
5154   DONE;
5155 })
5156
5157 ;
5158 ; divdf3 instruction pattern(s).
5159 ;
5160
5161 (define_expand "divdf3"
5162   [(set (match_operand:DF 0 "register_operand" "=f,f")
5163         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5164                 (match_operand:DF 2 "general_operand" "f,R")))]
5165   "TARGET_HARD_FLOAT"
5166   "")
5167
5168 (define_insn "*divdf3"
5169   [(set (match_operand:DF 0 "register_operand" "=f,f")
5170         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5171                 (match_operand:DF 2 "general_operand" "f,R")))]
5172   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5173   "@
5174    ddbr\t%0,%2
5175    ddb\t%0,%2"
5176   [(set_attr "op_type"  "RRE,RXE")
5177    (set_attr "type"     "fdivd")])
5178
5179 (define_insn "*divdf3_ibm"
5180   [(set (match_operand:DF 0 "register_operand" "=f,f")
5181         (div:DF (match_operand:DF 1 "register_operand" "0,0")
5182                 (match_operand:DF 2 "general_operand" "f,R")))]
5183   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5184   "@
5185    ddr\t%0,%2
5186    dd\t%0,%2"
5187   [(set_attr "op_type"  "RR,RX")
5188    (set_attr "type"     "fdivd")])
5189
5190 ;
5191 ; divsf3 instruction pattern(s).
5192 ;
5193
5194 (define_expand "divsf3"
5195   [(set (match_operand:SF 0 "register_operand" "=f,f")
5196         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5197                 (match_operand:SF 2 "general_operand" "f,R")))]
5198   "TARGET_HARD_FLOAT"
5199   "")
5200
5201 (define_insn "*divsf3"
5202   [(set (match_operand:SF 0 "register_operand" "=f,f")
5203         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5204                 (match_operand:SF 2 "general_operand" "f,R")))]
5205   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5206   "@
5207    debr\t%0,%2
5208    deb\t%0,%2"
5209   [(set_attr "op_type"  "RRE,RXE")
5210    (set_attr "type"     "fdivs")])
5211
5212 (define_insn "*divsf3"
5213   [(set (match_operand:SF 0 "register_operand" "=f,f")
5214         (div:SF (match_operand:SF 1 "register_operand" "0,0")
5215                 (match_operand:SF 2 "general_operand" "f,R")))]
5216   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5217   "@
5218    der\t%0,%2
5219    de\t%0,%2"
5220   [(set_attr "op_type"  "RR,RX")
5221    (set_attr "type"     "fdivs")])
5222
5223
5224 ;;
5225 ;;- And instructions.
5226 ;;
5227
5228 ;
5229 ; anddi3 instruction pattern(s).
5230 ;
5231
5232 (define_insn "*anddi3_cc"
5233   [(set (reg 33)
5234         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5235                          (match_operand:DI 2 "general_operand" "d,m"))
5236                  (const_int 0)))
5237    (set (match_operand:DI 0 "register_operand" "=d,d")
5238         (and:DI (match_dup 1) (match_dup 2)))]
5239   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5240   "@
5241    ngr\t%0,%2
5242    ng\t%0,%2"
5243   [(set_attr "op_type"  "RRE,RXY")])
5244
5245 (define_insn "*anddi3_cconly"
5246   [(set (reg 33)
5247         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5248                          (match_operand:DI 2 "general_operand" "d,m"))
5249                  (const_int 0)))
5250    (clobber (match_scratch:DI 0 "=d,d"))]
5251   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
5252    /* Do not steal TM patterns.  */
5253    && s390_single_part (operands[2], DImode, HImode, 0) < 0"
5254   "@
5255    ngr\t%0,%2
5256    ng\t%0,%2"
5257   [(set_attr "op_type"  "RRE,RXY")])
5258
5259 (define_insn "*anddi3"
5260   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
5261         (and:DI (match_operand:DI 1 "nonimmediate_operand"
5262                                     "%d,o,0,0,0,0,0,0,0,0")
5263                 (match_operand:DI 2 "general_operand"
5264                                     "M,M,N0HDF,N1HDF,N2HDF,N3HDF,d,m,NxQDF,Q")))
5265    (clobber (reg:CC 33))]
5266   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5267   "@
5268    #
5269    #
5270    nihh\t%0,%j2
5271    nihl\t%0,%j2
5272    nilh\t%0,%j2
5273    nill\t%0,%j2
5274    ngr\t%0,%2
5275    ng\t%0,%2
5276    #
5277    #"
5278   [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RRE,RXY,SI,SS")])
5279
5280 (define_split
5281   [(set (match_operand:DI 0 "s_operand" "")
5282         (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5283    (clobber (reg:CC 33))]
5284   "reload_completed"
5285   [(parallel
5286     [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5287      (clobber (reg:CC 33))])]
5288   "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5289
5290 (define_expand "anddi3"
5291   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5292         (and:DI (match_operand:DI 1 "nonimmediate_operand" "")
5293                 (match_operand:DI 2 "general_operand" "")))
5294    (clobber (reg:CC 33))]
5295   "TARGET_64BIT"
5296   "s390_expand_logical_operator (AND, DImode, operands); DONE;")
5297
5298 ;
5299 ; andsi3 instruction pattern(s).
5300 ;
5301
5302 (define_insn "*andsi3_cc"
5303   [(set (reg 33)
5304         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5305                          (match_operand:SI 2 "general_operand" "d,R,T"))
5306                  (const_int 0)))
5307    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5308         (and:SI (match_dup 1) (match_dup 2)))]
5309   "s390_match_ccmode(insn, CCTmode)"
5310   "@
5311    nr\t%0,%2
5312    n\t%0,%2
5313    ny\t%0,%2"
5314   [(set_attr "op_type"  "RR,RX,RXY")])
5315
5316 (define_insn "*andsi3_cconly"
5317   [(set (reg 33)
5318         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5319                          (match_operand:SI 2 "general_operand" "d,R,T"))
5320                  (const_int 0)))
5321    (clobber (match_scratch:SI 0 "=d,d,d"))]
5322   "s390_match_ccmode(insn, CCTmode)
5323    /* Do not steal TM patterns.  */
5324    && s390_single_part (operands[2], SImode, HImode, 0) < 0"
5325   "@
5326    nr\t%0,%2
5327    n\t%0,%2
5328    ny\t%0,%2"
5329   [(set_attr "op_type"  "RR,RX,RXY")])
5330
5331 (define_insn "*andsi3_zarch"
5332   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,AQ,Q")
5333         (and:SI (match_operand:SI 1 "nonimmediate_operand"
5334                                     "%d,o,0,0,0,0,0,0,0")
5335                 (match_operand:SI 2 "general_operand"
5336                                     "M,M,N0HSF,N1HSF,d,R,T,NxQSF,Q")))
5337    (clobber (reg:CC 33))]
5338   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5339   "@
5340    #
5341    #
5342    nilh\t%0,%j2
5343    nill\t%0,%j2
5344    nr\t%0,%2
5345    n\t%0,%2
5346    ny\t%0,%2
5347    #
5348    #"
5349   [(set_attr "op_type"  "RRE,RXE,RI,RI,RR,RX,RXY,SI,SS")])
5350
5351 (define_insn "*andsi3_esa"
5352   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5353         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5354                 (match_operand:SI 2 "general_operand" "d,R,NxQSF,Q")))
5355    (clobber (reg:CC 33))]
5356   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5357   "@
5358    nr\t%0,%2
5359    n\t%0,%2
5360    #
5361    #"
5362   [(set_attr "op_type"  "RR,RX,SI,SS")])
5363
5364 (define_split
5365   [(set (match_operand:SI 0 "s_operand" "")
5366         (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5367    (clobber (reg:CC 33))]
5368   "reload_completed"
5369   [(parallel
5370     [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5371      (clobber (reg:CC 33))])]
5372   "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5373
5374 (define_expand "andsi3"
5375   [(set (match_operand:SI 0 "nonimmediate_operand" "")
5376         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
5377                 (match_operand:SI 2 "general_operand" "")))
5378    (clobber (reg:CC 33))]
5379   ""
5380   "s390_expand_logical_operator (AND, SImode, operands); DONE;")
5381
5382 ;
5383 ; andhi3 instruction pattern(s).
5384 ;
5385
5386 (define_insn "*andhi3_zarch"
5387   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5388         (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5389                 (match_operand:HI 2 "general_operand" "d,n,NxQHF,Q")))
5390    (clobber (reg:CC 33))]
5391   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5392   "@
5393    nr\t%0,%2
5394    nill\t%0,%x2
5395    #
5396    #"
5397   [(set_attr "op_type"  "RR,RI,SI,SS")])
5398
5399 (define_insn "*andhi3_esa"
5400   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5401         (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5402                 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
5403    (clobber (reg:CC 33))]
5404   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5405   "@
5406    nr\t%0,%2
5407    #
5408    #"
5409   [(set_attr "op_type"  "RR,SI,SS")])
5410
5411 (define_split
5412   [(set (match_operand:HI 0 "s_operand" "")
5413         (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5414    (clobber (reg:CC 33))]
5415   "reload_completed"
5416   [(parallel
5417     [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5418      (clobber (reg:CC 33))])]
5419   "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5420
5421 (define_expand "andhi3"
5422   [(set (match_operand:HI 0 "nonimmediate_operand" "")
5423         (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
5424                 (match_operand:HI 2 "general_operand" "")))
5425    (clobber (reg:CC 33))]
5426   ""
5427   "s390_expand_logical_operator (AND, HImode, operands); DONE;")
5428
5429 ;
5430 ; andqi3 instruction pattern(s).
5431 ;
5432
5433 (define_insn "*andqi3_zarch"
5434   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5435         (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5436                 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5437    (clobber (reg:CC 33))]
5438   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5439   "@
5440    nr\t%0,%2
5441    nill\t%0,%b2
5442    ni\t%S0,%b2
5443    niy\t%S0,%b2
5444    #"
5445   [(set_attr "op_type"  "RR,RI,SI,SIY,SS")])
5446
5447 (define_insn "*andqi3_esa"
5448   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5449         (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5450                 (match_operand:QI 2 "general_operand" "d,n,Q")))
5451    (clobber (reg:CC 33))]
5452   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5453   "@
5454    nr\t%0,%2
5455    ni\t%S0,%b2
5456    #"
5457   [(set_attr "op_type"  "RR,SI,SS")])
5458
5459 (define_expand "andqi3"
5460   [(set (match_operand:QI 0 "nonimmediate_operand" "")
5461         (and:QI (match_operand:QI 1 "nonimmediate_operand" "")
5462                 (match_operand:QI 2 "general_operand" "")))
5463    (clobber (reg:CC 33))]
5464   ""
5465   "s390_expand_logical_operator (AND, QImode, operands); DONE;")
5466
5467 ;
5468 ; Block and (NC) patterns.
5469 ;
5470
5471 (define_insn "*nc"
5472   [(set (match_operand:BLK 0 "memory_operand" "=Q")
5473         (and:BLK (match_dup 0)
5474                  (match_operand:BLK 1 "memory_operand" "Q")))
5475    (use (match_operand 2 "const_int_operand" "n"))
5476    (clobber (reg:CC 33))]
5477   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5478   "nc\t%O0(%2,%R0),%S1"
5479   [(set_attr "op_type" "SS")])
5480
5481 (define_split
5482   [(set (match_operand 0 "memory_operand" "")
5483         (and (match_dup 0)
5484              (match_operand 1 "memory_operand" "")))
5485    (clobber (reg:CC 33))]
5486   "reload_completed
5487    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5488    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
5489   [(parallel
5490     [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
5491      (use (match_dup 2))
5492      (clobber (reg:CC 33))])]
5493 {
5494   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
5495   operands[0] = adjust_address (operands[0], BLKmode, 0);
5496   operands[1] = adjust_address (operands[1], BLKmode, 0);
5497 })
5498
5499 (define_peephole2
5500   [(parallel
5501     [(set (match_operand:BLK 0 "memory_operand" "")
5502           (and:BLK (match_dup 0)
5503                    (match_operand:BLK 1 "memory_operand" "")))
5504      (use (match_operand 2 "const_int_operand" ""))
5505      (clobber (reg:CC 33))])
5506    (parallel
5507     [(set (match_operand:BLK 3 "memory_operand" "")
5508           (and:BLK (match_dup 3)
5509                    (match_operand:BLK 4 "memory_operand" "")))
5510      (use (match_operand 5 "const_int_operand" ""))
5511      (clobber (reg:CC 33))])]
5512   "s390_offset_p (operands[0], operands[3], operands[2])
5513    && s390_offset_p (operands[1], operands[4], operands[2])
5514    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
5515   [(parallel
5516     [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
5517      (use (match_dup 8))
5518      (clobber (reg:CC 33))])]
5519   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
5520    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
5521    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
5522
5523
5524 ;;
5525 ;;- Bit set (inclusive or) instructions.
5526 ;;
5527
5528 ;
5529 ; iordi3 instruction pattern(s).
5530 ;
5531
5532 (define_insn "*iordi3_cc"
5533   [(set (reg 33)
5534         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5535                          (match_operand:DI 2 "general_operand" "d,m"))
5536                  (const_int 0)))
5537    (set (match_operand:DI 0 "register_operand" "=d,d")
5538         (ior:DI (match_dup 1) (match_dup 2)))]
5539   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5540   "@
5541    ogr\t%0,%2
5542    og\t%0,%2"
5543   [(set_attr "op_type"  "RRE,RXY")])
5544
5545 (define_insn "*iordi3_cconly"
5546   [(set (reg 33)
5547         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5548                          (match_operand:DI 2 "general_operand" "d,m"))
5549                  (const_int 0)))
5550    (clobber (match_scratch:DI 0 "=d,d"))]
5551   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5552   "@
5553    ogr\t%0,%2
5554    og\t%0,%2"
5555   [(set_attr "op_type"  "RRE,RXY")])
5556
5557 (define_insn "*iordi3"
5558   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,AQ,Q")
5559         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "0,0,0,0,0,0,0,0")
5560                 (match_operand:DI 2 "general_operand"
5561                                     "N0HD0,N1HD0,N2HD0,N3HD0,d,m,NxQD0,Q")))
5562    (clobber (reg:CC 33))]
5563   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5564   "@
5565    oihh\t%0,%i2
5566    oihl\t%0,%i2
5567    oilh\t%0,%i2
5568    oill\t%0,%i2
5569    ogr\t%0,%2
5570    og\t%0,%2
5571    #
5572    #"
5573   [(set_attr "op_type"  "RI,RI,RI,RI,RRE,RXY,SI,SS")])
5574
5575 (define_split
5576   [(set (match_operand:DI 0 "s_operand" "")
5577         (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5578    (clobber (reg:CC 33))]
5579   "reload_completed"
5580   [(parallel
5581     [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5582      (clobber (reg:CC 33))])]
5583   "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5584
5585 (define_expand "iordi3"
5586   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5587         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "")
5588                 (match_operand:DI 2 "general_operand" "")))
5589    (clobber (reg:CC 33))]
5590   "TARGET_64BIT"
5591   "s390_expand_logical_operator (IOR, DImode, operands); DONE;")
5592
5593 ;
5594 ; iorsi3 instruction pattern(s).
5595 ;
5596
5597 (define_insn "*iorsi3_cc"
5598   [(set (reg 33)
5599         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5600                          (match_operand:SI 2 "general_operand" "d,R,T"))
5601                  (const_int 0)))
5602    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5603         (ior:SI (match_dup 1) (match_dup 2)))]
5604   "s390_match_ccmode(insn, CCTmode)"
5605   "@
5606    or\t%0,%2
5607    o\t%0,%2
5608    oy\t%0,%2"
5609   [(set_attr "op_type"  "RR,RX,RXY")])
5610
5611 (define_insn "*iorsi3_cconly"
5612   [(set (reg 33)
5613         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5614                          (match_operand:SI 2 "general_operand" "d,R,T"))
5615                  (const_int 0)))
5616    (clobber (match_scratch:SI 0 "=d,d,d"))]
5617   "s390_match_ccmode(insn, CCTmode)"
5618   "@
5619    or\t%0,%2
5620    o\t%0,%2
5621    oy\t%0,%2"
5622   [(set_attr "op_type"  "RR,RX,RXY")])
5623
5624 (define_insn "*iorsi3_zarch"
5625   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,AQ,Q")
5626         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "0,0,0,0,0,0,0")
5627                 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,d,R,T,NxQS0,Q")))
5628    (clobber (reg:CC 33))]
5629   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5630   "@
5631    oilh\t%0,%i2
5632    oill\t%0,%i2
5633    or\t%0,%2
5634    o\t%0,%2
5635    oy\t%0,%2
5636    #
5637    #"
5638   [(set_attr "op_type"  "RI,RI,RR,RX,RXY,SI,SS")])
5639
5640 (define_insn "*iorsi3_esa"
5641   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5642         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "0,0,0,0")
5643                 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
5644    (clobber (reg:CC 33))]
5645   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5646   "@
5647    or\t%0,%2
5648    o\t%0,%2
5649    #
5650    #"
5651   [(set_attr "op_type"  "RR,RX,SI,SS")])
5652
5653 (define_split
5654   [(set (match_operand:SI 0 "s_operand" "")
5655         (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5656    (clobber (reg:CC 33))]
5657   "reload_completed"
5658   [(parallel
5659     [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5660      (clobber (reg:CC 33))])]
5661   "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5662
5663 (define_expand "iorsi3"
5664   [(set (match_operand:SI 0 "nonimmediate_operand" "")
5665         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "")
5666                 (match_operand:SI 2 "general_operand" "")))
5667    (clobber (reg:CC 33))]
5668   ""
5669   "s390_expand_logical_operator (IOR, SImode, operands); DONE;")
5670
5671 ;
5672 ; iorhi3 instruction pattern(s).
5673 ;
5674
5675 (define_insn "*iorhi3_zarch"
5676   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5677         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5678                 (match_operand:HI 2 "general_operand" "d,n,NxQH0,Q")))
5679    (clobber (reg:CC 33))]
5680   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5681   "@
5682    or\t%0,%2
5683    oill\t%0,%x2
5684    #
5685    #"
5686   [(set_attr "op_type"  "RR,RI,SI,SS")])
5687
5688 (define_insn "*iorhi3_esa"
5689   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5690         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5691                 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
5692    (clobber (reg:CC 33))]
5693   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5694   "@
5695    or\t%0,%2
5696    #
5697    #"
5698   [(set_attr "op_type"  "RR,SI,SS")])
5699
5700 (define_split
5701   [(set (match_operand:HI 0 "s_operand" "")
5702         (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5703    (clobber (reg:CC 33))]
5704   "reload_completed"
5705   [(parallel
5706     [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
5707      (clobber (reg:CC 33))])]
5708   "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
5709
5710 (define_expand "iorhi3"
5711   [(set (match_operand:HI 0 "nonimmediate_operand" "")
5712         (ior:HI (match_operand:HI 1 "nonimmediate_operand" "")
5713                 (match_operand:HI 2 "general_operand" "")))
5714    (clobber (reg:CC 33))]
5715   ""
5716   "s390_expand_logical_operator (IOR, HImode, operands); DONE;")
5717
5718 ;
5719 ; iorqi3 instruction pattern(s).
5720 ;
5721
5722 (define_insn "*iorqi3_zarch"
5723   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5724         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5725                 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5726    (clobber (reg:CC 33))]
5727   "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5728   "@
5729    or\t%0,%2
5730    oill\t%0,%b2
5731    oi\t%S0,%b2
5732    oiy\t%S0,%b2
5733    #"
5734   [(set_attr "op_type"  "RR,RI,SI,SIY,SS")])
5735
5736 (define_insn "*iorqi3_esa"
5737   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5738         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5739                 (match_operand:QI 2 "general_operand" "d,n,Q")))
5740    (clobber (reg:CC 33))]
5741   "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5742   "@
5743    or\t%0,%2
5744    oi\t%S0,%b2
5745    #"
5746   [(set_attr "op_type"  "RR,SI,SS")])
5747
5748 (define_expand "iorqi3"
5749   [(set (match_operand:QI 0 "nonimmediate_operand" "")
5750         (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
5751                 (match_operand:QI 2 "general_operand" "")))
5752    (clobber (reg:CC 33))]
5753   ""
5754   "s390_expand_logical_operator (IOR, QImode, operands); DONE;")
5755
5756 ;
5757 ; Block inclusive or (OC) patterns.
5758 ;
5759
5760 (define_insn "*oc"
5761   [(set (match_operand:BLK 0 "memory_operand" "=Q")
5762         (ior:BLK (match_dup 0)
5763                  (match_operand:BLK 1 "memory_operand" "Q")))
5764    (use (match_operand 2 "const_int_operand" "n"))
5765    (clobber (reg:CC 33))]
5766   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5767   "oc\t%O0(%2,%R0),%S1"
5768   [(set_attr "op_type" "SS")])
5769
5770 (define_split
5771   [(set (match_operand 0 "memory_operand" "")
5772         (ior (match_dup 0)
5773              (match_operand 1 "memory_operand" "")))
5774    (clobber (reg:CC 33))]
5775   "reload_completed
5776    && GET_MODE (operands[0]) == GET_MODE (operands[1])
5777    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
5778   [(parallel
5779     [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
5780      (use (match_dup 2))
5781      (clobber (reg:CC 33))])]
5782 {
5783   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
5784   operands[0] = adjust_address (operands[0], BLKmode, 0);
5785   operands[1] = adjust_address (operands[1], BLKmode, 0);
5786 })
5787
5788 (define_peephole2
5789   [(parallel
5790     [(set (match_operand:BLK 0 "memory_operand" "")
5791           (ior:BLK (match_dup 0)
5792                    (match_operand:BLK 1 "memory_operand" "")))
5793      (use (match_operand 2 "const_int_operand" ""))
5794      (clobber (reg:CC 33))])
5795    (parallel
5796     [(set (match_operand:BLK 3 "memory_operand" "")
5797           (ior:BLK (match_dup 3)
5798                    (match_operand:BLK 4 "memory_operand" "")))
5799      (use (match_operand 5 "const_int_operand" ""))
5800      (clobber (reg:CC 33))])]
5801   "s390_offset_p (operands[0], operands[3], operands[2])
5802    && s390_offset_p (operands[1], operands[4], operands[2])
5803    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
5804   [(parallel
5805     [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
5806      (use (match_dup 8))
5807      (clobber (reg:CC 33))])]
5808   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
5809    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
5810    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
5811
5812
5813 ;;
5814 ;;- Xor instructions.
5815 ;;
5816
5817 ;
5818 ; xordi3 instruction pattern(s).
5819 ;
5820
5821 (define_insn "*xordi3_cc"
5822   [(set (reg 33)
5823         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5824                          (match_operand:DI 2 "general_operand" "d,m"))
5825                  (const_int 0)))
5826    (set (match_operand:DI 0 "register_operand" "=d,d")
5827         (xor:DI (match_dup 1) (match_dup 2)))]
5828   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5829   "@
5830    xgr\t%0,%2
5831    xg\t%0,%2"
5832   [(set_attr "op_type"  "RRE,RXY")])
5833
5834 (define_insn "*xordi3_cconly"
5835   [(set (reg 33)
5836         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5837                          (match_operand:DI 2 "general_operand" "d,m"))
5838                  (const_int 0)))
5839    (clobber (match_scratch:DI 0 "=d,d"))]
5840   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5841   "@
5842    xgr\t%0,%2
5843    xr\t%0,%2"
5844   [(set_attr "op_type"  "RRE,RXY")])
5845
5846 (define_insn "*xordi3"
5847   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5848         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5849                 (match_operand:DI 2 "general_operand" "d,m,NxQD0,Q")))
5850    (clobber (reg:CC 33))]
5851   "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5852   "@
5853    xgr\t%0,%2
5854    xg\t%0,%2
5855    #
5856    #"
5857   [(set_attr "op_type"  "RRE,RXY,SI,SS")])
5858
5859 (define_split
5860   [(set (match_operand:DI 0 "s_operand" "")
5861         (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5862    (clobber (reg:CC 33))]
5863   "reload_completed"
5864   [(parallel
5865     [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5866      (clobber (reg:CC 33))])]
5867   "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5868
5869 (define_expand "xordi3"
5870   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5871         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "")
5872                 (match_operand:DI 2 "general_operand" "")))
5873    (clobber (reg:CC 33))]
5874   "TARGET_64BIT"
5875   "s390_expand_logical_operator (XOR, DImode, operands); DONE;")
5876
5877 ;
5878 ; xorsi3 instruction pattern(s).
5879 ;
5880
5881 (define_insn "*xorsi3_cc"
5882   [(set (reg 33)
5883         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5884                          (match_operand:SI 2 "general_operand" "d,R,T"))
5885                  (const_int 0)))
5886    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5887         (xor:SI (match_dup 1) (match_dup 2)))]
5888   "s390_match_ccmode(insn, CCTmode)"
5889   "@
5890    xr\t%0,%2
5891    x\t%0,%2
5892    xy\t%0,%2"
5893   [(set_attr "op_type"  "RR,RX,RXY")])
5894
5895 (define_insn "*xorsi3_cconly"
5896   [(set (reg 33)
5897         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5898                          (match_operand:SI 2 "general_operand" "d,R,T"))
5899                  (const_int 0)))
5900    (clobber (match_scratch:SI 0 "=d,d,d"))]
5901   "s390_match_ccmode(insn, CCTmode)"
5902   "@
5903    xr\t%0,%2
5904    x\t%0,%2
5905    xy\t%0,%2"
5906   [(set_attr "op_type"  "RR,RX,RXY")])
5907
5908 (define_insn "*xorsi3"
5909   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,AQ,Q")
5910         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
5911                 (match_operand:SI 2 "general_operand" "d,R,T,NxQS0,Q")))
5912    (clobber (reg:CC 33))]
5913   "s390_logical_operator_ok_p (operands)"
5914   "@
5915    xr\t%0,%2
5916    x\t%0,%2
5917    xy\t%0,%2
5918    #
5919    #"
5920   [(set_attr "op_type"  "RR,RX,RXY,SI,SS")])
5921
5922 (define_split
5923   [(set (match_operand:SI 0 "s_operand" "")
5924         (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5925    (clobber (reg:CC 33))]
5926   "reload_completed"
5927   [(parallel
5928     [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5929      (clobber (reg:CC 33))])]
5930   "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5931
5932 (define_expand "xorsi3"
5933   [(set (match_operand:SI 0 "nonimmediate_operand" "")
5934         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "")
5935                 (match_operand:SI 2 "general_operand" "")))
5936    (clobber (reg:CC 33))]
5937   ""
5938   "s390_expand_logical_operator (XOR, SImode, operands); DONE;")
5939
5940 ;
5941 ; xorhi3 instruction pattern(s).
5942 ;
5943
5944 (define_insn "*xorhi3"
5945   [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5946         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5947                 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
5948    (clobber (reg:CC 33))]
5949   "s390_logical_operator_ok_p (operands)"
5950   "@
5951    xr\t%0,%2
5952    #
5953    #"
5954   [(set_attr "op_type"  "RR,SI,SS")])
5955
5956 (define_split
5957   [(set (match_operand:HI 0 "s_operand" "")
5958         (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5959    (clobber (reg:CC 33))]
5960   "reload_completed"
5961   [(parallel
5962     [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
5963      (clobber (reg:CC 33))])]
5964   "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
5965
5966 (define_expand "xorhi3"
5967   [(set (match_operand:HI 0 "nonimmediate_operand" "")
5968         (xor:HI (match_operand:HI 1 "nonimmediate_operand" "")
5969                 (match_operand:HI 2 "general_operand" "")))
5970    (clobber (reg:CC 33))]
5971   ""
5972   "s390_expand_logical_operator (XOR, HImode, operands); DONE;")
5973
5974 ;
5975 ; xorqi3 instruction pattern(s).
5976 ;
5977
5978 (define_insn "*xorqi3"
5979   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,S,Q")
5980         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0")
5981                 (match_operand:QI 2 "general_operand" "d,n,n,Q")))
5982    (clobber (reg:CC 33))]
5983   "s390_logical_operator_ok_p (operands)"
5984   "@
5985    xr\t%0,%2
5986    xi\t%S0,%b2
5987    xiy\t%S0,%b2
5988    #"
5989   [(set_attr "op_type"  "RR,SI,SIY,SS")])
5990
5991 (define_expand "xorqi3"
5992   [(set (match_operand:QI 0 "nonimmediate_operand" "")
5993         (xor:QI (match_operand:QI 1 "nonimmediate_operand" "")
5994                 (match_operand:QI 2 "general_operand" "")))
5995    (clobber (reg:CC 33))]
5996   ""
5997   "s390_expand_logical_operator (XOR, QImode, operands); DONE;")
5998
5999 ;
6000 ; Block exclusive or (XC) patterns.
6001 ;
6002
6003 (define_insn "*xc"
6004   [(set (match_operand:BLK 0 "memory_operand" "=Q")
6005         (xor:BLK (match_dup 0)
6006                  (match_operand:BLK 1 "memory_operand" "Q")))
6007    (use (match_operand 2 "const_int_operand" "n"))
6008    (clobber (reg:CC 33))]
6009   "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6010   "xc\t%O0(%2,%R0),%S1"
6011   [(set_attr "op_type" "SS")])
6012
6013 (define_split
6014   [(set (match_operand 0 "memory_operand" "")
6015         (xor (match_dup 0)
6016              (match_operand 1 "memory_operand" "")))
6017    (clobber (reg:CC 33))]
6018   "reload_completed
6019    && GET_MODE (operands[0]) == GET_MODE (operands[1])
6020    && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6021   [(parallel
6022     [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
6023      (use (match_dup 2))
6024      (clobber (reg:CC 33))])]
6025 {
6026   operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6027   operands[0] = adjust_address (operands[0], BLKmode, 0);
6028   operands[1] = adjust_address (operands[1], BLKmode, 0);
6029 })
6030
6031 (define_peephole2
6032   [(parallel
6033     [(set (match_operand:BLK 0 "memory_operand" "")
6034           (xor:BLK (match_dup 0)
6035                    (match_operand:BLK 1 "memory_operand" "")))
6036      (use (match_operand 2 "const_int_operand" ""))
6037      (clobber (reg:CC 33))])
6038    (parallel
6039     [(set (match_operand:BLK 3 "memory_operand" "")
6040           (xor:BLK (match_dup 3)
6041                    (match_operand:BLK 4 "memory_operand" "")))
6042      (use (match_operand 5 "const_int_operand" ""))
6043      (clobber (reg:CC 33))])]
6044   "s390_offset_p (operands[0], operands[3], operands[2])
6045    && s390_offset_p (operands[1], operands[4], operands[2])
6046    && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6047   [(parallel
6048     [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
6049      (use (match_dup 8))
6050      (clobber (reg:CC 33))])]
6051   "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6052    operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6053    operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6054
6055 ;
6056 ; Block xor (XC) patterns with src == dest.
6057 ;
6058
6059 (define_insn "*xc_zero"
6060   [(set (match_operand:BLK 0 "memory_operand" "=Q")
6061         (const_int 0))
6062    (use (match_operand 1 "const_int_operand" "n"))
6063    (clobber (reg:CC 33))]
6064   "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
6065   "xc\t%O0(%1,%R0),%S0"
6066   [(set_attr "op_type" "SS")])
6067
6068 (define_peephole2
6069   [(parallel
6070     [(set (match_operand:BLK 0 "memory_operand" "")
6071           (const_int 0))
6072      (use (match_operand 1 "const_int_operand" ""))
6073      (clobber (reg:CC 33))])
6074    (parallel
6075     [(set (match_operand:BLK 2 "memory_operand" "")
6076           (const_int 0))
6077      (use (match_operand 3 "const_int_operand" ""))
6078      (clobber (reg:CC 33))])]
6079   "s390_offset_p (operands[0], operands[2], operands[1])
6080    && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
6081   [(parallel
6082     [(set (match_dup 4) (const_int 0))
6083      (use (match_dup 5))
6084      (clobber (reg:CC 33))])]
6085   "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6086    operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
6087
6088
6089 ;;
6090 ;;- Negate instructions.
6091 ;;
6092
6093 ;
6094 ; negdi2 instruction pattern(s).
6095 ;
6096
6097 (define_expand "negdi2"
6098   [(parallel
6099     [(set (match_operand:DI 0 "register_operand" "=d")
6100           (neg:DI (match_operand:DI 1 "register_operand" "d")))
6101      (clobber (reg:CC 33))])]
6102   ""
6103   "")
6104
6105 (define_insn "*negdi2_64"
6106   [(set (match_operand:DI 0 "register_operand" "=d")
6107         (neg:DI (match_operand:DI 1 "register_operand" "d")))
6108    (clobber (reg:CC 33))]
6109   "TARGET_64BIT"
6110   "lcgr\t%0,%1"
6111   [(set_attr "op_type"  "RR")])
6112
6113 (define_insn "*negdi2_31"
6114   [(set (match_operand:DI 0 "register_operand" "=d")
6115         (neg:DI (match_operand:DI 1 "register_operand" "d")))
6116    (clobber (reg:CC 33))]
6117   "!TARGET_64BIT"
6118 {
6119   rtx xop[1];
6120   xop[0] = gen_label_rtx ();
6121   output_asm_insn ("lcr\t%0,%1", operands);
6122   output_asm_insn ("lcr\t%N0,%N1", operands);
6123   output_asm_insn ("je\t%l0", xop);
6124   output_asm_insn ("bctr\t%0,0", operands);
6125   targetm.asm_out.internal_label (asm_out_file, "L",
6126                              CODE_LABEL_NUMBER (xop[0]));
6127   return "";
6128 }
6129   [(set_attr "length" "10")])
6130
6131 ;
6132 ; negsi2 instruction pattern(s).
6133 ;
6134
6135 (define_insn "negsi2"
6136   [(set (match_operand:SI 0 "register_operand" "=d")
6137         (neg:SI (match_operand:SI 1 "register_operand" "d")))
6138    (clobber (reg:CC 33))]
6139   ""
6140   "lcr\t%0,%1"
6141   [(set_attr "op_type"  "RR")])
6142
6143 ;
6144 ; negdf2 instruction pattern(s).
6145 ;
6146
6147 (define_expand "negdf2"
6148   [(parallel
6149     [(set (match_operand:DF 0 "register_operand" "=f")
6150           (neg:DF (match_operand:DF 1 "register_operand" "f")))
6151      (clobber (reg:CC 33))])]
6152   "TARGET_HARD_FLOAT"
6153   "")
6154
6155 (define_insn "*negdf2"
6156   [(set (match_operand:DF 0 "register_operand" "=f")
6157         (neg:DF (match_operand:DF 1 "register_operand" "f")))
6158    (clobber (reg:CC 33))]
6159   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6160   "lcdbr\t%0,%1"
6161   [(set_attr "op_type"  "RRE")
6162    (set_attr "type"     "fsimpd")])
6163
6164 (define_insn "*negdf2_ibm"
6165   [(set (match_operand:DF 0 "register_operand" "=f")
6166         (neg:DF (match_operand:DF 1 "register_operand" "f")))
6167    (clobber (reg:CC 33))]
6168   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6169   "lcdr\t%0,%1"
6170   [(set_attr "op_type"  "RR")
6171    (set_attr "type"     "fsimpd")])
6172
6173 ;
6174 ; negsf2 instruction pattern(s).
6175 ;
6176
6177 (define_expand "negsf2"
6178   [(parallel
6179     [(set (match_operand:SF 0 "register_operand" "=f")
6180           (neg:SF (match_operand:SF 1 "register_operand" "f")))
6181      (clobber (reg:CC 33))])]
6182   "TARGET_HARD_FLOAT"
6183   "")
6184
6185 (define_insn "*negsf2"
6186   [(set (match_operand:SF 0 "register_operand" "=f")
6187         (neg:SF (match_operand:SF 1 "register_operand" "f")))
6188    (clobber (reg:CC 33))]
6189   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6190   "lcebr\t%0,%1"
6191   [(set_attr "op_type"  "RRE")
6192    (set_attr "type"     "fsimps")])
6193
6194 (define_insn "*negsf2"
6195   [(set (match_operand:SF 0 "register_operand" "=f")
6196         (neg:SF (match_operand:SF 1 "register_operand" "f")))
6197    (clobber (reg:CC 33))]
6198   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6199   "lcer\t%0,%1"
6200   [(set_attr "op_type"  "RR")
6201    (set_attr "type"     "fsimps")])
6202
6203
6204 ;;
6205 ;;- Absolute value instructions.
6206 ;;
6207
6208 ;
6209 ; absdi2 instruction pattern(s).
6210 ;
6211
6212 (define_insn "absdi2"
6213   [(set (match_operand:DI 0 "register_operand" "=d")
6214         (abs:DI (match_operand:DI 1 "register_operand" "d")))
6215    (clobber (reg:CC 33))]
6216   "TARGET_64BIT"
6217   "lpgr\t%0,%1"
6218   [(set_attr "op_type"  "RRE")])
6219
6220 ;
6221 ; abssi2 instruction pattern(s).
6222 ;
6223
6224 (define_insn "abssi2"
6225   [(set (match_operand:SI 0 "register_operand" "=d")
6226         (abs:SI (match_operand:SI 1 "register_operand" "d")))
6227    (clobber (reg:CC 33))]
6228   ""
6229   "lpr\t%0,%1"
6230   [(set_attr "op_type"  "RR")])
6231
6232 ;
6233 ; absdf2 instruction pattern(s).
6234 ;
6235
6236 (define_expand "absdf2"
6237   [(parallel
6238     [(set (match_operand:DF 0 "register_operand" "=f")
6239           (abs:DF (match_operand:DF 1 "register_operand" "f")))
6240      (clobber (reg:CC 33))])]
6241   "TARGET_HARD_FLOAT"
6242   "")
6243
6244 (define_insn "*absdf2"
6245   [(set (match_operand:DF 0 "register_operand" "=f")
6246         (abs:DF (match_operand:DF 1 "register_operand" "f")))
6247    (clobber (reg:CC 33))]
6248   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6249   "lpdbr\t%0,%1"
6250   [(set_attr "op_type"  "RRE")
6251    (set_attr "type"     "fsimpd")])
6252
6253 (define_insn "*absdf2_ibm"
6254   [(set (match_operand:DF 0 "register_operand" "=f")
6255         (abs:DF (match_operand:DF 1 "register_operand" "f")))
6256    (clobber (reg:CC 33))]
6257   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6258   "lpdr\t%0,%1"
6259   [(set_attr "op_type"  "RR")
6260    (set_attr "type"     "fsimpd")])
6261
6262 ;
6263 ; abssf2 instruction pattern(s).
6264 ;
6265
6266 (define_expand "abssf2"
6267   [(parallel
6268     [(set (match_operand:SF 0 "register_operand" "=f")
6269           (abs:SF (match_operand:SF 1 "register_operand" "f")))
6270      (clobber (reg:CC 33))])]
6271   "TARGET_HARD_FLOAT"
6272   "")
6273
6274 (define_insn "*abssf2"
6275   [(set (match_operand:SF 0 "register_operand" "=f")
6276         (abs:SF (match_operand:SF 1 "register_operand" "f")))
6277    (clobber (reg:CC 33))]
6278   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6279   "lpebr\t%0,%1"
6280   [(set_attr "op_type"  "RRE")
6281    (set_attr "type"     "fsimps")])
6282
6283 (define_insn "*abssf2_ibm"
6284   [(set (match_operand:SF 0 "register_operand" "=f")
6285         (abs:SF (match_operand:SF 1 "register_operand" "f")))
6286    (clobber (reg:CC 33))]
6287   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
6288   "lper\t%0,%1"
6289   [(set_attr "op_type"  "RR")
6290    (set_attr "type"     "fsimps")])
6291
6292 ;;
6293 ;;- Negated absolute value instructions
6294 ;;
6295
6296 ;
6297 ; Integer
6298 ;
6299
6300 (define_insn "*negabssi2"
6301   [(set (match_operand:SI 0 "register_operand" "=d")
6302         (neg:SI (abs:SI (match_operand:SI 1 "register_operand" "d"))))
6303    (clobber (reg:CC 33))]
6304   ""
6305   "lnr\t%0,%1"
6306   [(set_attr "op_type" "RR")])
6307
6308 (define_insn "*negabsdi2"
6309   [(set (match_operand:DI 0 "register_operand" "=d")
6310         (neg:DI (abs:DI (match_operand:DI 1 "register_operand" "d"))))
6311    (clobber (reg:CC 33))]
6312   "TARGET_64BIT"
6313   "lngr\t%0,%1"
6314   [(set_attr "op_type" "RRE")])
6315
6316 ;
6317 ; Floating point
6318 ;
6319
6320 (define_insn "*negabssf2"
6321   [(set (match_operand:SF 0 "register_operand" "=f")
6322         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
6323    (clobber (reg:CC 33))]
6324   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6325   "lnebr\t%0,%1"
6326   [(set_attr "op_type"  "RRE")
6327    (set_attr "type"     "fsimps")])
6328
6329 (define_insn "*negabsdf2"
6330   [(set (match_operand:DF 0 "register_operand" "=f")
6331         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
6332    (clobber (reg:CC 33))]
6333   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6334   "lndbr\t%0,%1"
6335   [(set_attr "op_type"  "RRE")
6336    (set_attr "type"     "fsimpd")])
6337
6338 ;;
6339 ;;- Square root instructions.
6340 ;;
6341
6342 ;
6343 ; sqrtdf2 instruction pattern(s).
6344 ;
6345
6346 (define_insn "sqrtdf2"
6347   [(set (match_operand:DF 0 "register_operand" "=f,f")
6348         (sqrt:DF (match_operand:DF 1 "general_operand" "f,R")))]
6349   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6350   "@
6351    sqdbr\t%0,%1
6352    sqdb\t%0,%1"
6353   [(set_attr "op_type" "RRE,RXE")
6354    (set_attr "type" "fsqrtd")])
6355
6356 ;
6357 ; sqrtsf2 instruction pattern(s).
6358 ;
6359
6360 (define_insn "sqrtsf2"
6361   [(set (match_operand:SF 0 "register_operand" "=f,f")
6362         (sqrt:SF (match_operand:SF 1 "general_operand" "f,R")))]
6363   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
6364   "@
6365    sqebr\t%0,%1
6366    sqeb\t%0,%1"
6367   [(set_attr "op_type" "RRE,RXE")
6368    (set_attr "type" "fsqrts")])
6369
6370 ;;
6371 ;;- One complement instructions.
6372 ;;
6373
6374 ;
6375 ; one_cmpldi2 instruction pattern(s).
6376 ;
6377
6378 (define_expand "one_cmpldi2"
6379   [(parallel
6380     [(set (match_operand:DI 0 "register_operand" "")
6381           (xor:DI (match_operand:DI 1 "register_operand" "")
6382                   (const_int -1)))
6383      (clobber (reg:CC 33))])]
6384   "TARGET_64BIT"
6385   "")
6386
6387 ;
6388 ; one_cmplsi2 instruction pattern(s).
6389 ;
6390
6391 (define_expand "one_cmplsi2"
6392   [(parallel
6393     [(set (match_operand:SI 0 "register_operand" "")
6394           (xor:SI (match_operand:SI 1 "register_operand" "")
6395                   (const_int -1)))
6396      (clobber (reg:CC 33))])]
6397   ""
6398   "")
6399
6400 ;
6401 ; one_cmplhi2 instruction pattern(s).
6402 ;
6403
6404 (define_expand "one_cmplhi2"
6405   [(parallel
6406     [(set (match_operand:HI 0 "register_operand" "")
6407           (xor:HI (match_operand:HI 1 "register_operand" "")
6408                   (const_int -1)))
6409      (clobber (reg:CC 33))])]
6410   ""
6411   "")
6412
6413 ;
6414 ; one_cmplqi2 instruction pattern(s).
6415 ;
6416
6417 (define_expand "one_cmplqi2"
6418   [(parallel
6419     [(set (match_operand:QI 0 "register_operand" "")
6420           (xor:QI (match_operand:QI 1 "register_operand" "")
6421                   (const_int -1)))
6422      (clobber (reg:CC 33))])]
6423   ""
6424   "")
6425
6426
6427 ;;
6428 ;;- Rotate instructions.
6429 ;;
6430
6431 ;
6432 ; rotldi3 instruction pattern(s).
6433 ;
6434
6435 (define_insn "rotldi3"
6436   [(set (match_operand:DI 0 "register_operand" "=d")
6437         (rotate:DI (match_operand:DI 1 "register_operand" "d")
6438                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6439   "TARGET_64BIT"
6440   "rllg\t%0,%1,%Y2"
6441   [(set_attr "op_type"  "RSE")
6442    (set_attr "atype"    "reg")])
6443
6444 ;
6445 ; rotlsi3 instruction pattern(s).
6446 ;
6447
6448 (define_insn "rotlsi3"
6449   [(set (match_operand:SI 0 "register_operand" "=d")
6450         (rotate:SI (match_operand:SI 1 "register_operand" "d")
6451                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6452   "TARGET_CPU_ZARCH"
6453   "rll\t%0,%1,%Y2"
6454   [(set_attr "op_type"  "RSE")
6455    (set_attr "atype"    "reg")])
6456
6457
6458 ;;
6459 ;;- Arithmetic shift instructions.
6460 ;;
6461
6462 ;
6463 ; ashldi3 instruction pattern(s).
6464 ;
6465
6466 (define_expand "ashldi3"
6467   [(set (match_operand:DI 0 "register_operand" "")
6468         (ashift:DI (match_operand:DI 1 "register_operand" "")
6469                    (match_operand:SI 2 "shift_count_operand" "")))]
6470   ""
6471   "")
6472
6473 (define_insn "*ashldi3_31"
6474   [(set (match_operand:DI 0 "register_operand" "=d")
6475         (ashift:DI (match_operand:DI 1 "register_operand" "0")
6476                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6477   "!TARGET_64BIT"
6478   "sldl\t%0,%Y2"
6479   [(set_attr "op_type"  "RS")
6480    (set_attr "atype"    "reg")])
6481
6482 (define_insn "*ashldi3_64"
6483   [(set (match_operand:DI 0 "register_operand" "=d")
6484         (ashift:DI (match_operand:DI 1 "register_operand" "d")
6485                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6486   "TARGET_64BIT"
6487   "sllg\t%0,%1,%Y2"
6488   [(set_attr "op_type"  "RSE")
6489    (set_attr "atype"    "reg")])
6490
6491 ;
6492 ; ashrdi3 instruction pattern(s).
6493 ;
6494
6495 (define_expand "ashrdi3"
6496   [(parallel
6497     [(set (match_operand:DI 0 "register_operand" "")
6498           (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6499                        (match_operand:SI 2 "shift_count_operand" "")))
6500      (clobber (reg:CC 33))])]
6501   ""
6502   "")
6503
6504 (define_insn "*ashrdi3_cc_31"
6505   [(set (reg 33)
6506         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6507                               (match_operand:SI 2 "shift_count_operand" "Y"))
6508                  (const_int 0)))
6509    (set (match_operand:DI 0 "register_operand" "=d")
6510         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6511   "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6512   "srda\t%0,%Y2"
6513   [(set_attr "op_type"  "RS")
6514    (set_attr "atype"    "reg")])
6515
6516 (define_insn "*ashrdi3_cconly_31"
6517   [(set (reg 33)
6518         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6519                               (match_operand:SI 2 "shift_count_operand" "Y"))
6520                  (const_int 0)))
6521    (clobber (match_scratch:DI 0 "=d"))]
6522   "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6523   "srda\t%0,%Y2"
6524   [(set_attr "op_type"  "RS")
6525    (set_attr "atype"    "reg")])
6526
6527 (define_insn "*ashrdi3_31"
6528   [(set (match_operand:DI 0 "register_operand" "=d")
6529         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6530                      (match_operand:SI 2 "shift_count_operand" "Y")))
6531    (clobber (reg:CC 33))]
6532   "!TARGET_64BIT"
6533   "srda\t%0,%Y2"
6534   [(set_attr "op_type"  "RS")
6535    (set_attr "atype"    "reg")])
6536
6537 (define_insn "*ashrdi3_cc_64"
6538   [(set (reg 33)
6539         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6540                               (match_operand:SI 2 "shift_count_operand" "Y"))
6541                  (const_int 0)))
6542    (set (match_operand:DI 0 "register_operand" "=d")
6543         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6544   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
6545   "srag\t%0,%1,%Y2"
6546   [(set_attr "op_type"  "RSE")
6547    (set_attr "atype"    "reg")])
6548
6549 (define_insn "*ashrdi3_cconly_64"
6550   [(set (reg 33)
6551         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6552                               (match_operand:SI 2 "shift_count_operand" "Y"))
6553                  (const_int 0)))
6554    (clobber (match_scratch:DI 0 "=d"))]
6555   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
6556   "srag\t%0,%1,%Y2"
6557   [(set_attr "op_type"  "RSE")
6558    (set_attr "atype"    "reg")])
6559
6560 (define_insn "*ashrdi3_64"
6561   [(set (match_operand:DI 0 "register_operand" "=d")
6562         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6563                      (match_operand:SI 2 "shift_count_operand" "Y")))
6564    (clobber (reg:CC 33))]
6565   "TARGET_64BIT"
6566   "srag\t%0,%1,%Y2"
6567   [(set_attr "op_type"  "RSE")
6568    (set_attr "atype"    "reg")])
6569
6570
6571 ;
6572 ; ashlsi3 instruction pattern(s).
6573 ;
6574
6575 (define_insn "ashlsi3"
6576   [(set (match_operand:SI 0 "register_operand" "=d")
6577         (ashift:SI (match_operand:SI 1 "register_operand" "0")
6578                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6579   ""
6580   "sll\t%0,%Y2"
6581   [(set_attr "op_type"  "RS")
6582    (set_attr "atype"    "reg")])
6583
6584 ;
6585 ; ashrsi3 instruction pattern(s).
6586 ;
6587
6588 (define_insn "*ashrsi3_cc"
6589   [(set (reg 33)
6590         (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6591                               (match_operand:SI 2 "shift_count_operand" "Y"))
6592                  (const_int 0)))
6593    (set (match_operand:SI 0 "register_operand" "=d")
6594         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
6595   "s390_match_ccmode(insn, CCSmode)"
6596   "sra\t%0,%Y2"
6597   [(set_attr "op_type"  "RS")
6598    (set_attr "atype"    "reg")])
6599
6600
6601 (define_insn "*ashrsi3_cconly"
6602   [(set (reg 33)
6603         (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6604                               (match_operand:SI 2 "shift_count_operand" "Y"))
6605                  (const_int 0)))
6606    (clobber (match_scratch:SI 0 "=d"))]
6607   "s390_match_ccmode(insn, CCSmode)"
6608   "sra\t%0,%Y2"
6609   [(set_attr "op_type"  "RS")
6610    (set_attr "atype"    "reg")])
6611
6612 (define_insn "ashrsi3"
6613   [(set (match_operand:SI 0 "register_operand" "=d")
6614         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6615                      (match_operand:SI 2 "shift_count_operand" "Y")))
6616    (clobber (reg:CC 33))]
6617   ""
6618   "sra\t%0,%Y2"
6619   [(set_attr "op_type"  "RS")
6620    (set_attr "atype"    "reg")])
6621
6622
6623 ;;
6624 ;;- logical shift instructions.
6625 ;;
6626
6627 ;
6628 ; lshrdi3 instruction pattern(s).
6629 ;
6630
6631 (define_expand "lshrdi3"
6632   [(set (match_operand:DI 0 "register_operand" "")
6633         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6634                      (match_operand:SI 2 "shift_count_operand" "")))]
6635   ""
6636   "")
6637
6638 (define_insn "*lshrdi3_31"
6639   [(set (match_operand:DI 0 "register_operand" "=d")
6640         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
6641                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6642   "!TARGET_64BIT"
6643   "srdl\t%0,%Y2"
6644    [(set_attr "op_type"  "RS")
6645     (set_attr "atype"    "reg")])
6646
6647 (define_insn "*lshrdi3_64"
6648   [(set (match_operand:DI 0 "register_operand" "=d")
6649         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6650                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6651   "TARGET_64BIT"
6652   "srlg\t%0,%1,%Y2"
6653   [(set_attr "op_type"  "RSE")
6654    (set_attr "atype"    "reg")])
6655
6656 ;
6657 ; lshrsi3 instruction pattern(s).
6658 ;
6659
6660 (define_insn "lshrsi3"
6661   [(set (match_operand:SI 0 "register_operand" "=d")
6662         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
6663                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6664   ""
6665   "srl\t%0,%Y2"
6666   [(set_attr "op_type"  "RS")
6667    (set_attr "atype"    "reg")])
6668
6669
6670 ;;
6671 ;; Branch instruction patterns.
6672 ;;
6673
6674 (define_expand "beq"
6675   [(match_operand 0 "" "")]
6676   ""
6677   "s390_emit_jump (operands[0],
6678     s390_emit_compare (EQ, s390_compare_op0, s390_compare_op1)); DONE;")
6679
6680 (define_expand "bne"
6681   [(match_operand 0 "" "")]
6682   ""
6683   "s390_emit_jump (operands[0],
6684     s390_emit_compare (NE, s390_compare_op0, s390_compare_op1)); DONE;")
6685
6686 (define_expand "bgt"
6687   [(match_operand 0 "" "")]
6688   ""
6689   "s390_emit_jump (operands[0],
6690     s390_emit_compare (GT, s390_compare_op0, s390_compare_op1)); DONE;")
6691
6692 (define_expand "bgtu"
6693   [(match_operand 0 "" "")]
6694   ""
6695   "s390_emit_jump (operands[0],
6696     s390_emit_compare (GTU, s390_compare_op0, s390_compare_op1)); DONE;")
6697
6698 (define_expand "blt"
6699   [(match_operand 0 "" "")]
6700   ""
6701   "s390_emit_jump (operands[0],
6702     s390_emit_compare (LT, s390_compare_op0, s390_compare_op1)); DONE;")
6703
6704 (define_expand "bltu"
6705   [(match_operand 0 "" "")]
6706   ""
6707   "s390_emit_jump (operands[0],
6708     s390_emit_compare (LTU, s390_compare_op0, s390_compare_op1)); DONE;")
6709
6710 (define_expand "bge"
6711   [(match_operand 0 "" "")]
6712   ""
6713   "s390_emit_jump (operands[0],
6714     s390_emit_compare (GE, s390_compare_op0, s390_compare_op1)); DONE;")
6715
6716 (define_expand "bgeu"
6717   [(match_operand 0 "" "")]
6718   ""
6719   "s390_emit_jump (operands[0],
6720     s390_emit_compare (GEU, s390_compare_op0, s390_compare_op1)); DONE;")
6721
6722 (define_expand "ble"
6723   [(match_operand 0 "" "")]
6724   ""
6725   "s390_emit_jump (operands[0],
6726     s390_emit_compare (LE, s390_compare_op0, s390_compare_op1)); DONE;")
6727
6728 (define_expand "bleu"
6729   [(match_operand 0 "" "")]
6730   ""
6731   "s390_emit_jump (operands[0],
6732     s390_emit_compare (LEU, s390_compare_op0, s390_compare_op1)); DONE;")
6733
6734 (define_expand "bunordered"
6735   [(match_operand 0 "" "")]
6736   ""
6737   "s390_emit_jump (operands[0],
6738     s390_emit_compare (UNORDERED, s390_compare_op0, s390_compare_op1)); DONE;")
6739
6740 (define_expand "bordered"
6741   [(match_operand 0 "" "")]
6742   ""
6743   "s390_emit_jump (operands[0],
6744     s390_emit_compare (ORDERED, s390_compare_op0, s390_compare_op1)); DONE;")
6745
6746 (define_expand "buneq"
6747   [(match_operand 0 "" "")]
6748   ""
6749   "s390_emit_jump (operands[0],
6750     s390_emit_compare (UNEQ, s390_compare_op0, s390_compare_op1)); DONE;")
6751
6752 (define_expand "bunlt"
6753   [(match_operand 0 "" "")]
6754   ""
6755   "s390_emit_jump (operands[0],
6756     s390_emit_compare (UNLT, s390_compare_op0, s390_compare_op1)); DONE;")
6757
6758 (define_expand "bungt"
6759   [(match_operand 0 "" "")]
6760   ""
6761   "s390_emit_jump (operands[0],
6762     s390_emit_compare (UNGT, s390_compare_op0, s390_compare_op1)); DONE;")
6763
6764 (define_expand "bunle"
6765   [(match_operand 0 "" "")]
6766   ""
6767   "s390_emit_jump (operands[0],
6768     s390_emit_compare (UNLE, s390_compare_op0, s390_compare_op1)); DONE;")
6769
6770 (define_expand "bunge"
6771   [(match_operand 0 "" "")]
6772   ""
6773   "s390_emit_jump (operands[0],
6774     s390_emit_compare (UNGE, s390_compare_op0, s390_compare_op1)); DONE;")
6775
6776 (define_expand "bltgt"
6777   [(match_operand 0 "" "")]
6778   ""
6779   "s390_emit_jump (operands[0],
6780     s390_emit_compare (LTGT, s390_compare_op0, s390_compare_op1)); DONE;")
6781
6782
6783 ;;
6784 ;;- Conditional jump instructions.
6785 ;;
6786
6787 (define_insn "*cjump_64"
6788   [(set (pc)
6789         (if_then_else
6790           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6791           (label_ref (match_operand 0 "" ""))
6792           (pc)))]
6793   "TARGET_CPU_ZARCH"
6794 {
6795   if (get_attr_length (insn) == 4)
6796     return "j%C1\t%l0";
6797   else
6798     return "jg%C1\t%l0";
6799 }
6800   [(set_attr "op_type" "RI")
6801    (set_attr "type"    "branch")
6802    (set (attr "length")
6803         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6804                       (const_int 4) (const_int 6)))])
6805
6806 (define_insn "*cjump_31"
6807   [(set (pc)
6808         (if_then_else
6809           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6810           (label_ref (match_operand 0 "" ""))
6811           (pc)))]
6812   "!TARGET_CPU_ZARCH"
6813 {
6814   if (get_attr_length (insn) == 4)
6815     return "j%C1\t%l0";
6816   else
6817     abort ();
6818 }
6819   [(set_attr "op_type" "RI")
6820    (set_attr "type"    "branch")
6821    (set (attr "length")
6822         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
6823           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6824                         (const_int 4) (const_int 6))
6825           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6826                         (const_int 4) (const_int 8))))])
6827
6828 (define_insn "*cjump_long"
6829   [(set (pc)
6830         (if_then_else
6831           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6832           (match_operand 0 "address_operand" "U")
6833           (pc)))]
6834   ""
6835 {
6836   if (get_attr_op_type (insn) == OP_TYPE_RR)
6837     return "b%C1r\t%0";
6838   else
6839     return "b%C1\t%a0";
6840 }
6841   [(set (attr "op_type")
6842         (if_then_else (match_operand 0 "register_operand" "")
6843                       (const_string "RR") (const_string "RX")))
6844    (set_attr "type"  "branch")
6845    (set_attr "atype" "agen")])
6846
6847
6848 ;;
6849 ;;- Negated conditional jump instructions.
6850 ;;
6851
6852 (define_insn "*icjump_64"
6853   [(set (pc)
6854         (if_then_else
6855           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6856           (pc)
6857           (label_ref (match_operand 0 "" ""))))]
6858   "TARGET_CPU_ZARCH"
6859 {
6860   if (get_attr_length (insn) == 4)
6861     return "j%D1\t%l0";
6862   else
6863     return "jg%D1\t%l0";
6864 }
6865   [(set_attr "op_type" "RI")
6866    (set_attr "type"    "branch")
6867    (set (attr "length")
6868         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6869                       (const_int 4) (const_int 6)))])
6870
6871 (define_insn "*icjump_31"
6872   [(set (pc)
6873         (if_then_else
6874           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6875           (pc)
6876           (label_ref (match_operand 0 "" ""))))]
6877   "!TARGET_CPU_ZARCH"
6878 {
6879   if (get_attr_length (insn) == 4)
6880     return "j%D1\t%l0";
6881   else
6882     abort ();
6883 }
6884   [(set_attr "op_type" "RI")
6885    (set_attr "type"    "branch")
6886    (set (attr "length")
6887         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
6888           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6889                         (const_int 4) (const_int 6))
6890           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6891                         (const_int 4) (const_int 8))))])
6892
6893 (define_insn "*icjump_long"
6894   [(set (pc)
6895         (if_then_else
6896           (match_operator 1 "s390_comparison" [(reg 33) (const_int 0)])
6897           (pc)
6898           (match_operand 0 "address_operand" "U")))]
6899   ""
6900 {
6901   if (get_attr_op_type (insn) == OP_TYPE_RR)
6902     return "b%D1r\t%0";
6903   else
6904     return "b%D1\t%a0";
6905 }
6906   [(set (attr "op_type")
6907         (if_then_else (match_operand 0 "register_operand" "")
6908                       (const_string "RR") (const_string "RX")))
6909    (set_attr "type"  "branch")
6910    (set_attr "atype" "agen")])
6911
6912 ;;
6913 ;;- Trap instructions.
6914 ;;
6915
6916 (define_insn "trap"
6917   [(trap_if (const_int 1) (const_int 0))]
6918   ""
6919   "j\t.+2"
6920   [(set_attr "op_type" "RI")
6921    (set_attr "type"  "branch")])
6922
6923 (define_expand "conditional_trap"
6924   [(trap_if (match_operand 0 "comparison_operator" "")
6925             (match_operand 1 "general_operand" ""))]
6926   ""
6927 {
6928   if (operands[1] != const0_rtx) FAIL;
6929   operands[0] = s390_emit_compare (GET_CODE (operands[0]), 
6930                                    s390_compare_op0, s390_compare_op1);
6931 })
6932
6933 (define_insn "*trap"
6934   [(trap_if (match_operator 0 "s390_comparison" [(reg 33) (const_int 0)])
6935             (const_int 0))]
6936   ""
6937   "j%C0\t.+2";
6938   [(set_attr "op_type" "RI")
6939    (set_attr "type"  "branch")])
6940
6941 ;;
6942 ;;- Loop instructions.
6943 ;;
6944 ;;  This is all complicated by the fact that since this is a jump insn
6945 ;;  we must handle our own output reloads.
6946
6947 (define_expand "doloop_end"
6948   [(use (match_operand 0 "" ""))        ; loop pseudo
6949    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
6950    (use (match_operand 2 "" ""))        ; max iterations
6951    (use (match_operand 3 "" ""))        ; loop level
6952    (use (match_operand 4 "" ""))]       ; label
6953   ""
6954 {
6955   if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
6956     emit_jump_insn (gen_doloop_si31 (operands[4], operands[0], operands[0]));
6957   else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
6958     emit_jump_insn (gen_doloop_si64 (operands[4], operands[0], operands[0]));
6959   else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
6960     emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
6961   else
6962     FAIL;
6963
6964   DONE;
6965 })
6966
6967 (define_insn_and_split "doloop_si64"
6968   [(set (pc)
6969         (if_then_else
6970           (ne (match_operand:SI 1 "register_operand" "d,d")
6971               (const_int 1))
6972           (label_ref (match_operand 0 "" ""))
6973           (pc)))
6974    (set (match_operand:SI 2 "nonimmediate_operand" "=1,?*m*d")
6975         (plus:SI (match_dup 1) (const_int -1)))
6976    (clobber (match_scratch:SI 3 "=X,&d"))
6977    (clobber (reg:CC 33))]
6978   "TARGET_CPU_ZARCH"
6979 {
6980   if (which_alternative != 0)
6981     return "#";
6982   else if (get_attr_length (insn) == 4)
6983     return "brct\t%1,%l0";
6984   else
6985     return "ahi\t%1,-1\;jgne\t%l0";
6986 }
6987   "&& reload_completed
6988    && (! REG_P (operands[2])
6989        || ! rtx_equal_p (operands[1], operands[2]))"
6990   [(set (match_dup 3) (match_dup 1))
6991    (parallel [(set (reg:CCAN 33)
6992                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
6993                                  (const_int 0)))
6994               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
6995    (set (match_dup 2) (match_dup 3))
6996    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
6997                            (label_ref (match_dup 0))
6998                            (pc)))]
6999   ""
7000   [(set_attr "op_type"  "RI")
7001    (set_attr "type"  "branch")
7002    (set (attr "length")
7003         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7004                       (const_int 4) (const_int 10)))])
7005
7006 (define_insn_and_split "doloop_si31"
7007   [(set (pc)
7008         (if_then_else
7009           (ne (match_operand:SI 1 "register_operand" "d,d")
7010               (const_int 1))
7011           (label_ref (match_operand 0 "" ""))
7012           (pc)))
7013    (set (match_operand:SI 2 "nonimmediate_operand" "=1,?*m*d")
7014         (plus:SI (match_dup 1) (const_int -1)))
7015    (clobber (match_scratch:SI 3 "=X,&d"))
7016    (clobber (reg:CC 33))]
7017   "!TARGET_CPU_ZARCH"
7018 {
7019   if (which_alternative != 0)
7020     return "#";
7021   else if (get_attr_length (insn) == 4)
7022     return "brct\t%1,%l0";
7023   else
7024     abort ();
7025 }
7026   "&& reload_completed
7027    && (! REG_P (operands[2])
7028        || ! rtx_equal_p (operands[1], operands[2]))"
7029   [(set (match_dup 3) (match_dup 1))
7030    (parallel [(set (reg:CCAN 33)
7031                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7032                                  (const_int 0)))
7033               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7034    (set (match_dup 2) (match_dup 3))
7035    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
7036                            (label_ref (match_dup 0))
7037                            (pc)))]
7038   ""
7039   [(set_attr "op_type"  "RI")
7040    (set_attr "type"  "branch")
7041    (set (attr "length")
7042         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7043           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7044                         (const_int 4) (const_int 6))
7045           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7046                         (const_int 4) (const_int 8))))])
7047
7048 (define_insn "*doloop_si_long"
7049   [(set (pc)
7050         (if_then_else
7051           (ne (match_operand:SI 1 "register_operand" "d,d")
7052               (const_int 1))
7053           (match_operand 0 "address_operand" "U,U")
7054           (pc)))
7055    (set (match_operand:SI 2 "register_operand" "=1,?*m*d")
7056         (plus:SI (match_dup 1) (const_int -1)))
7057    (clobber (match_scratch:SI 3 "=X,&d"))
7058    (clobber (reg:CC 33))]
7059   "!TARGET_CPU_ZARCH"
7060 {
7061   if (get_attr_op_type (insn) == OP_TYPE_RR)
7062     return "bctr\t%1,%0";
7063   else
7064     return "bct\t%1,%a0";
7065 }
7066   [(set (attr "op_type")
7067         (if_then_else (match_operand 0 "register_operand" "")
7068                       (const_string "RR") (const_string "RX")))
7069    (set_attr "type"  "branch")
7070    (set_attr "atype" "agen")])
7071
7072 (define_insn_and_split "doloop_di"
7073   [(set (pc)
7074         (if_then_else
7075           (ne (match_operand:DI 1 "register_operand" "d,d")
7076               (const_int 1))
7077           (label_ref (match_operand 0 "" ""))
7078           (pc)))
7079    (set (match_operand:DI 2 "nonimmediate_operand" "=1,?*m*r")
7080         (plus:DI (match_dup 1) (const_int -1)))
7081    (clobber (match_scratch:DI 3 "=X,&d"))
7082    (clobber (reg:CC 33))]
7083   "TARGET_64BIT"
7084 {
7085   if (which_alternative != 0)
7086     return "#";
7087   else if (get_attr_length (insn) == 4)
7088     return "brctg\t%1,%l0";
7089   else
7090     return "aghi\t%1,-1\;jgne\t%l0";
7091 }
7092   "&& reload_completed
7093    && (! REG_P (operands[2])
7094        || ! rtx_equal_p (operands[1], operands[2]))"
7095   [(set (match_dup 3) (match_dup 1))
7096    (parallel [(set (reg:CCAN 33)
7097                    (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
7098                                  (const_int 0)))
7099               (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
7100    (set (match_dup 2) (match_dup 3))
7101    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
7102                            (label_ref (match_dup 0))
7103                            (pc)))]
7104   ""
7105   [(set_attr "op_type"  "RI")
7106    (set_attr "type"  "branch")
7107    (set (attr "length")
7108         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7109                       (const_int 4) (const_int 10)))])
7110
7111 ;;
7112 ;;- Unconditional jump instructions.
7113 ;;
7114
7115 ;
7116 ; jump instruction pattern(s).
7117 ;
7118
7119 (define_expand "jump"
7120   [(match_operand 0 "" "")]
7121   ""
7122   "s390_emit_jump (operands[0], NULL_RTX); DONE;")
7123
7124 (define_insn "*jump64"
7125   [(set (pc) (label_ref (match_operand 0 "" "")))]
7126   "TARGET_CPU_ZARCH"
7127 {
7128   if (get_attr_length (insn) == 4)
7129     return "j\t%l0";
7130   else
7131     return "jg\t%l0";
7132 }
7133   [(set_attr "op_type" "RI")
7134    (set_attr "type"  "branch")
7135    (set (attr "length")
7136         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7137                       (const_int 4) (const_int 6)))])
7138
7139 (define_insn "*jump31"
7140   [(set (pc) (label_ref (match_operand 0 "" "")))]
7141   "!TARGET_CPU_ZARCH"
7142 {
7143   if (get_attr_length (insn) == 4)
7144     return "j\t%l0";
7145   else
7146     abort ();
7147 }
7148   [(set_attr "op_type" "RI")
7149    (set_attr "type"  "branch")
7150    (set (attr "length")
7151         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7152           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7153                         (const_int 4) (const_int 6))
7154           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7155                         (const_int 4) (const_int 8))))])
7156
7157 ;
7158 ; indirect-jump instruction pattern(s).
7159 ;
7160
7161 (define_insn "indirect_jump"
7162  [(set (pc) (match_operand 0 "address_operand" "U"))]
7163   ""
7164 {
7165   if (get_attr_op_type (insn) == OP_TYPE_RR)
7166     return "br\t%0";
7167   else
7168     return "b\t%a0";
7169 }
7170   [(set (attr "op_type")
7171         (if_then_else (match_operand 0 "register_operand" "")
7172                       (const_string "RR") (const_string "RX")))
7173    (set_attr "type"  "branch")
7174    (set_attr "atype" "agen")])
7175
7176 ;
7177 ; casesi instruction pattern(s).
7178 ;
7179
7180 (define_insn "casesi_jump"
7181  [(set (pc) (match_operand 0 "address_operand" "U"))
7182    (use (label_ref (match_operand 1 "" "")))]
7183   ""
7184 {
7185   if (get_attr_op_type (insn) == OP_TYPE_RR)
7186     return "br\t%0";
7187   else
7188     return "b\t%a0";
7189 }
7190   [(set (attr "op_type")
7191         (if_then_else (match_operand 0 "register_operand" "")
7192                       (const_string "RR") (const_string "RX")))
7193    (set_attr "type"  "branch")
7194    (set_attr "atype" "agen")])
7195
7196 (define_expand "casesi"
7197   [(match_operand:SI 0 "general_operand" "")
7198    (match_operand:SI 1 "general_operand" "")
7199    (match_operand:SI 2 "general_operand" "")
7200    (label_ref (match_operand 3 "" ""))
7201    (label_ref (match_operand 4 "" ""))]
7202   ""
7203 {
7204    rtx index  = gen_reg_rtx (SImode);
7205    rtx base   = gen_reg_rtx (Pmode);
7206    rtx target = gen_reg_rtx (Pmode);
7207
7208    emit_move_insn (index, operands[0]);
7209    emit_insn (gen_subsi3 (index, index, operands[1]));
7210    emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
7211                             operands[4]);
7212
7213    if (Pmode != SImode)
7214      index = convert_to_mode (Pmode, index, 1);
7215    if (GET_CODE (index) != REG)
7216      index = copy_to_mode_reg (Pmode, index);
7217
7218    if (TARGET_64BIT)
7219        emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
7220    else
7221        emit_insn (gen_ashlsi3 (index, index, const2_rtx));
7222
7223    emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
7224
7225    index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
7226    emit_move_insn (target, index);
7227
7228    if (flag_pic)
7229      target = gen_rtx_PLUS (Pmode, base, target);
7230    emit_jump_insn (gen_casesi_jump (target, operands[3]));
7231
7232    DONE;
7233 })
7234
7235
7236 ;;
7237 ;;- Jump to subroutine.
7238 ;;
7239 ;;
7240
7241 ;
7242 ; untyped call instruction pattern(s).
7243 ;
7244
7245 ;; Call subroutine returning any type.
7246 (define_expand "untyped_call"
7247   [(parallel [(call (match_operand 0 "" "")
7248                     (const_int 0))
7249               (match_operand 1 "" "")
7250               (match_operand 2 "" "")])]
7251   ""
7252 {
7253   int i;
7254
7255   emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
7256
7257   for (i = 0; i < XVECLEN (operands[2], 0); i++)
7258     {
7259       rtx set = XVECEXP (operands[2], 0, i);
7260       emit_move_insn (SET_DEST (set), SET_SRC (set));
7261     }
7262
7263   /* The optimizer does not know that the call sets the function value
7264      registers we stored in the result block.  We avoid problems by
7265      claiming that all hard registers are used and clobbered at this
7266      point.  */
7267   emit_insn (gen_blockage ());
7268
7269   DONE;
7270 })
7271
7272 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7273 ;; all of memory.  This blocks insns from being moved across this point.
7274
7275 (define_insn "blockage"
7276   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
7277   ""
7278   ""
7279   [(set_attr "type"    "none")
7280    (set_attr "length"  "0")])
7281
7282 ;
7283 ; sibcall patterns
7284 ;
7285
7286 (define_expand "sibcall"
7287   [(call (match_operand 0 "" "")
7288          (match_operand 1 "" ""))]
7289   ""
7290 {
7291   s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
7292   DONE;
7293 })
7294
7295 (define_insn "*sibcall_br"
7296   [(call (mem:QI (reg 1))
7297          (match_operand 0 "const_int_operand" "n"))]
7298   "SIBLING_CALL_P (insn)
7299    && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
7300   "br\t%%r1"
7301   [(set_attr "op_type" "RR")
7302    (set_attr "type"  "branch")
7303    (set_attr "atype" "agen")])
7304
7305 (define_insn "*sibcall_brc"
7306   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7307          (match_operand 1 "const_int_operand" "n"))]
7308   "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7309   "j\t%0"
7310   [(set_attr "op_type" "RI")
7311    (set_attr "type"    "branch")])
7312
7313 (define_insn "*sibcall_brcl"
7314   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7315          (match_operand 1 "const_int_operand" "n"))]
7316   "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7317   "jg\t%0"
7318   [(set_attr "op_type" "RIL")
7319    (set_attr "type"    "branch")])
7320
7321 ;
7322 ; sibcall_value patterns
7323 ;
7324
7325 (define_expand "sibcall_value"
7326   [(set (match_operand 0 "" "")
7327         (call (match_operand 1 "" "")
7328               (match_operand 2 "" "")))]
7329   ""
7330 {
7331   s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
7332   DONE;
7333 })
7334
7335 (define_insn "*sibcall_value_br"
7336   [(set (match_operand 0 "" "")
7337         (call (mem:QI (reg 1))
7338               (match_operand 1 "const_int_operand" "n")))]
7339   "SIBLING_CALL_P (insn)
7340    && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
7341   "br\t%%r1"
7342   [(set_attr "op_type" "RR")
7343    (set_attr "type"  "branch")
7344    (set_attr "atype" "agen")])
7345
7346 (define_insn "*sibcall_value_brc"
7347   [(set (match_operand 0 "" "")
7348         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7349               (match_operand 2 "const_int_operand" "n")))]
7350   "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7351   "j\t%1"
7352   [(set_attr "op_type" "RI")
7353    (set_attr "type"    "branch")])
7354
7355 (define_insn "*sibcall_value_brcl"
7356   [(set (match_operand 0 "" "")
7357         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7358               (match_operand 2 "const_int_operand" "n")))]
7359   "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7360   "jg\t%1"
7361   [(set_attr "op_type" "RIL")
7362    (set_attr "type"    "branch")])
7363
7364
7365 ;
7366 ; call instruction pattern(s).
7367 ;
7368
7369 (define_expand "call"
7370   [(call (match_operand 0 "" "")
7371          (match_operand 1 "" ""))
7372    (use (match_operand 2 "" ""))]
7373   ""
7374 {
7375   s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
7376                   gen_rtx_REG (Pmode, RETURN_REGNUM));
7377   DONE;
7378 })
7379
7380 (define_insn "*bras"
7381   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7382          (match_operand 1 "const_int_operand" "n"))
7383    (clobber (match_operand 2 "register_operand" "=r"))]
7384   "!SIBLING_CALL_P (insn)
7385    && TARGET_SMALL_EXEC
7386    && GET_MODE (operands[2]) == Pmode"
7387   "bras\t%2,%0"
7388   [(set_attr "op_type" "RI")
7389    (set_attr "type"    "jsr")])
7390
7391 (define_insn "*brasl"
7392   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7393          (match_operand 1 "const_int_operand" "n"))
7394    (clobber (match_operand 2 "register_operand" "=r"))]
7395   "!SIBLING_CALL_P (insn)
7396    && TARGET_CPU_ZARCH
7397    && GET_MODE (operands[2]) == Pmode"
7398   "brasl\t%2,%0"
7399   [(set_attr "op_type" "RIL")
7400    (set_attr "type"    "jsr")])
7401
7402 (define_insn "*basr"
7403   [(call (mem:QI (match_operand 0 "address_operand" "U"))
7404          (match_operand 1 "const_int_operand" "n"))
7405    (clobber (match_operand 2 "register_operand" "=r"))]
7406   "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
7407 {
7408   if (get_attr_op_type (insn) == OP_TYPE_RR)
7409     return "basr\t%2,%0";
7410   else
7411     return "bas\t%2,%a0";
7412 }
7413   [(set (attr "op_type")
7414         (if_then_else (match_operand 0 "register_operand" "")
7415                       (const_string "RR") (const_string "RX")))
7416    (set_attr "type"  "jsr")
7417    (set_attr "atype" "agen")])
7418
7419 ;
7420 ; call_value instruction pattern(s).
7421 ;
7422
7423 (define_expand "call_value"
7424   [(set (match_operand 0 "" "")
7425         (call (match_operand 1 "" "")
7426               (match_operand 2 "" "")))
7427    (use (match_operand 3 "" ""))]
7428   ""
7429 {
7430   s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
7431                   gen_rtx_REG (Pmode, RETURN_REGNUM));
7432   DONE;
7433 })
7434
7435 (define_insn "*bras_r"
7436   [(set (match_operand 0 "" "")
7437         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7438               (match_operand:SI 2 "const_int_operand" "n")))
7439    (clobber (match_operand 3 "register_operand" "=r"))]
7440   "!SIBLING_CALL_P (insn)
7441    && TARGET_SMALL_EXEC
7442    && GET_MODE (operands[3]) == Pmode"
7443   "bras\t%3,%1"
7444   [(set_attr "op_type" "RI")
7445    (set_attr "type"    "jsr")])
7446
7447 (define_insn "*brasl_r"
7448   [(set (match_operand 0 "" "")
7449         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7450               (match_operand 2 "const_int_operand" "n")))
7451    (clobber (match_operand 3 "register_operand" "=r"))]
7452   "!SIBLING_CALL_P (insn)
7453    && TARGET_CPU_ZARCH
7454    && GET_MODE (operands[3]) == Pmode"
7455   "brasl\t%3,%1"
7456   [(set_attr "op_type" "RIL")
7457    (set_attr "type"    "jsr")])
7458
7459 (define_insn "*basr_r"
7460   [(set (match_operand 0 "" "")
7461         (call (mem:QI (match_operand 1 "address_operand" "U"))
7462               (match_operand 2 "const_int_operand" "n")))
7463    (clobber (match_operand 3 "register_operand" "=r"))]
7464   "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
7465 {
7466   if (get_attr_op_type (insn) == OP_TYPE_RR)
7467     return "basr\t%3,%1";
7468   else
7469     return "bas\t%3,%a1";
7470 }
7471   [(set (attr "op_type")
7472         (if_then_else (match_operand 1 "register_operand" "")
7473                       (const_string "RR") (const_string "RX")))
7474    (set_attr "type"  "jsr")
7475    (set_attr "atype" "agen")])
7476
7477 ;;
7478 ;;- Thread-local storage support.
7479 ;;
7480
7481 (define_expand "get_tp_64"
7482   [(set (match_operand:DI 0 "nonimmediate_operand" "") (reg:DI 36))]
7483   "TARGET_64BIT"
7484   "")
7485
7486 (define_expand "get_tp_31"
7487   [(set (match_operand:SI 0 "nonimmediate_operand" "") (reg:SI 36))]
7488   "!TARGET_64BIT"
7489   "")
7490
7491 (define_expand "set_tp_64"
7492   [(set (reg:DI 36) (match_operand:DI 0 "nonimmediate_operand" ""))
7493    (unspec_volatile [(reg:DI 36)] UNSPECV_SET_TP)]
7494   "TARGET_64BIT"
7495   "")
7496
7497 (define_expand "set_tp_31"
7498   [(set (reg:SI 36) (match_operand:SI 0 "nonimmediate_operand" ""))
7499    (unspec_volatile [(reg:SI 36)] UNSPECV_SET_TP)]
7500   "!TARGET_64BIT"
7501   "")
7502
7503 (define_insn "*set_tp"
7504   [(unspec_volatile [(reg 36)] UNSPECV_SET_TP)]
7505   ""
7506   ""
7507   [(set_attr "type" "none")
7508    (set_attr "length" "0")])
7509
7510 (define_insn "*tls_load_64"
7511   [(set (match_operand:DI 0 "register_operand" "=d")
7512         (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
7513                     (match_operand:DI 2 "" "")]
7514                    UNSPEC_TLS_LOAD))]
7515   "TARGET_64BIT"
7516   "lg\t%0,%1%J2"
7517   [(set_attr "op_type" "RXE")])
7518
7519 (define_insn "*tls_load_31"
7520   [(set (match_operand:SI 0 "register_operand" "=d,d")
7521         (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
7522                     (match_operand:SI 2 "" "")]
7523                    UNSPEC_TLS_LOAD))]
7524   "!TARGET_64BIT"
7525   "@
7526    l\t%0,%1%J2
7527    ly\t%0,%1%J2"
7528   [(set_attr "op_type" "RX,RXY")])
7529
7530 (define_insn "*bras_tls"
7531   [(set (match_operand 0 "" "")
7532         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7533               (match_operand 2 "const_int_operand" "n")))
7534    (clobber (match_operand 3 "register_operand" "=r"))
7535    (use (match_operand 4 "" ""))]
7536   "!SIBLING_CALL_P (insn)
7537    && TARGET_SMALL_EXEC
7538    && GET_MODE (operands[3]) == Pmode"
7539   "bras\t%3,%1%J4"
7540   [(set_attr "op_type" "RI")
7541    (set_attr "type"    "jsr")])
7542
7543 (define_insn "*brasl_tls"
7544   [(set (match_operand 0 "" "")
7545         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7546               (match_operand 2 "const_int_operand" "n")))
7547    (clobber (match_operand 3 "register_operand" "=r"))
7548    (use (match_operand 4 "" ""))]
7549   "!SIBLING_CALL_P (insn)
7550    && TARGET_CPU_ZARCH
7551    && GET_MODE (operands[3]) == Pmode"
7552   "brasl\t%3,%1%J4"
7553   [(set_attr "op_type" "RIL")
7554    (set_attr "type"    "jsr")])
7555
7556 (define_insn "*basr_tls"
7557   [(set (match_operand 0 "" "")
7558         (call (mem:QI (match_operand 1 "address_operand" "U"))
7559               (match_operand 2 "const_int_operand" "n")))
7560    (clobber (match_operand 3 "register_operand" "=r"))
7561    (use (match_operand 4 "" ""))]
7562   "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
7563 {
7564   if (get_attr_op_type (insn) == OP_TYPE_RR)
7565     return "basr\t%3,%1%J4";
7566   else
7567     return "bas\t%3,%a1%J4";
7568 }
7569   [(set (attr "op_type")
7570         (if_then_else (match_operand 1 "register_operand" "")
7571                       (const_string "RR") (const_string "RX")))
7572    (set_attr "type"  "jsr")
7573    (set_attr "atype" "agen")])
7574
7575 ;;
7576 ;;- Miscellaneous instructions.
7577 ;;
7578
7579 ;
7580 ; allocate stack instruction pattern(s).
7581 ;
7582
7583 (define_expand "allocate_stack"
7584   [(match_operand 0 "general_operand" "")
7585    (match_operand 1 "general_operand" "")]
7586  "TARGET_BACKCHAIN || TARGET_KERNEL_BACKCHAIN"
7587 {
7588   rtx temp = gen_reg_rtx (Pmode);
7589
7590   emit_move_insn (temp, s390_back_chain_rtx ());
7591   anti_adjust_stack (operands[1]);
7592   emit_move_insn (s390_back_chain_rtx (), temp);
7593
7594   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
7595   DONE;
7596 })
7597
7598
7599 ;
7600 ; setjmp instruction pattern.
7601 ;
7602
7603 (define_expand "builtin_setjmp_receiver"
7604   [(match_operand 0 "" "")]
7605   "flag_pic"
7606 {
7607   emit_insn (s390_load_got ());
7608   emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
7609   DONE;
7610 })
7611
7612 ;; These patterns say how to save and restore the stack pointer.  We need not
7613 ;; save the stack pointer at function level since we are careful to
7614 ;; preserve the backchain.  At block level, we have to restore the backchain
7615 ;; when we restore the stack pointer.
7616 ;;
7617 ;; For nonlocal gotos, we must save both the stack pointer and its
7618 ;; backchain and restore both.  Note that in the nonlocal case, the
7619 ;; save area is a memory location.
7620
7621 (define_expand "save_stack_function"
7622   [(match_operand 0 "general_operand" "")
7623    (match_operand 1 "general_operand" "")]
7624   ""
7625   "DONE;")
7626
7627 (define_expand "restore_stack_function"
7628   [(match_operand 0 "general_operand" "")
7629    (match_operand 1 "general_operand" "")]
7630   ""
7631   "DONE;")
7632
7633 (define_expand "restore_stack_block"
7634   [(match_operand 0 "register_operand" "")
7635    (match_operand 1 "register_operand" "")]
7636   "TARGET_BACKCHAIN || TARGET_KERNEL_BACKCHAIN"
7637 {
7638   rtx temp = gen_reg_rtx (Pmode);
7639
7640   emit_move_insn (temp, s390_back_chain_rtx ());
7641   emit_move_insn (operands[0], operands[1]);
7642   emit_move_insn (s390_back_chain_rtx (), temp);
7643
7644   DONE;
7645 })
7646
7647 (define_expand "save_stack_nonlocal"
7648   [(match_operand 0 "memory_operand" "")
7649    (match_operand 1 "register_operand" "")]
7650   ""
7651 {
7652   enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
7653   rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
7654
7655   /* Copy the backchain to the first word, sp to the second and the
7656      literal pool base to the third.  */
7657
7658   if (TARGET_BACKCHAIN || TARGET_KERNEL_BACKCHAIN)
7659     {
7660       rtx temp = force_reg (Pmode, s390_back_chain_rtx ());
7661       emit_move_insn (operand_subword (operands[0], 0, 0, mode), temp);
7662     }
7663
7664   emit_move_insn (operand_subword (operands[0], 1, 0, mode), operands[1]);
7665   emit_move_insn (operand_subword (operands[0], 2, 0, mode), base);
7666
7667   DONE;
7668 })
7669
7670 (define_expand "restore_stack_nonlocal"
7671   [(match_operand 0 "register_operand" "")
7672    (match_operand 1 "memory_operand" "")]
7673   ""
7674 {
7675   enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
7676   rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
7677   rtx temp = NULL_RTX;
7678
7679   /* Restore the backchain from the first word, sp from the second and the
7680      literal pool base from the third.  */
7681
7682   if (TARGET_BACKCHAIN || TARGET_KERNEL_BACKCHAIN)
7683     temp = force_reg (Pmode, operand_subword (operands[1], 0, 0, mode));
7684     
7685   emit_move_insn (base, operand_subword (operands[1], 2, 0, mode));
7686   emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, mode));
7687
7688   if (temp)
7689     emit_move_insn (s390_back_chain_rtx (), temp);
7690
7691   emit_insn (gen_rtx_USE (VOIDmode, base));
7692   DONE;
7693 })
7694
7695
7696 ;
7697 ; nop instruction pattern(s).
7698 ;
7699
7700 (define_insn "nop"
7701   [(const_int 0)]
7702   ""
7703   "lr\t0,0"
7704   [(set_attr "op_type" "RR")])
7705
7706
7707 ;
7708 ; Special literal pool access instruction pattern(s).
7709 ;
7710
7711 (define_insn "*pool_entry"
7712   [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
7713                     UNSPECV_POOL_ENTRY)]
7714   ""
7715 {
7716   enum machine_mode mode = GET_MODE (PATTERN (insn));
7717   unsigned int align = GET_MODE_BITSIZE (mode);
7718   s390_output_pool_entry (operands[0], mode, align);
7719   return "";
7720 }
7721   [(set (attr "length")
7722         (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
7723
7724 (define_insn "pool_align"
7725   [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
7726                     UNSPECV_POOL_ALIGN)]
7727   ""
7728   ".align\t%0"
7729   [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
7730
7731 (define_insn "pool_section_start"
7732   [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
7733   ""
7734   ".section\t.rodata"
7735   [(set_attr "length" "0")])
7736
7737 (define_insn "pool_section_end"
7738   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
7739   ""
7740   ".previous"
7741   [(set_attr "length" "0")])
7742
7743 (define_insn "main_base_31_small"
7744   [(set (match_operand 0 "register_operand" "=a")
7745         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7746   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7747   "basr\t%0,0"
7748   [(set_attr "op_type" "RR")
7749    (set_attr "type"    "la")])
7750
7751 (define_insn "main_base_31_large"
7752   [(set (match_operand 0 "register_operand" "=a")
7753         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
7754    (set (pc) (label_ref (match_operand 2 "" "")))]
7755   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7756   "bras\t%0,%2"
7757   [(set_attr "op_type" "RI")])
7758
7759 (define_insn "main_base_64"
7760   [(set (match_operand 0 "register_operand" "=a")
7761         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7762   "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7763   "larl\t%0,%1"
7764   [(set_attr "op_type" "RIL")
7765    (set_attr "type"    "larl")])
7766
7767 (define_insn "main_pool"
7768   [(set (match_operand 0 "register_operand" "=a")
7769         (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
7770   "GET_MODE (operands[0]) == Pmode"
7771   "* abort ();"
7772   [(set (attr "type") 
7773         (if_then_else (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
7774                       (const_string "larl") (const_string "la")))])
7775
7776 (define_insn "reload_base_31"
7777   [(set (match_operand 0 "register_operand" "=a")
7778         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7779   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7780   "basr\t%0,0\;la\t%0,%1-.(%0)"
7781   [(set_attr "length" "6")
7782    (set_attr "type" "la")])
7783
7784 (define_insn "reload_base_64"
7785   [(set (match_operand 0 "register_operand" "=a")
7786         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7787   "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7788   "larl\t%0,%1"
7789   [(set_attr "op_type" "RIL")
7790    (set_attr "type"    "larl")])
7791
7792 (define_insn "pool"
7793   [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
7794   ""
7795   "* abort ();"
7796   [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
7797
7798 ;;
7799 ;; Insns related to generating the function prologue and epilogue.
7800 ;;
7801
7802
7803 (define_expand "prologue"
7804   [(use (const_int 0))]
7805   ""
7806   "s390_emit_prologue (); DONE;")
7807
7808 (define_insn "prologue_tpf"
7809   [(unspec_volatile [(const_int 0)] UNSPECV_TPF_PROLOGUE)
7810    (clobber (reg:DI 1))]
7811   "TARGET_TPF_PROFILING"
7812   "bas\t%%r1,4064"
7813   [(set_attr "type" "jsr")
7814    (set_attr "op_type" "RX")])
7815
7816 (define_expand "epilogue"
7817   [(use (const_int 1))]
7818   ""
7819   "s390_emit_epilogue (false); DONE;")
7820
7821 (define_insn "epilogue_tpf"
7822   [(unspec_volatile [(const_int 0)] UNSPECV_TPF_EPILOGUE)
7823    (clobber (reg:DI 1))]
7824   "TARGET_TPF_PROFILING"
7825   "bas\t%%r1,4070"
7826   [(set_attr "type" "jsr")
7827    (set_attr "op_type" "RX")])
7828
7829
7830 (define_expand "sibcall_epilogue"
7831   [(use (const_int 0))]
7832   ""
7833   "s390_emit_epilogue (true); DONE;")
7834
7835 (define_insn "*return"
7836   [(return)
7837    (use (match_operand 0 "register_operand" "a"))]
7838   "GET_MODE (operands[0]) == Pmode"
7839   "br\t%0"
7840   [(set_attr "op_type" "RR")
7841    (set_attr "type"    "jsr")
7842    (set_attr "atype"   "agen")])
7843
7844
7845 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
7846 ;; pointer. This is used for compatibility.
7847
7848 (define_expand "ptr_extend"
7849   [(set (match_operand:DI 0 "register_operand" "=r")
7850         (match_operand:SI 1 "register_operand" "r"))]
7851   "TARGET_64BIT"
7852 {
7853   emit_insn (gen_anddi3 (operands[0],
7854                          gen_lowpart (DImode, operands[1]),
7855                          GEN_INT (0x7fffffff)));
7856   DONE;
7857 })
7858
7859 ;; Instruction definition to expand eh_return macro to support
7860 ;; swapping in special linkage return addresses.
7861
7862 (define_expand "eh_return"
7863   [(use (match_operand 0 "register_operand" ""))]
7864   "TARGET_TPF"
7865 {
7866   s390_emit_tpf_eh_return (operands[0]);
7867   DONE;
7868 })
7869