OSDN Git Service

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