OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [config/] [s390/] [s390.md] - Blame information for rev 311

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
;;- Machine description for GNU compiler -- S/390 / zSeries version.
2
;;  Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
3
;;  2009, 2010 Free Software Foundation, Inc.
4
;;  Contributed by Hartmut Penner (hpenner@de.ibm.com) and
5
;;                 Ulrich Weigand (uweigand@de.ibm.com) and
6
;;                 Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
7
 
8
;; This file is part of GCC.
9
 
10
;; GCC is free software; you can redistribute it and/or modify it under
11
;; the terms of the GNU General Public License as published by the Free
12
;; Software Foundation; either version 3, or (at your option) any later
13
;; version.
14
 
15
;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16
;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18
;; for more details.
19
 
20
;; You should have received a copy of the GNU General Public License
21
;; along with GCC; see the file COPYING3.  If not see
22
;; .
23
 
24
;;
25
;; See constraints.md for a description of constraints specific to s390.
26
;;
27
 
28
;; Special formats used for outputting 390 instructions.
29
;;
30
;;     %C: print opcode suffix for branch condition.
31
;;     %D: print opcode suffix for inverse branch condition.
32
;;     %J: print tls_load/tls_gdcall/tls_ldcall suffix
33
;;     %G: print the size of the operand in bytes.
34
;;     %O: print only the displacement of a memory reference.
35
;;     %R: print only the base register of a memory reference.
36
;;     %S: print S-type memory reference (base+displacement).
37
;;     %N: print the second word of a DImode operand.
38
;;     %M: print the second word of a TImode operand.
39
;;     %Y: print shift count operand.
40
;;
41
;;     %b: print integer X as if it's an unsigned byte.
42
;;     %c: print integer X as if it's an signed byte.
43
;;     %x: print integer X as if it's an unsigned halfword.
44
;;     %h: print integer X as if it's a signed halfword.
45
;;     %i: print the first nonzero HImode part of X.
46
;;     %j: print the first HImode part unequal to -1 of X.
47
;;     %k: print the first nonzero SImode part of X.
48
;;     %m: print the first SImode part unequal to -1 of X.
49
;;     %o: print integer X as if it's an unsigned 32bit word.
50
;;
51
;; We have a special constraint for pattern matching.
52
;;
53
;;   s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
54
;;
55
 
56
;;
57
;; UNSPEC usage
58
;;
59
 
60
(define_constants
61
  [; Miscellaneous
62
   (UNSPEC_ROUND                1)
63
   (UNSPEC_CCU_TO_INT           2)
64
   (UNSPEC_CCZ_TO_INT           3)
65
   (UNSPEC_ICM                  10)
66
   (UNSPEC_TIE                  11)
67
 
68
   ; GOT/PLT and lt-relative accesses
69
   (UNSPEC_LTREL_OFFSET         100)
70
   (UNSPEC_LTREL_BASE           101)
71
   (UNSPEC_POOL_OFFSET          102)
72
   (UNSPEC_GOTENT               110)
73
   (UNSPEC_GOT                  111)
74
   (UNSPEC_GOTOFF               112)
75
   (UNSPEC_PLT                  113)
76
   (UNSPEC_PLTOFF               114)
77
 
78
   ; Literal pool
79
   (UNSPEC_RELOAD_BASE          210)
80
   (UNSPEC_MAIN_BASE            211)
81
   (UNSPEC_LTREF                212)
82
   (UNSPEC_INSN                 213)
83
   (UNSPEC_EXECUTE              214)
84
 
85
   ; Atomic Support
86
   (UNSPEC_MB                   400)
87
 
88
   ; TLS relocation specifiers
89
   (UNSPEC_TLSGD                500)
90
   (UNSPEC_TLSLDM               501)
91
   (UNSPEC_NTPOFF               502)
92
   (UNSPEC_DTPOFF               503)
93
   (UNSPEC_GOTNTPOFF            504)
94
   (UNSPEC_INDNTPOFF            505)
95
 
96
   ; TLS support
97
   (UNSPEC_TLSLDM_NTPOFF        511)
98
   (UNSPEC_TLS_LOAD             512)
99
 
100
   ; String Functions
101
   (UNSPEC_SRST                 600)
102
   (UNSPEC_MVST                 601)
103
 
104
   ; Stack Smashing Protector
105
   (UNSPEC_SP_SET               700)
106
   (UNSPEC_SP_TEST              701)
107
 
108
   ; Test Data Class (TDC)
109
   (UNSPEC_TDC_INSN             800)
110
 ])
111
 
112
;;
113
;; UNSPEC_VOLATILE usage
114
;;
115
 
116
(define_constants
117
  [; Blockage
118
   (UNSPECV_BLOCKAGE            0)
119
 
120
   ; TPF Support
121
   (UNSPECV_TPF_PROLOGUE        20)
122
   (UNSPECV_TPF_EPILOGUE        21)
123
 
124
   ; Literal pool
125
   (UNSPECV_POOL                200)
126
   (UNSPECV_POOL_SECTION        201)
127
   (UNSPECV_POOL_ALIGN          202)
128
   (UNSPECV_POOL_ENTRY          203)
129
   (UNSPECV_MAIN_POOL           300)
130
 
131
   ; TLS support
132
   (UNSPECV_SET_TP              500)
133
 
134
   ; Atomic Support
135
   (UNSPECV_CAS                 700)
136
  ])
137
 
138
;;
139
;; Registers
140
;;
141
 
142
; Registers with special meaning
143
 
144
(define_constants
145
  [
146
   ; Sibling call register.
147
   (SIBCALL_REGNUM               1)
148
   ; Literal pool base register.
149
   (BASE_REGNUM                 13)
150
   ; Return address register.
151
   (RETURN_REGNUM               14)
152
   ; Condition code register.
153
   (CC_REGNUM                   33)
154
   ; Thread local storage pointer register.
155
   (TP_REGNUM                   36)
156
  ])
157
 
158
; Hardware register names
159
 
160
(define_constants
161
  [
162
   ; General purpose registers
163
   (GPR0_REGNUM                  0)
164
   ; Floating point registers.
165
   (FPR0_REGNUM                 16)
166
   (FPR2_REGNUM                 18)
167
  ])
168
 
169
;;
170
;; PFPO GPR0 argument format
171
;;
172
 
173
(define_constants
174
  [
175
   ; PFPO operation type
176
   (PFPO_CONVERT          0x1000000)
177
   ; PFPO operand types
178
   (PFPO_OP_TYPE_SF             0x5)
179
   (PFPO_OP_TYPE_DF             0x6)
180
   (PFPO_OP_TYPE_TF             0x7)
181
   (PFPO_OP_TYPE_SD             0x8)
182
   (PFPO_OP_TYPE_DD             0x9)
183
   (PFPO_OP_TYPE_TD             0xa)
184
   ; Bitposition of operand types
185
   (PFPO_OP0_TYPE_SHIFT          16)
186
   (PFPO_OP1_TYPE_SHIFT           8)
187
  ])
188
 
189
 
190
;; Instruction operand type as used in the Principles of Operation.
191
;; Used to determine defaults for length and other attribute values.
192
 
193
(define_attr "op_type"
194
  "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR,SIL,RRS,RIS"
195
  (const_string "NN"))
196
 
197
;; Instruction type attribute used for scheduling.
198
 
199
(define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
200
                     cs,vs,store,sem,idiv,
201
                     imulhi,imulsi,imuldi,
202
                     branch,jsr,fsimptf,fsimpdf,fsimpsf,fhex,
203
                     floadtf,floaddf,floadsf,fstoredf,fstoresf,
204
                     fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
205
                     ftoi,fsqrttf,fsqrtdf,fsqrtsf,
206
                     ftrunctf,ftruncdf, ftruncsd, ftruncdd,
207
                     itoftf, itofdf, itofsf, itofdd, itoftd,
208
                     fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
209
                     fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
210
                     ftoidfp, other"
211
  (cond [(eq_attr "op_type" "NN")  (const_string "other")
212
         (eq_attr "op_type" "SS")  (const_string "cs")]
213
    (const_string "integer")))
214
 
215
;; Another attribute used for scheduling purposes:
216
;;   agen: Instruction uses the address generation unit
217
;;   reg: Instruction does not use the agen unit
218
 
219
(define_attr "atype" "agen,reg"
220
  (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF,RRR")
221
                (const_string "reg")
222
                (const_string "agen")))
223
 
224
;; Properties concerning Z10 execution grouping and value forwarding.
225
;; z10_super: instruction is superscalar.
226
;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
227
;; z10_fwd: The instruction reads the value of an operand and stores it into a
228
;;   target register.  It can forward this value to a second instruction that reads
229
;;   the same register if that second instruction is issued in the same group.
230
;; z10_rec: The instruction is in the T pipeline and reads a register. If the
231
;;   instruction in the S pipe writes to the register, then the T instruction
232
;;   can immediately read the new value.
233
;; z10_fr: union of Z10_fwd and z10_rec.
234
;; z10_c: second operand of instruction is a register and read with complemented bits.
235
;;
236
;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
237
 
238
 
239
(define_attr "z10prop" "none,
240
                        z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
241
                        z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
242
                        z10_rec,
243
                        z10_fr, z10_fr_A3, z10_fr_E1,
244
                        z10_c"
245
             (const_string "none"))
246
 
247
 
248
;; Length in bytes.
249
 
250
(define_attr "length" ""
251
  (cond [(eq_attr "op_type" "E,RR")                           (const_int 2)
252
         (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF,RRR")  (const_int 4)]
253
    (const_int 6)))
254
 
255
 
256
;; Processor type.  This attribute must exactly match the processor_type
257
;; enumeration in s390.h.  The current machine description does not
258
;; distinguish between g5 and g6, but there are differences between the two
259
;; CPUs could in theory be modeled.
260
 
261
(define_attr "cpu" "g5,g6,z900,z990,z9_109,z10"
262
  (const (symbol_ref "s390_tune_attr")))
263
 
264
(define_attr "cpu_facility" "standard,ieee,zarch,longdisp,extimm,dfp,z10"
265
  (const_string "standard"))
266
 
267
(define_attr "enabled" ""
268
  (cond [(eq_attr "cpu_facility" "standard")
269
         (const_int 1)
270
 
271
         (and (eq_attr "cpu_facility" "ieee")
272
              (ne (symbol_ref "TARGET_CPU_IEEE_FLOAT") (const_int 0)))
273
         (const_int 1)
274
 
275
         (and (eq_attr "cpu_facility" "zarch")
276
              (ne (symbol_ref "TARGET_ZARCH") (const_int 0)))
277
         (const_int 1)
278
 
279
         (and (eq_attr "cpu_facility" "longdisp")
280
              (ne (symbol_ref "TARGET_LONG_DISPLACEMENT") (const_int 0)))
281
         (const_int 1)
282
 
283
         (and (eq_attr "cpu_facility" "extimm")
284
              (ne (symbol_ref "TARGET_EXTIMM") (const_int 0)))
285
         (const_int 1)
286
 
287
         (and (eq_attr "cpu_facility" "dfp")
288
              (ne (symbol_ref "TARGET_DFP") (const_int 0)))
289
         (const_int 1)
290
 
291
         (and (eq_attr "cpu_facility" "z10")
292
              (ne (symbol_ref "TARGET_Z10") (const_int 0)))
293
         (const_int 1)]
294
        (const_int 0)))
295
 
296
;; Pipeline description for z900.  For lack of anything better,
297
;; this description is also used for the g5 and g6.
298
(include "2064.md")
299
 
300
;; Pipeline description for z990, z9-109 and z9-ec.
301
(include "2084.md")
302
 
303
;; Pipeline description for z10
304
(include "2097.md")
305
 
306
;; Predicates
307
(include "predicates.md")
308
 
309
;; Constraint definitions
310
(include "constraints.md")
311
 
312
;; Other includes
313
(include "tpf.md")
314
 
315
;; Iterators
316
 
317
;; These mode iterators allow floating point patterns to be generated from the
318
;; same template.
319
(define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
320
                              (SD "TARGET_HARD_DFP")])
321
(define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
322
(define_mode_iterator FPALL [TF DF SF TD DD SD])
323
(define_mode_iterator BFP [TF DF SF])
324
(define_mode_iterator DFP [TD DD])
325
(define_mode_iterator DFP_ALL [TD DD SD])
326
(define_mode_iterator DSF [DF SF])
327
(define_mode_iterator SD_SF [SF SD])
328
(define_mode_iterator DD_DF [DF DD])
329
(define_mode_iterator TD_TF [TF TD])
330
 
331
;; This mode iterator allows 31-bit and 64-bit TDSI patterns to be generated
332
;; from the same template.
333
(define_mode_iterator TDSI [(TI "TARGET_64BIT") DI SI])
334
 
335
;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
336
;; from the same template.
337
(define_mode_iterator GPR [(DI "TARGET_64BIT") SI])
338
(define_mode_iterator DSI [DI SI])
339
 
340
;; These mode iterators allow :P to be used for patterns that operate on
341
;; pointer-sized quantities.  Exactly one of the two alternatives will match.
342
(define_mode_iterator DP  [(TI "TARGET_64BIT") (DI "!TARGET_64BIT")])
343
(define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
344
 
345
;; This mode iterator allows the QI and HI patterns to be defined from
346
;; the same template.
347
(define_mode_iterator HQI [HI QI])
348
 
349
;; This mode iterator allows the integer patterns to be defined from the
350
;; same template.
351
(define_mode_iterator INT [(DI "TARGET_64BIT") SI HI QI])
352
(define_mode_iterator INTALL [TI DI SI HI QI])
353
 
354
;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
355
;; the same template.
356
(define_code_iterator SHIFT [ashift lshiftrt])
357
 
358
;; This iterator and attribute allow to combine most atomic operations.
359
(define_code_iterator ATOMIC [and ior xor plus minus mult])
360
(define_code_attr atomic [(and "and") (ior "ior") (xor "xor")
361
                          (plus "add") (minus "sub") (mult "nand")])
362
 
363
;; In FP templates, a string like "ltbr" will expand to "ltxbr" in
364
;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
365
(define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
366
 
367
;; In FP templates, a  in "mr" will expand to "mxr" in
368
;; TF/TDmode, "mdr" in DF/DDmode, "meer" in SFmode and "mer in
369
;; SDmode.
370
(define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
371
 
372
;; In FP templates, "" will expand to "RRE" in TFmode and "RR" otherwise.
373
;; Likewise for "".
374
(define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
375
(define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
376
 
377
;; The decimal floating point variants of add, sub, div and mul support 3
378
;; fp register operands.  The following attributes allow to merge the bfp and
379
;; dfp variants in a single insn definition.
380
 
381
;; This attribute is used to set op_type accordingly.
382
(define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
383
                        (DD "RRR") (SD "RRR")])
384
 
385
;; This attribute is used in the operand constraint list in order to have the
386
;; first and the second operand match for bfp modes.
387
(define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
388
 
389
;; This attribute is used in the operand list of the instruction to have an
390
;; additional operand for the dfp instructions.
391
(define_mode_attr op1 [(TF "") (DF "") (SF "")
392
                       (TD "%1,") (DD "%1,") (SD "%1,")])
393
 
394
 
395
;; This attribute is used in the operand constraint list
396
;; for instructions dealing with the sign bit of 32 or 64bit fp values.
397
;; TFmode values are represented by a fp register pair.  Since the
398
;; sign bit instructions only handle single source and target fp registers
399
;; these instructions can only be used for TFmode values if the source and
400
;; target operand uses the same fp register.
401
(define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
402
 
403
;; In FP templates, "" will expand to "f" in TFmode and "R" otherwise.
404
;; This is used to disable the memory alternative in TFmode patterns.
405
(define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
406
 
407
;; This attribute adds b for bfp instructions and t for dfp instructions and is used
408
;; within instruction mnemonics.
409
(define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
410
 
411
;; This attribute is used within instruction mnemonics.  It evaluates to d for dfp
412
;; modes and to an empty string for bfp modes.
413
(define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
414
 
415
;; In GPR and P templates, a constraint like "" will expand to "d" in DImode
416
;; and "0" in SImode. This allows to combine instructions of which the 31bit
417
;; version only operates on one register.
418
(define_mode_attr d0 [(DI "d") (SI "0")])
419
 
420
;; In combination with d0 this allows to combine instructions of which the 31bit
421
;; version only operates on one register. The DImode version needs an additional
422
;; register for the assembler output.
423
(define_mode_attr 1 [(DI "%1,") (SI "")])
424
 
425
;; In SHIFT templates, a string like "sdl" will expand to "sldl" in
426
;; 'ashift' and "srdl" in 'lshiftrt'.
427
(define_code_attr lr [(ashift "l") (lshiftrt "r")])
428
 
429
;; In SHIFT templates, this attribute holds the correct standard name for the
430
;; pattern itself and the corresponding function calls.
431
(define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
432
 
433
;; This attribute handles differences in the instruction 'type' and will result
434
;; in "RRE" for DImode and "RR" for SImode.
435
(define_mode_attr E [(DI "E") (SI "")])
436
 
437
;; This attribute handles differences in the instruction 'type' and makes RX
438
;; to result in "RXY" for DImode and "RX" for SImode.
439
(define_mode_attr Y [(DI "Y") (SI "")])
440
 
441
;; This attribute handles differences in the instruction 'type' and will result
442
;; in "RSE" for TImode and "RS" for DImode.
443
(define_mode_attr TE [(TI "E") (DI "")])
444
 
445
;; In GPR templates, a string like "lcr" will expand to "lcgr" in DImode
446
;; and "lcr" in SImode.
447
(define_mode_attr g [(DI "g") (SI "")])
448
 
449
;; In GPR templates, a string like "sl" will expand to "slg" in DImode
450
;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
451
;; were enhanced with long displacements whereas 31bit instructions got a ..y
452
;; variant for long displacements.
453
(define_mode_attr y [(DI "g") (SI "y")])
454
 
455
;; In DP templates, a string like "cds" will expand to "cdsg" in TImode
456
;; and "cds" in DImode.
457
(define_mode_attr tg [(TI "g") (DI "")])
458
 
459
;; In GPR templates, a string like "cdbr" will expand to "cgdbr" in DImode
460
;; and "cfdbr" in SImode.
461
(define_mode_attr gf [(DI "g") (SI "f")])
462
 
463
;; ICM mask required to load MODE value into the lowest subreg
464
;; of a SImode register.
465
(define_mode_attr icm_lo [(HI "3") (QI "1")])
466
 
467
;; In HQI templates, a string like "llg" will expand to "llgh" in
468
;; HImode and "llgc" in QImode.
469
(define_mode_attr hc [(HI "h") (QI "c")])
470
 
471
;; In P templates, the mode  will expand to "TI" in DImode and "DI"
472
;; in SImode.
473
(define_mode_attr DBL [(DI "TI") (SI "DI")])
474
 
475
;; This attribute expands to DF for TFmode and to DD for TDmode .  It is
476
;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
477
(define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
478
 
479
;; Maximum unsigned integer that fits in MODE.
480
(define_mode_attr max_uint [(HI "65535") (QI "255")])
481
 
482
;;
483
;;- Compare instructions.
484
;;
485
 
486
; Test-under-Mask instructions
487
 
488
(define_insn "*tmqi_mem"
489
  [(set (reg CC_REGNUM)
490
        (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
491
                         (match_operand:QI 1 "immediate_operand" "n,n"))
492
                 (match_operand:QI 2 "immediate_operand" "n,n")))]
493
  "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
494
  "@
495
   tm\t%S0,%b1
496
   tmy\t%S0,%b1"
497
  [(set_attr "op_type" "SI,SIY")
498
   (set_attr "z10prop" "z10_super,z10_super")])
499
 
500
(define_insn "*tmdi_reg"
501
  [(set (reg CC_REGNUM)
502
        (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
503
                         (match_operand:DI 1 "immediate_operand"
504
                                             "N0HD0,N1HD0,N2HD0,N3HD0"))
505
                 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
506
  "TARGET_64BIT
507
   && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
508
   && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
509
  "@
510
   tmhh\t%0,%i1
511
   tmhl\t%0,%i1
512
   tmlh\t%0,%i1
513
   tmll\t%0,%i1"
514
  [(set_attr "op_type" "RI")
515
   (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
516
 
517
(define_insn "*tmsi_reg"
518
  [(set (reg CC_REGNUM)
519
        (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
520
                         (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
521
                 (match_operand:SI 2 "immediate_operand" "n,n")))]
522
  "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
523
   && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
524
  "@
525
   tmh\t%0,%i1
526
   tml\t%0,%i1"
527
  [(set_attr "op_type" "RI")
528
   (set_attr "z10prop" "z10_super,z10_super")])
529
 
530
(define_insn "*tm_full"
531
  [(set (reg CC_REGNUM)
532
        (compare (match_operand:HQI 0 "register_operand" "d")
533
                 (match_operand:HQI 1 "immediate_operand" "n")))]
534
  "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
535
  "tml\t%0,"
536
  [(set_attr "op_type" "RI")
537
   (set_attr "z10prop" "z10_super")])
538
 
539
 
540
;
541
; Load-and-Test instructions
542
;
543
 
544
; tst(di|si) instruction pattern(s).
545
 
546
(define_insn "*tstdi_sign"
547
  [(set (reg CC_REGNUM)
548
        (compare
549
          (ashiftrt:DI
550
            (ashift:DI
551
              (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,RT") 0)
552
              (const_int 32)) (const_int 32))
553
          (match_operand:DI 1 "const0_operand" "")))
554
   (set (match_operand:DI 2 "register_operand" "=d,d")
555
        (sign_extend:DI (match_dup 0)))]
556
  "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
557
  "ltgfr\t%2,%0
558
   ltgf\t%2,%0"
559
  [(set_attr "op_type"      "RRE,RXY")
560
   (set_attr "cpu_facility" "*,z10")
561
   (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
562
 
563
; ltr, lt, ltgr, ltg
564
(define_insn "*tst_extimm"
565
  [(set (reg CC_REGNUM)
566
        (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
567
                 (match_operand:GPR 1 "const0_operand" "")))
568
   (set (match_operand:GPR 2 "register_operand" "=d,d")
569
        (match_dup 0))]
570
  "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
571
  "@
572
   ltr\t%2,%0
573
   lt\t%2,%0"
574
  [(set_attr "op_type" "RR,RXY")
575
   (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
576
 
577
; ltr, lt, ltgr, ltg
578
(define_insn "*tst_cconly_extimm"
579
  [(set (reg CC_REGNUM)
580
        (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
581
                 (match_operand:GPR 1 "const0_operand" "")))
582
   (clobber (match_scratch:GPR 2 "=X,d"))]
583
  "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
584
  "@
585
   ltr\t%0,%0
586
   lt\t%2,%0"
587
  [(set_attr "op_type" "RR,RXY")
588
   (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
589
 
590
(define_insn "*tstdi"
591
  [(set (reg CC_REGNUM)
592
        (compare (match_operand:DI 0 "register_operand" "d")
593
                 (match_operand:DI 1 "const0_operand" "")))
594
   (set (match_operand:DI 2 "register_operand" "=d")
595
        (match_dup 0))]
596
  "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT && !TARGET_EXTIMM"
597
  "ltgr\t%2,%0"
598
  [(set_attr "op_type" "RRE")
599
   (set_attr "z10prop" "z10_fr_E1")])
600
 
601
(define_insn "*tstsi"
602
  [(set (reg CC_REGNUM)
603
        (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
604
                 (match_operand:SI 1 "const0_operand" "")))
605
   (set (match_operand:SI 2 "register_operand" "=d,d,d")
606
        (match_dup 0))]
607
  "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
608
  "@
609
   ltr\t%2,%0
610
   icm\t%2,15,%S0
611
   icmy\t%2,15,%S0"
612
  [(set_attr "op_type" "RR,RS,RSY")
613
   (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
614
 
615
(define_insn "*tstsi_cconly"
616
  [(set (reg CC_REGNUM)
617
        (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
618
                 (match_operand:SI 1 "const0_operand" "")))
619
   (clobber (match_scratch:SI 2 "=X,d,d"))]
620
  "s390_match_ccmode(insn, CCSmode)"
621
  "@
622
   ltr\t%0,%0
623
   icm\t%2,15,%S0
624
   icmy\t%2,15,%S0"
625
  [(set_attr "op_type" "RR,RS,RSY")
626
   (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
627
 
628
(define_insn "*tstdi_cconly_31"
629
  [(set (reg CC_REGNUM)
630
        (compare (match_operand:DI 0 "register_operand" "d")
631
                 (match_operand:DI 1 "const0_operand" "")))]
632
  "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
633
  "srda\t%0,0"
634
  [(set_attr "op_type" "RS")
635
   (set_attr "atype"   "reg")])
636
 
637
; ltr, ltgr
638
(define_insn "*tst_cconly2"
639
  [(set (reg CC_REGNUM)
640
        (compare (match_operand:GPR 0 "register_operand" "d")
641
                 (match_operand:GPR 1 "const0_operand" "")))]
642
  "s390_match_ccmode(insn, CCSmode)"
643
  "ltr\t%0,%0"
644
  [(set_attr "op_type" "RR")
645
   (set_attr "z10prop" "z10_fr_E1")])
646
 
647
; tst(hi|qi) instruction pattern(s).
648
 
649
(define_insn "*tstCCT"
650
  [(set (reg CC_REGNUM)
651
        (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
652
                 (match_operand:HQI 1 "const0_operand" "")))
653
   (set (match_operand:HQI 2 "register_operand" "=d,d,0")
654
        (match_dup 0))]
655
  "s390_match_ccmode(insn, CCTmode)"
656
  "@
657
   icm\t%2,,%S0
658
   icmy\t%2,,%S0
659
   tml\t%0,"
660
  [(set_attr "op_type" "RS,RSY,RI")
661
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
662
 
663
(define_insn "*tsthiCCT_cconly"
664
  [(set (reg CC_REGNUM)
665
        (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
666
                 (match_operand:HI 1 "const0_operand" "")))
667
   (clobber (match_scratch:HI 2 "=d,d,X"))]
668
  "s390_match_ccmode(insn, CCTmode)"
669
  "@
670
   icm\t%2,3,%S0
671
   icmy\t%2,3,%S0
672
   tml\t%0,65535"
673
  [(set_attr "op_type" "RS,RSY,RI")
674
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
675
 
676
(define_insn "*tstqiCCT_cconly"
677
  [(set (reg CC_REGNUM)
678
        (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
679
                 (match_operand:QI 1 "const0_operand" "")))]
680
  "s390_match_ccmode(insn, CCTmode)"
681
  "@
682
   cli\t%S0,0
683
   cliy\t%S0,0
684
   tml\t%0,255"
685
  [(set_attr "op_type" "SI,SIY,RI")
686
   (set_attr "z10prop" "z10_super,z10_super,z10_super")])
687
 
688
(define_insn "*tst"
689
  [(set (reg CC_REGNUM)
690
        (compare (match_operand:HQI 0 "s_operand" "Q,S")
691
                 (match_operand:HQI 1 "const0_operand" "")))
692
   (set (match_operand:HQI 2 "register_operand" "=d,d")
693
        (match_dup 0))]
694
  "s390_match_ccmode(insn, CCSmode)"
695
  "@
696
   icm\t%2,,%S0
697
   icmy\t%2,,%S0"
698
  [(set_attr "op_type" "RS,RSY")
699
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
700
 
701
(define_insn "*tst_cconly"
702
  [(set (reg CC_REGNUM)
703
        (compare (match_operand:HQI 0 "s_operand" "Q,S")
704
                 (match_operand:HQI 1 "const0_operand" "")))
705
   (clobber (match_scratch:HQI 2 "=d,d"))]
706
  "s390_match_ccmode(insn, CCSmode)"
707
  "@
708
   icm\t%2,,%S0
709
   icmy\t%2,,%S0"
710
  [(set_attr "op_type" "RS,RSY")
711
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
712
 
713
 
714
; Compare (equality) instructions
715
 
716
(define_insn "*cmpdi_cct"
717
  [(set (reg CC_REGNUM)
718
        (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
719
                 (match_operand:DI 1 "general_operand" "d,K,Os,RT,BQ")))]
720
  "s390_match_ccmode (insn, CCTmode) && TARGET_64BIT"
721
  "@
722
   cgr\t%0,%1
723
   cghi\t%0,%h1
724
   cgfi\t%0,%1
725
   cg\t%0,%1
726
   #"
727
  [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
728
   (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
729
 
730
(define_insn "*cmpsi_cct"
731
  [(set (reg CC_REGNUM)
732
        (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
733
                 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
734
  "s390_match_ccmode (insn, CCTmode)"
735
  "@
736
   cr\t%0,%1
737
   chi\t%0,%h1
738
   cfi\t%0,%1
739
   c\t%0,%1
740
   cy\t%0,%1
741
   #"
742
  [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
743
   (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*")])
744
 
745
; Compare (signed) instructions
746
 
747
(define_insn "*cmpdi_ccs_sign"
748
  [(set (reg CC_REGNUM)
749
        (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
750
                                                     "d,RT,b"))
751
                 (match_operand:DI 0 "register_operand" "d, d,d")))]
752
  "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
753
  "@
754
   cgfr\t%0,%1
755
   cgf\t%0,%1
756
   cgfrl\t%0,%1"
757
  [(set_attr "op_type"      "RRE,RXY,RIL")
758
   (set_attr "z10prop" "z10_c,*,*")
759
   (set_attr "type"         "*,*,larl")])
760
 
761
 
762
 
763
(define_insn "*cmpsi_ccs_sign"
764
  [(set (reg CC_REGNUM)
765
        (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
766
                 (match_operand:SI 0 "register_operand" "d,d,d")))]
767
  "s390_match_ccmode(insn, CCSRmode)"
768
  "@
769
   ch\t%0,%1
770
   chy\t%0,%1
771
   chrl\t%0,%1"
772
  [(set_attr "op_type"      "RX,RXY,RIL")
773
   (set_attr "cpu_facility" "*,*,z10")
774
   (set_attr "type"         "*,*,larl")])
775
 
776
(define_insn "*cmphi_ccs_z10"
777
  [(set (reg CC_REGNUM)
778
        (compare (match_operand:HI 0 "s_operand"         "Q")
779
                 (match_operand:HI 1 "immediate_operand" "K")))]
780
  "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
781
  "chhsi\t%0,%1"
782
  [(set_attr "op_type" "SIL")])
783
 
784
(define_insn "*cmpdi_ccs_signhi_rl"
785
  [(set (reg CC_REGNUM)
786
        (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT,b"))
787
                 (match_operand:GPR 0 "register_operand"  "d,d")))]
788
  "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
789
  "@
790
   cgh\t%0,%1
791
   cghrl\t%0,%1"
792
  [(set_attr "op_type" "RXY,RIL")
793
   (set_attr "type"    "*,larl")])
794
 
795
; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
796
(define_insn "*cmp_ccs"
797
  [(set (reg CC_REGNUM)
798
        (compare (match_operand:GPR 0 "nonimmediate_operand"
799
                                      "d,d,Q, d,d,d,d")
800
                 (match_operand:GPR 1 "general_operand"
801
                                      "d,K,K,Os,R,T,b")))]
802
  "s390_match_ccmode(insn, CCSmode)"
803
  "@
804
   cr\t%0,%1
805
   chi\t%0,%h1
806
   chsi\t%0,%h1
807
   cfi\t%0,%1
808
   c\t%0,%1
809
   c\t%0,%1
810
   crl\t%0,%1"
811
  [(set_attr "op_type" "RR,RI,SIL,RIL,RX,RXY,RIL")
812
   (set_attr "cpu_facility" "*,*,z10,extimm,*,*,z10")
813
   (set_attr "type" "*,*,*,*,*,*,larl")
814
   (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
815
 
816
 
817
; Compare (unsigned) instructions
818
 
819
(define_insn "*cmpsi_ccu_zerohi_rlsi"
820
  [(set (reg CC_REGNUM)
821
        (compare (zero_extend:SI (mem:HI (match_operand:SI 1
822
                                          "larl_operand" "X")))
823
                 (match_operand:SI 0 "register_operand" "d")))]
824
  "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
825
  "clhrl\t%0,%1"
826
  [(set_attr "op_type" "RIL")
827
   (set_attr "type"    "larl")
828
   (set_attr "z10prop" "z10_super")])
829
 
830
; clhrl, clghrl
831
(define_insn "*cmp_ccu_zerohi_rldi"
832
  [(set (reg CC_REGNUM)
833
        (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
834
                                          "larl_operand" "X")))
835
                 (match_operand:GPR 0 "register_operand" "d")))]
836
  "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
837
  "clhrl\t%0,%1"
838
  [(set_attr "op_type" "RIL")
839
   (set_attr "type"    "larl")
840
   (set_attr "z10prop" "z10_super")])
841
 
842
(define_insn "*cmpdi_ccu_zero"
843
  [(set (reg CC_REGNUM)
844
        (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
845
                                                        "d,RT,b"))
846
                 (match_operand:DI 0 "register_operand" "d, d,d")))]
847
  "s390_match_ccmode (insn, CCURmode) && TARGET_64BIT"
848
  "@
849
   clgfr\t%0,%1
850
   clgf\t%0,%1
851
   clgfrl\t%0,%1"
852
  [(set_attr "op_type"      "RRE,RXY,RIL")
853
   (set_attr "cpu_facility" "*,*,z10")
854
   (set_attr "type"         "*,*,larl")
855
   (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
856
 
857
(define_insn "*cmpdi_ccu"
858
  [(set (reg CC_REGNUM)
859
        (compare (match_operand:DI 0 "nonimmediate_operand"
860
                                     "d, d,d,Q, d, Q,BQ")
861
                 (match_operand:DI 1 "general_operand"
862
                                     "d,Op,b,D,RT,BQ,Q")))]
863
  "s390_match_ccmode (insn, CCUmode) && TARGET_64BIT"
864
  "@
865
   clgr\t%0,%1
866
   clgfi\t%0,%1
867
   clgrl\t%0,%1
868
   clghsi\t%0,%x1
869
   clg\t%0,%1
870
   #
871
   #"
872
  [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
873
   (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
874
   (set_attr "type"         "*,*,larl,*,*,*,*")
875
   (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
876
 
877
(define_insn "*cmpsi_ccu"
878
  [(set (reg CC_REGNUM)
879
        (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
880
                 (match_operand:SI 1 "general_operand"      "d,Os,b,D,R,T,BQ, Q")))]
881
  "s390_match_ccmode (insn, CCUmode)"
882
  "@
883
   clr\t%0,%1
884
   clfi\t%0,%o1
885
   clrl\t%0,%1
886
   clfhsi\t%0,%x1
887
   cl\t%0,%1
888
   cly\t%0,%1
889
   #
890
   #"
891
  [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
892
   (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*,*")
893
   (set_attr "type"         "*,*,larl,*,*,*,*,*")
894
   (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
895
 
896
(define_insn "*cmphi_ccu"
897
  [(set (reg CC_REGNUM)
898
        (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
899
                 (match_operand:HI 1 "general_operand"      "Q,S,D,BQ,Q")))]
900
  "s390_match_ccmode (insn, CCUmode)
901
   && !register_operand (operands[1], HImode)"
902
  "@
903
   clm\t%0,3,%S1
904
   clmy\t%0,3,%S1
905
   clhhsi\t%0,%1
906
   #
907
   #"
908
  [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
909
   (set_attr "cpu_facility" "*,*,z10,*,*")
910
   (set_attr "z10prop" "*,*,z10_super,*,*")])
911
 
912
(define_insn "*cmpqi_ccu"
913
  [(set (reg CC_REGNUM)
914
        (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
915
                 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
916
  "s390_match_ccmode (insn, CCUmode)
917
   && !register_operand (operands[1], QImode)"
918
  "@
919
   clm\t%0,1,%S1
920
   clmy\t%0,1,%S1
921
   cli\t%S0,%b1
922
   cliy\t%S0,%b1
923
   #
924
   #"
925
  [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
926
   (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
927
 
928
 
929
; Block compare (CLC) instruction patterns.
930
 
931
(define_insn "*clc"
932
  [(set (reg CC_REGNUM)
933
        (compare (match_operand:BLK 0 "memory_operand" "Q")
934
                 (match_operand:BLK 1 "memory_operand" "Q")))
935
   (use (match_operand 2 "const_int_operand" "n"))]
936
  "s390_match_ccmode (insn, CCUmode)
937
   && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
938
  "clc\t%O0(%2,%R0),%S1"
939
  [(set_attr "op_type" "SS")])
940
 
941
(define_split
942
  [(set (reg CC_REGNUM)
943
        (compare (match_operand 0 "memory_operand" "")
944
                 (match_operand 1 "memory_operand" "")))]
945
  "reload_completed
946
   && s390_match_ccmode (insn, CCUmode)
947
   && GET_MODE (operands[0]) == GET_MODE (operands[1])
948
   && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
949
  [(parallel
950
    [(set (match_dup 0) (match_dup 1))
951
     (use (match_dup 2))])]
952
{
953
  operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
954
  operands[0] = adjust_address (operands[0], BLKmode, 0);
955
  operands[1] = adjust_address (operands[1], BLKmode, 0);
956
 
957
  operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
958
                                 operands[0], operands[1]);
959
  operands[0] = SET_DEST (PATTERN (curr_insn));
960
})
961
 
962
 
963
; (TF|DF|SF|TD|DD|SD) instructions
964
 
965
; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
966
(define_insn "*cmp_ccs_0"
967
  [(set (reg CC_REGNUM)
968
        (compare (match_operand:FP 0 "register_operand" "f")
969
                 (match_operand:FP 1 "const0_operand"   "")))]
970
  "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
971
  "ltr\t%0,%0"
972
   [(set_attr "op_type" "RRE")
973
    (set_attr "type"  "fsimp")])
974
 
975
; cxtr, cxbr, cdbr, cebr, cdb, ceb, cxbtr, cdbtr
976
(define_insn "*cmp_ccs"
977
  [(set (reg CC_REGNUM)
978
        (compare (match_operand:FP 0 "register_operand" "f,f")
979
                 (match_operand:FP 1 "general_operand"  "f,")))]
980
  "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
981
  "@
982
   cr\t%0,%1
983
   cb\t%0,%1"
984
   [(set_attr "op_type" "RRE,RXE")
985
    (set_attr "type"  "fsimp")])
986
 
987
 
988
; Compare and Branch instructions
989
 
990
; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
991
; The following instructions do a complementary access of their second
992
; operand (z01 only): crj_c, cgrjc, cr, cgr
993
(define_insn "*cmp_and_br_signed_"
994
  [(set (pc)
995
        (if_then_else (match_operator 0 "s390_signed_integer_comparison"
996
                        [(match_operand:GPR 1 "register_operand"  "d,d")
997
                         (match_operand:GPR 2 "nonmemory_operand" "d,C")])
998
                      (label_ref (match_operand 3 "" ""))
999
                      (pc)))
1000
   (clobber (reg:CC CC_REGNUM))]
1001
  "TARGET_Z10"
1002
{
1003
  if (get_attr_length (insn) == 6)
1004
    return which_alternative ?
1005
      "cij%C0\t%1,%c2,%l3" : "crj%C0\t%1,%2,%l3";
1006
  else
1007
    return which_alternative ?
1008
      "cfi\t%1,%c2\;jg%C0\t%l3" : "cr\t%1,%2\;jg%C0\t%l3";
1009
}
1010
  [(set_attr "op_type" "RIE")
1011
   (set_attr "type"    "branch")
1012
   (set_attr "z10prop" "z10_super_c,z10_super")
1013
   (set (attr "length")
1014
        (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1015
                      (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1016
                                                       ; 10 byte for cgr/jg
1017
 
1018
; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1019
; The following instructions do a complementary access of their second
1020
; operand (z10 only): clrj, clgrj, clr, clgr
1021
(define_insn "*cmp_and_br_unsigned_"
1022
  [(set (pc)
1023
        (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1024
                        [(match_operand:GPR 1 "register_operand"  "d,d")
1025
                         (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1026
                      (label_ref (match_operand 3 "" ""))
1027
                      (pc)))
1028
   (clobber (reg:CC CC_REGNUM))]
1029
  "TARGET_Z10"
1030
{
1031
  if (get_attr_length (insn) == 6)
1032
    return which_alternative ?
1033
      "clij%C0\t%1,%b2,%l3" : "clrj%C0\t%1,%2,%l3";
1034
  else
1035
    return which_alternative ?
1036
      "clfi\t%1,%b2\;jg%C0\t%l3" : "clr\t%1,%2\;jg%C0\t%l3";
1037
}
1038
  [(set_attr "op_type" "RIE")
1039
   (set_attr "type"    "branch")
1040
   (set_attr "z10prop" "z10_super_c,z10_super")
1041
   (set (attr "length")
1042
        (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1043
                      (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1044
                                                       ; 10 byte for clgr/jg
1045
 
1046
; And now the same two patterns as above but with a negated CC mask.
1047
 
1048
; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1049
; The following instructions do a complementary access of their second
1050
; operand (z01 only): crj_c, cgrjc, cr, cgr
1051
(define_insn "*icmp_and_br_signed_"
1052
  [(set (pc)
1053
        (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1054
                        [(match_operand:GPR 1 "register_operand"  "d,d")
1055
                         (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1056
                      (pc)
1057
                      (label_ref (match_operand 3 "" ""))))
1058
   (clobber (reg:CC CC_REGNUM))]
1059
  "TARGET_Z10"
1060
{
1061
  if (get_attr_length (insn) == 6)
1062
    return which_alternative ?
1063
      "cij%D0\t%1,%c2,%l3" : "crj%D0\t%1,%2,%l3";
1064
  else
1065
    return which_alternative ?
1066
      "cfi\t%1,%c2\;jg%D0\t%l3" : "cr\t%1,%2\;jg%D0\t%l3";
1067
}
1068
  [(set_attr "op_type" "RIE")
1069
   (set_attr "type"    "branch")
1070
   (set_attr "z10prop" "z10_super_c,z10_super")
1071
   (set (attr "length")
1072
        (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1073
                      (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1074
                                                       ; 10 byte for cgr/jg
1075
 
1076
; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1077
; The following instructions do a complementary access of their second
1078
; operand (z10 only): clrj, clgrj, clr, clgr
1079
(define_insn "*icmp_and_br_unsigned_"
1080
  [(set (pc)
1081
        (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1082
                        [(match_operand:GPR 1 "register_operand"  "d,d")
1083
                         (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1084
                      (pc)
1085
                      (label_ref (match_operand 3 "" ""))))
1086
   (clobber (reg:CC CC_REGNUM))]
1087
  "TARGET_Z10"
1088
{
1089
  if (get_attr_length (insn) == 6)
1090
    return which_alternative ?
1091
      "clij%D0\t%1,%b2,%l3" : "clrj%D0\t%1,%2,%l3";
1092
  else
1093
    return which_alternative ?
1094
      "clfi\t%1,%b2\;jg%D0\t%l3" : "clr\t%1,%2\;jg%D0\t%l3";
1095
}
1096
  [(set_attr "op_type" "RIE")
1097
   (set_attr "type"    "branch")
1098
   (set_attr "z10prop" "z10_super_c,z10_super")
1099
   (set (attr "length")
1100
        (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1101
                      (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1102
                                                       ; 10 byte for clgr/jg
1103
 
1104
;;
1105
;;- Move instructions.
1106
;;
1107
 
1108
;
1109
; movti instruction pattern(s).
1110
;
1111
 
1112
(define_insn "movti"
1113
  [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o")
1114
        (match_operand:TI 1 "general_operand" "QS,d,dPRT,d"))]
1115
  "TARGET_64BIT"
1116
  "@
1117
   lmg\t%0,%N0,%S1
1118
   stmg\t%1,%N1,%S0
1119
   #
1120
   #"
1121
  [(set_attr "op_type" "RSY,RSY,*,*")
1122
   (set_attr "type" "lm,stm,*,*")])
1123
 
1124
(define_split
1125
  [(set (match_operand:TI 0 "nonimmediate_operand" "")
1126
        (match_operand:TI 1 "general_operand" ""))]
1127
  "TARGET_64BIT && reload_completed
1128
   && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
1129
  [(set (match_dup 2) (match_dup 4))
1130
   (set (match_dup 3) (match_dup 5))]
1131
{
1132
  operands[2] = operand_subword (operands[0], 0, 0, TImode);
1133
  operands[3] = operand_subword (operands[0], 1, 0, TImode);
1134
  operands[4] = operand_subword (operands[1], 0, 0, TImode);
1135
  operands[5] = operand_subword (operands[1], 1, 0, TImode);
1136
})
1137
 
1138
(define_split
1139
  [(set (match_operand:TI 0 "nonimmediate_operand" "")
1140
        (match_operand:TI 1 "general_operand" ""))]
1141
  "TARGET_64BIT && reload_completed
1142
   && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1143
  [(set (match_dup 2) (match_dup 4))
1144
   (set (match_dup 3) (match_dup 5))]
1145
{
1146
  operands[2] = operand_subword (operands[0], 1, 0, TImode);
1147
  operands[3] = operand_subword (operands[0], 0, 0, TImode);
1148
  operands[4] = operand_subword (operands[1], 1, 0, TImode);
1149
  operands[5] = operand_subword (operands[1], 0, 0, TImode);
1150
})
1151
 
1152
(define_split
1153
  [(set (match_operand:TI 0 "register_operand" "")
1154
        (match_operand:TI 1 "memory_operand" ""))]
1155
  "TARGET_64BIT && reload_completed
1156
   && !s_operand (operands[1], VOIDmode)"
1157
  [(set (match_dup 0) (match_dup 1))]
1158
{
1159
  rtx addr = operand_subword (operands[0], 1, 0, TImode);
1160
  s390_load_address (addr, XEXP (operands[1], 0));
1161
  operands[1] = replace_equiv_address (operands[1], addr);
1162
})
1163
 
1164
 
1165
;
1166
; Patterns used for secondary reloads
1167
;
1168
 
1169
; z10 provides move instructions accepting larl memory operands.
1170
; Unfortunately there is no such variant for QI, TI and FP mode moves.
1171
; These patterns are also used for unaligned SI and DI accesses.
1172
 
1173
(define_expand "reload_tomem_z10"
1174
  [(parallel [(match_operand:INTALL 0 "memory_operand"   "")
1175
              (match_operand:INTALL 1 "register_operand" "=d")
1176
              (match_operand:P 2 "register_operand" "=&a")])]
1177
  "TARGET_Z10"
1178
{
1179
  s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1180
  DONE;
1181
})
1182
 
1183
(define_expand "reload_toreg_z10"
1184
  [(parallel [(match_operand:INTALL 0 "register_operand" "=d")
1185
              (match_operand:INTALL 1 "memory_operand"   "")
1186
              (match_operand:P 2 "register_operand" "=a")])]
1187
  "TARGET_Z10"
1188
{
1189
  s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1190
  DONE;
1191
})
1192
 
1193
(define_expand "reload_tomem_z10"
1194
  [(parallel [(match_operand:FPALL 0 "memory_operand"   "")
1195
              (match_operand:FPALL 1 "register_operand" "=d")
1196
              (match_operand:P 2 "register_operand" "=&a")])]
1197
  "TARGET_Z10"
1198
{
1199
  s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1200
  DONE;
1201
})
1202
 
1203
(define_expand "reload_toreg_z10"
1204
  [(parallel [(match_operand:FPALL 0 "register_operand" "=d")
1205
              (match_operand:FPALL 1 "memory_operand"   "")
1206
              (match_operand:P 2 "register_operand" "=a")])]
1207
  "TARGET_Z10"
1208
{
1209
  s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1210
  DONE;
1211
})
1212
 
1213
(define_expand "reload_larl_odd_addend_z10"
1214
  [(parallel [(match_operand:P 0 "register_operand" "=d")
1215
              (match_operand:P 1 "larl_operand"     "")
1216
              (match_operand:P 2 "register_operand" "=a")])]
1217
  "TARGET_Z10"
1218
{
1219
  s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1220
  DONE;
1221
})
1222
 
1223
; Handles loading a PLUS (load address) expression
1224
 
1225
(define_expand "reload_plus"
1226
  [(parallel [(match_operand:P 0 "register_operand"  "=a")
1227
              (match_operand:P 1 "s390_plus_operand" "")
1228
              (match_operand:P 2 "register_operand"  "=&a")])]
1229
  ""
1230
{
1231
  s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1232
  DONE;
1233
})
1234
 
1235
; Handles assessing a non-offsetable memory address
1236
 
1237
(define_expand "reload_nonoffmem_in"
1238
  [(parallel [(match_operand 0   "register_operand" "")
1239
              (match_operand 1   "" "")
1240
              (match_operand:P 2 "register_operand" "=&a")])]
1241
  ""
1242
{
1243
  gcc_assert (MEM_P (operands[1]));
1244
  s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1245
  operands[1] = replace_equiv_address (operands[1], operands[2]);
1246
  emit_move_insn (operands[0], operands[1]);
1247
  DONE;
1248
})
1249
 
1250
(define_expand "reload_nonoffmem_out"
1251
  [(parallel [(match_operand   0 "" "")
1252
              (match_operand   1 "register_operand" "")
1253
              (match_operand:P 2 "register_operand" "=&a")])]
1254
  ""
1255
{
1256
  gcc_assert (MEM_P (operands[0]));
1257
  s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1258
  operands[0] = replace_equiv_address (operands[0], operands[2]);
1259
  emit_move_insn (operands[0], operands[1]);
1260
  DONE;
1261
})
1262
 
1263
(define_expand "reload_PIC_addr"
1264
  [(parallel [(match_operand   0 "register_operand" "=d")
1265
              (match_operand   1 "larl_operand"     "")
1266
              (match_operand:P 2 "register_operand" "=a")])]
1267
  ""
1268
{
1269
  rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1270
  emit_move_insn (operands[0], new_rtx);
1271
})
1272
 
1273
;
1274
; movdi instruction pattern(s).
1275
;
1276
 
1277
(define_expand "movdi"
1278
  [(set (match_operand:DI 0 "general_operand" "")
1279
        (match_operand:DI 1 "general_operand" ""))]
1280
  ""
1281
{
1282
  /* Handle symbolic constants.  */
1283
  if (TARGET_64BIT
1284
      && (SYMBOLIC_CONST (operands[1])
1285
          || (GET_CODE (operands[1]) == PLUS
1286
              && XEXP (operands[1], 0) == pic_offset_table_rtx
1287
              && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
1288
    emit_symbolic_move (operands);
1289
})
1290
 
1291
(define_insn "*movdi_larl"
1292
  [(set (match_operand:DI 0 "register_operand" "=d")
1293
        (match_operand:DI 1 "larl_operand" "X"))]
1294
  "TARGET_64BIT
1295
   && !FP_REG_P (operands[0])"
1296
  "larl\t%0,%1"
1297
   [(set_attr "op_type" "RIL")
1298
    (set_attr "type"    "larl")
1299
    (set_attr "z10prop" "z10_super_A1")])
1300
 
1301
(define_insn "*movdi_64"
1302
  [(set (match_operand:DI 0 "nonimmediate_operand"
1303
                            "=d,d,d,d,d,d,d,d,f,d,d,d,d,d,
1304
                             RT,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t")
1305
        (match_operand:DI 1 "general_operand"
1306
                            "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,RT,
1307
                             d,*f,R,T,*f,*f,d,K,t,d,t,Q"))]
1308
  "TARGET_64BIT"
1309
  "@
1310
   lghi\t%0,%h1
1311
   llihh\t%0,%i1
1312
   llihl\t%0,%i1
1313
   llilh\t%0,%i1
1314
   llill\t%0,%i1
1315
   lgfi\t%0,%1
1316
   llihf\t%0,%k1
1317
   llilf\t%0,%k1
1318
   ldgr\t%0,%1
1319
   lgdr\t%0,%1
1320
   lay\t%0,%a1
1321
   lgrl\t%0,%1
1322
   lgr\t%0,%1
1323
   lg\t%0,%1
1324
   stg\t%1,%0
1325
   ldr\t%0,%1
1326
   ld\t%0,%1
1327
   ldy\t%0,%1
1328
   std\t%1,%0
1329
   stdy\t%1,%0
1330
   stgrl\t%1,%0
1331
   mvghi\t%0,%1
1332
   #
1333
   #
1334
   stam\t%1,%N1,%S0
1335
   lam\t%0,%N0,%S1"
1336
  [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
1337
                        RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS")
1338
   (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
1339
                     floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,
1340
                     *,*")
1341
   (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
1342
                             z10,*,*,*,*,*,longdisp,*,longdisp,
1343
                             z10,z10,*,*,*,*")
1344
   (set_attr "z10prop" "z10_fwd_A1,
1345
                        z10_fwd_E1,
1346
                        z10_fwd_E1,
1347
                        z10_fwd_E1,
1348
                        z10_fwd_E1,
1349
                        z10_fwd_A1,
1350
                        z10_fwd_E1,
1351
                        z10_fwd_E1,
1352
                        *,
1353
                        *,
1354
                        z10_fwd_A1,
1355
                        z10_fwd_A3,
1356
                        z10_fr_E1,
1357
                        z10_fwd_A3,
1358
                        z10_rec,
1359
                        *,
1360
                        *,
1361
                        *,
1362
                        *,
1363
                        *,
1364
                        z10_rec,
1365
                        z10_super,
1366
                        *,
1367
                        *,
1368
                        *,
1369
                        *")
1370
])
1371
 
1372
(define_split
1373
  [(set (match_operand:DI 0 "register_operand" "")
1374
        (match_operand:DI 1 "register_operand" ""))]
1375
  "TARGET_64BIT && ACCESS_REG_P (operands[1])"
1376
  [(set (match_dup 2) (match_dup 3))
1377
   (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1378
   (set (strict_low_part (match_dup 2)) (match_dup 4))]
1379
  "operands[2] = gen_lowpart (SImode, operands[0]);
1380
   s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1381
 
1382
(define_split
1383
  [(set (match_operand:DI 0 "register_operand" "")
1384
        (match_operand:DI 1 "register_operand" ""))]
1385
  "TARGET_64BIT && ACCESS_REG_P (operands[0])
1386
   && dead_or_set_p (insn, operands[1])"
1387
  [(set (match_dup 3) (match_dup 2))
1388
   (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1389
   (set (match_dup 4) (match_dup 2))]
1390
  "operands[2] = gen_lowpart (SImode, operands[1]);
1391
   s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1392
 
1393
(define_split
1394
  [(set (match_operand:DI 0 "register_operand" "")
1395
        (match_operand:DI 1 "register_operand" ""))]
1396
  "TARGET_64BIT && ACCESS_REG_P (operands[0])
1397
   && !dead_or_set_p (insn, operands[1])"
1398
  [(set (match_dup 3) (match_dup 2))
1399
   (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1400
   (set (match_dup 4) (match_dup 2))
1401
   (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1402
  "operands[2] = gen_lowpart (SImode, operands[1]);
1403
   s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1404
 
1405
(define_insn "*movdi_31"
1406
  [(set (match_operand:DI 0 "nonimmediate_operand"
1407
                            "=d,d,Q,S,d   ,o,!*f,!*f,!*f,!R,!T,d")
1408
        (match_operand:DI 1 "general_operand"
1409
                            " Q,S,d,d,dPRT,d, *f,  R,  T,*f,*f,b"))]
1410
  "!TARGET_64BIT"
1411
  "@
1412
   lm\t%0,%N0,%S1
1413
   lmy\t%0,%N0,%S1
1414
   stm\t%1,%N1,%S0
1415
   stmy\t%1,%N1,%S0
1416
   #
1417
   #
1418
   ldr\t%0,%1
1419
   ld\t%0,%1
1420
   ldy\t%0,%1
1421
   std\t%1,%0
1422
   stdy\t%1,%0
1423
   #"
1424
  [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1425
   (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
1426
   (set_attr "cpu_facility" "*,*,*,*,*,*,*,*,*,*,*,z10")])
1427
 
1428
; For a load from a symbol ref we can use one of the target registers
1429
; together with larl to load the address.
1430
(define_split
1431
  [(set (match_operand:DI 0 "register_operand" "")
1432
        (match_operand:DI 1 "memory_operand" ""))]
1433
  "!TARGET_64BIT && reload_completed && TARGET_Z10
1434
   && larl_operand (XEXP (operands[1], 0), SImode)"
1435
  [(set (match_dup 2) (match_dup 3))
1436
   (set (match_dup 0) (match_dup 1))]
1437
{
1438
  operands[2] = operand_subword (operands[0], 1, 0, DImode);
1439
  operands[3] = XEXP (operands[1], 0);
1440
  operands[1] = replace_equiv_address (operands[1], operands[2]);
1441
})
1442
 
1443
(define_split
1444
  [(set (match_operand:DI 0 "nonimmediate_operand" "")
1445
        (match_operand:DI 1 "general_operand" ""))]
1446
  "!TARGET_64BIT && reload_completed
1447
   && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
1448
  [(set (match_dup 2) (match_dup 4))
1449
   (set (match_dup 3) (match_dup 5))]
1450
{
1451
  operands[2] = operand_subword (operands[0], 0, 0, DImode);
1452
  operands[3] = operand_subword (operands[0], 1, 0, DImode);
1453
  operands[4] = operand_subword (operands[1], 0, 0, DImode);
1454
  operands[5] = operand_subword (operands[1], 1, 0, DImode);
1455
})
1456
 
1457
(define_split
1458
  [(set (match_operand:DI 0 "nonimmediate_operand" "")
1459
        (match_operand:DI 1 "general_operand" ""))]
1460
  "!TARGET_64BIT && reload_completed
1461
   && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1462
  [(set (match_dup 2) (match_dup 4))
1463
   (set (match_dup 3) (match_dup 5))]
1464
{
1465
  operands[2] = operand_subword (operands[0], 1, 0, DImode);
1466
  operands[3] = operand_subword (operands[0], 0, 0, DImode);
1467
  operands[4] = operand_subword (operands[1], 1, 0, DImode);
1468
  operands[5] = operand_subword (operands[1], 0, 0, DImode);
1469
})
1470
 
1471
(define_split
1472
  [(set (match_operand:DI 0 "register_operand" "")
1473
        (match_operand:DI 1 "memory_operand" ""))]
1474
  "!TARGET_64BIT && reload_completed
1475
   && !FP_REG_P (operands[0])
1476
   && !s_operand (operands[1], VOIDmode)"
1477
  [(set (match_dup 0) (match_dup 1))]
1478
{
1479
  rtx addr = operand_subword (operands[0], 1, 0, DImode);
1480
  s390_load_address (addr, XEXP (operands[1], 0));
1481
  operands[1] = replace_equiv_address (operands[1], addr);
1482
})
1483
 
1484
(define_peephole2
1485
  [(set (match_operand:DI 0 "register_operand" "")
1486
        (mem:DI (match_operand 1 "address_operand" "")))]
1487
  "TARGET_64BIT
1488
   && !FP_REG_P (operands[0])
1489
   && GET_CODE (operands[1]) == SYMBOL_REF
1490
   && CONSTANT_POOL_ADDRESS_P (operands[1])
1491
   && get_pool_mode (operands[1]) == DImode
1492
   && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1493
  [(set (match_dup 0) (match_dup 2))]
1494
  "operands[2] = get_pool_constant (operands[1]);")
1495
 
1496
(define_insn "*la_64"
1497
  [(set (match_operand:DI 0 "register_operand" "=d,d")
1498
        (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))]
1499
  "TARGET_64BIT"
1500
  "@
1501
   la\t%0,%a1
1502
   lay\t%0,%a1"
1503
  [(set_attr "op_type" "RX,RXY")
1504
   (set_attr "type"    "la")
1505
   (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1506
 
1507
(define_peephole2
1508
  [(parallel
1509
    [(set (match_operand:DI 0 "register_operand" "")
1510
          (match_operand:QI 1 "address_operand" ""))
1511
     (clobber (reg:CC CC_REGNUM))])]
1512
  "TARGET_64BIT
1513
   && preferred_la_operand_p (operands[1], const0_rtx)"
1514
  [(set (match_dup 0) (match_dup 1))]
1515
  "")
1516
 
1517
(define_peephole2
1518
  [(set (match_operand:DI 0 "register_operand" "")
1519
        (match_operand:DI 1 "register_operand" ""))
1520
   (parallel
1521
    [(set (match_dup 0)
1522
          (plus:DI (match_dup 0)
1523
                   (match_operand:DI 2 "nonmemory_operand" "")))
1524
     (clobber (reg:CC CC_REGNUM))])]
1525
  "TARGET_64BIT
1526
   && !reg_overlap_mentioned_p (operands[0], operands[2])
1527
   && preferred_la_operand_p (operands[1], operands[2])"
1528
  [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1529
  "")
1530
 
1531
;
1532
; movsi instruction pattern(s).
1533
;
1534
 
1535
(define_expand "movsi"
1536
  [(set (match_operand:SI 0 "general_operand" "")
1537
        (match_operand:SI 1 "general_operand" ""))]
1538
  ""
1539
{
1540
  /* Handle symbolic constants.  */
1541
  if (!TARGET_64BIT
1542
      && (SYMBOLIC_CONST (operands[1])
1543
          || (GET_CODE (operands[1]) == PLUS
1544
              && XEXP (operands[1], 0) == pic_offset_table_rtx
1545
              && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
1546
    emit_symbolic_move (operands);
1547
})
1548
 
1549
(define_insn "*movsi_larl"
1550
  [(set (match_operand:SI 0 "register_operand" "=d")
1551
        (match_operand:SI 1 "larl_operand" "X"))]
1552
  "!TARGET_64BIT && TARGET_CPU_ZARCH
1553
   && !FP_REG_P (operands[0])"
1554
  "larl\t%0,%1"
1555
   [(set_attr "op_type" "RIL")
1556
    (set_attr "type"    "larl")
1557
    (set_attr "z10prop" "z10_fwd_A1")])
1558
 
1559
(define_insn "*movsi_zarch"
1560
  [(set (match_operand:SI 0 "nonimmediate_operand"
1561
                            "=d,d,d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,b,Q,t")
1562
        (match_operand:SI 1 "general_operand"
1563
                            "K,N0HS0,N1HS0,Os,L,b,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,d,K,Q"))]
1564
  "TARGET_ZARCH"
1565
  "@
1566
   lhi\t%0,%h1
1567
   llilh\t%0,%i1
1568
   llill\t%0,%i1
1569
   iilf\t%0,%o1
1570
   lay\t%0,%a1
1571
   lrl\t%0,%1
1572
   lr\t%0,%1
1573
   l\t%0,%1
1574
   ly\t%0,%1
1575
   st\t%1,%0
1576
   sty\t%1,%0
1577
   ler\t%0,%1
1578
   le\t%0,%1
1579
   ley\t%0,%1
1580
   ste\t%1,%0
1581
   stey\t%1,%0
1582
   ear\t%0,%1
1583
   sar\t%0,%1
1584
   stam\t%1,%1,%S0
1585
   strl\t%1,%0
1586
   mvhi\t%0,%1
1587
   lam\t%0,%0,%S1"
1588
  [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
1589
                        RR,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS")
1590
   (set_attr "type" "*,
1591
                     *,
1592
                     *,
1593
                     *,
1594
                     la,
1595
                     larl,
1596
                     lr,
1597
                     load,
1598
                     load,
1599
                     store,
1600
                     store,
1601
                     floadsf,
1602
                     floadsf,
1603
                     floadsf,
1604
                     fstoresf,
1605
                     fstoresf,
1606
                     *,
1607
                     *,
1608
                     *,
1609
                     larl,
1610
                     *,
1611
                     *")
1612
   (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
1613
                             *,*,longdisp,*,longdisp,*,*,*,z10,z10,*")
1614
   (set_attr "z10prop" "z10_fwd_A1,
1615
                        z10_fwd_E1,
1616
                        z10_fwd_E1,
1617
                        z10_fwd_A1,
1618
                        z10_fwd_A1,
1619
                        z10_fwd_A3,
1620
                        z10_fr_E1,
1621
                        z10_fwd_A3,
1622
                        z10_fwd_A3,
1623
                        z10_rec,
1624
                        z10_rec,
1625
                        *,
1626
                        *,
1627
                        *,
1628
                        *,
1629
                        *,
1630
                        z10_super_E1,
1631
                        z10_super,
1632
                        *,
1633
                        z10_rec,
1634
                        z10_super,
1635
                        *")])
1636
 
1637
(define_insn "*movsi_esa"
1638
  [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t")
1639
        (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q"))]
1640
  "!TARGET_ZARCH"
1641
  "@
1642
   lhi\t%0,%h1
1643
   lr\t%0,%1
1644
   l\t%0,%1
1645
   st\t%1,%0
1646
   ler\t%0,%1
1647
   le\t%0,%1
1648
   ste\t%1,%0
1649
   ear\t%0,%1
1650
   sar\t%0,%1
1651
   stam\t%1,%1,%S0
1652
   lam\t%0,%0,%S1"
1653
  [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS")
1654
   (set_attr "type" "*,lr,load,store,floadsf,floadsf,fstoresf,*,*,*,*")
1655
   (set_attr "z10prop" "z10_fwd_A1,
1656
                        z10_fr_E1,
1657
                        z10_fwd_A3,
1658
                        z10_rec,
1659
                        *,
1660
                        *,
1661
                        *,
1662
                        z10_super_E1,
1663
                        z10_super,
1664
                        *,
1665
                        *")
1666
])
1667
 
1668
(define_peephole2
1669
  [(set (match_operand:SI 0 "register_operand" "")
1670
        (mem:SI (match_operand 1 "address_operand" "")))]
1671
  "!FP_REG_P (operands[0])
1672
   && GET_CODE (operands[1]) == SYMBOL_REF
1673
   && CONSTANT_POOL_ADDRESS_P (operands[1])
1674
   && get_pool_mode (operands[1]) == SImode
1675
   && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1676
  [(set (match_dup 0) (match_dup 2))]
1677
  "operands[2] = get_pool_constant (operands[1]);")
1678
 
1679
(define_insn "*la_31"
1680
  [(set (match_operand:SI 0 "register_operand" "=d,d")
1681
        (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))]
1682
  "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1683
  "@
1684
   la\t%0,%a1
1685
   lay\t%0,%a1"
1686
  [(set_attr "op_type"  "RX,RXY")
1687
   (set_attr "type"     "la")
1688
   (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1689
 
1690
(define_peephole2
1691
  [(parallel
1692
    [(set (match_operand:SI 0 "register_operand" "")
1693
          (match_operand:QI 1 "address_operand" ""))
1694
     (clobber (reg:CC CC_REGNUM))])]
1695
  "!TARGET_64BIT
1696
   && preferred_la_operand_p (operands[1], const0_rtx)"
1697
  [(set (match_dup 0) (match_dup 1))]
1698
  "")
1699
 
1700
(define_peephole2
1701
  [(set (match_operand:SI 0 "register_operand" "")
1702
        (match_operand:SI 1 "register_operand" ""))
1703
   (parallel
1704
    [(set (match_dup 0)
1705
          (plus:SI (match_dup 0)
1706
                   (match_operand:SI 2 "nonmemory_operand" "")))
1707
     (clobber (reg:CC CC_REGNUM))])]
1708
  "!TARGET_64BIT
1709
   && !reg_overlap_mentioned_p (operands[0], operands[2])
1710
   && preferred_la_operand_p (operands[1], operands[2])"
1711
  [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1712
  "")
1713
 
1714
(define_insn "*la_31_and"
1715
  [(set (match_operand:SI 0 "register_operand" "=d,d")
1716
        (and:SI (match_operand:QI 1 "address_operand" "ZQZR,ZSZT")
1717
                (const_int 2147483647)))]
1718
  "!TARGET_64BIT"
1719
  "@
1720
   la\t%0,%a1
1721
   lay\t%0,%a1"
1722
  [(set_attr "op_type"  "RX,RXY")
1723
   (set_attr "type"     "la")
1724
   (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1725
 
1726
(define_insn_and_split "*la_31_and_cc"
1727
  [(set (match_operand:SI 0 "register_operand" "=d")
1728
        (and:SI (match_operand:QI 1 "address_operand" "p")
1729
                (const_int 2147483647)))
1730
   (clobber (reg:CC CC_REGNUM))]
1731
  "!TARGET_64BIT"
1732
  "#"
1733
  "&& reload_completed"
1734
  [(set (match_dup 0)
1735
        (and:SI (match_dup 1) (const_int 2147483647)))]
1736
  ""
1737
  [(set_attr "op_type"  "RX")
1738
   (set_attr "type"     "la")])
1739
 
1740
(define_insn "force_la_31"
1741
  [(set (match_operand:SI 0 "register_operand" "=d,d")
1742
        (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))
1743
   (use (const_int 0))]
1744
  "!TARGET_64BIT"
1745
  "@
1746
   la\t%0,%a1
1747
   lay\t%0,%a1"
1748
  [(set_attr "op_type"  "RX")
1749
   (set_attr "type"     "la")
1750
   (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1751
 
1752
;
1753
; movhi instruction pattern(s).
1754
;
1755
 
1756
(define_expand "movhi"
1757
  [(set (match_operand:HI 0 "nonimmediate_operand" "")
1758
        (match_operand:HI 1 "general_operand" ""))]
1759
  ""
1760
{
1761
  /* Make it explicit that loading a register from memory
1762
     always sign-extends (at least) to SImode.  */
1763
  if (optimize && can_create_pseudo_p ()
1764
      && register_operand (operands[0], VOIDmode)
1765
      && GET_CODE (operands[1]) == MEM)
1766
    {
1767
      rtx tmp = gen_reg_rtx (SImode);
1768
      rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1769
      emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1770
      operands[1] = gen_lowpart (HImode, tmp);
1771
    }
1772
})
1773
 
1774
(define_insn "*movhi"
1775
  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q")
1776
        (match_operand:HI 1 "general_operand"      " d,n,R,T,b,d,d,d,K"))]
1777
  ""
1778
  "@
1779
   lr\t%0,%1
1780
   lhi\t%0,%h1
1781
   lh\t%0,%1
1782
   lhy\t%0,%1
1783
   lhrl\t%0,%1
1784
   sth\t%1,%0
1785
   sthy\t%1,%0
1786
   sthrl\t%1,%0
1787
   mvhhi\t%0,%1"
1788
  [(set_attr "op_type"      "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL")
1789
   (set_attr "type"         "lr,*,*,*,larl,store,store,store,*")
1790
   (set_attr "cpu_facility" "*,*,*,*,z10,*,*,z10,z10")
1791
   (set_attr "z10prop" "z10_fr_E1,
1792
                       z10_fwd_A1,
1793
                       z10_super_E1,
1794
                       z10_super_E1,
1795
                       z10_super_E1,
1796
                       z10_rec,
1797
                       z10_rec,
1798
                       z10_rec,
1799
                       z10_super")])
1800
 
1801
(define_peephole2
1802
  [(set (match_operand:HI 0 "register_operand" "")
1803
        (mem:HI (match_operand 1 "address_operand" "")))]
1804
  "GET_CODE (operands[1]) == SYMBOL_REF
1805
   && CONSTANT_POOL_ADDRESS_P (operands[1])
1806
   && get_pool_mode (operands[1]) == HImode
1807
   && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1808
  [(set (match_dup 0) (match_dup 2))]
1809
  "operands[2] = get_pool_constant (operands[1]);")
1810
 
1811
;
1812
; movqi instruction pattern(s).
1813
;
1814
 
1815
(define_expand "movqi"
1816
  [(set (match_operand:QI 0 "nonimmediate_operand" "")
1817
        (match_operand:QI 1 "general_operand" ""))]
1818
  ""
1819
{
1820
  /* On z/Architecture, zero-extending from memory to register
1821
     is just as fast as a QImode load.  */
1822
  if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
1823
      && register_operand (operands[0], VOIDmode)
1824
      && GET_CODE (operands[1]) == MEM)
1825
    {
1826
      rtx tmp = gen_reg_rtx (word_mode);
1827
      rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
1828
      emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1829
      operands[1] = gen_lowpart (QImode, tmp);
1830
    }
1831
})
1832
 
1833
(define_insn "*movqi"
1834
  [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1835
        (match_operand:QI 1 "general_operand"      " d,n,R,T,d,d,n,n,?Q"))]
1836
  ""
1837
  "@
1838
   lr\t%0,%1
1839
   lhi\t%0,%b1
1840
   ic\t%0,%1
1841
   icy\t%0,%1
1842
   stc\t%1,%0
1843
   stcy\t%1,%0
1844
   mvi\t%S0,%b1
1845
   mviy\t%S0,%b1
1846
   #"
1847
  [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1848
   (set_attr "type" "lr,*,*,*,store,store,store,store,*")
1849
   (set_attr "z10prop" "z10_fr_E1,
1850
                        z10_fwd_A1,
1851
                        z10_super_E1,
1852
                        z10_super_E1,
1853
                        z10_rec,
1854
                        z10_rec,
1855
                        z10_super,
1856
                        z10_super,
1857
                        *")])
1858
 
1859
(define_peephole2
1860
  [(set (match_operand:QI 0 "nonimmediate_operand" "")
1861
        (mem:QI (match_operand 1 "address_operand" "")))]
1862
  "GET_CODE (operands[1]) == SYMBOL_REF
1863
   && CONSTANT_POOL_ADDRESS_P (operands[1])
1864
   && get_pool_mode (operands[1]) == QImode
1865
   && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1866
  [(set (match_dup 0) (match_dup 2))]
1867
  "operands[2] = get_pool_constant (operands[1]);")
1868
 
1869
;
1870
; movstrictqi instruction pattern(s).
1871
;
1872
 
1873
(define_insn "*movstrictqi"
1874
  [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1875
                         (match_operand:QI 1 "memory_operand" "R,T"))]
1876
  ""
1877
  "@
1878
   ic\t%0,%1
1879
   icy\t%0,%1"
1880
  [(set_attr "op_type"  "RX,RXY")
1881
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1882
 
1883
;
1884
; movstricthi instruction pattern(s).
1885
;
1886
 
1887
(define_insn "*movstricthi"
1888
  [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1889
                         (match_operand:HI 1 "memory_operand" "Q,S"))
1890
   (clobber (reg:CC CC_REGNUM))]
1891
  ""
1892
  "@
1893
   icm\t%0,3,%S1
1894
   icmy\t%0,3,%S1"
1895
  [(set_attr "op_type" "RS,RSY")
1896
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1897
 
1898
;
1899
; movstrictsi instruction pattern(s).
1900
;
1901
 
1902
(define_insn "movstrictsi"
1903
  [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1904
                         (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1905
  "TARGET_64BIT"
1906
  "@
1907
   lr\t%0,%1
1908
   l\t%0,%1
1909
   ly\t%0,%1
1910
   ear\t%0,%1"
1911
  [(set_attr "op_type" "RR,RX,RXY,RRE")
1912
   (set_attr "type" "lr,load,load,*")
1913
   (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
1914
 
1915
;
1916
; mov(tf|td) instruction pattern(s).
1917
;
1918
 
1919
(define_expand "mov"
1920
  [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1921
        (match_operand:TD_TF 1 "general_operand"      ""))]
1922
  ""
1923
  "")
1924
 
1925
(define_insn "*mov_64"
1926
  [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,o, d,QS,  d,o")
1927
        (match_operand:TD_TF 1 "general_operand"      " f,o,f,QS, d,dRT,d"))]
1928
  "TARGET_64BIT"
1929
  "@
1930
   lxr\t%0,%1
1931
   #
1932
   #
1933
   lmg\t%0,%N0,%S1
1934
   stmg\t%1,%N1,%S0
1935
   #
1936
   #"
1937
  [(set_attr "op_type" "RRE,*,*,RSY,RSY,*,*")
1938
   (set_attr "type"    "fsimptf,*,*,lm,stm,*,*")])
1939
 
1940
(define_insn "*mov_31"
1941
  [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,o")
1942
        (match_operand:TD_TF 1 "general_operand"      " f,o,f"))]
1943
  "!TARGET_64BIT"
1944
  "@
1945
   lxr\t%0,%1
1946
   #
1947
   #"
1948
  [(set_attr "op_type" "RRE,*,*")
1949
   (set_attr "type"    "fsimptf,*,*")])
1950
 
1951
; TFmode in GPRs splitters
1952
 
1953
(define_split
1954
  [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1955
        (match_operand:TD_TF 1 "general_operand"      ""))]
1956
  "TARGET_64BIT && reload_completed
1957
   && s390_split_ok_p (operands[0], operands[1], mode, 0)"
1958
  [(set (match_dup 2) (match_dup 4))
1959
   (set (match_dup 3) (match_dup 5))]
1960
{
1961
  operands[2] = operand_subword (operands[0], 0, 0, mode);
1962
  operands[3] = operand_subword (operands[0], 1, 0, mode);
1963
  operands[4] = operand_subword (operands[1], 0, 0, mode);
1964
  operands[5] = operand_subword (operands[1], 1, 0, mode);
1965
})
1966
 
1967
(define_split
1968
  [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1969
        (match_operand:TD_TF 1 "general_operand"      ""))]
1970
  "TARGET_64BIT && reload_completed
1971
   && s390_split_ok_p (operands[0], operands[1], mode, 1)"
1972
  [(set (match_dup 2) (match_dup 4))
1973
   (set (match_dup 3) (match_dup 5))]
1974
{
1975
  operands[2] = operand_subword (operands[0], 1, 0, mode);
1976
  operands[3] = operand_subword (operands[0], 0, 0, mode);
1977
  operands[4] = operand_subword (operands[1], 1, 0, mode);
1978
  operands[5] = operand_subword (operands[1], 0, 0, mode);
1979
})
1980
 
1981
(define_split
1982
  [(set (match_operand:TD_TF 0 "register_operand" "")
1983
        (match_operand:TD_TF 1 "memory_operand"   ""))]
1984
  "TARGET_64BIT && reload_completed
1985
   && !FP_REG_P (operands[0])
1986
   && !s_operand (operands[1], VOIDmode)"
1987
  [(set (match_dup 0) (match_dup 1))]
1988
{
1989
  rtx addr = operand_subword (operands[0], 1, 0, mode);
1990
  s390_load_address (addr, XEXP (operands[1], 0));
1991
  operands[1] = replace_equiv_address (operands[1], addr);
1992
})
1993
 
1994
; TFmode in BFPs splitters
1995
 
1996
(define_split
1997
  [(set (match_operand:TD_TF 0 "register_operand" "")
1998
        (match_operand:TD_TF 1 "memory_operand" ""))]
1999
  "reload_completed && offsettable_memref_p (operands[1])
2000
   && FP_REG_P (operands[0])"
2001
  [(set (match_dup 2) (match_dup 4))
2002
   (set (match_dup 3) (match_dup 5))]
2003
{
2004
  operands[2] = simplify_gen_subreg (mode, operands[0],
2005
                                     mode, 0);
2006
  operands[3] = simplify_gen_subreg (mode, operands[0],
2007
                                     mode, 8);
2008
  operands[4] = adjust_address_nv (operands[1], mode, 0);
2009
  operands[5] = adjust_address_nv (operands[1], mode, 8);
2010
})
2011
 
2012
(define_split
2013
  [(set (match_operand:TD_TF 0 "memory_operand" "")
2014
        (match_operand:TD_TF 1 "register_operand" ""))]
2015
  "reload_completed && offsettable_memref_p (operands[0])
2016
   && FP_REG_P (operands[1])"
2017
  [(set (match_dup 2) (match_dup 4))
2018
   (set (match_dup 3) (match_dup 5))]
2019
{
2020
  operands[2] = adjust_address_nv (operands[0], mode, 0);
2021
  operands[3] = adjust_address_nv (operands[0], mode, 8);
2022
  operands[4] = simplify_gen_subreg (mode, operands[1],
2023
                                     mode, 0);
2024
  operands[5] = simplify_gen_subreg (mode, operands[1],
2025
                                     mode, 8);
2026
})
2027
 
2028
;
2029
; mov(df|dd) instruction pattern(s).
2030
;
2031
 
2032
(define_expand "mov"
2033
  [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2034
        (match_operand:DD_DF 1 "general_operand"  ""))]
2035
  ""
2036
  "")
2037
 
2038
(define_insn "*mov_64dfp"
2039
  [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2040
                               "=f,f,d,f,f,R,T,d, d,RT")
2041
        (match_operand:DD_DF 1 "general_operand"
2042
                               " f,d,f,R,T,f,f,d,RT, d"))]
2043
  "TARGET_64BIT && TARGET_DFP"
2044
  "@
2045
   ldr\t%0,%1
2046
   ldgr\t%0,%1
2047
   lgdr\t%0,%1
2048
   ld\t%0,%1
2049
   ldy\t%0,%1
2050
   std\t%1,%0
2051
   stdy\t%1,%0
2052
   lgr\t%0,%1
2053
   lg\t%0,%1
2054
   stg\t%1,%0"
2055
  [(set_attr "op_type" "RR,RRE,RRE,RX,RXY,RX,RXY,RRE,RXY,RXY")
2056
   (set_attr "type" "floaddf,floaddf,floaddf,floaddf,floaddf,
2057
                     fstoredf,fstoredf,lr,load,store")
2058
   (set_attr "z10prop" "*,*,*,*,*,*,*,z10_fr_E1,z10_fwd_A3,z10_rec")
2059
])
2060
 
2061
(define_insn "*mov_64"
2062
  [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,R,T,d, d,RT")
2063
        (match_operand:DD_DF 1 "general_operand"       "f,R,T,f,f,d,RT, d"))]
2064
  "TARGET_64BIT"
2065
  "@
2066
   ldr\t%0,%1
2067
   ld\t%0,%1
2068
   ldy\t%0,%1
2069
   std\t%1,%0
2070
   stdy\t%1,%0
2071
   lgr\t%0,%1
2072
   lg\t%0,%1
2073
   stg\t%1,%0"
2074
  [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RRE,RXY,RXY")
2075
   (set_attr "type" "fload,fload,fload,
2076
                     fstore,fstore,lr,load,store")
2077
   (set_attr "z10prop" "*,*,*,*,*,z10_fr_E1,z10_fwd_A3,z10_rec")])
2078
 
2079
(define_insn "*mov_31"
2080
  [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2081
                               "=f,f,f,R,T,d,d,Q,S,   d,o")
2082
        (match_operand:DD_DF 1 "general_operand"
2083
                               " f,R,T,f,f,Q,S,d,d,dPRT,d"))]
2084
  "!TARGET_64BIT"
2085
  "@
2086
   ldr\t%0,%1
2087
   ld\t%0,%1
2088
   ldy\t%0,%1
2089
   std\t%1,%0
2090
   stdy\t%1,%0
2091
   lm\t%0,%N0,%S1
2092
   lmy\t%0,%N0,%S1
2093
   stm\t%1,%N1,%S0
2094
   stmy\t%1,%N1,%S0
2095
   #
2096
   #"
2097
  [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2098
   (set_attr "type" "fload,fload,fload,
2099
                     fstore,fstore,lm,lm,stm,stm,*,*")])
2100
 
2101
(define_split
2102
  [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2103
        (match_operand:DD_DF 1 "general_operand" ""))]
2104
  "!TARGET_64BIT && reload_completed
2105
   && s390_split_ok_p (operands[0], operands[1], mode, 0)"
2106
  [(set (match_dup 2) (match_dup 4))
2107
   (set (match_dup 3) (match_dup 5))]
2108
{
2109
  operands[2] = operand_subword (operands[0], 0, 0, mode);
2110
  operands[3] = operand_subword (operands[0], 1, 0, mode);
2111
  operands[4] = operand_subword (operands[1], 0, 0, mode);
2112
  operands[5] = operand_subword (operands[1], 1, 0, mode);
2113
})
2114
 
2115
(define_split
2116
  [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2117
        (match_operand:DD_DF 1 "general_operand" ""))]
2118
  "!TARGET_64BIT && reload_completed
2119
   && s390_split_ok_p (operands[0], operands[1], mode, 1)"
2120
  [(set (match_dup 2) (match_dup 4))
2121
   (set (match_dup 3) (match_dup 5))]
2122
{
2123
  operands[2] = operand_subword (operands[0], 1, 0, mode);
2124
  operands[3] = operand_subword (operands[0], 0, 0, mode);
2125
  operands[4] = operand_subword (operands[1], 1, 0, mode);
2126
  operands[5] = operand_subword (operands[1], 0, 0, mode);
2127
})
2128
 
2129
(define_split
2130
  [(set (match_operand:DD_DF 0 "register_operand" "")
2131
        (match_operand:DD_DF 1 "memory_operand" ""))]
2132
  "!TARGET_64BIT && reload_completed
2133
   && !FP_REG_P (operands[0])
2134
   && !s_operand (operands[1], VOIDmode)"
2135
  [(set (match_dup 0) (match_dup 1))]
2136
{
2137
  rtx addr = operand_subword (operands[0], 1, 0, mode);
2138
  s390_load_address (addr, XEXP (operands[1], 0));
2139
  operands[1] = replace_equiv_address (operands[1], addr);
2140
})
2141
 
2142
;
2143
; mov(sf|sd) instruction pattern(s).
2144
;
2145
 
2146
(define_insn "mov"
2147
  [(set (match_operand:SD_SF 0 "nonimmediate_operand"
2148
                               "=f,f,f,R,T,d,d,d,R,T")
2149
        (match_operand:SD_SF 1 "general_operand"
2150
                               " f,R,T,f,f,d,R,T,d,d"))]
2151
  ""
2152
  "@
2153
   ler\t%0,%1
2154
   le\t%0,%1
2155
   ley\t%0,%1
2156
   ste\t%1,%0
2157
   stey\t%1,%0
2158
   lr\t%0,%1
2159
   l\t%0,%1
2160
   ly\t%0,%1
2161
   st\t%1,%0
2162
   sty\t%1,%0"
2163
  [(set_attr "op_type" "RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY")
2164
   (set_attr "type" "fload,fload,fload,
2165
                     fstore,fstore,lr,load,load,store,store")
2166
   (set_attr "z10prop" "*,*,*,*,*,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")])
2167
 
2168
;
2169
; movcc instruction pattern
2170
;
2171
 
2172
(define_insn "movcc"
2173
  [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
2174
        (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
2175
  ""
2176
  "@
2177
   lr\t%0,%1
2178
   tmh\t%1,12288
2179
   ipm\t%0
2180
   st\t%0,%1
2181
   sty\t%0,%1
2182
   l\t%1,%0
2183
   ly\t%1,%0"
2184
  [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
2185
   (set_attr "type" "lr,*,*,store,store,load,load")
2186
   (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_rec,z10_rec,z10_fwd_A3,z10_fwd_A3")])
2187
 
2188
;
2189
; Block move (MVC) patterns.
2190
;
2191
 
2192
(define_insn "*mvc"
2193
  [(set (match_operand:BLK 0 "memory_operand" "=Q")
2194
        (match_operand:BLK 1 "memory_operand" "Q"))
2195
   (use (match_operand 2 "const_int_operand" "n"))]
2196
  "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
2197
  "mvc\t%O0(%2,%R0),%S1"
2198
  [(set_attr "op_type" "SS")])
2199
 
2200
; This splitter converts a QI to QI mode copy into a BLK mode copy in
2201
; order to have it implemented with mvc.
2202
 
2203
(define_split
2204
  [(set (match_operand:QI 0 "memory_operand" "")
2205
        (match_operand:QI 1 "memory_operand" ""))]
2206
  "reload_completed"
2207
  [(parallel
2208
    [(set (match_dup 0) (match_dup 1))
2209
     (use (const_int 1))])]
2210
{
2211
  operands[0] = adjust_address (operands[0], BLKmode, 0);
2212
  operands[1] = adjust_address (operands[1], BLKmode, 0);
2213
})
2214
 
2215
 
2216
(define_peephole2
2217
  [(parallel
2218
    [(set (match_operand:BLK 0 "memory_operand" "")
2219
          (match_operand:BLK 1 "memory_operand" ""))
2220
     (use (match_operand 2 "const_int_operand" ""))])
2221
   (parallel
2222
    [(set (match_operand:BLK 3 "memory_operand" "")
2223
          (match_operand:BLK 4 "memory_operand" ""))
2224
     (use (match_operand 5 "const_int_operand" ""))])]
2225
  "s390_offset_p (operands[0], operands[3], operands[2])
2226
   && s390_offset_p (operands[1], operands[4], operands[2])
2227
   && !s390_overlap_p (operands[0], operands[1],
2228
                       INTVAL (operands[2]) + INTVAL (operands[5]))
2229
   && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2230
  [(parallel
2231
    [(set (match_dup 6) (match_dup 7))
2232
     (use (match_dup 8))])]
2233
  "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2234
   operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2235
   operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2236
 
2237
 
2238
;
2239
; load_multiple pattern(s).
2240
;
2241
; ??? Due to reload problems with replacing registers inside match_parallel
2242
; we currently support load_multiple/store_multiple only after reload.
2243
;
2244
 
2245
(define_expand "load_multiple"
2246
  [(match_par_dup 3 [(set (match_operand 0 "" "")
2247
                          (match_operand 1 "" ""))
2248
                     (use (match_operand 2 "" ""))])]
2249
  "reload_completed"
2250
{
2251
  enum machine_mode mode;
2252
  int regno;
2253
  int count;
2254
  rtx from;
2255
  int i, off;
2256
 
2257
  /* Support only loading a constant number of fixed-point registers from
2258
     memory and only bother with this if more than two */
2259
  if (GET_CODE (operands[2]) != CONST_INT
2260
      || INTVAL (operands[2]) < 2
2261
      || INTVAL (operands[2]) > 16
2262
      || GET_CODE (operands[1]) != MEM
2263
      || GET_CODE (operands[0]) != REG
2264
      || REGNO (operands[0]) >= 16)
2265
    FAIL;
2266
 
2267
  count = INTVAL (operands[2]);
2268
  regno = REGNO (operands[0]);
2269
  mode = GET_MODE (operands[0]);
2270
  if (mode != SImode && mode != word_mode)
2271
    FAIL;
2272
 
2273
  operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2274
  if (!can_create_pseudo_p ())
2275
    {
2276
      if (GET_CODE (XEXP (operands[1], 0)) == REG)
2277
        {
2278
          from = XEXP (operands[1], 0);
2279
          off = 0;
2280
        }
2281
      else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2282
               && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2283
               && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2284
        {
2285
          from = XEXP (XEXP (operands[1], 0), 0);
2286
          off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2287
        }
2288
      else
2289
        FAIL;
2290
    }
2291
  else
2292
    {
2293
      from = force_reg (Pmode, XEXP (operands[1], 0));
2294
      off = 0;
2295
    }
2296
 
2297
  for (i = 0; i < count; i++)
2298
    XVECEXP (operands[3], 0, i)
2299
      = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
2300
                     change_address (operands[1], mode,
2301
                       plus_constant (from, off + i * GET_MODE_SIZE (mode))));
2302
})
2303
 
2304
(define_insn "*load_multiple_di"
2305
  [(match_parallel 0 "load_multiple_operation"
2306
                   [(set (match_operand:DI 1 "register_operand" "=r")
2307
                         (match_operand:DI 2 "s_operand" "QS"))])]
2308
  "reload_completed && word_mode == DImode"
2309
{
2310
  int words = XVECLEN (operands[0], 0);
2311
  operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
2312
  return "lmg\t%1,%0,%S2";
2313
}
2314
   [(set_attr "op_type" "RSY")
2315
    (set_attr "type"    "lm")])
2316
 
2317
(define_insn "*load_multiple_si"
2318
  [(match_parallel 0 "load_multiple_operation"
2319
                   [(set (match_operand:SI 1 "register_operand" "=r,r")
2320
                         (match_operand:SI 2 "s_operand" "Q,S"))])]
2321
  "reload_completed"
2322
{
2323
  int words = XVECLEN (operands[0], 0);
2324
  operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
2325
  return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
2326
}
2327
   [(set_attr "op_type" "RS,RSY")
2328
    (set_attr "type"    "lm")])
2329
 
2330
;
2331
; store multiple pattern(s).
2332
;
2333
 
2334
(define_expand "store_multiple"
2335
  [(match_par_dup 3 [(set (match_operand 0 "" "")
2336
                          (match_operand 1 "" ""))
2337
                     (use (match_operand 2 "" ""))])]
2338
  "reload_completed"
2339
{
2340
  enum machine_mode mode;
2341
  int regno;
2342
  int count;
2343
  rtx to;
2344
  int i, off;
2345
 
2346
  /* Support only storing a constant number of fixed-point registers to
2347
     memory and only bother with this if more than two.  */
2348
  if (GET_CODE (operands[2]) != CONST_INT
2349
      || INTVAL (operands[2]) < 2
2350
      || INTVAL (operands[2]) > 16
2351
      || GET_CODE (operands[0]) != MEM
2352
      || GET_CODE (operands[1]) != REG
2353
      || REGNO (operands[1]) >= 16)
2354
    FAIL;
2355
 
2356
  count = INTVAL (operands[2]);
2357
  regno = REGNO (operands[1]);
2358
  mode = GET_MODE (operands[1]);
2359
  if (mode != SImode && mode != word_mode)
2360
    FAIL;
2361
 
2362
  operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2363
 
2364
  if (!can_create_pseudo_p ())
2365
    {
2366
      if (GET_CODE (XEXP (operands[0], 0)) == REG)
2367
        {
2368
          to = XEXP (operands[0], 0);
2369
          off = 0;
2370
        }
2371
      else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2372
               && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2373
               && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2374
        {
2375
          to = XEXP (XEXP (operands[0], 0), 0);
2376
          off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2377
        }
2378
      else
2379
        FAIL;
2380
    }
2381
  else
2382
    {
2383
      to = force_reg (Pmode, XEXP (operands[0], 0));
2384
      off = 0;
2385
    }
2386
 
2387
  for (i = 0; i < count; i++)
2388
    XVECEXP (operands[3], 0, i)
2389
      = gen_rtx_SET (VOIDmode,
2390
                     change_address (operands[0], mode,
2391
                       plus_constant (to, off + i * GET_MODE_SIZE (mode))),
2392
                     gen_rtx_REG (mode, regno + i));
2393
})
2394
 
2395
(define_insn "*store_multiple_di"
2396
  [(match_parallel 0 "store_multiple_operation"
2397
                   [(set (match_operand:DI 1 "s_operand" "=QS")
2398
                         (match_operand:DI 2 "register_operand" "r"))])]
2399
  "reload_completed && word_mode == DImode"
2400
{
2401
  int words = XVECLEN (operands[0], 0);
2402
  operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
2403
  return "stmg\t%2,%0,%S1";
2404
}
2405
   [(set_attr "op_type" "RSY")
2406
    (set_attr "type"    "stm")])
2407
 
2408
 
2409
(define_insn "*store_multiple_si"
2410
  [(match_parallel 0 "store_multiple_operation"
2411
                   [(set (match_operand:SI 1 "s_operand" "=Q,S")
2412
                         (match_operand:SI 2 "register_operand" "r,r"))])]
2413
  "reload_completed"
2414
{
2415
  int words = XVECLEN (operands[0], 0);
2416
  operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
2417
  return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
2418
}
2419
   [(set_attr "op_type" "RS,RSY")
2420
    (set_attr "type"    "stm")])
2421
 
2422
;;
2423
;; String instructions.
2424
;;
2425
 
2426
(define_insn "*execute_rl"
2427
  [(match_parallel 0 ""
2428
    [(unspec [(match_operand 1    "register_operand" "a")
2429
              (match_operand 2    "" "")
2430
              (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2431
  "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2432
   && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2433
  "exrl\t%1,%3"
2434
  [(set_attr "op_type" "RIL")
2435
   (set_attr "type"    "cs")])
2436
 
2437
(define_insn "*execute"
2438
  [(match_parallel 0 ""
2439
    [(unspec [(match_operand 1 "register_operand" "a")
2440
              (match_operand:BLK 2 "memory_operand" "R")
2441
              (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2442
  "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2443
   && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2444
  "ex\t%1,%2"
2445
  [(set_attr "op_type" "RX")
2446
   (set_attr "type" "cs")])
2447
 
2448
 
2449
;
2450
; strlenM instruction pattern(s).
2451
;
2452
 
2453
(define_expand "strlen"
2454
  [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2455
   (parallel
2456
    [(set (match_dup 4)
2457
          (unspec:P [(const_int 0)
2458
                      (match_operand:BLK 1 "memory_operand" "")
2459
                      (reg:SI 0)
2460
                      (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
2461
     (clobber (scratch:P))
2462
     (clobber (reg:CC CC_REGNUM))])
2463
   (parallel
2464
    [(set (match_operand:P 0 "register_operand" "")
2465
          (minus:P (match_dup 4) (match_dup 5)))
2466
     (clobber (reg:CC CC_REGNUM))])]
2467
  ""
2468
{
2469
  operands[4] = gen_reg_rtx (Pmode);
2470
  operands[5] = gen_reg_rtx (Pmode);
2471
  emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2472
  operands[1] = replace_equiv_address (operands[1], operands[5]);
2473
})
2474
 
2475
(define_insn "*strlen"
2476
  [(set (match_operand:P 0 "register_operand" "=a")
2477
        (unspec:P [(match_operand:P 2 "general_operand" "0")
2478
                    (mem:BLK (match_operand:P 3 "register_operand" "1"))
2479
                    (reg:SI 0)
2480
                    (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
2481
   (clobber (match_scratch:P 1 "=a"))
2482
   (clobber (reg:CC CC_REGNUM))]
2483
  ""
2484
  "srst\t%0,%1\;jo\t.-4"
2485
  [(set_attr "length" "8")
2486
   (set_attr "type" "vs")])
2487
 
2488
;
2489
; cmpstrM instruction pattern(s).
2490
;
2491
 
2492
(define_expand "cmpstrsi"
2493
  [(set (reg:SI 0) (const_int 0))
2494
   (parallel
2495
    [(clobber (match_operand 3 "" ""))
2496
     (clobber (match_dup 4))
2497
     (set (reg:CCU CC_REGNUM)
2498
          (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2499
                       (match_operand:BLK 2 "memory_operand" "")))
2500
     (use (reg:SI 0))])
2501
   (parallel
2502
    [(set (match_operand:SI 0 "register_operand" "=d")
2503
          (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_CCU_TO_INT))
2504
     (clobber (reg:CC CC_REGNUM))])]
2505
  ""
2506
{
2507
  /* As the result of CMPINT is inverted compared to what we need,
2508
     we have to swap the operands.  */
2509
  rtx op1 = operands[2];
2510
  rtx op2 = operands[1];
2511
  rtx addr1 = gen_reg_rtx (Pmode);
2512
  rtx addr2 = gen_reg_rtx (Pmode);
2513
 
2514
  emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2515
  emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2516
  operands[1] = replace_equiv_address_nv (op1, addr1);
2517
  operands[2] = replace_equiv_address_nv (op2, addr2);
2518
  operands[3] = addr1;
2519
  operands[4] = addr2;
2520
})
2521
 
2522
(define_insn "*cmpstr"
2523
  [(clobber (match_operand:P 0 "register_operand" "=d"))
2524
   (clobber (match_operand:P 1 "register_operand" "=d"))
2525
   (set (reg:CCU CC_REGNUM)
2526
        (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2527
                     (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2528
   (use (reg:SI 0))]
2529
  ""
2530
  "clst\t%0,%1\;jo\t.-4"
2531
  [(set_attr "length" "8")
2532
   (set_attr "type" "vs")])
2533
 
2534
;
2535
; movstr instruction pattern.
2536
;
2537
 
2538
(define_expand "movstr"
2539
  [(set (reg:SI 0) (const_int 0))
2540
   (parallel
2541
    [(clobber (match_dup 3))
2542
     (set (match_operand:BLK 1 "memory_operand" "")
2543
          (match_operand:BLK 2 "memory_operand" ""))
2544
     (set (match_operand 0 "register_operand" "")
2545
          (unspec [(match_dup 1)
2546
                   (match_dup 2)
2547
                   (reg:SI 0)] UNSPEC_MVST))
2548
     (clobber (reg:CC CC_REGNUM))])]
2549
  ""
2550
{
2551
  rtx addr1 = gen_reg_rtx (Pmode);
2552
  rtx addr2 = gen_reg_rtx (Pmode);
2553
 
2554
  emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2555
  emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
2556
  operands[1] = replace_equiv_address_nv (operands[1], addr1);
2557
  operands[2] = replace_equiv_address_nv (operands[2], addr2);
2558
  operands[3] = addr2;
2559
})
2560
 
2561
(define_insn "*movstr"
2562
  [(clobber (match_operand:P 2 "register_operand" "=d"))
2563
   (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
2564
        (mem:BLK (match_operand:P 3 "register_operand" "2")))
2565
   (set (match_operand:P 0 "register_operand" "=d")
2566
        (unspec [(mem:BLK (match_dup 1))
2567
                 (mem:BLK (match_dup 3))
2568
                 (reg:SI 0)] UNSPEC_MVST))
2569
   (clobber (reg:CC CC_REGNUM))]
2570
  ""
2571
  "mvst\t%1,%2\;jo\t.-4"
2572
  [(set_attr "length" "8")
2573
   (set_attr "type" "vs")])
2574
 
2575
 
2576
;
2577
; movmemM instruction pattern(s).
2578
;
2579
 
2580
(define_expand "movmem"
2581
  [(set (match_operand:BLK 0 "memory_operand" "")   ; destination
2582
        (match_operand:BLK 1 "memory_operand" ""))  ; source
2583
   (use (match_operand:GPR 2 "general_operand" "")) ; count
2584
   (match_operand 3 "" "")]
2585
  ""
2586
  "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
2587
 
2588
; Move a block that is up to 256 bytes in length.
2589
; The block length is taken as (operands[2] % 256) + 1.
2590
 
2591
(define_expand "movmem_short"
2592
  [(parallel
2593
    [(set (match_operand:BLK 0 "memory_operand" "")
2594
          (match_operand:BLK 1 "memory_operand" ""))
2595
     (use (match_operand 2 "nonmemory_operand" ""))
2596
     (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2597
     (clobber (match_dup 3))])]
2598
  ""
2599
  "operands[3] = gen_rtx_SCRATCH (Pmode);")
2600
 
2601
(define_insn "*movmem_short"
2602
  [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2603
        (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
2604
   (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2605
   (use (match_operand 3 "immediate_operand" "X,R,X,X"))
2606
   (clobber (match_scratch 4 "=X,X,X,&a"))]
2607
  "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2608
   && GET_MODE (operands[4]) == Pmode"
2609
  "#"
2610
  [(set_attr "type"         "cs")
2611
   (set_attr "cpu_facility" "*,*,z10,*")])
2612
 
2613
(define_split
2614
  [(set (match_operand:BLK 0 "memory_operand" "")
2615
        (match_operand:BLK 1 "memory_operand" ""))
2616
   (use (match_operand 2 "const_int_operand" ""))
2617
   (use (match_operand 3 "immediate_operand" ""))
2618
   (clobber (scratch))]
2619
  "reload_completed"
2620
  [(parallel
2621
    [(set (match_dup 0) (match_dup 1))
2622
     (use (match_dup 2))])]
2623
  "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2624
 
2625
(define_split
2626
  [(set (match_operand:BLK 0 "memory_operand" "")
2627
        (match_operand:BLK 1 "memory_operand" ""))
2628
   (use (match_operand 2 "register_operand" ""))
2629
   (use (match_operand 3 "memory_operand" ""))
2630
   (clobber (scratch))]
2631
  "reload_completed"
2632
  [(parallel
2633
    [(unspec [(match_dup 2) (match_dup 3)
2634
              (const_int 0)] UNSPEC_EXECUTE)
2635
     (set (match_dup 0) (match_dup 1))
2636
     (use (const_int 1))])]
2637
  "")
2638
 
2639
(define_split
2640
  [(set (match_operand:BLK 0 "memory_operand" "")
2641
        (match_operand:BLK 1 "memory_operand" ""))
2642
   (use (match_operand 2 "register_operand" ""))
2643
   (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2644
   (clobber (scratch))]
2645
  "TARGET_Z10 && reload_completed"
2646
  [(parallel
2647
    [(unspec [(match_dup 2) (const_int 0)
2648
              (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2649
     (set (match_dup 0) (match_dup 1))
2650
     (use (const_int 1))])]
2651
  "operands[3] = gen_label_rtx ();")
2652
 
2653
(define_split
2654
  [(set (match_operand:BLK 0 "memory_operand" "")
2655
        (match_operand:BLK 1 "memory_operand" ""))
2656
   (use (match_operand 2 "register_operand" ""))
2657
   (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2658
   (clobber (match_operand 3 "register_operand" ""))]
2659
  "reload_completed && TARGET_CPU_ZARCH"
2660
  [(set (match_dup 3) (label_ref (match_dup 4)))
2661
   (parallel
2662
    [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2663
              (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2664
     (set (match_dup 0) (match_dup 1))
2665
     (use (const_int 1))])]
2666
  "operands[4] = gen_label_rtx ();")
2667
 
2668
; Move a block of arbitrary length.
2669
 
2670
(define_expand "movmem_long"
2671
  [(parallel
2672
    [(clobber (match_dup 2))
2673
     (clobber (match_dup 3))
2674
     (set (match_operand:BLK 0 "memory_operand" "")
2675
          (match_operand:BLK 1 "memory_operand" ""))
2676
     (use (match_operand 2 "general_operand" ""))
2677
     (use (match_dup 3))
2678
     (clobber (reg:CC CC_REGNUM))])]
2679
  ""
2680
{
2681
  enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2682
  rtx reg0 = gen_reg_rtx (dword_mode);
2683
  rtx reg1 = gen_reg_rtx (dword_mode);
2684
  rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2685
  rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2686
  rtx len0 = gen_lowpart (Pmode, reg0);
2687
  rtx len1 = gen_lowpart (Pmode, reg1);
2688
 
2689
  emit_clobber (reg0);
2690
  emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2691
  emit_move_insn (len0, operands[2]);
2692
 
2693
  emit_clobber (reg1);
2694
  emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2695
  emit_move_insn (len1, operands[2]);
2696
 
2697
  operands[0] = replace_equiv_address_nv (operands[0], addr0);
2698
  operands[1] = replace_equiv_address_nv (operands[1], addr1);
2699
  operands[2] = reg0;
2700
  operands[3] = reg1;
2701
})
2702
 
2703
(define_insn "*movmem_long"
2704
  [(clobber (match_operand: 0 "register_operand" "=d"))
2705
   (clobber (match_operand: 1 "register_operand" "=d"))
2706
   (set (mem:BLK (subreg:P (match_operand: 2 "register_operand" "0") 0))
2707
        (mem:BLK (subreg:P (match_operand: 3 "register_operand" "1") 0)))
2708
   (use (match_dup 2))
2709
   (use (match_dup 3))
2710
   (clobber (reg:CC CC_REGNUM))]
2711
  ""
2712
  "mvcle\t%0,%1,0\;jo\t.-4"
2713
  [(set_attr "length" "8")
2714
   (set_attr "type" "vs")])
2715
 
2716
 
2717
;
2718
; Test data class.
2719
;
2720
 
2721
(define_expand "signbit2"
2722
  [(set (reg:CCZ CC_REGNUM)
2723
        (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2724
                     (match_dup 2)]
2725
                     UNSPEC_TDC_INSN))
2726
   (set (match_operand:SI 0 "register_operand" "=d")
2727
        (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2728
  "TARGET_HARD_FLOAT"
2729
{
2730
  operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
2731
})
2732
 
2733
(define_expand "isinf2"
2734
  [(set (reg:CCZ CC_REGNUM)
2735
        (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2736
                     (match_dup 2)]
2737
                     UNSPEC_TDC_INSN))
2738
   (set (match_operand:SI 0 "register_operand" "=d")
2739
        (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2740
  "TARGET_HARD_FLOAT"
2741
{
2742
  operands[2] = GEN_INT (S390_TDC_INFINITY);
2743
})
2744
 
2745
; This insn is used to generate all variants of the Test Data Class
2746
; instruction, namely tcxb, tcdb, and tceb.  The insn's first operand
2747
; is the register to be tested and the second one is the bit mask
2748
; specifying the required test(s).
2749
;
2750
(define_insn "*TDC_insn_"
2751
  [(set (reg:CCZ CC_REGNUM)
2752
        (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
2753
                     (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
2754
  "TARGET_HARD_FLOAT"
2755
  "t<_d>c\t%0,%1"
2756
   [(set_attr "op_type" "RXE")
2757
    (set_attr "type"  "fsimp")])
2758
 
2759
(define_insn_and_split "*ccz_to_int"
2760
  [(set (match_operand:SI 0 "register_operand" "=d")
2761
        (unspec:SI [(match_operand:CCZ 1 "register_operand" "0")]
2762
                   UNSPEC_CCZ_TO_INT))]
2763
  ""
2764
  "#"
2765
  "reload_completed"
2766
  [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
2767
 
2768
 
2769
;
2770
; setmemM instruction pattern(s).
2771
;
2772
 
2773
(define_expand "setmem"
2774
  [(set (match_operand:BLK 0 "memory_operand" "")
2775
        (match_operand:QI 2 "general_operand" ""))
2776
   (use (match_operand:GPR 1 "general_operand" ""))
2777
   (match_operand 3 "" "")]
2778
  ""
2779
  "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
2780
 
2781
; Clear a block that is up to 256 bytes in length.
2782
; The block length is taken as (operands[1] % 256) + 1.
2783
 
2784
(define_expand "clrmem_short"
2785
  [(parallel
2786
    [(set (match_operand:BLK 0 "memory_operand" "")
2787
          (const_int 0))
2788
     (use (match_operand 1 "nonmemory_operand" ""))
2789
     (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2790
     (clobber (match_dup 2))
2791
     (clobber (reg:CC CC_REGNUM))])]
2792
  ""
2793
  "operands[2] = gen_rtx_SCRATCH (Pmode);")
2794
 
2795
(define_insn "*clrmem_short"
2796
  [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2797
        (const_int 0))
2798
   (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
2799
   (use (match_operand 2 "immediate_operand" "X,R,X,X"))
2800
   (clobber (match_scratch 3 "=X,X,X,&a"))
2801
   (clobber (reg:CC CC_REGNUM))]
2802
  "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
2803
   && GET_MODE (operands[3]) == Pmode"
2804
  "#"
2805
  [(set_attr "type" "cs")
2806
   (set_attr "cpu_facility" "*,*,z10,*")])
2807
 
2808
(define_split
2809
  [(set (match_operand:BLK 0 "memory_operand" "")
2810
        (const_int 0))
2811
   (use (match_operand 1 "const_int_operand" ""))
2812
   (use (match_operand 2 "immediate_operand" ""))
2813
   (clobber (scratch))
2814
   (clobber (reg:CC CC_REGNUM))]
2815
  "reload_completed"
2816
  [(parallel
2817
    [(set (match_dup 0) (const_int 0))
2818
     (use (match_dup 1))
2819
     (clobber (reg:CC CC_REGNUM))])]
2820
  "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
2821
 
2822
(define_split
2823
  [(set (match_operand:BLK 0 "memory_operand" "")
2824
        (const_int 0))
2825
   (use (match_operand 1 "register_operand" ""))
2826
   (use (match_operand 2 "memory_operand" ""))
2827
   (clobber (scratch))
2828
   (clobber (reg:CC CC_REGNUM))]
2829
  "reload_completed"
2830
  [(parallel
2831
    [(unspec [(match_dup 1) (match_dup 2)
2832
              (const_int 0)] UNSPEC_EXECUTE)
2833
     (set (match_dup 0) (const_int 0))
2834
     (use (const_int 1))
2835
     (clobber (reg:CC CC_REGNUM))])]
2836
  "")
2837
 
2838
(define_split
2839
  [(set (match_operand:BLK 0 "memory_operand" "")
2840
        (const_int 0))
2841
   (use (match_operand 1 "register_operand" ""))
2842
   (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2843
   (clobber (scratch))
2844
   (clobber (reg:CC CC_REGNUM))]
2845
  "TARGET_Z10 && reload_completed"
2846
  [(parallel
2847
    [(unspec [(match_dup 1) (const_int 0)
2848
              (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2849
     (set (match_dup 0) (const_int 0))
2850
     (use (const_int 1))
2851
     (clobber (reg:CC CC_REGNUM))])]
2852
  "operands[3] = gen_label_rtx ();")
2853
 
2854
(define_split
2855
  [(set (match_operand:BLK 0 "memory_operand" "")
2856
        (const_int 0))
2857
   (use (match_operand 1 "register_operand" ""))
2858
   (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2859
   (clobber (match_operand 2 "register_operand" ""))
2860
   (clobber (reg:CC CC_REGNUM))]
2861
  "reload_completed && TARGET_CPU_ZARCH"
2862
  [(set (match_dup 2) (label_ref (match_dup 3)))
2863
   (parallel
2864
    [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
2865
              (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2866
     (set (match_dup 0) (const_int 0))
2867
     (use (const_int 1))
2868
     (clobber (reg:CC CC_REGNUM))])]
2869
  "operands[3] = gen_label_rtx ();")
2870
 
2871
; Initialize a block of arbitrary length with (operands[2] % 256).
2872
 
2873
(define_expand "setmem_long"
2874
  [(parallel
2875
    [(clobber (match_dup 1))
2876
     (set (match_operand:BLK 0 "memory_operand" "")
2877
          (match_operand 2 "shift_count_or_setmem_operand" ""))
2878
     (use (match_operand 1 "general_operand" ""))
2879
     (use (match_dup 3))
2880
     (clobber (reg:CC CC_REGNUM))])]
2881
  ""
2882
{
2883
  enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2884
  rtx reg0 = gen_reg_rtx (dword_mode);
2885
  rtx reg1 = gen_reg_rtx (dword_mode);
2886
  rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2887
  rtx len0 = gen_lowpart (Pmode, reg0);
2888
 
2889
  emit_clobber (reg0);
2890
  emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2891
  emit_move_insn (len0, operands[1]);
2892
 
2893
  emit_move_insn (reg1, const0_rtx);
2894
 
2895
  operands[0] = replace_equiv_address_nv (operands[0], addr0);
2896
  operands[1] = reg0;
2897
  operands[3] = reg1;
2898
})
2899
 
2900
(define_insn "*setmem_long"
2901
  [(clobber (match_operand: 0 "register_operand" "=d"))
2902
   (set (mem:BLK (subreg:P (match_operand: 3 "register_operand" "0") 0))
2903
        (match_operand 2 "shift_count_or_setmem_operand" "Y"))
2904
   (use (match_dup 3))
2905
   (use (match_operand: 1 "register_operand" "d"))
2906
   (clobber (reg:CC CC_REGNUM))]
2907
  ""
2908
  "mvcle\t%0,%1,%Y2\;jo\t.-4"
2909
  [(set_attr "length" "8")
2910
   (set_attr "type" "vs")])
2911
 
2912
(define_insn "*setmem_long_and"
2913
  [(clobber (match_operand: 0 "register_operand" "=d"))
2914
   (set (mem:BLK (subreg:P (match_operand: 3 "register_operand" "0") 0))
2915
        (and (match_operand 2 "shift_count_or_setmem_operand" "Y")
2916
             (match_operand 4 "const_int_operand"             "n")))
2917
   (use (match_dup 3))
2918
   (use (match_operand: 1 "register_operand" "d"))
2919
   (clobber (reg:CC CC_REGNUM))]
2920
  "(INTVAL (operands[4]) & 255) == 255"
2921
  "mvcle\t%0,%1,%Y2\;jo\t.-4"
2922
  [(set_attr "length" "8")
2923
   (set_attr "type" "vs")])
2924
;
2925
; cmpmemM instruction pattern(s).
2926
;
2927
 
2928
(define_expand "cmpmemsi"
2929
  [(set (match_operand:SI 0 "register_operand" "")
2930
        (compare:SI (match_operand:BLK 1 "memory_operand" "")
2931
                    (match_operand:BLK 2 "memory_operand" "") ) )
2932
   (use (match_operand:SI 3 "general_operand" ""))
2933
   (use (match_operand:SI 4 "" ""))]
2934
  ""
2935
  "s390_expand_cmpmem (operands[0], operands[1],
2936
                       operands[2], operands[3]); DONE;")
2937
 
2938
; Compare a block that is up to 256 bytes in length.
2939
; The block length is taken as (operands[2] % 256) + 1.
2940
 
2941
(define_expand "cmpmem_short"
2942
  [(parallel
2943
    [(set (reg:CCU CC_REGNUM)
2944
          (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2945
                       (match_operand:BLK 1 "memory_operand" "")))
2946
     (use (match_operand 2 "nonmemory_operand" ""))
2947
     (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2948
     (clobber (match_dup 3))])]
2949
  ""
2950
  "operands[3] = gen_rtx_SCRATCH (Pmode);")
2951
 
2952
(define_insn "*cmpmem_short"
2953
  [(set (reg:CCU CC_REGNUM)
2954
        (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
2955
                     (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
2956
   (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2957
   (use (match_operand 3 "immediate_operand" "X,R,X,X"))
2958
   (clobber (match_scratch 4 "=X,X,X,&a"))]
2959
  "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2960
   && GET_MODE (operands[4]) == Pmode"
2961
  "#"
2962
  [(set_attr "type" "cs")
2963
   (set_attr "cpu_facility" "*,*,z10,*")])
2964
 
2965
(define_split
2966
  [(set (reg:CCU CC_REGNUM)
2967
        (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2968
                     (match_operand:BLK 1 "memory_operand" "")))
2969
   (use (match_operand 2 "const_int_operand" ""))
2970
   (use (match_operand 3 "immediate_operand" ""))
2971
   (clobber (scratch))]
2972
  "reload_completed"
2973
  [(parallel
2974
    [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2975
     (use (match_dup 2))])]
2976
  "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2977
 
2978
(define_split
2979
  [(set (reg:CCU CC_REGNUM)
2980
        (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2981
                     (match_operand:BLK 1 "memory_operand" "")))
2982
   (use (match_operand 2 "register_operand" ""))
2983
   (use (match_operand 3 "memory_operand" ""))
2984
   (clobber (scratch))]
2985
  "reload_completed"
2986
  [(parallel
2987
    [(unspec [(match_dup 2) (match_dup 3)
2988
              (const_int 0)] UNSPEC_EXECUTE)
2989
     (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2990
     (use (const_int 1))])]
2991
  "")
2992
 
2993
(define_split
2994
  [(set (reg:CCU CC_REGNUM)
2995
        (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2996
                     (match_operand:BLK 1 "memory_operand" "")))
2997
   (use (match_operand 2 "register_operand" ""))
2998
   (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2999
   (clobber (scratch))]
3000
  "TARGET_Z10 && reload_completed"
3001
  [(parallel
3002
    [(unspec [(match_dup 2) (const_int 0)
3003
              (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3004
     (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3005
     (use (const_int 1))])]
3006
  "operands[4] = gen_label_rtx ();")
3007
 
3008
(define_split
3009
  [(set (reg:CCU CC_REGNUM)
3010
        (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3011
                     (match_operand:BLK 1 "memory_operand" "")))
3012
   (use (match_operand 2 "register_operand" ""))
3013
   (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3014
   (clobber (match_operand 3 "register_operand" ""))]
3015
  "reload_completed && TARGET_CPU_ZARCH"
3016
  [(set (match_dup 3) (label_ref (match_dup 4)))
3017
   (parallel
3018
    [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
3019
              (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3020
     (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3021
     (use (const_int 1))])]
3022
  "operands[4] = gen_label_rtx ();")
3023
 
3024
; Compare a block of arbitrary length.
3025
 
3026
(define_expand "cmpmem_long"
3027
  [(parallel
3028
    [(clobber (match_dup 2))
3029
     (clobber (match_dup 3))
3030
     (set (reg:CCU CC_REGNUM)
3031
          (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3032
                       (match_operand:BLK 1 "memory_operand" "")))
3033
     (use (match_operand 2 "general_operand" ""))
3034
     (use (match_dup 3))])]
3035
  ""
3036
{
3037
  enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
3038
  rtx reg0 = gen_reg_rtx (dword_mode);
3039
  rtx reg1 = gen_reg_rtx (dword_mode);
3040
  rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
3041
  rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
3042
  rtx len0 = gen_lowpart (Pmode, reg0);
3043
  rtx len1 = gen_lowpart (Pmode, reg1);
3044
 
3045
  emit_clobber (reg0);
3046
  emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3047
  emit_move_insn (len0, operands[2]);
3048
 
3049
  emit_clobber (reg1);
3050
  emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3051
  emit_move_insn (len1, operands[2]);
3052
 
3053
  operands[0] = replace_equiv_address_nv (operands[0], addr0);
3054
  operands[1] = replace_equiv_address_nv (operands[1], addr1);
3055
  operands[2] = reg0;
3056
  operands[3] = reg1;
3057
})
3058
 
3059
(define_insn "*cmpmem_long"
3060
  [(clobber (match_operand: 0 "register_operand" "=d"))
3061
   (clobber (match_operand: 1 "register_operand" "=d"))
3062
   (set (reg:CCU CC_REGNUM)
3063
        (compare:CCU (mem:BLK (subreg:P (match_operand: 2 "register_operand" "0") 0))
3064
                     (mem:BLK (subreg:P (match_operand: 3 "register_operand" "1") 0))))
3065
   (use (match_dup 2))
3066
   (use (match_dup 3))]
3067
  ""
3068
  "clcle\t%0,%1,0\;jo\t.-4"
3069
  [(set_attr "length" "8")
3070
   (set_attr "type" "vs")])
3071
 
3072
; Convert CCUmode condition code to integer.
3073
; Result is zero if EQ, positive if LTU, negative if GTU.
3074
 
3075
(define_insn_and_split "cmpint"
3076
  [(set (match_operand:SI 0 "register_operand" "=d")
3077
        (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3078
                   UNSPEC_CCU_TO_INT))
3079
   (clobber (reg:CC CC_REGNUM))]
3080
  ""
3081
  "#"
3082
  "reload_completed"
3083
  [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3084
   (parallel
3085
    [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
3086
     (clobber (reg:CC CC_REGNUM))])])
3087
 
3088
(define_insn_and_split "*cmpint_cc"
3089
  [(set (reg CC_REGNUM)
3090
        (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3091
                            UNSPEC_CCU_TO_INT)
3092
                 (const_int 0)))
3093
   (set (match_operand:SI 0 "register_operand" "=d")
3094
        (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT))]
3095
  "s390_match_ccmode (insn, CCSmode)"
3096
  "#"
3097
  "&& reload_completed"
3098
  [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3099
   (parallel
3100
    [(set (match_dup 2) (match_dup 3))
3101
     (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
3102
{
3103
  rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3104
  operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3105
  operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3106
})
3107
 
3108
(define_insn_and_split "*cmpint_sign"
3109
  [(set (match_operand:DI 0 "register_operand" "=d")
3110
        (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3111
                                   UNSPEC_CCU_TO_INT)))
3112
   (clobber (reg:CC CC_REGNUM))]
3113
  "TARGET_64BIT"
3114
  "#"
3115
  "&& reload_completed"
3116
  [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3117
   (parallel
3118
    [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
3119
     (clobber (reg:CC CC_REGNUM))])])
3120
 
3121
(define_insn_and_split "*cmpint_sign_cc"
3122
  [(set (reg CC_REGNUM)
3123
        (compare (ashiftrt:DI (ashift:DI (subreg:DI
3124
                   (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3125
                              UNSPEC_CCU_TO_INT) 0)
3126
                   (const_int 32)) (const_int 32))
3127
                 (const_int 0)))
3128
   (set (match_operand:DI 0 "register_operand" "=d")
3129
        (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT)))]
3130
  "s390_match_ccmode (insn, CCSmode) && TARGET_64BIT"
3131
  "#"
3132
  "&& reload_completed"
3133
  [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3134
   (parallel
3135
    [(set (match_dup 2) (match_dup 3))
3136
     (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
3137
{
3138
  rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3139
  operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3140
  operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3141
})
3142
 
3143
 
3144
;;
3145
;;- Conversion instructions.
3146
;;
3147
 
3148
(define_insn "*sethighpartsi"
3149
  [(set (match_operand:SI 0 "register_operand" "=d,d")
3150
        (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3151
                    (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3152
   (clobber (reg:CC CC_REGNUM))]
3153
  ""
3154
  "@
3155
   icm\t%0,%2,%S1
3156
   icmy\t%0,%2,%S1"
3157
  [(set_attr "op_type" "RS,RSY")
3158
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3159
 
3160
(define_insn "*sethighpartdi_64"
3161
  [(set (match_operand:DI 0 "register_operand" "=d")
3162
        (unspec:DI [(match_operand:BLK 1 "s_operand" "QS")
3163
                    (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
3164
   (clobber (reg:CC CC_REGNUM))]
3165
  "TARGET_64BIT"
3166
  "icmh\t%0,%2,%S1"
3167
  [(set_attr "op_type" "RSY")
3168
   (set_attr "z10prop" "z10_super")])
3169
 
3170
(define_insn "*sethighpartdi_31"
3171
  [(set (match_operand:DI 0 "register_operand" "=d,d")
3172
        (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3173
                    (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3174
   (clobber (reg:CC CC_REGNUM))]
3175
  "!TARGET_64BIT"
3176
  "@
3177
   icm\t%0,%2,%S1
3178
   icmy\t%0,%2,%S1"
3179
  [(set_attr "op_type" "RS,RSY")
3180
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3181
 
3182
 
3183
(define_insn_and_split "*extzv"
3184
  [(set (match_operand:GPR 0 "register_operand" "=d")
3185
        (zero_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3186
                          (match_operand 2 "const_int_operand" "n")
3187
                          (const_int 0)))
3188
   (clobber (reg:CC CC_REGNUM))]
3189
  "INTVAL (operands[2]) > 0
3190
   && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
3191
  "#"
3192
  "&& reload_completed"
3193
  [(parallel
3194
    [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3195
     (clobber (reg:CC CC_REGNUM))])
3196
   (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
3197
{
3198
  int bitsize = INTVAL (operands[2]);
3199
  int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3200
  int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3201
 
3202
  operands[1] = adjust_address (operands[1], BLKmode, 0);
3203
  set_mem_size (operands[1], GEN_INT (size));
3204
  operands[2] = GEN_INT (GET_MODE_BITSIZE (mode) - bitsize);
3205
  operands[3] = GEN_INT (mask);
3206
})
3207
 
3208
(define_insn_and_split "*extv"
3209
  [(set (match_operand:GPR 0 "register_operand" "=d")
3210
        (sign_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3211
                          (match_operand 2 "const_int_operand" "n")
3212
                          (const_int 0)))
3213
   (clobber (reg:CC CC_REGNUM))]
3214
  "INTVAL (operands[2]) > 0
3215
   && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
3216
  "#"
3217
  "&& reload_completed"
3218
  [(parallel
3219
    [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3220
     (clobber (reg:CC CC_REGNUM))])
3221
   (parallel
3222
    [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3223
     (clobber (reg:CC CC_REGNUM))])]
3224
{
3225
  int bitsize = INTVAL (operands[2]);
3226
  int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3227
  int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3228
 
3229
  operands[1] = adjust_address (operands[1], BLKmode, 0);
3230
  set_mem_size (operands[1], GEN_INT (size));
3231
  operands[2] = GEN_INT (GET_MODE_BITSIZE (mode) - bitsize);
3232
  operands[3] = GEN_INT (mask);
3233
})
3234
 
3235
;
3236
; insv instruction patterns
3237
;
3238
 
3239
(define_expand "insv"
3240
  [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3241
                      (match_operand 1 "const_int_operand" "")
3242
                      (match_operand 2 "const_int_operand" ""))
3243
        (match_operand 3 "general_operand" ""))]
3244
  ""
3245
{
3246
  if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3247
    DONE;
3248
  FAIL;
3249
})
3250
 
3251
(define_insn "*insv_z10"
3252
  [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
3253
                          (match_operand 1 "const_int_operand"    "I")
3254
                          (match_operand 2 "const_int_operand"    "I"))
3255
        (match_operand:GPR 3 "nonimmediate_operand" "d"))
3256
   (clobber (reg:CC CC_REGNUM))]
3257
  "TARGET_Z10
3258
   && (INTVAL (operands[1]) + INTVAL (operands[2])) <=
3259
      GET_MODE_BITSIZE (mode)"
3260
{
3261
  int start = INTVAL (operands[2]);
3262
  int size = INTVAL (operands[1]);
3263
  int offset = 64 - GET_MODE_BITSIZE (mode);
3264
 
3265
  operands[2] = GEN_INT (offset + start);              /* start bit position */
3266
  operands[1] = GEN_INT (offset + start + size - 1);   /* end bit position */
3267
  operands[4] = GEN_INT (GET_MODE_BITSIZE (mode) -
3268
                         start - size);       /* left shift count */
3269
 
3270
  return "risbg\t%0,%3,%b2,%b1,%b4";
3271
}
3272
  [(set_attr "op_type" "RIE")
3273
   (set_attr "z10prop" "z10_super_E1")])
3274
 
3275
; and op1 with a mask being 1 for the selected bits and 0 for the rest
3276
; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
3277
(define_insn "*insv_z10_noshift"
3278
  [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3279
        (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3280
                          (match_operand 2 "const_int_operand" "n"))
3281
                 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
3282
                          (match_operand 4 "const_int_operand" "n"))))
3283
   (clobber (reg:CC CC_REGNUM))]
3284
  "TARGET_Z10
3285
   && s390_contiguous_bitmask_p (INTVAL (operands[2]),
3286
                                 GET_MODE_BITSIZE (mode), NULL, NULL)
3287
   && INTVAL (operands[2]) == ~(INTVAL (operands[4]))"
3288
 
3289
{
3290
  int start;
3291
  int size;
3292
 
3293
  s390_contiguous_bitmask_p (INTVAL (operands[2]),
3294
                             GET_MODE_BITSIZE (mode), &start, &size);
3295
 
3296
  operands[5] = GEN_INT (64 - start - size); /* start bit position */
3297
  operands[6] = GEN_INT (64 - 1 - start);    /* end bit position */
3298
  operands[7] = const0_rtx;                  /* left shift count */
3299
 
3300
  return "risbg\t%0,%1,%b5,%b6,%b7";
3301
}
3302
  [(set_attr "op_type" "RIE")
3303
   (set_attr "z10prop" "z10_super_E1")])
3304
 
3305
; and op1 with a mask being 1 for the selected bits and 0 for the rest
3306
(define_insn "*insv_or_z10_noshift"
3307
  [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3308
        (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3309
                          (match_operand 2 "const_int_operand" "n"))
3310
                (match_operand:GPR 3 "nonimmediate_operand" "0")))
3311
   (clobber (reg:CC CC_REGNUM))]
3312
  "TARGET_Z10
3313
   && s390_contiguous_bitmask_p (INTVAL (operands[2]),
3314
                                 GET_MODE_BITSIZE (mode), NULL, NULL)"
3315
{
3316
  int start;
3317
  int size;
3318
 
3319
  s390_contiguous_bitmask_p (INTVAL (operands[2]),
3320
                             GET_MODE_BITSIZE (mode), &start, &size);
3321
 
3322
  operands[4] = GEN_INT (64 - start - size); /* start bit position */
3323
  operands[5] = GEN_INT (64 - 1 - start);    /* end bit position */
3324
  operands[6] = const0_rtx;                  /* left shift count */
3325
 
3326
  return "rosbg\t%0,%1,%b4,%b5,%b6";
3327
}
3328
  [(set_attr "op_type" "RIE")])
3329
 
3330
(define_insn "*insv_mem_reg"
3331
  [(set (zero_extract:P (match_operand:QI 0 "memory_operand" "+Q,S")
3332
                        (match_operand 1 "const_int_operand" "n,n")
3333
                        (const_int 0))
3334
        (match_operand:P 2 "register_operand" "d,d"))]
3335
  "INTVAL (operands[1]) > 0
3336
   && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3337
   && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3338
{
3339
    int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3340
 
3341
    operands[1] = GEN_INT ((1ul << size) - 1);
3342
    return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
3343
                                    : "stcmy\t%2,%1,%S0";
3344
}
3345
  [(set_attr "op_type" "RS,RSY")
3346
   (set_attr "z10prop" "z10_super,z10_super")])
3347
 
3348
(define_insn "*insvdi_mem_reghigh"
3349
  [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+QS")
3350
                         (match_operand 1 "const_int_operand" "n")
3351
                         (const_int 0))
3352
        (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
3353
                     (const_int 32)))]
3354
  "TARGET_64BIT
3355
   && INTVAL (operands[1]) > 0
3356
   && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3357
   && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3358
{
3359
    int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3360
 
3361
    operands[1] = GEN_INT ((1ul << size) - 1);
3362
    return "stcmh\t%2,%1,%S0";
3363
}
3364
[(set_attr "op_type" "RSY")
3365
 (set_attr "z10prop" "z10_super")])
3366
 
3367
(define_insn "*insv_reg_imm"
3368
  [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
3369
                        (const_int 16)
3370
                        (match_operand 1 "const_int_operand" "n"))
3371
        (match_operand:P 2 "const_int_operand" "n"))]
3372
  "TARGET_ZARCH
3373
   && INTVAL (operands[1]) >= 0
3374
   && INTVAL (operands[1]) < BITS_PER_WORD
3375
   && INTVAL (operands[1]) % 16 == 0"
3376
{
3377
  switch (BITS_PER_WORD - INTVAL (operands[1]))
3378
    {
3379
      case 64: return "iihh\t%0,%x2"; break;
3380
      case 48: return "iihl\t%0,%x2"; break;
3381
      case 32: return "iilh\t%0,%x2"; break;
3382
      case 16: return "iill\t%0,%x2"; break;
3383
      default: gcc_unreachable();
3384
    }
3385
}
3386
  [(set_attr "op_type" "RI")
3387
   (set_attr "z10prop" "z10_super_E1")])
3388
 
3389
; Update the left-most 32 bit of a DI.
3390
(define_insn "*insv_h_di_reg_extimm"
3391
  [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3392
                         (const_int 32)
3393
                         (const_int 0))
3394
        (match_operand:DI 1 "const_int_operand" "n"))]
3395
  "TARGET_EXTIMM"
3396
  "iihf\t%0,%o1"
3397
  [(set_attr "op_type" "RIL")
3398
   (set_attr "z10prop" "z10_fwd_E1")])
3399
 
3400
; Update the right-most 32 bit of a DI, or the whole of a SI.
3401
(define_insn "*insv_l_reg_extimm"
3402
  [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
3403
                        (const_int 32)
3404
                        (match_operand 1 "const_int_operand" "n"))
3405
        (match_operand:P 2 "const_int_operand" "n"))]
3406
  "TARGET_EXTIMM
3407
   && BITS_PER_WORD - INTVAL (operands[1]) == 32"
3408
  "iilf\t%0,%o2"
3409
  [(set_attr "op_type" "RIL")
3410
   (set_attr "z10prop" "z10_fwd_A1")])
3411
 
3412
;
3413
; extendsidi2 instruction pattern(s).
3414
;
3415
 
3416
(define_expand "extendsidi2"
3417
  [(set (match_operand:DI 0 "register_operand" "")
3418
        (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3419
  ""
3420
{
3421
  if (!TARGET_64BIT)
3422
    {
3423
      emit_clobber (operands[0]);
3424
      emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
3425
      emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
3426
      emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
3427
      DONE;
3428
    }
3429
})
3430
 
3431
(define_insn "*extendsidi2"
3432
  [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3433
        (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3434
  "TARGET_64BIT"
3435
  "@
3436
   lgfr\t%0,%1
3437
   lgf\t%0,%1
3438
   lgfrl\t%0,%1"
3439
  [(set_attr "op_type"      "RRE,RXY,RIL")
3440
   (set_attr "type"         "*,*,larl")
3441
   (set_attr "cpu_facility" "*,*,z10")
3442
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3443
 
3444
;
3445
; extend(hi|qi)(si|di)2 instruction pattern(s).
3446
;
3447
 
3448
(define_expand "extend2"
3449
  [(set (match_operand:DSI 0 "register_operand" "")
3450
        (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3451
  ""
3452
{
3453
  if (mode == DImode && !TARGET_64BIT)
3454
    {
3455
      rtx tmp = gen_reg_rtx (SImode);
3456
      emit_insn (gen_extendsi2 (tmp, operands[1]));
3457
      emit_insn (gen_extendsidi2 (operands[0], tmp));
3458
      DONE;
3459
    }
3460
  else if (!TARGET_EXTIMM)
3461
    {
3462
      rtx bitcount = GEN_INT (GET_MODE_BITSIZE (mode) -
3463
                              GET_MODE_BITSIZE (mode));
3464
 
3465
      operands[1] = gen_lowpart (mode, operands[1]);
3466
      emit_insn (gen_ashl3 (operands[0], operands[1], bitcount));
3467
      emit_insn (gen_ashr3 (operands[0], operands[0], bitcount));
3468
      DONE;
3469
    }
3470
})
3471
 
3472
;
3473
; extendhidi2 instruction pattern(s).
3474
;
3475
 
3476
(define_insn "*extendhidi2_extimm"
3477
  [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3478
        (sign_extend:DI (match_operand:HI 1 "general_operand" "d,RT,b")))]
3479
  "TARGET_64BIT && TARGET_EXTIMM"
3480
  "@
3481
   lghr\t%0,%1
3482
   lgh\t%0,%1
3483
   lghrl\t%0,%1"
3484
  [(set_attr "op_type"      "RRE,RXY,RIL")
3485
   (set_attr "type"         "*,*,larl")
3486
   (set_attr "cpu_facility" "extimm,extimm,z10")
3487
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3488
 
3489
(define_insn "*extendhidi2"
3490
  [(set (match_operand:DI 0 "register_operand" "=d")
3491
        (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT")))]
3492
  "TARGET_64BIT"
3493
  "lgh\t%0,%1"
3494
  [(set_attr "op_type" "RXY")
3495
   (set_attr "z10prop" "z10_super_E1")])
3496
 
3497
;
3498
; extendhisi2 instruction pattern(s).
3499
;
3500
 
3501
(define_insn "*extendhisi2_extimm"
3502
  [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3503
        (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
3504
  "TARGET_EXTIMM"
3505
  "@
3506
   lhr\t%0,%1
3507
   lh\t%0,%1
3508
   lhy\t%0,%1
3509
   lhrl\t%0,%1"
3510
  [(set_attr "op_type"      "RRE,RX,RXY,RIL")
3511
   (set_attr "type"         "*,*,*,larl")
3512
   (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
3513
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
3514
 
3515
(define_insn "*extendhisi2"
3516
  [(set (match_operand:SI 0 "register_operand" "=d,d")
3517
        (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
3518
  "!TARGET_EXTIMM"
3519
  "@
3520
   lh\t%0,%1
3521
   lhy\t%0,%1"
3522
  [(set_attr "op_type" "RX,RXY")
3523
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3524
 
3525
;
3526
; extendqi(si|di)2 instruction pattern(s).
3527
;
3528
 
3529
; lbr, lgbr, lb, lgb
3530
(define_insn "*extendqi2_extimm"
3531
  [(set (match_operand:GPR 0 "register_operand" "=d,d")
3532
        (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,RT")))]
3533
  "TARGET_EXTIMM"
3534
  "@
3535
   lbr\t%0,%1
3536
   lb\t%0,%1"
3537
  [(set_attr "op_type" "RRE,RXY")
3538
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3539
 
3540
; lb, lgb
3541
(define_insn "*extendqi2"
3542
  [(set (match_operand:GPR 0 "register_operand" "=d")
3543
        (sign_extend:GPR (match_operand:QI 1 "memory_operand" "RT")))]
3544
  "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
3545
  "lb\t%0,%1"
3546
  [(set_attr "op_type" "RXY")
3547
   (set_attr "z10prop" "z10_super_E1")])
3548
 
3549
(define_insn_and_split "*extendqi2_short_displ"
3550
  [(set (match_operand:GPR 0 "register_operand" "=d")
3551
        (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
3552
   (clobber (reg:CC CC_REGNUM))]
3553
  "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
3554
  "#"
3555
  "&& reload_completed"
3556
  [(parallel
3557
    [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
3558
     (clobber (reg:CC CC_REGNUM))])
3559
   (parallel
3560
    [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3561
     (clobber (reg:CC CC_REGNUM))])]
3562
{
3563
  operands[1] = adjust_address (operands[1], BLKmode, 0);
3564
  set_mem_size (operands[1], GEN_INT (GET_MODE_SIZE (QImode)));
3565
  operands[2] = GEN_INT (GET_MODE_BITSIZE (mode)
3566
                         - GET_MODE_BITSIZE (QImode));
3567
})
3568
 
3569
;
3570
; zero_extendsidi2 instruction pattern(s).
3571
;
3572
 
3573
(define_expand "zero_extendsidi2"
3574
  [(set (match_operand:DI 0 "register_operand" "")
3575
        (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3576
  ""
3577
{
3578
  if (!TARGET_64BIT)
3579
    {
3580
      emit_clobber (operands[0]);
3581
      emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
3582
      emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
3583
      DONE;
3584
    }
3585
})
3586
 
3587
(define_insn "*zero_extendsidi2"
3588
  [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3589
        (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3590
  "TARGET_64BIT"
3591
  "@
3592
   llgfr\t%0,%1
3593
   llgf\t%0,%1
3594
   llgfrl\t%0,%1"
3595
  [(set_attr "op_type"      "RRE,RXY,RIL")
3596
   (set_attr "type"         "*,*,larl")
3597
   (set_attr "cpu_facility" "*,*,z10")
3598
   (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
3599
 
3600
;
3601
; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
3602
;
3603
 
3604
(define_insn "*llgt_sidi"
3605
  [(set (match_operand:DI 0 "register_operand" "=d")
3606
        (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3607
                (const_int 2147483647)))]
3608
  "TARGET_64BIT"
3609
  "llgt\t%0,%1"
3610
  [(set_attr "op_type"  "RXE")
3611
   (set_attr "z10prop" "z10_super_E1")])
3612
 
3613
(define_insn_and_split "*llgt_sidi_split"
3614
  [(set (match_operand:DI 0 "register_operand" "=d")
3615
        (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3616
                (const_int 2147483647)))
3617
   (clobber (reg:CC CC_REGNUM))]
3618
  "TARGET_64BIT"
3619
  "#"
3620
  "&& reload_completed"
3621
  [(set (match_dup 0)
3622
        (and:DI (subreg:DI (match_dup 1) 0)
3623
                (const_int 2147483647)))]
3624
  "")
3625
 
3626
(define_insn "*llgt_sisi"
3627
  [(set (match_operand:SI 0 "register_operand" "=d,d")
3628
        (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,RT")
3629
                (const_int 2147483647)))]
3630
  "TARGET_ZARCH"
3631
  "@
3632
   llgtr\t%0,%1
3633
   llgt\t%0,%1"
3634
  [(set_attr "op_type"  "RRE,RXE")
3635
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3636
 
3637
(define_insn "*llgt_didi"
3638
  [(set (match_operand:DI 0 "register_operand" "=d,d")
3639
        (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
3640
                (const_int 2147483647)))]
3641
  "TARGET_64BIT"
3642
  "@
3643
   llgtr\t%0,%1
3644
   llgt\t%0,%N1"
3645
  [(set_attr "op_type"  "RRE,RXE")
3646
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3647
 
3648
(define_split
3649
  [(set (match_operand:GPR 0 "register_operand" "")
3650
        (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
3651
                 (const_int 2147483647)))
3652
   (clobber (reg:CC CC_REGNUM))]
3653
  "TARGET_ZARCH && reload_completed"
3654
  [(set (match_dup 0)
3655
        (and:GPR (match_dup 1)
3656
                 (const_int 2147483647)))]
3657
  "")
3658
 
3659
;
3660
; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
3661
;
3662
 
3663
(define_expand "zero_extenddi2"
3664
  [(set (match_operand:DI 0 "register_operand" "")
3665
        (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3666
  ""
3667
{
3668
  if (!TARGET_64BIT)
3669
    {
3670
      rtx tmp = gen_reg_rtx (SImode);
3671
      emit_insn (gen_zero_extendsi2 (tmp, operands[1]));
3672
      emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
3673
      DONE;
3674
    }
3675
  else if (!TARGET_EXTIMM)
3676
    {
3677
      rtx bitcount = GEN_INT (GET_MODE_BITSIZE(DImode) -
3678
                              GET_MODE_BITSIZE(mode));
3679
      operands[1] = gen_lowpart (DImode, operands[1]);
3680
      emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
3681
      emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
3682
      DONE;
3683
    }
3684
})
3685
 
3686
(define_expand "zero_extendsi2"
3687
  [(set (match_operand:SI 0 "register_operand" "")
3688
        (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3689
  ""
3690
{
3691
  if (!TARGET_EXTIMM)
3692
    {
3693
      operands[1] = gen_lowpart (SImode, operands[1]);
3694
      emit_insn (gen_andsi3 (operands[0], operands[1],
3695
                   GEN_INT ((1 << GET_MODE_BITSIZE(mode)) - 1)));
3696
      DONE;
3697
    }
3698
})
3699
 
3700
; llhrl, llghrl
3701
(define_insn "*zero_extendhi2_z10"
3702
  [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
3703
        (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,RT,b")))]
3704
  "TARGET_Z10"
3705
  "@
3706
   llhr\t%0,%1
3707
   llh\t%0,%1
3708
   llhrl\t%0,%1"
3709
  [(set_attr "op_type"      "RXY,RRE,RIL")
3710
   (set_attr "type"         "*,*,larl")
3711
   (set_attr "cpu_facility" "*,*,z10")
3712
   (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
3713
 
3714
; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
3715
(define_insn "*zero_extend2_extimm"
3716
  [(set (match_operand:GPR 0 "register_operand" "=d,d")
3717
        (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,RT")))]
3718
  "TARGET_EXTIMM"
3719
  "@
3720
   llr\t%0,%1
3721
   ll\t%0,%1"
3722
  [(set_attr "op_type" "RRE,RXY")
3723
   (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
3724
 
3725
; llgh, llgc
3726
(define_insn "*zero_extend2"
3727
  [(set (match_operand:GPR 0 "register_operand" "=d")
3728
        (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "RT")))]
3729
  "TARGET_ZARCH && !TARGET_EXTIMM"
3730
  "llg\t%0,%1"
3731
  [(set_attr "op_type" "RXY")
3732
   (set_attr "z10prop" "z10_fwd_A3")])
3733
 
3734
(define_insn_and_split "*zero_extendhisi2_31"
3735
  [(set (match_operand:SI 0 "register_operand" "=&d")
3736
        (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
3737
   (clobber (reg:CC CC_REGNUM))]
3738
  "!TARGET_ZARCH"
3739
  "#"
3740
  "&& reload_completed"
3741
  [(set (match_dup 0) (const_int 0))
3742
   (parallel
3743
    [(set (strict_low_part (match_dup 2)) (match_dup 1))
3744
     (clobber (reg:CC CC_REGNUM))])]
3745
  "operands[2] = gen_lowpart (HImode, operands[0]);")
3746
 
3747
(define_insn_and_split "*zero_extendqisi2_31"
3748
  [(set (match_operand:SI 0 "register_operand" "=&d")
3749
        (zero_extend:SI (match_operand:QI 1 "memory_operand" "RT")))]
3750
  "!TARGET_ZARCH"
3751
  "#"
3752
  "&& reload_completed"
3753
  [(set (match_dup 0) (const_int 0))
3754
   (set (strict_low_part (match_dup 2)) (match_dup 1))]
3755
  "operands[2] = gen_lowpart (QImode, operands[0]);")
3756
 
3757
;
3758
; zero_extendqihi2 instruction pattern(s).
3759
;
3760
 
3761
(define_expand "zero_extendqihi2"
3762
  [(set (match_operand:HI 0 "register_operand" "")
3763
        (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
3764
  "TARGET_ZARCH && !TARGET_EXTIMM"
3765
{
3766
  operands[1] = gen_lowpart (HImode, operands[1]);
3767
  emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
3768
  DONE;
3769
})
3770
 
3771
(define_insn "*zero_extendqihi2_64"
3772
  [(set (match_operand:HI 0 "register_operand" "=d")
3773
        (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
3774
  "TARGET_ZARCH && !TARGET_EXTIMM"
3775
  "llgc\t%0,%1"
3776
  [(set_attr "op_type" "RXY")
3777
   (set_attr "z10prop" "z10_fwd_A3")])
3778
 
3779
(define_insn_and_split "*zero_extendqihi2_31"
3780
  [(set (match_operand:HI 0 "register_operand" "=&d")
3781
        (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
3782
  "!TARGET_ZARCH"
3783
  "#"
3784
  "&& reload_completed"
3785
  [(set (match_dup 0) (const_int 0))
3786
   (set (strict_low_part (match_dup 2)) (match_dup 1))]
3787
  "operands[2] = gen_lowpart (QImode, operands[0]);")
3788
 
3789
;
3790
; fixuns_trunc(dd|td)di2 instruction pattern(s).
3791
;
3792
 
3793
(define_expand "fixuns_truncdddi2"
3794
  [(parallel
3795
    [(set (match_operand:DI 0 "register_operand" "")
3796
          (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
3797
     (clobber (match_scratch:TD 2 "=f"))])]
3798
 
3799
  "TARGET_HARD_DFP"
3800
{
3801
  rtx label1 = gen_label_rtx ();
3802
  rtx label2 = gen_label_rtx ();
3803
  rtx temp = gen_reg_rtx (TDmode);
3804
  REAL_VALUE_TYPE cmp, sub;
3805
 
3806
  decimal_real_from_string (&cmp, "9223372036854775808.0");  /* 2^63 */
3807
  decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3808
 
3809
  /* 2^63 can't be represented as 64bit DFP number with full precision.  The
3810
     solution is doing the check and the subtraction in TD mode and using a
3811
     TD -> DI convert afterwards.  */
3812
  emit_insn (gen_extendddtd2 (temp, operands[1]));
3813
  temp = force_reg (TDmode, temp);
3814
  emit_cmp_and_jump_insns (temp,
3815
        CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode),
3816
        LT, NULL_RTX, VOIDmode, 0, label1);
3817
  emit_insn (gen_subtd3 (temp, temp,
3818
        CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3819
  emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3820
  emit_jump (label2);
3821
 
3822
  emit_label (label1);
3823
  emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3824
  emit_label (label2);
3825
  DONE;
3826
})
3827
 
3828
(define_expand "fixuns_trunctddi2"
3829
  [(set (match_operand:DI 0 "register_operand" "")
3830
        (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))]
3831
  "TARGET_HARD_DFP"
3832
{
3833
  rtx label1 = gen_label_rtx ();
3834
  rtx label2 = gen_label_rtx ();
3835
  rtx temp = gen_reg_rtx (TDmode);
3836
  REAL_VALUE_TYPE cmp, sub;
3837
 
3838
  operands[1] = force_reg (TDmode, operands[1]);
3839
  decimal_real_from_string (&cmp, "9223372036854775808.0");  /* 2^63 */
3840
  decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3841
 
3842
  emit_cmp_and_jump_insns (operands[1],
3843
        CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode),
3844
        LT, NULL_RTX, VOIDmode, 0, label1);
3845
  emit_insn (gen_subtd3 (temp, operands[1],
3846
        CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3847
  emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3848
  emit_jump (label2);
3849
 
3850
  emit_label (label1);
3851
  emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3852
  emit_label (label2);
3853
  DONE;
3854
})
3855
 
3856
;
3857
; fixuns_trunc(sf|df)(si|di)2 and fix_trunc(sf|df)(si|di)2
3858
; instruction pattern(s).
3859
;
3860
 
3861
(define_expand "fixuns_trunc2"
3862
  [(set (match_operand:GPR 0 "register_operand" "")
3863
        (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))]
3864
  "TARGET_HARD_FLOAT"
3865
{
3866
  rtx label1 = gen_label_rtx ();
3867
  rtx label2 = gen_label_rtx ();
3868
  rtx temp = gen_reg_rtx (mode);
3869
  REAL_VALUE_TYPE cmp, sub;
3870
 
3871
  operands[1] = force_reg (mode, operands[1]);
3872
  real_2expN (&cmp, GET_MODE_BITSIZE(mode) - 1, mode);
3873
  real_2expN (&sub, GET_MODE_BITSIZE(mode), mode);
3874
 
3875
  emit_cmp_and_jump_insns (operands[1],
3876
        CONST_DOUBLE_FROM_REAL_VALUE (cmp, mode),
3877
        LT, NULL_RTX, VOIDmode, 0, label1);
3878
  emit_insn (gen_sub3 (temp, operands[1],
3879
        CONST_DOUBLE_FROM_REAL_VALUE (sub, mode)));
3880
  emit_insn (gen_fix_trunc2_bfp (operands[0], temp,
3881
        GEN_INT (7)));
3882
  emit_jump (label2);
3883
 
3884
  emit_label (label1);
3885
  emit_insn (gen_fix_trunc2_bfp (operands[0],
3886
        operands[1], GEN_INT (5)));
3887
  emit_label (label2);
3888
  DONE;
3889
})
3890
 
3891
(define_expand "fix_trunc2"
3892
  [(set (match_operand:GPR 0 "register_operand" "")
3893
        (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
3894
  "TARGET_HARD_FLOAT"
3895
{
3896
  emit_insn (gen_fix_trunc2_bfp (operands[0], operands[1],
3897
             GEN_INT (5)));
3898
  DONE;
3899
})
3900
 
3901
; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
3902
(define_insn "fix_trunc2_bfp"
3903
  [(set (match_operand:GPR 0 "register_operand" "=d")
3904
        (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
3905
   (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
3906
   (clobber (reg:CC CC_REGNUM))]
3907
  "TARGET_HARD_FLOAT"
3908
  "cbr\t%0,%h2,%1"
3909
  [(set_attr "op_type" "RRE")
3910
   (set_attr "type"    "ftoi")])
3911
 
3912
 
3913
;
3914
; fix_trunc(td|dd)di2 instruction pattern(s).
3915
;
3916
 
3917
(define_expand "fix_truncdi2"
3918
  [(set (match_operand:DI 0 "register_operand" "")
3919
        (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
3920
  "TARGET_64BIT && TARGET_HARD_DFP"
3921
{
3922
  operands[1] = force_reg (mode, operands[1]);
3923
  emit_insn (gen_fix_truncdi2_dfp (operands[0], operands[1],
3924
      GEN_INT (9)));
3925
  DONE;
3926
})
3927
 
3928
; cgxtr, cgdtr
3929
(define_insn "fix_truncdi2_dfp"
3930
  [(set (match_operand:DI 0 "register_operand" "=d")
3931
        (fix:DI (match_operand:DFP 1 "register_operand" "f")))
3932
   (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
3933
   (clobber (reg:CC CC_REGNUM))]
3934
  "TARGET_64BIT && TARGET_HARD_DFP"
3935
  "cgtr\t%0,%h2,%1"
3936
  [(set_attr "op_type" "RRF")
3937
   (set_attr "type"    "ftoidfp")])
3938
 
3939
 
3940
;
3941
; fix_trunctf(si|di)2 instruction pattern(s).
3942
;
3943
 
3944
(define_expand "fix_trunctf2"
3945
  [(parallel [(set (match_operand:GPR 0 "register_operand" "")
3946
                   (fix:GPR (match_operand:TF 1 "register_operand" "")))
3947
              (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
3948
              (clobber (reg:CC CC_REGNUM))])]
3949
  "TARGET_HARD_FLOAT"
3950
  "")
3951
 
3952
 
3953
;
3954
; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
3955
;
3956
 
3957
; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
3958
(define_insn "floatdi2"
3959
  [(set (match_operand:FP 0 "register_operand" "=f")
3960
        (float:FP (match_operand:DI 1 "register_operand" "d")))]
3961
  "TARGET_64BIT && TARGET_HARD_FLOAT"
3962
  "cgr\t%0,%1"
3963
  [(set_attr "op_type" "RRE")
3964
   (set_attr "type"    "itof" )])
3965
 
3966
; cxfbr, cdfbr, cefbr
3967
(define_insn "floatsi2"
3968
  [(set (match_operand:BFP 0 "register_operand" "=f")
3969
        (float:BFP (match_operand:SI 1 "register_operand" "d")))]
3970
  "TARGET_HARD_FLOAT"
3971
  "cfbr\t%0,%1"
3972
  [(set_attr "op_type" "RRE")
3973
   (set_attr "type"   "itof" )])
3974
 
3975
 
3976
;
3977
; truncdfsf2 instruction pattern(s).
3978
;
3979
 
3980
(define_insn "truncdfsf2"
3981
  [(set (match_operand:SF 0 "register_operand" "=f")
3982
        (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3983
  "TARGET_HARD_FLOAT"
3984
  "ledbr\t%0,%1"
3985
  [(set_attr "op_type"  "RRE")
3986
   (set_attr "type"   "ftruncdf")])
3987
 
3988
;
3989
; trunctf(df|sf)2 instruction pattern(s).
3990
;
3991
 
3992
; ldxbr, lexbr
3993
(define_insn "trunctf2"
3994
  [(set (match_operand:DSF 0 "register_operand" "=f")
3995
        (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
3996
   (clobber (match_scratch:TF 2 "=f"))]
3997
  "TARGET_HARD_FLOAT"
3998
  "lxbr\t%2,%1\;lr\t%0,%2"
3999
  [(set_attr "length" "6")
4000
   (set_attr "type"   "ftrunctf")])
4001
 
4002
;
4003
; trunctddd2 and truncddsd2 instruction pattern(s).
4004
;
4005
 
4006
(define_insn "trunctddd2"
4007
  [(set (match_operand:DD 0 "register_operand" "=f")
4008
        (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
4009
   (clobber (match_scratch:TD 2 "=f"))]
4010
  "TARGET_HARD_DFP"
4011
  "ldxtr\t%2,0,%1,0\;ldr\t%0,%2"
4012
  [(set_attr "length"  "6")
4013
   (set_attr "type"    "ftruncdd")])
4014
 
4015
(define_insn "truncddsd2"
4016
  [(set (match_operand:SD 0 "register_operand" "=f")
4017
        (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
4018
  "TARGET_HARD_DFP"
4019
  "ledtr\t%0,0,%1,0"
4020
  [(set_attr "op_type" "RRF")
4021
   (set_attr "type"    "ftruncsd")])
4022
 
4023
;
4024
; extend(sf|df)(df|tf)2 instruction pattern(s).
4025
;
4026
 
4027
; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
4028
(define_insn "extend2"
4029
  [(set (match_operand:BFP 0 "register_operand" "=f,f")
4030
        (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand"  "f,R")))]
4031
  "TARGET_HARD_FLOAT
4032
   && GET_MODE_SIZE (mode) > GET_MODE_SIZE (mode)"
4033
  "@
4034
   lbr\t%0,%1
4035
   lb\t%0,%1"
4036
  [(set_attr "op_type"  "RRE,RXE")
4037
   (set_attr "type"   "fsimp, fload")])
4038
 
4039
;
4040
; extendddtd2 and extendsddd2 instruction pattern(s).
4041
;
4042
 
4043
(define_insn "extendddtd2"
4044
  [(set (match_operand:TD 0 "register_operand" "=f")
4045
        (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
4046
  "TARGET_HARD_DFP"
4047
  "lxdtr\t%0,%1,0"
4048
  [(set_attr "op_type" "RRF")
4049
   (set_attr "type"    "fsimptf")])
4050
 
4051
(define_insn "extendsddd2"
4052
  [(set (match_operand:DD 0 "register_operand" "=f")
4053
        (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
4054
  "TARGET_HARD_DFP"
4055
  "ldetr\t%0,%1,0"
4056
  [(set_attr "op_type" "RRF")
4057
   (set_attr "type"    "fsimptf")])
4058
 
4059
; Binary <-> Decimal floating point trunc patterns
4060
;
4061
 
4062
(define_insn "*trunc2"
4063
  [(set (reg:DFP_ALL FPR0_REGNUM)
4064
        (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
4065
   (use (reg:SI GPR0_REGNUM))
4066
   (clobber (reg:CC CC_REGNUM))]
4067
  "TARGET_HARD_DFP"
4068
  "pfpo")
4069
 
4070
(define_insn "*trunc2"
4071
  [(set (reg:BFP FPR0_REGNUM)
4072
        (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
4073
   (use (reg:SI GPR0_REGNUM))
4074
   (clobber (reg:CC CC_REGNUM))]
4075
  "TARGET_HARD_DFP"
4076
  "pfpo")
4077
 
4078
(define_expand "trunc2"
4079
  [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4080
   (set (reg:SI GPR0_REGNUM) (match_dup 2))
4081
   (parallel
4082
    [(set (reg:DFP_ALL FPR0_REGNUM)
4083
          (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
4084
     (use (reg:SI GPR0_REGNUM))
4085
     (clobber (reg:CC CC_REGNUM))])
4086
   (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4087
        (reg:DFP_ALL FPR0_REGNUM))]
4088
  "TARGET_HARD_DFP
4089
   && GET_MODE_SIZE (mode) > GET_MODE_SIZE (mode)"
4090
{
4091
  HOST_WIDE_INT flags;
4092
 
4093
  flags = (PFPO_CONVERT |
4094
           PFPO_OP_TYPE_ << PFPO_OP0_TYPE_SHIFT |
4095
           PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT);
4096
 
4097
  operands[2] = GEN_INT (flags);
4098
})
4099
 
4100
(define_expand "trunc2"
4101
  [(set (reg:DFP_ALL FPR2_REGNUM)
4102
        (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4103
   (set (reg:SI GPR0_REGNUM) (match_dup 2))
4104
   (parallel
4105
    [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
4106
     (use (reg:SI GPR0_REGNUM))
4107
     (clobber (reg:CC CC_REGNUM))])
4108
   (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4109
  "TARGET_HARD_DFP
4110
   && GET_MODE_SIZE (mode) >= GET_MODE_SIZE (mode)"
4111
{
4112
  HOST_WIDE_INT flags;
4113
 
4114
  flags = (PFPO_CONVERT |
4115
           PFPO_OP_TYPE_ << PFPO_OP0_TYPE_SHIFT |
4116
           PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT);
4117
 
4118
  operands[2] = GEN_INT (flags);
4119
})
4120
 
4121
;
4122
; Binary <-> Decimal floating point extend patterns
4123
;
4124
 
4125
(define_insn "*extend2"
4126
  [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR2_REGNUM)))
4127
   (use (reg:SI GPR0_REGNUM))
4128
   (clobber (reg:CC CC_REGNUM))]
4129
  "TARGET_HARD_DFP"
4130
  "pfpo")
4131
 
4132
(define_insn "*extend2"
4133
  [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR2_REGNUM)))
4134
   (use (reg:SI GPR0_REGNUM))
4135
   (clobber (reg:CC CC_REGNUM))]
4136
  "TARGET_HARD_DFP"
4137
  "pfpo")
4138
 
4139
(define_expand "extend2"
4140
  [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4141
   (set (reg:SI GPR0_REGNUM) (match_dup 2))
4142
   (parallel
4143
    [(set (reg:DFP_ALL FPR0_REGNUM)
4144
          (float_extend:DFP_ALL (reg:BFP FPR2_REGNUM)))
4145
     (use (reg:SI GPR0_REGNUM))
4146
     (clobber (reg:CC CC_REGNUM))])
4147
   (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4148
        (reg:DFP_ALL FPR0_REGNUM))]
4149
  "TARGET_HARD_DFP
4150
   && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (mode)"
4151
{
4152
  HOST_WIDE_INT flags;
4153
 
4154
  flags = (PFPO_CONVERT |
4155
           PFPO_OP_TYPE_ << PFPO_OP0_TYPE_SHIFT |
4156
           PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT);
4157
 
4158
  operands[2] = GEN_INT (flags);
4159
})
4160
 
4161
(define_expand "extend2"
4162
  [(set (reg:DFP_ALL FPR2_REGNUM)
4163
        (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4164
   (set (reg:SI GPR0_REGNUM) (match_dup 2))
4165
   (parallel
4166
    [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR2_REGNUM)))
4167
     (use (reg:SI GPR0_REGNUM))
4168
     (clobber (reg:CC CC_REGNUM))])
4169
   (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4170
  "TARGET_HARD_DFP
4171
   && GET_MODE_SIZE (mode) < GET_MODE_SIZE (mode)"
4172
{
4173
  HOST_WIDE_INT flags;
4174
 
4175
  flags = (PFPO_CONVERT |
4176
           PFPO_OP_TYPE_ << PFPO_OP0_TYPE_SHIFT |
4177
           PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT);
4178
 
4179
  operands[2] = GEN_INT (flags);
4180
})
4181
 
4182
 
4183
;;
4184
;; ARITHMETIC OPERATIONS
4185
;;
4186
;  arithmetic operations set the ConditionCode,
4187
;  because of unpredictable Bits in Register for Halfword and Byte
4188
;  the ConditionCode can be set wrong in operations for Halfword and Byte
4189
 
4190
;;
4191
;;- Add instructions.
4192
;;
4193
 
4194
;
4195
; addti3 instruction pattern(s).
4196
;
4197
 
4198
(define_insn_and_split "addti3"
4199
  [(set (match_operand:TI 0 "register_operand" "=&d")
4200
        (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
4201
                 (match_operand:TI 2 "general_operand" "do") ) )
4202
   (clobber (reg:CC CC_REGNUM))]
4203
  "TARGET_64BIT"
4204
  "#"
4205
  "&& reload_completed"
4206
  [(parallel
4207
    [(set (reg:CCL1 CC_REGNUM)
4208
          (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
4209
                        (match_dup 7)))
4210
     (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
4211
   (parallel
4212
    [(set (match_dup 3) (plus:DI
4213
                          (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
4214
                                   (match_dup 4)) (match_dup 5)))
4215
     (clobber (reg:CC CC_REGNUM))])]
4216
  "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4217
   operands[4] = operand_subword (operands[1], 0, 0, TImode);
4218
   operands[5] = operand_subword (operands[2], 0, 0, TImode);
4219
   operands[6] = operand_subword (operands[0], 1, 0, TImode);
4220
   operands[7] = operand_subword (operands[1], 1, 0, TImode);
4221
   operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4222
 
4223
;
4224
; adddi3 instruction pattern(s).
4225
;
4226
 
4227
(define_expand "adddi3"
4228
  [(parallel
4229
    [(set (match_operand:DI 0 "nonimmediate_operand" "")
4230
          (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4231
                   (match_operand:DI 2 "general_operand" "")))
4232
     (clobber (reg:CC CC_REGNUM))])]
4233
  ""
4234
  "")
4235
 
4236
(define_insn "*adddi3_sign"
4237
  [(set (match_operand:DI 0 "register_operand" "=d,d")
4238
        (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4239
                 (match_operand:DI 1 "register_operand" "0,0")))
4240
   (clobber (reg:CC CC_REGNUM))]
4241
  "TARGET_64BIT"
4242
  "@
4243
   agfr\t%0,%2
4244
   agf\t%0,%2"
4245
  [(set_attr "op_type"  "RRE,RXY")])
4246
 
4247
(define_insn "*adddi3_zero_cc"
4248
  [(set (reg CC_REGNUM)
4249
        (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4250
                          (match_operand:DI 1 "register_operand" "0,0"))
4251
                 (const_int 0)))
4252
   (set (match_operand:DI 0 "register_operand" "=d,d")
4253
        (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
4254
  "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4255
  "@
4256
   algfr\t%0,%2
4257
   algf\t%0,%2"
4258
  [(set_attr "op_type"  "RRE,RXY")
4259
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4260
 
4261
(define_insn "*adddi3_zero_cconly"
4262
  [(set (reg CC_REGNUM)
4263
        (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4264
                          (match_operand:DI 1 "register_operand" "0,0"))
4265
                 (const_int 0)))
4266
   (clobber (match_scratch:DI 0 "=d,d"))]
4267
  "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4268
  "@
4269
   algfr\t%0,%2
4270
   algf\t%0,%2"
4271
  [(set_attr "op_type"  "RRE,RXY")
4272
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4273
 
4274
(define_insn "*adddi3_zero"
4275
  [(set (match_operand:DI 0 "register_operand" "=d,d")
4276
        (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4277
                 (match_operand:DI 1 "register_operand" "0,0")))
4278
   (clobber (reg:CC CC_REGNUM))]
4279
  "TARGET_64BIT"
4280
  "@
4281
   algfr\t%0,%2
4282
   algf\t%0,%2"
4283
  [(set_attr "op_type"  "RRE,RXY")
4284
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4285
 
4286
(define_insn_and_split "*adddi3_31z"
4287
  [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4288
        (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4289
                 (match_operand:DI 2 "general_operand" "do") ) )
4290
   (clobber (reg:CC CC_REGNUM))]
4291
  "!TARGET_64BIT && TARGET_CPU_ZARCH"
4292
  "#"
4293
  "&& reload_completed"
4294
  [(parallel
4295
    [(set (reg:CCL1 CC_REGNUM)
4296
          (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4297
                        (match_dup 7)))
4298
     (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4299
   (parallel
4300
    [(set (match_dup 3) (plus:SI
4301
                          (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
4302
                                   (match_dup 4)) (match_dup 5)))
4303
     (clobber (reg:CC CC_REGNUM))])]
4304
  "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4305
   operands[4] = operand_subword (operands[1], 0, 0, DImode);
4306
   operands[5] = operand_subword (operands[2], 0, 0, DImode);
4307
   operands[6] = operand_subword (operands[0], 1, 0, DImode);
4308
   operands[7] = operand_subword (operands[1], 1, 0, DImode);
4309
   operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4310
 
4311
(define_insn_and_split "*adddi3_31"
4312
  [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4313
        (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4314
                 (match_operand:DI 2 "general_operand" "do") ) )
4315
   (clobber (reg:CC CC_REGNUM))]
4316
  "!TARGET_CPU_ZARCH"
4317
  "#"
4318
  "&& reload_completed"
4319
  [(parallel
4320
    [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
4321
     (clobber (reg:CC CC_REGNUM))])
4322
   (parallel
4323
    [(set (reg:CCL1 CC_REGNUM)
4324
          (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4325
                        (match_dup 7)))
4326
     (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4327
   (set (pc)
4328
        (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
4329
                      (pc)
4330
                      (label_ref (match_dup 9))))
4331
   (parallel
4332
    [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
4333
     (clobber (reg:CC CC_REGNUM))])
4334
   (match_dup 9)]
4335
  "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4336
   operands[4] = operand_subword (operands[1], 0, 0, DImode);
4337
   operands[5] = operand_subword (operands[2], 0, 0, DImode);
4338
   operands[6] = operand_subword (operands[0], 1, 0, DImode);
4339
   operands[7] = operand_subword (operands[1], 1, 0, DImode);
4340
   operands[8] = operand_subword (operands[2], 1, 0, DImode);
4341
   operands[9] = gen_label_rtx ();")
4342
 
4343
;
4344
; addsi3 instruction pattern(s).
4345
;
4346
 
4347
(define_expand "addsi3"
4348
  [(parallel
4349
    [(set (match_operand:SI 0 "nonimmediate_operand" "")
4350
          (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
4351
                   (match_operand:SI 2 "general_operand" "")))
4352
     (clobber (reg:CC CC_REGNUM))])]
4353
  ""
4354
  "")
4355
 
4356
(define_insn "*addsi3_sign"
4357
  [(set (match_operand:SI 0 "register_operand" "=d,d")
4358
        (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
4359
                 (match_operand:SI 1 "register_operand" "0,0")))
4360
   (clobber (reg:CC CC_REGNUM))]
4361
  ""
4362
  "@
4363
   ah\t%0,%2
4364
   ahy\t%0,%2"
4365
  [(set_attr "op_type"  "RX,RXY")])
4366
 
4367
;
4368
; add(di|si)3 instruction pattern(s).
4369
;
4370
 
4371
; ar, ahi, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
4372
(define_insn "*add3"
4373
  [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,QS")
4374
        (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0,0")
4375
                  (match_operand:GPR 2 "general_operand" "d,K,Op,On,R,T,C") ) )
4376
   (clobber (reg:CC CC_REGNUM))]
4377
  ""
4378
  "@
4379
   ar\t%0,%2
4380
   ahi\t%0,%h2
4381
   alfi\t%0,%2
4382
   slfi\t%0,%n2
4383
   a\t%0,%2
4384
   a\t%0,%2
4385
   asi\t%0,%c2"
4386
  [(set_attr "op_type"  "RR,RI,RIL,RIL,RX,RXY,SIY")
4387
   (set_attr "cpu_facility" "*,*,extimm,extimm,*,*,z10")
4388
   (set_attr "z10prop" "z10_super_E1,
4389
                        z10_super_E1,
4390
                        z10_super_E1,
4391
                        z10_super_E1,
4392
                        z10_super_E1,
4393
                        z10_super_E1,
4394
                        z10_super_E1")])
4395
 
4396
; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4397
(define_insn "*add3_carry1_cc"
4398
  [(set (reg CC_REGNUM)
4399
        (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4400
                           (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4401
                 (match_dup 1)))
4402
   (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d")
4403
        (plus:GPR (match_dup 1) (match_dup 2)))]
4404
  "s390_match_ccmode (insn, CCL1mode)"
4405
  "@
4406
   alr\t%0,%2
4407
   alfi\t%0,%2
4408
   slfi\t%0,%n2
4409
   al\t%0,%2
4410
   al\t%0,%2
4411
   alsi\t%0,%c2"
4412
  [(set_attr "op_type"      "RR,RIL,RIL,RX,RXY,SIY")
4413
   (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4414
   (set_attr "z10prop" "z10_super_E1,
4415
                        z10_super_E1,
4416
                        z10_super_E1,
4417
                        z10_super_E1,
4418
                        z10_super_E1,
4419
                        z10_super_E1")])
4420
 
4421
; alr, al, aly, algr, alg
4422
(define_insn "*add3_carry1_cconly"
4423
  [(set (reg CC_REGNUM)
4424
        (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4425
                           (match_operand:GPR 2 "general_operand" "d,R,T"))
4426
                 (match_dup 1)))
4427
   (clobber (match_scratch:GPR 0 "=d,d,d"))]
4428
  "s390_match_ccmode (insn, CCL1mode)"
4429
  "@
4430
   alr\t%0,%2
4431
   al\t%0,%2
4432
   al\t%0,%2"
4433
  [(set_attr "op_type"  "RR,RX,RXY")
4434
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4435
 
4436
; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4437
(define_insn "*add3_carry2_cc"
4438
  [(set (reg CC_REGNUM)
4439
        (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4440
                           (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4441
                 (match_dup 2)))
4442
   (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,RS")
4443
        (plus:GPR (match_dup 1) (match_dup 2)))]
4444
  "s390_match_ccmode (insn, CCL1mode)"
4445
  "@
4446
   alr\t%0,%2
4447
   alfi\t%0,%2
4448
   slfi\t%0,%n2
4449
   al\t%0,%2
4450
   al\t%0,%2
4451
   alsi\t%0,%c2"
4452
  [(set_attr "op_type"  "RR,RIL,RIL,RX,RXY,SIY")
4453
   (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4454
   (set_attr "z10prop" "z10_super_E1,
4455
                        z10_super_E1,
4456
                        z10_super_E1,
4457
                        z10_super_E1,
4458
                        z10_super_E1,
4459
                        z10_super_E1")])
4460
 
4461
; alr, al, aly, algr, alg
4462
(define_insn "*add3_carry2_cconly"
4463
  [(set (reg CC_REGNUM)
4464
        (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4465
                           (match_operand:GPR 2 "general_operand" "d,R,T"))
4466
                 (match_dup 2)))
4467
   (clobber (match_scratch:GPR 0 "=d,d,d"))]
4468
  "s390_match_ccmode (insn, CCL1mode)"
4469
  "@
4470
   alr\t%0,%2
4471
   al\t%0,%2
4472
   al\t%0,%2"
4473
  [(set_attr "op_type"  "RR,RX,RXY")
4474
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4475
 
4476
; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4477
(define_insn "*add3_cc"
4478
  [(set (reg CC_REGNUM)
4479
        (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4480
                           (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4481
                 (const_int 0)))
4482
   (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,RS")
4483
        (plus:GPR (match_dup 1) (match_dup 2)))]
4484
  "s390_match_ccmode (insn, CCLmode)"
4485
  "@
4486
   alr\t%0,%2
4487
   alfi\t%0,%2
4488
   slfi\t%0,%n2
4489
   al\t%0,%2
4490
   al\t%0,%2
4491
   alsi\t%0,%c2"
4492
  [(set_attr "op_type"  "RR,RIL,RIL,RX,RXY,SIY")
4493
   (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4494
   (set_attr "z10prop" "z10_super_E1,
4495
                        z10_super_E1,
4496
                        z10_super_E1,
4497
                        z10_super_E1,
4498
                        z10_super_E1,
4499
                        z10_super_E1")])
4500
 
4501
; alr, al, aly, algr, alg
4502
(define_insn "*add3_cconly"
4503
  [(set (reg CC_REGNUM)
4504
        (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4505
                           (match_operand:GPR 2 "general_operand" "d,R,T"))
4506
                 (const_int 0)))
4507
   (clobber (match_scratch:GPR 0 "=d,d,d"))]
4508
  "s390_match_ccmode (insn, CCLmode)"
4509
  "@
4510
   alr\t%0,%2
4511
   al\t%0,%2
4512
   al\t%0,%2"
4513
  [(set_attr "op_type"  "RR,RX,RXY")
4514
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4515
 
4516
; alr, al, aly, algr, alg
4517
(define_insn "*add3_cconly2"
4518
  [(set (reg CC_REGNUM)
4519
        (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4520
                 (neg:GPR (match_operand:GPR 2 "general_operand" "d,R,T"))))
4521
   (clobber (match_scratch:GPR 0 "=d,d,d"))]
4522
  "s390_match_ccmode(insn, CCLmode)"
4523
  "@
4524
   alr\t%0,%2
4525
   al\t%0,%2
4526
   al\t%0,%2"
4527
  [(set_attr "op_type"  "RR,RX,RXY")
4528
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4529
 
4530
; ahi, afi, aghi, agfi, asi, agsi
4531
(define_insn "*add3_imm_cc"
4532
  [(set (reg CC_REGNUM)
4533
        (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0,0")
4534
                           (match_operand:GPR 2 "const_int_operand" "K,Os,C"))
4535
                 (const_int 0)))
4536
   (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,QS")
4537
        (plus:GPR (match_dup 1) (match_dup 2)))]
4538
  "s390_match_ccmode (insn, CCAmode)
4539
   && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
4540
       || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
4541
       || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'C', \"C\"))
4542
   && INTVAL (operands[2]) != -((HOST_WIDE_INT)1 << (GET_MODE_BITSIZE(mode) - 1))"
4543
  "@
4544
   ahi\t%0,%h2
4545
   afi\t%0,%2
4546
   asi\t%0,%c2"
4547
  [(set_attr "op_type"      "RI,RIL,SIY")
4548
   (set_attr "cpu_facility" "*,extimm,z10")
4549
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4550
 
4551
;
4552
; add(tf|df|sf|td|dd)3 instruction pattern(s).
4553
;
4554
 
4555
; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4556
(define_insn "add3"
4557
  [(set (match_operand:FP 0 "register_operand"              "=f,   f")
4558
        (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%,0")
4559
                 (match_operand:FP 2 "general_operand"      " f,")))
4560
   (clobber (reg:CC CC_REGNUM))]
4561
  "TARGET_HARD_FLOAT"
4562
  "@
4563
   ar\t%0,%2
4564
   ab\t%0,%2"
4565
  [(set_attr "op_type"  ",RXE")
4566
   (set_attr "type"     "fsimp")])
4567
 
4568
; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4569
(define_insn "*add3_cc"
4570
  [(set (reg CC_REGNUM)
4571
        (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%,0")
4572
                          (match_operand:FP 2 "general_operand"      " f,"))
4573
                 (match_operand:FP 3 "const0_operand" "")))
4574
   (set (match_operand:FP 0 "register_operand" "=f,f")
4575
        (plus:FP (match_dup 1) (match_dup 2)))]
4576
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4577
  "@
4578
   ar\t%0,%2
4579
   ab\t%0,%2"
4580
  [(set_attr "op_type"  ",RXE")
4581
   (set_attr "type"     "fsimp")])
4582
 
4583
; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4584
(define_insn "*add3_cconly"
4585
  [(set (reg CC_REGNUM)
4586
        (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%,0")
4587
                           (match_operand:FP 2 "general_operand"      " f,"))
4588
                 (match_operand:FP 3 "const0_operand" "")))
4589
   (clobber (match_scratch:FP 0 "=f,f"))]
4590
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4591
  "@
4592
   ar\t%0,%2
4593
   ab\t%0,%2"
4594
  [(set_attr "op_type"  ",RXE")
4595
   (set_attr "type"     "fsimp")])
4596
 
4597
 
4598
;;
4599
;;- Subtract instructions.
4600
;;
4601
 
4602
;
4603
; subti3 instruction pattern(s).
4604
;
4605
 
4606
(define_insn_and_split "subti3"
4607
  [(set (match_operand:TI 0 "register_operand" "=&d")
4608
        (minus:TI (match_operand:TI 1 "register_operand" "0")
4609
                  (match_operand:TI 2 "general_operand" "do") ) )
4610
   (clobber (reg:CC CC_REGNUM))]
4611
  "TARGET_64BIT"
4612
  "#"
4613
  "&& reload_completed"
4614
  [(parallel
4615
    [(set (reg:CCL2 CC_REGNUM)
4616
          (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
4617
                        (match_dup 7)))
4618
     (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
4619
   (parallel
4620
    [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
4621
                                  (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
4622
     (clobber (reg:CC CC_REGNUM))])]
4623
  "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4624
   operands[4] = operand_subword (operands[1], 0, 0, TImode);
4625
   operands[5] = operand_subword (operands[2], 0, 0, TImode);
4626
   operands[6] = operand_subword (operands[0], 1, 0, TImode);
4627
   operands[7] = operand_subword (operands[1], 1, 0, TImode);
4628
   operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4629
 
4630
;
4631
; subdi3 instruction pattern(s).
4632
;
4633
 
4634
(define_expand "subdi3"
4635
  [(parallel
4636
    [(set (match_operand:DI 0 "register_operand" "")
4637
          (minus:DI (match_operand:DI 1 "register_operand" "")
4638
                    (match_operand:DI 2 "general_operand" "")))
4639
     (clobber (reg:CC CC_REGNUM))])]
4640
  ""
4641
  "")
4642
 
4643
(define_insn "*subdi3_sign"
4644
  [(set (match_operand:DI 0 "register_operand" "=d,d")
4645
        (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4646
                  (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
4647
   (clobber (reg:CC CC_REGNUM))]
4648
  "TARGET_64BIT"
4649
  "@
4650
   sgfr\t%0,%2
4651
   sgf\t%0,%2"
4652
  [(set_attr "op_type"  "RRE,RXY")
4653
   (set_attr "z10prop" "z10_c,*")])
4654
 
4655
(define_insn "*subdi3_zero_cc"
4656
  [(set (reg CC_REGNUM)
4657
        (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4658
                           (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
4659
                 (const_int 0)))
4660
   (set (match_operand:DI 0 "register_operand" "=d,d")
4661
        (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
4662
  "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4663
  "@
4664
   slgfr\t%0,%2
4665
   slgf\t%0,%2"
4666
  [(set_attr "op_type"  "RRE,RXY")
4667
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4668
 
4669
(define_insn "*subdi3_zero_cconly"
4670
  [(set (reg CC_REGNUM)
4671
        (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4672
                           (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
4673
                 (const_int 0)))
4674
   (clobber (match_scratch:DI 0 "=d,d"))]
4675
  "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4676
  "@
4677
   slgfr\t%0,%2
4678
   slgf\t%0,%2"
4679
  [(set_attr "op_type"  "RRE,RXY")
4680
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4681
 
4682
(define_insn "*subdi3_zero"
4683
  [(set (match_operand:DI 0 "register_operand" "=d,d")
4684
        (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4685
                  (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
4686
   (clobber (reg:CC CC_REGNUM))]
4687
  "TARGET_64BIT"
4688
  "@
4689
   slgfr\t%0,%2
4690
   slgf\t%0,%2"
4691
  [(set_attr "op_type"  "RRE,RXY")
4692
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4693
 
4694
(define_insn_and_split "*subdi3_31z"
4695
  [(set (match_operand:DI 0 "register_operand" "=&d")
4696
        (minus:DI (match_operand:DI 1 "register_operand" "0")
4697
                  (match_operand:DI 2 "general_operand" "do") ) )
4698
   (clobber (reg:CC CC_REGNUM))]
4699
  "!TARGET_64BIT && TARGET_CPU_ZARCH"
4700
  "#"
4701
  "&& reload_completed"
4702
  [(parallel
4703
    [(set (reg:CCL2 CC_REGNUM)
4704
          (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4705
                        (match_dup 7)))
4706
     (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4707
   (parallel
4708
    [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
4709
                                  (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
4710
     (clobber (reg:CC CC_REGNUM))])]
4711
  "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4712
   operands[4] = operand_subword (operands[1], 0, 0, DImode);
4713
   operands[5] = operand_subword (operands[2], 0, 0, DImode);
4714
   operands[6] = operand_subword (operands[0], 1, 0, DImode);
4715
   operands[7] = operand_subword (operands[1], 1, 0, DImode);
4716
   operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4717
 
4718
(define_insn_and_split "*subdi3_31"
4719
  [(set (match_operand:DI 0 "register_operand" "=&d")
4720
        (minus:DI (match_operand:DI 1 "register_operand" "0")
4721
                  (match_operand:DI 2 "general_operand" "do") ) )
4722
   (clobber (reg:CC CC_REGNUM))]
4723
  "!TARGET_CPU_ZARCH"
4724
  "#"
4725
  "&& reload_completed"
4726
  [(parallel
4727
    [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
4728
     (clobber (reg:CC CC_REGNUM))])
4729
   (parallel
4730
    [(set (reg:CCL2 CC_REGNUM)
4731
          (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4732
                        (match_dup 7)))
4733
     (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4734
   (set (pc)
4735
        (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
4736
                      (pc)
4737
                      (label_ref (match_dup 9))))
4738
   (parallel
4739
    [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
4740
     (clobber (reg:CC CC_REGNUM))])
4741
   (match_dup 9)]
4742
  "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4743
   operands[4] = operand_subword (operands[1], 0, 0, DImode);
4744
   operands[5] = operand_subword (operands[2], 0, 0, DImode);
4745
   operands[6] = operand_subword (operands[0], 1, 0, DImode);
4746
   operands[7] = operand_subword (operands[1], 1, 0, DImode);
4747
   operands[8] = operand_subword (operands[2], 1, 0, DImode);
4748
   operands[9] = gen_label_rtx ();")
4749
 
4750
;
4751
; subsi3 instruction pattern(s).
4752
;
4753
 
4754
(define_expand "subsi3"
4755
  [(parallel
4756
    [(set (match_operand:SI 0 "register_operand" "")
4757
          (minus:SI (match_operand:SI 1 "register_operand" "")
4758
                    (match_operand:SI 2 "general_operand" "")))
4759
     (clobber (reg:CC CC_REGNUM))])]
4760
  ""
4761
  "")
4762
 
4763
(define_insn "*subsi3_sign"
4764
  [(set (match_operand:SI 0 "register_operand" "=d,d")
4765
        (minus:SI (match_operand:SI 1 "register_operand" "0,0")
4766
                  (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
4767
   (clobber (reg:CC CC_REGNUM))]
4768
  ""
4769
  "@
4770
   sh\t%0,%2
4771
   shy\t%0,%2"
4772
  [(set_attr "op_type"  "RX,RXY")])
4773
 
4774
;
4775
; sub(di|si)3 instruction pattern(s).
4776
;
4777
 
4778
; sr, s, sy, sgr, sg
4779
(define_insn "*sub3"
4780
  [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
4781
        (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4782
                   (match_operand:GPR 2 "general_operand" "d,R,T") ) )
4783
   (clobber (reg:CC CC_REGNUM))]
4784
  ""
4785
  "@
4786
   sr\t%0,%2
4787
   s\t%0,%2
4788
   s\t%0,%2"
4789
  [(set_attr "op_type"  "RR,RX,RXY")
4790
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4791
 
4792
; slr, sl, sly, slgr, slg
4793
(define_insn "*sub3_borrow_cc"
4794
  [(set (reg CC_REGNUM)
4795
        (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4796
                            (match_operand:GPR 2 "general_operand" "d,R,T"))
4797
                 (match_dup 1)))
4798
   (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4799
        (minus:GPR (match_dup 1) (match_dup 2)))]
4800
  "s390_match_ccmode (insn, CCL2mode)"
4801
  "@
4802
   slr\t%0,%2
4803
   sl\t%0,%2
4804
   sl\t%0,%2"
4805
  [(set_attr "op_type"  "RR,RX,RXY")
4806
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4807
 
4808
; slr, sl, sly, slgr, slg
4809
(define_insn "*sub3_borrow_cconly"
4810
  [(set (reg CC_REGNUM)
4811
        (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4812
                            (match_operand:GPR 2 "general_operand" "d,R,T"))
4813
                 (match_dup 1)))
4814
   (clobber (match_scratch:GPR 0 "=d,d,d"))]
4815
  "s390_match_ccmode (insn, CCL2mode)"
4816
  "@
4817
   slr\t%0,%2
4818
   sl\t%0,%2
4819
   sl\t%0,%2"
4820
  [(set_attr "op_type"  "RR,RX,RXY")
4821
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4822
 
4823
; slr, sl, sly, slgr, slg
4824
(define_insn "*sub3_cc"
4825
  [(set (reg CC_REGNUM)
4826
        (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4827
                            (match_operand:GPR 2 "general_operand" "d,R,T"))
4828
                 (const_int 0)))
4829
   (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4830
        (minus:GPR (match_dup 1) (match_dup 2)))]
4831
  "s390_match_ccmode (insn, CCLmode)"
4832
  "@
4833
   slr\t%0,%2
4834
   sl\t%0,%2
4835
   sl\t%0,%2"
4836
  [(set_attr "op_type"  "RR,RX,RXY")
4837
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4838
 
4839
; slr, sl, sly, slgr, slg
4840
(define_insn "*sub3_cc2"
4841
  [(set (reg CC_REGNUM)
4842
        (compare (match_operand:GPR 1 "register_operand" "0,0,0")
4843
                 (match_operand:GPR 2 "general_operand" "d,R,T")))
4844
   (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4845
        (minus:GPR (match_dup 1) (match_dup 2)))]
4846
  "s390_match_ccmode (insn, CCL3mode)"
4847
  "@
4848
   slr\t%0,%2
4849
   sl\t%0,%2
4850
   sl\t%0,%2"
4851
  [(set_attr "op_type"  "RR,RX,RXY")
4852
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4853
 
4854
; slr, sl, sly, slgr, slg
4855
(define_insn "*sub3_cconly"
4856
  [(set (reg CC_REGNUM)
4857
        (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4858
                            (match_operand:GPR 2 "general_operand" "d,R,T"))
4859
                 (const_int 0)))
4860
   (clobber (match_scratch:GPR 0 "=d,d,d"))]
4861
  "s390_match_ccmode (insn, CCLmode)"
4862
  "@
4863
   slr\t%0,%2
4864
   sl\t%0,%2
4865
   sl\t%0,%2"
4866
  [(set_attr "op_type"  "RR,RX,RXY")
4867
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4868
 
4869
 
4870
; slr, sl, sly, slgr, slg
4871
(define_insn "*sub3_cconly2"
4872
  [(set (reg CC_REGNUM)
4873
        (compare (match_operand:GPR 1 "register_operand" "0,0,0")
4874
                 (match_operand:GPR 2 "general_operand" "d,R,T")))
4875
   (clobber (match_scratch:GPR 0 "=d,d,d"))]
4876
  "s390_match_ccmode (insn, CCL3mode)"
4877
  "@
4878
   slr\t%0,%2
4879
   sl\t%0,%2
4880
   sl\t%0,%2"
4881
  [(set_attr "op_type"  "RR,RX,RXY")
4882
   (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4883
 
4884
 
4885
;
4886
; sub(tf|df|sf|td|dd)3 instruction pattern(s).
4887
;
4888
 
4889
; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4890
(define_insn "sub3"
4891
  [(set (match_operand:FP 0 "register_operand"            "=f,  f")
4892
        (minus:FP (match_operand:FP 1 "register_operand" ",0")
4893
                  (match_operand:FP 2 "general_operand"  "f,")))
4894
   (clobber (reg:CC CC_REGNUM))]
4895
  "TARGET_HARD_FLOAT"
4896
  "@
4897
   sr\t%0,%2
4898
   sb\t%0,%2"
4899
  [(set_attr "op_type"  ",RXE")
4900
   (set_attr "type"     "fsimp")])
4901
 
4902
; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4903
(define_insn "*sub3_cc"
4904
  [(set (reg CC_REGNUM)
4905
        (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" ",0")
4906
                           (match_operand:FP 2 "general_operand"      "f,"))
4907
                 (match_operand:FP 3 "const0_operand" "")))
4908
   (set (match_operand:FP 0 "register_operand" "=f,f")
4909
        (minus:FP (match_dup 1) (match_dup 2)))]
4910
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4911
  "@
4912
   sr\t%0,%2
4913
   sb\t%0,%2"
4914
  [(set_attr "op_type"  ",RXE")
4915
   (set_attr "type"     "fsimp")])
4916
 
4917
; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4918
(define_insn "*sub3_cconly"
4919
  [(set (reg CC_REGNUM)
4920
        (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" ",0")
4921
                           (match_operand:FP 2 "general_operand"      "f,"))
4922
                 (match_operand:FP 3 "const0_operand" "")))
4923
   (clobber (match_scratch:FP 0 "=f,f"))]
4924
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4925
  "@
4926
   sr\t%0,%2
4927
   sb\t%0,%2"
4928
  [(set_attr "op_type"  ",RXE")
4929
   (set_attr "type"     "fsimp")])
4930
 
4931
 
4932
;;
4933
;;- Conditional add/subtract instructions.
4934
;;
4935
 
4936
;
4937
; add(di|si)cc instruction pattern(s).
4938
;
4939
 
4940
; the following 4 patterns are used when the result of an add with
4941
; carry is checked for an overflow condition
4942
 
4943
; op1 + op2 + c < op1
4944
 
4945
; alcr, alc, alcgr, alcg
4946
(define_insn "*add3_alc_carry1_cc"
4947
  [(set (reg CC_REGNUM)
4948
        (compare
4949
          (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4950
                              (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4951
                    (match_operand:GPR 2 "general_operand" "d,RT"))
4952
          (match_dup 1)))
4953
   (set (match_operand:GPR 0 "register_operand" "=d,d")
4954
        (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
4955
  "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4956
  "@
4957
   alcr\t%0,%2
4958
   alc\t%0,%2"
4959
  [(set_attr "op_type"  "RRE,RXY")])
4960
 
4961
; alcr, alc, alcgr, alcg
4962
(define_insn "*add3_alc_carry1_cconly"
4963
  [(set (reg CC_REGNUM)
4964
        (compare
4965
          (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4966
                              (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4967
                    (match_operand:GPR 2 "general_operand" "d,RT"))
4968
          (match_dup 1)))
4969
   (clobber (match_scratch:GPR 0 "=d,d"))]
4970
  "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4971
  "@
4972
   alcr\t%0,%2
4973
   alc\t%0,%2"
4974
  [(set_attr "op_type"  "RRE,RXY")])
4975
 
4976
; op1 + op2 + c < op2
4977
 
4978
; alcr, alc, alcgr, alcg
4979
(define_insn "*add3_alc_carry2_cc"
4980
  [(set (reg CC_REGNUM)
4981
        (compare
4982
          (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4983
                              (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4984
                    (match_operand:GPR 2 "general_operand" "d,RT"))
4985
          (match_dup 2)))
4986
   (set (match_operand:GPR 0 "register_operand" "=d,d")
4987
        (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
4988
  "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4989
  "@
4990
   alcr\t%0,%2
4991
   alc\t%0,%2"
4992
  [(set_attr "op_type"  "RRE,RXY")])
4993
 
4994
; alcr, alc, alcgr, alcg
4995
(define_insn "*add3_alc_carry2_cconly"
4996
  [(set (reg CC_REGNUM)
4997
        (compare
4998
          (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4999
                              (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5000
                    (match_operand:GPR 2 "general_operand" "d,RT"))
5001
          (match_dup 2)))
5002
   (clobber (match_scratch:GPR 0 "=d,d"))]
5003
  "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5004
  "@
5005
   alcr\t%0,%2
5006
   alc\t%0,%2"
5007
  [(set_attr "op_type"  "RRE,RXY")])
5008
 
5009
; alcr, alc, alcgr, alcg
5010
(define_insn "*add3_alc_cc"
5011
  [(set (reg CC_REGNUM)
5012
        (compare
5013
          (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5014
                              (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5015
                    (match_operand:GPR 2 "general_operand" "d,RT"))
5016
          (const_int 0)))
5017
   (set (match_operand:GPR 0 "register_operand" "=d,d")
5018
        (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5019
  "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5020
  "@
5021
   alcr\t%0,%2
5022
   alc\t%0,%2"
5023
  [(set_attr "op_type"  "RRE,RXY")])
5024
 
5025
; alcr, alc, alcgr, alcg
5026
(define_insn "*add3_alc"
5027
  [(set (match_operand:GPR 0 "register_operand" "=d,d")
5028
        (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5029
                            (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5030
                  (match_operand:GPR 2 "general_operand" "d,RT")))
5031
   (clobber (reg:CC CC_REGNUM))]
5032
  "TARGET_CPU_ZARCH"
5033
  "@
5034
   alcr\t%0,%2
5035
   alc\t%0,%2"
5036
  [(set_attr "op_type"  "RRE,RXY")])
5037
 
5038
; slbr, slb, slbgr, slbg
5039
(define_insn "*sub3_slb_cc"
5040
  [(set (reg CC_REGNUM)
5041
        (compare
5042
          (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5043
                                (match_operand:GPR 2 "general_operand" "d,RT"))
5044
                     (match_operand:GPR 3 "s390_slb_comparison" ""))
5045
          (const_int 0)))
5046
   (set (match_operand:GPR 0 "register_operand" "=d,d")
5047
        (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
5048
  "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5049
  "@
5050
   slbr\t%0,%2
5051
   slb\t%0,%2"
5052
  [(set_attr "op_type"  "RRE,RXY")
5053
   (set_attr "z10prop" "z10_c,*")])
5054
 
5055
; slbr, slb, slbgr, slbg
5056
(define_insn "*sub3_slb"
5057
  [(set (match_operand:GPR 0 "register_operand" "=d,d")
5058
        (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5059
                              (match_operand:GPR 2 "general_operand" "d,RT"))
5060
                   (match_operand:GPR 3 "s390_slb_comparison" "")))
5061
   (clobber (reg:CC CC_REGNUM))]
5062
  "TARGET_CPU_ZARCH"
5063
  "@
5064
   slbr\t%0,%2
5065
   slb\t%0,%2"
5066
  [(set_attr "op_type"  "RRE,RXY")
5067
   (set_attr "z10prop" "z10_c,*")])
5068
 
5069
(define_expand "addcc"
5070
  [(match_operand:GPR 0 "register_operand" "")
5071
   (match_operand 1 "comparison_operator" "")
5072
   (match_operand:GPR 2 "register_operand" "")
5073
   (match_operand:GPR 3 "const_int_operand" "")]
5074
  "TARGET_CPU_ZARCH"
5075
  "if (!s390_expand_addcc (GET_CODE (operands[1]),
5076
                           XEXP (operands[1], 0), XEXP (operands[1], 1),
5077
                           operands[0], operands[2],
5078
                           operands[3])) FAIL; DONE;")
5079
 
5080
;
5081
; scond instruction pattern(s).
5082
;
5083
 
5084
(define_insn_and_split "*scond"
5085
  [(set (match_operand:GPR 0 "register_operand" "=&d")
5086
        (match_operand:GPR 1 "s390_alc_comparison" ""))
5087
   (clobber (reg:CC CC_REGNUM))]
5088
  "TARGET_CPU_ZARCH"
5089
  "#"
5090
  "&& reload_completed"
5091
  [(set (match_dup 0) (const_int 0))
5092
   (parallel
5093
    [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
5094
                                  (match_dup 0)))
5095
     (clobber (reg:CC CC_REGNUM))])]
5096
  "")
5097
 
5098
(define_insn_and_split "*scond_neg"
5099
  [(set (match_operand:GPR 0 "register_operand" "=&d")
5100
        (match_operand:GPR 1 "s390_slb_comparison" ""))
5101
   (clobber (reg:CC CC_REGNUM))]
5102
  "TARGET_CPU_ZARCH"
5103
  "#"
5104
  "&& reload_completed"
5105
  [(set (match_dup 0) (const_int 0))
5106
   (parallel
5107
    [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
5108
                                   (match_dup 1)))
5109
     (clobber (reg:CC CC_REGNUM))])
5110
   (parallel
5111
    [(set (match_dup 0) (neg:GPR (match_dup 0)))
5112
     (clobber (reg:CC CC_REGNUM))])]
5113
  "")
5114
 
5115
 
5116
(define_expand "cstore4"
5117
  [(set (match_operand:SI 0 "register_operand" "")
5118
        (match_operator:SI 1 "s390_scond_operator"
5119
         [(match_operand:GPR 2 "register_operand" "")
5120
          (match_operand:GPR 3 "general_operand" "")]))]
5121
  "TARGET_CPU_ZARCH"
5122
  "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3],
5123
                           operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
5124
 
5125
(define_expand "cstorecc4"
5126
  [(parallel
5127
    [(set (match_operand:SI 0 "register_operand" "")
5128
          (match_operator:SI 1 "s390_eqne_operator"
5129
           [(match_operand:CCZ1 2 "register_operand")
5130
            (match_operand 3 "const0_operand")]))
5131
     (clobber (reg:CC CC_REGNUM))])]
5132
  ""
5133
  "emit_insn (gen_sne (operands[0], operands[2]));
5134
   if (GET_CODE (operands[1]) == EQ)
5135
     emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
5136
   DONE;")
5137
 
5138
(define_insn_and_split "sne"
5139
  [(set (match_operand:SI 0 "register_operand" "=d")
5140
        (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
5141
               (const_int 0)))
5142
   (clobber (reg:CC CC_REGNUM))]
5143
  ""
5144
  "#"
5145
  "reload_completed"
5146
  [(parallel
5147
    [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
5148
     (clobber (reg:CC CC_REGNUM))])])
5149
 
5150
 
5151
;;
5152
;;- Multiply instructions.
5153
;;
5154
 
5155
;
5156
; muldi3 instruction pattern(s).
5157
;
5158
 
5159
(define_insn "*muldi3_sign"
5160
  [(set (match_operand:DI 0 "register_operand" "=d,d")
5161
        (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
5162
                 (match_operand:DI 1 "register_operand" "0,0")))]
5163
  "TARGET_64BIT"
5164
  "@
5165
   msgfr\t%0,%2
5166
   msgf\t%0,%2"
5167
  [(set_attr "op_type"      "RRE,RXY")
5168
   (set_attr "type"         "imuldi")])
5169
 
5170
(define_insn "muldi3"
5171
  [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
5172
        (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5173
                 (match_operand:DI 2 "general_operand" "d,K,RT,Os")))]
5174
  "TARGET_64BIT"
5175
  "@
5176
   msgr\t%0,%2
5177
   mghi\t%0,%h2
5178
   msg\t%0,%2
5179
   msgfi\t%0,%2"
5180
  [(set_attr "op_type"      "RRE,RI,RXY,RIL")
5181
   (set_attr "type"         "imuldi")
5182
   (set_attr "cpu_facility" "*,*,*,z10")])
5183
 
5184
;
5185
; mulsi3 instruction pattern(s).
5186
;
5187
 
5188
(define_insn "*mulsi3_sign"
5189
  [(set (match_operand:SI 0 "register_operand" "=d,d")
5190
        (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5191
                 (match_operand:SI 1 "register_operand" "0,0")))]
5192
  ""
5193
  "@
5194
   mh\t%0,%2
5195
   mhy\t%0,%2"
5196
  [(set_attr "op_type"      "RX,RXY")
5197
   (set_attr "type"         "imulhi")
5198
   (set_attr "cpu_facility" "*,z10")])
5199
 
5200
(define_insn "mulsi3"
5201
  [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
5202
        (mult:SI  (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
5203
                  (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
5204
  ""
5205
  "@
5206
   msr\t%0,%2
5207
   mhi\t%0,%h2
5208
   ms\t%0,%2
5209
   msy\t%0,%2
5210
   msfi\t%0,%2"
5211
  [(set_attr "op_type"      "RRE,RI,RX,RXY,RIL")
5212
   (set_attr "type"         "imulsi,imulhi,imulsi,imulsi,imulsi")
5213
   (set_attr "cpu_facility" "*,*,*,*,z10")])
5214
 
5215
;
5216
; mulsidi3 instruction pattern(s).
5217
;
5218
 
5219
(define_insn "mulsidi3"
5220
  [(set (match_operand:DI 0 "register_operand" "=d,d,d")
5221
        (mult:DI (sign_extend:DI
5222
                   (match_operand:SI 1 "register_operand" "%0,0,0"))
5223
                 (sign_extend:DI
5224
                   (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
5225
  "!TARGET_64BIT"
5226
  "@
5227
   mr\t%0,%2
5228
   m\t%0,%2
5229
   mfy\t%0,%2"
5230
  [(set_attr "op_type"      "RR,RX,RXY")
5231
   (set_attr "type"         "imulsi")
5232
   (set_attr "cpu_facility" "*,*,z10")])
5233
 
5234
;
5235
; umulsidi3 instruction pattern(s).
5236
;
5237
 
5238
(define_insn "umulsidi3"
5239
  [(set (match_operand:DI 0 "register_operand" "=d,d")
5240
        (mult:DI (zero_extend:DI
5241
                   (match_operand:SI 1 "register_operand" "%0,0"))
5242
                 (zero_extend:DI
5243
                   (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))]
5244
  "!TARGET_64BIT && TARGET_CPU_ZARCH"
5245
  "@
5246
   mlr\t%0,%2
5247
   ml\t%0,%2"
5248
  [(set_attr "op_type"  "RRE,RXY")
5249
   (set_attr "type"     "imulsi")])
5250
 
5251
;
5252
; mul(tf|df|sf|td|dd)3 instruction pattern(s).
5253
;
5254
 
5255
; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
5256
(define_insn "mul3"
5257
  [(set (match_operand:FP 0 "register_operand"              "=f,f")
5258
        (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%,0")
5259
                 (match_operand:FP 2 "general_operand"      "f,")))]
5260
  "TARGET_HARD_FLOAT"
5261
  "@
5262
   mr\t%0,%2
5263
   mb\t%0,%2"
5264
  [(set_attr "op_type"  ",RXE")
5265
   (set_attr "type"     "fmul")])
5266
 
5267
; madbr, maebr, maxb, madb, maeb
5268
(define_insn "*fmadd"
5269
  [(set (match_operand:DSF 0 "register_operand" "=f,f")
5270
        (plus:DSF (mult:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f")
5271
                            (match_operand:DSF 2 "nonimmediate_operand" "f,R"))
5272
                 (match_operand:DSF 3 "register_operand" "0,0")))]
5273
  "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5274
  "@
5275
   mabr\t%0,%1,%2
5276
   mab\t%0,%1,%2"
5277
  [(set_attr "op_type"  "RRE,RXE")
5278
   (set_attr "type"     "fmul")])
5279
 
5280
; msxbr, msdbr, msebr, msxb, msdb, mseb
5281
(define_insn "*fmsub"
5282
  [(set (match_operand:DSF 0 "register_operand" "=f,f")
5283
        (minus:DSF (mult:DSF (match_operand:DSF 1 "nonimmediate_operand" "f,f")
5284
                             (match_operand:DSF 2 "nonimmediate_operand" "f,R"))
5285
                 (match_operand:DSF 3 "register_operand" "0,0")))]
5286
  "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5287
  "@
5288
   msbr\t%0,%1,%2
5289
   msb\t%0,%1,%2"
5290
  [(set_attr "op_type"  "RRE,RXE")
5291
   (set_attr "type"     "fmul")])
5292
 
5293
;;
5294
;;- Divide and modulo instructions.
5295
;;
5296
 
5297
;
5298
; divmoddi4 instruction pattern(s).
5299
;
5300
 
5301
(define_expand "divmoddi4"
5302
  [(parallel [(set (match_operand:DI 0 "general_operand" "")
5303
                   (div:DI (match_operand:DI 1 "register_operand" "")
5304
                           (match_operand:DI 2 "general_operand" "")))
5305
              (set (match_operand:DI 3 "general_operand" "")
5306
                   (mod:DI (match_dup 1) (match_dup 2)))])
5307
   (clobber (match_dup 4))]
5308
  "TARGET_64BIT"
5309
{
5310
  rtx insn, div_equal, mod_equal;
5311
 
5312
  div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
5313
  mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
5314
 
5315
  operands[4] = gen_reg_rtx(TImode);
5316
  emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
5317
 
5318
  insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5319
  set_unique_reg_note (insn, REG_EQUAL, div_equal);
5320
 
5321
  insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5322
  set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5323
 
5324
  DONE;
5325
})
5326
 
5327
(define_insn "divmodtidi3"
5328
  [(set (match_operand:TI 0 "register_operand" "=d,d")
5329
        (ior:TI
5330
          (ashift:TI
5331
            (zero_extend:TI
5332
              (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5333
                      (match_operand:DI 2 "general_operand" "d,RT")))
5334
            (const_int 64))
5335
          (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
5336
  "TARGET_64BIT"
5337
  "@
5338
   dsgr\t%0,%2
5339
   dsg\t%0,%2"
5340
  [(set_attr "op_type"  "RRE,RXY")
5341
   (set_attr "type"     "idiv")])
5342
 
5343
(define_insn "divmodtisi3"
5344
  [(set (match_operand:TI 0 "register_operand" "=d,d")
5345
        (ior:TI
5346
          (ashift:TI
5347
            (zero_extend:TI
5348
              (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5349
                      (sign_extend:DI
5350
                        (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))
5351
            (const_int 64))
5352
          (zero_extend:TI
5353
            (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
5354
  "TARGET_64BIT"
5355
  "@
5356
   dsgfr\t%0,%2
5357
   dsgf\t%0,%2"
5358
  [(set_attr "op_type"  "RRE,RXY")
5359
   (set_attr "type"     "idiv")])
5360
 
5361
;
5362
; udivmoddi4 instruction pattern(s).
5363
;
5364
 
5365
(define_expand "udivmoddi4"
5366
  [(parallel [(set (match_operand:DI 0 "general_operand" "")
5367
                   (udiv:DI (match_operand:DI 1 "general_operand" "")
5368
                            (match_operand:DI 2 "nonimmediate_operand" "")))
5369
              (set (match_operand:DI 3 "general_operand" "")
5370
                   (umod:DI (match_dup 1) (match_dup 2)))])
5371
   (clobber (match_dup 4))]
5372
  "TARGET_64BIT"
5373
{
5374
  rtx insn, div_equal, mod_equal, equal;
5375
 
5376
  div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
5377
  mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
5378
  equal = gen_rtx_IOR (TImode,
5379
                       gen_rtx_ASHIFT (TImode,
5380
                                       gen_rtx_ZERO_EXTEND (TImode, mod_equal),
5381
                                       GEN_INT (64)),
5382
                       gen_rtx_ZERO_EXTEND (TImode, div_equal));
5383
 
5384
  operands[4] = gen_reg_rtx(TImode);
5385
  emit_clobber (operands[4]);
5386
  emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
5387
  emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
5388
 
5389
  insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
5390
  set_unique_reg_note (insn, REG_EQUAL, equal);
5391
 
5392
  insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5393
  set_unique_reg_note (insn, REG_EQUAL, div_equal);
5394
 
5395
  insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5396
  set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5397
 
5398
  DONE;
5399
})
5400
 
5401
(define_insn "udivmodtidi3"
5402
  [(set (match_operand:TI 0 "register_operand" "=d,d")
5403
        (ior:TI
5404
          (ashift:TI
5405
            (zero_extend:TI
5406
              (truncate:DI
5407
                (umod:TI (match_operand:TI 1 "register_operand" "0,0")
5408
                         (zero_extend:TI
5409
                           (match_operand:DI 2 "nonimmediate_operand" "d,RT")))))
5410
            (const_int 64))
5411
          (zero_extend:TI
5412
            (truncate:DI
5413
              (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
5414
  "TARGET_64BIT"
5415
  "@
5416
   dlgr\t%0,%2
5417
   dlg\t%0,%2"
5418
  [(set_attr "op_type"  "RRE,RXY")
5419
   (set_attr "type"     "idiv")])
5420
 
5421
;
5422
; divmodsi4 instruction pattern(s).
5423
;
5424
 
5425
(define_expand "divmodsi4"
5426
  [(parallel [(set (match_operand:SI 0 "general_operand" "")
5427
                   (div:SI (match_operand:SI 1 "general_operand" "")
5428
                           (match_operand:SI 2 "nonimmediate_operand" "")))
5429
              (set (match_operand:SI 3 "general_operand" "")
5430
                   (mod:SI (match_dup 1) (match_dup 2)))])
5431
   (clobber (match_dup 4))]
5432
  "!TARGET_64BIT"
5433
{
5434
  rtx insn, div_equal, mod_equal, equal;
5435
 
5436
  div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
5437
  mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
5438
  equal = gen_rtx_IOR (DImode,
5439
                       gen_rtx_ASHIFT (DImode,
5440
                                       gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5441
                                       GEN_INT (32)),
5442
                       gen_rtx_ZERO_EXTEND (DImode, div_equal));
5443
 
5444
  operands[4] = gen_reg_rtx(DImode);
5445
  emit_insn (gen_extendsidi2 (operands[4], operands[1]));
5446
 
5447
  insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
5448
  set_unique_reg_note (insn, REG_EQUAL, equal);
5449
 
5450
  insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5451
  set_unique_reg_note (insn, REG_EQUAL, div_equal);
5452
 
5453
  insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5454
  set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5455
 
5456
  DONE;
5457
})
5458
 
5459
(define_insn "divmoddisi3"
5460
  [(set (match_operand:DI 0 "register_operand" "=d,d")
5461
        (ior:DI
5462
          (ashift:DI
5463
            (zero_extend:DI
5464
              (truncate:SI
5465
                (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5466
                        (sign_extend:DI
5467
                          (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
5468
            (const_int 32))
5469
          (zero_extend:DI
5470
            (truncate:SI
5471
              (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
5472
  "!TARGET_64BIT"
5473
  "@
5474
   dr\t%0,%2
5475
   d\t%0,%2"
5476
  [(set_attr "op_type"  "RR,RX")
5477
   (set_attr "type"     "idiv")])
5478
 
5479
;
5480
; udivsi3 and umodsi3 instruction pattern(s).
5481
;
5482
 
5483
(define_expand "udivmodsi4"
5484
  [(parallel [(set (match_operand:SI 0 "general_operand" "")
5485
                   (udiv:SI (match_operand:SI 1 "general_operand" "")
5486
                            (match_operand:SI 2 "nonimmediate_operand" "")))
5487
              (set (match_operand:SI 3 "general_operand" "")
5488
                   (umod:SI (match_dup 1) (match_dup 2)))])
5489
   (clobber (match_dup 4))]
5490
  "!TARGET_64BIT && TARGET_CPU_ZARCH"
5491
{
5492
  rtx insn, div_equal, mod_equal, equal;
5493
 
5494
  div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5495
  mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5496
  equal = gen_rtx_IOR (DImode,
5497
                       gen_rtx_ASHIFT (DImode,
5498
                                       gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5499
                                       GEN_INT (32)),
5500
                       gen_rtx_ZERO_EXTEND (DImode, div_equal));
5501
 
5502
  operands[4] = gen_reg_rtx(DImode);
5503
  emit_clobber (operands[4]);
5504
  emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
5505
  emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
5506
 
5507
  insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
5508
  set_unique_reg_note (insn, REG_EQUAL, equal);
5509
 
5510
  insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5511
  set_unique_reg_note (insn, REG_EQUAL, div_equal);
5512
 
5513
  insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5514
  set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5515
 
5516
  DONE;
5517
})
5518
 
5519
(define_insn "udivmoddisi3"
5520
  [(set (match_operand:DI 0 "register_operand" "=d,d")
5521
        (ior:DI
5522
          (ashift:DI
5523
            (zero_extend:DI
5524
              (truncate:SI
5525
                (umod:DI (match_operand:DI 1 "register_operand" "0,0")
5526
                         (zero_extend:DI
5527
                           (match_operand:SI 2 "nonimmediate_operand" "d,RT")))))
5528
            (const_int 32))
5529
          (zero_extend:DI
5530
            (truncate:SI
5531
              (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
5532
  "!TARGET_64BIT && TARGET_CPU_ZARCH"
5533
  "@
5534
   dlr\t%0,%2
5535
   dl\t%0,%2"
5536
  [(set_attr "op_type"  "RRE,RXY")
5537
   (set_attr "type"     "idiv")])
5538
 
5539
(define_expand "udivsi3"
5540
  [(set (match_operand:SI 0 "register_operand" "=d")
5541
        (udiv:SI (match_operand:SI 1 "general_operand" "")
5542
                 (match_operand:SI 2 "general_operand" "")))
5543
   (clobber (match_dup 3))]
5544
  "!TARGET_64BIT && !TARGET_CPU_ZARCH"
5545
{
5546
  rtx insn, udiv_equal, umod_equal, equal;
5547
 
5548
  udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5549
  umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5550
  equal = gen_rtx_IOR (DImode,
5551
                       gen_rtx_ASHIFT (DImode,
5552
                                       gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5553
                                       GEN_INT (32)),
5554
                       gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5555
 
5556
  operands[3] = gen_reg_rtx (DImode);
5557
 
5558
  if (CONSTANT_P (operands[2]))
5559
    {
5560
      if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
5561
        {
5562
          rtx label1 = gen_label_rtx ();
5563
 
5564
          operands[1] = make_safe_from (operands[1], operands[0]);
5565
          emit_move_insn (operands[0], const0_rtx);
5566
          emit_cmp_and_jump_insns (operands[1], operands[2], LT, NULL_RTX,
5567
                                   SImode, 1, label1);
5568
          emit_move_insn (operands[0], const1_rtx);
5569
          emit_label (label1);
5570
        }
5571
      else
5572
        {
5573
          operands[2] = force_reg (SImode, operands[2]);
5574
          operands[2] = make_safe_from (operands[2], operands[0]);
5575
 
5576
          emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5577
          insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5578
                                             operands[2]));
5579
          set_unique_reg_note (insn, REG_EQUAL, equal);
5580
 
5581
          insn = emit_move_insn (operands[0],
5582
                                 gen_lowpart (SImode, operands[3]));
5583
          set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5584
        }
5585
    }
5586
  else
5587
    {
5588
      rtx label1 = gen_label_rtx ();
5589
      rtx label2 = gen_label_rtx ();
5590
      rtx label3 = gen_label_rtx ();
5591
 
5592
      operands[1] = force_reg (SImode, operands[1]);
5593
      operands[1] = make_safe_from (operands[1], operands[0]);
5594
      operands[2] = force_reg (SImode, operands[2]);
5595
      operands[2] = make_safe_from (operands[2], operands[0]);
5596
 
5597
      emit_move_insn (operands[0], const0_rtx);
5598
      emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
5599
                               SImode, 1, label3);
5600
      emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
5601
                               SImode, 0, label2);
5602
      emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
5603
                               SImode, 0, label1);
5604
      emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5605
      insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5606
                                         operands[2]));
5607
      set_unique_reg_note (insn, REG_EQUAL, equal);
5608
 
5609
      insn = emit_move_insn (operands[0],
5610
                             gen_lowpart (SImode, operands[3]));
5611
      set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5612
 
5613
      emit_jump (label3);
5614
      emit_label (label1);
5615
      emit_move_insn (operands[0], operands[1]);
5616
      emit_jump (label3);
5617
      emit_label (label2);
5618
      emit_move_insn (operands[0], const1_rtx);
5619
      emit_label (label3);
5620
    }
5621
  emit_move_insn (operands[0], operands[0]);
5622
  DONE;
5623
})
5624
 
5625
(define_expand "umodsi3"
5626
  [(set (match_operand:SI 0 "register_operand" "=d")
5627
        (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
5628
                 (match_operand:SI 2 "nonimmediate_operand" "")))
5629
   (clobber (match_dup 3))]
5630
  "!TARGET_64BIT && !TARGET_CPU_ZARCH"
5631
{
5632
  rtx insn, udiv_equal, umod_equal, equal;
5633
 
5634
  udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5635
  umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5636
  equal = gen_rtx_IOR (DImode,
5637
                       gen_rtx_ASHIFT (DImode,
5638
                                       gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5639
                                       GEN_INT (32)),
5640
                       gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5641
 
5642
  operands[3] = gen_reg_rtx (DImode);
5643
 
5644
  if (CONSTANT_P (operands[2]))
5645
    {
5646
      if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
5647
        {
5648
          rtx label1 = gen_label_rtx ();
5649
 
5650
          operands[1] = make_safe_from (operands[1], operands[0]);
5651
          emit_move_insn (operands[0], operands[1]);
5652
          emit_cmp_and_jump_insns (operands[0], operands[2], LT, NULL_RTX,
5653
                                   SImode, 1, label1);
5654
          emit_insn (gen_abssi2 (operands[0], operands[2]));
5655
          emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
5656
          emit_label (label1);
5657
        }
5658
      else
5659
        {
5660
          operands[2] = force_reg (SImode, operands[2]);
5661
          operands[2] = make_safe_from (operands[2], operands[0]);
5662
 
5663
          emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5664
          insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5665
                                             operands[2]));
5666
          set_unique_reg_note (insn, REG_EQUAL, equal);
5667
 
5668
          insn = emit_move_insn (operands[0],
5669
                                 gen_highpart (SImode, operands[3]));
5670
          set_unique_reg_note (insn, REG_EQUAL, umod_equal);
5671
        }
5672
    }
5673
  else
5674
    {
5675
      rtx label1 = gen_label_rtx ();
5676
      rtx label2 = gen_label_rtx ();
5677
      rtx label3 = gen_label_rtx ();
5678
 
5679
      operands[1] = force_reg (SImode, operands[1]);
5680
      operands[1] = make_safe_from (operands[1], operands[0]);
5681
      operands[2] = force_reg (SImode, operands[2]);
5682
      operands[2] = make_safe_from (operands[2], operands[0]);
5683
 
5684
      emit_move_insn(operands[0], operands[1]);
5685
      emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
5686
                               SImode, 1, label3);
5687
      emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
5688
                               SImode, 0, label2);
5689
      emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
5690
                               SImode, 0, label1);
5691
      emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5692
      insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5693
                                         operands[2]));
5694
      set_unique_reg_note (insn, REG_EQUAL, equal);
5695
 
5696
      insn = emit_move_insn (operands[0],
5697
                             gen_highpart (SImode, operands[3]));
5698
      set_unique_reg_note (insn, REG_EQUAL, umod_equal);
5699
 
5700
      emit_jump (label3);
5701
      emit_label (label1);
5702
      emit_move_insn (operands[0], const0_rtx);
5703
      emit_jump (label3);
5704
      emit_label (label2);
5705
      emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
5706
      emit_label (label3);
5707
    }
5708
  DONE;
5709
})
5710
 
5711
;
5712
; div(df|sf)3 instruction pattern(s).
5713
;
5714
 
5715
; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
5716
(define_insn "div3"
5717
  [(set (match_operand:FP 0 "register_operand"          "=f,f")
5718
        (div:FP (match_operand:FP 1 "register_operand" ",0")
5719
                 (match_operand:FP 2 "general_operand"  "f,")))]
5720
  "TARGET_HARD_FLOAT"
5721
  "@
5722
   dr\t%0,%2
5723
   db\t%0,%2"
5724
  [(set_attr "op_type"  ",RXE")
5725
   (set_attr "type"     "fdiv")])
5726
 
5727
 
5728
;;
5729
;;- And instructions.
5730
;;
5731
 
5732
(define_expand "and3"
5733
  [(set (match_operand:INT 0 "nonimmediate_operand" "")
5734
        (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
5735
                 (match_operand:INT 2 "general_operand" "")))
5736
   (clobber (reg:CC CC_REGNUM))]
5737
  ""
5738
  "s390_expand_logical_operator (AND, mode, operands); DONE;")
5739
 
5740
;
5741
; anddi3 instruction pattern(s).
5742
;
5743
 
5744
(define_insn "*anddi3_cc"
5745
  [(set (reg CC_REGNUM)
5746
        (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5747
                         (match_operand:DI 2 "general_operand" "d,RT"))
5748
                 (const_int 0)))
5749
   (set (match_operand:DI 0 "register_operand" "=d,d")
5750
        (and:DI (match_dup 1) (match_dup 2)))]
5751
  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5752
  "@
5753
   ngr\t%0,%2
5754
   ng\t%0,%2"
5755
  [(set_attr "op_type"  "RRE,RXY")
5756
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5757
 
5758
(define_insn "*anddi3_cconly"
5759
  [(set (reg CC_REGNUM)
5760
        (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5761
                         (match_operand:DI 2 "general_operand" "d,RT"))
5762
                 (const_int 0)))
5763
   (clobber (match_scratch:DI 0 "=d,d"))]
5764
  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
5765
   /* Do not steal TM patterns.  */
5766
   && s390_single_part (operands[2], DImode, HImode, 0) < 0"
5767
  "@
5768
   ngr\t%0,%2
5769
   ng\t%0,%2"
5770
  [(set_attr "op_type"  "RRE,RXY")
5771
   (set_attr "z10prop" "z10_super_E1, z10_super_E1")])
5772
 
5773
(define_insn "*anddi3"
5774
  [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,d,d,AQ,Q")
5775
        (and:DI (match_operand:DI 1 "nonimmediate_operand"
5776
                                    "%d,o,0,0,0,0,0,0,0,0,0,0")
5777
                (match_operand:DI 2 "general_operand"
5778
                                    "M,M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,RT,NxQDF,Q")))
5779
   (clobber (reg:CC CC_REGNUM))]
5780
  "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5781
  "@
5782
   #
5783
   #
5784
   nihh\t%0,%j2
5785
   nihl\t%0,%j2
5786
   nilh\t%0,%j2
5787
   nill\t%0,%j2
5788
   nihf\t%0,%m2
5789
   nilf\t%0,%m2
5790
   ngr\t%0,%2
5791
   ng\t%0,%2
5792
   #
5793
   #"
5794
  [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")
5795
   (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,*,*,*")
5796
   (set_attr "z10prop" "*,
5797
                        *,
5798
                        z10_super_E1,
5799
                        z10_super_E1,
5800
                        z10_super_E1,
5801
                        z10_super_E1,
5802
                        z10_super_E1,
5803
                        z10_super_E1,
5804
                        z10_super_E1,
5805
                        z10_super_E1,
5806
                        *,
5807
                        *")])
5808
 
5809
(define_split
5810
  [(set (match_operand:DI 0 "s_operand" "")
5811
        (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5812
   (clobber (reg:CC CC_REGNUM))]
5813
  "reload_completed"
5814
  [(parallel
5815
    [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5816
     (clobber (reg:CC CC_REGNUM))])]
5817
  "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5818
 
5819
 
5820
;
5821
; andsi3 instruction pattern(s).
5822
;
5823
 
5824
(define_insn "*andsi3_cc"
5825
  [(set (reg CC_REGNUM)
5826
        (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5827
                         (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5828
                 (const_int 0)))
5829
   (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
5830
        (and:SI (match_dup 1) (match_dup 2)))]
5831
  "s390_match_ccmode(insn, CCTmode)"
5832
  "@
5833
   nilf\t%0,%o2
5834
   nr\t%0,%2
5835
   n\t%0,%2
5836
   ny\t%0,%2"
5837
  [(set_attr "op_type"  "RIL,RR,RX,RXY")
5838
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
5839
 
5840
(define_insn "*andsi3_cconly"
5841
  [(set (reg CC_REGNUM)
5842
        (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5843
                         (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5844
                 (const_int 0)))
5845
   (clobber (match_scratch:SI 0 "=d,d,d,d"))]
5846
  "s390_match_ccmode(insn, CCTmode)
5847
   /* Do not steal TM patterns.  */
5848
   && s390_single_part (operands[2], SImode, HImode, 0) < 0"
5849
  "@
5850
   nilf\t%0,%o2
5851
   nr\t%0,%2
5852
   n\t%0,%2
5853
   ny\t%0,%2"
5854
  [(set_attr "op_type"  "RIL,RR,RX,RXY")
5855
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
5856
 
5857
(define_insn "*andsi3_zarch"
5858
  [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
5859
        (and:SI (match_operand:SI 1 "nonimmediate_operand"
5860
                                    "%d,o,0,0,0,0,0,0,0,0")
5861
                (match_operand:SI 2 "general_operand"
5862
                                    "M,M,N0HSF,N1HSF,Os,d,R,T,NxQSF,Q")))
5863
   (clobber (reg:CC CC_REGNUM))]
5864
  "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5865
  "@
5866
   #
5867
   #
5868
   nilh\t%0,%j2
5869
   nill\t%0,%j2
5870
   nilf\t%0,%o2
5871
   nr\t%0,%2
5872
   n\t%0,%2
5873
   ny\t%0,%2
5874
   #
5875
   #"
5876
  [(set_attr "op_type"  "RRE,RXE,RI,RI,RIL,RR,RX,RXY,SI,SS")
5877
   (set_attr "z10prop" "*,
5878
                        *,
5879
                        z10_super_E1,
5880
                        z10_super_E1,
5881
                        z10_super_E1,
5882
                        z10_super_E1,
5883
                        z10_super_E1,
5884
                        z10_super_E1,
5885
                        *,
5886
                        *")])
5887
 
5888
(define_insn "*andsi3_esa"
5889
  [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5890
        (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5891
                (match_operand:SI 2 "general_operand" "d,R,NxQSF,Q")))
5892
   (clobber (reg:CC CC_REGNUM))]
5893
  "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5894
  "@
5895
   nr\t%0,%2
5896
   n\t%0,%2
5897
   #
5898
   #"
5899
  [(set_attr "op_type"  "RR,RX,SI,SS")
5900
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
5901
 
5902
 
5903
(define_split
5904
  [(set (match_operand:SI 0 "s_operand" "")
5905
        (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5906
   (clobber (reg:CC CC_REGNUM))]
5907
  "reload_completed"
5908
  [(parallel
5909
    [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5910
     (clobber (reg:CC CC_REGNUM))])]
5911
  "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5912
 
5913
;
5914
; andhi3 instruction pattern(s).
5915
;
5916
 
5917
(define_insn "*andhi3_zarch"
5918
  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5919
        (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5920
                (match_operand:HI 2 "general_operand" "d,n,NxQHF,Q")))
5921
   (clobber (reg:CC CC_REGNUM))]
5922
  "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5923
  "@
5924
   nr\t%0,%2
5925
   nill\t%0,%x2
5926
   #
5927
   #"
5928
  [(set_attr "op_type"  "RR,RI,SI,SS")
5929
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")
5930
])
5931
 
5932
(define_insn "*andhi3_esa"
5933
  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5934
        (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5935
                (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
5936
   (clobber (reg:CC CC_REGNUM))]
5937
  "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5938
  "@
5939
   nr\t%0,%2
5940
   #
5941
   #"
5942
  [(set_attr "op_type"  "RR,SI,SS")
5943
   (set_attr "z10prop" "z10_super_E1,*,*")
5944
])
5945
 
5946
(define_split
5947
  [(set (match_operand:HI 0 "s_operand" "")
5948
        (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5949
   (clobber (reg:CC CC_REGNUM))]
5950
  "reload_completed"
5951
  [(parallel
5952
    [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5953
     (clobber (reg:CC CC_REGNUM))])]
5954
  "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5955
 
5956
;
5957
; andqi3 instruction pattern(s).
5958
;
5959
 
5960
(define_insn "*andqi3_zarch"
5961
  [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5962
        (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5963
                (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5964
   (clobber (reg:CC CC_REGNUM))]
5965
  "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5966
  "@
5967
   nr\t%0,%2
5968
   nill\t%0,%b2
5969
   ni\t%S0,%b2
5970
   niy\t%S0,%b2
5971
   #"
5972
  [(set_attr "op_type"  "RR,RI,SI,SIY,SS")
5973
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
5974
 
5975
(define_insn "*andqi3_esa"
5976
  [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5977
        (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5978
                (match_operand:QI 2 "general_operand" "d,n,Q")))
5979
   (clobber (reg:CC CC_REGNUM))]
5980
  "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5981
  "@
5982
   nr\t%0,%2
5983
   ni\t%S0,%b2
5984
   #"
5985
  [(set_attr "op_type"  "RR,SI,SS")
5986
   (set_attr "z10prop" "z10_super_E1,z10_super,*")])
5987
 
5988
;
5989
; Block and (NC) patterns.
5990
;
5991
 
5992
(define_insn "*nc"
5993
  [(set (match_operand:BLK 0 "memory_operand" "=Q")
5994
        (and:BLK (match_dup 0)
5995
                 (match_operand:BLK 1 "memory_operand" "Q")))
5996
   (use (match_operand 2 "const_int_operand" "n"))
5997
   (clobber (reg:CC CC_REGNUM))]
5998
  "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5999
  "nc\t%O0(%2,%R0),%S1"
6000
  [(set_attr "op_type" "SS")])
6001
 
6002
(define_split
6003
  [(set (match_operand 0 "memory_operand" "")
6004
        (and (match_dup 0)
6005
             (match_operand 1 "memory_operand" "")))
6006
   (clobber (reg:CC CC_REGNUM))]
6007
  "reload_completed
6008
   && GET_MODE (operands[0]) == GET_MODE (operands[1])
6009
   && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6010
  [(parallel
6011
    [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
6012
     (use (match_dup 2))
6013
     (clobber (reg:CC CC_REGNUM))])]
6014
{
6015
  operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6016
  operands[0] = adjust_address (operands[0], BLKmode, 0);
6017
  operands[1] = adjust_address (operands[1], BLKmode, 0);
6018
})
6019
 
6020
(define_peephole2
6021
  [(parallel
6022
    [(set (match_operand:BLK 0 "memory_operand" "")
6023
          (and:BLK (match_dup 0)
6024
                   (match_operand:BLK 1 "memory_operand" "")))
6025
     (use (match_operand 2 "const_int_operand" ""))
6026
     (clobber (reg:CC CC_REGNUM))])
6027
   (parallel
6028
    [(set (match_operand:BLK 3 "memory_operand" "")
6029
          (and:BLK (match_dup 3)
6030
                   (match_operand:BLK 4 "memory_operand" "")))
6031
     (use (match_operand 5 "const_int_operand" ""))
6032
     (clobber (reg:CC CC_REGNUM))])]
6033
  "s390_offset_p (operands[0], operands[3], operands[2])
6034
   && s390_offset_p (operands[1], operands[4], operands[2])
6035
   && !s390_overlap_p (operands[0], operands[1],
6036
                       INTVAL (operands[2]) + INTVAL (operands[5]))
6037
   && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6038
  [(parallel
6039
    [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
6040
     (use (match_dup 8))
6041
     (clobber (reg:CC CC_REGNUM))])]
6042
  "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6043
   operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6044
   operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6045
 
6046
 
6047
;;
6048
;;- Bit set (inclusive or) instructions.
6049
;;
6050
 
6051
(define_expand "ior3"
6052
  [(set (match_operand:INT 0 "nonimmediate_operand" "")
6053
        (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
6054
                 (match_operand:INT 2 "general_operand" "")))
6055
   (clobber (reg:CC CC_REGNUM))]
6056
  ""
6057
  "s390_expand_logical_operator (IOR, mode, operands); DONE;")
6058
 
6059
;
6060
; iordi3 instruction pattern(s).
6061
;
6062
 
6063
(define_insn "*iordi3_cc"
6064
  [(set (reg CC_REGNUM)
6065
        (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6066
                         (match_operand:DI 2 "general_operand" "d,RT"))
6067
                 (const_int 0)))
6068
   (set (match_operand:DI 0 "register_operand" "=d,d")
6069
        (ior:DI (match_dup 1) (match_dup 2)))]
6070
  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6071
  "@
6072
   ogr\t%0,%2
6073
   og\t%0,%2"
6074
  [(set_attr "op_type"  "RRE,RXY")
6075
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6076
 
6077
(define_insn "*iordi3_cconly"
6078
  [(set (reg CC_REGNUM)
6079
        (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6080
                         (match_operand:DI 2 "general_operand" "d,RT"))
6081
                 (const_int 0)))
6082
   (clobber (match_scratch:DI 0 "=d,d"))]
6083
  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6084
  "@
6085
   ogr\t%0,%2
6086
   og\t%0,%2"
6087
  [(set_attr "op_type"  "RRE,RXY")
6088
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6089
 
6090
(define_insn "*iordi3"
6091
  [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
6092
        (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0,0,0")
6093
                (match_operand:DI 2 "general_operand"
6094
                                    "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,RT,NxQD0,Q")))
6095
   (clobber (reg:CC CC_REGNUM))]
6096
  "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
6097
  "@
6098
   oihh\t%0,%i2
6099
   oihl\t%0,%i2
6100
   oilh\t%0,%i2
6101
   oill\t%0,%i2
6102
   oihf\t%0,%k2
6103
   oilf\t%0,%k2
6104
   ogr\t%0,%2
6105
   og\t%0,%2
6106
   #
6107
   #"
6108
  [(set_attr "op_type"  "RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")
6109
   (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,*,*,*")
6110
   (set_attr "z10prop" "z10_super_E1,
6111
                        z10_super_E1,
6112
                        z10_super_E1,
6113
                        z10_super_E1,
6114
                        z10_super_E1,
6115
                        z10_super_E1,
6116
                        z10_super_E1,
6117
                        z10_super_E1,
6118
                        *,
6119
                        *")])
6120
 
6121
(define_split
6122
  [(set (match_operand:DI 0 "s_operand" "")
6123
        (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6124
   (clobber (reg:CC CC_REGNUM))]
6125
  "reload_completed"
6126
  [(parallel
6127
    [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6128
     (clobber (reg:CC CC_REGNUM))])]
6129
  "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6130
 
6131
;
6132
; iorsi3 instruction pattern(s).
6133
;
6134
 
6135
(define_insn "*iorsi3_cc"
6136
  [(set (reg CC_REGNUM)
6137
        (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6138
                         (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6139
                 (const_int 0)))
6140
   (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
6141
        (ior:SI (match_dup 1) (match_dup 2)))]
6142
  "s390_match_ccmode(insn, CCTmode)"
6143
  "@
6144
   oilf\t%0,%o2
6145
   or\t%0,%2
6146
   o\t%0,%2
6147
   oy\t%0,%2"
6148
  [(set_attr "op_type"  "RIL,RR,RX,RXY")
6149
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6150
 
6151
(define_insn "*iorsi3_cconly"
6152
  [(set (reg CC_REGNUM)
6153
        (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6154
                         (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6155
                 (const_int 0)))
6156
   (clobber (match_scratch:SI 0 "=d,d,d,d"))]
6157
  "s390_match_ccmode(insn, CCTmode)"
6158
  "@
6159
   oilf\t%0,%o2
6160
   or\t%0,%2
6161
   o\t%0,%2
6162
   oy\t%0,%2"
6163
  [(set_attr "op_type"  "RIL,RR,RX,RXY")
6164
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6165
 
6166
(define_insn "*iorsi3_zarch"
6167
  [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,AQ,Q")
6168
        (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0")
6169
                (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,R,T,NxQS0,Q")))
6170
   (clobber (reg:CC CC_REGNUM))]
6171
  "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6172
  "@
6173
   oilh\t%0,%i2
6174
   oill\t%0,%i2
6175
   oilf\t%0,%o2
6176
   or\t%0,%2
6177
   o\t%0,%2
6178
   oy\t%0,%2
6179
   #
6180
   #"
6181
  [(set_attr "op_type"  "RI,RI,RIL,RR,RX,RXY,SI,SS")
6182
   (set_attr "z10prop" "z10_super_E1,
6183
                        z10_super_E1,
6184
                        z10_super_E1,
6185
                        z10_super_E1,
6186
                        z10_super_E1,
6187
                        z10_super_E1,
6188
                        *,
6189
                        *")])
6190
 
6191
(define_insn "*iorsi3_esa"
6192
  [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6193
        (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6194
                (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
6195
   (clobber (reg:CC CC_REGNUM))]
6196
  "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6197
  "@
6198
   or\t%0,%2
6199
   o\t%0,%2
6200
   #
6201
   #"
6202
  [(set_attr "op_type"  "RR,RX,SI,SS")
6203
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6204
 
6205
(define_split
6206
  [(set (match_operand:SI 0 "s_operand" "")
6207
        (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6208
   (clobber (reg:CC CC_REGNUM))]
6209
  "reload_completed"
6210
  [(parallel
6211
    [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6212
     (clobber (reg:CC CC_REGNUM))])]
6213
  "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6214
 
6215
;
6216
; iorhi3 instruction pattern(s).
6217
;
6218
 
6219
(define_insn "*iorhi3_zarch"
6220
  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6221
        (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
6222
                (match_operand:HI 2 "general_operand" "d,n,NxQH0,Q")))
6223
   (clobber (reg:CC CC_REGNUM))]
6224
  "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6225
  "@
6226
   or\t%0,%2
6227
   oill\t%0,%x2
6228
   #
6229
   #"
6230
  [(set_attr "op_type"  "RR,RI,SI,SS")
6231
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6232
 
6233
(define_insn "*iorhi3_esa"
6234
  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
6235
        (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
6236
                (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
6237
   (clobber (reg:CC CC_REGNUM))]
6238
  "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6239
  "@
6240
   or\t%0,%2
6241
   #
6242
   #"
6243
  [(set_attr "op_type"  "RR,SI,SS")
6244
   (set_attr "z10prop" "z10_super_E1,*,*")])
6245
 
6246
(define_split
6247
  [(set (match_operand:HI 0 "s_operand" "")
6248
        (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6249
   (clobber (reg:CC CC_REGNUM))]
6250
  "reload_completed"
6251
  [(parallel
6252
    [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6253
     (clobber (reg:CC CC_REGNUM))])]
6254
  "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6255
 
6256
;
6257
; iorqi3 instruction pattern(s).
6258
;
6259
 
6260
(define_insn "*iorqi3_zarch"
6261
  [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
6262
        (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
6263
                (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
6264
   (clobber (reg:CC CC_REGNUM))]
6265
  "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6266
  "@
6267
   or\t%0,%2
6268
   oill\t%0,%b2
6269
   oi\t%S0,%b2
6270
   oiy\t%S0,%b2
6271
   #"
6272
  [(set_attr "op_type"  "RR,RI,SI,SIY,SS")
6273
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
6274
 
6275
(define_insn "*iorqi3_esa"
6276
  [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
6277
        (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6278
                (match_operand:QI 2 "general_operand" "d,n,Q")))
6279
   (clobber (reg:CC CC_REGNUM))]
6280
  "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6281
  "@
6282
   or\t%0,%2
6283
   oi\t%S0,%b2
6284
   #"
6285
  [(set_attr "op_type"  "RR,SI,SS")
6286
   (set_attr "z10prop" "z10_super_E1,z10_super,*")])
6287
 
6288
;
6289
; Block inclusive or (OC) patterns.
6290
;
6291
 
6292
(define_insn "*oc"
6293
  [(set (match_operand:BLK 0 "memory_operand" "=Q")
6294
        (ior:BLK (match_dup 0)
6295
                 (match_operand:BLK 1 "memory_operand" "Q")))
6296
   (use (match_operand 2 "const_int_operand" "n"))
6297
   (clobber (reg:CC CC_REGNUM))]
6298
  "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6299
  "oc\t%O0(%2,%R0),%S1"
6300
  [(set_attr "op_type" "SS")])
6301
 
6302
(define_split
6303
  [(set (match_operand 0 "memory_operand" "")
6304
        (ior (match_dup 0)
6305
             (match_operand 1 "memory_operand" "")))
6306
   (clobber (reg:CC CC_REGNUM))]
6307
  "reload_completed
6308
   && GET_MODE (operands[0]) == GET_MODE (operands[1])
6309
   && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6310
  [(parallel
6311
    [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
6312
     (use (match_dup 2))
6313
     (clobber (reg:CC CC_REGNUM))])]
6314
{
6315
  operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6316
  operands[0] = adjust_address (operands[0], BLKmode, 0);
6317
  operands[1] = adjust_address (operands[1], BLKmode, 0);
6318
})
6319
 
6320
(define_peephole2
6321
  [(parallel
6322
    [(set (match_operand:BLK 0 "memory_operand" "")
6323
          (ior:BLK (match_dup 0)
6324
                   (match_operand:BLK 1 "memory_operand" "")))
6325
     (use (match_operand 2 "const_int_operand" ""))
6326
     (clobber (reg:CC CC_REGNUM))])
6327
   (parallel
6328
    [(set (match_operand:BLK 3 "memory_operand" "")
6329
          (ior:BLK (match_dup 3)
6330
                   (match_operand:BLK 4 "memory_operand" "")))
6331
     (use (match_operand 5 "const_int_operand" ""))
6332
     (clobber (reg:CC CC_REGNUM))])]
6333
  "s390_offset_p (operands[0], operands[3], operands[2])
6334
   && s390_offset_p (operands[1], operands[4], operands[2])
6335
   && !s390_overlap_p (operands[0], operands[1],
6336
                       INTVAL (operands[2]) + INTVAL (operands[5]))
6337
   && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6338
  [(parallel
6339
    [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
6340
     (use (match_dup 8))
6341
     (clobber (reg:CC CC_REGNUM))])]
6342
  "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6343
   operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6344
   operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6345
 
6346
 
6347
;;
6348
;;- Xor instructions.
6349
;;
6350
 
6351
(define_expand "xor3"
6352
  [(set (match_operand:INT 0 "nonimmediate_operand" "")
6353
        (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
6354
                 (match_operand:INT 2 "general_operand" "")))
6355
   (clobber (reg:CC CC_REGNUM))]
6356
  ""
6357
  "s390_expand_logical_operator (XOR, mode, operands); DONE;")
6358
 
6359
;
6360
; xordi3 instruction pattern(s).
6361
;
6362
 
6363
(define_insn "*xordi3_cc"
6364
  [(set (reg CC_REGNUM)
6365
        (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6366
                         (match_operand:DI 2 "general_operand" "d,RT"))
6367
                 (const_int 0)))
6368
   (set (match_operand:DI 0 "register_operand" "=d,d")
6369
        (xor:DI (match_dup 1) (match_dup 2)))]
6370
  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6371
  "@
6372
   xgr\t%0,%2
6373
   xg\t%0,%2"
6374
  [(set_attr "op_type"  "RRE,RXY")
6375
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6376
 
6377
(define_insn "*xordi3_cconly"
6378
  [(set (reg CC_REGNUM)
6379
        (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6380
                         (match_operand:DI 2 "general_operand" "d,RT"))
6381
                 (const_int 0)))
6382
   (clobber (match_scratch:DI 0 "=d,d"))]
6383
  "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6384
  "@
6385
   xgr\t%0,%2
6386
   xg\t%0,%2"
6387
  [(set_attr "op_type"  "RRE,RXY")
6388
   (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6389
 
6390
(define_insn "*xordi3"
6391
  [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
6392
        (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
6393
                (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,RT,NxQD0,Q")))
6394
   (clobber (reg:CC CC_REGNUM))]
6395
  "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
6396
  "@
6397
   xihf\t%0,%k2
6398
   xilf\t%0,%k2
6399
   xgr\t%0,%2
6400
   xg\t%0,%2
6401
   #
6402
   #"
6403
  [(set_attr "op_type"  "RIL,RIL,RRE,RXY,SI,SS")
6404
   (set_attr "cpu_facility" "extimm,extimm,*,*,*,*")
6405
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1,*,*")])
6406
 
6407
(define_split
6408
  [(set (match_operand:DI 0 "s_operand" "")
6409
        (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6410
   (clobber (reg:CC CC_REGNUM))]
6411
  "reload_completed"
6412
  [(parallel
6413
    [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6414
     (clobber (reg:CC CC_REGNUM))])]
6415
  "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6416
 
6417
;
6418
; xorsi3 instruction pattern(s).
6419
;
6420
 
6421
(define_insn "*xorsi3_cc"
6422
  [(set (reg CC_REGNUM)
6423
        (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6424
                         (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6425
                 (const_int 0)))
6426
   (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
6427
        (xor:SI (match_dup 1) (match_dup 2)))]
6428
  "s390_match_ccmode(insn, CCTmode)"
6429
  "@
6430
   xilf\t%0,%o2
6431
   xr\t%0,%2
6432
   x\t%0,%2
6433
   xy\t%0,%2"
6434
  [(set_attr "op_type"  "RIL,RR,RX,RXY")
6435
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6436
 
6437
(define_insn "*xorsi3_cconly"
6438
  [(set (reg CC_REGNUM)
6439
        (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6440
                         (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6441
                 (const_int 0)))
6442
   (clobber (match_scratch:SI 0 "=d,d,d,d"))]
6443
  "s390_match_ccmode(insn, CCTmode)"
6444
  "@
6445
   xilf\t%0,%o2
6446
   xr\t%0,%2
6447
   x\t%0,%2
6448
   xy\t%0,%2"
6449
  [(set_attr "op_type"  "RIL,RR,RX,RXY")
6450
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6451
 
6452
(define_insn "*xorsi3"
6453
  [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
6454
        (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
6455
                (match_operand:SI 2 "general_operand" "Os,d,R,T,NxQS0,Q")))
6456
   (clobber (reg:CC CC_REGNUM))]
6457
  "s390_logical_operator_ok_p (operands)"
6458
  "@
6459
   xilf\t%0,%o2
6460
   xr\t%0,%2
6461
   x\t%0,%2
6462
   xy\t%0,%2
6463
   #
6464
   #"
6465
  [(set_attr "op_type"  "RIL,RR,RX,RXY,SI,SS")
6466
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1,*,*")])
6467
 
6468
(define_split
6469
  [(set (match_operand:SI 0 "s_operand" "")
6470
        (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6471
   (clobber (reg:CC CC_REGNUM))]
6472
  "reload_completed"
6473
  [(parallel
6474
    [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6475
     (clobber (reg:CC CC_REGNUM))])]
6476
  "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6477
 
6478
;
6479
; xorhi3 instruction pattern(s).
6480
;
6481
 
6482
(define_insn "*xorhi3"
6483
  [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6484
        (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
6485
                (match_operand:HI 2 "general_operand" "Os,d,NxQH0,Q")))
6486
   (clobber (reg:CC CC_REGNUM))]
6487
  "s390_logical_operator_ok_p (operands)"
6488
  "@
6489
   xilf\t%0,%x2
6490
   xr\t%0,%2
6491
   #
6492
   #"
6493
  [(set_attr "op_type"  "RIL,RR,SI,SS")
6494
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6495
 
6496
(define_split
6497
  [(set (match_operand:HI 0 "s_operand" "")
6498
        (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6499
   (clobber (reg:CC CC_REGNUM))]
6500
  "reload_completed"
6501
  [(parallel
6502
    [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6503
     (clobber (reg:CC CC_REGNUM))])]
6504
  "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6505
 
6506
;
6507
; xorqi3 instruction pattern(s).
6508
;
6509
 
6510
(define_insn "*xorqi3"
6511
  [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
6512
        (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
6513
                (match_operand:QI 2 "general_operand" "Os,d,n,n,Q")))
6514
   (clobber (reg:CC CC_REGNUM))]
6515
  "s390_logical_operator_ok_p (operands)"
6516
  "@
6517
   xilf\t%0,%b2
6518
   xr\t%0,%2
6519
   xi\t%S0,%b2
6520
   xiy\t%S0,%b2
6521
   #"
6522
  [(set_attr "op_type"  "RIL,RR,SI,SIY,SS")
6523
   (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
6524
 
6525
 
6526
;
6527
; Block exclusive or (XC) patterns.
6528
;
6529
 
6530
(define_insn "*xc"
6531
  [(set (match_operand:BLK 0 "memory_operand" "=Q")
6532
        (xor:BLK (match_dup 0)
6533
                 (match_operand:BLK 1 "memory_operand" "Q")))
6534
   (use (match_operand 2 "const_int_operand" "n"))
6535
   (clobber (reg:CC CC_REGNUM))]
6536
  "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6537
  "xc\t%O0(%2,%R0),%S1"
6538
  [(set_attr "op_type" "SS")])
6539
 
6540
(define_split
6541
  [(set (match_operand 0 "memory_operand" "")
6542
        (xor (match_dup 0)
6543
             (match_operand 1 "memory_operand" "")))
6544
   (clobber (reg:CC CC_REGNUM))]
6545
  "reload_completed
6546
   && GET_MODE (operands[0]) == GET_MODE (operands[1])
6547
   && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6548
  [(parallel
6549
    [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
6550
     (use (match_dup 2))
6551
     (clobber (reg:CC CC_REGNUM))])]
6552
{
6553
  operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6554
  operands[0] = adjust_address (operands[0], BLKmode, 0);
6555
  operands[1] = adjust_address (operands[1], BLKmode, 0);
6556
})
6557
 
6558
(define_peephole2
6559
  [(parallel
6560
    [(set (match_operand:BLK 0 "memory_operand" "")
6561
          (xor:BLK (match_dup 0)
6562
                   (match_operand:BLK 1 "memory_operand" "")))
6563
     (use (match_operand 2 "const_int_operand" ""))
6564
     (clobber (reg:CC CC_REGNUM))])
6565
   (parallel
6566
    [(set (match_operand:BLK 3 "memory_operand" "")
6567
          (xor:BLK (match_dup 3)
6568
                   (match_operand:BLK 4 "memory_operand" "")))
6569
     (use (match_operand 5 "const_int_operand" ""))
6570
     (clobber (reg:CC CC_REGNUM))])]
6571
  "s390_offset_p (operands[0], operands[3], operands[2])
6572
   && s390_offset_p (operands[1], operands[4], operands[2])
6573
   && !s390_overlap_p (operands[0], operands[1],
6574
                       INTVAL (operands[2]) + INTVAL (operands[5]))
6575
   && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6576
  [(parallel
6577
    [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
6578
     (use (match_dup 8))
6579
     (clobber (reg:CC CC_REGNUM))])]
6580
  "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6581
   operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6582
   operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6583
 
6584
;
6585
; Block xor (XC) patterns with src == dest.
6586
;
6587
 
6588
(define_insn "*xc_zero"
6589
  [(set (match_operand:BLK 0 "memory_operand" "=Q")
6590
        (const_int 0))
6591
   (use (match_operand 1 "const_int_operand" "n"))
6592
   (clobber (reg:CC CC_REGNUM))]
6593
  "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
6594
  "xc\t%O0(%1,%R0),%S0"
6595
  [(set_attr "op_type" "SS")])
6596
 
6597
(define_peephole2
6598
  [(parallel
6599
    [(set (match_operand:BLK 0 "memory_operand" "")
6600
          (const_int 0))
6601
     (use (match_operand 1 "const_int_operand" ""))
6602
     (clobber (reg:CC CC_REGNUM))])
6603
   (parallel
6604
    [(set (match_operand:BLK 2 "memory_operand" "")
6605
          (const_int 0))
6606
     (use (match_operand 3 "const_int_operand" ""))
6607
     (clobber (reg:CC CC_REGNUM))])]
6608
  "s390_offset_p (operands[0], operands[2], operands[1])
6609
   && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
6610
  [(parallel
6611
    [(set (match_dup 4) (const_int 0))
6612
     (use (match_dup 5))
6613
     (clobber (reg:CC CC_REGNUM))])]
6614
  "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6615
   operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
6616
 
6617
 
6618
;;
6619
;;- Negate instructions.
6620
;;
6621
 
6622
;
6623
; neg(di|si)2 instruction pattern(s).
6624
;
6625
 
6626
(define_expand "neg2"
6627
  [(parallel
6628
    [(set (match_operand:DSI 0 "register_operand" "=d")
6629
          (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
6630
     (clobber (reg:CC CC_REGNUM))])]
6631
  ""
6632
  "")
6633
 
6634
(define_insn "*negdi2_sign_cc"
6635
  [(set (reg CC_REGNUM)
6636
        (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
6637
                           (match_operand:SI 1 "register_operand" "d") 0)
6638
                           (const_int 32)) (const_int 32)))
6639
                 (const_int 0)))
6640
   (set (match_operand:DI 0 "register_operand" "=d")
6641
        (neg:DI (sign_extend:DI (match_dup 1))))]
6642
  "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6643
  "lcgfr\t%0,%1"
6644
  [(set_attr "op_type"  "RRE")
6645
   (set_attr "z10prop" "z10_c")])
6646
 
6647
(define_insn "*negdi2_sign"
6648
  [(set (match_operand:DI 0 "register_operand" "=d")
6649
        (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6650
   (clobber (reg:CC CC_REGNUM))]
6651
  "TARGET_64BIT"
6652
  "lcgfr\t%0,%1"
6653
  [(set_attr "op_type"  "RRE")
6654
   (set_attr "z10prop" "z10_c")])
6655
 
6656
; lcr, lcgr
6657
(define_insn "*neg2_cc"
6658
  [(set (reg CC_REGNUM)
6659
        (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
6660
                 (const_int 0)))
6661
   (set (match_operand:GPR 0 "register_operand" "=d")
6662
        (neg:GPR (match_dup 1)))]
6663
  "s390_match_ccmode (insn, CCAmode)"
6664
  "lcr\t%0,%1"
6665
  [(set_attr "op_type"  "RR")
6666
   (set_attr "z10prop" "z10_super_c_E1")])
6667
 
6668
; lcr, lcgr
6669
(define_insn "*neg2_cconly"
6670
  [(set (reg CC_REGNUM)
6671
        (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
6672
                 (const_int 0)))
6673
   (clobber (match_scratch:GPR 0 "=d"))]
6674
  "s390_match_ccmode (insn, CCAmode)"
6675
  "lcr\t%0,%1"
6676
  [(set_attr "op_type"  "RR")
6677
   (set_attr "z10prop" "z10_super_c_E1")])
6678
 
6679
; lcr, lcgr
6680
(define_insn "*neg2"
6681
  [(set (match_operand:GPR 0 "register_operand" "=d")
6682
        (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
6683
   (clobber (reg:CC CC_REGNUM))]
6684
  ""
6685
  "lcr\t%0,%1"
6686
  [(set_attr "op_type"  "RR")
6687
   (set_attr "z10prop" "z10_super_c_E1")])
6688
 
6689
(define_insn_and_split "*negdi2_31"
6690
  [(set (match_operand:DI 0 "register_operand" "=d")
6691
        (neg:DI (match_operand:DI 1 "register_operand" "d")))
6692
   (clobber (reg:CC CC_REGNUM))]
6693
  "!TARGET_64BIT"
6694
  "#"
6695
  "&& reload_completed"
6696
  [(parallel
6697
    [(set (match_dup 2) (neg:SI (match_dup 3)))
6698
     (clobber (reg:CC CC_REGNUM))])
6699
   (parallel
6700
    [(set (reg:CCAP CC_REGNUM)
6701
          (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
6702
     (set (match_dup 4) (neg:SI (match_dup 5)))])
6703
   (set (pc)
6704
        (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
6705
                      (pc)
6706
                      (label_ref (match_dup 6))))
6707
   (parallel
6708
    [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
6709
     (clobber (reg:CC CC_REGNUM))])
6710
   (match_dup 6)]
6711
  "operands[2] = operand_subword (operands[0], 0, 0, DImode);
6712
   operands[3] = operand_subword (operands[1], 0, 0, DImode);
6713
   operands[4] = operand_subword (operands[0], 1, 0, DImode);
6714
   operands[5] = operand_subword (operands[1], 1, 0, DImode);
6715
   operands[6] = gen_label_rtx ();")
6716
 
6717
;
6718
; neg(df|sf)2 instruction pattern(s).
6719
;
6720
 
6721
(define_expand "neg2"
6722
  [(parallel
6723
    [(set (match_operand:BFP 0 "register_operand" "=f")
6724
          (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6725
     (clobber (reg:CC CC_REGNUM))])]
6726
  "TARGET_HARD_FLOAT"
6727
  "")
6728
 
6729
; lcxbr, lcdbr, lcebr
6730
(define_insn "*neg2_cc"
6731
  [(set (reg CC_REGNUM)
6732
        (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
6733
                 (match_operand:BFP 2 "const0_operand" "")))
6734
   (set (match_operand:BFP 0 "register_operand" "=f")
6735
        (neg:BFP (match_dup 1)))]
6736
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6737
  "lcbr\t%0,%1"
6738
  [(set_attr "op_type"  "RRE")
6739
   (set_attr "type"     "fsimp")])
6740
 
6741
; lcxbr, lcdbr, lcebr
6742
(define_insn "*neg2_cconly"
6743
  [(set (reg CC_REGNUM)
6744
        (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
6745
                 (match_operand:BFP 2 "const0_operand" "")))
6746
   (clobber (match_scratch:BFP 0 "=f"))]
6747
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6748
  "lcbr\t%0,%1"
6749
  [(set_attr "op_type"  "RRE")
6750
   (set_attr "type"     "fsimp")])
6751
 
6752
; lcdfr
6753
(define_insn "*neg2_nocc"
6754
  [(set (match_operand:FP 0 "register_operand"         "=f")
6755
        (neg:FP (match_operand:FP 1 "register_operand" "")))]
6756
  "TARGET_DFP"
6757
  "lcdfr\t%0,%1"
6758
  [(set_attr "op_type"  "RRE")
6759
   (set_attr "type"     "fsimp")])
6760
 
6761
; lcxbr, lcdbr, lcebr
6762
(define_insn "*neg2"
6763
  [(set (match_operand:BFP 0 "register_operand" "=f")
6764
        (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6765
   (clobber (reg:CC CC_REGNUM))]
6766
  "TARGET_HARD_FLOAT"
6767
  "lcbr\t%0,%1"
6768
  [(set_attr "op_type"  "RRE")
6769
   (set_attr "type"     "fsimp")])
6770
 
6771
 
6772
;;
6773
;;- Absolute value instructions.
6774
;;
6775
 
6776
;
6777
; abs(di|si)2 instruction pattern(s).
6778
;
6779
 
6780
(define_insn "*absdi2_sign_cc"
6781
  [(set (reg CC_REGNUM)
6782
        (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6783
                           (match_operand:SI 1 "register_operand" "d") 0)
6784
                           (const_int 32)) (const_int 32)))
6785
                 (const_int 0)))
6786
   (set (match_operand:DI 0 "register_operand" "=d")
6787
        (abs:DI (sign_extend:DI (match_dup 1))))]
6788
  "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6789
  "lpgfr\t%0,%1"
6790
  [(set_attr "op_type"  "RRE")
6791
   (set_attr "z10prop" "z10_c")])
6792
 
6793
(define_insn "*absdi2_sign"
6794
  [(set (match_operand:DI 0 "register_operand" "=d")
6795
        (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6796
   (clobber (reg:CC CC_REGNUM))]
6797
  "TARGET_64BIT"
6798
  "lpgfr\t%0,%1"
6799
  [(set_attr "op_type"  "RRE")
6800
   (set_attr "z10prop" "z10_c")])
6801
 
6802
; lpr, lpgr
6803
(define_insn "*abs2_cc"
6804
  [(set (reg CC_REGNUM)
6805
        (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
6806
                 (const_int 0)))
6807
   (set (match_operand:GPR 0 "register_operand" "=d")
6808
        (abs:GPR (match_dup 1)))]
6809
  "s390_match_ccmode (insn, CCAmode)"
6810
  "lpr\t%0,%1"
6811
  [(set_attr "op_type"  "RR")
6812
   (set_attr "z10prop" "z10_c")])
6813
 
6814
; lpr, lpgr
6815
(define_insn "*abs2_cconly"
6816
  [(set (reg CC_REGNUM)
6817
        (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
6818
                 (const_int 0)))
6819
   (clobber (match_scratch:GPR 0 "=d"))]
6820
  "s390_match_ccmode (insn, CCAmode)"
6821
  "lpr\t%0,%1"
6822
  [(set_attr "op_type"  "RR")
6823
   (set_attr "z10prop" "z10_c")])
6824
 
6825
; lpr, lpgr
6826
(define_insn "abs2"
6827
  [(set (match_operand:GPR 0 "register_operand" "=d")
6828
        (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6829
   (clobber (reg:CC CC_REGNUM))]
6830
  ""
6831
  "lpr\t%0,%1"
6832
  [(set_attr "op_type"  "RR")
6833
   (set_attr "z10prop" "z10_c")])
6834
 
6835
;
6836
; abs(df|sf)2 instruction pattern(s).
6837
;
6838
 
6839
(define_expand "abs2"
6840
  [(parallel
6841
    [(set (match_operand:BFP 0 "register_operand" "=f")
6842
          (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6843
     (clobber (reg:CC CC_REGNUM))])]
6844
  "TARGET_HARD_FLOAT"
6845
  "")
6846
 
6847
; lpxbr, lpdbr, lpebr
6848
(define_insn "*abs2_cc"
6849
  [(set (reg CC_REGNUM)
6850
        (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
6851
                 (match_operand:BFP 2 "const0_operand" "")))
6852
   (set (match_operand:BFP 0 "register_operand" "=f")
6853
        (abs:BFP (match_dup 1)))]
6854
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6855
  "lpbr\t%0,%1"
6856
  [(set_attr "op_type"  "RRE")
6857
   (set_attr "type"     "fsimp")])
6858
 
6859
; lpxbr, lpdbr, lpebr
6860
(define_insn "*abs2_cconly"
6861
  [(set (reg CC_REGNUM)
6862
        (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
6863
                 (match_operand:BFP 2 "const0_operand" "")))
6864
   (clobber (match_scratch:BFP 0 "=f"))]
6865
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6866
  "lpbr\t%0,%1"
6867
  [(set_attr "op_type"  "RRE")
6868
   (set_attr "type"     "fsimp")])
6869
 
6870
; lpdfr
6871
(define_insn "*abs2_nocc"
6872
  [(set (match_operand:FP 0 "register_operand"         "=f")
6873
        (abs:FP (match_operand:FP 1 "register_operand" "")))]
6874
  "TARGET_DFP"
6875
  "lpdfr\t%0,%1"
6876
  [(set_attr "op_type"  "RRE")
6877
   (set_attr "type"     "fsimp")])
6878
 
6879
; lpxbr, lpdbr, lpebr
6880
(define_insn "*abs2"
6881
  [(set (match_operand:BFP 0 "register_operand" "=f")
6882
        (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6883
   (clobber (reg:CC CC_REGNUM))]
6884
  "TARGET_HARD_FLOAT"
6885
  "lpbr\t%0,%1"
6886
  [(set_attr "op_type"  "RRE")
6887
   (set_attr "type"     "fsimp")])
6888
 
6889
 
6890
;;
6891
;;- Negated absolute value instructions
6892
;;
6893
 
6894
;
6895
; Integer
6896
;
6897
 
6898
(define_insn "*negabsdi2_sign_cc"
6899
  [(set (reg CC_REGNUM)
6900
        (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6901
                           (match_operand:SI 1 "register_operand" "d") 0)
6902
                           (const_int 32)) (const_int 32))))
6903
                 (const_int 0)))
6904
   (set (match_operand:DI 0 "register_operand" "=d")
6905
        (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
6906
  "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6907
  "lngfr\t%0,%1"
6908
  [(set_attr "op_type"  "RRE")
6909
   (set_attr "z10prop" "z10_c")])
6910
 
6911
(define_insn "*negabsdi2_sign"
6912
  [(set (match_operand:DI 0 "register_operand" "=d")
6913
        (neg:DI (abs:DI (sign_extend:DI
6914
                          (match_operand:SI 1 "register_operand" "d")))))
6915
   (clobber (reg:CC CC_REGNUM))]
6916
  "TARGET_64BIT"
6917
  "lngfr\t%0,%1"
6918
  [(set_attr "op_type" "RRE")
6919
   (set_attr "z10prop" "z10_c")])
6920
 
6921
; lnr, lngr
6922
(define_insn "*negabs2_cc"
6923
  [(set (reg CC_REGNUM)
6924
        (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6925
                 (const_int 0)))
6926
   (set (match_operand:GPR 0 "register_operand" "=d")
6927
        (neg:GPR (abs:GPR (match_dup 1))))]
6928
  "s390_match_ccmode (insn, CCAmode)"
6929
  "lnr\t%0,%1"
6930
  [(set_attr "op_type"  "RR")
6931
   (set_attr "z10prop" "z10_c")])
6932
 
6933
; lnr, lngr
6934
(define_insn "*negabs2_cconly"
6935
  [(set (reg CC_REGNUM)
6936
        (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6937
                 (const_int 0)))
6938
   (clobber (match_scratch:GPR 0 "=d"))]
6939
  "s390_match_ccmode (insn, CCAmode)"
6940
  "lnr\t%0,%1"
6941
  [(set_attr "op_type"  "RR")
6942
   (set_attr "z10prop" "z10_c")])
6943
 
6944
; lnr, lngr
6945
(define_insn "*negabs2"
6946
  [(set (match_operand:GPR 0 "register_operand" "=d")
6947
        (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
6948
   (clobber (reg:CC CC_REGNUM))]
6949
  ""
6950
  "lnr\t%0,%1"
6951
  [(set_attr "op_type" "RR")
6952
   (set_attr "z10prop" "z10_c")])
6953
 
6954
;
6955
; Floating point
6956
;
6957
 
6958
; lnxbr, lndbr, lnebr
6959
(define_insn "*negabs2_cc"
6960
  [(set (reg CC_REGNUM)
6961
        (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6962
                 (match_operand:BFP 2 "const0_operand" "")))
6963
   (set (match_operand:BFP 0 "register_operand" "=f")
6964
        (neg:BFP (abs:BFP (match_dup 1))))]
6965
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6966
  "lnbr\t%0,%1"
6967
  [(set_attr "op_type"  "RRE")
6968
   (set_attr "type"     "fsimp")])
6969
 
6970
; lnxbr, lndbr, lnebr
6971
(define_insn "*negabs2_cconly"
6972
  [(set (reg CC_REGNUM)
6973
        (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6974
                 (match_operand:BFP 2 "const0_operand" "")))
6975
   (clobber (match_scratch:BFP 0 "=f"))]
6976
  "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6977
  "lnbr\t%0,%1"
6978
  [(set_attr "op_type"  "RRE")
6979
   (set_attr "type"     "fsimp")])
6980
 
6981
; lndfr
6982
(define_insn "*negabs2_nocc"
6983
  [(set (match_operand:FP 0 "register_operand"                  "=f")
6984
        (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" ""))))]
6985
  "TARGET_DFP"
6986
  "lndfr\t%0,%1"
6987
  [(set_attr "op_type"  "RRE")
6988
   (set_attr "type"     "fsimp")])
6989
 
6990
; lnxbr, lndbr, lnebr
6991
(define_insn "*negabs2"
6992
  [(set (match_operand:BFP 0 "register_operand" "=f")
6993
        (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f"))))
6994
   (clobber (reg:CC CC_REGNUM))]
6995
  "TARGET_HARD_FLOAT"
6996
  "lnbr\t%0,%1"
6997
  [(set_attr "op_type"  "RRE")
6998
   (set_attr "type"     "fsimp")])
6999
 
7000
;;
7001
;;- Square root instructions.
7002
;;
7003
 
7004
;
7005
; sqrt(df|sf)2 instruction pattern(s).
7006
;
7007
 
7008
; sqxbr, sqdbr, sqebr, sqdb, sqeb
7009
(define_insn "sqrt2"
7010
  [(set (match_operand:BFP 0 "register_operand" "=f,f")
7011
        (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,")))]
7012
  "TARGET_HARD_FLOAT"
7013
  "@
7014
   sqbr\t%0,%1
7015
   sqb\t%0,%1"
7016
  [(set_attr "op_type" "RRE,RXE")
7017
   (set_attr "type" "fsqrt")])
7018
 
7019
 
7020
;;
7021
;;- One complement instructions.
7022
;;
7023
 
7024
;
7025
; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
7026
;
7027
 
7028
(define_expand "one_cmpl2"
7029
  [(parallel
7030
    [(set (match_operand:INT 0 "register_operand" "")
7031
          (xor:INT (match_operand:INT 1 "register_operand" "")
7032
                   (const_int -1)))
7033
     (clobber (reg:CC CC_REGNUM))])]
7034
  ""
7035
  "")
7036
 
7037
 
7038
;;
7039
;; Find leftmost bit instructions.
7040
;;
7041
 
7042
(define_expand "clzdi2"
7043
  [(set (match_operand:DI 0 "register_operand" "=d")
7044
        (clz:DI (match_operand:DI 1 "register_operand" "d")))]
7045
  "TARGET_EXTIMM && TARGET_64BIT"
7046
{
7047
  rtx insn, clz_equal;
7048
  rtx wide_reg = gen_reg_rtx (TImode);
7049
  rtx msb = gen_rtx_CONST_INT (DImode, (unsigned HOST_WIDE_INT) 1 << 63);
7050
 
7051
  clz_equal = gen_rtx_CLZ (DImode, operands[1]);
7052
 
7053
  emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
7054
 
7055
  insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
7056
  set_unique_reg_note (insn, REG_EQUAL, clz_equal);
7057
 
7058
  DONE;
7059
})
7060
 
7061
(define_insn "clztidi2"
7062
  [(set (match_operand:TI 0 "register_operand" "=d")
7063
        (ior:TI
7064
          (ashift:TI
7065
            (zero_extend:TI
7066
              (xor:DI (match_operand:DI 1 "register_operand" "d")
7067
                      (lshiftrt (match_operand:DI 2 "const_int_operand" "")
7068
                                (subreg:SI (clz:DI (match_dup 1)) 4))))
7069
 
7070
            (const_int 64))
7071
          (zero_extend:TI (clz:DI (match_dup 1)))))
7072
   (clobber (reg:CC CC_REGNUM))]
7073
  "(unsigned HOST_WIDE_INT) INTVAL (operands[2])
7074
   == (unsigned HOST_WIDE_INT) 1 << 63
7075
   && TARGET_EXTIMM && TARGET_64BIT"
7076
  "flogr\t%0,%1"
7077
  [(set_attr "op_type"  "RRE")])
7078
 
7079
 
7080
;;
7081
;;- Rotate instructions.
7082
;;
7083
 
7084
;
7085
; rotl(di|si)3 instruction pattern(s).
7086
;
7087
 
7088
; rll, rllg
7089
(define_insn "rotl3"
7090
  [(set (match_operand:GPR 0 "register_operand" "=d")
7091
        (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7092
                    (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7093
  "TARGET_CPU_ZARCH"
7094
  "rll\t%0,%1,%Y2"
7095
  [(set_attr "op_type"  "RSE")
7096
   (set_attr "atype"    "reg")
7097
   (set_attr "z10prop" "z10_super_E1")])
7098
 
7099
; rll, rllg
7100
(define_insn "*rotl3_and"
7101
  [(set (match_operand:GPR 0 "register_operand" "=d")
7102
        (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7103
                    (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7104
                            (match_operand:SI 3 "const_int_operand"   "n"))))]
7105
  "TARGET_CPU_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7106
  "rll\t%0,%1,%Y2"
7107
  [(set_attr "op_type"  "RSE")
7108
   (set_attr "atype"    "reg")
7109
   (set_attr "z10prop" "z10_super_E1")])
7110
 
7111
 
7112
;;
7113
;;- Shift instructions.
7114
;;
7115
 
7116
;
7117
; (ashl|lshr)(di|si)3 instruction pattern(s).
7118
;
7119
 
7120
(define_expand "3"
7121
  [(set (match_operand:DSI 0 "register_operand" "")
7122
        (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
7123
                   (match_operand:SI 2 "shift_count_or_setmem_operand" "")))]
7124
  ""
7125
  "")
7126
 
7127
; sldl, srdl
7128
(define_insn "*di3_31"
7129
  [(set (match_operand:DI 0 "register_operand" "=d")
7130
        (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7131
                  (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7132
  "!TARGET_64BIT"
7133
  "sdl\t%0,%Y2"
7134
  [(set_attr "op_type"  "RS")
7135
   (set_attr "atype"    "reg")])
7136
 
7137
; sll, srl, sllg, srlg
7138
(define_insn "*3"
7139
  [(set (match_operand:GPR 0 "register_operand" "=d")
7140
        (SHIFT:GPR (match_operand:GPR 1 "register_operand" "")
7141
                   (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7142
  ""
7143
  "sl\t%0,<1>%Y2"
7144
  [(set_attr "op_type"  "RS")
7145
   (set_attr "atype"    "reg")
7146
   (set_attr "z10prop" "z10_super_E1")])
7147
 
7148
; sldl, srdl
7149
(define_insn "*di3_31_and"
7150
  [(set (match_operand:DI 0 "register_operand" "=d")
7151
        (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7152
                  (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7153
                          (match_operand:SI 3 "const_int_operand"   "n"))))]
7154
  "!TARGET_64BIT && (INTVAL (operands[3]) & 63) == 63"
7155
  "sdl\t%0,%Y2"
7156
  [(set_attr "op_type"  "RS")
7157
   (set_attr "atype"    "reg")])
7158
 
7159
; sll, srl, sllg, srlg
7160
(define_insn "*3_and"
7161
  [(set (match_operand:GPR 0 "register_operand" "=d")
7162
        (SHIFT:GPR (match_operand:GPR 1 "register_operand" "")
7163
                   (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7164
                           (match_operand:SI 3 "const_int_operand"   "n"))))]
7165
  "(INTVAL (operands[3]) & 63) == 63"
7166
  "sl\t%0,<1>%Y2"
7167
  [(set_attr "op_type"  "RS")
7168
   (set_attr "atype"    "reg")
7169
   (set_attr "z10prop" "z10_super_E1")])
7170
 
7171
;
7172
; ashr(di|si)3 instruction pattern(s).
7173
;
7174
 
7175
(define_expand "ashr3"
7176
  [(parallel
7177
    [(set (match_operand:DSI 0 "register_operand" "")
7178
          (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
7179
                        (match_operand:SI 2 "shift_count_or_setmem_operand" "")))
7180
     (clobber (reg:CC CC_REGNUM))])]
7181
  ""
7182
  "")
7183
 
7184
(define_insn "*ashrdi3_cc_31"
7185
  [(set (reg CC_REGNUM)
7186
        (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7187
                              (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7188
                 (const_int 0)))
7189
   (set (match_operand:DI 0 "register_operand" "=d")
7190
        (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7191
  "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
7192
  "srda\t%0,%Y2"
7193
  [(set_attr "op_type"  "RS")
7194
   (set_attr "atype"    "reg")])
7195
 
7196
(define_insn "*ashrdi3_cconly_31"
7197
  [(set (reg CC_REGNUM)
7198
        (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7199
                              (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7200
                 (const_int 0)))
7201
   (clobber (match_scratch:DI 0 "=d"))]
7202
  "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
7203
  "srda\t%0,%Y2"
7204
  [(set_attr "op_type"  "RS")
7205
   (set_attr "atype"    "reg")])
7206
 
7207
(define_insn "*ashrdi3_31"
7208
  [(set (match_operand:DI 0 "register_operand" "=d")
7209
        (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7210
                     (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
7211
   (clobber (reg:CC CC_REGNUM))]
7212
  "!TARGET_64BIT"
7213
  "srda\t%0,%Y2"
7214
  [(set_attr "op_type"  "RS")
7215
   (set_attr "atype"    "reg")])
7216
 
7217
; sra, srag
7218
(define_insn "*ashr3_cc"
7219
  [(set (reg CC_REGNUM)
7220
        (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "")
7221
                               (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7222
                 (const_int 0)))
7223
   (set (match_operand:GPR 0 "register_operand" "=d")
7224
        (ashiftrt:GPR (match_dup 1) (match_dup 2)))]
7225
  "s390_match_ccmode(insn, CCSmode)"
7226
  "sra\t%0,<1>%Y2"
7227
  [(set_attr "op_type"  "RS")
7228
   (set_attr "atype"    "reg")
7229
   (set_attr "z10prop" "z10_super_E1")])
7230
 
7231
; sra, srag
7232
(define_insn "*ashr3_cconly"
7233
  [(set (reg CC_REGNUM)
7234
        (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "")
7235
                               (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7236
                 (const_int 0)))
7237
   (clobber (match_scratch:GPR 0 "=d"))]
7238
  "s390_match_ccmode(insn, CCSmode)"
7239
  "sra\t%0,<1>%Y2"
7240
  [(set_attr "op_type"  "RS")
7241
   (set_attr "atype"    "reg")
7242
   (set_attr "z10prop" "z10_super_E1")])
7243
 
7244
; sra, srag
7245
(define_insn "*ashr3"
7246
  [(set (match_operand:GPR 0 "register_operand" "=d")
7247
        (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "")
7248
                      (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
7249
   (clobber (reg:CC CC_REGNUM))]
7250
  ""
7251
  "sra\t%0,<1>%Y2"
7252
  [(set_attr "op_type"  "RS")
7253
   (set_attr "atype"    "reg")
7254
   (set_attr "z10prop" "z10_super_E1")])
7255
 
7256
 
7257
; shift pattern with implicit ANDs
7258
 
7259
(define_insn "*ashrdi3_cc_31_and"
7260
  [(set (reg CC_REGNUM)
7261
        (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7262
                              (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7263
                                      (match_operand:SI 3 "const_int_operand"   "n")))
7264
                 (const_int 0)))
7265
   (set (match_operand:DI 0 "register_operand" "=d")
7266
        (ashiftrt:DI (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7267
  "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)
7268
   && (INTVAL (operands[3]) & 63) == 63"
7269
  "srda\t%0,%Y2"
7270
  [(set_attr "op_type"  "RS")
7271
   (set_attr "atype"    "reg")])
7272
 
7273
(define_insn "*ashrdi3_cconly_31_and"
7274
  [(set (reg CC_REGNUM)
7275
        (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7276
                              (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7277
                                      (match_operand:SI 3 "const_int_operand"   "n")))
7278
                 (const_int 0)))
7279
   (clobber (match_scratch:DI 0 "=d"))]
7280
  "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)
7281
   && (INTVAL (operands[3]) & 63) == 63"
7282
  "srda\t%0,%Y2"
7283
  [(set_attr "op_type"  "RS")
7284
   (set_attr "atype"    "reg")])
7285
 
7286
(define_insn "*ashrdi3_31_and"
7287
  [(set (match_operand:DI 0 "register_operand" "=d")
7288
        (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7289
                     (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7290
                             (match_operand:SI 3 "const_int_operand"   "n"))))
7291
   (clobber (reg:CC CC_REGNUM))]
7292
  "!TARGET_64BIT && (INTVAL (operands[3]) & 63) == 63"
7293
  "srda\t%0,%Y2"
7294
  [(set_attr "op_type"  "RS")
7295
   (set_attr "atype"    "reg")])
7296
 
7297
; sra, srag
7298
(define_insn "*ashr3_cc_and"
7299
  [(set (reg CC_REGNUM)
7300
        (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "")
7301
                               (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7302
                                       (match_operand:SI 3 "const_int_operand"   "n")))
7303
                 (const_int 0)))
7304
   (set (match_operand:GPR 0 "register_operand" "=d")
7305
        (ashiftrt:GPR (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7306
  "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7307
  "sra\t%0,<1>%Y2"
7308
  [(set_attr "op_type"  "RS")
7309
   (set_attr "atype"    "reg")
7310
   (set_attr "z10prop" "z10_super_E1")])
7311
 
7312
; sra, srag
7313
(define_insn "*ashr3_cconly_and"
7314
  [(set (reg CC_REGNUM)
7315
        (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "")
7316
                               (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7317
                                       (match_operand:SI 3 "const_int_operand"   "n")))
7318
                 (const_int 0)))
7319
   (clobber (match_scratch:GPR 0 "=d"))]
7320
  "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7321
  "sra\t%0,<1>%Y2"
7322
  [(set_attr "op_type"  "RS")
7323
   (set_attr "atype"    "reg")
7324
   (set_attr "z10prop" "z10_super_E1")])
7325
 
7326
; sra, srag
7327
(define_insn "*ashr3_and"
7328
  [(set (match_operand:GPR 0 "register_operand" "=d")
7329
        (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "")
7330
                      (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7331
                              (match_operand:SI 3 "const_int_operand"   "n"))))
7332
   (clobber (reg:CC CC_REGNUM))]
7333
  "(INTVAL (operands[3]) & 63) == 63"
7334
  "sra\t%0,<1>%Y2"
7335
  [(set_attr "op_type"  "RS")
7336
   (set_attr "atype"    "reg")
7337
   (set_attr "z10prop" "z10_super_E1")])
7338
 
7339
 
7340
;;
7341
;; Branch instruction patterns.
7342
;;
7343
 
7344
(define_expand "cbranch4"
7345
  [(set (pc)
7346
        (if_then_else (match_operator 0 "comparison_operator"
7347
                       [(match_operand:GPR 1 "register_operand" "")
7348
                        (match_operand:GPR 2 "general_operand" "")])
7349
                      (label_ref (match_operand 3 "" ""))
7350
                      (pc)))]
7351
  ""
7352
  "s390_emit_jump (operands[3],
7353
    s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
7354
   DONE;")
7355
 
7356
(define_expand "cbranch4"
7357
  [(set (pc)
7358
        (if_then_else (match_operator 0 "comparison_operator"
7359
                       [(match_operand:FP 1 "register_operand" "")
7360
                        (match_operand:FP 2 "general_operand" "")])
7361
                      (label_ref (match_operand 3 "" ""))
7362
                      (pc)))]
7363
  "TARGET_HARD_FLOAT"
7364
  "s390_emit_jump (operands[3],
7365
    s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
7366
   DONE;")
7367
 
7368
(define_expand "cbranchcc4"
7369
  [(set (pc)
7370
        (if_then_else (match_operator 0 "s390_eqne_operator"
7371
                       [(match_operand 1 "cc_reg_operand" "")
7372
                        (match_operand 2 "const0_operand" "")])
7373
                      (label_ref (match_operand 3 "" ""))
7374
                      (pc)))]
7375
  "TARGET_HARD_FLOAT"
7376
  "s390_emit_jump (operands[3],
7377
    s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
7378
   DONE;")
7379
 
7380
 
7381
 
7382
;;
7383
;;- Conditional jump instructions.
7384
;;
7385
 
7386
(define_insn "*cjump_64"
7387
  [(set (pc)
7388
        (if_then_else
7389
          (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7390
          (label_ref (match_operand 0 "" ""))
7391
          (pc)))]
7392
  "TARGET_CPU_ZARCH"
7393
{
7394
  if (get_attr_length (insn) == 4)
7395
    return "j%C1\t%l0";
7396
  else
7397
    return "jg%C1\t%l0";
7398
}
7399
  [(set_attr "op_type" "RI")
7400
   (set_attr "type"    "branch")
7401
   (set (attr "length")
7402
        (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7403
                      (const_int 4) (const_int 6)))])
7404
 
7405
(define_insn "*cjump_31"
7406
  [(set (pc)
7407
        (if_then_else
7408
          (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7409
          (label_ref (match_operand 0 "" ""))
7410
          (pc)))]
7411
  "!TARGET_CPU_ZARCH"
7412
{
7413
  gcc_assert (get_attr_length (insn) == 4);
7414
  return "j%C1\t%l0";
7415
}
7416
  [(set_attr "op_type" "RI")
7417
   (set_attr "type"    "branch")
7418
   (set (attr "length")
7419
        (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7420
          (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7421
                        (const_int 4) (const_int 6))
7422
          (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7423
                        (const_int 4) (const_int 8))))])
7424
 
7425
(define_insn "*cjump_long"
7426
  [(set (pc)
7427
        (if_then_else
7428
          (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7429
          (match_operand 0 "address_operand" "ZQZR")
7430
          (pc)))]
7431
  ""
7432
{
7433
  if (get_attr_op_type (insn) == OP_TYPE_RR)
7434
    return "b%C1r\t%0";
7435
  else
7436
    return "b%C1\t%a0";
7437
}
7438
  [(set (attr "op_type")
7439
        (if_then_else (match_operand 0 "register_operand" "")
7440
                      (const_string "RR") (const_string "RX")))
7441
   (set_attr "type"  "branch")
7442
   (set_attr "atype" "agen")])
7443
 
7444
 
7445
;;
7446
;;- Negated conditional jump instructions.
7447
;;
7448
 
7449
(define_insn "*icjump_64"
7450
  [(set (pc)
7451
        (if_then_else
7452
          (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7453
          (pc)
7454
          (label_ref (match_operand 0 "" ""))))]
7455
  "TARGET_CPU_ZARCH"
7456
{
7457
  if (get_attr_length (insn) == 4)
7458
    return "j%D1\t%l0";
7459
  else
7460
    return "jg%D1\t%l0";
7461
}
7462
  [(set_attr "op_type" "RI")
7463
   (set_attr "type"    "branch")
7464
   (set (attr "length")
7465
        (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7466
                      (const_int 4) (const_int 6)))])
7467
 
7468
(define_insn "*icjump_31"
7469
  [(set (pc)
7470
        (if_then_else
7471
          (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7472
          (pc)
7473
          (label_ref (match_operand 0 "" ""))))]
7474
  "!TARGET_CPU_ZARCH"
7475
{
7476
  gcc_assert (get_attr_length (insn) == 4);
7477
  return "j%D1\t%l0";
7478
}
7479
  [(set_attr "op_type" "RI")
7480
   (set_attr "type"    "branch")
7481
   (set (attr "length")
7482
        (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7483
          (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7484
                        (const_int 4) (const_int 6))
7485
          (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7486
                        (const_int 4) (const_int 8))))])
7487
 
7488
(define_insn "*icjump_long"
7489
  [(set (pc)
7490
        (if_then_else
7491
          (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7492
          (pc)
7493
          (match_operand 0 "address_operand" "ZQZR")))]
7494
  ""
7495
{
7496
  if (get_attr_op_type (insn) == OP_TYPE_RR)
7497
    return "b%D1r\t%0";
7498
  else
7499
    return "b%D1\t%a0";
7500
}
7501
  [(set (attr "op_type")
7502
        (if_then_else (match_operand 0 "register_operand" "")
7503
                      (const_string "RR") (const_string "RX")))
7504
   (set_attr "type"  "branch")
7505
   (set_attr "atype" "agen")])
7506
 
7507
;;
7508
;;- Trap instructions.
7509
;;
7510
 
7511
(define_insn "trap"
7512
  [(trap_if (const_int 1) (const_int 0))]
7513
  ""
7514
  "j\t.+2"
7515
  [(set_attr "op_type" "RI")
7516
   (set_attr "type"  "branch")])
7517
 
7518
(define_expand "ctrap4"
7519
  [(trap_if (match_operator 0 "comparison_operator"
7520
             [(match_operand:GPR 1 "register_operand" "")
7521
              (match_operand:GPR 2 "general_operand" "")])
7522
             (match_operand 3 "const0_operand" ""))]
7523
  ""
7524
  {
7525
    rtx cond = s390_emit_compare (GET_CODE (operands[0]),
7526
                                  operands[1], operands[2]);
7527
    emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
7528
    DONE;
7529
  })
7530
 
7531
(define_expand "ctrap4"
7532
  [(trap_if (match_operator 0 "comparison_operator"
7533
             [(match_operand:FP 1 "register_operand" "")
7534
              (match_operand:FP 2 "general_operand" "")])
7535
             (match_operand 3 "const0_operand" ""))]
7536
  ""
7537
  {
7538
    rtx cond = s390_emit_compare (GET_CODE (operands[0]),
7539
                                  operands[1], operands[2]);
7540
    emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
7541
    DONE;
7542
  })
7543
 
7544
(define_insn "condtrap"
7545
  [(trap_if (match_operator 0 "s390_comparison"
7546
             [(match_operand 1 "cc_reg_operand" "c")
7547
              (const_int 0)])
7548
            (const_int 0))]
7549
  ""
7550
  "j%C0\t.+2";
7551
  [(set_attr "op_type" "RI")
7552
   (set_attr "type"  "branch")])
7553
 
7554
; crt, cgrt, cit, cgit
7555
(define_insn "*cmp_and_trap_signed_int"
7556
  [(trap_if (match_operator 0 "s390_signed_integer_comparison"
7557
               [(match_operand:GPR 1 "register_operand"  "d,d")
7558
                (match_operand:GPR 2 "nonmemory_operand" "d,K")])
7559
            (const_int 0))]
7560
  "TARGET_Z10"
7561
  "@
7562
   crt%C0\t%1,%2
7563
   cit%C0\t%1,%h2"
7564
  [(set_attr "op_type" "RRF,RIE")
7565
   (set_attr "type"    "branch")
7566
   (set_attr "z10prop" "z10_super_c,z10_super")])
7567
 
7568
; clrt, clgrt, clfit, clgit
7569
(define_insn "*cmp_and_trap_unsigned_int"
7570
  [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
7571
               [(match_operand:GPR 1 "register_operand"  "d,d")
7572
                (match_operand:GPR 2 "nonmemory_operand" "d,D")])
7573
            (const_int 0))]
7574
  "TARGET_Z10"
7575
  "@
7576
   clrt%C0\t%1,%2
7577
   clit%C0\t%1,%x2"
7578
  [(set_attr "op_type" "RRF,RIE")
7579
   (set_attr "type"    "branch")
7580
   (set_attr "z10prop" "z10_super_c,z10_super")])
7581
 
7582
;;
7583
;;- Loop instructions.
7584
;;
7585
;;  This is all complicated by the fact that since this is a jump insn
7586
;;  we must handle our own output reloads.
7587
 
7588
;; branch on index
7589
 
7590
; This splitter will be matched by combine and has to add the 2 moves
7591
; necessary to load the compare and the increment values into a
7592
; register pair as needed by brxle.
7593
 
7594
(define_insn_and_split "*brx_stage1_"
7595
  [(set (pc)
7596
        (if_then_else
7597
         (match_operator 6 "s390_brx_operator"
7598
            [(plus:GPR (match_operand:GPR 1 "register_operand" "")
7599
                       (match_operand:GPR 2 "general_operand"  ""))
7600
             (match_operand:GPR 3 "register_operand" "")])
7601
         (label_ref (match_operand 0 "" ""))
7602
         (pc)))
7603
   (set (match_operand:GPR 4 "nonimmediate_operand" "")
7604
        (plus:GPR (match_dup 1) (match_dup 2)))
7605
   (clobber (match_scratch:GPR 5 ""))]
7606
  "TARGET_CPU_ZARCH"
7607
  "#"
7608
  "!reload_completed && !reload_in_progress"
7609
  [(set (match_dup 7) (match_dup 2)) ; the increment
7610
   (set (match_dup 8) (match_dup 3)) ; the comparison value
7611
   (parallel [(set (pc)
7612
                   (if_then_else
7613
                    (match_op_dup 6
7614
                       [(plus:GPR (match_dup 1) (match_dup 7))
7615
                        (match_dup 8)])
7616
                    (label_ref (match_dup 0))
7617
                    (pc)))
7618
              (set (match_dup 4)
7619
                   (plus:GPR (match_dup 1) (match_dup 7)))
7620
              (clobber (match_dup 5))
7621
              (clobber (reg:CC CC_REGNUM))])]
7622
  {
7623
    rtx dreg = gen_reg_rtx (word_mode == DImode ? TImode : DImode);
7624
    operands[7] = gen_lowpart (mode,
7625
                               gen_highpart (word_mode, dreg));
7626
    operands[8] = gen_lowpart (mode,
7627
                               gen_lowpart (word_mode, dreg));
7628
  })
7629
 
7630
; brxlg, brxhg
7631
 
7632
(define_insn_and_split "*brxg_64bit"
7633
  [(set (pc)
7634
        (if_then_else
7635
          (match_operator 5 "s390_brx_operator"
7636
             [(plus:DI (match_operand:DI 1 "register_operand" "d,d,d")
7637
                       (subreg:DI (match_operand:TI 2 "register_operand" "d,d,d") 0))
7638
              (subreg:DI (match_dup 2) 8)])
7639
          (label_ref (match_operand 0 "" ""))
7640
          (pc)))
7641
   (set (match_operand:DI 3 "nonimmediate_operand" "=1,?X,?X")
7642
        (plus:DI (match_dup 1)
7643
                 (subreg:DI (match_dup 2) 0)))
7644
   (clobber (match_scratch:DI 4 "=X,&1,&?d"))
7645
   (clobber (reg:CC CC_REGNUM))]
7646
  "TARGET_64BIT"
7647
{
7648
  if (which_alternative != 0)
7649
    return "#";
7650
  else if (get_attr_length (insn) == 6)
7651
    return "brx%E5g\t%1,%2,%l0";
7652
  else
7653
    return "agr\t%1,%2\;cgr\t%1,%M2\;jg%C5\t%l0";
7654
}
7655
  "&& reload_completed
7656
   && (!REG_P (operands[3])
7657
       || !rtx_equal_p (operands[1], operands[3]))"
7658
  [(set (match_dup 4) (match_dup 1))
7659
   (parallel [(set (match_dup 4) (plus:DI (match_dup 4) (subreg:DI (match_dup 2) 0)))
7660
              (clobber (reg:CC CC_REGNUM))])
7661
   (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:DI (match_dup 2) 8)))
7662
   (set (match_dup 3) (match_dup 4))
7663
   (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
7664
                           (label_ref (match_dup 0))
7665
                           (pc)))]
7666
  ""
7667
  [(set_attr "op_type"  "RIE")
7668
   (set_attr "type"  "branch")
7669
   (set (attr "length")
7670
        (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7671
                      (const_int 6) (const_int 16)))])
7672
 
7673
; brxle, brxh
7674
 
7675
(define_insn_and_split "*brx_64bit"
7676
  [(set (pc)
7677
        (if_then_else
7678
          (match_operator 5 "s390_brx_operator"
7679
             [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
7680
                       (subreg:SI (match_operand:TI 2 "register_operand" "d,d,d") 4))
7681
              (subreg:SI (match_dup 2) 12)])
7682
          (label_ref (match_operand 0 "" ""))
7683
          (pc)))
7684
   (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
7685
        (plus:SI (match_dup 1)
7686
                 (subreg:SI (match_dup 2) 4)))
7687
   (clobber (match_scratch:SI 4 "=X,&1,&?d"))
7688
   (clobber (reg:CC CC_REGNUM))]
7689
  "TARGET_64BIT"
7690
{
7691
  if (which_alternative != 0)
7692
    return "#";
7693
  else if (get_attr_length (insn) == 6)
7694
    return "brx%C5\t%1,%2,%l0";
7695
  else
7696
    return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
7697
}
7698
  "&& reload_completed
7699
   && (!REG_P (operands[3])
7700
       || !rtx_equal_p (operands[1], operands[3]))"
7701
  [(set (match_dup 4) (match_dup 1))
7702
   (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 4)))
7703
              (clobber (reg:CC CC_REGNUM))])
7704
   (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 12)))
7705
   (set (match_dup 3) (match_dup 4))
7706
   (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
7707
                           (label_ref (match_dup 0))
7708
                           (pc)))]
7709
  ""
7710
  [(set_attr "op_type"  "RSI")
7711
   (set_attr "type"  "branch")
7712
   (set (attr "length")
7713
        (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7714
                      (const_int 6) (const_int 14)))])
7715
 
7716
; brxle, brxh
7717
 
7718
(define_insn_and_split "*brx_31bit"
7719
  [(set (pc)
7720
        (if_then_else
7721
          (match_operator 5 "s390_brx_operator"
7722
            [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
7723
                      (subreg:SI (match_operand:DI 2 "register_operand" "d,d,d") 0))
7724
             (subreg:SI (match_dup 2) 4)])
7725
          (label_ref (match_operand 0 "" ""))
7726
          (pc)))
7727
   (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
7728
        (plus:SI (match_dup 1)
7729
                 (subreg:SI (match_dup 2) 0)))
7730
   (clobber (match_scratch:SI 4 "=X,&1,&?d"))
7731
   (clobber (reg:CC CC_REGNUM))]
7732
  "!TARGET_64BIT && TARGET_CPU_ZARCH"
7733
{
7734
  if (which_alternative != 0)
7735
    return "#";
7736
  else if (get_attr_length (insn) == 6)
7737
    return "brx%C5\t%1,%2,%l0";
7738
  else
7739
    return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
7740
}
7741
  "&& reload_completed
7742
   && (!REG_P (operands[3])
7743
       || !rtx_equal_p (operands[1], operands[3]))"
7744
  [(set (match_dup 4) (match_dup 1))
7745
   (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 0)))
7746
              (clobber (reg:CC CC_REGNUM))])
7747
   (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 4)))
7748
   (set (match_dup 3) (match_dup 4))
7749
   (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
7750
                           (label_ref (match_dup 0))
7751
                           (pc)))]
7752
  ""
7753
  [(set_attr "op_type"  "RSI")
7754
   (set_attr "type"  "branch")
7755
   (set (attr "length")
7756
        (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7757
                      (const_int 6) (const_int 14)))])
7758
 
7759
 
7760
;; branch on count
7761
 
7762
(define_expand "doloop_end"
7763
  [(use (match_operand 0 "" ""))        ; loop pseudo
7764
   (use (match_operand 1 "" ""))        ; iterations; zero if unknown
7765
   (use (match_operand 2 "" ""))        ; max iterations
7766
   (use (match_operand 3 "" ""))        ; loop level
7767
   (use (match_operand 4 "" ""))]       ; label
7768
  ""
7769
{
7770
  if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
7771
    emit_jump_insn (gen_doloop_si31 (operands[4], operands[0], operands[0]));
7772
  else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
7773
    emit_jump_insn (gen_doloop_si64 (operands[4], operands[0], operands[0]));
7774
  else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
7775
    emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
7776
  else
7777
    FAIL;
7778
 
7779
  DONE;
7780
})
7781
 
7782
(define_insn_and_split "doloop_si64"
7783
  [(set (pc)
7784
        (if_then_else
7785
          (ne (match_operand:SI 1 "register_operand" "d,d,d")
7786
              (const_int 1))
7787
          (label_ref (match_operand 0 "" ""))
7788
          (pc)))
7789
   (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
7790
        (plus:SI (match_dup 1) (const_int -1)))
7791
   (clobber (match_scratch:SI 3 "=X,&1,&?d"))
7792
   (clobber (reg:CC CC_REGNUM))]
7793
  "TARGET_CPU_ZARCH"
7794
{
7795
  if (which_alternative != 0)
7796
    return "#";
7797
  else if (get_attr_length (insn) == 4)
7798
    return "brct\t%1,%l0";
7799
  else
7800
    return "ahi\t%1,-1\;jgne\t%l0";
7801
}
7802
  "&& reload_completed
7803
   && (! REG_P (operands[2])
7804
       || ! rtx_equal_p (operands[1], operands[2]))"
7805
  [(set (match_dup 3) (match_dup 1))
7806
   (parallel [(set (reg:CCAN CC_REGNUM)
7807
                   (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7808
                                 (const_int 0)))
7809
              (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7810
   (set (match_dup 2) (match_dup 3))
7811
   (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7812
                           (label_ref (match_dup 0))
7813
                           (pc)))]
7814
  ""
7815
  [(set_attr "op_type"  "RI")
7816
   ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7817
   ; hurt us in the (rare) case of ahi.
7818
   (set_attr "z10prop"  "z10_super_E1")
7819
   (set_attr "type"  "branch")
7820
   (set (attr "length")
7821
        (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7822
                      (const_int 4) (const_int 10)))])
7823
 
7824
(define_insn_and_split "doloop_si31"
7825
  [(set (pc)
7826
        (if_then_else
7827
          (ne (match_operand:SI 1 "register_operand" "d,d,d")
7828
              (const_int 1))
7829
          (label_ref (match_operand 0 "" ""))
7830
          (pc)))
7831
   (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
7832
        (plus:SI (match_dup 1) (const_int -1)))
7833
   (clobber (match_scratch:SI 3 "=X,&1,&?d"))
7834
   (clobber (reg:CC CC_REGNUM))]
7835
  "!TARGET_CPU_ZARCH"
7836
{
7837
  if (which_alternative != 0)
7838
    return "#";
7839
  else if (get_attr_length (insn) == 4)
7840
    return "brct\t%1,%l0";
7841
  else
7842
    gcc_unreachable ();
7843
}
7844
  "&& reload_completed
7845
   && (! REG_P (operands[2])
7846
       || ! rtx_equal_p (operands[1], operands[2]))"
7847
  [(set (match_dup 3) (match_dup 1))
7848
   (parallel [(set (reg:CCAN CC_REGNUM)
7849
                   (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7850
                                 (const_int 0)))
7851
              (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7852
   (set (match_dup 2) (match_dup 3))
7853
   (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7854
                           (label_ref (match_dup 0))
7855
                           (pc)))]
7856
  ""
7857
  [(set_attr "op_type"  "RI")
7858
   ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7859
   ; hurt us in the (rare) case of ahi.
7860
   (set_attr "z10prop"  "z10_super_E1")
7861
   (set_attr "type"  "branch")
7862
   (set (attr "length")
7863
        (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7864
          (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7865
                        (const_int 4) (const_int 6))
7866
          (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7867
                        (const_int 4) (const_int 8))))])
7868
 
7869
(define_insn "*doloop_si_long"
7870
  [(set (pc)
7871
        (if_then_else
7872
          (ne (match_operand:SI 1 "register_operand" "d")
7873
              (const_int 1))
7874
          (match_operand 0 "address_operand" "ZQZR")
7875
          (pc)))
7876
   (set (match_operand:SI 2 "register_operand" "=1")
7877
        (plus:SI (match_dup 1) (const_int -1)))
7878
   (clobber (match_scratch:SI 3 "=X"))
7879
   (clobber (reg:CC CC_REGNUM))]
7880
  "!TARGET_CPU_ZARCH"
7881
{
7882
  if (get_attr_op_type (insn) == OP_TYPE_RR)
7883
    return "bctr\t%1,%0";
7884
  else
7885
    return "bct\t%1,%a0";
7886
}
7887
  [(set (attr "op_type")
7888
        (if_then_else (match_operand 0 "register_operand" "")
7889
                      (const_string "RR") (const_string "RX")))
7890
   (set_attr "type"  "branch")
7891
   (set_attr "atype" "agen")
7892
   (set_attr "z10prop"  "z10_c")])
7893
 
7894
(define_insn_and_split "doloop_di"
7895
  [(set (pc)
7896
        (if_then_else
7897
          (ne (match_operand:DI 1 "register_operand" "d,d,d")
7898
              (const_int 1))
7899
          (label_ref (match_operand 0 "" ""))
7900
          (pc)))
7901
   (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
7902
        (plus:DI (match_dup 1) (const_int -1)))
7903
   (clobber (match_scratch:DI 3 "=X,&1,&?d"))
7904
   (clobber (reg:CC CC_REGNUM))]
7905
  "TARGET_64BIT"
7906
{
7907
  if (which_alternative != 0)
7908
    return "#";
7909
  else if (get_attr_length (insn) == 4)
7910
    return "brctg\t%1,%l0";
7911
  else
7912
    return "aghi\t%1,-1\;jgne\t%l0";
7913
}
7914
  "&& reload_completed
7915
   && (! REG_P (operands[2])
7916
       || ! rtx_equal_p (operands[1], operands[2]))"
7917
  [(set (match_dup 3) (match_dup 1))
7918
   (parallel [(set (reg:CCAN CC_REGNUM)
7919
                   (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
7920
                                 (const_int 0)))
7921
              (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
7922
   (set (match_dup 2) (match_dup 3))
7923
   (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7924
                           (label_ref (match_dup 0))
7925
                           (pc)))]
7926
  ""
7927
  [(set_attr "op_type"  "RI")
7928
   ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7929
   ; hurt us in the (rare) case of ahi.
7930
   (set_attr "z10prop"  "z10_super_E1")
7931
   (set_attr "type"  "branch")
7932
   (set (attr "length")
7933
        (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7934
                      (const_int 4) (const_int 10)))])
7935
 
7936
;;
7937
;;- Unconditional jump instructions.
7938
;;
7939
 
7940
;
7941
; jump instruction pattern(s).
7942
;
7943
 
7944
(define_expand "jump"
7945
  [(match_operand 0 "" "")]
7946
  ""
7947
  "s390_emit_jump (operands[0], NULL_RTX); DONE;")
7948
 
7949
(define_insn "*jump64"
7950
  [(set (pc) (label_ref (match_operand 0 "" "")))]
7951
  "TARGET_CPU_ZARCH"
7952
{
7953
  if (get_attr_length (insn) == 4)
7954
    return "j\t%l0";
7955
  else
7956
    return "jg\t%l0";
7957
}
7958
  [(set_attr "op_type" "RI")
7959
   (set_attr "type"  "branch")
7960
   (set (attr "length")
7961
        (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7962
                      (const_int 4) (const_int 6)))])
7963
 
7964
(define_insn "*jump31"
7965
  [(set (pc) (label_ref (match_operand 0 "" "")))]
7966
  "!TARGET_CPU_ZARCH"
7967
{
7968
  gcc_assert (get_attr_length (insn) == 4);
7969
  return "j\t%l0";
7970
}
7971
  [(set_attr "op_type" "RI")
7972
   (set_attr "type"  "branch")
7973
   (set (attr "length")
7974
        (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7975
          (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7976
                        (const_int 4) (const_int 6))
7977
          (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7978
                        (const_int 4) (const_int 8))))])
7979
 
7980
;
7981
; indirect-jump instruction pattern(s).
7982
;
7983
 
7984
(define_insn "indirect_jump"
7985
 [(set (pc) (match_operand 0 "address_operand" "ZQZR"))]
7986
  ""
7987
{
7988
  if (get_attr_op_type (insn) == OP_TYPE_RR)
7989
    return "br\t%0";
7990
  else
7991
    return "b\t%a0";
7992
}
7993
  [(set (attr "op_type")
7994
        (if_then_else (match_operand 0 "register_operand" "")
7995
                      (const_string "RR") (const_string "RX")))
7996
   (set_attr "type"  "branch")
7997
   (set_attr "atype" "agen")])
7998
 
7999
;
8000
; casesi instruction pattern(s).
8001
;
8002
 
8003
(define_insn "casesi_jump"
8004
 [(set (pc) (match_operand 0 "address_operand" "ZQZR"))
8005
   (use (label_ref (match_operand 1 "" "")))]
8006
  ""
8007
{
8008
  if (get_attr_op_type (insn) == OP_TYPE_RR)
8009
    return "br\t%0";
8010
  else
8011
    return "b\t%a0";
8012
}
8013
  [(set (attr "op_type")
8014
        (if_then_else (match_operand 0 "register_operand" "")
8015
                      (const_string "RR") (const_string "RX")))
8016
   (set_attr "type"  "branch")
8017
   (set_attr "atype" "agen")])
8018
 
8019
(define_expand "casesi"
8020
  [(match_operand:SI 0 "general_operand" "")
8021
   (match_operand:SI 1 "general_operand" "")
8022
   (match_operand:SI 2 "general_operand" "")
8023
   (label_ref (match_operand 3 "" ""))
8024
   (label_ref (match_operand 4 "" ""))]
8025
  ""
8026
{
8027
   rtx index  = gen_reg_rtx (SImode);
8028
   rtx base   = gen_reg_rtx (Pmode);
8029
   rtx target = gen_reg_rtx (Pmode);
8030
 
8031
   emit_move_insn (index, operands[0]);
8032
   emit_insn (gen_subsi3 (index, index, operands[1]));
8033
   emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
8034
                            operands[4]);
8035
 
8036
   if (Pmode != SImode)
8037
     index = convert_to_mode (Pmode, index, 1);
8038
   if (GET_CODE (index) != REG)
8039
     index = copy_to_mode_reg (Pmode, index);
8040
 
8041
   if (TARGET_64BIT)
8042
       emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
8043
   else
8044
       emit_insn (gen_ashlsi3 (index, index, const2_rtx));
8045
 
8046
   emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
8047
 
8048
   index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
8049
   emit_move_insn (target, index);
8050
 
8051
   if (flag_pic)
8052
     target = gen_rtx_PLUS (Pmode, base, target);
8053
   emit_jump_insn (gen_casesi_jump (target, operands[3]));
8054
 
8055
   DONE;
8056
})
8057
 
8058
 
8059
;;
8060
;;- Jump to subroutine.
8061
;;
8062
;;
8063
 
8064
;
8065
; untyped call instruction pattern(s).
8066
;
8067
 
8068
;; Call subroutine returning any type.
8069
(define_expand "untyped_call"
8070
  [(parallel [(call (match_operand 0 "" "")
8071
                    (const_int 0))
8072
              (match_operand 1 "" "")
8073
              (match_operand 2 "" "")])]
8074
  ""
8075
{
8076
  int i;
8077
 
8078
  emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
8079
 
8080
  for (i = 0; i < XVECLEN (operands[2], 0); i++)
8081
    {
8082
      rtx set = XVECEXP (operands[2], 0, i);
8083
      emit_move_insn (SET_DEST (set), SET_SRC (set));
8084
    }
8085
 
8086
  /* The optimizer does not know that the call sets the function value
8087
     registers we stored in the result block.  We avoid problems by
8088
     claiming that all hard registers are used and clobbered at this
8089
     point.  */
8090
  emit_insn (gen_blockage ());
8091
 
8092
  DONE;
8093
})
8094
 
8095
;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
8096
;; all of memory.  This blocks insns from being moved across this point.
8097
 
8098
(define_insn "blockage"
8099
  [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
8100
  ""
8101
  ""
8102
  [(set_attr "type"    "none")
8103
   (set_attr "length"  "0")])
8104
 
8105
;
8106
; sibcall patterns
8107
;
8108
 
8109
(define_expand "sibcall"
8110
  [(call (match_operand 0 "" "")
8111
         (match_operand 1 "" ""))]
8112
  ""
8113
{
8114
  s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
8115
  DONE;
8116
})
8117
 
8118
(define_insn "*sibcall_br"
8119
  [(call (mem:QI (reg SIBCALL_REGNUM))
8120
         (match_operand 0 "const_int_operand" "n"))]
8121
  "SIBLING_CALL_P (insn)
8122
   && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
8123
  "br\t%%r1"
8124
  [(set_attr "op_type" "RR")
8125
   (set_attr "type"  "branch")
8126
   (set_attr "atype" "agen")])
8127
 
8128
(define_insn "*sibcall_brc"
8129
  [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8130
         (match_operand 1 "const_int_operand" "n"))]
8131
  "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
8132
  "j\t%0"
8133
  [(set_attr "op_type" "RI")
8134
   (set_attr "type"    "branch")])
8135
 
8136
(define_insn "*sibcall_brcl"
8137
  [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8138
         (match_operand 1 "const_int_operand" "n"))]
8139
  "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
8140
  "jg\t%0"
8141
  [(set_attr "op_type" "RIL")
8142
   (set_attr "type"    "branch")])
8143
 
8144
;
8145
; sibcall_value patterns
8146
;
8147
 
8148
(define_expand "sibcall_value"
8149
  [(set (match_operand 0 "" "")
8150
        (call (match_operand 1 "" "")
8151
              (match_operand 2 "" "")))]
8152
  ""
8153
{
8154
  s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
8155
  DONE;
8156
})
8157
 
8158
(define_insn "*sibcall_value_br"
8159
  [(set (match_operand 0 "" "")
8160
        (call (mem:QI (reg SIBCALL_REGNUM))
8161
              (match_operand 1 "const_int_operand" "n")))]
8162
  "SIBLING_CALL_P (insn)
8163
   && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
8164
  "br\t%%r1"
8165
  [(set_attr "op_type" "RR")
8166
   (set_attr "type"  "branch")
8167
   (set_attr "atype" "agen")])
8168
 
8169
(define_insn "*sibcall_value_brc"
8170
  [(set (match_operand 0 "" "")
8171
        (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8172
              (match_operand 2 "const_int_operand" "n")))]
8173
  "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
8174
  "j\t%1"
8175
  [(set_attr "op_type" "RI")
8176
   (set_attr "type"    "branch")])
8177
 
8178
(define_insn "*sibcall_value_brcl"
8179
  [(set (match_operand 0 "" "")
8180
        (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8181
              (match_operand 2 "const_int_operand" "n")))]
8182
  "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
8183
  "jg\t%1"
8184
  [(set_attr "op_type" "RIL")
8185
   (set_attr "type"    "branch")])
8186
 
8187
 
8188
;
8189
; call instruction pattern(s).
8190
;
8191
 
8192
(define_expand "call"
8193
  [(call (match_operand 0 "" "")
8194
         (match_operand 1 "" ""))
8195
   (use (match_operand 2 "" ""))]
8196
  ""
8197
{
8198
  s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
8199
                  gen_rtx_REG (Pmode, RETURN_REGNUM));
8200
  DONE;
8201
})
8202
 
8203
(define_insn "*bras"
8204
  [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8205
         (match_operand 1 "const_int_operand" "n"))
8206
   (clobber (match_operand 2 "register_operand" "=r"))]
8207
  "!SIBLING_CALL_P (insn)
8208
   && TARGET_SMALL_EXEC
8209
   && GET_MODE (operands[2]) == Pmode"
8210
  "bras\t%2,%0"
8211
  [(set_attr "op_type" "RI")
8212
   (set_attr "type"    "jsr")])
8213
 
8214
(define_insn "*brasl"
8215
  [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8216
         (match_operand 1 "const_int_operand" "n"))
8217
   (clobber (match_operand 2 "register_operand" "=r"))]
8218
  "!SIBLING_CALL_P (insn)
8219
   && TARGET_CPU_ZARCH
8220
   && GET_MODE (operands[2]) == Pmode"
8221
  "brasl\t%2,%0"
8222
  [(set_attr "op_type" "RIL")
8223
   (set_attr "type"    "jsr")])
8224
 
8225
(define_insn "*basr"
8226
  [(call (mem:QI (match_operand 0 "address_operand" "ZQZR"))
8227
         (match_operand 1 "const_int_operand" "n"))
8228
   (clobber (match_operand 2 "register_operand" "=r"))]
8229
  "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
8230
{
8231
  if (get_attr_op_type (insn) == OP_TYPE_RR)
8232
    return "basr\t%2,%0";
8233
  else
8234
    return "bas\t%2,%a0";
8235
}
8236
  [(set (attr "op_type")
8237
        (if_then_else (match_operand 0 "register_operand" "")
8238
                      (const_string "RR") (const_string "RX")))
8239
   (set_attr "type"  "jsr")
8240
   (set_attr "atype" "agen")])
8241
 
8242
;
8243
; call_value instruction pattern(s).
8244
;
8245
 
8246
(define_expand "call_value"
8247
  [(set (match_operand 0 "" "")
8248
        (call (match_operand 1 "" "")
8249
              (match_operand 2 "" "")))
8250
   (use (match_operand 3 "" ""))]
8251
  ""
8252
{
8253
  s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
8254
                  gen_rtx_REG (Pmode, RETURN_REGNUM));
8255
  DONE;
8256
})
8257
 
8258
(define_insn "*bras_r"
8259
  [(set (match_operand 0 "" "")
8260
        (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8261
              (match_operand:SI 2 "const_int_operand" "n")))
8262
   (clobber (match_operand 3 "register_operand" "=r"))]
8263
  "!SIBLING_CALL_P (insn)
8264
   && TARGET_SMALL_EXEC
8265
   && GET_MODE (operands[3]) == Pmode"
8266
  "bras\t%3,%1"
8267
  [(set_attr "op_type" "RI")
8268
   (set_attr "type"    "jsr")])
8269
 
8270
(define_insn "*brasl_r"
8271
  [(set (match_operand 0 "" "")
8272
        (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8273
              (match_operand 2 "const_int_operand" "n")))
8274
   (clobber (match_operand 3 "register_operand" "=r"))]
8275
  "!SIBLING_CALL_P (insn)
8276
   && TARGET_CPU_ZARCH
8277
   && GET_MODE (operands[3]) == Pmode"
8278
  "brasl\t%3,%1"
8279
  [(set_attr "op_type" "RIL")
8280
   (set_attr "type"    "jsr")])
8281
 
8282
(define_insn "*basr_r"
8283
  [(set (match_operand 0 "" "")
8284
        (call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
8285
              (match_operand 2 "const_int_operand" "n")))
8286
   (clobber (match_operand 3 "register_operand" "=r"))]
8287
  "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8288
{
8289
  if (get_attr_op_type (insn) == OP_TYPE_RR)
8290
    return "basr\t%3,%1";
8291
  else
8292
    return "bas\t%3,%a1";
8293
}
8294
  [(set (attr "op_type")
8295
        (if_then_else (match_operand 1 "register_operand" "")
8296
                      (const_string "RR") (const_string "RX")))
8297
   (set_attr "type"  "jsr")
8298
   (set_attr "atype" "agen")])
8299
 
8300
;;
8301
;;- Thread-local storage support.
8302
;;
8303
 
8304
(define_expand "get_tp_64"
8305
  [(set (match_operand:DI 0 "nonimmediate_operand" "") (reg:DI TP_REGNUM))]
8306
  "TARGET_64BIT"
8307
  "")
8308
 
8309
(define_expand "get_tp_31"
8310
  [(set (match_operand:SI 0 "nonimmediate_operand" "") (reg:SI TP_REGNUM))]
8311
  "!TARGET_64BIT"
8312
  "")
8313
 
8314
(define_expand "set_tp_64"
8315
  [(set (reg:DI TP_REGNUM) (match_operand:DI 0 "nonimmediate_operand" ""))
8316
   (set (reg:DI TP_REGNUM) (unspec_volatile:DI [(reg:DI TP_REGNUM)] UNSPECV_SET_TP))]
8317
  "TARGET_64BIT"
8318
  "")
8319
 
8320
(define_expand "set_tp_31"
8321
  [(set (reg:SI TP_REGNUM) (match_operand:SI 0 "nonimmediate_operand" ""))
8322
   (set (reg:SI TP_REGNUM) (unspec_volatile:SI [(reg:SI TP_REGNUM)] UNSPECV_SET_TP))]
8323
  "!TARGET_64BIT"
8324
  "")
8325
 
8326
(define_insn "*set_tp"
8327
  [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
8328
  ""
8329
  ""
8330
  [(set_attr "type" "none")
8331
   (set_attr "length" "0")])
8332
 
8333
(define_insn "*tls_load_64"
8334
  [(set (match_operand:DI 0 "register_operand" "=d")
8335
        (unspec:DI [(match_operand:DI 1 "memory_operand" "RT")
8336
                    (match_operand:DI 2 "" "")]
8337
                   UNSPEC_TLS_LOAD))]
8338
  "TARGET_64BIT"
8339
  "lg\t%0,%1%J2"
8340
  [(set_attr "op_type" "RXE")
8341
   (set_attr "z10prop" "z10_fwd_A3")])
8342
 
8343
(define_insn "*tls_load_31"
8344
  [(set (match_operand:SI 0 "register_operand" "=d,d")
8345
        (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
8346
                    (match_operand:SI 2 "" "")]
8347
                   UNSPEC_TLS_LOAD))]
8348
  "!TARGET_64BIT"
8349
  "@
8350
   l\t%0,%1%J2
8351
   ly\t%0,%1%J2"
8352
  [(set_attr "op_type" "RX,RXY")
8353
   (set_attr "type" "load")
8354
   (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
8355
 
8356
(define_insn "*bras_tls"
8357
  [(set (match_operand 0 "" "")
8358
        (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8359
              (match_operand 2 "const_int_operand" "n")))
8360
   (clobber (match_operand 3 "register_operand" "=r"))
8361
   (use (match_operand 4 "" ""))]
8362
  "!SIBLING_CALL_P (insn)
8363
   && TARGET_SMALL_EXEC
8364
   && GET_MODE (operands[3]) == Pmode"
8365
  "bras\t%3,%1%J4"
8366
  [(set_attr "op_type" "RI")
8367
   (set_attr "type"    "jsr")])
8368
 
8369
(define_insn "*brasl_tls"
8370
  [(set (match_operand 0 "" "")
8371
        (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8372
              (match_operand 2 "const_int_operand" "n")))
8373
   (clobber (match_operand 3 "register_operand" "=r"))
8374
   (use (match_operand 4 "" ""))]
8375
  "!SIBLING_CALL_P (insn)
8376
   && TARGET_CPU_ZARCH
8377
   && GET_MODE (operands[3]) == Pmode"
8378
  "brasl\t%3,%1%J4"
8379
  [(set_attr "op_type" "RIL")
8380
   (set_attr "type"    "jsr")])
8381
 
8382
(define_insn "*basr_tls"
8383
  [(set (match_operand 0 "" "")
8384
        (call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
8385
              (match_operand 2 "const_int_operand" "n")))
8386
   (clobber (match_operand 3 "register_operand" "=r"))
8387
   (use (match_operand 4 "" ""))]
8388
  "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8389
{
8390
  if (get_attr_op_type (insn) == OP_TYPE_RR)
8391
    return "basr\t%3,%1%J4";
8392
  else
8393
    return "bas\t%3,%a1%J4";
8394
}
8395
  [(set (attr "op_type")
8396
        (if_then_else (match_operand 1 "register_operand" "")
8397
                      (const_string "RR") (const_string "RX")))
8398
   (set_attr "type"  "jsr")
8399
   (set_attr "atype" "agen")])
8400
 
8401
;;
8402
;;- Atomic operations
8403
;;
8404
 
8405
;
8406
; memory barrier pattern.
8407
;
8408
 
8409
(define_expand "memory_barrier"
8410
  [(set (match_dup 0)
8411
        (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
8412
  ""
8413
{
8414
  operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
8415
  MEM_VOLATILE_P (operands[0]) = 1;
8416
})
8417
 
8418
(define_insn "*memory_barrier"
8419
  [(set (match_operand:BLK 0 "" "")
8420
        (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
8421
  ""
8422
  "bcr\t15,0"
8423
  [(set_attr "op_type" "RR")])
8424
 
8425
; Although bcr is superscalar on Z10, this variant will never become part of
8426
; an execution group.
8427
 
8428
;
8429
; compare and swap patterns.
8430
;
8431
 
8432
(define_expand "sync_compare_and_swap"
8433
  [(parallel
8434
    [(set (match_operand:TDSI 0 "register_operand" "")
8435
          (match_operand:TDSI 1 "memory_operand" ""))
8436
     (set (match_dup 1)
8437
          (unspec_volatile:TDSI
8438
            [(match_dup 1)
8439
             (match_operand:TDSI 2 "register_operand" "")
8440
             (match_operand:TDSI 3 "register_operand" "")]
8441
            UNSPECV_CAS))
8442
     (set (reg:CCZ1 CC_REGNUM)
8443
          (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
8444
  "")
8445
 
8446
(define_expand "sync_compare_and_swap"
8447
  [(parallel
8448
    [(set (match_operand:HQI 0 "register_operand" "")
8449
          (match_operand:HQI 1 "memory_operand" ""))
8450
     (set (match_dup 1)
8451
          (unspec_volatile:HQI
8452
            [(match_dup 1)
8453
             (match_operand:HQI 2 "general_operand" "")
8454
             (match_operand:HQI 3 "general_operand" "")]
8455
            UNSPECV_CAS))
8456
     (clobber (reg:CC CC_REGNUM))])]
8457
  ""
8458
  "s390_expand_cs_hqi (mode, operands[0], operands[1],
8459
                       operands[2], operands[3]); DONE;")
8460
 
8461
; cds, cdsg
8462
(define_insn "*sync_compare_and_swap"
8463
  [(set (match_operand:DP 0 "register_operand" "=r")
8464
        (match_operand:DP 1 "memory_operand" "+Q"))
8465
   (set (match_dup 1)
8466
        (unspec_volatile:DP
8467
          [(match_dup 1)
8468
           (match_operand:DP 2 "register_operand" "0")
8469
           (match_operand:DP 3 "register_operand" "r")]
8470
          UNSPECV_CAS))
8471
   (set (reg:CCZ1 CC_REGNUM)
8472
        (compare:CCZ1 (match_dup 1) (match_dup 2)))]
8473
  ""
8474
  "cds\t%0,%3,%S1"
8475
  [(set_attr "op_type" "RS")
8476
   (set_attr "type"   "sem")])
8477
 
8478
; cs, csg
8479
(define_insn "*sync_compare_and_swap"
8480
  [(set (match_operand:GPR 0 "register_operand" "=r")
8481
        (match_operand:GPR 1 "memory_operand" "+Q"))
8482
   (set (match_dup 1)
8483
        (unspec_volatile:GPR
8484
          [(match_dup 1)
8485
           (match_operand:GPR 2 "register_operand" "0")
8486
           (match_operand:GPR 3 "register_operand" "r")]
8487
          UNSPECV_CAS))
8488
   (set (reg:CCZ1 CC_REGNUM)
8489
        (compare:CCZ1 (match_dup 1) (match_dup 2)))]
8490
  ""
8491
  "cs\t%0,%3,%S1"
8492
  [(set_attr "op_type" "RS")
8493
   (set_attr "type"   "sem")])
8494
 
8495
 
8496
;
8497
; Other atomic instruction patterns.
8498
;
8499
 
8500
(define_expand "sync_lock_test_and_set"
8501
  [(match_operand:HQI 0 "register_operand")
8502
   (match_operand:HQI 1 "memory_operand")
8503
   (match_operand:HQI 2 "general_operand")]
8504
  ""
8505
  "s390_expand_atomic (mode, SET, operands[0], operands[1],
8506
                       operands[2], false); DONE;")
8507
 
8508
(define_expand "sync_"
8509
  [(set (match_operand:HQI 0 "memory_operand")
8510
        (ATOMIC:HQI (match_dup 0)
8511
                    (match_operand:HQI 1 "general_operand")))]
8512
  ""
8513
  "s390_expand_atomic (mode, , NULL_RTX, operands[0],
8514
                       operands[1], false); DONE;")
8515
 
8516
(define_expand "sync_old_"
8517
  [(set (match_operand:HQI 0 "register_operand")
8518
        (match_operand:HQI 1 "memory_operand"))
8519
   (set (match_dup 1)
8520
        (ATOMIC:HQI (match_dup 1)
8521
                    (match_operand:HQI 2 "general_operand")))]
8522
  ""
8523
  "s390_expand_atomic (mode, , operands[0], operands[1],
8524
                       operands[2], false); DONE;")
8525
 
8526
(define_expand "sync_new_"
8527
  [(set (match_operand:HQI 0 "register_operand")
8528
        (ATOMIC:HQI (match_operand:HQI 1 "memory_operand")
8529
                    (match_operand:HQI 2 "general_operand")))
8530
   (set (match_dup 1) (ATOMIC:HQI (match_dup 1) (match_dup 2)))]
8531
  ""
8532
  "s390_expand_atomic (mode, , operands[0], operands[1],
8533
                       operands[2], true); DONE;")
8534
 
8535
;;
8536
;;- Miscellaneous instructions.
8537
;;
8538
 
8539
;
8540
; allocate stack instruction pattern(s).
8541
;
8542
 
8543
(define_expand "allocate_stack"
8544
  [(match_operand 0 "general_operand" "")
8545
   (match_operand 1 "general_operand" "")]
8546
 "TARGET_BACKCHAIN"
8547
{
8548
  rtx temp = gen_reg_rtx (Pmode);
8549
 
8550
  emit_move_insn (temp, s390_back_chain_rtx ());
8551
  anti_adjust_stack (operands[1]);
8552
  emit_move_insn (s390_back_chain_rtx (), temp);
8553
 
8554
  emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
8555
  DONE;
8556
})
8557
 
8558
 
8559
;
8560
; setjmp instruction pattern.
8561
;
8562
 
8563
(define_expand "builtin_setjmp_receiver"
8564
  [(match_operand 0 "" "")]
8565
  "flag_pic"
8566
{
8567
  emit_insn (s390_load_got ());
8568
  emit_use (pic_offset_table_rtx);
8569
  DONE;
8570
})
8571
 
8572
;; These patterns say how to save and restore the stack pointer.  We need not
8573
;; save the stack pointer at function level since we are careful to
8574
;; preserve the backchain.  At block level, we have to restore the backchain
8575
;; when we restore the stack pointer.
8576
;;
8577
;; For nonlocal gotos, we must save both the stack pointer and its
8578
;; backchain and restore both.  Note that in the nonlocal case, the
8579
;; save area is a memory location.
8580
 
8581
(define_expand "save_stack_function"
8582
  [(match_operand 0 "general_operand" "")
8583
   (match_operand 1 "general_operand" "")]
8584
  ""
8585
  "DONE;")
8586
 
8587
(define_expand "restore_stack_function"
8588
  [(match_operand 0 "general_operand" "")
8589
   (match_operand 1 "general_operand" "")]
8590
  ""
8591
  "DONE;")
8592
 
8593
(define_expand "restore_stack_block"
8594
  [(match_operand 0 "register_operand" "")
8595
   (match_operand 1 "register_operand" "")]
8596
  "TARGET_BACKCHAIN"
8597
{
8598
  rtx temp = gen_reg_rtx (Pmode);
8599
 
8600
  emit_move_insn (temp, s390_back_chain_rtx ());
8601
  emit_move_insn (operands[0], operands[1]);
8602
  emit_move_insn (s390_back_chain_rtx (), temp);
8603
 
8604
  DONE;
8605
})
8606
 
8607
(define_expand "save_stack_nonlocal"
8608
  [(match_operand 0 "memory_operand" "")
8609
   (match_operand 1 "register_operand" "")]
8610
  ""
8611
{
8612
  enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
8613
  rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
8614
 
8615
  /* Copy the backchain to the first word, sp to the second and the
8616
     literal pool base to the third.  */
8617
 
8618
  if (TARGET_BACKCHAIN)
8619
    {
8620
      rtx temp = force_reg (Pmode, s390_back_chain_rtx ());
8621
      emit_move_insn (operand_subword (operands[0], 0, 0, mode), temp);
8622
    }
8623
 
8624
  emit_move_insn (operand_subword (operands[0], 1, 0, mode), operands[1]);
8625
  emit_move_insn (operand_subword (operands[0], 2, 0, mode), base);
8626
 
8627
  DONE;
8628
})
8629
 
8630
(define_expand "restore_stack_nonlocal"
8631
  [(match_operand 0 "register_operand" "")
8632
   (match_operand 1 "memory_operand" "")]
8633
  ""
8634
{
8635
  enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
8636
  rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
8637
  rtx temp = NULL_RTX;
8638
 
8639
  /* Restore the backchain from the first word, sp from the second and the
8640
     literal pool base from the third.  */
8641
 
8642
  if (TARGET_BACKCHAIN)
8643
    temp = force_reg (Pmode, operand_subword (operands[1], 0, 0, mode));
8644
 
8645
  emit_move_insn (base, operand_subword (operands[1], 2, 0, mode));
8646
  emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, mode));
8647
 
8648
  if (temp)
8649
    emit_move_insn (s390_back_chain_rtx (), temp);
8650
 
8651
  emit_use (base);
8652
  DONE;
8653
})
8654
 
8655
(define_expand "exception_receiver"
8656
  [(const_int 0)]
8657
  ""
8658
{
8659
  s390_set_has_landing_pad_p (true);
8660
  DONE;
8661
})
8662
 
8663
;
8664
; nop instruction pattern(s).
8665
;
8666
 
8667
(define_insn "nop"
8668
  [(const_int 0)]
8669
  ""
8670
  "lr\t0,0"
8671
  [(set_attr "op_type" "RR")
8672
   (set_attr "z10prop"  "z10_fr_E1")])
8673
 
8674
(define_insn "nop1"
8675
  [(const_int 1)]
8676
  ""
8677
  "lr\t1,1"
8678
  [(set_attr "op_type" "RR")])
8679
 
8680
 
8681
;
8682
; Special literal pool access instruction pattern(s).
8683
;
8684
 
8685
(define_insn "*pool_entry"
8686
  [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
8687
                    UNSPECV_POOL_ENTRY)]
8688
  ""
8689
{
8690
  enum machine_mode mode = GET_MODE (PATTERN (insn));
8691
  unsigned int align = GET_MODE_BITSIZE (mode);
8692
  s390_output_pool_entry (operands[0], mode, align);
8693
  return "";
8694
}
8695
  [(set (attr "length")
8696
        (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
8697
 
8698
(define_insn "pool_align"
8699
  [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
8700
                    UNSPECV_POOL_ALIGN)]
8701
  ""
8702
  ".align\t%0"
8703
  [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
8704
 
8705
(define_insn "pool_section_start"
8706
  [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
8707
  ""
8708
  ".section\t.rodata"
8709
  [(set_attr "length" "0")])
8710
 
8711
(define_insn "pool_section_end"
8712
  [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
8713
  ""
8714
  ".previous"
8715
  [(set_attr "length" "0")])
8716
 
8717
(define_insn "main_base_31_small"
8718
  [(set (match_operand 0 "register_operand" "=a")
8719
        (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
8720
  "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8721
  "basr\t%0,0"
8722
  [(set_attr "op_type" "RR")
8723
   (set_attr "type"    "la")])
8724
 
8725
(define_insn "main_base_31_large"
8726
  [(set (match_operand 0 "register_operand" "=a")
8727
        (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
8728
   (set (pc) (label_ref (match_operand 2 "" "")))]
8729
  "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8730
  "bras\t%0,%2"
8731
  [(set_attr "op_type" "RI")])
8732
 
8733
(define_insn "main_base_64"
8734
  [(set (match_operand 0 "register_operand" "=a")
8735
        (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
8736
  "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8737
  "larl\t%0,%1"
8738
  [(set_attr "op_type" "RIL")
8739
   (set_attr "type"    "larl")
8740
   (set_attr "z10prop" "z10_fwd_A1")])
8741
 
8742
(define_insn "main_pool"
8743
  [(set (match_operand 0 "register_operand" "=a")
8744
        (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
8745
  "GET_MODE (operands[0]) == Pmode"
8746
{
8747
  gcc_unreachable ();
8748
}
8749
  [(set (attr "type")
8750
        (if_then_else (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
8751
                      (const_string "larl") (const_string "la")))])
8752
 
8753
(define_insn "reload_base_31"
8754
  [(set (match_operand 0 "register_operand" "=a")
8755
        (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
8756
  "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8757
  "basr\t%0,0\;la\t%0,%1-.(%0)"
8758
  [(set_attr "length" "6")
8759
   (set_attr "type" "la")])
8760
 
8761
(define_insn "reload_base_64"
8762
  [(set (match_operand 0 "register_operand" "=a")
8763
        (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
8764
  "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8765
  "larl\t%0,%1"
8766
  [(set_attr "op_type" "RIL")
8767
   (set_attr "type"    "larl")
8768
   (set_attr "z10prop" "z10_fwd_A1")])
8769
 
8770
(define_insn "pool"
8771
  [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
8772
  ""
8773
{
8774
  gcc_unreachable ();
8775
}
8776
  [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
8777
 
8778
;;
8779
;; Insns related to generating the function prologue and epilogue.
8780
;;
8781
 
8782
 
8783
(define_expand "prologue"
8784
  [(use (const_int 0))]
8785
  ""
8786
  "s390_emit_prologue (); DONE;")
8787
 
8788
(define_expand "epilogue"
8789
  [(use (const_int 1))]
8790
  ""
8791
  "s390_emit_epilogue (false); DONE;")
8792
 
8793
(define_expand "sibcall_epilogue"
8794
  [(use (const_int 0))]
8795
  ""
8796
  "s390_emit_epilogue (true); DONE;")
8797
 
8798
(define_insn "*return"
8799
  [(return)
8800
   (use (match_operand 0 "register_operand" "a"))]
8801
  "GET_MODE (operands[0]) == Pmode"
8802
  "br\t%0"
8803
  [(set_attr "op_type" "RR")
8804
   (set_attr "type"    "jsr")
8805
   (set_attr "atype"   "agen")])
8806
 
8807
 
8808
;; Instruction definition to extend a 31-bit pointer into a 64-bit
8809
;; pointer. This is used for compatibility.
8810
 
8811
(define_expand "ptr_extend"
8812
  [(set (match_operand:DI 0 "register_operand" "=r")
8813
        (match_operand:SI 1 "register_operand" "r"))]
8814
  "TARGET_64BIT"
8815
{
8816
  emit_insn (gen_anddi3 (operands[0],
8817
                         gen_lowpart (DImode, operands[1]),
8818
                         GEN_INT (0x7fffffff)));
8819
  DONE;
8820
})
8821
 
8822
;; Instruction definition to expand eh_return macro to support
8823
;; swapping in special linkage return addresses.
8824
 
8825
(define_expand "eh_return"
8826
  [(use (match_operand 0 "register_operand" ""))]
8827
  "TARGET_TPF"
8828
{
8829
  s390_emit_tpf_eh_return (operands[0]);
8830
  DONE;
8831
})
8832
 
8833
;
8834
; Stack Protector Patterns
8835
;
8836
 
8837
(define_expand "stack_protect_set"
8838
  [(set (match_operand 0 "memory_operand" "")
8839
        (match_operand 1 "memory_operand" ""))]
8840
  ""
8841
{
8842
#ifdef TARGET_THREAD_SSP_OFFSET
8843
  operands[1]
8844
    = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
8845
                                        GEN_INT (TARGET_THREAD_SSP_OFFSET)));
8846
#endif
8847
  if (TARGET_64BIT)
8848
    emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
8849
  else
8850
    emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
8851
 
8852
  DONE;
8853
})
8854
 
8855
(define_insn "stack_protect_set"
8856
  [(set (match_operand:DSI 0 "memory_operand" "=Q")
8857
        (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
8858
  ""
8859
  "mvc\t%O0(%G0,%R0),%S1"
8860
  [(set_attr "op_type" "SS")])
8861
 
8862
(define_expand "stack_protect_test"
8863
  [(set (reg:CC CC_REGNUM)
8864
        (compare (match_operand 0 "memory_operand" "")
8865
                 (match_operand 1 "memory_operand" "")))
8866
   (match_operand 2 "" "")]
8867
  ""
8868
{
8869
  rtx cc_reg, test;
8870
#ifdef TARGET_THREAD_SSP_OFFSET
8871
  operands[1]
8872
    = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
8873
                                        GEN_INT (TARGET_THREAD_SSP_OFFSET)));
8874
#endif
8875
  if (TARGET_64BIT)
8876
    emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
8877
  else
8878
    emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
8879
 
8880
  cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM);
8881
  test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx);
8882
  emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2]));
8883
  DONE;
8884
})
8885
 
8886
(define_insn "stack_protect_test"
8887
  [(set (reg:CCZ CC_REGNUM)
8888
        (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
8889
                     (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
8890
  ""
8891
  "clc\t%O0(%G0,%R0),%S1"
8892
  [(set_attr "op_type" "SS")])
8893
 
8894
; This is used in s390_emit_prologue in order to prevent insns
8895
; adjusting the stack pointer to be moved over insns writing stack
8896
; slots using a copy of the stack pointer in a different register.
8897
(define_insn "stack_tie"
8898
  [(set (match_operand:BLK 0 "memory_operand" "+m")
8899
        (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
8900
  ""
8901
  ""
8902
  [(set_attr "length" "0")])
8903
 
8904
 
8905
;
8906
; Data prefetch patterns
8907
;
8908
 
8909
(define_insn "prefetch"
8910
  [(prefetch (match_operand 0    "address_operand"   "ZQZRZSZT,X")
8911
             (match_operand:SI 1 "const_int_operand" "       n,n")
8912
             (match_operand:SI 2 "const_int_operand" "       n,n"))]
8913
  "TARGET_Z10"
8914
{
8915
  switch (which_alternative)
8916
    {
8917
      case 0:
8918
        return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
8919
      case 1:
8920
        if (larl_operand (operands[0], Pmode))
8921
          return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
8922
      default:
8923
 
8924
        /* This might be reached for symbolic operands with an odd
8925
           addend.  We simply omit the prefetch for such rare cases.  */
8926
 
8927
        return "";
8928
     }
8929
}
8930
  [(set_attr "type" "load,larl")
8931
   (set_attr "op_type" "RXY,RIL")
8932
   (set_attr "z10prop" "z10_super")])
8933
 
8934
 
8935
;
8936
; Byte swap instructions
8937
;
8938
 
8939
(define_insn "bswap2"
8940
  [(set (match_operand:GPR 0            "register_operand"     "=d, d")
8941
        (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,RT")))]
8942
  "TARGET_CPU_ZARCH"
8943
  "@
8944
   lrvr\t%0,%1
8945
   lrv\t%0,%1"
8946
  [(set_attr "type" "*,load")
8947
   (set_attr "op_type" "RRE,RXY")
8948
   (set_attr "z10prop" "z10_super")])

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.