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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [s390/] [s390.md] - Blame information for rev 709

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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