OSDN Git Service

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