OSDN Git Service

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