OSDN Git Service

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