OSDN Git Service

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