OSDN Git Service

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