OSDN Git Service

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