OSDN Git Service

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