OSDN Git Service

* config/s390/s390.md ("movstr_short_64", "movstr_short_31"): Merge ...
[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 64-bit, zero-extending from memory to register
1360      is just as fast as a QImode load.  */
1361   if (TARGET_64BIT && optimize && !no_new_pseudos
1362       && register_operand (operands[0], VOIDmode)
1363       && memory_operand (operands[1], VOIDmode))
1364     {
1365       rtx tmp = gen_reg_rtx (DImode);
1366       rtx ext = gen_rtx_ZERO_EXTEND (DImode, 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   int regno;
1591   int count;
1592   rtx from;
1593   int i, off;
1594
1595   /* Support only loading a constant number of fixed-point registers from
1596      memory and only bother with this if more than two */
1597   if (GET_CODE (operands[2]) != CONST_INT
1598       || INTVAL (operands[2]) < 2
1599       || INTVAL (operands[2]) > 16
1600       || GET_CODE (operands[1]) != MEM
1601       || GET_CODE (operands[0]) != REG
1602       || REGNO (operands[0]) >= 16)
1603     FAIL;
1604
1605   count = INTVAL (operands[2]);
1606   regno = REGNO (operands[0]);
1607
1608   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1609   if (no_new_pseudos)
1610     {
1611       if (GET_CODE (XEXP (operands[1], 0)) == REG)
1612         {
1613           from = XEXP (operands[1], 0);
1614           off = 0;
1615         }
1616       else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
1617                && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
1618                && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
1619         {
1620           from = XEXP (XEXP (operands[1], 0), 0);
1621           off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
1622         }
1623       else
1624         FAIL;
1625
1626       if (from == frame_pointer_rtx || from == arg_pointer_rtx)
1627         FAIL;
1628     }
1629   else
1630     {
1631       from = force_reg (Pmode, XEXP (operands[1], 0));
1632       off = 0;
1633     }
1634
1635   for (i = 0; i < count; i++)
1636     XVECEXP (operands[3], 0, i)
1637       = gen_rtx_SET (VOIDmode, gen_rtx_REG (Pmode, regno + i),
1638                      change_address (operands[1], Pmode,
1639                                      plus_constant (from,
1640                                                     off + i * UNITS_PER_WORD)));
1641 })
1642
1643 (define_insn "*load_multiple_di"
1644   [(match_parallel 0 "load_multiple_operation"
1645                    [(set (match_operand:DI 1 "register_operand" "=r")
1646                          (match_operand:DI 2 "s_operand" "QS"))])]
1647   ""
1648 {
1649   int words = XVECLEN (operands[0], 0);
1650   operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
1651   return "lmg\t%1,%0,%2";
1652 }
1653    [(set_attr "op_type" "RSY")
1654     (set_attr "type"    "lm")])
1655
1656 (define_insn "*load_multiple_si"
1657   [(match_parallel 0 "load_multiple_operation"
1658                    [(set (match_operand:SI 1 "register_operand" "=r,r")
1659                          (match_operand:SI 2 "s_operand" "Q,S"))])]
1660   ""
1661 {
1662   int words = XVECLEN (operands[0], 0);
1663   operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
1664   return which_alternative == 0 ? "lm\t%1,%0,%2" : "lmy\t%1,%0,%2";
1665 }
1666    [(set_attr "op_type" "RS,RSY")
1667     (set_attr "type"    "lm")])
1668
1669 ;
1670 ; store multiple pattern(s).
1671 ;
1672
1673 (define_expand "store_multiple"
1674   [(match_par_dup 3 [(set (match_operand 0 "" "")
1675                           (match_operand 1 "" ""))
1676                      (use (match_operand 2 "" ""))])]
1677   ""
1678 {
1679   int regno;
1680   int count;
1681   rtx to;
1682   int i, off;
1683
1684   /* Support only storing a constant number of fixed-point registers to
1685      memory and only bother with this if more than two.  */
1686   if (GET_CODE (operands[2]) != CONST_INT
1687       || INTVAL (operands[2]) < 2
1688       || INTVAL (operands[2]) > 16
1689       || GET_CODE (operands[0]) != MEM
1690       || GET_CODE (operands[1]) != REG
1691       || REGNO (operands[1]) >= 16)
1692     FAIL;
1693
1694   count = INTVAL (operands[2]);
1695   regno = REGNO (operands[1]);
1696
1697   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
1698
1699   if (no_new_pseudos)
1700     {
1701       if (GET_CODE (XEXP (operands[0], 0)) == REG)
1702         {
1703           to = XEXP (operands[0], 0);
1704           off = 0;
1705         }
1706       else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
1707                && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
1708                && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
1709         {
1710           to = XEXP (XEXP (operands[0], 0), 0);
1711           off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
1712         }
1713       else
1714         FAIL;
1715
1716       if (to == frame_pointer_rtx || to == arg_pointer_rtx)
1717         FAIL;
1718     }
1719   else
1720     {
1721       to = force_reg (Pmode, XEXP (operands[0], 0));
1722       off = 0;
1723     }
1724
1725   for (i = 0; i < count; i++)
1726     XVECEXP (operands[3], 0, i)
1727       = gen_rtx_SET (VOIDmode,
1728                      change_address (operands[0], Pmode,
1729                                      plus_constant (to,
1730                                                     off + i * UNITS_PER_WORD)),
1731                      gen_rtx_REG (Pmode, regno + i));
1732 })
1733
1734 (define_insn "*store_multiple_di"
1735   [(match_parallel 0 "store_multiple_operation"
1736                    [(set (match_operand:DI 1 "s_operand" "=QS")
1737                          (match_operand:DI 2 "register_operand" "r"))])]
1738   ""
1739 {
1740   int words = XVECLEN (operands[0], 0);
1741   operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
1742   return "stmg\t%2,%0,%1";
1743 }
1744    [(set_attr "op_type" "RSY")
1745     (set_attr "type"    "stm")])
1746
1747
1748 (define_insn "*store_multiple_si"
1749   [(match_parallel 0 "store_multiple_operation"
1750                    [(set (match_operand:SI 1 "s_operand" "=Q,S")
1751                          (match_operand:SI 2 "register_operand" "r,r"))])]
1752   ""
1753 {
1754   int words = XVECLEN (operands[0], 0);
1755   operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
1756   return which_alternative == 0 ? "stm\t%2,%0,%1" : "stmy\t%2,%0,%1";
1757 }
1758    [(set_attr "op_type" "RS,RSY")
1759     (set_attr "type"    "stm")])
1760
1761 ;;
1762 ;; String instructions.
1763 ;;
1764
1765 ;
1766 ; movstrM instruction pattern(s).
1767 ;
1768
1769 (define_expand "movstrdi"
1770   [(set (match_operand:BLK 0 "memory_operand" "")
1771         (match_operand:BLK 1 "memory_operand" ""))
1772    (use (match_operand:DI 2 "general_operand" ""))
1773    (match_operand 3 "" "")]
1774   "TARGET_64BIT"
1775   "s390_expand_movstr (operands[0], operands[1], operands[2]); DONE;")
1776
1777 (define_expand "movstrsi"
1778   [(set (match_operand:BLK 0 "memory_operand" "")
1779         (match_operand:BLK 1 "memory_operand" ""))
1780    (use (match_operand:SI 2 "general_operand" ""))
1781    (match_operand 3 "" "")]
1782   ""
1783   "s390_expand_movstr (operands[0], operands[1], operands[2]); DONE;")
1784
1785 ; Move a block that is up to 256 bytes in length.
1786 ; The block length is taken as (operands[2] % 256) + 1.
1787
1788 (define_expand "movstr_short"
1789   [(parallel
1790     [(set (match_operand:BLK 0 "memory_operand" "")
1791           (match_operand:BLK 1 "memory_operand" ""))
1792      (use (match_operand 2 "nonmemory_operand" ""))
1793      (clobber (match_dup 3))])]
1794   ""
1795   "operands[3] = gen_rtx_SCRATCH (Pmode);")
1796
1797 (define_insn "*movstr_short"
1798   [(set (match_operand:BLK 0 "memory_operand" "=Q,Q")
1799         (match_operand:BLK 1 "memory_operand" "Q,Q"))
1800    (use (match_operand 2 "nonmemory_operand" "n,a"))
1801    (clobber (match_scratch 3 "=X,&a"))]
1802   "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
1803    && GET_MODE (operands[3]) == Pmode"
1804 {
1805   switch (which_alternative)
1806     {
1807       case 0:
1808         return "mvc\t%O0(%b2+1,%R0),%1";
1809
1810       case 1:
1811         output_asm_insn ("bras\t%3,.+10", operands);
1812         output_asm_insn ("mvc\t%O0(1,%R0),%1", operands);
1813         return "ex\t%2,0(%3)";
1814
1815       default:
1816         abort ();
1817     }
1818 }
1819   [(set_attr "op_type" "SS,NN")
1820    (set_attr "type"    "cs,cs")
1821    (set_attr "atype"   "*,agen")
1822    (set_attr "length"  "*,14")])
1823
1824 ; Move a block of arbitrary length.
1825
1826 (define_expand "movstr_long"
1827   [(parallel
1828     [(clobber (match_dup 2))
1829      (clobber (match_dup 3))
1830      (set (match_operand:BLK 0 "memory_operand" "")
1831           (match_operand:BLK 1 "memory_operand" ""))
1832      (use (match_operand 2 "general_operand" ""))
1833      (use (match_dup 3))
1834      (clobber (reg:CC 33))])]
1835   ""
1836 {
1837   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
1838   rtx reg0 = gen_reg_rtx (dword_mode);
1839   rtx reg1 = gen_reg_rtx (dword_mode);
1840   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
1841   rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
1842   rtx len0 = gen_lowpart (Pmode, reg0);
1843   rtx len1 = gen_lowpart (Pmode, reg1);
1844
1845   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
1846   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
1847   emit_move_insn (len0, operands[2]);
1848
1849   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
1850   emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
1851   emit_move_insn (len1, operands[2]);
1852
1853   operands[0] = replace_equiv_address_nv (operands[0], addr0);
1854   operands[1] = replace_equiv_address_nv (operands[1], addr1);
1855   operands[2] = reg0;
1856   operands[3] = reg1;
1857 })
1858
1859 (define_insn "*movstr_long_64"
1860   [(clobber (match_operand:TI 0 "register_operand" "=d"))
1861    (clobber (match_operand:TI 1 "register_operand" "=d"))
1862    (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
1863         (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0)))
1864    (use (match_dup 2))
1865    (use (match_dup 3))
1866    (clobber (reg:CC 33))]
1867   "TARGET_64BIT"
1868   "mvcle\t%0,%1,0\;jo\t.-4"
1869   [(set_attr "op_type" "NN")
1870    (set_attr "type"    "vs")
1871    (set_attr "length"  "8")])
1872
1873 (define_insn "*movstr_long_31"
1874   [(clobber (match_operand:DI 0 "register_operand" "=d"))
1875    (clobber (match_operand:DI 1 "register_operand" "=d"))
1876    (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
1877         (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0)))
1878    (use (match_dup 2))
1879    (use (match_dup 3))
1880    (clobber (reg:CC 33))]
1881   "!TARGET_64BIT"
1882   "mvcle\t%0,%1,0\;jo\t.-4"
1883   [(set_attr "op_type" "NN")
1884    (set_attr "type"    "vs")
1885    (set_attr "length"  "8")])
1886
1887 ;
1888 ; clrstrM instruction pattern(s).
1889 ;
1890
1891 (define_expand "clrstrdi"
1892   [(set (match_operand:BLK 0 "memory_operand" "")
1893         (const_int 0))
1894    (use (match_operand:DI 1 "general_operand" ""))
1895    (match_operand 2 "" "")]
1896   "TARGET_64BIT"
1897   "s390_expand_clrstr (operands[0], operands[1]); DONE;")
1898
1899 (define_expand "clrstrsi"
1900   [(set (match_operand:BLK 0 "memory_operand" "")
1901         (const_int 0))
1902    (use (match_operand:SI 1 "general_operand" ""))
1903    (match_operand 2 "" "")]
1904   ""
1905   "s390_expand_clrstr (operands[0], operands[1]); DONE;")
1906
1907 ; Clear a block that is up to 256 bytes in length.
1908 ; The block length is taken as (operands[1] % 256) + 1.
1909
1910 (define_expand "clrstr_short"
1911   [(parallel
1912     [(set (match_operand:BLK 0 "memory_operand" "")
1913           (const_int 0))
1914      (use (match_operand 1 "nonmemory_operand" ""))
1915      (clobber (match_dup 2))
1916      (clobber (reg:CC 33))])]
1917   ""
1918   "operands[2] = gen_rtx_SCRATCH (Pmode);")
1919
1920 (define_insn "*clrstr_short"
1921   [(set (match_operand:BLK 0 "memory_operand" "=Q,Q")
1922         (const_int 0))
1923    (use (match_operand 1 "nonmemory_operand" "n,a"))
1924    (clobber (match_scratch 2 "=X,&a"))
1925    (clobber (reg:CC 33))]
1926   "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
1927    && GET_MODE (operands[2]) == Pmode"
1928 {
1929   switch (which_alternative)
1930     {
1931       case 0:
1932         return "xc\t%O0(%b1+1,%R0),%0";
1933
1934       case 1:
1935         output_asm_insn ("bras\t%2,.+10", operands);
1936         output_asm_insn ("xc\t%O0(1,%R0),%0", operands);
1937         return "ex\t%1,0(%2)";
1938
1939       default:
1940         abort ();
1941     }
1942 }
1943   [(set_attr "op_type" "SS,NN")
1944    (set_attr "type"    "cs,cs")
1945    (set_attr "atype"   "*,agen")
1946    (set_attr "length"  "*,14")])
1947
1948 ; Clear a block of arbitrary length.
1949
1950 (define_expand "clrstr_long"
1951   [(parallel
1952     [(clobber (match_dup 1))
1953      (set (match_operand:BLK 0 "memory_operand" "")
1954           (const_int 0))
1955      (use (match_operand 1 "general_operand" ""))
1956      (use (match_dup 2))
1957      (clobber (reg:CC 33))])]
1958   ""
1959 {
1960   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
1961   rtx reg0 = gen_reg_rtx (dword_mode);
1962   rtx reg1 = gen_reg_rtx (dword_mode);
1963   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
1964   rtx len0 = gen_lowpart (Pmode, reg0);
1965
1966   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
1967   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
1968   emit_move_insn (len0, operands[1]);
1969
1970   emit_move_insn (reg1, const0_rtx);
1971
1972   operands[0] = replace_equiv_address_nv (operands[0], addr0);
1973   operands[1] = reg0;
1974   operands[2] = reg1;
1975 })
1976
1977 (define_insn "*clrstr_long_64"
1978   [(clobber (match_operand:TI 0 "register_operand" "=d"))
1979    (set (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
1980         (const_int 0))
1981    (use (match_dup 2))
1982    (use (match_operand:TI 1 "register_operand" "d"))
1983    (clobber (reg:CC 33))]
1984   "TARGET_64BIT"
1985   "mvcle\t%0,%1,0\;jo\t.-4"
1986   [(set_attr "op_type" "NN")
1987    (set_attr "type"    "vs")
1988    (set_attr "length"  "8")])
1989
1990 (define_insn "*clrstr_long_31"
1991   [(clobber (match_operand:DI 0 "register_operand" "=d"))
1992    (set (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
1993         (const_int 0))
1994    (use (match_dup 2))
1995    (use (match_operand:DI 1 "register_operand" "d"))
1996    (clobber (reg:CC 33))]
1997   "!TARGET_64BIT"
1998   "mvcle\t%0,%1,0\;jo\t.-4"
1999   [(set_attr "op_type" "NN")
2000    (set_attr "type"    "vs")
2001    (set_attr "length"  "8")])
2002
2003 ;
2004 ; cmpmemM instruction pattern(s).
2005 ;
2006
2007 (define_expand "cmpmemdi"
2008   [(set (match_operand:DI 0 "register_operand" "")
2009         (compare:DI (match_operand:BLK 1 "memory_operand" "")
2010                     (match_operand:BLK 2 "memory_operand" "") ) )
2011    (use (match_operand:DI 3 "general_operand" ""))
2012    (use (match_operand:DI 4 "" ""))]
2013   "TARGET_64BIT"
2014   "s390_expand_cmpmem (operands[0], operands[1],
2015                        operands[2], operands[3]); DONE;")
2016
2017 (define_expand "cmpmemsi"
2018   [(set (match_operand:SI 0 "register_operand" "")
2019         (compare:SI (match_operand:BLK 1 "memory_operand" "")
2020                     (match_operand:BLK 2 "memory_operand" "") ) )
2021    (use (match_operand:SI 3 "general_operand" ""))
2022    (use (match_operand:SI 4 "" ""))]
2023   ""
2024   "s390_expand_cmpmem (operands[0], operands[1],
2025                        operands[2], operands[3]); DONE;")
2026
2027 ; Compare a block that is up to 256 bytes in length.
2028 ; The block length is taken as (operands[2] % 256) + 1.
2029
2030 (define_expand "cmpmem_short"
2031   [(parallel
2032     [(set (reg:CCS 33)
2033           (compare:CCS (match_operand:BLK 0 "memory_operand" "")
2034                        (match_operand:BLK 1 "memory_operand" "")))
2035      (use (match_operand 2 "nonmemory_operand" ""))
2036      (clobber (match_dup 3))])]
2037   ""
2038   "operands[3] = gen_rtx_SCRATCH (Pmode);")
2039
2040 (define_insn "*cmpmem_short"
2041   [(set (reg:CCS 33)
2042         (compare:CCS (match_operand:BLK 0 "memory_operand" "=Q,Q")
2043                      (match_operand:BLK 1 "memory_operand" "Q,Q")))
2044    (use (match_operand 2 "nonmemory_operand" "n,a"))
2045    (clobber (match_scratch 3 "=X,&a"))]
2046   "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2047    && GET_MODE (operands[3]) == Pmode"
2048 {
2049   switch (which_alternative)
2050     {
2051       case 0:
2052         return "clc\t%O0(%b2+1,%R0),%1";
2053
2054       case 1:
2055         output_asm_insn ("bras\t%3,.+10", operands);
2056         output_asm_insn ("clc\t%O0(1,%R0),%1", operands);
2057         return "ex\t%2,0(%3)";
2058
2059       default:
2060         abort ();
2061     }
2062 }
2063   [(set_attr "op_type" "SS,NN")
2064    (set_attr "type"    "cs,cs")
2065    (set_attr "atype"   "*,agen")
2066    (set_attr "length"  "*,14")])
2067
2068 ; Compare a block of arbitrary length.
2069
2070 (define_expand "cmpmem_long"
2071   [(parallel
2072     [(clobber (match_dup 2))
2073      (clobber (match_dup 3))
2074      (set (reg:CCS 33)
2075           (compare:CCS (match_operand:BLK 0 "memory_operand" "")
2076                        (match_operand:BLK 1 "memory_operand" "")))
2077      (use (match_operand 2 "general_operand" ""))
2078      (use (match_dup 3))])]
2079   ""
2080 {
2081   enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2082   rtx reg0 = gen_reg_rtx (dword_mode);
2083   rtx reg1 = gen_reg_rtx (dword_mode);
2084   rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2085   rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2086   rtx len0 = gen_lowpart (Pmode, reg0);
2087   rtx len1 = gen_lowpart (Pmode, reg1);
2088
2089   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg0));
2090   emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2091   emit_move_insn (len0, operands[2]);
2092
2093   emit_insn (gen_rtx_CLOBBER (VOIDmode, reg1));
2094   emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2095   emit_move_insn (len1, operands[2]);
2096
2097   operands[0] = replace_equiv_address_nv (operands[0], addr0);
2098   operands[1] = replace_equiv_address_nv (operands[1], addr1);
2099   operands[2] = reg0;
2100   operands[3] = reg1;
2101 })
2102
2103 (define_insn "*cmpmem_long_64"
2104   [(clobber (match_operand:TI 0 "register_operand" "=d"))
2105    (clobber (match_operand:TI 1 "register_operand" "=d"))
2106    (set (reg:CCS 33)
2107         (compare:CCS (mem:BLK (subreg:DI (match_operand:TI 2 "register_operand" "0") 0))
2108                      (mem:BLK (subreg:DI (match_operand:TI 3 "register_operand" "1") 0))))
2109    (use (match_dup 2))
2110    (use (match_dup 3))]
2111   "TARGET_64BIT"
2112   "clcl\t%0,%1"
2113   [(set_attr "op_type" "RR")
2114    (set_attr "type"    "vs")])
2115
2116 (define_insn "*cmpmem_long_31"
2117   [(clobber (match_operand:DI 0 "register_operand" "=d"))
2118    (clobber (match_operand:DI 1 "register_operand" "=d"))
2119    (set (reg:CCS 33)
2120         (compare:CCS (mem:BLK (subreg:SI (match_operand:DI 2 "register_operand" "0") 0))
2121                      (mem:BLK (subreg:SI (match_operand:DI 3 "register_operand" "1") 0))))
2122    (use (match_dup 2))
2123    (use (match_dup 3))]
2124   "!TARGET_64BIT"
2125   "clcl\t%0,%1"
2126   [(set_attr "op_type" "RR")
2127    (set_attr "type"    "vs")])
2128
2129 ; Convert condition code to integer in range (-1, 0, 1)
2130
2131 (define_insn "cmpint_si"
2132   [(set (match_operand:SI 0 "register_operand" "=d")
2133         (compare:SI (reg:CCS 33) (const_int 0)))]
2134   ""
2135 {
2136    output_asm_insn ("lhi\t%0,1", operands);
2137    output_asm_insn ("jh\t.+12", operands);
2138    output_asm_insn ("jl\t.+6", operands);
2139    output_asm_insn ("sr\t%0,%0", operands);
2140    return "lcr\t%0,%0";
2141 }
2142   [(set_attr "op_type" "NN")
2143    (set_attr "length"  "16")
2144    (set_attr "type"    "other")])
2145
2146 (define_insn "cmpint_di"
2147   [(set (match_operand:DI 0 "register_operand" "=d")
2148         (compare:DI (reg:CCS 33) (const_int 0)))]
2149   "TARGET_64BIT"
2150 {
2151    output_asm_insn ("lghi\t%0,1", operands);
2152    output_asm_insn ("jh\t.+12", operands);
2153    output_asm_insn ("jl\t.+6", operands);
2154    output_asm_insn ("sgr\t%0,%0", operands);
2155    return "lcgr\t%0,%0";
2156 }
2157   [(set_attr "op_type" "NN")
2158    (set_attr "length"  "22")
2159    (set_attr "type"    "other")])
2160
2161
2162 ;;
2163 ;;- Conversion instructions.
2164 ;;
2165
2166 (define_insn "*sethighqisi"
2167   [(set (match_operand:SI 0 "register_operand" "=d,d")
2168         (unspec:SI [(match_operand:QI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2169    (clobber (reg:CC 33))]
2170   ""
2171   "@
2172    icm\t%0,8,%1
2173    icmy\t%0,8,%1"
2174   [(set_attr "op_type" "RS,RSY")])
2175
2176 (define_insn "*sethighhisi"
2177   [(set (match_operand:SI 0 "register_operand" "=d,d")
2178         (unspec:SI [(match_operand:HI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2179    (clobber (reg:CC 33))]
2180   ""
2181   "@
2182    icm\t%0,12,%1
2183    icmy\t%0,12,%1"
2184   [(set_attr "op_type" "RS,RSY")])
2185
2186 (define_insn "*sethighqidi_64"
2187   [(set (match_operand:DI 0 "register_operand" "=d")
2188         (unspec:DI [(match_operand:QI 1 "s_operand" "QS")] UNSPEC_SETHIGH))
2189    (clobber (reg:CC 33))]
2190   "TARGET_64BIT"
2191   "icmh\t%0,8,%1"
2192   [(set_attr "op_type" "RSY")])
2193
2194 (define_insn "*sethighqidi_31"
2195   [(set (match_operand:DI 0 "register_operand" "=d,d")
2196         (unspec:DI [(match_operand:QI 1 "s_operand" "Q,S")] UNSPEC_SETHIGH))
2197    (clobber (reg:CC 33))]
2198   "!TARGET_64BIT"
2199   "@
2200    icm\t%0,8,%1
2201    icmy\t%0,8,%1"
2202   [(set_attr "op_type" "RS,RSY")])
2203
2204 (define_insn_and_split "*extractqi"
2205   [(set (match_operand:SI 0 "register_operand" "=d")
2206         (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2207                          (match_operand 2 "const_int_operand" "n")
2208                          (const_int 0)))
2209    (clobber (reg:CC 33))]
2210   "!TARGET_64BIT
2211    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 8"
2212   "#"
2213   "&& reload_completed"
2214   [(parallel
2215     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2216      (clobber (reg:CC 33))])
2217     (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
2218 {
2219   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2220   operands[1] = change_address (operands[1], QImode, 0);
2221 }
2222   [(set_attr "atype"   "agen")])
2223
2224 (define_insn_and_split "*extracthi"
2225   [(set (match_operand:SI 0 "register_operand" "=d")
2226         (zero_extract:SI (match_operand:QI 1 "s_operand" "Q")
2227                          (match_operand 2 "const_int_operand" "n")
2228                          (const_int 0)))
2229    (clobber (reg:CC 33))]
2230   "!TARGET_64BIT
2231    && INTVAL (operands[2]) >= 8 && INTVAL (operands[2]) < 16"
2232   "#"
2233   "&& reload_completed"
2234   [(parallel
2235     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2236      (clobber (reg:CC 33))])
2237     (set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 2)))]
2238 {
2239   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
2240   operands[1] = change_address (operands[1], HImode, 0);
2241 }
2242   [(set_attr "atype"   "agen")])
2243
2244 ;
2245 ; extendsidi2 instruction pattern(s).
2246 ;
2247
2248 (define_expand "extendsidi2"
2249   [(set (match_operand:DI 0 "register_operand" "")
2250         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2251   ""
2252   "
2253 {
2254   if (!TARGET_64BIT)
2255     {
2256       emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2257       emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
2258       emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
2259       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
2260       DONE;
2261     }
2262 }
2263 ")
2264
2265 (define_insn "*extendsidi2"
2266   [(set (match_operand:DI 0 "register_operand" "=d,d")
2267         (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2268   "TARGET_64BIT"
2269   "@
2270    lgfr\t%0,%1
2271    lgf\t%0,%1"
2272   [(set_attr "op_type" "RRE,RXY")])
2273
2274 ;
2275 ; extendhidi2 instruction pattern(s).
2276 ;
2277
2278 (define_expand "extendhidi2"
2279   [(set (match_operand:DI 0 "register_operand" "")
2280         (sign_extend:DI (match_operand:HI 1 "register_operand" "")))]
2281   ""
2282   "
2283 {
2284   if (!TARGET_64BIT)
2285     {
2286       rtx tmp = gen_reg_rtx (SImode);
2287       emit_insn (gen_extendhisi2 (tmp, operands[1]));
2288       emit_insn (gen_extendsidi2 (operands[0], tmp));
2289       DONE;
2290     }
2291   else
2292     {
2293       operands[1] = gen_lowpart (DImode, operands[1]);
2294       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (48)));
2295       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (48)));
2296       DONE;
2297     }
2298 }
2299 ")
2300
2301 (define_insn "*extendhidi2"
2302   [(set (match_operand:DI 0 "register_operand" "=d")
2303         (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2304   "TARGET_64BIT"
2305   "lgh\t%0,%1"
2306   [(set_attr "op_type" "RXY")])
2307
2308 ;
2309 ; extendqidi2 instruction pattern(s).
2310 ;
2311
2312 (define_expand "extendqidi2"
2313   [(set (match_operand:DI 0 "register_operand" "")
2314         (sign_extend:DI (match_operand:QI 1 "register_operand" "")))]
2315   ""
2316   "
2317 {
2318   if (!TARGET_64BIT)
2319     {
2320       rtx tmp = gen_reg_rtx (SImode);
2321       emit_insn (gen_extendqisi2 (tmp, operands[1]));
2322       emit_insn (gen_extendsidi2 (operands[0], tmp));
2323       DONE;
2324     }
2325   else
2326     {
2327       operands[1] = gen_lowpart (DImode, operands[1]);
2328       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (56)));
2329       emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (56)));
2330       DONE;
2331     }
2332 }
2333 ")
2334
2335 (define_insn "*extendqidi2"
2336   [(set (match_operand:DI 0 "register_operand" "=d")
2337         (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
2338   "TARGET_64BIT && TARGET_LONG_DISPLACEMENT"
2339   "lgb\t%0,%1"
2340   [(set_attr "op_type" "RXY")])
2341
2342 (define_split
2343   [(set (match_operand:DI 0 "register_operand" "")
2344         (sign_extend:DI (match_operand:QI 1 "s_operand" "")))]
2345   "TARGET_64BIT && !TARGET_LONG_DISPLACEMENT && !reload_completed"
2346   [(parallel
2347     [(set (match_dup 0) (unspec:DI [(match_dup 1)] UNSPEC_SETHIGH))
2348      (clobber (reg:CC 33))])
2349    (parallel
2350     [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 56)))
2351      (clobber (reg:CC 33))])]
2352   "")
2353
2354 ;
2355 ; extendhisi2 instruction pattern(s).
2356 ;
2357
2358 (define_expand "extendhisi2"
2359   [(set (match_operand:SI 0 "register_operand" "")
2360         (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
2361   ""
2362   "
2363 {
2364   operands[1] = gen_lowpart (SImode, operands[1]);
2365   emit_insn (gen_ashlsi3 (operands[0], operands[1], GEN_INT (16)));
2366   emit_insn (gen_ashrsi3 (operands[0], operands[0], GEN_INT (16)));
2367   DONE;
2368 }
2369 ")
2370
2371 (define_insn "*extendhisi2"
2372   [(set (match_operand:SI 0 "register_operand" "=d,d")
2373         (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
2374   ""
2375   "@
2376    lh\t%0,%1
2377    lhy\t%0,%1"
2378   [(set_attr "op_type" "RX,RXY")])
2379
2380 ;
2381 ; extendqisi2 instruction pattern(s).
2382 ;
2383
2384 (define_expand "extendqisi2"
2385   [(set (match_operand:SI 0 "register_operand" "")
2386         (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
2387   ""
2388   "
2389 {
2390   operands[1] = gen_lowpart (SImode, operands[1]);
2391   emit_insn (gen_ashlsi3 (operands[0], operands[1], GEN_INT (24)));
2392   emit_insn (gen_ashrsi3 (operands[0], operands[0], GEN_INT (24)));
2393   DONE;
2394 }
2395 ")
2396
2397 (define_insn "*extendqisi2"
2398   [(set (match_operand:SI 0 "register_operand" "=d")
2399         (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2400   "TARGET_LONG_DISPLACEMENT"
2401   "lb\t%0,%1"
2402   [(set_attr "op_type" "RXY")])
2403
2404 (define_split
2405   [(set (match_operand:SI 0 "register_operand" "")
2406         (sign_extend:SI (match_operand:QI 1 "s_operand" "")))]
2407   "!TARGET_LONG_DISPLACEMENT && !reload_completed"
2408   [(parallel
2409     [(set (match_dup 0) (unspec:SI [(match_dup 1)] UNSPEC_SETHIGH))
2410      (clobber (reg:CC 33))])
2411    (parallel
2412     [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 24)))
2413      (clobber (reg:CC 33))])]
2414   "")
2415
2416 ;
2417 ; extendqihi2 instruction pattern(s).
2418 ;
2419
2420
2421 ;
2422 ; zero_extendsidi2 instruction pattern(s).
2423 ;
2424
2425 (define_expand "zero_extendsidi2"
2426   [(set (match_operand:DI 0 "register_operand" "")
2427         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
2428   ""
2429   "
2430 {
2431   if (!TARGET_64BIT)
2432     {
2433       emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[0]));
2434       emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
2435       emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
2436       DONE;
2437     }
2438 }
2439 ")
2440
2441 (define_insn "*zero_extendsidi2"
2442   [(set (match_operand:DI 0 "register_operand" "=d,d")
2443         (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,m")))]
2444   "TARGET_64BIT"
2445   "@
2446    llgfr\t%0,%1
2447    llgf\t%0,%1"
2448   [(set_attr "op_type" "RRE,RXY")])
2449
2450 ;
2451 ; zero_extendhidi2 instruction pattern(s).
2452 ;
2453
2454 (define_expand "zero_extendhidi2"
2455   [(set (match_operand:DI 0 "register_operand" "")
2456         (zero_extend:DI (match_operand:HI 1 "register_operand" "")))]
2457   ""
2458   "
2459 {
2460   if (!TARGET_64BIT)
2461     {
2462       rtx tmp = gen_reg_rtx (SImode);
2463       emit_insn (gen_zero_extendhisi2 (tmp, operands[1]));
2464       emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
2465       DONE;
2466     }
2467   else
2468     {
2469       operands[1] = gen_lowpart (DImode, operands[1]);
2470       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (48)));
2471       emit_insn (gen_lshrdi3 (operands[0], operands[0], GEN_INT (48)));
2472       DONE;
2473     }
2474 }
2475 ")
2476
2477 (define_insn "*zero_extendhidi2"
2478   [(set (match_operand:DI 0 "register_operand" "=d")
2479         (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
2480   "TARGET_64BIT"
2481   "llgh\t%0,%1"
2482   [(set_attr "op_type" "RXY")])
2483
2484 ;
2485 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
2486 ;
2487
2488 (define_insn "*llgt_sisi"
2489   [(set (match_operand:SI 0 "register_operand" "=d,d")
2490         (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,m")
2491                 (const_int 2147483647)))]
2492   "TARGET_64BIT"
2493   "@
2494    llgtr\t%0,%1
2495    llgt\t%0,%1"
2496   [(set_attr "op_type"  "RRE,RXE")])
2497
2498 (define_insn_and_split "*llgt_sisi_split"
2499   [(set (match_operand:SI 0 "register_operand" "=d,d")
2500         (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,m")
2501                 (const_int 2147483647)))
2502    (clobber (reg:CC 33))]
2503   "TARGET_64BIT"
2504   "#"
2505   "&& reload_completed"
2506   [(set (match_dup 0)
2507         (and:SI (match_dup 1)
2508                 (const_int 2147483647)))]
2509   "")
2510
2511 (define_insn "*llgt_didi"
2512   [(set (match_operand:DI 0 "register_operand" "=d,d")
2513         (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
2514                 (const_int 2147483647)))]
2515   "TARGET_64BIT"
2516   "@
2517    llgtr\t%0,%1
2518    llgt\t%0,%N1"
2519   [(set_attr "op_type"  "RRE,RXE")])
2520
2521 (define_insn_and_split "*llgt_didi_split"
2522   [(set (match_operand:DI 0 "register_operand" "=d,d")
2523         (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
2524                 (const_int 2147483647)))
2525    (clobber (reg:CC 33))]
2526   "TARGET_64BIT"
2527   "#"
2528   "&& reload_completed"
2529   [(set (match_dup 0)
2530         (and:DI (match_dup 1)
2531                 (const_int 2147483647)))]
2532   "")
2533
2534 (define_insn "*llgt_sidi"
2535   [(set (match_operand:DI 0 "register_operand" "=d")
2536         (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0)
2537                 (const_int 2147483647)))]
2538   "TARGET_64BIT"
2539   "llgt\t%0,%1"
2540   [(set_attr "op_type"  "RXE")])
2541
2542 (define_insn_and_split "*llgt_sidi_split"
2543   [(set (match_operand:DI 0 "register_operand" "=d")
2544         (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "m") 0) 
2545                 (const_int 2147483647)))
2546    (clobber (reg:CC 33))]
2547   "TARGET_64BIT"
2548   "#"
2549   "&& reload_completed"
2550   [(set (match_dup 0)
2551         (and:DI (subreg:DI (match_dup 1) 0) 
2552                 (const_int 2147483647)))]
2553   "")
2554
2555 ;
2556 ; zero_extendqidi2 instruction pattern(s)
2557 ;
2558
2559 (define_expand "zero_extendqidi2"
2560   [(set (match_operand:DI 0 "register_operand" "")
2561         (zero_extend:DI (match_operand:QI 1 "register_operand" "")))]
2562   ""
2563   "
2564 {
2565   if (!TARGET_64BIT)
2566     {
2567       rtx tmp = gen_reg_rtx (SImode);
2568       emit_insn (gen_zero_extendqisi2 (tmp, operands[1]));
2569       emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
2570       DONE;
2571     }
2572   else
2573     {
2574       operands[1] = gen_lowpart (DImode, operands[1]);
2575       emit_insn (gen_ashldi3 (operands[0], operands[1], GEN_INT (56)));
2576       emit_insn (gen_lshrdi3 (operands[0], operands[0], GEN_INT (56)));
2577       DONE;
2578     }
2579 }
2580 ")
2581
2582 (define_insn "*zero_extendqidi2"
2583   [(set (match_operand:DI 0 "register_operand" "=d")
2584         (zero_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
2585   "TARGET_64BIT"
2586   "llgc\t%0,%1"
2587   [(set_attr "op_type" "RXY")])
2588
2589 ;
2590 ; zero_extendhisi2 instruction pattern(s).
2591 ;
2592
2593 (define_expand "zero_extendhisi2"
2594   [(set (match_operand:SI 0 "register_operand" "")
2595         (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
2596   ""
2597   "
2598 {
2599   operands[1] = gen_lowpart (SImode, operands[1]);
2600   emit_insn (gen_andsi3 (operands[0], operands[1], GEN_INT (0xffff)));
2601   DONE;
2602 }
2603 ")
2604
2605 (define_insn "*zero_extendhisi2_64"
2606   [(set (match_operand:SI 0 "register_operand" "=d")
2607         (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
2608   "TARGET_64BIT"
2609   "llgh\t%0,%1"
2610   [(set_attr "op_type" "RXY")])
2611
2612 (define_insn_and_split "*zero_extendhisi2_31"
2613   [(set (match_operand:SI 0 "register_operand" "=&d")
2614         (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
2615    (clobber (reg:CC 33))]
2616   "!TARGET_64BIT"
2617   "#"
2618   "&& reload_completed"
2619   [(set (match_dup 0) (const_int 0))
2620    (parallel
2621     [(set (strict_low_part (match_dup 2)) (match_dup 1))
2622      (clobber (reg:CC 33))])]
2623   "operands[2] = gen_lowpart (HImode, operands[0]);"
2624   [(set_attr "atype" "agen")])
2625
2626 ;
2627 ; zero_extendqisi2 instruction pattern(s).
2628 ;
2629
2630 (define_expand "zero_extendqisi2"
2631   [(set (match_operand:SI 0 "register_operand" "")
2632         (zero_extend:SI (match_operand:QI 1 "register_operand" "")))]
2633   ""
2634   "
2635 {
2636   operands[1] = gen_lowpart (SImode, operands[1]);
2637   emit_insn (gen_andsi3 (operands[0], operands[1], GEN_INT (0xff)));
2638   DONE;
2639 }
2640 ")
2641
2642 (define_insn "*zero_extendqisi2_64"
2643   [(set (match_operand:SI 0 "register_operand" "=d")
2644         (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2645   "TARGET_ZARCH"
2646   "llgc\t%0,%1"
2647   [(set_attr "op_type" "RXY")])
2648
2649 (define_insn_and_split "*zero_extendqisi2_31"
2650   [(set (match_operand:SI 0 "register_operand" "=&d")
2651         (zero_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
2652   "!TARGET_ZARCH"
2653   "#"
2654   "&& reload_completed"
2655   [(set (match_dup 0) (const_int 0))
2656    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2657   "operands[2] = gen_lowpart (QImode, operands[0]);"
2658   [(set_attr "atype" "agen")])
2659
2660 ;
2661 ; zero_extendqihi2 instruction pattern(s).
2662 ;
2663
2664 (define_expand "zero_extendqihi2"
2665   [(set (match_operand:HI 0 "register_operand" "")
2666         (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
2667   "TARGET_ZARCH"
2668   "
2669 {
2670   operands[1] = gen_lowpart (HImode, operands[1]);
2671   emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
2672   DONE;
2673 }
2674 ")
2675
2676 (define_insn "*zero_extendqihi2_64"
2677   [(set (match_operand:HI 0 "register_operand" "=d")
2678         (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2679   "TARGET_ZARCH"
2680   "llgc\t%0,%1"
2681   [(set_attr "op_type" "RXY")])
2682
2683 (define_insn_and_split "*zero_extendqihi2_31"
2684   [(set (match_operand:HI 0 "register_operand" "=&d")
2685         (zero_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
2686   "!TARGET_ZARCH"
2687   "#"
2688   "&& reload_completed"
2689   [(set (match_dup 0) (const_int 0))
2690    (set (strict_low_part (match_dup 2)) (match_dup 1))]
2691   "operands[2] = gen_lowpart (QImode, operands[0]);"
2692   [(set_attr "atype" "agen")])
2693
2694
2695 ;
2696 ; fixuns_truncdfdi2 and fix_truncdfsi2 instruction pattern(s).
2697 ;
2698
2699 (define_expand "fixuns_truncdfdi2"
2700   [(set (match_operand:DI 0 "register_operand" "")
2701         (unsigned_fix:DI (match_operand:DF 1 "register_operand" "")))]
2702   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2703 {
2704   rtx label1 = gen_label_rtx ();
2705   rtx label2 = gen_label_rtx ();
2706   rtx temp = gen_reg_rtx (DFmode);
2707   operands[1] = force_reg (DFmode, operands[1]);
2708
2709   emit_insn (gen_cmpdf (operands[1],
2710         CONST_DOUBLE_FROM_REAL_VALUE (
2711           REAL_VALUE_ATOF ("9223372036854775808.0", DFmode), DFmode)));
2712   emit_jump_insn (gen_blt (label1));
2713   emit_insn (gen_subdf3 (temp, operands[1],
2714         CONST_DOUBLE_FROM_REAL_VALUE (
2715           REAL_VALUE_ATOF ("18446744073709551616.0", DFmode), DFmode)));
2716   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], temp, GEN_INT(7)));
2717   emit_jump (label2);
2718
2719   emit_label (label1);
2720   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2721   emit_label (label2);
2722   DONE;
2723 })
2724
2725 (define_expand "fix_truncdfdi2"
2726   [(set (match_operand:DI 0 "register_operand" "")
2727         (fix:DI (match_operand:DF 1 "nonimmediate_operand" "")))]
2728   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2729 {
2730   operands[1] = force_reg (DFmode, operands[1]);
2731   emit_insn (gen_fix_truncdfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2732   DONE;
2733 })
2734
2735 (define_insn "fix_truncdfdi2_ieee"
2736   [(set (match_operand:DI 0 "register_operand" "=d")
2737         (fix:DI (match_operand:DF 1 "register_operand" "f")))
2738    (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2739    (clobber (reg:CC 33))]
2740   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2741   "cgdbr\t%0,%h2,%1"
2742   [(set_attr "op_type" "RRE")
2743    (set_attr "type"    "ftoi")])
2744
2745 ;
2746 ; fixuns_truncdfsi2 and fix_truncdfsi2 instruction pattern(s).
2747 ;
2748
2749 (define_expand "fixuns_truncdfsi2"
2750   [(set (match_operand:SI 0 "register_operand" "")
2751         (unsigned_fix:SI (match_operand:DF 1 "register_operand" "")))]
2752   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2753 {
2754   rtx label1 = gen_label_rtx ();
2755   rtx label2 = gen_label_rtx ();
2756   rtx temp = gen_reg_rtx (DFmode);
2757
2758   operands[1] = force_reg (DFmode,operands[1]);
2759   emit_insn (gen_cmpdf (operands[1],
2760         CONST_DOUBLE_FROM_REAL_VALUE (
2761           REAL_VALUE_ATOF ("2147483648.0", DFmode), DFmode)));
2762   emit_jump_insn (gen_blt (label1));
2763   emit_insn (gen_subdf3 (temp, operands[1],
2764         CONST_DOUBLE_FROM_REAL_VALUE (
2765           REAL_VALUE_ATOF ("4294967296.0", DFmode), DFmode)));
2766   emit_insn (gen_fix_truncdfsi2_ieee (operands[0], temp, GEN_INT (7)));
2767   emit_jump (label2);
2768
2769   emit_label (label1);
2770   emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2771   emit_label (label2);
2772   DONE;
2773 })
2774
2775 (define_expand "fix_truncdfsi2"
2776   [(set (match_operand:SI 0 "register_operand" "")
2777         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "")))]
2778   "TARGET_HARD_FLOAT"
2779 {
2780   if (TARGET_IBM_FLOAT)
2781     {
2782       /* This is the algorithm from POP chapter A.5.7.2.  */
2783
2784       rtx temp   = assign_stack_local (BLKmode, 2 * UNITS_PER_WORD, BITS_PER_WORD);
2785       rtx two31r = s390_gen_rtx_const_DI (0x4f000000, 0x08000000);
2786       rtx two32  = s390_gen_rtx_const_DI (0x4e000001, 0x00000000);
2787
2788       operands[1] = force_reg (DFmode, operands[1]);
2789       emit_insn (gen_fix_truncdfsi2_ibm (operands[0], operands[1],
2790                                          two31r, two32, temp));
2791     }
2792   else
2793     {
2794       operands[1] = force_reg (DFmode, operands[1]);
2795       emit_insn (gen_fix_truncdfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2796     }
2797
2798   DONE;
2799 })
2800
2801 (define_insn "fix_truncdfsi2_ieee"
2802   [(set (match_operand:SI 0 "register_operand" "=d")
2803         (fix:SI (match_operand:DF 1 "register_operand" "f")))
2804     (unspec:SI [(match_operand:SI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2805     (clobber (reg:CC 33))]
2806   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2807   "cfdbr\t%0,%h2,%1"
2808    [(set_attr "op_type" "RRE")
2809     (set_attr "type"    "other" )])
2810
2811 (define_insn "fix_truncdfsi2_ibm"
2812   [(set (match_operand:SI 0 "register_operand" "=d")
2813         (fix:SI (match_operand:DF 1 "nonimmediate_operand" "+f")))
2814    (use (match_operand:DI 2 "immediate_operand" "m"))
2815    (use (match_operand:DI 3 "immediate_operand" "m"))
2816    (use (match_operand:BLK 4 "memory_operand" "m"))
2817    (clobber (reg:CC 33))]
2818   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
2819 {
2820    output_asm_insn ("sd\t%1,%2", operands);
2821    output_asm_insn ("aw\t%1,%3", operands);
2822    output_asm_insn ("std\t%1,%4", operands);
2823    output_asm_insn ("xi\t%N4,128", operands);
2824    return "l\t%0,%N4";
2825 }
2826   [(set_attr "op_type" "NN")
2827    (set_attr "type"    "ftoi")
2828    (set_attr "atype"   "agen")
2829    (set_attr "length"  "20")])
2830
2831 ;
2832 ; fixuns_truncsfdi2 and fix_truncsfdi2 instruction pattern(s).
2833 ;
2834
2835 (define_expand "fixuns_truncsfdi2"
2836   [(set (match_operand:DI 0 "register_operand" "")
2837         (unsigned_fix:DI (match_operand:SF 1 "register_operand" "")))]
2838   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2839 {
2840   rtx label1 = gen_label_rtx ();
2841   rtx label2 = gen_label_rtx ();
2842   rtx temp = gen_reg_rtx (SFmode);
2843
2844   operands[1] = force_reg (SFmode, operands[1]);
2845   emit_insn (gen_cmpsf (operands[1],
2846         CONST_DOUBLE_FROM_REAL_VALUE (
2847           REAL_VALUE_ATOF ("9223372036854775808.0", SFmode), SFmode)));
2848   emit_jump_insn (gen_blt (label1));
2849
2850   emit_insn (gen_subsf3 (temp, operands[1],
2851         CONST_DOUBLE_FROM_REAL_VALUE (
2852           REAL_VALUE_ATOF ("18446744073709551616.0", SFmode), SFmode)));
2853   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], temp, GEN_INT(7)));
2854   emit_jump (label2);
2855
2856   emit_label (label1);
2857   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2858   emit_label (label2);
2859   DONE;
2860 })
2861
2862 (define_expand "fix_truncsfdi2"
2863   [(set (match_operand:DI 0 "register_operand" "")
2864         (fix:DI (match_operand:SF 1 "nonimmediate_operand" "")))]
2865   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2866 {
2867   operands[1] = force_reg (SFmode, operands[1]);
2868   emit_insn (gen_fix_truncsfdi2_ieee (operands[0], operands[1], GEN_INT(5)));
2869   DONE;
2870 })
2871
2872 (define_insn "fix_truncsfdi2_ieee"
2873   [(set (match_operand:DI 0 "register_operand" "=d")
2874         (fix:DI (match_operand:SF 1 "register_operand"  "f")))
2875    (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2876    (clobber (reg:CC 33))]
2877   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2878   "cgebr\t%0,%h2,%1"
2879   [(set_attr "op_type" "RRE")
2880    (set_attr "type"    "ftoi")])
2881
2882 ;
2883 ; fixuns_truncsfsi2 and fix_truncsfsi2 instruction pattern(s).
2884 ;
2885
2886 (define_expand "fixuns_truncsfsi2"
2887   [(set (match_operand:SI 0 "register_operand" "")
2888         (unsigned_fix:SI (match_operand:SF 1 "register_operand" "")))]
2889   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2890 {
2891   rtx label1 = gen_label_rtx ();
2892   rtx label2 = gen_label_rtx ();
2893   rtx temp = gen_reg_rtx (SFmode);
2894
2895   operands[1] = force_reg (SFmode, operands[1]);
2896   emit_insn (gen_cmpsf (operands[1],
2897         CONST_DOUBLE_FROM_REAL_VALUE (
2898           REAL_VALUE_ATOF ("2147483648.0", SFmode), SFmode)));
2899   emit_jump_insn (gen_blt (label1));
2900   emit_insn (gen_subsf3 (temp, operands[1],
2901         CONST_DOUBLE_FROM_REAL_VALUE (
2902           REAL_VALUE_ATOF ("4294967296.0", SFmode), SFmode)));
2903   emit_insn (gen_fix_truncsfsi2_ieee (operands[0], temp, GEN_INT (7)));
2904   emit_jump (label2);
2905
2906   emit_label (label1);
2907   emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2908   emit_label (label2);
2909   DONE;
2910 })
2911
2912 (define_expand "fix_truncsfsi2"
2913   [(set (match_operand:SI 0 "register_operand" "")
2914         (fix:SI (match_operand:SF 1 "nonimmediate_operand" "")))]
2915   "TARGET_HARD_FLOAT"
2916 {
2917   if (TARGET_IBM_FLOAT)
2918     {
2919       /* Convert to DFmode and then use the POP algorithm.  */
2920       rtx temp = gen_reg_rtx (DFmode);
2921       emit_insn (gen_extendsfdf2 (temp, operands[1]));
2922       emit_insn (gen_fix_truncdfsi2 (operands[0], temp));
2923     }
2924   else
2925     {
2926       operands[1] = force_reg (SFmode, operands[1]);
2927       emit_insn (gen_fix_truncsfsi2_ieee (operands[0], operands[1], GEN_INT (5)));
2928     }
2929
2930   DONE;
2931 })
2932
2933 (define_insn "fix_truncsfsi2_ieee"
2934   [(set (match_operand:SI 0 "register_operand" "=d")
2935         (fix:SI (match_operand:SF 1 "register_operand" "f")))
2936     (unspec:SI [(match_operand:SI 2 "immediate_operand" "K")] UNSPEC_ROUND)
2937     (clobber (reg:CC 33))]
2938   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2939   "cfebr\t%0,%h2,%1"
2940   [(set_attr "op_type" "RRE")
2941    (set_attr "type"    "ftoi")])
2942
2943 ;
2944 ; floatdidf2 instruction pattern(s).
2945 ;
2946
2947 (define_insn "floatdidf2"
2948   [(set (match_operand:DF 0 "register_operand" "=f")
2949         (float:DF (match_operand:DI 1 "register_operand" "d")))
2950    (clobber (reg:CC 33))]
2951   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2952   "cdgbr\t%0,%1"
2953   [(set_attr "op_type" "RRE")
2954    (set_attr "type"    "itof" )])
2955
2956 ;
2957 ; floatdisf2 instruction pattern(s).
2958 ;
2959
2960 (define_insn "floatdisf2"
2961   [(set (match_operand:SF 0 "register_operand" "=f")
2962         (float:SF (match_operand:DI 1 "register_operand" "d")))
2963    (clobber (reg:CC 33))]
2964   "TARGET_64BIT && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2965   "cegbr\t%0,%1"
2966   [(set_attr "op_type" "RRE")
2967    (set_attr "type"    "itof" )])
2968
2969 ;
2970 ; floatsidf2 instruction pattern(s).
2971 ;
2972
2973 (define_expand "floatsidf2"
2974   [(parallel
2975     [(set (match_operand:DF 0 "register_operand" "")
2976           (float:DF (match_operand:SI 1 "register_operand" "")))
2977      (clobber (reg:CC 33))])]
2978   "TARGET_HARD_FLOAT"
2979 {
2980   if (TARGET_IBM_FLOAT)
2981     {
2982       /* This is the algorithm from POP chapter A.5.7.1.  */
2983
2984       rtx temp  = assign_stack_local (BLKmode, 2 * UNITS_PER_WORD, BITS_PER_WORD);
2985       rtx two31 = s390_gen_rtx_const_DI (0x4e000000, 0x80000000);
2986
2987       emit_insn (gen_floatsidf2_ibm (operands[0], operands[1], two31, temp));
2988       DONE;
2989     }
2990 })
2991
2992 (define_insn "floatsidf2_ieee"
2993   [(set (match_operand:DF 0 "register_operand" "=f")
2994         (float:DF (match_operand:SI 1 "register_operand"  "d")))
2995    (clobber (reg:CC 33))]
2996   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
2997   "cdfbr\t%0,%1"
2998   [(set_attr "op_type" "RRE")
2999    (set_attr "type"   "itof" )])
3000
3001 (define_insn "floatsidf2_ibm"
3002   [(set (match_operand:DF 0 "register_operand" "=f")
3003         (float:DF (match_operand:SI 1 "register_operand" "d")))
3004    (use (match_operand:DI 2 "immediate_operand" "m"))
3005    (use (match_operand:BLK 3 "memory_operand" "m"))
3006    (clobber (reg:CC 33))]
3007   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3008 {
3009    output_asm_insn ("st\t%1,%N3", operands);
3010    output_asm_insn ("xi\t%N3,128", operands);
3011    output_asm_insn ("mvc\t%O3(4,%R3),%2", operands);
3012    output_asm_insn ("ld\t%0,%3", operands);
3013    return "sd\t%0,%2";
3014 }
3015   [(set_attr "op_type" "NN")
3016    (set_attr "type"    "other" )
3017    (set_attr "atype"   "agen")
3018    (set_attr "length"  "20")])
3019
3020 ;
3021 ; floatsisf2 instruction pattern(s).
3022 ;
3023
3024 (define_expand "floatsisf2"
3025   [(parallel
3026     [(set (match_operand:SF 0 "register_operand" "")
3027           (float:SF (match_operand:SI 1 "register_operand" "")))
3028      (clobber (reg:CC 33))])]
3029   "TARGET_HARD_FLOAT"
3030 {
3031   if (TARGET_IBM_FLOAT)
3032     {
3033       /* Use the POP algorithm to convert to DFmode and then truncate.  */
3034       rtx temp = gen_reg_rtx (DFmode);
3035       emit_insn (gen_floatsidf2 (temp, operands[1]));
3036       emit_insn (gen_truncdfsf2 (operands[0], temp));
3037       DONE;
3038     }
3039 })
3040
3041 (define_insn "floatsisf2_ieee"
3042   [(set (match_operand:SF 0 "register_operand" "=f")
3043         (float:SF (match_operand:SI 1 "register_operand" "d")))
3044    (clobber (reg:CC 33))]
3045   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3046   "cefbr\t%0,%1"
3047   [(set_attr "op_type" "RRE")
3048    (set_attr "type"    "itof" )])
3049
3050 ;
3051 ; truncdfsf2 instruction pattern(s).
3052 ;
3053
3054 (define_expand "truncdfsf2"
3055   [(set (match_operand:SF 0 "register_operand" "")
3056         (float_truncate:SF (match_operand:DF 1 "general_operand" "")))]
3057   "TARGET_HARD_FLOAT"
3058   "")
3059
3060 (define_insn "truncdfsf2_ieee"
3061   [(set (match_operand:SF 0 "register_operand" "=f")
3062         (float_truncate:SF (match_operand:DF 1 "general_operand" "f")))]
3063   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3064   "ledbr\t%0,%1"
3065   [(set_attr "op_type"  "RRE")])
3066
3067 (define_insn "truncdfsf2_ibm"
3068   [(set (match_operand:SF 0 "register_operand" "=f,f")
3069         (float_truncate:SF (match_operand:DF 1 "general_operand" "f,R")))]
3070   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3071   "@
3072    lrer\t%0,%1
3073    le\t%0,%1"
3074   [(set_attr "op_type"  "RR,RX")
3075    (set_attr "type"   "floads,floads")])
3076
3077 ;
3078 ; extendsfdf2 instruction pattern(s).
3079 ;
3080
3081 (define_expand "extendsfdf2"
3082   [(set (match_operand:DF 0 "register_operand" "")
3083         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "")))]
3084   "TARGET_HARD_FLOAT"
3085 {
3086   if (TARGET_IBM_FLOAT)
3087     {
3088       emit_insn (gen_extendsfdf2_ibm (operands[0], operands[1]));
3089       DONE;
3090     }
3091 })
3092
3093 (define_insn "extendsfdf2_ieee"
3094   [(set (match_operand:DF 0 "register_operand" "=f,f")
3095         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand"  "f,R")))]
3096   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3097   "@
3098    ldebr\t%0,%1
3099    ldeb\t%0,%1"
3100   [(set_attr "op_type"  "RRE,RXE")
3101    (set_attr "type"   "floads,floads")])
3102
3103 (define_insn "extendsfdf2_ibm"
3104   [(set (match_operand:DF 0 "register_operand" "=f,f")
3105         (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R")))
3106    (clobber (reg:CC 33))]
3107   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3108   "@
3109    sdr\t%0,%0\;ler\t%0,%1
3110    sdr\t%0,%0\;le\t%0,%1"
3111   [(set_attr "op_type"  "NN,NN")
3112    (set_attr "atype"    "reg,agen")
3113    (set_attr "length"   "4,6")
3114    (set_attr "type"     "o2,o2")])
3115
3116
3117 ;;
3118 ;; ARITHMETIC OPERATIONS
3119 ;;
3120 ;  arithmetic operations set the ConditionCode,
3121 ;  because of unpredictable Bits in Register for Halfword and Byte
3122 ;  the ConditionCode can be set wrong in operations for Halfword and Byte
3123
3124 ;;
3125 ;;- Add instructions.
3126 ;;
3127
3128 ;
3129 ; adddi3 instruction pattern(s).
3130 ;
3131
3132 (define_insn "*adddi3_sign"
3133   [(set (match_operand:DI 0 "register_operand" "=d,d")
3134         (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3135                  (match_operand:DI 1 "register_operand" "0,0")))
3136    (clobber (reg:CC 33))]
3137   "TARGET_64BIT"
3138   "@
3139    agfr\t%0,%2
3140    agf\t%0,%2"
3141   [(set_attr "op_type"  "RRE,RXY")])
3142
3143 (define_insn "*adddi3_zero_cc"
3144   [(set (reg 33)
3145         (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3146                           (match_operand:DI 1 "register_operand" "0,0"))
3147                  (const_int 0)))
3148    (set (match_operand:DI 0 "register_operand" "=d,d")
3149         (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
3150   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3151   "@
3152    algfr\t%0,%2
3153    algf\t%0,%2"
3154   [(set_attr "op_type"  "RRE,RXY")])
3155
3156 (define_insn "*adddi3_zero_cconly"
3157   [(set (reg 33)
3158         (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3159                           (match_operand:DI 1 "register_operand" "0,0"))
3160                  (const_int 0)))
3161    (clobber (match_scratch:DI 0 "=d,d"))]
3162   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3163   "@
3164    algfr\t%0,%2
3165    algf\t%0,%2"
3166   [(set_attr "op_type"  "RRE,RXY")])
3167
3168 (define_insn "*adddi3_zero"
3169   [(set (match_operand:DI 0 "register_operand" "=d,d")
3170         (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))
3171                  (match_operand:DI 1 "register_operand" "0,0")))
3172    (clobber (reg:CC 33))]
3173   "TARGET_64BIT"
3174   "@
3175    algfr\t%0,%2
3176    algf\t%0,%2"
3177   [(set_attr "op_type"  "RRE,RXY")])
3178
3179 (define_insn "*adddi3_imm_cc"
3180   [(set (reg 33)
3181         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "0")
3182                           (match_operand:DI 2 "const_int_operand" "K"))
3183                  (const_int 0)))
3184    (set (match_operand:DI 0 "register_operand" "=d")
3185         (plus:DI (match_dup 1) (match_dup 2)))]
3186   "TARGET_64BIT
3187    && s390_match_ccmode (insn, CCAmode)
3188    && CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')"
3189   "aghi\t%0,%h2"
3190   [(set_attr "op_type"  "RI")])
3191
3192 (define_insn "*adddi3_carry1_cc"
3193   [(set (reg 33)
3194         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3195                           (match_operand:DI 2 "general_operand" "d,m"))
3196                  (match_dup 1)))
3197    (set (match_operand:DI 0 "register_operand" "=d,d")
3198         (plus:DI (match_dup 1) (match_dup 2)))]
3199   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3200   "@
3201    algr\t%0,%2
3202    alg\t%0,%2"
3203   [(set_attr "op_type"  "RRE,RXY")])
3204
3205 (define_insn "*adddi3_carry1_cconly"
3206   [(set (reg 33)
3207         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3208                           (match_operand:DI 2 "general_operand" "d,m"))
3209                  (match_dup 1)))
3210    (clobber (match_scratch:DI 0 "=d,d"))]
3211   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3212   "@
3213    algr\t%0,%2
3214    alg\t%0,%2"
3215   [(set_attr "op_type"  "RRE,RXY")])
3216
3217 (define_insn "*adddi3_carry2_cc"
3218   [(set (reg 33)
3219         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3220                           (match_operand:DI 2 "general_operand" "d,m"))
3221                  (match_dup 2)))
3222    (set (match_operand:DI 0 "register_operand" "=d,d")
3223         (plus:DI (match_dup 1) (match_dup 2)))]
3224   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3225   "@
3226    algr\t%0,%2
3227    alg\t%0,%2"
3228   [(set_attr "op_type"  "RRE,RXY")])
3229
3230 (define_insn "*adddi3_carry2_cconly"
3231   [(set (reg 33)
3232         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3233                           (match_operand:DI 2 "general_operand" "d,m"))
3234                  (match_dup 2)))
3235    (clobber (match_scratch:DI 0 "=d,d"))]
3236   "s390_match_ccmode (insn, CCL1mode) && TARGET_64BIT"
3237   "@
3238    algr\t%0,%2
3239    alg\t%0,%2"
3240   [(set_attr "op_type"  "RRE,RXY")])
3241
3242 (define_insn "*adddi3_cc"
3243   [(set (reg 33)
3244         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3245                           (match_operand:DI 2 "general_operand" "d,m"))
3246                  (const_int 0)))
3247    (set (match_operand:DI 0 "register_operand" "=d,d")
3248         (plus:DI (match_dup 1) (match_dup 2)))]
3249   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3250   "@
3251    algr\t%0,%2
3252    alg\t%0,%2"
3253   [(set_attr "op_type"  "RRE,RXY")])
3254
3255 (define_insn "*adddi3_cconly"
3256   [(set (reg 33)
3257         (compare (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3258                           (match_operand:DI 2 "general_operand" "d,m"))
3259                  (const_int 0)))
3260    (clobber (match_scratch:DI 0 "=d,d"))]
3261   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3262   "@
3263    algr\t%0,%2
3264    alg\t%0,%2"
3265   [(set_attr "op_type"  "RRE,RXY")])
3266
3267 (define_insn "*adddi3_cconly2"
3268   [(set (reg 33)
3269         (compare (match_operand:DI 1 "nonimmediate_operand" "%0,0")
3270                  (neg:SI (match_operand:DI 2 "general_operand" "d,m"))))
3271    (clobber (match_scratch:DI 0 "=d,d"))]
3272   "s390_match_ccmode(insn, CCLmode) && TARGET_64BIT"
3273   "@
3274    algr\t%0,%2
3275    alg\t%0,%2"
3276   [(set_attr "op_type"  "RRE,RXY")])
3277
3278 (define_insn "*adddi3_64"
3279   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3280         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
3281                  (match_operand:DI 2 "general_operand" "d,K,m") ) )
3282    (clobber (reg:CC 33))]
3283   "TARGET_64BIT"
3284   "@
3285    agr\t%0,%2
3286    aghi\t%0,%h2
3287    ag\t%0,%2"
3288   [(set_attr "op_type"  "RRE,RI,RXY")])
3289
3290 (define_insn_and_split "*adddi3_31z"
3291   [(set (match_operand:DI 0 "register_operand" "=&d")
3292         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3293                  (match_operand:DI 2 "general_operand" "do") ) )
3294    (clobber (reg:CC 33))]
3295   "!TARGET_64BIT && TARGET_CPU_ZARCH"
3296   "#"
3297   "&& reload_completed"
3298   [(parallel
3299     [(set (reg:CCL1 33)
3300           (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3301                         (match_dup 7)))
3302      (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3303    (parallel
3304     [(set (match_dup 3) (plus:SI (plus:SI (match_dup 4) (match_dup 5))
3305                                  (ltu:SI (reg:CCL1 33) (const_int 0))))
3306      (clobber (reg:CC 33))])]
3307   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3308    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3309    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3310    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3311    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3312    operands[8] = operand_subword (operands[2], 1, 0, DImode);"
3313   [(set_attr "op_type"  "NN")])
3314
3315 (define_insn_and_split "*adddi3_31"
3316   [(set (match_operand:DI 0 "register_operand" "=&d")
3317         (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
3318                  (match_operand:DI 2 "general_operand" "do") ) )
3319    (clobber (reg:CC 33))]
3320   "!TARGET_CPU_ZARCH"
3321   "#"
3322   "&& reload_completed"
3323   [(parallel
3324     [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
3325      (clobber (reg:CC 33))])
3326    (parallel
3327     [(set (reg:CCL1 33)
3328           (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
3329                         (match_dup 7)))
3330      (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
3331    (set (pc)
3332         (if_then_else (ltu (reg:CCL1 33) (const_int 0))
3333                       (pc)
3334                       (label_ref (match_dup 9))))
3335    (parallel
3336     [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
3337      (clobber (reg:CC 33))])
3338    (match_dup 9)]
3339   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3340    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3341    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3342    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3343    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3344    operands[8] = operand_subword (operands[2], 1, 0, DImode);
3345    operands[9] = gen_label_rtx ();"
3346   [(set_attr "op_type"  "NN")])
3347
3348 (define_expand "adddi3"
3349   [(parallel
3350     [(set (match_operand:DI 0 "register_operand" "")
3351           (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
3352                    (match_operand:DI 2 "general_operand" "")))
3353      (clobber (reg:CC 33))])]
3354   ""
3355   "")
3356
3357 (define_insn "*la_64"
3358   [(set (match_operand:DI 0 "register_operand" "=d,d")
3359         (match_operand:QI 1 "address_operand" "U,W"))]
3360   "TARGET_64BIT"
3361   "@
3362    la\t%0,%a1
3363    lay\t%0,%a1"
3364   [(set_attr "op_type" "RX,RXY")
3365    (set_attr "type"    "la")])
3366
3367 (define_peephole2
3368   [(parallel
3369     [(set (match_operand:DI 0 "register_operand" "")
3370           (match_operand:QI 1 "address_operand" ""))
3371      (clobber (reg:CC 33))])]
3372   "TARGET_64BIT
3373    && strict_memory_address_p (VOIDmode, operands[1])
3374    && preferred_la_operand_p (operands[1])"
3375   [(set (match_dup 0) (match_dup 1))]
3376   "")
3377
3378 (define_peephole2
3379   [(set (match_operand:DI 0 "register_operand" "")
3380         (match_operand:DI 1 "register_operand" ""))
3381    (parallel
3382     [(set (match_dup 0)
3383           (plus:DI (match_dup 0)
3384                    (match_operand:DI 2 "nonmemory_operand" "")))
3385      (clobber (reg:CC 33))])]
3386   "TARGET_64BIT
3387    && !reg_overlap_mentioned_p (operands[0], operands[2])
3388    && strict_memory_address_p (VOIDmode, gen_rtx_PLUS (DImode, operands[1], operands[2]))
3389    && preferred_la_operand_p (gen_rtx_PLUS (DImode, operands[1], operands[2]))"
3390   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3391   "")
3392
3393 (define_expand "reload_indi"
3394   [(parallel [(match_operand:DI 0 "register_operand" "=a")
3395               (match_operand:DI 1 "s390_plus_operand" "")
3396               (match_operand:DI 2 "register_operand" "=&a")])]
3397   "TARGET_64BIT"
3398 {
3399   s390_expand_plus_operand (operands[0], operands[1], operands[2]);
3400   DONE;
3401 })
3402
3403
3404 ;
3405 ; addsi3 instruction pattern(s).
3406 ;
3407
3408 (define_insn "*addsi3_imm_cc"
3409   [(set (reg 33)
3410         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "0")
3411                           (match_operand:SI 2 "const_int_operand" "K"))
3412                  (const_int 0)))
3413    (set (match_operand:SI 0 "register_operand" "=d")
3414         (plus:SI (match_dup 1) (match_dup 2)))]
3415   "s390_match_ccmode (insn, CCAmode)
3416    && CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'K')"
3417   "ahi\t%0,%h2"
3418   [(set_attr "op_type"  "RI")])
3419
3420 (define_insn "*addsi3_carry1_cc"
3421   [(set (reg 33)
3422         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3423                           (match_operand:SI 2 "general_operand" "d,R,T"))
3424                  (match_dup 1)))
3425    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3426         (plus:SI (match_dup 1) (match_dup 2)))]
3427   "s390_match_ccmode (insn, CCL1mode)"
3428   "@
3429    alr\t%0,%2
3430    al\t%0,%2
3431    aly\t%0,%2"
3432   [(set_attr "op_type"  "RR,RX,RXY")])
3433
3434 (define_insn "*addsi3_carry1_cconly"
3435   [(set (reg 33)
3436         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3437                           (match_operand:SI 2 "general_operand" "d,R,T"))
3438                  (match_dup 1)))
3439    (clobber (match_scratch:SI 0 "=d,d,d"))]
3440   "s390_match_ccmode (insn, CCL1mode)"
3441   "@
3442    alr\t%0,%2
3443    al\t%0,%2
3444    aly\t%0,%2"
3445   [(set_attr "op_type"  "RR,RX,RXY")])
3446
3447 (define_insn "*addsi3_carry2_cc"
3448   [(set (reg 33)
3449         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3450                           (match_operand:SI 2 "general_operand" "d,R,T"))
3451                  (match_dup 2)))
3452    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3453         (plus:SI (match_dup 1) (match_dup 2)))]
3454   "s390_match_ccmode (insn, CCL1mode)"
3455   "@
3456    alr\t%0,%2
3457    al\t%0,%2
3458    aly\t%0,%2"
3459   [(set_attr "op_type"  "RR,RX,RXY")])
3460
3461 (define_insn "*addsi3_carry2_cconly"
3462   [(set (reg 33)
3463         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3464                           (match_operand:SI 2 "general_operand" "d,R,T"))
3465                  (match_dup 2)))
3466    (clobber (match_scratch:SI 0 "=d,d,d"))]
3467   "s390_match_ccmode (insn, CCL1mode)"
3468   "@
3469    alr\t%0,%2
3470    al\t%0,%2
3471    aly\t%0,%2"
3472   [(set_attr "op_type"  "RR,RX,RXY")])
3473
3474 (define_insn "*addsi3_cc"
3475   [(set (reg 33)
3476         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3477                           (match_operand:SI 2 "general_operand" "d,R,T"))
3478                  (const_int 0)))
3479    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3480         (plus:SI (match_dup 1) (match_dup 2)))]
3481   "s390_match_ccmode (insn, CCLmode)"
3482   "@
3483    alr\t%0,%2
3484    al\t%0,%2
3485    aly\t%0,%2"
3486   [(set_attr "op_type"  "RR,RX,RXY")])
3487
3488 (define_insn "*addsi3_cconly"
3489   [(set (reg 33)
3490         (compare (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3491                           (match_operand:SI 2 "general_operand" "d,R,T"))
3492                  (const_int 0)))
3493    (clobber (match_scratch:SI 0 "=d,d,d"))]
3494   "s390_match_ccmode (insn, CCLmode)"
3495   "@
3496    alr\t%0,%2
3497    al\t%0,%2
3498    aly\t%0,%2"
3499   [(set_attr "op_type"  "RR,RX,RXY")])
3500
3501 (define_insn "*addsi3_cconly2"
3502   [(set (reg 33)
3503         (compare (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
3504                  (neg:SI (match_operand:SI 2 "general_operand" "d,R,T"))))
3505    (clobber (match_scratch:SI 0 "=d,d,d"))]
3506   "s390_match_ccmode (insn, CCLmode)"
3507   "@
3508    alr\t%0,%2
3509    al\t%0,%2
3510    aly\t%0,%2"
3511   [(set_attr "op_type"  "RR,RX,RXY")])
3512
3513 (define_insn "*addsi3_sign"
3514   [(set (match_operand:SI 0 "register_operand" "=d,d")
3515         (plus:SI (match_operand:SI 1 "register_operand" "0,0")
3516                  (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
3517    (clobber (reg:CC 33))]
3518   ""
3519   "@
3520    ah\t%0,%2
3521    ahy\t%0,%2"
3522   [(set_attr "op_type"  "RX,RXY")])
3523
3524 (define_insn "addsi3"
3525   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3526         (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
3527                  (match_operand:SI 2 "general_operand" "d,K,R,T")))
3528    (clobber (reg:CC 33))]
3529   ""
3530   "@
3531    ar\t%0,%2
3532    ahi\t%0,%h2
3533    a\t%0,%2
3534    ay\t%0,%2"
3535   [(set_attr "op_type"  "RR,RI,RX,RXY")])
3536
3537 (define_insn "*la_31"
3538   [(set (match_operand:SI 0 "register_operand" "=d,d")
3539         (match_operand:QI 1 "address_operand" "U,W"))]
3540   "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
3541   "@
3542    la\t%0,%a1
3543    lay\t%0,%a1"
3544   [(set_attr "op_type"  "RX,RXY")
3545    (set_attr "type"     "la")])
3546
3547 (define_peephole2
3548   [(parallel
3549     [(set (match_operand:SI 0 "register_operand" "")
3550           (match_operand:QI 1 "address_operand" ""))
3551      (clobber (reg:CC 33))])]
3552   "!TARGET_64BIT
3553    && strict_memory_address_p (VOIDmode, operands[1])
3554    && preferred_la_operand_p (operands[1])"
3555   [(set (match_dup 0) (match_dup 1))]
3556   "")
3557
3558 (define_peephole2
3559   [(set (match_operand:SI 0 "register_operand" "")
3560         (match_operand:SI 1 "register_operand" ""))
3561    (parallel
3562     [(set (match_dup 0)
3563           (plus:SI (match_dup 0)
3564                    (match_operand:SI 2 "nonmemory_operand" "")))
3565      (clobber (reg:CC 33))])]
3566   "!TARGET_64BIT
3567    && !reg_overlap_mentioned_p (operands[0], operands[2])
3568    && strict_memory_address_p (VOIDmode, gen_rtx_PLUS (SImode, operands[1], operands[2]))
3569    && preferred_la_operand_p (gen_rtx_PLUS (SImode, operands[1], operands[2]))"
3570   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
3571   "")
3572
3573 (define_insn "*la_31_and"
3574   [(set (match_operand:SI 0 "register_operand" "=d,d")
3575         (and:SI (match_operand:QI 1 "address_operand" "U,W")
3576                 (const_int 2147483647)))]
3577   "!TARGET_64BIT"
3578   "@
3579    la\t%0,%a1
3580    lay\t%0,%a1"
3581   [(set_attr "op_type"  "RX,RXY")
3582    (set_attr "type"     "la")])
3583
3584 (define_insn_and_split "*la_31_and_cc"
3585   [(set (match_operand:SI 0 "register_operand" "=d")
3586         (and:SI (match_operand:QI 1 "address_operand" "p")
3587                 (const_int 2147483647)))
3588    (clobber (reg:CC 33))]
3589   "!TARGET_64BIT"
3590   "#"
3591   "&& reload_completed"
3592   [(set (match_dup 0)
3593         (and:SI (match_dup 1) (const_int 2147483647)))]
3594   ""
3595   [(set_attr "op_type"  "RX")
3596    (set_attr "type"     "la")])
3597
3598 (define_insn "force_la_31"
3599   [(set (match_operand:SI 0 "register_operand" "=d,d")
3600         (match_operand:QI 1 "address_operand" "U,W"))
3601    (use (const_int 0))]
3602   "!TARGET_64BIT"
3603   "@
3604    la\t%0,%a1
3605    lay\t%0,%a1"
3606   [(set_attr "op_type"  "RX")
3607    (set_attr "type"     "la")])
3608
3609 (define_expand "reload_insi"
3610   [(parallel [(match_operand:SI 0 "register_operand" "=a")
3611               (match_operand:SI 1 "s390_plus_operand" "")
3612               (match_operand:SI 2 "register_operand" "=&a")])]
3613   "!TARGET_64BIT"
3614 {
3615   s390_expand_plus_operand (operands[0], operands[1], operands[2]);
3616   DONE;
3617 })
3618
3619
3620 ;
3621 ; adddf3 instruction pattern(s).
3622 ;
3623
3624 (define_expand "adddf3"
3625   [(parallel
3626     [(set (match_operand:DF 0 "register_operand" "=f,f")
3627           (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3628                    (match_operand:DF 2 "general_operand" "f,R")))
3629      (clobber (reg:CC 33))])]
3630   "TARGET_HARD_FLOAT"
3631   "")
3632
3633 (define_insn "*adddf3"
3634   [(set (match_operand:DF 0 "register_operand" "=f,f")
3635         (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3636                  (match_operand:DF 2 "general_operand" "f,R")))
3637    (clobber (reg:CC 33))]
3638   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3639   "@
3640    adbr\t%0,%2
3641    adb\t%0,%2"
3642   [(set_attr "op_type"  "RRE,RXE")
3643    (set_attr "type"     "fsimpd,fsimpd")])
3644
3645 (define_insn "*adddf3_cc"
3646   [(set (reg 33)
3647         (compare (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3648                           (match_operand:DF 2 "general_operand" "f,R"))
3649                  (match_operand:DF 3 "const0_operand" "")))
3650    (set (match_operand:DF 0 "register_operand" "=f,f")
3651         (plus:DF (match_dup 1) (match_dup 2)))]
3652   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3653   "@
3654    adbr\t%0,%2
3655    adb\t%0,%2"
3656   [(set_attr "op_type"  "RRE,RXE")
3657    (set_attr "type"     "fsimpd,fsimpd")])
3658
3659 (define_insn "*adddf3_cconly"
3660   [(set (reg 33)
3661         (compare (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3662                           (match_operand:DF 2 "general_operand" "f,R"))
3663                  (match_operand:DF 3 "const0_operand" "")))
3664    (clobber (match_scratch:DF 0 "=f,f"))]
3665   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3666   "@
3667   adbr\t%0,%2
3668   adb\t%0,%2"
3669   [(set_attr "op_type"  "RRE,RXE")
3670    (set_attr "type"     "fsimpd,fsimpd")])
3671
3672 (define_insn "*adddf3_ibm"
3673   [(set (match_operand:DF 0 "register_operand" "=f,f")
3674         (plus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
3675                  (match_operand:DF 2 "general_operand" "f,R")))
3676    (clobber (reg:CC 33))]
3677   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3678   "@
3679    adr\t%0,%2
3680    ad\t%0,%2"
3681   [(set_attr "op_type"  "RR,RX")
3682    (set_attr "type"     "fsimpd,fsimpd")])
3683
3684 ;
3685 ; addsf3 instruction pattern(s).
3686 ;
3687
3688 (define_expand "addsf3"
3689   [(parallel
3690     [(set (match_operand:SF 0 "register_operand" "=f,f")
3691           (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3692                    (match_operand:SF 2 "general_operand" "f,R")))
3693      (clobber (reg:CC 33))])]
3694   "TARGET_HARD_FLOAT"
3695   "")
3696
3697 (define_insn "*addsf3"
3698   [(set (match_operand:SF 0 "register_operand" "=f,f")
3699         (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3700                  (match_operand:SF 2 "general_operand" "f,R")))
3701    (clobber (reg:CC 33))]
3702   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3703   "@
3704    aebr\t%0,%2
3705    aeb\t%0,%2"
3706   [(set_attr "op_type"  "RRE,RXE")
3707    (set_attr "type"     "fsimps,fsimps")])
3708
3709 (define_insn "*addsf3_cc"
3710   [(set (reg 33)
3711         (compare (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3712                           (match_operand:SF 2 "general_operand" "f,R"))
3713                  (match_operand:SF 3 "const0_operand" "")))
3714    (set (match_operand:SF 0 "register_operand" "=f,f")
3715         (plus:SF (match_dup 1) (match_dup 2)))]
3716   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3717   "@
3718    aebr\t%0,%2
3719    aeb\t%0,%2"
3720   [(set_attr "op_type"  "RRE,RXE")
3721    (set_attr "type"     "fsimps,fsimps")])
3722
3723 (define_insn "*addsf3_cconly"
3724   [(set (reg 33)
3725         (compare (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3726                           (match_operand:SF 2 "general_operand" "f,R"))
3727                  (match_operand:SF 3 "const0_operand" "")))
3728    (clobber (match_scratch:SF 0 "=f,f"))]
3729   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
3730   "@
3731    aebr\t%0,%2
3732    aeb\t%0,%2"
3733   [(set_attr "op_type"  "RRE,RXE")
3734    (set_attr "type"     "fsimps,fsimps")])
3735
3736 (define_insn "*addsf3"
3737   [(set (match_operand:SF 0 "register_operand" "=f,f")
3738         (plus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
3739                  (match_operand:SF 2 "general_operand" "f,R")))
3740    (clobber (reg:CC 33))]
3741   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
3742   "@
3743    aer\t%0,%2
3744    ae\t%0,%2"
3745   [(set_attr "op_type"  "RR,RX")
3746    (set_attr "type"     "fsimps,fsimps")])
3747
3748
3749 ;;
3750 ;;- Subtract instructions.
3751 ;;
3752
3753 ;
3754 ; subdi3 instruction pattern(s).
3755 ;
3756
3757 (define_insn "*subdi3_sign"
3758   [(set (match_operand:DI 0 "register_operand" "=d,d")
3759         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3760                   (sign_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3761    (clobber (reg:CC 33))]
3762   "TARGET_64BIT"
3763   "@
3764    sgfr\t%0,%2
3765    sgf\t%0,%2"
3766   [(set_attr "op_type"  "RRE,RXY")])
3767
3768 (define_insn "*subdi3_zero_cc"
3769   [(set (reg 33)
3770         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3771                            (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3772                  (const_int 0)))
3773    (set (match_operand:DI 0 "register_operand" "=d,d")
3774         (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
3775   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3776   "@
3777    slgfr\t%0,%2
3778    slgf\t%0,%2"
3779   [(set_attr "op_type"  "RRE,RXY")])
3780
3781 (define_insn "*subdi3_zero_cconly"
3782   [(set (reg 33)
3783         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3784                            (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m")))
3785                  (const_int 0)))
3786    (clobber (match_scratch:DI 0 "=d,d"))]
3787   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3788   "@
3789    slgfr\t%0,%2
3790    slgf\t%0,%2"
3791   [(set_attr "op_type"  "RRE,RXY")])
3792
3793 (define_insn "*subdi3_zero"
3794   [(set (match_operand:DI 0 "register_operand" "=d,d")
3795         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3796                   (zero_extend:DI (match_operand:SI 2 "general_operand" "d,m"))))
3797    (clobber (reg:CC 33))]
3798   "TARGET_64BIT"
3799   "@
3800    slgfr\t%0,%2
3801    slgf\t%0,%2"
3802   [(set_attr "op_type"  "RRE,RXY")])
3803
3804 (define_insn "*subdi3_borrow_cc"
3805   [(set (reg 33)
3806         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3807                            (match_operand:DI 2 "general_operand" "d,m"))
3808                  (match_dup 1)))
3809    (set (match_operand:DI 0 "register_operand" "=d,d")
3810         (minus:DI (match_dup 1) (match_dup 2)))]
3811   "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3812   "@
3813    slgr\t%0,%2
3814    slg\t%0,%2"
3815   [(set_attr "op_type"  "RRE,RXY")])
3816
3817 (define_insn "*subdi3_borrow_cconly"
3818   [(set (reg 33)
3819         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3820                            (match_operand:DI 2 "general_operand" "d,m"))
3821                  (match_dup 1)))
3822    (clobber (match_scratch:DI 0 "=d,d"))]
3823   "s390_match_ccmode (insn, CCL2mode) && TARGET_64BIT"
3824   "@
3825    slgr\t%0,%2
3826    slg\t%0,%2"
3827   [(set_attr "op_type"  "RRE,RXY")])
3828
3829 (define_insn "*subdi3_cc"
3830   [(set (reg 33)
3831         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3832                            (match_operand:DI 2 "general_operand" "d,m"))
3833                  (const_int 0)))
3834    (set (match_operand:DI 0 "register_operand" "=d,d")
3835         (minus:DI (match_dup 1) (match_dup 2)))]
3836   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3837   "@
3838    slgr\t%0,%2
3839    slg\t%0,%2"
3840   [(set_attr "op_type"  "RRE,RXY")])
3841
3842 (define_insn "*subdi3_cconly"
3843   [(set (reg 33)
3844         (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3845                            (match_operand:DI 2 "general_operand" "d,m"))
3846                  (const_int 0)))
3847    (clobber (match_scratch:DI 0 "=d,d"))]
3848   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
3849   "@
3850    slgr\t%0,%2
3851    slg\t%0,%2"
3852   [(set_attr "op_type"  "RRE,RXY")])
3853
3854 (define_insn "*subdi3_64"
3855   [(set (match_operand:DI 0 "register_operand" "=d,d")
3856         (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3857                   (match_operand:DI 2 "general_operand" "d,m") ) )
3858    (clobber (reg:CC 33))]
3859   "TARGET_64BIT"
3860   "@
3861    sgr\t%0,%2
3862    sg\t%0,%2"
3863   [(set_attr "op_type"  "RRE,RRE")])
3864
3865 (define_insn_and_split "*subdi3_31z"
3866   [(set (match_operand:DI 0 "register_operand" "=&d")
3867         (minus:DI (match_operand:DI 1 "register_operand" "0")
3868                   (match_operand:DI 2 "general_operand" "do") ) )
3869    (clobber (reg:CC 33))]
3870   "!TARGET_64BIT && TARGET_CPU_ZARCH"
3871   "#"
3872   "&& reload_completed"
3873   [(parallel
3874     [(set (reg:CCL2 33)
3875           (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
3876                         (match_dup 7)))
3877      (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
3878    (parallel
3879     [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
3880                                   (gtu:SI (reg:CCL2 33) (const_int 0))))
3881      (clobber (reg:CC 33))])]
3882   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3883    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3884    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3885    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3886    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3887    operands[8] = operand_subword (operands[2], 1, 0, DImode);"
3888   [(set_attr "op_type"  "NN")])
3889
3890 (define_insn_and_split "*subdi3_31"
3891   [(set (match_operand:DI 0 "register_operand" "=&d")
3892         (minus:DI (match_operand:DI 1 "register_operand" "0")
3893                   (match_operand:DI 2 "general_operand" "do") ) )
3894    (clobber (reg:CC 33))]
3895   "!TARGET_CPU_ZARCH"
3896   "#"
3897   "&& reload_completed"
3898   [(parallel
3899     [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
3900      (clobber (reg:CC 33))])
3901    (parallel
3902     [(set (reg:CCL2 33)
3903           (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
3904                         (match_dup 7)))
3905      (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
3906    (set (pc)
3907         (if_then_else (gtu (reg:CCL2 33) (const_int 0))
3908                       (pc)
3909                       (label_ref (match_dup 9))))
3910    (parallel
3911     [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
3912      (clobber (reg:CC 33))])
3913    (match_dup 9)]
3914   "operands[3] = operand_subword (operands[0], 0, 0, DImode);
3915    operands[4] = operand_subword (operands[1], 0, 0, DImode);
3916    operands[5] = operand_subword (operands[2], 0, 0, DImode);
3917    operands[6] = operand_subword (operands[0], 1, 0, DImode);
3918    operands[7] = operand_subword (operands[1], 1, 0, DImode);
3919    operands[8] = operand_subword (operands[2], 1, 0, DImode);
3920    operands[9] = gen_label_rtx ();"
3921   [(set_attr "op_type"  "NN")])
3922
3923 (define_expand "subdi3"
3924   [(parallel
3925     [(set (match_operand:DI 0 "register_operand" "")
3926           (minus:DI (match_operand:DI 1 "register_operand" "")
3927                     (match_operand:DI 2 "general_operand" "")))
3928      (clobber (reg:CC 33))])]
3929   ""
3930   "")
3931
3932 ;
3933 ; subsi3 instruction pattern(s).
3934 ;
3935
3936 (define_insn "*subsi3_borrow_cc"
3937   [(set (reg 33)
3938         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3939                            (match_operand:SI 2 "general_operand" "d,R,T"))
3940                  (match_dup 1)))
3941    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3942         (minus:SI (match_dup 1) (match_dup 2)))]
3943   "s390_match_ccmode (insn, CCL2mode)"
3944   "@
3945    slr\t%0,%2
3946    sl\t%0,%2
3947    sly\t%0,%2"
3948   [(set_attr "op_type"  "RR,RX,RXY")])
3949
3950 (define_insn "*subsi3_borrow_cconly"
3951   [(set (reg 33)
3952         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3953                            (match_operand:SI 2 "general_operand" "d,R,T"))
3954                  (match_dup 1)))
3955    (clobber (match_scratch:SI 0 "=d,d,d"))]
3956   "s390_match_ccmode (insn, CCL2mode)"
3957   "@
3958    slr\t%0,%2
3959    sl\t%0,%2
3960    sly\t%0,%2"
3961   [(set_attr "op_type"  "RR,RX,RXY")])
3962
3963 (define_insn "*subsi3_cc"
3964   [(set (reg 33)
3965         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3966                            (match_operand:SI 2 "general_operand" "d,R,T"))
3967                  (const_int 0)))
3968    (set (match_operand:SI 0 "register_operand" "=d,d,d")
3969         (minus:SI (match_dup 1) (match_dup 2)))]
3970   "s390_match_ccmode (insn, CCLmode)"
3971   "@
3972    slr\t%0,%2
3973    sl\t%0,%2
3974    sly\t%0,%2"
3975   [(set_attr "op_type"  "RR,RX,RXY")])
3976
3977 (define_insn "*subsi3_cconly"
3978   [(set (reg 33)
3979         (compare (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
3980                            (match_operand:SI 2 "general_operand" "d,R,T"))
3981                  (const_int 0)))
3982    (clobber (match_scratch:SI 0 "=d,d,d"))]
3983   "s390_match_ccmode (insn, CCLmode)"
3984   "@
3985    slr\t%0,%2
3986    sl\t%0,%2
3987    sly\t%0,%2"
3988   [(set_attr "op_type"  "RR,RX,RXY")])
3989
3990 (define_insn "*subsi3_sign"
3991   [(set (match_operand:SI 0 "register_operand" "=d,d")
3992         (minus:SI (match_operand:SI 1 "register_operand" "0,0")
3993                   (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
3994    (clobber (reg:CC 33))]
3995   ""
3996   "@
3997    sh\t%0,%2
3998    shy\t%0,%2"
3999   [(set_attr "op_type"  "RX,RXY")])
4000
4001 (define_insn "subsi3"
4002   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
4003         (minus:SI (match_operand:SI 1 "register_operand" "0,0,0")
4004                   (match_operand:SI 2 "general_operand" "d,R,T")))
4005    (clobber (reg:CC 33))]
4006   ""
4007   "@
4008    sr\t%0,%2
4009    s\t%0,%2
4010    sy\t%0,%2"
4011   [(set_attr "op_type"  "RR,RX,RXY")])
4012
4013
4014 ;
4015 ; subdf3 instruction pattern(s).
4016 ;
4017
4018 (define_expand "subdf3"
4019   [(parallel
4020     [(set (match_operand:DF 0 "register_operand" "=f,f")
4021           (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4022                     (match_operand:DF 2 "general_operand" "f,R")))
4023      (clobber (reg:CC 33))])]
4024   "TARGET_HARD_FLOAT"
4025   "")
4026
4027 (define_insn "*subdf3"
4028   [(set (match_operand:DF 0 "register_operand" "=f,f")
4029         (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4030                   (match_operand:DF 2 "general_operand" "f,R")))
4031    (clobber (reg:CC 33))]
4032   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4033   "@
4034    sdbr\t%0,%2
4035    sdb\t%0,%2"
4036   [(set_attr "op_type"  "RRE,RXE")
4037    (set_attr "type"     "fsimpd,fsimpd")])
4038
4039 (define_insn "*subdf3_cc"
4040   [(set (reg 33)
4041         (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4042                            (match_operand:DF 2 "general_operand" "f,R"))
4043                  (match_operand:DF 3 "const0_operand" "")))
4044    (set (match_operand:DF 0 "register_operand" "=f,f")
4045         (plus:DF (match_dup 1) (match_dup 2)))]
4046   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4047   "@
4048    sdbr\t%0,%2
4049    sdb\t%0,%2"
4050   [(set_attr "op_type"  "RRE,RXE")
4051    (set_attr "type"     "fsimpd,fsimpd")])
4052
4053 (define_insn "*subdf3_cconly"
4054   [(set (reg 33)
4055         (compare (minus:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4056                            (match_operand:DF 2 "general_operand" "f,R"))
4057                  (match_operand:DF 3 "const0_operand" "")))
4058    (clobber (match_scratch:DF 0 "=f,f"))]
4059   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4060   "@
4061    sdbr\t%0,%2
4062    sdb\t%0,%2"
4063   [(set_attr "op_type"  "RRE,RXE")
4064    (set_attr "type"     "fsimpd,fsimpd")])
4065
4066 (define_insn "*subdf3_ibm"
4067   [(set (match_operand:DF 0 "register_operand" "=f,f")
4068         (minus:DF (match_operand:DF 1 "register_operand" "0,0")
4069                   (match_operand:DF 2 "general_operand" "f,R")))
4070    (clobber (reg:CC 33))]
4071   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4072   "@
4073    sdr\t%0,%2
4074    sd\t%0,%2"
4075   [(set_attr "op_type"  "RR,RX")
4076    (set_attr "type"     "fsimpd,fsimpd")])
4077
4078 ;
4079 ; subsf3 instruction pattern(s).
4080 ;
4081
4082 (define_expand "subsf3"
4083   [(parallel
4084     [(set (match_operand:SF 0 "register_operand" "=f,f")
4085           (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4086                     (match_operand:SF 2 "general_operand" "f,R")))
4087      (clobber (reg:CC 33))])]
4088   "TARGET_HARD_FLOAT"
4089   "")
4090
4091 (define_insn "*subsf3"
4092   [(set (match_operand:SF 0 "register_operand" "=f,f")
4093         (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4094                   (match_operand:SF 2 "general_operand" "f,R")))
4095    (clobber (reg:CC 33))]
4096   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4097   "@
4098    sebr\t%0,%2
4099    seb\t%0,%2"
4100   [(set_attr "op_type"  "RRE,RXE")
4101    (set_attr "type"     "fsimps,fsimps")])
4102
4103 (define_insn "*subsf3_cc"
4104   [(set (reg 33)
4105         (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4106                            (match_operand:SF 2 "general_operand" "f,R"))
4107                  (match_operand:SF 3 "const0_operand" "")))
4108    (set (match_operand:SF 0 "register_operand" "=f,f")
4109         (minus:SF (match_dup 1) (match_dup 2)))]
4110   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4111   "@
4112    sebr\t%0,%2
4113    seb\t%0,%2"
4114   [(set_attr "op_type"  "RRE,RXE")
4115    (set_attr "type"     "fsimps,fsimps")])
4116
4117 (define_insn "*subsf3_cconly"
4118   [(set (reg 33)
4119         (compare (minus:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4120                            (match_operand:SF 2 "general_operand" "f,R"))
4121                  (match_operand:SF 3 "const0_operand" "")))
4122    (clobber (match_scratch:SF 0 "=f,f"))]
4123   "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4124   "@
4125    sebr\t%0,%2
4126    seb\t%0,%2"
4127   [(set_attr "op_type"  "RRE,RXE")
4128    (set_attr "type"     "fsimps,fsimps")])
4129
4130 (define_insn "*subsf3_ibm"
4131   [(set (match_operand:SF 0 "register_operand" "=f,f")
4132         (minus:SF (match_operand:SF 1 "register_operand" "0,0")
4133                   (match_operand:SF 2 "general_operand" "f,R")))
4134    (clobber (reg:CC 33))]
4135   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4136   "@
4137    ser\t%0,%2
4138    se\t%0,%2"
4139   [(set_attr "op_type"  "RR,RX")
4140    (set_attr "type"     "fsimps,fsimps")])
4141
4142
4143 ;;
4144 ;;- Conditional add/subtract instructions.
4145 ;;
4146
4147 ;
4148 ; adddicc instruction pattern(s).
4149 ;
4150
4151 (define_insn "*adddi3_alc_cc"
4152   [(set (reg 33) 
4153         (compare
4154           (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4155                             (match_operand:DI 2 "general_operand" "d,m"))
4156                    (match_operand:DI 3 "s390_alc_comparison" ""))
4157           (const_int 0)))
4158    (set (match_operand:DI 0 "register_operand" "=d,d")
4159         (plus:DI (plus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4160   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT" 
4161   "@
4162    alcgr\\t%0,%2
4163    alcg\\t%0,%2"
4164   [(set_attr "op_type"  "RRE,RXY")])
4165
4166 (define_insn "*adddi3_alc"
4167   [(set (match_operand:DI 0 "register_operand" "=d,d")
4168         (plus:DI (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4169                           (match_operand:DI 2 "general_operand" "d,m"))
4170                  (match_operand:DI 3 "s390_alc_comparison" "")))
4171    (clobber (reg:CC 33))] 
4172   "TARGET_64BIT" 
4173   "@
4174    alcgr\\t%0,%2
4175    alcg\\t%0,%2"
4176   [(set_attr "op_type"  "RRE,RXY")])
4177
4178 (define_insn "*subdi3_slb_cc"
4179   [(set (reg 33) 
4180         (compare
4181           (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4182                               (match_operand:DI 2 "general_operand" "d,m"))
4183                     (match_operand:DI 3 "s390_slb_comparison" ""))
4184           (const_int 0)))
4185    (set (match_operand:DI 0 "register_operand" "=d,d")
4186         (minus:DI (minus:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4187   "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT" 
4188   "@
4189    slbgr\\t%0,%2
4190    slbg\\t%0,%2"
4191   [(set_attr "op_type"  "RRE,RXY")])
4192
4193 (define_insn "*subdi3_slb"
4194   [(set (match_operand:DI 0 "register_operand" "=d,d")
4195         (minus:DI (minus:DI (match_operand:DI 1 "nonimmediate_operand" "0,0")
4196                             (match_operand:DI 2 "general_operand" "d,m"))
4197                   (match_operand:DI 3 "s390_slb_comparison" "")))
4198    (clobber (reg:CC 33))] 
4199   "TARGET_64BIT" 
4200   "@
4201    slbgr\\t%0,%2
4202    slbg\\t%0,%2"
4203   [(set_attr "op_type"  "RRE,RXY")])
4204
4205 ;
4206 ; addsicc instruction pattern(s).
4207 ;
4208
4209 (define_insn "*addsi3_alc_cc"
4210   [(set (reg 33) 
4211         (compare
4212           (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4213                             (match_operand:SI 2 "general_operand" "d,m"))
4214                    (match_operand:SI 3 "s390_alc_comparison" ""))
4215           (const_int 0)))
4216    (set (match_operand:SI 0 "register_operand" "=d,d")
4217         (plus:SI (plus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4218   "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH" 
4219   "@
4220    alcr\\t%0,%2
4221    alc\\t%0,%2"
4222   [(set_attr "op_type"  "RRE,RXY")])
4223
4224 (define_insn "*addsi3_alc"
4225   [(set (match_operand:SI 0 "register_operand" "=d,d")
4226         (plus:SI (plus:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0")
4227                           (match_operand:SI 2 "general_operand" "d,m"))
4228                  (match_operand:SI 3 "s390_alc_comparison" "")))
4229    (clobber (reg:CC 33))]
4230   "TARGET_CPU_ZARCH" 
4231   "@
4232    alcr\\t%0,%2
4233    alc\\t%0,%2"
4234   [(set_attr "op_type"  "RRE,RXY")])
4235
4236 (define_insn "*subsi3_slb_cc"
4237   [(set (reg 33) 
4238         (compare
4239           (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4240                               (match_operand:SI 2 "general_operand" "d,m"))
4241                     (match_operand:SI 3 "s390_slb_comparison" ""))
4242           (const_int 0)))
4243    (set (match_operand:SI 0 "register_operand" "=d,d")
4244         (minus:SI (minus:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4245   "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH" 
4246   "@
4247    slbr\\t%0,%2
4248    slb\\t%0,%2"
4249   [(set_attr "op_type"  "RRE,RXY")])
4250
4251 (define_insn "*subsi3_slb"
4252   [(set (match_operand:SI 0 "register_operand" "=d,d")
4253         (minus:SI (minus:SI (match_operand:SI 1 "nonimmediate_operand" "0,0")
4254                             (match_operand:SI 2 "general_operand" "d,m"))
4255                   (match_operand:SI 3 "s390_slb_comparison" "")))
4256    (clobber (reg:CC 33))] 
4257   "TARGET_CPU_ZARCH" 
4258   "@
4259    slbr\\t%0,%2
4260    slb\\t%0,%2"
4261   [(set_attr "op_type"  "RRE,RXY")])
4262
4263
4264 ;;
4265 ;;- Multiply instructions.
4266 ;;
4267
4268 ;
4269 ; muldi3 instruction pattern(s).
4270 ;
4271
4272 (define_insn "*muldi3_sign"
4273   [(set (match_operand:DI 0 "register_operand" "=d,d")
4274         (mult:DI (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m"))
4275                  (match_operand:DI 1 "register_operand" "0,0")))]
4276   "TARGET_64BIT"
4277   "@
4278    msgfr\t%0,%2
4279    msgf\t%0,%2"
4280   [(set_attr "op_type"  "RRE,RXY")
4281    (set_attr "type"     "imul")])
4282
4283 (define_insn "muldi3"
4284   [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4285         (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0")
4286                  (match_operand:DI 2 "general_operand" "d,K,m")))]
4287   "TARGET_64BIT"
4288   "@
4289    msgr\t%0,%2
4290    mghi\t%0,%h2
4291    msg\t%0,%2"
4292   [(set_attr "op_type"  "RRE,RI,RXY")
4293    (set_attr "type"     "imul")])
4294
4295 ;
4296 ; mulsi3 instruction pattern(s).
4297 ;
4298
4299 (define_insn "*mulsi3_sign"
4300   [(set (match_operand:SI 0 "register_operand" "=d")
4301         (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R"))
4302                  (match_operand:SI 1 "register_operand" "0")))]
4303   ""
4304   "mh\t%0,%2"
4305   [(set_attr "op_type"  "RX")
4306    (set_attr "type"     "imul")])
4307
4308 (define_insn "mulsi3"
4309   [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4310         (mult:SI  (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
4311                   (match_operand:SI 2 "general_operand" "d,K,R,T")))]
4312   ""
4313   "@
4314    msr\t%0,%2
4315    mhi\t%0,%h2
4316    ms\t%0,%2
4317    msy\t%0,%2"
4318   [(set_attr "op_type"  "RRE,RI,RX,RXY")
4319    (set_attr "type"     "imul")])
4320
4321 ;
4322 ; mulsidi3 instruction pattern(s).
4323 ;
4324
4325 (define_insn "mulsidi3"
4326   [(set (match_operand:DI 0 "register_operand" "=d,d")
4327         (mult:DI (sign_extend:DI
4328                    (match_operand:SI 1 "register_operand" "%0,0"))
4329                  (sign_extend:DI
4330                    (match_operand:SI 2 "nonimmediate_operand" "d,R"))))]
4331   "!TARGET_64BIT"
4332   "@
4333    mr\t%0,%2
4334    m\t%0,%2"
4335   [(set_attr "op_type"  "RR,RX")
4336    (set_attr "type"     "imul")])
4337
4338 ;
4339 ; umulsidi3 instruction pattern(s).
4340 ;
4341
4342 (define_insn "umulsidi3"
4343   [(set (match_operand:DI 0 "register_operand" "=d,d")
4344         (mult:DI (zero_extend:DI
4345                    (match_operand:SI 1 "register_operand" "%0,0"))
4346                  (zero_extend:DI
4347                    (match_operand:SI 2 "nonimmediate_operand" "d,m"))))]
4348   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4349   "@
4350    mlr\t%0,%2
4351    ml\t%0,%2"
4352   [(set_attr "op_type"  "RRE,RXY")
4353    (set_attr "type"     "imul")])
4354
4355 ;
4356 ; muldf3 instruction pattern(s).
4357 ;
4358
4359 (define_expand "muldf3"
4360   [(set (match_operand:DF 0 "register_operand" "=f,f")
4361         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4362                  (match_operand:DF 2 "general_operand" "f,R")))]
4363   "TARGET_HARD_FLOAT"
4364   "")
4365
4366 (define_insn "*muldf3"
4367   [(set (match_operand:DF 0 "register_operand" "=f,f")
4368         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4369                  (match_operand:DF 2 "general_operand" "f,R")))]
4370   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4371   "@
4372    mdbr\t%0,%2
4373    mdb\t%0,%2"
4374   [(set_attr "op_type"  "RRE,RXE")
4375    (set_attr "type"     "fmuld")])
4376
4377 (define_insn "*muldf3_ibm"
4378   [(set (match_operand:DF 0 "register_operand" "=f,f")
4379         (mult:DF (match_operand:DF 1 "nonimmediate_operand" "%0,0")
4380                  (match_operand:DF 2 "general_operand" "f,R")))]
4381   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4382   "@
4383    mdr\t%0,%2
4384    md\t%0,%2"
4385   [(set_attr "op_type"  "RR,RX")
4386    (set_attr "type"    "fmuld")])
4387
4388 (define_insn "*fmadddf"
4389   [(set (match_operand:DF 0 "register_operand" "=f,f")
4390         (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "%f,f")
4391                           (match_operand:DF 2 "nonimmediate_operand"  "f,R"))
4392                  (match_operand:DF 3 "register_operand" "0,0")))]
4393   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4394   "@
4395    madbr\t%0,%1,%2
4396    madb\t%0,%1,%2"
4397   [(set_attr "op_type"  "RRE,RXE")
4398    (set_attr "type" "fmuld")])
4399
4400 (define_insn "*fmsubdf"
4401   [(set (match_operand:DF 0 "register_operand" "=f,f")
4402         (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "f,f")
4403                            (match_operand:DF 2 "nonimmediate_operand"  "f,R"))
4404                  (match_operand:DF 3 "register_operand" "0,0")))]
4405   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4406   "@
4407    msdbr\t%0,%1,%2
4408    msdb\t%0,%1,%2"
4409   [(set_attr "op_type"  "RRE,RXE")
4410    (set_attr "type" "fmuld")])
4411
4412 ;
4413 ; mulsf3 instruction pattern(s).
4414 ;
4415
4416 (define_expand "mulsf3"
4417   [(set (match_operand:SF 0 "register_operand" "=f,f")
4418         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4419                  (match_operand:SF 2 "general_operand" "f,R")))]
4420   "TARGET_HARD_FLOAT"
4421   "")
4422
4423 (define_insn "*mulsf3"
4424   [(set (match_operand:SF 0 "register_operand" "=f,f")
4425         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4426                  (match_operand:SF 2 "general_operand" "f,R")))]
4427   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4428   "@
4429    meebr\t%0,%2
4430    meeb\t%0,%2"
4431   [(set_attr "op_type"  "RRE,RXE")
4432    (set_attr "type"     "fmuls")])
4433
4434 (define_insn "*mulsf3_ibm"
4435   [(set (match_operand:SF 0 "register_operand" "=f,f")
4436         (mult:SF (match_operand:SF 1 "nonimmediate_operand" "%0,0")
4437                  (match_operand:SF 2 "general_operand" "f,R")))]
4438   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4439   "@
4440    mer\t%0,%2
4441    me\t%0,%2"
4442   [(set_attr "op_type"  "RR,RX")
4443    (set_attr "type"     "fmuls")])
4444
4445 (define_insn "*fmaddsf"
4446   [(set (match_operand:SF 0 "register_operand" "=f,f")
4447         (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f,f")
4448                           (match_operand:SF 2 "nonimmediate_operand"  "f,R"))
4449                  (match_operand:SF 3 "register_operand" "0,0")))]
4450   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4451   "@
4452    maebr\t%0,%1,%2
4453    maeb\t%0,%1,%2"
4454   [(set_attr "op_type"  "RRE,RXE")
4455    (set_attr "type" "fmuls")])
4456
4457 (define_insn "*fmsubsf"
4458   [(set (match_operand:SF 0 "register_operand" "=f,f")
4459         (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "f,f")
4460                            (match_operand:SF 2 "nonimmediate_operand"  "f,R"))
4461                   (match_operand:SF 3 "register_operand" "0,0")))]
4462   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT && TARGET_FUSED_MADD"
4463   "@
4464    msebr\t%0,%1,%2
4465    mseb\t%0,%1,%2"
4466   [(set_attr "op_type"  "RRE,RXE")
4467    (set_attr "type" "fmuls")])
4468
4469 ;;
4470 ;;- Divide and modulo instructions.
4471 ;;
4472
4473 ;
4474 ; divmoddi4 instruction pattern(s).
4475 ;
4476
4477 (define_expand "divmoddi4"
4478   [(parallel [(set (match_operand:DI 0 "general_operand" "")
4479                    (div:DI (match_operand:DI 1 "register_operand" "")
4480                            (match_operand:DI 2 "general_operand" "")))
4481               (set (match_operand:DI 3 "general_operand" "")
4482                    (mod:DI (match_dup 1) (match_dup 2)))])
4483    (clobber (match_dup 4))]
4484   "TARGET_64BIT"
4485 {
4486   rtx insn, div_equal, mod_equal;
4487
4488   div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
4489   mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4490
4491   operands[4] = gen_reg_rtx(TImode);
4492   emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4493
4494   insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4495   REG_NOTES (insn) =
4496         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4497
4498   insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4499   REG_NOTES (insn) =
4500         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4501
4502   DONE;
4503 })
4504
4505 (define_insn "divmodtidi3"
4506   [(set (match_operand:TI 0 "register_operand" "=d,d")
4507         (ior:TI
4508           (zero_extend:TI
4509             (div:DI (match_operand:DI 1 "register_operand" "0,0")
4510                     (match_operand:DI 2 "general_operand" "d,m")))
4511           (ashift:TI
4512             (zero_extend:TI
4513               (mod:DI (match_dup 1)
4514                       (match_dup 2)))
4515             (const_int 64))))]
4516   "TARGET_64BIT"
4517   "@
4518    dsgr\t%0,%2
4519    dsg\t%0,%2"
4520   [(set_attr "op_type"  "RRE,RXY")
4521    (set_attr "type"     "idiv")])
4522
4523 (define_insn "divmodtisi3"
4524   [(set (match_operand:TI 0 "register_operand" "=d,d")
4525         (ior:TI
4526           (zero_extend:TI
4527             (div:DI (match_operand:DI 1 "register_operand" "0,0")
4528                     (sign_extend:DI (match_operand:SI 2 "nonimmediate_operand" "d,m"))))
4529           (ashift:TI
4530             (zero_extend:TI
4531               (mod:DI (match_dup 1)
4532                       (sign_extend:DI (match_dup 2))))
4533             (const_int 64))))]
4534   "TARGET_64BIT"
4535   "@
4536    dsgfr\t%0,%2
4537    dsgf\t%0,%2"
4538   [(set_attr "op_type"  "RRE,RXY")
4539    (set_attr "type"     "idiv")])
4540
4541 ;
4542 ; udivmoddi4 instruction pattern(s).
4543 ;
4544
4545 (define_expand "udivmoddi4"
4546   [(parallel [(set (match_operand:DI 0 "general_operand" "")
4547                    (udiv:DI (match_operand:DI 1 "general_operand" "")
4548                             (match_operand:DI 2 "nonimmediate_operand" "")))
4549               (set (match_operand:DI 3 "general_operand" "")
4550                    (umod:DI (match_dup 1) (match_dup 2)))])
4551    (clobber (match_dup 4))]
4552   "TARGET_64BIT"
4553 {
4554   rtx insn, div_equal, mod_equal, equal;
4555
4556   div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
4557   mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
4558   equal = gen_rtx_IOR (TImode,
4559                        gen_rtx_ZERO_EXTEND (TImode, div_equal),
4560                        gen_rtx_ASHIFT (TImode,
4561                                        gen_rtx_ZERO_EXTEND (TImode, mod_equal),
4562                                        GEN_INT (64)));
4563
4564   operands[4] = gen_reg_rtx(TImode);
4565   emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4566   emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
4567   emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
4568   insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
4569   REG_NOTES (insn) =
4570         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4571
4572   insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
4573   REG_NOTES (insn) =
4574         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4575
4576   insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
4577   REG_NOTES (insn) =
4578         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4579
4580   DONE;
4581 })
4582
4583 (define_insn "udivmodtidi3"
4584   [(set (match_operand:TI 0 "register_operand" "=d,d")
4585         (ior:TI (zero_extend:TI
4586                   (truncate:DI
4587                     (udiv:TI (match_operand:TI 1 "register_operand" "0,0")
4588                              (zero_extend:TI
4589                                (match_operand:DI 2 "nonimmediate_operand" "d,m")))))
4590                 (ashift:TI
4591                   (zero_extend:TI
4592                     (truncate:DI
4593                       (umod:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))
4594                   (const_int 64))))]
4595   "TARGET_64BIT"
4596   "@
4597    dlgr\t%0,%2
4598    dlg\t%0,%2"
4599   [(set_attr "op_type"  "RRE,RXY")
4600    (set_attr "type"     "idiv")])
4601
4602 ;
4603 ; divmodsi4 instruction pattern(s).
4604 ;
4605
4606 (define_expand "divmodsi4"
4607   [(parallel [(set (match_operand:SI 0 "general_operand" "")
4608                    (div:SI (match_operand:SI 1 "general_operand" "")
4609                            (match_operand:SI 2 "nonimmediate_operand" "")))
4610               (set (match_operand:SI 3 "general_operand" "")
4611                    (mod:SI (match_dup 1) (match_dup 2)))])
4612    (clobber (match_dup 4))]
4613   "!TARGET_64BIT"
4614 {
4615   rtx insn, div_equal, mod_equal, equal;
4616
4617   div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
4618   mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
4619   equal = gen_rtx_IOR (DImode,
4620                        gen_rtx_ZERO_EXTEND (DImode, div_equal),
4621                        gen_rtx_ASHIFT (DImode,
4622                                        gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4623                                        GEN_INT (32)));
4624
4625   operands[4] = gen_reg_rtx(DImode);
4626   emit_insn (gen_extendsidi2 (operands[4], operands[1]));
4627   insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
4628   REG_NOTES (insn) =
4629         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4630
4631   insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4632   REG_NOTES (insn) =
4633         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4634
4635   insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4636   REG_NOTES (insn) =
4637         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4638
4639   DONE;
4640 })
4641
4642 (define_insn "divmoddisi3"
4643   [(set (match_operand:DI 0 "register_operand" "=d,d")
4644         (ior:DI (zero_extend:DI
4645                   (truncate:SI
4646                     (div:DI (match_operand:DI 1 "register_operand" "0,0")
4647                             (sign_extend:DI
4648                               (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
4649                 (ashift:DI
4650                   (zero_extend:DI
4651                     (truncate:SI
4652                       (mod:DI (match_dup 1) (sign_extend:SI (match_dup 2)))))
4653                   (const_int 32))))]
4654   "!TARGET_64BIT"
4655   "@
4656    dr\t%0,%2
4657    d\t%0,%2"
4658   [(set_attr "op_type"  "RR,RX")
4659    (set_attr "type"     "idiv")])
4660
4661 ;
4662 ; udivsi3 and umodsi3 instruction pattern(s).
4663 ;
4664
4665 (define_expand "udivmodsi4"
4666   [(parallel [(set (match_operand:SI 0 "general_operand" "")
4667                    (udiv:SI (match_operand:SI 1 "general_operand" "")
4668                             (match_operand:SI 2 "nonimmediate_operand" "")))
4669               (set (match_operand:SI 3 "general_operand" "")
4670                    (umod:SI (match_dup 1) (match_dup 2)))])
4671    (clobber (match_dup 4))]
4672   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4673 {
4674   rtx insn, div_equal, mod_equal, equal;
4675
4676   div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4677   mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4678   equal = gen_rtx_IOR (DImode,
4679                        gen_rtx_ZERO_EXTEND (DImode, div_equal),
4680                        gen_rtx_ASHIFT (DImode,
4681                                        gen_rtx_ZERO_EXTEND (DImode, mod_equal),
4682                                        GEN_INT (32)));
4683
4684   operands[4] = gen_reg_rtx(DImode);
4685   emit_insn (gen_rtx_CLOBBER (VOIDmode, operands[4]));
4686   emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
4687   emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
4688   insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
4689   REG_NOTES (insn) =
4690         gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4691
4692   insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
4693   REG_NOTES (insn) =
4694         gen_rtx_EXPR_LIST (REG_EQUAL, div_equal, REG_NOTES (insn));
4695
4696   insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
4697   REG_NOTES (insn) =
4698         gen_rtx_EXPR_LIST (REG_EQUAL, mod_equal, REG_NOTES (insn));
4699
4700   DONE;
4701 })
4702
4703 (define_insn "udivmoddisi3"
4704   [(set (match_operand:DI 0 "register_operand" "=d,d")
4705         (ior:DI (zero_extend:DI
4706                   (truncate:SI
4707                     (udiv:DI (match_operand:DI 1 "register_operand" "0,0")
4708                              (zero_extend:DI
4709                                (match_operand:SI 2 "nonimmediate_operand" "d,m")))))
4710                 (ashift:DI
4711                   (zero_extend:DI
4712                     (truncate:SI
4713                       (umod:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))
4714                   (const_int 32))))]
4715   "!TARGET_64BIT && TARGET_CPU_ZARCH"
4716   "@
4717    dlr\t%0,%2
4718    dl\t%0,%2"
4719   [(set_attr "op_type"  "RRE,RXY")
4720    (set_attr "type"     "idiv")])
4721
4722 (define_expand "udivsi3"
4723   [(set (match_operand:SI 0 "register_operand" "=d")
4724         (udiv:SI (match_operand:SI 1 "general_operand" "")
4725                  (match_operand:SI 2 "general_operand" "")))
4726    (clobber (match_dup 3))]
4727   "!TARGET_64BIT && !TARGET_CPU_ZARCH"
4728 {
4729   rtx insn, udiv_equal, umod_equal, equal;
4730
4731   udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4732   umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4733   equal = gen_rtx_IOR (DImode,
4734                        gen_rtx_ZERO_EXTEND (DImode, udiv_equal),
4735                        gen_rtx_ASHIFT (DImode,
4736                                        gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4737                                        GEN_INT (32)));
4738
4739   operands[3] = gen_reg_rtx (DImode);
4740
4741   if (CONSTANT_P (operands[2]))
4742     {
4743       if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
4744         {
4745           rtx label1 = gen_label_rtx ();
4746
4747           operands[1] = make_safe_from (operands[1], operands[0]);
4748           emit_move_insn (operands[0], const0_rtx);
4749           emit_insn (gen_cmpsi (operands[1], operands[2]));
4750           emit_jump_insn (gen_bltu (label1));
4751           emit_move_insn (operands[0], const1_rtx);
4752           emit_label (label1);
4753         }
4754       else
4755         {
4756           operands[2] = force_reg (SImode, operands[2]);
4757           operands[2] = make_safe_from (operands[2], operands[0]);
4758
4759           emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4760           insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4761                                              operands[2]));
4762           REG_NOTES (insn) =
4763             gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4764
4765           insn = emit_move_insn (operands[0],
4766                                  gen_lowpart (SImode, operands[3]));
4767           REG_NOTES (insn) =
4768             gen_rtx_EXPR_LIST (REG_EQUAL,
4769                                udiv_equal, REG_NOTES (insn));
4770         }
4771     }
4772   else
4773     {
4774       rtx label1 = gen_label_rtx ();
4775       rtx label2 = gen_label_rtx ();
4776       rtx label3 = gen_label_rtx ();
4777
4778       operands[1] = force_reg (SImode, operands[1]);
4779       operands[1] = make_safe_from (operands[1], operands[0]);
4780       operands[2] = force_reg (SImode, operands[2]);
4781       operands[2] = make_safe_from (operands[2], operands[0]);
4782
4783       emit_move_insn (operands[0], const0_rtx);
4784       emit_insn (gen_cmpsi (operands[2], operands[1]));
4785       emit_jump_insn (gen_bgtu (label3));
4786       emit_insn (gen_cmpsi (operands[2], const1_rtx));
4787       emit_jump_insn (gen_blt (label2));
4788       emit_insn (gen_cmpsi (operands[2], const1_rtx));
4789       emit_jump_insn (gen_beq (label1));
4790       emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4791       insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4792                                          operands[2]));
4793       REG_NOTES (insn) =
4794       gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4795
4796       insn = emit_move_insn (operands[0],
4797                              gen_lowpart (SImode, operands[3]));
4798       REG_NOTES (insn) =
4799       gen_rtx_EXPR_LIST (REG_EQUAL,
4800                                udiv_equal, REG_NOTES (insn));
4801       emit_jump (label3);
4802       emit_label (label1);
4803       emit_move_insn (operands[0], operands[1]);
4804       emit_jump (label3);
4805       emit_label (label2);
4806       emit_move_insn (operands[0], const1_rtx);
4807       emit_label (label3);
4808     }
4809   emit_move_insn (operands[0], operands[0]);
4810   DONE;
4811 })
4812
4813 (define_expand "umodsi3"
4814   [(set (match_operand:SI 0 "register_operand" "=d")
4815         (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
4816                  (match_operand:SI 2 "nonimmediate_operand" "")))
4817    (clobber (match_dup 3))]
4818   "!TARGET_64BIT && !TARGET_CPU_ZARCH"
4819 {
4820   rtx insn, udiv_equal, umod_equal, equal;
4821
4822   udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
4823   umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
4824   equal = gen_rtx_IOR (DImode,
4825                        gen_rtx_ZERO_EXTEND (DImode, udiv_equal),
4826                        gen_rtx_ASHIFT (DImode,
4827                                        gen_rtx_ZERO_EXTEND (DImode, umod_equal),
4828                                        GEN_INT (32)));
4829
4830   operands[3] = gen_reg_rtx (DImode);
4831
4832   if (CONSTANT_P (operands[2]))
4833     {
4834       if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
4835         {
4836           rtx label1 = gen_label_rtx ();
4837
4838           operands[1] = make_safe_from (operands[1], operands[0]);
4839           emit_move_insn (operands[0], operands[1]);
4840           emit_insn (gen_cmpsi (operands[0], operands[2]));
4841           emit_jump_insn (gen_bltu (label1));
4842           emit_insn (gen_abssi2 (operands[0], operands[2]));
4843           emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
4844           emit_label (label1);
4845         }
4846       else
4847         {
4848           operands[2] = force_reg (SImode, operands[2]);
4849           operands[2] = make_safe_from (operands[2], operands[0]);
4850
4851           emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4852           insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4853                                              operands[2]));
4854           REG_NOTES (insn) =
4855             gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4856
4857           insn = emit_move_insn (operands[0],
4858                                  gen_highpart (SImode, operands[3]));
4859           REG_NOTES (insn) =
4860             gen_rtx_EXPR_LIST (REG_EQUAL,
4861                                umod_equal, REG_NOTES (insn));
4862         }
4863     }
4864   else
4865     {
4866       rtx label1 = gen_label_rtx ();
4867       rtx label2 = gen_label_rtx ();
4868       rtx label3 = gen_label_rtx ();
4869
4870       operands[1] = force_reg (SImode, operands[1]);
4871       operands[1] = make_safe_from (operands[1], operands[0]);
4872       operands[2] = force_reg (SImode, operands[2]);
4873       operands[2] = make_safe_from (operands[2], operands[0]);
4874
4875       emit_move_insn(operands[0], operands[1]);
4876       emit_insn (gen_cmpsi (operands[2], operands[1]));
4877       emit_jump_insn (gen_bgtu (label3));
4878       emit_insn (gen_cmpsi (operands[2], const1_rtx));
4879       emit_jump_insn (gen_blt (label2));
4880       emit_insn (gen_cmpsi (operands[2], const1_rtx));
4881       emit_jump_insn (gen_beq (label1));
4882       emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
4883       insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
4884                                          operands[2]));
4885       REG_NOTES (insn) =
4886       gen_rtx_EXPR_LIST (REG_EQUAL, equal, REG_NOTES (insn));
4887
4888       insn = emit_move_insn (operands[0],
4889                              gen_highpart (SImode, operands[3]));
4890       REG_NOTES (insn) =
4891       gen_rtx_EXPR_LIST (REG_EQUAL,
4892                          umod_equal, REG_NOTES (insn));
4893       emit_jump (label3);
4894       emit_label (label1);
4895       emit_move_insn (operands[0], const0_rtx);
4896       emit_jump (label3);
4897       emit_label (label2);
4898       emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
4899       emit_label (label3);
4900     }
4901   DONE;
4902 })
4903
4904 ;
4905 ; divdf3 instruction pattern(s).
4906 ;
4907
4908 (define_expand "divdf3"
4909   [(set (match_operand:DF 0 "register_operand" "=f,f")
4910         (div:DF (match_operand:DF 1 "register_operand" "0,0")
4911                 (match_operand:DF 2 "general_operand" "f,R")))]
4912   "TARGET_HARD_FLOAT"
4913   "")
4914
4915 (define_insn "*divdf3"
4916   [(set (match_operand:DF 0 "register_operand" "=f,f")
4917         (div:DF (match_operand:DF 1 "register_operand" "0,0")
4918                 (match_operand:DF 2 "general_operand" "f,R")))]
4919   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4920   "@
4921    ddbr\t%0,%2
4922    ddb\t%0,%2"
4923   [(set_attr "op_type"  "RRE,RXE")
4924    (set_attr "type"     "fdivd")])
4925
4926 (define_insn "*divdf3_ibm"
4927   [(set (match_operand:DF 0 "register_operand" "=f,f")
4928         (div:DF (match_operand:DF 1 "register_operand" "0,0")
4929                 (match_operand:DF 2 "general_operand" "f,R")))]
4930   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4931   "@
4932    ddr\t%0,%2
4933    dd\t%0,%2"
4934   [(set_attr "op_type"  "RR,RX")
4935    (set_attr "type"     "fdivd")])
4936
4937 ;
4938 ; divsf3 instruction pattern(s).
4939 ;
4940
4941 (define_expand "divsf3"
4942   [(set (match_operand:SF 0 "register_operand" "=f,f")
4943         (div:SF (match_operand:SF 1 "register_operand" "0,0")
4944                 (match_operand:SF 2 "general_operand" "f,R")))]
4945   "TARGET_HARD_FLOAT"
4946   "")
4947
4948 (define_insn "*divsf3"
4949   [(set (match_operand:SF 0 "register_operand" "=f,f")
4950         (div:SF (match_operand:SF 1 "register_operand" "0,0")
4951                 (match_operand:SF 2 "general_operand" "f,R")))]
4952   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
4953   "@
4954    debr\t%0,%2
4955    deb\t%0,%2"
4956   [(set_attr "op_type"  "RRE,RXE")
4957    (set_attr "type"     "fdivs")])
4958
4959 (define_insn "*divsf3"
4960   [(set (match_operand:SF 0 "register_operand" "=f,f")
4961         (div:SF (match_operand:SF 1 "register_operand" "0,0")
4962                 (match_operand:SF 2 "general_operand" "f,R")))]
4963   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
4964   "@
4965    der\t%0,%2
4966    de\t%0,%2"
4967   [(set_attr "op_type"  "RR,RX")
4968    (set_attr "type"     "fdivs")])
4969
4970
4971 ;;
4972 ;;- And instructions.
4973 ;;
4974
4975 ;
4976 ; anddi3 instruction pattern(s).
4977 ;
4978
4979 (define_insn "*anddi3_cc"
4980   [(set (reg 33)
4981         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4982                          (match_operand:DI 2 "general_operand" "d,m"))
4983                  (const_int 0)))
4984    (set (match_operand:DI 0 "register_operand" "=d,d")
4985         (and:DI (match_dup 1) (match_dup 2)))]
4986   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
4987   "@
4988    ngr\t%0,%2
4989    ng\t%0,%2"
4990   [(set_attr "op_type"  "RRE,RXY")])
4991
4992 (define_insn "*anddi3_cconly"
4993   [(set (reg 33)
4994         (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
4995                          (match_operand:DI 2 "general_operand" "d,m"))
4996                  (const_int 0)))
4997    (clobber (match_scratch:DI 0 "=d,d"))]
4998   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
4999   "@
5000    ngr\t%0,%2
5001    ng\t%0,%2"
5002   [(set_attr "op_type"  "RRE,RXY")])
5003
5004 (define_insn "*anddi3_ni"
5005   [(set (match_operand:DI 0 "register_operand" "=d")
5006         (and:DI (match_operand:DI 1 "nonimmediate_operand" "0")
5007                 (match_operand:DI 2 "immediate_operand" "n")))
5008    (clobber (reg:CC 33))]
5009   "TARGET_64BIT && s390_single_hi (operands[2], DImode, -1) >= 0"
5010 {
5011   int part = s390_single_hi (operands[2], DImode, -1);
5012   operands[2] = GEN_INT (s390_extract_hi (operands[2], DImode, part));
5013
5014   switch (part)
5015     {
5016       case 0: return "nihh\t%0,%x2";
5017       case 1: return "nihl\t%0,%x2";
5018       case 2: return "nilh\t%0,%x2";
5019       case 3: return "nill\t%0,%x2";
5020       default: abort ();
5021     }
5022 }
5023   [(set_attr "op_type"  "RI")])
5024
5025 (define_insn "anddi3"
5026   [(set (match_operand:DI 0 "register_operand" "=d,d")
5027         (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5028                 (match_operand:DI 2 "general_operand" "d,m")))
5029    (clobber (reg:CC 33))]
5030   "TARGET_64BIT"
5031   "@
5032    ngr\t%0,%2
5033    ng\t%0,%2"
5034   [(set_attr "op_type"  "RRE,RXY")])
5035
5036 (define_insn "*anddi3_ss"
5037   [(set (match_operand:DI 0 "s_operand" "=Q")
5038         (and:DI (match_dup 0)
5039                 (match_operand:DI 1 "s_imm_operand" "Q")))
5040    (clobber (reg:CC 33))]
5041   ""
5042   "nc\t%O0(8,%R0),%1"
5043   [(set_attr "op_type"  "SS")])
5044
5045 (define_insn "*anddi3_ss_inv"
5046   [(set (match_operand:DI 0 "s_operand" "=Q")
5047         (and:DI (match_operand:DI 1 "s_imm_operand" "Q")
5048                 (match_dup 0)))
5049    (clobber (reg:CC 33))]
5050   ""
5051   "nc\t%O0(8,%R0),%1"
5052   [(set_attr "op_type"  "SS")])
5053
5054 ;
5055 ; andsi3 instruction pattern(s).
5056 ;
5057
5058 (define_insn "*andsi3_cc"
5059   [(set (reg 33)
5060         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5061                          (match_operand:SI 2 "general_operand" "d,R,T"))
5062                  (const_int 0)))
5063    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5064         (and:SI (match_dup 1) (match_dup 2)))]
5065   "s390_match_ccmode(insn, CCTmode)"
5066   "@
5067    nr\t%0,%2
5068    n\t%0,%2
5069    ny\t%0,%2"
5070   [(set_attr "op_type"  "RR,RX,RXY")])
5071
5072 (define_insn "*andsi3_cconly"
5073   [(set (reg 33)
5074         (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5075                          (match_operand:SI 2 "general_operand" "d,R,T"))
5076                  (const_int 0)))
5077    (clobber (match_scratch:SI 0 "=d,d,d"))]
5078   "s390_match_ccmode(insn, CCTmode)"
5079   "@
5080    nr\t%0,%2
5081    n\t%0,%2
5082    ny\t%0,%2"
5083   [(set_attr "op_type"  "RR,RX,RXY")])
5084
5085 (define_insn "*andsi3_ni"
5086   [(set (match_operand:SI 0 "register_operand" "=d")
5087         (and:SI (match_operand:SI 1 "nonimmediate_operand" "0")
5088                 (match_operand:SI 2 "immediate_operand" "n")))
5089    (clobber (reg:CC 33))]
5090   "TARGET_ZARCH && s390_single_hi (operands[2], SImode, -1) >= 0"
5091 {
5092   int part = s390_single_hi (operands[2], SImode, -1);
5093   operands[2] = GEN_INT (s390_extract_hi (operands[2], SImode, part));
5094
5095   switch (part)
5096     {
5097       case 0: return "nilh\t%0,%x2";
5098       case 1: return "nill\t%0,%x2";
5099       default: abort ();
5100     }
5101 }
5102   [(set_attr "op_type"  "RI")])
5103
5104 (define_insn "andsi3"
5105   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
5106         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5107                 (match_operand:SI 2 "general_operand" "d,R,T")))
5108    (clobber (reg:CC 33))]
5109   ""
5110   "@
5111    nr\t%0,%2
5112    n\t%0,%2
5113    ny\t%0,%2"
5114   [(set_attr "op_type"  "RR,RX,RXY")])
5115
5116 (define_insn "*andsi3_ss"
5117   [(set (match_operand:SI 0 "s_operand" "=Q")
5118         (and:SI (match_dup 0)
5119                 (match_operand:SI 1 "s_imm_operand" "Q")))
5120    (clobber (reg:CC 33))]
5121   ""
5122   "nc\t%O0(4,%R0),%1"
5123   [(set_attr "op_type"  "SS")])
5124
5125 (define_insn "*andsi3_ss_inv"
5126   [(set (match_operand:SI 0 "s_operand" "=Q")
5127         (and:SI (match_operand:SI 1 "s_imm_operand" "Q")
5128                 (match_dup 0)))
5129    (clobber (reg:CC 33))]
5130   ""
5131   "nc\t%O0(4,%R0),%1"
5132   [(set_attr "op_type"  "SS")])
5133
5134 ;
5135 ; andhi3 instruction pattern(s).
5136 ;
5137
5138 (define_insn "*andhi3_ni"
5139   [(set (match_operand:HI 0 "register_operand" "=d,d")
5140         (and:HI (match_operand:HI 1 "register_operand" "%0,0")
5141                 (match_operand:HI 2 "nonmemory_operand" "d,n")))
5142    (clobber (reg:CC 33))]
5143   "TARGET_ZARCH"
5144   "@
5145    nr\t%0,%2
5146    nill\t%0,%x2"
5147   [(set_attr "op_type"  "RR,RI")])
5148
5149 (define_insn "andhi3"
5150   [(set (match_operand:HI 0 "register_operand" "=d")
5151         (and:HI (match_operand:HI 1 "register_operand" "%0")
5152                 (match_operand:HI 2 "nonmemory_operand" "d")))
5153    (clobber (reg:CC 33))]
5154   ""
5155   "nr\t%0,%2"
5156   [(set_attr "op_type"  "RR")])
5157
5158 (define_insn "*andhi3_ss"
5159   [(set (match_operand:HI 0 "s_operand" "=Q")
5160         (and:HI (match_dup 0)
5161                 (match_operand:HI 1 "s_imm_operand" "Q")))
5162    (clobber (reg:CC 33))]
5163   ""
5164   "nc\t%O0(2,%R0),%1"
5165   [(set_attr "op_type"  "SS")])
5166
5167 (define_insn "*andhi3_ss_inv"
5168   [(set (match_operand:HI 0 "s_operand" "=Q")
5169         (and:HI (match_operand:HI 1 "s_imm_operand" "Q")
5170                 (match_dup 0)))
5171    (clobber (reg:CC 33))]
5172   ""
5173   "nc\t%O0(2,%R0),%1"
5174   [(set_attr "op_type"  "SS")])
5175
5176 ;
5177 ; andqi3 instruction pattern(s).
5178 ;
5179
5180 (define_insn "*andqi3_ni"
5181   [(set (match_operand:QI 0 "register_operand" "=d,d")
5182         (and:QI (match_operand:QI 1 "register_operand" "%0,0")
5183                 (match_operand:QI 2 "nonmemory_operand" "d,n")))
5184    (clobber (reg:CC 33))]
5185   "TARGET_ZARCH"
5186   "@
5187    nr\t%0,%2
5188    nill\t%0,%b2"
5189   [(set_attr "op_type"  "RR,RI")])
5190
5191 (define_insn "andqi3"
5192   [(set (match_operand:QI 0 "register_operand" "=d")
5193         (and:QI (match_operand:QI 1 "register_operand" "%0")
5194                 (match_operand:QI 2 "nonmemory_operand" "d")))
5195    (clobber (reg:CC 33))]
5196   ""
5197   "nr\t%0,%2"
5198   [(set_attr "op_type"  "RR")])
5199
5200 (define_insn "*andqi3_ss"
5201   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5202         (and:QI (match_dup 0)
5203                 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
5204    (clobber (reg:CC 33))]
5205   ""
5206   "@
5207    ni\t%0,%b1
5208    niy\t%0,%b1
5209    nc\t%O0(1,%R0),%1"
5210   [(set_attr "op_type"  "SI,SIY,SS")])
5211
5212 (define_insn "*andqi3_ss_inv"
5213   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5214         (and:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
5215                 (match_dup 0)))
5216    (clobber (reg:CC 33))]
5217   ""
5218   "@
5219    ni\t%0,%b1
5220    niy\t%0,%b1
5221    nc\t%O0(1,%R0),%1"
5222   [(set_attr "op_type"  "SI,SIY,SS")])
5223
5224
5225 ;;
5226 ;;- Bit set (inclusive or) instructions.
5227 ;;
5228
5229 ;
5230 ; iordi3 instruction pattern(s).
5231 ;
5232
5233 (define_insn "*iordi3_cc"
5234   [(set (reg 33)
5235         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5236                          (match_operand:DI 2 "general_operand" "d,m"))
5237                  (const_int 0)))
5238    (set (match_operand:DI 0 "register_operand" "=d,d")
5239         (ior:DI (match_dup 1) (match_dup 2)))]
5240   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5241   "@
5242    ogr\t%0,%2
5243    og\t%0,%2"
5244   [(set_attr "op_type"  "RRE,RXY")])
5245
5246 (define_insn "*iordi3_cconly"
5247   [(set (reg 33)
5248         (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5249                          (match_operand:DI 2 "general_operand" "d,m"))
5250                  (const_int 0)))
5251    (clobber (match_scratch:DI 0 "=d,d"))]
5252   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5253   "@
5254    ogr\t%0,%2
5255    og\t%0,%2"
5256   [(set_attr "op_type"  "RRE,RXY")])
5257
5258 (define_insn "*iordi3_oi"
5259   [(set (match_operand:DI 0 "register_operand" "=d")
5260         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "0")
5261                 (match_operand:DI 2 "immediate_operand" "n")))
5262    (clobber (reg:CC 33))]
5263   "TARGET_64BIT && s390_single_hi (operands[2], DImode, 0) >= 0"
5264 {
5265   int part = s390_single_hi (operands[2], DImode, 0);
5266   operands[2] = GEN_INT (s390_extract_hi (operands[2], DImode, part));
5267
5268   switch (part)
5269     {
5270       case 0: return "oihh\t%0,%x2";
5271       case 1: return "oihl\t%0,%x2";
5272       case 2: return "oilh\t%0,%x2";
5273       case 3: return "oill\t%0,%x2";
5274       default: abort ();
5275     }
5276 }
5277   [(set_attr "op_type"  "RI")])
5278
5279 (define_insn "iordi3"
5280   [(set (match_operand:DI 0 "register_operand" "=d,d")
5281         (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5282                 (match_operand:DI 2 "general_operand" "d,m")))
5283    (clobber (reg:CC 33))]
5284   "TARGET_64BIT"
5285   "@
5286    ogr\t%0,%2
5287    og\t%0,%2"
5288   [(set_attr "op_type"  "RRE,RXY")])
5289
5290 (define_insn "*iordi3_ss"
5291   [(set (match_operand:DI 0 "s_operand" "=Q")
5292         (ior:DI (match_dup 0)
5293                 (match_operand:DI 1 "s_imm_operand" "Q")))
5294    (clobber (reg:CC 33))]
5295   ""
5296   "oc\t%O0(8,%R0),%1"
5297   [(set_attr "op_type"  "SS")])
5298
5299 (define_insn "*iordi3_ss_inv"
5300   [(set (match_operand:DI 0 "s_operand" "=Q")
5301         (ior:DI (match_operand:DI 1 "s_imm_operand" "Q")
5302                 (match_dup 0)))
5303    (clobber (reg:CC 33))]
5304   ""
5305   "oc\t%O0(8,%R0),%1"
5306   [(set_attr "op_type"  "SS")])
5307
5308 ;
5309 ; iorsi3 instruction pattern(s).
5310 ;
5311
5312 (define_insn "*iorsi3_cc"
5313   [(set (reg 33)
5314         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5315                          (match_operand:SI 2 "general_operand" "d,R,T"))
5316                  (const_int 0)))
5317    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5318         (ior:SI (match_dup 1) (match_dup 2)))]
5319   "s390_match_ccmode(insn, CCTmode)"
5320   "@
5321    or\t%0,%2
5322    o\t%0,%2
5323    oy\t%0,%2"
5324   [(set_attr "op_type"  "RR,RX,RXY")])
5325
5326 (define_insn "*iorsi3_cconly"
5327   [(set (reg 33)
5328         (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5329                          (match_operand:SI 2 "general_operand" "d,R,T"))
5330                  (const_int 0)))
5331    (clobber (match_scratch:SI 0 "=d,d,d"))]
5332   "s390_match_ccmode(insn, CCTmode)"
5333   "@
5334    or\t%0,%2
5335    o\t%0,%2
5336    oy\t%0,%2"
5337   [(set_attr "op_type"  "RR,RX,RXY")])
5338
5339 (define_insn "*iorsi3_oi"
5340   [(set (match_operand:SI 0 "register_operand" "=d")
5341         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "0")
5342                 (match_operand:SI 2 "immediate_operand" "n")))
5343    (clobber (reg:CC 33))]
5344   "TARGET_ZARCH && s390_single_hi (operands[2], SImode, 0) >= 0"
5345 {
5346   int part = s390_single_hi (operands[2], SImode, 0);
5347   operands[2] = GEN_INT (s390_extract_hi (operands[2], SImode, part));
5348
5349   switch (part)
5350     {
5351       case 0: return "oilh\t%0,%x2";
5352       case 1: return "oill\t%0,%x2";
5353       default: abort ();
5354     }
5355 }
5356   [(set_attr "op_type"  "RI")])
5357
5358 (define_insn "iorsi3"
5359   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
5360         (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5361                 (match_operand:SI 2 "general_operand" "d,R,T")))
5362    (clobber (reg:CC 33))]
5363   ""
5364   "@
5365    or\t%0,%2
5366    o\t%0,%2
5367    oy\t%0,%2"
5368   [(set_attr "op_type"  "RR,RX,RXY")])
5369
5370 (define_insn "*iorsi3_ss"
5371   [(set (match_operand:SI 0 "s_operand" "=Q")
5372         (ior:SI (match_dup 0)
5373                 (match_operand:SI 1 "s_imm_operand" "Q")))
5374    (clobber (reg:CC 33))]
5375   ""
5376   "oc\t%O0(4,%R0),%1"
5377   [(set_attr "op_type"  "SS")])
5378
5379 (define_insn "*iorsi3_ss_inv"
5380   [(set (match_operand:SI 0 "s_operand" "=Q")
5381         (ior:SI (match_operand:SI 1 "s_imm_operand" "Q")
5382                 (match_dup 0)))
5383    (clobber (reg:CC 33))]
5384   ""
5385   "oc\t%O0(4,%R0),%1"
5386   [(set_attr "op_type"  "SS")])
5387
5388 ;
5389 ; iorhi3 instruction pattern(s).
5390 ;
5391
5392 (define_insn "*iorhi3_oi"
5393   [(set (match_operand:HI 0 "register_operand" "=d,d")
5394         (ior:HI (match_operand:HI 1 "register_operand" "%0,0")
5395                 (match_operand:HI 2 "nonmemory_operand" "d,n")))
5396    (clobber (reg:CC 33))]
5397   "TARGET_ZARCH"
5398   "@
5399    or\t%0,%2
5400    oill\t%0,%x2"
5401   [(set_attr "op_type"  "RR,RI")])
5402
5403 (define_insn "iorhi3"
5404   [(set (match_operand:HI 0 "register_operand" "=d")
5405         (ior:HI (match_operand:HI 1 "register_operand" "%0")
5406                 (match_operand:HI 2 "nonmemory_operand" "d")))
5407    (clobber (reg:CC 33))]
5408   ""
5409   "or\t%0,%2"
5410   [(set_attr "op_type"  "RR")])
5411
5412 (define_insn "*iorhi3_ss"
5413   [(set (match_operand:HI 0 "s_operand" "=Q")
5414         (ior:HI (match_dup 0)
5415                 (match_operand:HI 1 "s_imm_operand" "Q")))
5416    (clobber (reg:CC 33))]
5417   ""
5418   "oc\t%O0(2,%R0),%1"
5419   [(set_attr "op_type"  "SS")])
5420
5421 (define_insn "*iorhi3_ss_inv"
5422   [(set (match_operand:HI 0 "s_operand" "=Q")
5423         (ior:HI (match_operand:HI 1 "s_imm_operand" "Q")
5424                 (match_dup 0)))
5425    (clobber (reg:CC 33))]
5426   ""
5427   "oc\t%O0(2,%R0),%1"
5428   [(set_attr "op_type"  "SS")])
5429
5430 ;
5431 ; iorqi3 instruction pattern(s).
5432 ;
5433
5434 (define_insn "*iorqi3_oi"
5435   [(set (match_operand:QI 0 "register_operand" "=d,d")
5436         (ior:QI (match_operand:QI 1 "register_operand" "%0,0")
5437                 (match_operand:QI 2 "nonmemory_operand" "d,n")))
5438    (clobber (reg:CC 33))]
5439   "TARGET_ZARCH"
5440   "@
5441    or\t%0,%2
5442    oill\t%0,%b2"
5443   [(set_attr "op_type"  "RR,RI")])
5444
5445 (define_insn "iorqi3"
5446   [(set (match_operand:QI 0 "register_operand" "=d")
5447         (ior:QI (match_operand:QI 1 "register_operand" "%0")
5448                 (match_operand:QI 2 "nonmemory_operand" "d")))
5449    (clobber (reg:CC 33))]
5450   ""
5451   "or\t%0,%2"
5452   [(set_attr "op_type"  "RR")])
5453
5454 (define_insn "*iorqi3_ss"
5455   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5456         (ior:QI (match_dup 0)
5457                 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
5458    (clobber (reg:CC 33))]
5459   ""
5460   "@
5461    oi\t%0,%b1
5462    oiy\t%0,%b1
5463    oc\t%O0(1,%R0),%1"
5464   [(set_attr "op_type"  "SI,SIY,SS")])
5465
5466 (define_insn "*iorqi3_ss_inv"
5467   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5468         (ior:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
5469                 (match_dup 0)))
5470    (clobber (reg:CC 33))]
5471   ""
5472   "@
5473    oi\t%0,%b1
5474    oiy\t%0,%b1
5475    oc\t%O0(1,%R0),%1"
5476   [(set_attr "op_type"  "SI,SIY,SS")])
5477
5478
5479 ;;
5480 ;;- Xor instructions.
5481 ;;
5482
5483 ;
5484 ; xordi3 instruction pattern(s).
5485 ;
5486
5487 (define_insn "*xordi3_cc"
5488   [(set (reg 33)
5489         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5490                          (match_operand:DI 2 "general_operand" "d,m"))
5491                  (const_int 0)))
5492    (set (match_operand:DI 0 "register_operand" "=d,d")
5493         (xor:DI (match_dup 1) (match_dup 2)))]
5494   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5495   "@
5496    xgr\t%0,%2
5497    xg\t%0,%2"
5498   [(set_attr "op_type"  "RRE,RXY")])
5499
5500 (define_insn "*xordi3_cconly"
5501   [(set (reg 33)
5502         (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5503                          (match_operand:DI 2 "general_operand" "d,m"))
5504                  (const_int 0)))
5505    (clobber (match_scratch:DI 0 "=d,d"))]
5506   "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5507   "@
5508    xgr\t%0,%2
5509    xr\t%0,%2"
5510   [(set_attr "op_type"  "RRE,RXY")])
5511
5512 (define_insn "xordi3"
5513   [(set (match_operand:DI 0 "register_operand" "=d,d")
5514         (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5515                 (match_operand:DI 2 "general_operand" "d,m")))
5516    (clobber (reg:CC 33))]
5517   "TARGET_64BIT"
5518   "@
5519    xgr\t%0,%2
5520    xg\t%0,%2"
5521   [(set_attr "op_type"  "RRE,RXY")])
5522
5523 (define_insn "*xordi3_ss"
5524   [(set (match_operand:DI 0 "s_operand" "=Q")
5525         (xor:DI (match_dup 0)
5526                 (match_operand:DI 1 "s_imm_operand" "Q")))
5527    (clobber (reg:CC 33))]
5528   ""
5529   "xc\t%O0(8,%R0),%1"
5530   [(set_attr "op_type"  "SS")])
5531
5532 (define_insn "*xordi3_ss_inv"
5533   [(set (match_operand:DI 0 "s_operand" "=Q")
5534         (xor:DI (match_operand:DI 1 "s_imm_operand" "Q")
5535                 (match_dup 0)))
5536    (clobber (reg:CC 33))]
5537   ""
5538   "xc\t%O0(8,%R0),%1"
5539   [(set_attr "op_type"  "SS")])
5540
5541 ;
5542 ; xorsi3 instruction pattern(s).
5543 ;
5544
5545 (define_insn "*xorsi3_cc"
5546   [(set (reg 33)
5547         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5548                          (match_operand:SI 2 "general_operand" "d,R,T"))
5549                  (const_int 0)))
5550    (set (match_operand:SI 0 "register_operand" "=d,d,d")
5551         (xor:SI (match_dup 1) (match_dup 2)))]
5552   "s390_match_ccmode(insn, CCTmode)"
5553   "@
5554    xr\t%0,%2
5555    x\t%0,%2
5556    xy\t%0,%2"
5557   [(set_attr "op_type"  "RR,RX,RXY")])
5558
5559 (define_insn "*xorsi3_cconly"
5560   [(set (reg 33)
5561         (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5562                          (match_operand:SI 2 "general_operand" "d,R,T"))
5563                  (const_int 0)))
5564    (clobber (match_scratch:SI 0 "=d,d,d"))]
5565   "s390_match_ccmode(insn, CCTmode)"
5566   "@
5567    xr\t%0,%2
5568    x\t%0,%2
5569    xy\t%0,%2"
5570   [(set_attr "op_type"  "RR,RX,RXY")])
5571
5572 (define_insn "xorsi3"
5573   [(set (match_operand:SI 0 "register_operand" "=d,d,d")
5574         (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0")
5575                 (match_operand:SI 2 "general_operand" "d,R,T")))
5576    (clobber (reg:CC 33))]
5577   ""
5578   "@
5579    xr\t%0,%2
5580    x\t%0,%2
5581    xy\t%0,%2"
5582   [(set_attr "op_type"  "RR,RX,RXY")])
5583
5584 (define_insn "*xorsi3_ss"
5585   [(set (match_operand:SI 0 "s_operand" "=Q")
5586         (xor:SI (match_dup 0)
5587                 (match_operand:SI 1 "s_imm_operand" "Q")))
5588    (clobber (reg:CC 33))]
5589   ""
5590   "xc\t%O0(4,%R0),%1"
5591   [(set_attr "op_type"  "SS")])
5592
5593 (define_insn "*xorsi3_ss_inv"
5594   [(set (match_operand:SI 0 "s_operand" "=Q")
5595         (xor:SI (match_operand:SI 1 "s_imm_operand" "Q")
5596                 (match_dup 0)))
5597    (clobber (reg:CC 33))]
5598   ""
5599   "xc\t%O0(4,%R0),%1"
5600   [(set_attr "op_type"  "SS")])
5601
5602 ;
5603 ; xorhi3 instruction pattern(s).
5604 ;
5605
5606 (define_insn "xorhi3"
5607   [(set (match_operand:HI 0 "register_operand" "=d")
5608         (xor:HI (match_operand:HI 1 "register_operand" "%0")
5609                 (match_operand:HI 2 "nonmemory_operand" "d")))
5610    (clobber (reg:CC 33))]
5611   ""
5612   "xr\t%0,%2"
5613   [(set_attr "op_type"  "RR")])
5614
5615 (define_insn "*xorhi3_ss"
5616   [(set (match_operand:HI 0 "s_operand" "=Q")
5617         (xor:HI (match_dup 0)
5618                 (match_operand:HI 1 "s_imm_operand" "Q")))
5619    (clobber (reg:CC 33))]
5620   ""
5621   "xc\t%O0(2,%R0),%1"
5622   [(set_attr "op_type"  "SS")])
5623
5624 (define_insn "*xorhi3_ss_inv"
5625   [(set (match_operand:HI 0 "s_operand" "=Q")
5626         (xor:HI (match_operand:HI 1 "s_imm_operand" "Q")
5627                 (match_dup 0)))
5628    (clobber (reg:CC 33))]
5629   ""
5630   "xc\t%O0(2,%R0),%1"
5631   [(set_attr "op_type"  "SS")])
5632
5633 ;
5634 ; xorqi3 instruction pattern(s).
5635 ;
5636
5637 (define_insn "xorqi3"
5638   [(set (match_operand:QI 0 "register_operand" "=d")
5639         (xor:QI (match_operand:QI 1 "register_operand" "%0")
5640                 (match_operand:QI 2 "nonmemory_operand" "d")))
5641    (clobber (reg:CC 33))]
5642   ""
5643   "xr\t%0,%2"
5644   [(set_attr "op_type"  "RR")])
5645
5646 (define_insn "*xorqi3_ss"
5647   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5648         (xor:QI (match_dup 0)
5649                 (match_operand:QI 1 "s_imm_operand" "n,n,Q")))
5650    (clobber (reg:CC 33))]
5651   ""
5652   "@
5653    xi\t%0,%b1
5654    xiy\t%0,%b1
5655    xc\t%O0(1,%R0),%1"
5656   [(set_attr "op_type"  "SI,SIY,SS")])
5657
5658 (define_insn "*xorqi3_ss_inv"
5659   [(set (match_operand:QI 0 "s_operand" "=Q,S,Q")
5660         (xor:QI (match_operand:QI 1 "s_imm_operand" "n,n,Q")
5661                 (match_dup 0)))
5662    (clobber (reg:CC 33))]
5663   ""
5664   "@
5665    xi\t%0,%b1
5666    xiy\t%0,%b1
5667    xc\t%O0(1,%R0),%1"
5668   [(set_attr "op_type"  "SI,SIY,SS")])
5669
5670
5671 ;;
5672 ;;- Negate instructions.
5673 ;;
5674
5675 ;
5676 ; negdi2 instruction pattern(s).
5677 ;
5678
5679 (define_expand "negdi2"
5680   [(parallel
5681     [(set (match_operand:DI 0 "register_operand" "=d")
5682           (neg:DI (match_operand:DI 1 "register_operand" "d")))
5683      (clobber (reg:CC 33))])]
5684   ""
5685   "")
5686
5687 (define_insn "*negdi2_64"
5688   [(set (match_operand:DI 0 "register_operand" "=d")
5689         (neg:DI (match_operand:DI 1 "register_operand" "d")))
5690    (clobber (reg:CC 33))]
5691   "TARGET_64BIT"
5692   "lcgr\t%0,%1"
5693   [(set_attr "op_type"  "RR")])
5694
5695 (define_insn "*negdi2_31"
5696   [(set (match_operand:DI 0 "register_operand" "=d")
5697         (neg:DI (match_operand:DI 1 "register_operand" "d")))
5698    (clobber (reg:CC 33))]
5699   "!TARGET_64BIT"
5700 {
5701   rtx xop[1];
5702   xop[0] = gen_label_rtx ();
5703   output_asm_insn ("lcr\t%0,%1", operands);
5704   output_asm_insn ("lcr\t%N0,%N1", operands);
5705   output_asm_insn ("je\t%l0", xop);
5706   output_asm_insn ("bctr\t%0,0", operands);
5707   targetm.asm_out.internal_label (asm_out_file, "L",
5708                              CODE_LABEL_NUMBER (xop[0]));
5709   return "";
5710 }
5711   [(set_attr "op_type"  "NN")
5712    (set_attr "type"     "other")
5713    (set_attr "length"   "10")])
5714
5715 ;
5716 ; negsi2 instruction pattern(s).
5717 ;
5718
5719 (define_insn "negsi2"
5720   [(set (match_operand:SI 0 "register_operand" "=d")
5721         (neg:SI (match_operand:SI 1 "register_operand" "d")))
5722    (clobber (reg:CC 33))]
5723   ""
5724   "lcr\t%0,%1"
5725   [(set_attr "op_type"  "RR")])
5726
5727 ;
5728 ; negdf2 instruction pattern(s).
5729 ;
5730
5731 (define_expand "negdf2"
5732   [(parallel
5733     [(set (match_operand:DF 0 "register_operand" "=f")
5734           (neg:DF (match_operand:DF 1 "register_operand" "f")))
5735      (clobber (reg:CC 33))])]
5736   "TARGET_HARD_FLOAT"
5737   "")
5738
5739 (define_insn "*negdf2"
5740   [(set (match_operand:DF 0 "register_operand" "=f")
5741         (neg:DF (match_operand:DF 1 "register_operand" "f")))
5742    (clobber (reg:CC 33))]
5743   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5744   "lcdbr\t%0,%1"
5745   [(set_attr "op_type"  "RRE")
5746    (set_attr "type"     "fsimpd")])
5747
5748 (define_insn "*negdf2_ibm"
5749   [(set (match_operand:DF 0 "register_operand" "=f")
5750         (neg:DF (match_operand:DF 1 "register_operand" "f")))
5751    (clobber (reg:CC 33))]
5752   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5753   "lcdr\t%0,%1"
5754   [(set_attr "op_type"  "RR")
5755    (set_attr "type"     "fsimpd")])
5756
5757 ;
5758 ; negsf2 instruction pattern(s).
5759 ;
5760
5761 (define_expand "negsf2"
5762   [(parallel
5763     [(set (match_operand:SF 0 "register_operand" "=f")
5764           (neg:SF (match_operand:SF 1 "register_operand" "f")))
5765      (clobber (reg:CC 33))])]
5766   "TARGET_HARD_FLOAT"
5767   "")
5768
5769 (define_insn "*negsf2"
5770   [(set (match_operand:SF 0 "register_operand" "=f")
5771         (neg:SF (match_operand:SF 1 "register_operand" "f")))
5772    (clobber (reg:CC 33))]
5773   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5774   "lcebr\t%0,%1"
5775   [(set_attr "op_type"  "RRE")
5776    (set_attr "type"     "fsimps")])
5777
5778 (define_insn "*negsf2"
5779   [(set (match_operand:SF 0 "register_operand" "=f")
5780         (neg:SF (match_operand:SF 1 "register_operand" "f")))
5781    (clobber (reg:CC 33))]
5782   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5783   "lcer\t%0,%1"
5784   [(set_attr "op_type"  "RR")
5785    (set_attr "type"     "fsimps")])
5786
5787
5788 ;;
5789 ;;- Absolute value instructions.
5790 ;;
5791
5792 ;
5793 ; absdi2 instruction pattern(s).
5794 ;
5795
5796 (define_insn "absdi2"
5797   [(set (match_operand:DI 0 "register_operand" "=d")
5798         (abs:DI (match_operand:DI 1 "register_operand" "d")))
5799    (clobber (reg:CC 33))]
5800   "TARGET_64BIT"
5801   "lpgr\t%0,%1"
5802   [(set_attr "op_type"  "RRE")])
5803
5804 ;
5805 ; abssi2 instruction pattern(s).
5806 ;
5807
5808 (define_insn "abssi2"
5809   [(set (match_operand:SI 0 "register_operand" "=d")
5810         (abs:SI (match_operand:SI 1 "register_operand" "d")))
5811    (clobber (reg:CC 33))]
5812   ""
5813   "lpr\t%0,%1"
5814   [(set_attr "op_type"  "RR")])
5815
5816 ;
5817 ; absdf2 instruction pattern(s).
5818 ;
5819
5820 (define_expand "absdf2"
5821   [(parallel
5822     [(set (match_operand:DF 0 "register_operand" "=f")
5823           (abs:DF (match_operand:DF 1 "register_operand" "f")))
5824      (clobber (reg:CC 33))])]
5825   "TARGET_HARD_FLOAT"
5826   "")
5827
5828 (define_insn "*absdf2"
5829   [(set (match_operand:DF 0 "register_operand" "=f")
5830         (abs:DF (match_operand:DF 1 "register_operand" "f")))
5831    (clobber (reg:CC 33))]
5832   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5833   "lpdbr\t%0,%1"
5834   [(set_attr "op_type"  "RRE")
5835    (set_attr "type"     "fsimpd")])
5836
5837 (define_insn "*absdf2_ibm"
5838   [(set (match_operand:DF 0 "register_operand" "=f")
5839         (abs:DF (match_operand:DF 1 "register_operand" "f")))
5840    (clobber (reg:CC 33))]
5841   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5842   "lpdr\t%0,%1"
5843   [(set_attr "op_type"  "RR")
5844    (set_attr "type"     "fsimpd")])
5845
5846 ;
5847 ; abssf2 instruction pattern(s).
5848 ;
5849
5850 (define_expand "abssf2"
5851   [(parallel
5852     [(set (match_operand:SF 0 "register_operand" "=f")
5853           (abs:SF (match_operand:SF 1 "register_operand" "f")))
5854      (clobber (reg:CC 33))])]
5855   "TARGET_HARD_FLOAT"
5856   "")
5857
5858 (define_insn "*abssf2"
5859   [(set (match_operand:SF 0 "register_operand" "=f")
5860         (abs:SF (match_operand:SF 1 "register_operand" "f")))
5861    (clobber (reg:CC 33))]
5862   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5863   "lpebr\t%0,%1"
5864   [(set_attr "op_type"  "RRE")
5865    (set_attr "type"     "fsimps")])
5866
5867 (define_insn "*abssf2_ibm"
5868   [(set (match_operand:SF 0 "register_operand" "=f")
5869         (abs:SF (match_operand:SF 1 "register_operand" "f")))
5870    (clobber (reg:CC 33))]
5871   "TARGET_HARD_FLOAT && TARGET_IBM_FLOAT"
5872   "lper\t%0,%1"
5873   [(set_attr "op_type"  "RR")
5874    (set_attr "type"     "fsimps")])
5875
5876 ;;
5877 ;;- Negated absolute value instructions
5878 ;;
5879
5880 ;
5881 ; Integer
5882 ;
5883
5884 (define_insn "*negabssi2"
5885   [(set (match_operand:SI 0 "register_operand" "=d")
5886         (neg:SI (abs:SI (match_operand:SI 1 "register_operand" "d"))))
5887    (clobber (reg:CC 33))]
5888   ""
5889   "lnr\t%0,%1"
5890   [(set_attr "op_type" "RR")])
5891
5892 (define_insn "*negabsdi2"
5893   [(set (match_operand:DI 0 "register_operand" "=d")
5894         (neg:DI (abs:DI (match_operand:DI 1 "register_operand" "d"))))
5895    (clobber (reg:CC 33))]
5896   "TARGET_64BIT"
5897   "lngr\t%0,%1"
5898   [(set_attr "op_type" "RRE")])
5899
5900 ;
5901 ; Floating point
5902 ;
5903
5904 (define_insn "*negabssf2"
5905   [(set (match_operand:SF 0 "register_operand" "=f")
5906         (neg:SF (abs:SF (match_operand:SF 1 "register_operand" "f"))))
5907    (clobber (reg:CC 33))]
5908   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5909   "lnebr\t%0,%1"
5910   [(set_attr "op_type"  "RRE")
5911    (set_attr "type"     "fsimps")])
5912
5913 (define_insn "*negabsdf2"
5914   [(set (match_operand:DF 0 "register_operand" "=f")
5915         (neg:DF (abs:DF (match_operand:DF 1 "register_operand" "f"))))
5916    (clobber (reg:CC 33))]
5917   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5918   "lndbr\t%0,%1"
5919   [(set_attr "op_type"  "RRE")
5920    (set_attr "type"     "fsimpd")])
5921
5922 ;;
5923 ;;- Square root instructions.
5924 ;;
5925
5926 ;
5927 ; sqrtdf2 instruction pattern(s).
5928 ;
5929
5930 (define_insn "sqrtdf2"
5931   [(set (match_operand:DF 0 "register_operand" "=f,f")
5932         (sqrt:DF (match_operand:DF 1 "general_operand" "f,R")))]
5933   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5934   "@
5935    sqdbr\t%0,%1
5936    sqdb\t%0,%1"
5937   [(set_attr "op_type"  "RRE,RXE")])
5938
5939 ;
5940 ; sqrtsf2 instruction pattern(s).
5941 ;
5942
5943 (define_insn "sqrtsf2"
5944   [(set (match_operand:SF 0 "register_operand" "=f,f")
5945         (sqrt:SF (match_operand:SF 1 "general_operand" "f,R")))]
5946   "TARGET_HARD_FLOAT && TARGET_IEEE_FLOAT"
5947   "@
5948    sqebr\t%0,%1
5949    sqeb\t%0,%1"
5950   [(set_attr "op_type"  "RRE,RXE")])
5951
5952 ;;
5953 ;;- One complement instructions.
5954 ;;
5955
5956 ;
5957 ; one_cmpldi2 instruction pattern(s).
5958 ;
5959
5960 (define_expand "one_cmpldi2"
5961   [(parallel
5962     [(set (match_operand:DI 0 "register_operand" "")
5963           (xor:DI (match_operand:DI 1 "register_operand" "")
5964                   (const_int -1)))
5965      (clobber (reg:CC 33))])]
5966   "TARGET_64BIT"
5967   "")
5968
5969 ;
5970 ; one_cmplsi2 instruction pattern(s).
5971 ;
5972
5973 (define_expand "one_cmplsi2"
5974   [(parallel
5975     [(set (match_operand:SI 0 "register_operand" "")
5976           (xor:SI (match_operand:SI 1 "register_operand" "")
5977                   (const_int -1)))
5978      (clobber (reg:CC 33))])]
5979   ""
5980   "")
5981
5982 ;
5983 ; one_cmplhi2 instruction pattern(s).
5984 ;
5985
5986 (define_expand "one_cmplhi2"
5987   [(parallel
5988     [(set (match_operand:HI 0 "register_operand" "")
5989           (xor:HI (match_operand:HI 1 "register_operand" "")
5990                   (const_int -1)))
5991      (clobber (reg:CC 33))])]
5992   ""
5993   "")
5994
5995 ;
5996 ; one_cmplqi2 instruction pattern(s).
5997 ;
5998
5999 (define_expand "one_cmplqi2"
6000   [(parallel
6001     [(set (match_operand:QI 0 "register_operand" "")
6002           (xor:QI (match_operand:QI 1 "register_operand" "")
6003                   (const_int -1)))
6004      (clobber (reg:CC 33))])]
6005   ""
6006   "")
6007
6008
6009 ;;
6010 ;;- Rotate instructions.
6011 ;;
6012
6013 ;
6014 ; rotldi3 instruction pattern(s).
6015 ;
6016
6017 (define_insn "rotldi3"
6018   [(set (match_operand:DI 0 "register_operand" "=d")
6019         (rotate:DI (match_operand:DI 1 "register_operand" "d")
6020                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6021   "TARGET_64BIT"
6022   "rllg\t%0,%1,%Y2"
6023   [(set_attr "op_type"  "RSE")
6024    (set_attr "atype"    "reg")])
6025
6026 ;
6027 ; rotlsi3 instruction pattern(s).
6028 ;
6029
6030 (define_insn "rotlsi3"
6031   [(set (match_operand:SI 0 "register_operand" "=d")
6032         (rotate:SI (match_operand:SI 1 "register_operand" "d")
6033                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6034   "TARGET_CPU_ZARCH"
6035   "rll\t%0,%1,%Y2"
6036   [(set_attr "op_type"  "RSE")
6037    (set_attr "atype"    "reg")])
6038
6039
6040 ;;
6041 ;;- Arithmetic shift instructions.
6042 ;;
6043
6044 ;
6045 ; ashldi3 instruction pattern(s).
6046 ;
6047
6048 (define_expand "ashldi3"
6049   [(set (match_operand:DI 0 "register_operand" "")
6050         (ashift:DI (match_operand:DI 1 "register_operand" "")
6051                    (match_operand:SI 2 "shift_count_operand" "")))]
6052   ""
6053   "")
6054
6055 (define_insn "*ashldi3_31"
6056   [(set (match_operand:DI 0 "register_operand" "=d")
6057         (ashift:DI (match_operand:DI 1 "register_operand" "0")
6058                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6059   "!TARGET_64BIT"
6060   "sldl\t%0,%Y2"
6061   [(set_attr "op_type"  "RS")
6062    (set_attr "atype"    "reg")])
6063
6064 (define_insn "*ashldi3_64"
6065   [(set (match_operand:DI 0 "register_operand" "=d")
6066         (ashift:DI (match_operand:DI 1 "register_operand" "d")
6067                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6068   "TARGET_64BIT"
6069   "sllg\t%0,%1,%Y2"
6070   [(set_attr "op_type"  "RSE")
6071    (set_attr "atype"    "reg")])
6072
6073 ;
6074 ; ashrdi3 instruction pattern(s).
6075 ;
6076
6077 (define_expand "ashrdi3"
6078   [(parallel
6079     [(set (match_operand:DI 0 "register_operand" "")
6080           (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
6081                        (match_operand:SI 2 "shift_count_operand" "")))
6082      (clobber (reg:CC 33))])]
6083   ""
6084   "")
6085
6086 (define_insn "*ashrdi3_cc_31"
6087   [(set (reg 33)
6088         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6089                               (match_operand:SI 2 "shift_count_operand" "Y"))
6090                  (const_int 0)))
6091    (set (match_operand:DI 0 "register_operand" "=d")
6092         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6093   "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6094   "srda\t%0,%Y2"
6095   [(set_attr "op_type"  "RS")
6096    (set_attr "atype"    "reg")])
6097
6098 (define_insn "*ashrdi3_cconly_31"
6099   [(set (reg 33)
6100         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6101                               (match_operand:SI 2 "shift_count_operand" "Y"))
6102                  (const_int 0)))
6103    (clobber (match_scratch:DI 0 "=d"))]
6104   "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
6105   "srda\t%0,%Y2"
6106   [(set_attr "op_type"  "RS")
6107    (set_attr "atype"    "reg")])
6108
6109 (define_insn "*ashrdi3_31"
6110   [(set (match_operand:DI 0 "register_operand" "=d")
6111         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
6112                      (match_operand:SI 2 "shift_count_operand" "Y")))
6113    (clobber (reg:CC 33))]
6114   "!TARGET_64BIT"
6115   "srda\t%0,%Y2"
6116   [(set_attr "op_type"  "RS")
6117    (set_attr "atype"    "reg")])
6118
6119 (define_insn "*ashrdi3_cc_64"
6120   [(set (reg 33)
6121         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6122                               (match_operand:SI 2 "shift_count_operand" "Y"))
6123                  (const_int 0)))
6124    (set (match_operand:DI 0 "register_operand" "=d")
6125         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
6126   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
6127   "srag\t%0,%1,%Y2"
6128   [(set_attr "op_type"  "RSE")
6129    (set_attr "atype"    "reg")])
6130
6131 (define_insn "*ashrdi3_cconly_64"
6132   [(set (reg 33)
6133         (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6134                               (match_operand:SI 2 "shift_count_operand" "Y"))
6135                  (const_int 0)))
6136    (clobber (match_scratch:DI 0 "=d"))]
6137   "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
6138   "srag\t%0,%1,%Y2"
6139   [(set_attr "op_type"  "RSE")
6140    (set_attr "atype"    "reg")])
6141
6142 (define_insn "*ashrdi3_64"
6143   [(set (match_operand:DI 0 "register_operand" "=d")
6144         (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
6145                      (match_operand:SI 2 "shift_count_operand" "Y")))
6146    (clobber (reg:CC 33))]
6147   "TARGET_64BIT"
6148   "srag\t%0,%1,%Y2"
6149   [(set_attr "op_type"  "RSE")
6150    (set_attr "atype"    "reg")])
6151
6152
6153 ;
6154 ; ashlsi3 instruction pattern(s).
6155 ;
6156
6157 (define_insn "ashlsi3"
6158   [(set (match_operand:SI 0 "register_operand" "=d")
6159         (ashift:SI (match_operand:SI 1 "register_operand" "0")
6160                    (match_operand:SI 2 "shift_count_operand" "Y")))]
6161   ""
6162   "sll\t%0,%Y2"
6163   [(set_attr "op_type"  "RS")
6164    (set_attr "atype"    "reg")])
6165
6166 ;
6167 ; ashrsi3 instruction pattern(s).
6168 ;
6169
6170 (define_insn "*ashrsi3_cc"
6171   [(set (reg 33)
6172         (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6173                               (match_operand:SI 2 "shift_count_operand" "Y"))
6174                  (const_int 0)))
6175    (set (match_operand:SI 0 "register_operand" "=d")
6176         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
6177   "s390_match_ccmode(insn, CCSmode)"
6178   "sra\t%0,%Y2"
6179   [(set_attr "op_type"  "RS")
6180    (set_attr "atype"    "reg")])
6181
6182
6183 (define_insn "*ashrsi3_cconly"
6184   [(set (reg 33)
6185         (compare (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6186                               (match_operand:SI 2 "shift_count_operand" "Y"))
6187                  (const_int 0)))
6188    (clobber (match_scratch:SI 0 "=d"))]
6189   "s390_match_ccmode(insn, CCSmode)"
6190   "sra\t%0,%Y2"
6191   [(set_attr "op_type"  "RS")
6192    (set_attr "atype"    "reg")])
6193
6194 (define_insn "ashrsi3"
6195   [(set (match_operand:SI 0 "register_operand" "=d")
6196         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
6197                      (match_operand:SI 2 "shift_count_operand" "Y")))
6198    (clobber (reg:CC 33))]
6199   ""
6200   "sra\t%0,%Y2"
6201   [(set_attr "op_type"  "RS")
6202    (set_attr "atype"    "reg")])
6203
6204
6205 ;;
6206 ;;- logical shift instructions.
6207 ;;
6208
6209 ;
6210 ; lshrdi3 instruction pattern(s).
6211 ;
6212
6213 (define_expand "lshrdi3"
6214   [(set (match_operand:DI 0 "register_operand" "")
6215         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
6216                      (match_operand:SI 2 "shift_count_operand" "")))]
6217   ""
6218   "")
6219
6220 (define_insn "*lshrdi3_31"
6221   [(set (match_operand:DI 0 "register_operand" "=d")
6222         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
6223                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6224   "!TARGET_64BIT"
6225   "srdl\t%0,%Y2"
6226    [(set_attr "op_type"  "RS")
6227     (set_attr "atype"    "reg")])
6228
6229 (define_insn "*lshrdi3_64"
6230   [(set (match_operand:DI 0 "register_operand" "=d")
6231         (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
6232                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6233   "TARGET_64BIT"
6234   "srlg\t%0,%1,%Y2"
6235   [(set_attr "op_type"  "RSE")
6236    (set_attr "atype"    "reg")])
6237
6238 ;
6239 ; lshrsi3 instruction pattern(s).
6240 ;
6241
6242 (define_insn "lshrsi3"
6243   [(set (match_operand:SI 0 "register_operand" "=d")
6244         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
6245                      (match_operand:SI 2 "shift_count_operand" "Y")))]
6246   ""
6247   "srl\t%0,%Y2"
6248   [(set_attr "op_type"  "RS")
6249    (set_attr "atype"    "reg")])
6250
6251
6252 ;;
6253 ;; Branch instruction patterns.
6254 ;;
6255
6256 (define_expand "beq"
6257   [(set (reg:CCZ 33) (compare:CCZ (match_dup 1) (match_dup 2)))
6258    (set (pc)
6259         (if_then_else (eq (reg:CCZ 33) (const_int 0))
6260                       (label_ref (match_operand 0 "" ""))
6261                       (pc)))]
6262   ""
6263   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6264
6265 (define_expand "bne"
6266   [(set (reg:CCZ 33) (compare:CCZ (match_dup 1) (match_dup 2)))
6267    (set (pc)
6268         (if_then_else (ne (reg:CCZ 33) (const_int 0))
6269                       (label_ref (match_operand 0 "" ""))
6270                       (pc)))]
6271   ""
6272   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6273
6274 (define_expand "bgt"
6275   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6276    (set (pc)
6277         (if_then_else (gt (reg:CCS 33) (const_int 0))
6278                       (label_ref (match_operand 0 "" ""))
6279                       (pc)))]
6280   ""
6281   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6282
6283 (define_expand "bgtu"
6284   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6285    (set (pc)
6286         (if_then_else (gtu (reg:CCU 33) (const_int 0))
6287                       (label_ref (match_operand 0 "" ""))
6288                       (pc)))]
6289   ""
6290   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6291
6292 (define_expand "blt"
6293   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6294    (set (pc)
6295         (if_then_else (lt (reg:CCS 33) (const_int 0))
6296                       (label_ref (match_operand 0 "" ""))
6297                       (pc)))]
6298   ""
6299   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6300
6301 (define_expand "bltu"
6302   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6303    (set (pc)
6304         (if_then_else (ltu (reg:CCU 33) (const_int 0))
6305                       (label_ref (match_operand 0 "" ""))
6306                       (pc)))]
6307   ""
6308   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6309
6310 (define_expand "bge"
6311   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6312    (set (pc)
6313         (if_then_else (ge (reg:CCS 33) (const_int 0))
6314                       (label_ref (match_operand 0 "" ""))
6315                       (pc)))]
6316   ""
6317   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6318
6319 (define_expand "bgeu"
6320   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6321    (set (pc)
6322         (if_then_else (geu (reg:CCU 33) (const_int 0))
6323                       (label_ref (match_operand 0 "" ""))
6324                       (pc)))]
6325   ""
6326   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6327
6328 (define_expand "ble"
6329   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6330    (set (pc)
6331         (if_then_else (le (reg:CCS 33) (const_int 0))
6332                       (label_ref (match_operand 0 "" ""))
6333                       (pc)))]
6334   ""
6335   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6336
6337 (define_expand "bleu"
6338   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
6339    (set (pc)
6340         (if_then_else (leu (reg:CCU 33) (const_int 0))
6341                       (label_ref (match_operand 0 "" ""))
6342                       (pc)))]
6343   ""
6344   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6345
6346 (define_expand "bunordered"
6347   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6348    (set (pc)
6349         (if_then_else (unordered (reg:CCS 33) (const_int 0))
6350                       (label_ref (match_operand 0 "" ""))
6351                       (pc)))]
6352   ""
6353   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6354
6355 (define_expand "bordered"
6356   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6357    (set (pc)
6358         (if_then_else (ordered (reg:CCS 33) (const_int 0))
6359                       (label_ref (match_operand 0 "" ""))
6360                       (pc)))]
6361   ""
6362   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6363
6364 (define_expand "buneq"
6365   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6366    (set (pc)
6367         (if_then_else (uneq (reg:CCS 33) (const_int 0))
6368                       (label_ref (match_operand 0 "" ""))
6369                       (pc)))]
6370   ""
6371   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6372
6373 (define_expand "bungt"
6374   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6375    (set (pc)
6376         (if_then_else (ungt (reg:CCS 33) (const_int 0))
6377                       (label_ref (match_operand 0 "" ""))
6378                       (pc)))]
6379   ""
6380   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6381
6382 (define_expand "bunlt"
6383   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6384    (set (pc)
6385         (if_then_else (unlt (reg:CCS 33) (const_int 0))
6386                       (label_ref (match_operand 0 "" ""))
6387                       (pc)))]
6388   ""
6389   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6390
6391 (define_expand "bunge"
6392   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6393    (set (pc)
6394         (if_then_else (unge (reg:CCS 33) (const_int 0))
6395                       (label_ref (match_operand 0 "" ""))
6396                       (pc)))]
6397   ""
6398   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6399
6400 (define_expand "bunle"
6401   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6402    (set (pc)
6403         (if_then_else (unle (reg:CCS 33) (const_int 0))
6404                       (label_ref (match_operand 0 "" ""))
6405                       (pc)))]
6406   ""
6407   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6408
6409 (define_expand "bltgt"
6410   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
6411    (set (pc)
6412         (if_then_else (ltgt (reg:CCS 33) (const_int 0))
6413                       (label_ref (match_operand 0 "" ""))
6414                       (pc)))]
6415   ""
6416   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
6417
6418
6419 ;;
6420 ;;- Conditional jump instructions.
6421 ;;
6422
6423 (define_insn "cjump"
6424  [(set (pc)
6425        (if_then_else
6426          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6427          (label_ref (match_operand 0 "" ""))
6428          (pc)))]
6429   ""
6430 {
6431   if (get_attr_length (insn) == 4)
6432     return "j%C1\t%l0";
6433   else if (TARGET_CPU_ZARCH)
6434     return "jg%C1\t%l0";
6435   else
6436     abort ();
6437 }
6438   [(set_attr "op_type" "RI")
6439    (set_attr "type"    "branch")
6440    (set (attr "length")
6441         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6442                 (const_int 4)
6443                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
6444                  (const_int 6)
6445                (eq (symbol_ref "flag_pic") (const_int 0))
6446                  (const_int 6)] (const_int 8)))])
6447
6448 (define_insn "*cjump_long"
6449  [(set (pc)
6450        (if_then_else
6451          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6452          (match_operand 0 "address_operand" "U")
6453          (pc)))]
6454   ""
6455 {
6456   if (get_attr_op_type (insn) == OP_TYPE_RR)
6457     return "b%C1r\t%0";
6458   else
6459     return "b%C1\t%a0";
6460 }
6461   [(set (attr "op_type")
6462         (if_then_else (match_operand 0 "register_operand" "")
6463                       (const_string "RR") (const_string "RX")))
6464    (set_attr "type"    "branch")
6465    (set_attr "atype" "agen")])
6466
6467
6468 ;;
6469 ;;- Negated conditional jump instructions.
6470 ;;
6471
6472 (define_insn "icjump"
6473  [(set (pc)
6474        (if_then_else
6475          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6476          (pc)
6477          (label_ref (match_operand 0 "" ""))))]
6478   ""
6479 {
6480   if (get_attr_length (insn) == 4)
6481     return "j%D1\t%l0";
6482   else if (TARGET_CPU_ZARCH)
6483     return "jg%D1\t%l0";
6484   else
6485     abort ();
6486 }
6487   [(set_attr "op_type" "RI")
6488    (set_attr "type"    "branch")
6489    (set (attr "length")
6490         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6491                 (const_int 4)
6492                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
6493                  (const_int 6)
6494                (eq (symbol_ref "flag_pic") (const_int 0))
6495                  (const_int 6)] (const_int 8)))])
6496
6497 (define_insn "*icjump_long"
6498  [(set (pc)
6499        (if_then_else
6500          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
6501          (pc)
6502          (match_operand 0 "address_operand" "U")))]
6503   ""
6504 {
6505   if (get_attr_op_type (insn) == OP_TYPE_RR)
6506     return "b%D1r\t%0";
6507   else
6508     return "b%D1\t%a0";
6509 }
6510   [(set (attr "op_type")
6511         (if_then_else (match_operand 0 "register_operand" "")
6512                       (const_string "RR") (const_string "RX")))
6513    (set_attr "type"  "branch")
6514    (set_attr "atype" "agen")])
6515
6516 ;;
6517 ;;- Trap instructions.
6518 ;;
6519
6520 (define_insn "trap"
6521   [(trap_if (const_int 1) (const_int 0))]
6522   ""
6523   "j\t.+2"
6524   [(set_attr "op_type" "RX")
6525    (set_attr "type"  "branch")])
6526
6527 (define_expand "conditional_trap"
6528   [(set (match_dup 2) (match_dup 3))
6529    (trap_if (match_operator 0 "comparison_operator"
6530                             [(match_dup 2) (const_int 0)])
6531             (match_operand:SI 1 "general_operand" ""))]
6532   ""
6533 {
6534    enum machine_mode ccmode;
6535
6536    if (operands[1] != const0_rtx) FAIL;
6537
6538    ccmode = s390_select_ccmode (GET_CODE (operands[0]),
6539                                 s390_compare_op0, s390_compare_op1);
6540    operands[2] = gen_rtx_REG (ccmode, 33);
6541    operands[3] = gen_rtx_COMPARE (ccmode, s390_compare_op0, s390_compare_op1);
6542 })
6543
6544 (define_insn "*trap"
6545   [(trap_if (match_operator 0 "comparison_operator" [(reg 33) (const_int 0)])
6546             (const_int 0))]
6547   ""
6548   "j%C0\t.+2";
6549   [(set_attr "op_type" "RI")
6550    (set_attr "type"  "branch")])
6551
6552 ;;
6553 ;;- Loop instructions.
6554 ;;
6555 ;;  This is all complicated by the fact that since this is a jump insn
6556 ;;  we must handle our own output reloads.
6557
6558 (define_expand "doloop_end"
6559   [(use (match_operand 0 "" ""))        ; loop pseudo
6560    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
6561    (use (match_operand 2 "" ""))        ; max iterations
6562    (use (match_operand 3 "" ""))        ; loop level
6563    (use (match_operand 4 "" ""))]       ; label
6564   ""
6565 {
6566   if (GET_MODE (operands[0]) == SImode)
6567     emit_jump_insn (gen_doloop_si (operands[4], operands[0], operands[0]));
6568   else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
6569     emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
6570   else
6571     FAIL;
6572
6573   DONE;
6574 })
6575
6576 (define_insn "doloop_si"
6577   [(set (pc)
6578         (if_then_else
6579           (ne (match_operand:SI 1 "register_operand" "d,d")
6580               (const_int 1))
6581           (label_ref (match_operand 0 "" ""))
6582           (pc)))
6583    (set (match_operand:SI 2 "register_operand" "=1,?*m*d")
6584         (plus:SI (match_dup 1) (const_int -1)))
6585    (clobber (match_scratch:SI 3 "=X,&d"))
6586    (clobber (reg:CC 33))]
6587   ""
6588 {
6589   if (which_alternative != 0)
6590     return "#";
6591   else if (get_attr_length (insn) == 4)
6592     return "brct\t%1,%l0";
6593   else
6594     abort ();
6595 }
6596   [(set_attr "op_type"  "RI")
6597    (set_attr "type"  "branch")
6598    (set (attr "length")
6599         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6600                 (const_int 4)
6601                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
6602                  (const_int 10)
6603                (eq (symbol_ref "flag_pic") (const_int 0))
6604                  (const_int 6)] (const_int 8)))])
6605
6606 (define_insn "*doloop_si_long"
6607   [(set (pc)
6608         (if_then_else
6609           (ne (match_operand:SI 1 "register_operand" "d,d")
6610               (const_int 1))
6611           (match_operand 0 "address_operand" "U,U")
6612           (pc)))
6613    (set (match_operand:SI 2 "register_operand" "=1,?*m*d")
6614         (plus:SI (match_dup 1) (const_int -1)))
6615    (clobber (match_scratch:SI 3 "=X,&d"))
6616    (clobber (reg:CC 33))]
6617   ""
6618 {
6619   if (get_attr_op_type (insn) == OP_TYPE_RR)
6620     return "bctr\t%1,%0";
6621   else
6622     return "bct\t%1,%a0";
6623 }
6624   [(set (attr "op_type")
6625         (if_then_else (match_operand 0 "register_operand" "")
6626                       (const_string "RR") (const_string "RX")))
6627    (set_attr "type"  "branch")
6628    (set_attr "atype" "agen")])
6629
6630 (define_split
6631   [(set (pc)
6632         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
6633                           (const_int 1))
6634                       (match_operand 0 "" "")
6635                       (pc)))
6636    (set (match_operand:SI 2 "nonimmediate_operand" "")
6637         (plus:SI (match_dup 1) (const_int -1)))
6638    (clobber (match_scratch:SI 3 ""))
6639    (clobber (reg:CC 33))]
6640   "reload_completed
6641    && (! REG_P (operands[2])
6642        || ! rtx_equal_p (operands[1], operands[2]))"
6643   [(set (match_dup 3) (match_dup 1))
6644    (parallel [(set (reg:CCAN 33)
6645                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
6646                                  (const_int 0)))
6647               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
6648    (set (match_dup 2) (match_dup 3))
6649    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
6650                            (match_dup 0)
6651                            (pc)))]
6652   "")
6653
6654 (define_insn "doloop_di"
6655   [(set (pc)
6656         (if_then_else
6657           (ne (match_operand:DI 1 "register_operand" "d,d")
6658               (const_int 1))
6659           (label_ref (match_operand 0 "" ""))
6660           (pc)))
6661    (set (match_operand:DI 2 "register_operand" "=1,?*m*r")
6662         (plus:DI (match_dup 1) (const_int -1)))
6663    (clobber (match_scratch:DI 3 "=X,&d"))
6664    (clobber (reg:CC 33))]
6665   "TARGET_64BIT"
6666 {
6667   if (which_alternative != 0)
6668     return "#";
6669   else if (get_attr_length (insn) == 4)
6670     return "brctg\t%1,%l0";
6671   else
6672     abort ();
6673 }
6674   [(set_attr "op_type"  "RI")
6675    (set_attr "type"  "branch")
6676    (set (attr "length")
6677         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6678                       (const_int 4) (const_int 12)))])
6679
6680 (define_insn "*doloop_di_long"
6681   [(set (pc)
6682         (if_then_else
6683           (ne (match_operand:DI 1 "register_operand" "d,d")
6684               (const_int 1))
6685           (match_operand 0 "address_operand" "U,U")
6686           (pc)))
6687    (set (match_operand:DI 2 "register_operand" "=1,?*m*d")
6688         (plus:DI (match_dup 1) (const_int -1)))
6689    (clobber (match_scratch:DI 3 "=X,&d"))
6690    (clobber (reg:CC 33))]
6691   ""
6692 {
6693   if (get_attr_op_type (insn) == OP_TYPE_RRE)
6694     return "bctgr\t%1,%0";
6695   else
6696     return "bctg\t%1,%a0";
6697 }
6698   [(set (attr "op_type")
6699         (if_then_else (match_operand 0 "register_operand" "")
6700                       (const_string "RRE") (const_string "RXE")))
6701    (set_attr "type"  "branch")
6702    (set_attr "atype" "agen")])
6703
6704 (define_split
6705   [(set (pc)
6706         (if_then_else (ne (match_operand:DI 1 "register_operand" "")
6707                           (const_int 1))
6708                       (match_operand 0 "" "")
6709                       (pc)))
6710    (set (match_operand:DI 2 "nonimmediate_operand" "")
6711         (plus:DI (match_dup 1) (const_int -1)))
6712    (clobber (match_scratch:DI 3 ""))
6713    (clobber (reg:CC 33))]
6714   "reload_completed
6715    && (! REG_P (operands[2])
6716        || ! rtx_equal_p (operands[1], operands[2]))"
6717   [(set (match_dup 3) (match_dup 1))
6718    (parallel [(set (reg:CCAN 33)
6719                    (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
6720                                  (const_int 0)))
6721               (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
6722    (set (match_dup 2) (match_dup 3))
6723    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
6724                            (match_dup 0)
6725                            (pc)))]
6726   "")
6727
6728 ;;
6729 ;;- Unconditional jump instructions.
6730 ;;
6731
6732 ;
6733 ; jump instruction pattern(s).
6734 ;
6735
6736 (define_insn "jump"
6737   [(set (pc) (label_ref (match_operand 0 "" "")))]
6738   ""
6739 {
6740   if (get_attr_length (insn) == 4)
6741     return "j\t%l0";
6742   else if (TARGET_CPU_ZARCH)
6743     return "jg\t%l0";
6744   else
6745     abort ();
6746 }
6747   [(set_attr "op_type" "RI")
6748    (set_attr "type"  "branch")
6749    (set (attr "length")
6750         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
6751                 (const_int 4)
6752                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
6753                  (const_int 6)
6754                (eq (symbol_ref "flag_pic") (const_int 0))
6755                  (const_int 6)] (const_int 8)))])
6756
6757 ;
6758 ; indirect-jump instruction pattern(s).
6759 ;
6760
6761 (define_insn "indirect_jump"
6762  [(set (pc) (match_operand 0 "address_operand" "U"))]
6763   ""
6764 {
6765   if (get_attr_op_type (insn) == OP_TYPE_RR)
6766     return "br\t%0";
6767   else
6768     return "b\t%a0";
6769 }
6770   [(set (attr "op_type")
6771         (if_then_else (match_operand 0 "register_operand" "")
6772                       (const_string "RR") (const_string "RX")))
6773    (set_attr "type"  "branch")
6774    (set_attr "atype" "agen")])
6775
6776 ;
6777 ; casesi instruction pattern(s).
6778 ;
6779
6780 (define_insn "casesi_jump"
6781  [(set (pc) (match_operand 0 "address_operand" "U"))
6782    (use (label_ref (match_operand 1 "" "")))]
6783   ""
6784 {
6785   if (get_attr_op_type (insn) == OP_TYPE_RR)
6786     return "br\t%0";
6787   else
6788     return "b\t%a0";
6789 }
6790   [(set (attr "op_type")
6791         (if_then_else (match_operand 0 "register_operand" "")
6792                       (const_string "RR") (const_string "RX")))
6793    (set_attr "type"  "branch")
6794    (set_attr "atype" "agen")])
6795
6796 (define_expand "casesi"
6797   [(match_operand:SI 0 "general_operand" "")
6798    (match_operand:SI 1 "general_operand" "")
6799    (match_operand:SI 2 "general_operand" "")
6800    (label_ref (match_operand 3 "" ""))
6801    (label_ref (match_operand 4 "" ""))]
6802   ""
6803 {
6804    rtx index  = gen_reg_rtx (SImode);
6805    rtx base   = gen_reg_rtx (Pmode);
6806    rtx target = gen_reg_rtx (Pmode);
6807
6808    emit_move_insn (index, operands[0]);
6809    emit_insn (gen_subsi3 (index, index, operands[1]));
6810    emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
6811                             operands[4]);
6812
6813    if (Pmode != SImode)
6814      index = convert_to_mode (Pmode, index, 1);
6815    if (GET_CODE (index) != REG)
6816      index = copy_to_mode_reg (Pmode, index);
6817
6818    if (TARGET_64BIT)
6819        emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
6820    else
6821        emit_insn (gen_ashlsi3 (index, index, GEN_INT (2)));
6822
6823    emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
6824
6825    index = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, base, index));
6826    emit_move_insn (target, index);
6827
6828    if (flag_pic)
6829      target = gen_rtx_PLUS (Pmode, base, target);
6830    emit_jump_insn (gen_casesi_jump (target, operands[3]));
6831
6832    DONE;
6833 })
6834
6835
6836 ;;
6837 ;;- Jump to subroutine.
6838 ;;
6839 ;;
6840
6841 ;
6842 ; untyped call instruction pattern(s).
6843 ;
6844
6845 ;; Call subroutine returning any type.
6846 (define_expand "untyped_call"
6847   [(parallel [(call (match_operand 0 "" "")
6848                     (const_int 0))
6849               (match_operand 1 "" "")
6850               (match_operand 2 "" "")])]
6851   ""
6852 {
6853   int i;
6854
6855   emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
6856
6857   for (i = 0; i < XVECLEN (operands[2], 0); i++)
6858     {
6859       rtx set = XVECEXP (operands[2], 0, i);
6860       emit_move_insn (SET_DEST (set), SET_SRC (set));
6861     }
6862
6863   /* The optimizer does not know that the call sets the function value
6864      registers we stored in the result block.  We avoid problems by
6865      claiming that all hard registers are used and clobbered at this
6866      point.  */
6867   emit_insn (gen_blockage ());
6868
6869   DONE;
6870 })
6871
6872 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6873 ;; all of memory.  This blocks insns from being moved across this point.
6874
6875 (define_insn "blockage"
6876   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6877   ""
6878   ""
6879   [(set_attr "type"    "none")
6880    (set_attr "length"  "0")])
6881
6882
6883
6884 ;
6885 ; call instruction pattern(s).
6886 ;
6887
6888 (define_expand "call"
6889   [(call (match_operand 0 "" "")
6890          (match_operand 1 "" ""))
6891    (use (match_operand 2 "" ""))]
6892   ""
6893 {
6894   bool plt_call = false;
6895   rtx insn;
6896
6897   /* Direct function calls need special treatment.  */
6898   if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
6899     {
6900       rtx sym = XEXP (operands[0], 0);
6901
6902       /* When calling a global routine in PIC mode, we must
6903          replace the symbol itself with the PLT stub.  */
6904       if (flag_pic && !SYMBOL_REF_LOCAL_P (sym))
6905         {
6906           sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), UNSPEC_PLT);
6907           sym = gen_rtx_CONST (Pmode, sym);
6908           plt_call = true;
6909         }
6910
6911       /* Unless we can use the bras(l) insn, force the
6912          routine address into a register.  */
6913       if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH)
6914         {
6915           if (flag_pic)
6916             sym = legitimize_pic_address (sym, 0);
6917           else
6918             sym = force_reg (Pmode, sym);
6919         }
6920
6921       operands[0] = gen_rtx_MEM (QImode, sym);
6922     }
6923
6924   /* Emit insn.  */
6925   insn = emit_call_insn (gen_call_exp (operands[0], operands[1],
6926                                        gen_rtx_REG (Pmode, RETURN_REGNUM)));
6927
6928   /* 31-bit PLT stubs use the GOT register implicitly.  */
6929   if (!TARGET_64BIT && plt_call)
6930     use_reg (&CALL_INSN_FUNCTION_USAGE (insn), pic_offset_table_rtx);
6931   
6932   DONE;
6933 })
6934
6935 (define_expand "call_exp"
6936   [(parallel [(call (match_operand 0 "" "")
6937                     (match_operand 1 "" ""))
6938               (clobber (match_operand 2 "" ""))])]
6939   ""
6940   "")
6941
6942 (define_insn "*bras"
6943   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
6944          (match_operand 1 "const_int_operand" "n"))
6945    (clobber (match_operand 2 "register_operand" "=r"))]
6946   "TARGET_SMALL_EXEC && GET_MODE (operands[2]) == Pmode"
6947   "bras\t%2,%0"
6948   [(set_attr "op_type" "RI")
6949    (set_attr "type"    "jsr")])
6950
6951 (define_insn "*brasl"
6952   [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
6953          (match_operand 1 "const_int_operand" "n"))
6954    (clobber (match_operand 2 "register_operand" "=r"))]
6955   "TARGET_CPU_ZARCH && GET_MODE (operands[2]) == Pmode"
6956   "brasl\t%2,%0"
6957   [(set_attr "op_type" "RIL")
6958    (set_attr "type"    "jsr")])
6959
6960 (define_insn "*basr"
6961   [(call (mem:QI (match_operand 0 "address_operand" "U"))
6962          (match_operand 1 "const_int_operand" "n"))
6963    (clobber (match_operand 2 "register_operand" "=r"))]
6964   "GET_MODE (operands[2]) == Pmode"
6965 {
6966   if (get_attr_op_type (insn) == OP_TYPE_RR)
6967     return "basr\t%2,%0";
6968   else
6969     return "bas\t%2,%a0";
6970 }
6971   [(set (attr "op_type")
6972         (if_then_else (match_operand 0 "register_operand" "")
6973                       (const_string "RR") (const_string "RX")))
6974    (set_attr "type"  "jsr")
6975    (set_attr "atype" "agen")])
6976
6977 ;
6978 ; call_value instruction pattern(s).
6979 ;
6980
6981 (define_expand "call_value"
6982   [(set (match_operand 0 "" "")
6983         (call (match_operand 1 "" "")
6984               (match_operand 2 "" "")))
6985    (use (match_operand 3 "" ""))]
6986   ""
6987 {
6988   bool plt_call = false;
6989   rtx insn;
6990
6991   /* Direct function calls need special treatment.  */
6992   if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
6993     {
6994       rtx sym = XEXP (operands[1], 0);
6995
6996       /* When calling a global routine in PIC mode, we must
6997          replace the symbol itself with the PLT stub.  */
6998       if (flag_pic && !SYMBOL_REF_LOCAL_P (sym))
6999         {
7000           sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), UNSPEC_PLT);
7001           sym = gen_rtx_CONST (Pmode, sym);
7002           plt_call = true;
7003         }
7004
7005       /* Unless we can use the bras(l) insn, force the
7006          routine address into a register.  */
7007       if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH)
7008         {
7009           if (flag_pic)
7010             sym = legitimize_pic_address (sym, 0);
7011           else
7012             sym = force_reg (Pmode, sym);
7013         }
7014
7015       operands[1] = gen_rtx_MEM (QImode, sym);
7016     }
7017
7018   /* Emit insn.  */
7019   insn = emit_call_insn (
7020             gen_call_value_exp (operands[0], operands[1], operands[2],
7021                                 gen_rtx_REG (Pmode, RETURN_REGNUM)));
7022
7023   /* 31-bit PLT stubs use the GOT register implicitly.  */
7024   if (!TARGET_64BIT && plt_call)
7025     use_reg (&CALL_INSN_FUNCTION_USAGE (insn), pic_offset_table_rtx);
7026   
7027   DONE;
7028 })
7029
7030 (define_expand "call_value_exp"
7031   [(parallel [(set (match_operand 0 "" "")
7032                    (call (match_operand 1 "" "")
7033                          (match_operand 2 "" "")))
7034               (clobber (match_operand 3 "" ""))])]
7035   ""
7036   "")
7037
7038 (define_insn "*bras_r"
7039   [(set (match_operand 0 "register_operand" "=df")
7040         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7041               (match_operand:SI 2 "const_int_operand" "n")))
7042    (clobber (match_operand 3 "register_operand" "=r"))]
7043   "TARGET_SMALL_EXEC && GET_MODE (operands[3]) == Pmode"
7044   "bras\t%3,%1"
7045   [(set_attr "op_type" "RI")
7046    (set_attr "type"    "jsr")])
7047
7048 (define_insn "*brasl_r"
7049   [(set (match_operand 0 "register_operand" "=df")
7050         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7051               (match_operand 2 "const_int_operand" "n")))
7052    (clobber (match_operand 3 "register_operand" "=r"))]
7053   "TARGET_CPU_ZARCH && GET_MODE (operands[3]) == Pmode"
7054   "brasl\t%3,%1"
7055   [(set_attr "op_type" "RIL")
7056    (set_attr "type"    "jsr")])
7057
7058 (define_insn "*basr_r"
7059   [(set (match_operand 0 "register_operand" "=df")
7060         (call (mem:QI (match_operand 1 "address_operand" "U"))
7061               (match_operand 2 "const_int_operand" "n")))
7062    (clobber (match_operand 3 "register_operand" "=r"))]
7063   "GET_MODE (operands[3]) == Pmode"
7064 {
7065   if (get_attr_op_type (insn) == OP_TYPE_RR)
7066     return "basr\t%3,%1";
7067   else
7068     return "bas\t%3,%a1";
7069 }
7070   [(set (attr "op_type")
7071         (if_then_else (match_operand 1 "register_operand" "")
7072                       (const_string "RR") (const_string "RX")))
7073    (set_attr "type"  "jsr")
7074    (set_attr "atype" "agen")])
7075
7076 ;;
7077 ;;- Thread-local storage support.
7078 ;;
7079
7080 (define_insn "get_tp_64"
7081   [(set (match_operand:DI 0 "nonimmediate_operand" "=??d,Q")
7082         (unspec:DI [(const_int 0)] UNSPEC_TP))]
7083   "TARGET_64BIT"
7084   "@
7085    ear\t%0,%%a0\;sllg\t%0,%0,32\;ear\t%0,%%a1
7086    stam\t%%a0,%%a1,%0"
7087   [(set_attr "op_type" "NN,RS")
7088    (set_attr "atype"   "reg,*")
7089    (set_attr "type"    "o3,*")
7090    (set_attr "length"  "14,*")])
7091
7092 (define_insn "get_tp_31"
7093   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,Q")
7094         (unspec:SI [(const_int 0)] UNSPEC_TP))]
7095   "!TARGET_64BIT"
7096   "@
7097    ear\t%0,%%a0
7098    stam\t%%a0,%%a0,%0"
7099   [(set_attr "op_type" "RRE,RS")])
7100
7101 (define_insn "set_tp_64"
7102   [(unspec_volatile [(match_operand:DI 0 "general_operand" "??d,Q")] UNSPECV_SET_TP)
7103    (clobber (match_scratch:SI 1 "=d,X"))]
7104   "TARGET_64BIT"
7105   "@
7106    sar\t%%a1,%0\;srlg\t%1,%0,32\;sar\t%%a0,%1
7107    lam\t%%a0,%%a1,%0"
7108   [(set_attr "op_type" "NN,RS")
7109    (set_attr "atype"   "reg,*")
7110    (set_attr "type"    "o3,*")
7111    (set_attr "length"  "14,*")])
7112
7113 (define_insn "set_tp_31"
7114   [(unspec_volatile [(match_operand:SI 0 "general_operand" "d,Q")] UNSPECV_SET_TP)]
7115   "!TARGET_64BIT"
7116   "@
7117    sar\t%%a0,%0
7118    lam\t%%a0,%%a0,%0"
7119   [(set_attr "op_type" "RRE,RS")])
7120
7121 (define_insn "*tls_load_64"
7122   [(set (match_operand:DI 0 "register_operand" "=d")
7123         (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
7124                     (match_operand:DI 2 "" "")]
7125                    UNSPEC_TLS_LOAD))]
7126   "TARGET_64BIT"
7127   "lg\t%0,%1%J2"
7128   [(set_attr "op_type" "RXE")])
7129
7130 (define_insn "*tls_load_31"
7131   [(set (match_operand:SI 0 "register_operand" "=d,d")
7132         (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
7133                     (match_operand:SI 2 "" "")]
7134                    UNSPEC_TLS_LOAD))]
7135   "!TARGET_64BIT"
7136   "@
7137    l\t%0,%1%J2
7138    ly\t%0,%1%J2"
7139   [(set_attr "op_type" "RX,RXY")])
7140
7141 (define_expand "call_value_tls"
7142   [(set (match_operand 0 "" "")
7143         (call (const_int 0) (const_int 0)))
7144    (use (match_operand 1 "" ""))]
7145   ""
7146 {
7147   rtx insn, sym;
7148
7149   if (!flag_pic)
7150     abort ();
7151
7152   sym = s390_tls_get_offset ();
7153   sym = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), UNSPEC_PLT);
7154   sym = gen_rtx_CONST (Pmode, sym);
7155
7156   /* Unless we can use the bras(l) insn, force the
7157      routine address into a register.  */
7158   if (!TARGET_SMALL_EXEC && !TARGET_CPU_ZARCH)
7159     {
7160       if (flag_pic)
7161         sym = legitimize_pic_address (sym, 0);
7162       else
7163         sym = force_reg (Pmode, sym);
7164     }
7165
7166   sym = gen_rtx_MEM (QImode, sym);
7167
7168   /* Emit insn.  */
7169   insn = emit_call_insn (
7170             gen_call_value_tls_exp (operands[0], sym, const0_rtx,
7171                                     gen_rtx_REG (Pmode, RETURN_REGNUM),
7172                                     operands[1]));
7173
7174   /* The calling convention of __tls_get_offset uses the
7175      GOT register implicitly.  */
7176   use_reg (&CALL_INSN_FUNCTION_USAGE (insn), pic_offset_table_rtx);
7177   use_reg (&CALL_INSN_FUNCTION_USAGE (insn), operands[0]);
7178   CONST_OR_PURE_CALL_P (insn) = 1;
7179
7180   DONE;
7181 })
7182
7183 (define_expand "call_value_tls_exp"
7184   [(parallel [(set (match_operand 0 "" "")
7185                    (call (match_operand 1 "" "")
7186                          (match_operand 2 "" "")))
7187               (clobber (match_operand 3 "" ""))
7188               (use (match_operand 4 "" ""))])]
7189   ""
7190   "")
7191
7192 (define_insn "*bras_tls"
7193   [(set (match_operand 0 "register_operand" "=df")
7194         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7195               (match_operand 2 "const_int_operand" "n")))
7196    (clobber (match_operand 3 "register_operand" "=r"))
7197    (use (match_operand 4 "" ""))]
7198   "TARGET_SMALL_EXEC && GET_MODE (operands[3]) == Pmode"
7199   "bras\t%3,%1%J4"
7200   [(set_attr "op_type" "RI")
7201    (set_attr "type"    "jsr")])
7202
7203 (define_insn "*brasl_tls"
7204   [(set (match_operand 0 "register_operand" "=df")
7205         (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7206               (match_operand 2 "const_int_operand" "n")))
7207    (clobber (match_operand 3 "register_operand" "=r"))
7208    (use (match_operand 4 "" ""))]
7209   "TARGET_CPU_ZARCH && GET_MODE (operands[3]) == Pmode"
7210   "brasl\t%3,%1%J4"
7211   [(set_attr "op_type" "RIL")
7212    (set_attr "type"    "jsr")])
7213
7214 (define_insn "*basr_tls"
7215   [(set (match_operand 0 "register_operand" "=df")
7216         (call (mem:QI (match_operand 1 "address_operand" "U"))
7217               (match_operand 2 "const_int_operand" "n")))
7218    (clobber (match_operand 3 "register_operand" "=r"))
7219    (use (match_operand 4 "" ""))]
7220   "GET_MODE (operands[3]) == Pmode"
7221 {
7222   if (get_attr_op_type (insn) == OP_TYPE_RR)
7223     return "basr\t%3,%1%J4";
7224   else
7225     return "bas\t%3,%a1%J4";
7226 }
7227   [(set (attr "op_type")
7228         (if_then_else (match_operand 1 "register_operand" "")
7229                       (const_string "RR") (const_string "RX")))
7230    (set_attr "type"  "jsr")
7231    (set_attr "atype" "agen")])
7232
7233 ;;
7234 ;;- Miscellaneous instructions.
7235 ;;
7236
7237 ;
7238 ; allocate stack instruction pattern(s).
7239 ;
7240
7241 (define_expand "allocate_stack"
7242   [(set (reg 15)
7243         (plus (reg 15) (match_operand 1 "general_operand" "")))
7244    (set (match_operand 0 "general_operand" "")
7245         (reg 15))]
7246  ""
7247 {
7248     rtx stack = gen_rtx (REG, Pmode, STACK_POINTER_REGNUM);
7249     rtx chain = gen_rtx (MEM, Pmode, stack);
7250     rtx temp = gen_reg_rtx (Pmode);
7251
7252     emit_move_insn (temp, chain);
7253
7254     if (TARGET_64BIT)
7255       emit_insn (gen_adddi3 (stack, stack, negate_rtx (Pmode, operands[1])));
7256     else
7257       emit_insn (gen_addsi3 (stack, stack, negate_rtx (Pmode, operands[1])));
7258
7259     emit_move_insn (chain, temp);
7260
7261     emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
7262     DONE;
7263 })
7264
7265
7266 ;
7267 ; setjmp instruction pattern.
7268 ;
7269
7270 (define_expand "builtin_setjmp_receiver"
7271   [(match_operand 0 "" "")]
7272   "flag_pic"
7273 {
7274   s390_load_got (false);
7275   emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
7276   DONE;
7277 })
7278
7279 ;; These patterns say how to save and restore the stack pointer.  We need not
7280 ;; save the stack pointer at function level since we are careful to
7281 ;; preserve the backchain.  At block level, we have to restore the backchain
7282 ;; when we restore the stack pointer.
7283 ;;
7284 ;; For nonlocal gotos, we must save both the stack pointer and its
7285 ;; backchain and restore both.  Note that in the nonlocal case, the
7286 ;; save area is a memory location.
7287
7288 (define_expand "save_stack_function"
7289   [(match_operand 0 "general_operand" "")
7290    (match_operand 1 "general_operand" "")]
7291   ""
7292   "DONE;")
7293
7294 (define_expand "restore_stack_function"
7295   [(match_operand 0 "general_operand" "")
7296    (match_operand 1 "general_operand" "")]
7297   ""
7298   "DONE;")
7299
7300 (define_expand "restore_stack_block"
7301   [(use (match_operand 0 "register_operand" ""))
7302    (set (match_dup 2) (match_dup 3))
7303    (set (match_dup 0) (match_operand 1 "register_operand" ""))
7304    (set (match_dup 3) (match_dup 2))]
7305   ""
7306 {
7307   operands[2] = gen_reg_rtx (Pmode);
7308   operands[3] = gen_rtx_MEM (Pmode, operands[0]);
7309 })
7310
7311 (define_expand "save_stack_nonlocal"
7312   [(match_operand 0 "memory_operand" "")
7313    (match_operand 1 "register_operand" "")]
7314   ""
7315 {
7316   rtx temp = gen_reg_rtx (Pmode);
7317
7318   /* Copy the backchain to the first word, sp to the second and the literal pool
7319      base to the third. */
7320   emit_move_insn (operand_subword (operands[0], 2, 0,
7321                   TARGET_64BIT ? OImode : TImode),
7322                   gen_rtx_REG (Pmode, BASE_REGISTER));
7323   emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
7324   emit_move_insn (operand_subword (operands[0], 0, 0,
7325                  TARGET_64BIT ? OImode : TImode),
7326                  temp);
7327   emit_move_insn (operand_subword (operands[0], 1, 0,
7328                  TARGET_64BIT ? OImode : TImode),
7329                  operands[1]);
7330   DONE;
7331 })
7332
7333 (define_expand "restore_stack_nonlocal"
7334   [(match_operand 0 "register_operand" "")
7335    (match_operand 1 "memory_operand" "")]
7336   ""
7337 {
7338   rtx temp = gen_reg_rtx (Pmode);
7339   rtx base = gen_rtx_REG (Pmode, BASE_REGISTER);
7340
7341   /* Restore the backchain from the first word, sp from the second and the
7342      literal pool base from the third. */
7343   emit_move_insn (temp,
7344                  operand_subword (operands[1], 0, 0,
7345                  TARGET_64BIT ? OImode : TImode));
7346   emit_move_insn (operands[0],
7347                  operand_subword (operands[1], 1, 0,
7348                  TARGET_64BIT ? OImode : TImode));
7349   emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
7350   emit_move_insn (base,
7351                   operand_subword (operands[1], 2, 0,
7352                   TARGET_64BIT ? OImode : TImode));
7353   emit_insn (gen_rtx_USE (VOIDmode, base));
7354
7355   DONE;
7356 })
7357
7358
7359 ;
7360 ; nop instruction pattern(s).
7361 ;
7362
7363 (define_insn "nop"
7364   [(const_int 0)]
7365   ""
7366   "lr\t0,0"
7367   [(set_attr "op_type" "RR")])
7368
7369
7370 ;
7371 ; Special literal pool access instruction pattern(s).
7372 ;
7373
7374 (define_insn "*pool_entry"
7375   [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
7376                     UNSPECV_POOL_ENTRY)]
7377   ""
7378 {
7379   enum machine_mode mode = GET_MODE (PATTERN (insn));
7380   unsigned int align = GET_MODE_BITSIZE (mode);
7381   s390_output_pool_entry (asm_out_file, operands[0], mode, align);
7382   return "";
7383 }
7384   [(set_attr "op_type" "NN")
7385    (set (attr "length") 
7386         (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
7387
7388 (define_insn "pool_start_31"
7389   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_START)]
7390   "!TARGET_CPU_ZARCH"
7391   ".align\t4"
7392   [(set_attr "op_type"  "NN")
7393    (set_attr "length"   "2")])
7394
7395 (define_insn "pool_end_31"
7396   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_END)]
7397   "!TARGET_CPU_ZARCH"
7398   ".align\t2"
7399   [(set_attr "op_type"  "NN")
7400    (set_attr "length"   "2")])
7401
7402 (define_insn "pool_start_64"
7403   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_START)]
7404   "TARGET_CPU_ZARCH"
7405   ".section\t.rodata\;.align\t8"
7406   [(set_attr "op_type"  "NN")
7407    (set_attr "length"   "0")])
7408
7409 (define_insn "pool_end_64"
7410   [(unspec_volatile [(const_int 0)] UNSPECV_POOL_END)]
7411   "TARGET_CPU_ZARCH"
7412   ".previous"
7413   [(set_attr "op_type"  "NN")
7414    (set_attr "length"   "0")])
7415
7416 (define_insn "main_base_31_small"
7417   [(set (match_operand 0 "register_operand" "=a")
7418         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7419   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7420   "basr\t%0,0"
7421   [(set_attr "op_type" "RR")
7422    (set_attr "type"    "la")])
7423
7424 (define_insn "main_base_31_large"
7425   [(set (match_operand 0 "register_operand" "=a")
7426         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
7427    (set (pc) (label_ref (match_operand 2 "" "")))]
7428   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7429   "bras\t%0,%2"
7430   [(set_attr "op_type" "RI")])
7431
7432 (define_insn "main_base_64"
7433   [(set (match_operand 0 "register_operand" "=a")
7434         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
7435   "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7436   "larl\t%0,%1"
7437   [(set_attr "op_type" "RIL")
7438    (set_attr "type"    "larl")])
7439
7440 (define_insn "main_pool"
7441   [(unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL)]
7442   ""
7443   "* abort ();"
7444   [(set_attr "op_type" "NN")])
7445
7446 (define_insn "reload_base_31"
7447   [(set (match_operand 0 "register_operand" "=a")
7448         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7449   "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7450   "basr\t%0,0\;la\t%0,%1-.(%0)"
7451   [(set_attr "op_type" "NN")
7452    (set_attr "type"    "la")
7453    (set_attr "length"  "6")])
7454
7455 (define_insn "reload_base_64"
7456   [(set (match_operand 0 "register_operand" "=a")
7457         (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
7458   "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
7459   "larl\t%0,%1"
7460   [(set_attr "op_type" "RIL")
7461    (set_attr "type"    "larl")])
7462
7463 (define_insn "pool"
7464   [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
7465   ""
7466   "* abort ();"
7467   [(set_attr "op_type" "NN")
7468    (set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
7469
7470 ;;
7471 ;; Insns related to generating the function prologue and epilogue.
7472 ;;
7473
7474
7475 (define_expand "prologue"
7476   [(use (const_int 0))]
7477   ""
7478   "s390_emit_prologue (); DONE;")
7479
7480 (define_expand "epilogue"
7481   [(use (const_int 1))]
7482   ""
7483   "s390_emit_epilogue (); DONE;")
7484
7485 (define_insn "*return"
7486   [(return)
7487    (use (match_operand 0 "register_operand" "a"))]
7488   "GET_MODE (operands[0]) == Pmode"
7489   "br\t%0"
7490   [(set_attr "op_type" "RR")
7491    (set_attr "type"    "jsr")
7492    (set_attr "atype"   "agen")])
7493
7494
7495 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
7496 ;; pointer. This is used for compatability.
7497
7498 (define_expand "ptr_extend"
7499   [(set (match_operand:DI 0 "register_operand" "=r")
7500         (match_operand:SI 1 "register_operand" "r"))]
7501   "TARGET_64BIT"
7502 {
7503   emit_insn (gen_anddi3 (operands[0],
7504                          gen_lowpart (DImode, operands[1]),
7505                          GEN_INT (0x7fffffff)));
7506   DONE;
7507 })