OSDN Git Service

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