]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/s390/s390.md
S/390: Add support for arch<n> arch/tune options.
[thirdparty/gcc.git] / gcc / config / s390 / s390.md
CommitLineData
9db1d521 1;;- Machine description for GNU compiler -- S/390 / zSeries version.
818ab71a 2;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
9db1d521 3;; Contributed by Hartmut Penner (hpenner@de.ibm.com) and
963fc8d0
AK
4;; Ulrich Weigand (uweigand@de.ibm.com) and
5;; Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
9db1d521 6
58add37a
UW
7;; This file is part of GCC.
8
9;; GCC is free software; you can redistribute it and/or modify it under
10;; the terms of the GNU General Public License as published by the Free
2f83c7d6 11;; Software Foundation; either version 3, or (at your option) any later
58add37a
UW
12;; version.
13
14;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
16;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17;; for more details.
9db1d521
HP
18
19;; You should have received a copy of the GNU General Public License
2f83c7d6
NC
20;; along with GCC; see the file COPYING3. If not see
21;; <http://www.gnu.org/licenses/>.
9db1d521
HP
22
23;;
cd8dc1f9 24;; See constraints.md for a description of constraints specific to s390.
9db1d521 25;;
cd8dc1f9 26
9db1d521
HP
27;; Special formats used for outputting 390 instructions.
28;;
f19a9af7
AK
29;; %C: print opcode suffix for branch condition.
30;; %D: print opcode suffix for inverse branch condition.
31;; %J: print tls_load/tls_gdcall/tls_ldcall suffix
da48f5ec 32;; %G: print the size of the operand in bytes.
f19a9af7
AK
33;; %O: print only the displacement of a memory reference.
34;; %R: print only the base register of a memory reference.
fc0ea003 35;; %S: print S-type memory reference (base+displacement).
f19a9af7
AK
36;; %N: print the second word of a DImode operand.
37;; %M: print the second word of a TImode operand.
da48f5ec 38;; %Y: print shift count operand.
f4aa3848 39;;
f19a9af7 40;; %b: print integer X as if it's an unsigned byte.
963fc8d0 41;; %c: print integer X as if it's an signed byte.
da48f5ec
AK
42;; %x: print integer X as if it's an unsigned halfword.
43;; %h: print integer X as if it's a signed halfword.
44;; %i: print the first nonzero HImode part of X.
45;; %j: print the first HImode part unequal to -1 of X.
46;; %k: print the first nonzero SImode part of X.
47;; %m: print the first SImode part unequal to -1 of X.
48;; %o: print integer X as if it's an unsigned 32bit word.
9db1d521
HP
49;;
50;; We have a special constraint for pattern matching.
51;;
52;; s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
53;;
9db1d521 54
fd3cd001
UW
55;;
56;; UNSPEC usage
57;;
58
30a49b23
AK
59(define_c_enum "unspec" [
60 ; Miscellaneous
61 UNSPEC_ROUND
30a49b23
AK
62 UNSPEC_ICM
63 UNSPEC_TIE
10bbf137 64
5a3fe9b6
AK
65 ; Convert CC into a str comparison result and copy it into an
66 ; integer register
67 ; cc0->0, cc1->1, cc2->-1, (cc3->-1)
68 UNSPEC_STRCMPCC_TO_INT
69
70 ; Copy CC as is into the lower 2 bits of an integer register
71 UNSPEC_CC_TO_INT
72
da0dcab1
DV
73 ; The right hand side of an setmem
74 UNSPEC_REPLICATE_BYTE
75
10bbf137 76 ; GOT/PLT and lt-relative accesses
30a49b23
AK
77 UNSPEC_LTREL_OFFSET
78 UNSPEC_LTREL_BASE
79 UNSPEC_POOL_OFFSET
80 UNSPEC_GOTENT
81 UNSPEC_GOT
82 UNSPEC_GOTOFF
83 UNSPEC_PLT
84 UNSPEC_PLTOFF
fd7643fb
UW
85
86 ; Literal pool
30a49b23
AK
87 UNSPEC_RELOAD_BASE
88 UNSPEC_MAIN_BASE
89 UNSPEC_LTREF
90 UNSPEC_INSN
91 UNSPEC_EXECUTE
fd7643fb 92
1a8c13b3 93 ; Atomic Support
30a49b23 94 UNSPEC_MB
78ce265b 95 UNSPEC_MOVA
1a8c13b3 96
fd7643fb 97 ; TLS relocation specifiers
30a49b23
AK
98 UNSPEC_TLSGD
99 UNSPEC_TLSLDM
100 UNSPEC_NTPOFF
101 UNSPEC_DTPOFF
102 UNSPEC_GOTNTPOFF
103 UNSPEC_INDNTPOFF
fd3cd001
UW
104
105 ; TLS support
30a49b23
AK
106 UNSPEC_TLSLDM_NTPOFF
107 UNSPEC_TLS_LOAD
91d39d71
UW
108
109 ; String Functions
30a49b23
AK
110 UNSPEC_SRST
111 UNSPEC_MVST
638e37c2 112
7b8acc34 113 ; Stack Smashing Protector
30a49b23
AK
114 UNSPEC_SP_SET
115 UNSPEC_SP_TEST
85dae55a 116
4cb4721f
MK
117 ; Split stack support
118 UNSPEC_STACK_CHECK
119
638e37c2 120 ; Test Data Class (TDC)
30a49b23 121 UNSPEC_TDC_INSN
65b1d8ea
AK
122
123 ; Population Count
30a49b23
AK
124 UNSPEC_POPCNT
125 UNSPEC_COPYSIGN
d12a76f3
AK
126
127 ; Load FP Integer
128 UNSPEC_FPINT_FLOOR
129 UNSPEC_FPINT_BTRUNC
130 UNSPEC_FPINT_ROUND
131 UNSPEC_FPINT_CEIL
132 UNSPEC_FPINT_NEARBYINT
133 UNSPEC_FPINT_RINT
085261c8 134
3af82a61
AK
135 UNSPEC_LCBB
136
085261c8 137 ; Vector
3af82a61
AK
138 UNSPEC_VEC_SMULT_HI
139 UNSPEC_VEC_UMULT_HI
140 UNSPEC_VEC_SMULT_LO
085261c8
AK
141 UNSPEC_VEC_SMULT_EVEN
142 UNSPEC_VEC_UMULT_EVEN
143 UNSPEC_VEC_SMULT_ODD
144 UNSPEC_VEC_UMULT_ODD
3af82a61
AK
145
146 UNSPEC_VEC_VMAL
147 UNSPEC_VEC_VMAH
148 UNSPEC_VEC_VMALH
149 UNSPEC_VEC_VMAE
150 UNSPEC_VEC_VMALE
151 UNSPEC_VEC_VMAO
152 UNSPEC_VEC_VMALO
153
154 UNSPEC_VEC_GATHER
155 UNSPEC_VEC_EXTRACT
156 UNSPEC_VEC_INSERT_AND_ZERO
157 UNSPEC_VEC_LOAD_BNDRY
085261c8 158 UNSPEC_VEC_LOAD_LEN
3af82a61
AK
159 UNSPEC_VEC_MERGEH
160 UNSPEC_VEC_MERGEL
161 UNSPEC_VEC_PACK
162 UNSPEC_VEC_PACK_SATURATE
163 UNSPEC_VEC_PACK_SATURATE_CC
164 UNSPEC_VEC_PACK_SATURATE_GENCC
165 UNSPEC_VEC_PACK_UNSIGNED_SATURATE
166 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_CC
167 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_GENCC
168 UNSPEC_VEC_PERM
169 UNSPEC_VEC_PERMI
170 UNSPEC_VEC_EXTEND
171 UNSPEC_VEC_STORE_LEN
172 UNSPEC_VEC_UNPACKH
173 UNSPEC_VEC_UNPACKH_L
174 UNSPEC_VEC_UNPACKL
175 UNSPEC_VEC_UNPACKL_L
176 UNSPEC_VEC_ADDC
3af82a61
AK
177 UNSPEC_VEC_ADDE_U128
178 UNSPEC_VEC_ADDEC_U128
179 UNSPEC_VEC_AVG
180 UNSPEC_VEC_AVGU
181 UNSPEC_VEC_CHECKSUM
182 UNSPEC_VEC_GFMSUM
183 UNSPEC_VEC_GFMSUM_128
184 UNSPEC_VEC_GFMSUM_ACCUM
185 UNSPEC_VEC_GFMSUM_ACCUM_128
186 UNSPEC_VEC_SET
187
188 UNSPEC_VEC_VSUMG
189 UNSPEC_VEC_VSUMQ
190 UNSPEC_VEC_VSUM
191 UNSPEC_VEC_RL_MASK
192 UNSPEC_VEC_SLL
193 UNSPEC_VEC_SLB
194 UNSPEC_VEC_SLDB
195 UNSPEC_VEC_SRAL
196 UNSPEC_VEC_SRAB
197 UNSPEC_VEC_SRL
198 UNSPEC_VEC_SRLB
199
3af82a61 200 UNSPEC_VEC_SUBC
3af82a61
AK
201 UNSPEC_VEC_SUBE_U128
202 UNSPEC_VEC_SUBEC_U128
203
204 UNSPEC_VEC_TEST_MASK
205
206 UNSPEC_VEC_VFAE
207 UNSPEC_VEC_VFAECC
208
209 UNSPEC_VEC_VFEE
210 UNSPEC_VEC_VFEECC
085261c8
AK
211 UNSPEC_VEC_VFENE
212 UNSPEC_VEC_VFENECC
3af82a61
AK
213
214 UNSPEC_VEC_VISTR
215 UNSPEC_VEC_VISTRCC
216
217 UNSPEC_VEC_VSTRC
218 UNSPEC_VEC_VSTRCCC
219
220 UNSPEC_VEC_VCDGB
221 UNSPEC_VEC_VCDLGB
222
223 UNSPEC_VEC_VCGDB
224 UNSPEC_VEC_VCLGDB
225
226 UNSPEC_VEC_VFIDB
227
228 UNSPEC_VEC_VLDEB
229 UNSPEC_VEC_VLEDB
230
231 UNSPEC_VEC_VFTCIDB
232 UNSPEC_VEC_VFTCIDBCC
085261c8 233])
fd3cd001
UW
234
235;;
236;; UNSPEC_VOLATILE usage
237;;
238
30a49b23
AK
239(define_c_enum "unspecv" [
240 ; Blockage
241 UNSPECV_BLOCKAGE
10bbf137 242
2f7e5a0d 243 ; TPF Support
30a49b23
AK
244 UNSPECV_TPF_PROLOGUE
245 UNSPECV_TPF_EPILOGUE
2f7e5a0d 246
10bbf137 247 ; Literal pool
30a49b23
AK
248 UNSPECV_POOL
249 UNSPECV_POOL_SECTION
250 UNSPECV_POOL_ALIGN
251 UNSPECV_POOL_ENTRY
252 UNSPECV_MAIN_POOL
fd7643fb
UW
253
254 ; TLS support
30a49b23 255 UNSPECV_SET_TP
e0374221
AS
256
257 ; Atomic Support
30a49b23
AK
258 UNSPECV_CAS
259 UNSPECV_ATOMIC_OP
5a3fe9b6 260
f8af0e30
DV
261 ; Hotpatching (unremovable NOPs)
262 UNSPECV_NOP_2_BYTE
263 UNSPECV_NOP_4_BYTE
264 UNSPECV_NOP_6_BYTE
265
5a3fe9b6
AK
266 ; Transactional Execution support
267 UNSPECV_TBEGIN
2561451d 268 UNSPECV_TBEGIN_TDB
5a3fe9b6
AK
269 UNSPECV_TBEGINC
270 UNSPECV_TEND
271 UNSPECV_TABORT
272 UNSPECV_ETND
273 UNSPECV_NTSTG
274 UNSPECV_PPA
004f64e1
AK
275
276 ; Set and get floating point control register
277 UNSPECV_SFPC
278 UNSPECV_EFPC
4cb4721f
MK
279
280 ; Split stack support
281 UNSPECV_SPLIT_STACK_CALL
282 UNSPECV_SPLIT_STACK_DATA
fd3cd001
UW
283 ])
284
ae156f85
AS
285;;
286;; Registers
287;;
288
35dd9a0e
AK
289; Registers with special meaning
290
ae156f85
AS
291(define_constants
292 [
293 ; Sibling call register.
294 (SIBCALL_REGNUM 1)
295 ; Literal pool base register.
296 (BASE_REGNUM 13)
297 ; Return address register.
298 (RETURN_REGNUM 14)
82c6f58a
AK
299 ; Stack pointer register.
300 (STACK_REGNUM 15)
ae156f85
AS
301 ; Condition code register.
302 (CC_REGNUM 33)
f4aa3848 303 ; Thread local storage pointer register.
ae156f85
AS
304 (TP_REGNUM 36)
305 ])
306
35dd9a0e
AK
307; Hardware register names
308
309(define_constants
310 [
311 ; General purpose registers
312 (GPR0_REGNUM 0)
af344a30 313 (GPR1_REGNUM 1)
82379bdf
AK
314 (GPR2_REGNUM 2)
315 (GPR6_REGNUM 6)
35dd9a0e
AK
316 ; Floating point registers.
317 (FPR0_REGNUM 16)
2cf4c39e
AK
318 (FPR1_REGNUM 20)
319 (FPR2_REGNUM 17)
320 (FPR3_REGNUM 21)
321 (FPR4_REGNUM 18)
322 (FPR5_REGNUM 22)
323 (FPR6_REGNUM 19)
324 (FPR7_REGNUM 23)
325 (FPR8_REGNUM 24)
326 (FPR9_REGNUM 28)
327 (FPR10_REGNUM 25)
328 (FPR11_REGNUM 29)
329 (FPR12_REGNUM 26)
330 (FPR13_REGNUM 30)
331 (FPR14_REGNUM 27)
332 (FPR15_REGNUM 31)
085261c8
AK
333 (VR0_REGNUM 16)
334 (VR16_REGNUM 38)
335 (VR23_REGNUM 45)
336 (VR24_REGNUM 46)
337 (VR31_REGNUM 53)
35dd9a0e
AK
338 ])
339
ae8e301e
AK
340; Rounding modes for binary floating point numbers
341(define_constants
342 [(BFP_RND_CURRENT 0)
343 (BFP_RND_NEAREST_TIE_AWAY_FROM_0 1)
344 (BFP_RND_PREP_FOR_SHORT_PREC 3)
345 (BFP_RND_NEAREST_TIE_TO_EVEN 4)
346 (BFP_RND_TOWARD_0 5)
347 (BFP_RND_TOWARD_INF 6)
348 (BFP_RND_TOWARD_MINF 7)])
349
350; Rounding modes for decimal floating point numbers
351; 1-7 were introduced with the floating point extension facility
352; available with z196
353; With these rounding modes (1-7) a quantum exception might occur
354; which is suppressed for the other modes.
355(define_constants
356 [(DFP_RND_CURRENT 0)
357 (DFP_RND_NEAREST_TIE_AWAY_FROM_0_QUANTEXC 1)
358 (DFP_RND_CURRENT_QUANTEXC 2)
359 (DFP_RND_PREP_FOR_SHORT_PREC_QUANTEXC 3)
360 (DFP_RND_NEAREST_TIE_TO_EVEN_QUANTEXC 4)
361 (DFP_RND_TOWARD_0_QUANTEXC 5)
362 (DFP_RND_TOWARD_INF_QUANTEXC 6)
363 (DFP_RND_TOWARD_MINF_QUANTEXC 7)
364 (DFP_RND_NEAREST_TIE_TO_EVEN 8)
365 (DFP_RND_TOWARD_0 9)
366 (DFP_RND_TOWARD_INF 10)
367 (DFP_RND_TOWARD_MINF 11)
368 (DFP_RND_NEAREST_TIE_AWAY_FROM_0 12)
369 (DFP_RND_NEAREST_TIE_TO_0 13)
370 (DFP_RND_AWAY_FROM_0 14)
371 (DFP_RND_PREP_FOR_SHORT_PREC 15)])
372
35dd9a0e
AK
373;;
374;; PFPO GPR0 argument format
375;;
376
377(define_constants
378 [
379 ; PFPO operation type
380 (PFPO_CONVERT 0x1000000)
381 ; PFPO operand types
382 (PFPO_OP_TYPE_SF 0x5)
383 (PFPO_OP_TYPE_DF 0x6)
384 (PFPO_OP_TYPE_TF 0x7)
385 (PFPO_OP_TYPE_SD 0x8)
386 (PFPO_OP_TYPE_DD 0x9)
387 (PFPO_OP_TYPE_TD 0xa)
388 ; Bitposition of operand types
389 (PFPO_OP0_TYPE_SHIFT 16)
390 (PFPO_OP1_TYPE_SHIFT 8)
391 ])
392
5a3fe9b6
AK
393; Immediate operands for tbegin and tbeginc
394(define_constants [(TBEGIN_MASK 65292)]) ; 0xff0c
395(define_constants [(TBEGINC_MASK 65288)]) ; 0xff08
fd3cd001 396
29a74354
UW
397;; Instruction operand type as used in the Principles of Operation.
398;; Used to determine defaults for length and other attribute values.
1fec52be 399
29a74354 400(define_attr "op_type"
62d3f261 401 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,SIL,RRS,RIS,VRI,VRR,VRS,VRV,VRX"
b628bd8e 402 (const_string "NN"))
9db1d521 403
29a74354 404;; Instruction type attribute used for scheduling.
9db1d521 405
077dab3b 406(define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
e0374221 407 cs,vs,store,sem,idiv,
ed0e512a 408 imulhi,imulsi,imuldi,
2cdece44 409 branch,jsr,fsimptf,fsimpdf,fsimpsf,fhex,
f61a2c7d
AK
410 floadtf,floaddf,floadsf,fstoredf,fstoresf,
411 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
9381e3f1 412 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
65b1d8ea 413 fmadddf,fmaddsf,
9381e3f1
WG
414 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
415 itoftf, itofdf, itofsf, itofdd, itoftd,
416 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
417 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
418 ftoidfp, other"
29a74354
UW
419 (cond [(eq_attr "op_type" "NN") (const_string "other")
420 (eq_attr "op_type" "SS") (const_string "cs")]
421 (const_string "integer")))
9db1d521 422
29a74354
UW
423;; Another attribute used for scheduling purposes:
424;; agen: Instruction uses the address generation unit
425;; reg: Instruction does not use the agen unit
077dab3b
HP
426
427(define_attr "atype" "agen,reg"
62d3f261 428 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF")
0101708c
AS
429 (const_string "reg")
430 (const_string "agen")))
9db1d521 431
9381e3f1
WG
432;; Properties concerning Z10 execution grouping and value forwarding.
433;; z10_super: instruction is superscalar.
434;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
435;; z10_fwd: The instruction reads the value of an operand and stores it into a
436;; target register. It can forward this value to a second instruction that reads
437;; the same register if that second instruction is issued in the same group.
438;; z10_rec: The instruction is in the T pipeline and reads a register. If the
439;; instruction in the S pipe writes to the register, then the T instruction
440;; can immediately read the new value.
441;; z10_fr: union of Z10_fwd and z10_rec.
442;; z10_c: second operand of instruction is a register and read with complemented bits.
9381e3f1
WG
443;;
444;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
445
446
447(define_attr "z10prop" "none,
448 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
449 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
450 z10_rec,
451 z10_fr, z10_fr_A3, z10_fr_E1,
e3cba5e5 452 z10_c"
9381e3f1
WG
453 (const_string "none"))
454
65b1d8ea
AK
455;; Properties concerning Z196 decoding
456;; z196_alone: must group alone
457;; z196_end: ends a group
458;; z196_cracked: instruction is cracked or expanded
459(define_attr "z196prop" "none,
460 z196_alone, z196_ends,
461 z196_cracked"
462 (const_string "none"))
9381e3f1 463
a9cc3f58 464(define_attr "mnemonic" "bcr_flush,unknown" (const_string "unknown"))
22ac2c2f 465
9db1d521
HP
466;; Length in bytes.
467
468(define_attr "length" ""
62d3f261
AK
469 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
470 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF") (const_int 4)]
b628bd8e 471 (const_int 6)))
9db1d521 472
29a74354
UW
473
474;; Processor type. This attribute must exactly match the processor_type
475;; enumeration in s390.h. The current machine description does not
476;; distinguish between g5 and g6, but there are differences between the two
477;; CPUs could in theory be modeled.
478
55ac540c 479(define_attr "cpu" "g5,g6,z900,z990,z9_109,z9_ec,z10,z196,zEC12,z13"
90c6fd8a 480 (const (symbol_ref "s390_tune_attr")))
29a74354 481
b5e0425c 482(define_attr "cpu_facility"
bf749919 483 "standard,ieee,zarch,cpu_zarch,longdisp,extimm,dfp,z10,z196,zEC12,vec,z13"
3af8e996
AK
484 (const_string "standard"))
485
486(define_attr "enabled" ""
487 (cond [(eq_attr "cpu_facility" "standard")
488 (const_int 1)
489
490 (and (eq_attr "cpu_facility" "ieee")
d7f99b2c 491 (match_test "TARGET_CPU_IEEE_FLOAT"))
3af8e996
AK
492 (const_int 1)
493
494 (and (eq_attr "cpu_facility" "zarch")
d7f99b2c 495 (match_test "TARGET_ZARCH"))
3af8e996
AK
496 (const_int 1)
497
498 (and (eq_attr "cpu_facility" "longdisp")
d7f99b2c 499 (match_test "TARGET_LONG_DISPLACEMENT"))
3af8e996
AK
500 (const_int 1)
501
502 (and (eq_attr "cpu_facility" "extimm")
d7f99b2c 503 (match_test "TARGET_EXTIMM"))
3af8e996
AK
504 (const_int 1)
505
506 (and (eq_attr "cpu_facility" "dfp")
d7f99b2c 507 (match_test "TARGET_DFP"))
93538e8e
AK
508 (const_int 1)
509
b5e0425c
AK
510 (and (eq_attr "cpu_facility" "cpu_zarch")
511 (match_test "TARGET_CPU_ZARCH"))
512 (const_int 1)
513
93538e8e 514 (and (eq_attr "cpu_facility" "z10")
d7f99b2c 515 (match_test "TARGET_Z10"))
65b1d8ea
AK
516 (const_int 1)
517
518 (and (eq_attr "cpu_facility" "z196")
d7f99b2c 519 (match_test "TARGET_Z196"))
22ac2c2f
AK
520 (const_int 1)
521
522 (and (eq_attr "cpu_facility" "zEC12")
523 (match_test "TARGET_ZEC12"))
55ac540c
AK
524 (const_int 1)
525
526 (and (eq_attr "cpu_facility" "vec")
527 (match_test "TARGET_VX"))
bf749919
DV
528 (const_int 1)
529
530 (and (eq_attr "cpu_facility" "z13")
531 (match_test "TARGET_Z13"))
532 (const_int 1)
533 ]
3af8e996
AK
534 (const_int 0)))
535
29a74354
UW
536;; Pipeline description for z900. For lack of anything better,
537;; this description is also used for the g5 and g6.
538(include "2064.md")
539
3443392a 540;; Pipeline description for z990, z9-109 and z9-ec.
29a74354
UW
541(include "2084.md")
542
9381e3f1
WG
543;; Pipeline description for z10
544(include "2097.md")
545
65b1d8ea
AK
546;; Pipeline description for z196
547(include "2817.md")
548
22ac2c2f
AK
549;; Pipeline description for zEC12
550(include "2827.md")
551
23902021
AK
552;; Pipeline description for z13
553(include "2964.md")
554
0bfc3f69
AS
555;; Predicates
556(include "predicates.md")
557
cd8dc1f9
WG
558;; Constraint definitions
559(include "constraints.md")
560
a8ba31f2
EC
561;; Other includes
562(include "tpf.md")
f52c81dd 563
3abcb3a7 564;; Iterators
f52c81dd 565
085261c8
AK
566(define_mode_iterator ALL [TI DI SI HI QI TF DF SF TD DD SD V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI V2DI V1SF V2SF V4SF V1TI V1DF V2DF V1TF])
567
3abcb3a7 568;; These mode iterators allow floating point patterns to be generated from the
f5905b37 569;; same template.
f4aa3848 570(define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
0387c142 571 (SD "TARGET_HARD_DFP")])
3abcb3a7
HPN
572(define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
573(define_mode_iterator BFP [TF DF SF])
574(define_mode_iterator DFP [TD DD])
575(define_mode_iterator DFP_ALL [TD DD SD])
576(define_mode_iterator DSF [DF SF])
577(define_mode_iterator SD_SF [SF SD])
578(define_mode_iterator DD_DF [DF DD])
579(define_mode_iterator TD_TF [TF TD])
580
3abcb3a7 581;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
9db2f16d 582;; from the same template.
9602b6a1 583(define_mode_iterator GPR [(DI "TARGET_ZARCH") SI])
78ce265b 584(define_mode_iterator DGPR [(TI "TARGET_ZARCH") DI SI])
3abcb3a7 585(define_mode_iterator DSI [DI SI])
78ce265b 586(define_mode_iterator TDI [TI DI])
9db2f16d 587
3abcb3a7 588;; These mode iterators allow :P to be used for patterns that operate on
9db2f16d 589;; pointer-sized quantities. Exactly one of the two alternatives will match.
3abcb3a7 590(define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
9db2f16d 591
78ce265b
RH
592;; These macros refer to the actual word_mode of the configuration.
593;; This is equal to Pmode except on 31-bit machines in zarch mode.
9602b6a1
AK
594(define_mode_iterator DW [(TI "TARGET_ZARCH") (DI "!TARGET_ZARCH")])
595(define_mode_iterator W [(DI "TARGET_ZARCH") (SI "!TARGET_ZARCH")])
596
6e0d70c9
AK
597;; Used by the umul pattern to express modes having half the size.
598(define_mode_attr DWH [(TI "DI") (DI "SI")])
599(define_mode_attr dwh [(TI "di") (DI "si")])
600
3abcb3a7 601;; This mode iterator allows the QI and HI patterns to be defined from
f52c81dd 602;; the same template.
3abcb3a7 603(define_mode_iterator HQI [HI QI])
f52c81dd 604
3abcb3a7 605;; This mode iterator allows the integer patterns to be defined from the
342cf42b 606;; same template.
9602b6a1 607(define_mode_iterator INT [(DI "TARGET_ZARCH") SI HI QI])
78ce265b 608(define_mode_iterator DINT [(TI "TARGET_ZARCH") DI SI HI QI])
64c744b9 609(define_mode_iterator SINT [SI HI QI])
342cf42b 610
3abcb3a7 611;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
f337b930 612;; the same template.
3abcb3a7 613(define_code_iterator SHIFT [ashift lshiftrt])
f337b930 614
d12a76f3 615;; This iterator allows r[ox]sbg to be defined with the same template
571e408a
RH
616(define_code_iterator IXOR [ior xor])
617
d12a76f3
AK
618;; This iterator is used to expand the patterns for the nearest
619;; integer functions.
620(define_int_iterator FPINT [UNSPEC_FPINT_FLOOR UNSPEC_FPINT_BTRUNC
621 UNSPEC_FPINT_ROUND UNSPEC_FPINT_CEIL
622 UNSPEC_FPINT_NEARBYINT])
623(define_int_attr fpint_name [(UNSPEC_FPINT_FLOOR "floor")
624 (UNSPEC_FPINT_BTRUNC "btrunc")
625 (UNSPEC_FPINT_ROUND "round")
626 (UNSPEC_FPINT_CEIL "ceil")
627 (UNSPEC_FPINT_NEARBYINT "nearbyint")])
628(define_int_attr fpint_roundingmode [(UNSPEC_FPINT_FLOOR "7")
629 (UNSPEC_FPINT_BTRUNC "5")
630 (UNSPEC_FPINT_ROUND "1")
631 (UNSPEC_FPINT_CEIL "6")
632 (UNSPEC_FPINT_NEARBYINT "0")])
633
3abcb3a7
HPN
634;; This iterator and attribute allow to combine most atomic operations.
635(define_code_iterator ATOMIC [and ior xor plus minus mult])
65b1d8ea 636(define_code_iterator ATOMIC_Z196 [and ior xor plus])
cf5b43b0 637(define_code_attr atomic [(and "and") (ior "or") (xor "xor")
45d18331 638 (plus "add") (minus "sub") (mult "nand")])
65b1d8ea 639(define_code_attr noxa [(and "n") (ior "o") (xor "x") (plus "a")])
45d18331 640
f4aa3848 641;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
609e7e80
AK
642;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
643(define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
f337b930 644
f4aa3848
AK
645;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
646;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
609e7e80
AK
647;; SDmode.
648(define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
f5905b37 649
609e7e80 650;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
f61a2c7d
AK
651;; Likewise for "<RXe>".
652(define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
653(define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
654
609e7e80 655;; The decimal floating point variants of add, sub, div and mul support 3
3abcb3a7 656;; fp register operands. The following attributes allow to merge the bfp and
609e7e80
AK
657;; dfp variants in a single insn definition.
658
62d3f261
AK
659;; These mode attributes are supposed to be used in the `enabled' insn
660;; attribute to disable certain alternatives for certain modes.
661(define_mode_attr nBFP [(TF "0") (DF "0") (SF "0") (TD "*") (DD "*") (DD "*")])
662(define_mode_attr nDFP [(TF "*") (DF "*") (SF "*") (TD "0") (DD "0") (DD "0")])
663(define_mode_attr DSF [(TF "0") (DF "*") (SF "*") (TD "0") (DD "0") (SD "0")])
664(define_mode_attr DFDI [(TF "0") (DF "*") (SF "0")
665 (TD "0") (DD "0") (DD "0")
666 (TI "0") (DI "*") (SI "0")])
f5905b37 667
85dae55a
AK
668;; This attribute is used in the operand constraint list
669;; for instructions dealing with the sign bit of 32 or 64bit fp values.
670;; TFmode values are represented by a fp register pair. Since the
671;; sign bit instructions only handle single source and target fp registers
672;; these instructions can only be used for TFmode values if the source and
673;; target operand uses the same fp register.
674(define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
675
3abcb3a7 676;; This attribute adds b for bfp instructions and t for dfp instructions and is used
609e7e80
AK
677;; within instruction mnemonics.
678(define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
679
0387c142
WG
680;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
681;; modes and to an empty string for bfp modes.
682(define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
683
1b48c8cc
AS
684;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
685;; and "0" in SImode. This allows to combine instructions of which the 31bit
686;; version only operates on one register.
687(define_mode_attr d0 [(DI "d") (SI "0")])
688
689;; In combination with d0 this allows to combine instructions of which the 31bit
690;; version only operates on one register. The DImode version needs an additional
691;; register for the assembler output.
692(define_mode_attr 1 [(DI "%1,") (SI "")])
9381e3f1
WG
693
694;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
f337b930
AS
695;; 'ashift' and "srdl" in 'lshiftrt'.
696(define_code_attr lr [(ashift "l") (lshiftrt "r")])
697
698;; In SHIFT templates, this attribute holds the correct standard name for the
9381e3f1 699;; pattern itself and the corresponding function calls.
f337b930 700(define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
9a91a21f
AS
701
702;; This attribute handles differences in the instruction 'type' and will result
703;; in "RRE" for DImode and "RR" for SImode.
704(define_mode_attr E [(DI "E") (SI "")])
705
3298c037
AK
706;; This attribute handles differences in the instruction 'type' and makes RX<Y>
707;; to result in "RXY" for DImode and "RX" for SImode.
708(define_mode_attr Y [(DI "Y") (SI "")])
709
8006eaa6
AS
710;; This attribute handles differences in the instruction 'type' and will result
711;; in "RSE" for TImode and "RS" for DImode.
712(define_mode_attr TE [(TI "E") (DI "")])
713
9a91a21f
AS
714;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
715;; and "lcr" in SImode.
716(define_mode_attr g [(DI "g") (SI "")])
f52c81dd 717
3298c037
AK
718;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
719;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
720;; were enhanced with long displacements whereas 31bit instructions got a ..y
721;; variant for long displacements.
722(define_mode_attr y [(DI "g") (SI "y")])
723
9602b6a1 724;; In DW templates, a string like "cds<g>" will expand to "cdsg" in TImode
8006eaa6
AS
725;; and "cds" in DImode.
726(define_mode_attr tg [(TI "g") (DI "")])
727
78ce265b
RH
728;; In TDI templates, a string like "c<d>sg".
729(define_mode_attr td [(TI "d") (DI "")])
730
2f8f8434
AS
731;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
732;; and "cfdbr" in SImode.
733(define_mode_attr gf [(DI "g") (SI "f")])
734
65b1d8ea
AK
735;; In GPR templates, a string like sll<gk> will expand to sllg for DI
736;; and sllk for SI. This way it is possible to merge the new z196 SI
737;; 3 operands shift instructions into the existing patterns.
738(define_mode_attr gk [(DI "g") (SI "k")])
739
f52c81dd
AS
740;; ICM mask required to load MODE value into the lowest subreg
741;; of a SImode register.
742(define_mode_attr icm_lo [(HI "3") (QI "1")])
743
f6ee577c
AS
744;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
745;; HImode and "llgc" in QImode.
746(define_mode_attr hc [(HI "h") (QI "c")])
747
a1aed706
AS
748;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
749;; in SImode.
750(define_mode_attr DBL [(DI "TI") (SI "DI")])
751
609e7e80
AK
752;; This attribute expands to DF for TFmode and to DD for TDmode . It is
753;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
754(define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
755
f52c81dd
AS
756;; Maximum unsigned integer that fits in MODE.
757(define_mode_attr max_uint [(HI "65535") (QI "255")])
758
75ca1b39
RH
759;; Start and end field computations for RISBG et al.
760(define_mode_attr bfstart [(DI "s") (SI "t")])
761(define_mode_attr bfend [(DI "e") (SI "f")])
762
2542ef05
RH
763;; In place of GET_MODE_BITSIZE (<MODE>mode)
764(define_mode_attr bitsize [(DI "64") (SI "32") (HI "16") (QI "8")])
576987fc
DV
765;; 64 - bitsize
766(define_mode_attr bitoff [(DI "0") (SI "32") (HI "48") (QI "56")])
767(define_mode_attr bitoff_plus [(DI "") (SI "32+") (HI "48+") (QI "56+")])
2542ef05 768
da0dcab1
DV
769;; In place of GET_MODE_SIZE (<MODE>mode)
770(define_mode_attr modesize [(DI "8") (SI "4")])
771
177bc204
RS
772;; Allow return and simple_return to be defined from a single template.
773(define_code_iterator ANY_RETURN [return simple_return])
774
6e5b5de8
AK
775
776
777; Condition code modes generated by vector fp comparisons. These will
778; be used also in single element mode.
779(define_mode_iterator VFCMP [CCVEQ CCVFH CCVFHE])
780; Used with VFCMP to expand part of the mnemonic
781; For fp we have a mismatch: eq in the insn name - e in asm
782(define_mode_attr asm_fcmp [(CCVEQ "e") (CCVFH "h") (CCVFHE "he")])
3af82a61 783(define_mode_attr insn_cmp [(CCVEQ "eq") (CCVH "h") (CCVHU "hl") (CCVFH "h") (CCVFHE "he")])
6e5b5de8 784
191eb16d
AK
785;; Subst pattern definitions
786(include "subst.md")
6e5b5de8 787
085261c8
AK
788(include "vector.md")
789
9db1d521
HP
790;;
791;;- Compare instructions.
792;;
793
07893d4f 794; Test-under-Mask instructions
9db1d521 795
07893d4f 796(define_insn "*tmqi_mem"
ae156f85 797 [(set (reg CC_REGNUM)
68f9c5e2
UW
798 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
799 (match_operand:QI 1 "immediate_operand" "n,n"))
800 (match_operand:QI 2 "immediate_operand" "n,n")))]
3ed99cc9 801 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
d3632d41 802 "@
fc0ea003
UW
803 tm\t%S0,%b1
804 tmy\t%S0,%b1"
9381e3f1 805 [(set_attr "op_type" "SI,SIY")
3e4be43f 806 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 807 (set_attr "z10prop" "z10_super,z10_super")])
9db1d521 808
05b9aaaa 809(define_insn "*tmdi_reg"
ae156f85 810 [(set (reg CC_REGNUM)
f19a9af7 811 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
2f7e5a0d 812 (match_operand:DI 1 "immediate_operand"
f19a9af7
AK
813 "N0HD0,N1HD0,N2HD0,N3HD0"))
814 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
9602b6a1 815 "TARGET_ZARCH
3ed99cc9 816 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
f19a9af7
AK
817 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
818 "@
819 tmhh\t%0,%i1
820 tmhl\t%0,%i1
821 tmlh\t%0,%i1
822 tmll\t%0,%i1"
9381e3f1
WG
823 [(set_attr "op_type" "RI")
824 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
05b9aaaa
UW
825
826(define_insn "*tmsi_reg"
ae156f85 827 [(set (reg CC_REGNUM)
f19a9af7
AK
828 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
829 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
830 (match_operand:SI 2 "immediate_operand" "n,n")))]
3ed99cc9 831 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
f19a9af7
AK
832 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
833 "@
834 tmh\t%0,%i1
835 tml\t%0,%i1"
729e750f
WG
836 [(set_attr "op_type" "RI")
837 (set_attr "z10prop" "z10_super,z10_super")])
05b9aaaa 838
f52c81dd 839(define_insn "*tm<mode>_full"
ae156f85 840 [(set (reg CC_REGNUM)
f52c81dd
AS
841 (compare (match_operand:HQI 0 "register_operand" "d")
842 (match_operand:HQI 1 "immediate_operand" "n")))]
3ed99cc9 843 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
f52c81dd 844 "tml\t%0,<max_uint>"
729e750f
WG
845 [(set_attr "op_type" "RI")
846 (set_attr "z10prop" "z10_super")])
9db1d521 847
07893d4f 848
08a5aaa2 849;
07893d4f 850; Load-and-Test instructions
08a5aaa2
AS
851;
852
c0220ea4 853; tst(di|si) instruction pattern(s).
07893d4f
UW
854
855(define_insn "*tstdi_sign"
ae156f85 856 [(set (reg CC_REGNUM)
963fc8d0
AK
857 (compare
858 (ashiftrt:DI
859 (ashift:DI
3e4be43f 860 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,T") 0)
963fc8d0
AK
861 (const_int 32)) (const_int 32))
862 (match_operand:DI 1 "const0_operand" "")))
863 (set (match_operand:DI 2 "register_operand" "=d,d")
07893d4f 864 (sign_extend:DI (match_dup 0)))]
9602b6a1 865 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH"
963fc8d0
AK
866 "ltgfr\t%2,%0
867 ltgf\t%2,%0"
868 [(set_attr "op_type" "RRE,RXY")
9381e3f1
WG
869 (set_attr "cpu_facility" "*,z10")
870 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
07893d4f 871
43a09b63 872; ltr, lt, ltgr, ltg
08a5aaa2 873(define_insn "*tst<mode>_extimm"
ec24698e 874 [(set (reg CC_REGNUM)
3e4be43f 875 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,T")
08a5aaa2
AS
876 (match_operand:GPR 1 "const0_operand" "")))
877 (set (match_operand:GPR 2 "register_operand" "=d,d")
ec24698e 878 (match_dup 0))]
08a5aaa2 879 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
ec24698e 880 "@
08a5aaa2
AS
881 lt<g>r\t%2,%0
882 lt<g>\t%2,%0"
9381e3f1 883 [(set_attr "op_type" "RR<E>,RXY")
729e750f 884 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
ec24698e 885
43a09b63 886; ltr, lt, ltgr, ltg
08a5aaa2 887(define_insn "*tst<mode>_cconly_extimm"
ec24698e 888 [(set (reg CC_REGNUM)
3e4be43f 889 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,T")
08a5aaa2
AS
890 (match_operand:GPR 1 "const0_operand" "")))
891 (clobber (match_scratch:GPR 2 "=X,d"))]
892 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
ec24698e 893 "@
08a5aaa2
AS
894 lt<g>r\t%0,%0
895 lt<g>\t%2,%0"
9381e3f1 896 [(set_attr "op_type" "RR<E>,RXY")
729e750f 897 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
ec24698e 898
07893d4f 899(define_insn "*tstdi"
ae156f85 900 [(set (reg CC_REGNUM)
07893d4f
UW
901 (compare (match_operand:DI 0 "register_operand" "d")
902 (match_operand:DI 1 "const0_operand" "")))
903 (set (match_operand:DI 2 "register_operand" "=d")
904 (match_dup 0))]
9602b6a1 905 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH && !TARGET_EXTIMM"
d40c829f 906 "ltgr\t%2,%0"
9381e3f1
WG
907 [(set_attr "op_type" "RRE")
908 (set_attr "z10prop" "z10_fr_E1")])
9db1d521 909
07893d4f 910(define_insn "*tstsi"
ae156f85 911 [(set (reg CC_REGNUM)
d3632d41 912 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
07893d4f 913 (match_operand:SI 1 "const0_operand" "")))
d3632d41 914 (set (match_operand:SI 2 "register_operand" "=d,d,d")
07893d4f 915 (match_dup 0))]
ec24698e 916 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
07893d4f 917 "@
d40c829f 918 ltr\t%2,%0
fc0ea003
UW
919 icm\t%2,15,%S0
920 icmy\t%2,15,%S0"
9381e3f1 921 [(set_attr "op_type" "RR,RS,RSY")
3e4be43f 922 (set_attr "cpu_facility" "*,*,longdisp")
9381e3f1 923 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
9db1d521 924
07893d4f 925(define_insn "*tstsi_cconly"
ae156f85 926 [(set (reg CC_REGNUM)
d3632d41 927 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
07893d4f 928 (match_operand:SI 1 "const0_operand" "")))
d3632d41 929 (clobber (match_scratch:SI 2 "=X,d,d"))]
07893d4f
UW
930 "s390_match_ccmode(insn, CCSmode)"
931 "@
d40c829f 932 ltr\t%0,%0
fc0ea003
UW
933 icm\t%2,15,%S0
934 icmy\t%2,15,%S0"
9381e3f1 935 [(set_attr "op_type" "RR,RS,RSY")
3e4be43f 936 (set_attr "cpu_facility" "*,*,longdisp")
9381e3f1 937 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
4023fb28 938
08a5aaa2
AS
939(define_insn "*tstdi_cconly_31"
940 [(set (reg CC_REGNUM)
941 (compare (match_operand:DI 0 "register_operand" "d")
942 (match_operand:DI 1 "const0_operand" "")))]
9602b6a1 943 "s390_match_ccmode(insn, CCSmode) && !TARGET_ZARCH"
08a5aaa2
AS
944 "srda\t%0,0"
945 [(set_attr "op_type" "RS")
946 (set_attr "atype" "reg")])
947
43a09b63 948; ltr, ltgr
08a5aaa2 949(define_insn "*tst<mode>_cconly2"
ae156f85 950 [(set (reg CC_REGNUM)
08a5aaa2
AS
951 (compare (match_operand:GPR 0 "register_operand" "d")
952 (match_operand:GPR 1 "const0_operand" "")))]
07893d4f 953 "s390_match_ccmode(insn, CCSmode)"
08a5aaa2 954 "lt<g>r\t%0,%0"
9381e3f1
WG
955 [(set_attr "op_type" "RR<E>")
956 (set_attr "z10prop" "z10_fr_E1")])
08a5aaa2 957
c0220ea4 958; tst(hi|qi) instruction pattern(s).
4023fb28 959
f52c81dd 960(define_insn "*tst<mode>CCT"
ae156f85 961 [(set (reg CC_REGNUM)
f52c81dd
AS
962 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
963 (match_operand:HQI 1 "const0_operand" "")))
964 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
3af97654
UW
965 (match_dup 0))]
966 "s390_match_ccmode(insn, CCTmode)"
967 "@
f52c81dd
AS
968 icm\t%2,<icm_lo>,%S0
969 icmy\t%2,<icm_lo>,%S0
970 tml\t%0,<max_uint>"
9381e3f1 971 [(set_attr "op_type" "RS,RSY,RI")
3e4be43f 972 (set_attr "cpu_facility" "*,longdisp,*")
9381e3f1 973 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
3af97654
UW
974
975(define_insn "*tsthiCCT_cconly"
ae156f85 976 [(set (reg CC_REGNUM)
d3632d41 977 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
3af97654 978 (match_operand:HI 1 "const0_operand" "")))
d3632d41 979 (clobber (match_scratch:HI 2 "=d,d,X"))]
3af97654
UW
980 "s390_match_ccmode(insn, CCTmode)"
981 "@
fc0ea003
UW
982 icm\t%2,3,%S0
983 icmy\t%2,3,%S0
d40c829f 984 tml\t%0,65535"
9381e3f1 985 [(set_attr "op_type" "RS,RSY,RI")
3e4be43f 986 (set_attr "cpu_facility" "*,longdisp,*")
9381e3f1 987 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
3af97654 988
3af97654 989(define_insn "*tstqiCCT_cconly"
ae156f85 990 [(set (reg CC_REGNUM)
d3632d41 991 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
3af97654
UW
992 (match_operand:QI 1 "const0_operand" "")))]
993 "s390_match_ccmode(insn, CCTmode)"
994 "@
fc0ea003
UW
995 cli\t%S0,0
996 cliy\t%S0,0
d40c829f 997 tml\t%0,255"
9381e3f1 998 [(set_attr "op_type" "SI,SIY,RI")
3e4be43f 999 (set_attr "cpu_facility" "*,longdisp,*")
729e750f 1000 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
3af97654 1001
f52c81dd 1002(define_insn "*tst<mode>"
ae156f85 1003 [(set (reg CC_REGNUM)
f52c81dd
AS
1004 (compare (match_operand:HQI 0 "s_operand" "Q,S")
1005 (match_operand:HQI 1 "const0_operand" "")))
1006 (set (match_operand:HQI 2 "register_operand" "=d,d")
07893d4f
UW
1007 (match_dup 0))]
1008 "s390_match_ccmode(insn, CCSmode)"
d3632d41 1009 "@
f52c81dd
AS
1010 icm\t%2,<icm_lo>,%S0
1011 icmy\t%2,<icm_lo>,%S0"
9381e3f1 1012 [(set_attr "op_type" "RS,RSY")
3e4be43f 1013 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 1014 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521 1015
f52c81dd 1016(define_insn "*tst<mode>_cconly"
ae156f85 1017 [(set (reg CC_REGNUM)
f52c81dd
AS
1018 (compare (match_operand:HQI 0 "s_operand" "Q,S")
1019 (match_operand:HQI 1 "const0_operand" "")))
1020 (clobber (match_scratch:HQI 2 "=d,d"))]
07893d4f 1021 "s390_match_ccmode(insn, CCSmode)"
d3632d41 1022 "@
f52c81dd
AS
1023 icm\t%2,<icm_lo>,%S0
1024 icmy\t%2,<icm_lo>,%S0"
9381e3f1 1025 [(set_attr "op_type" "RS,RSY")
3e4be43f 1026 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 1027 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
d3632d41 1028
9db1d521 1029
575f7c2b
UW
1030; Compare (equality) instructions
1031
1032(define_insn "*cmpdi_cct"
ae156f85 1033 [(set (reg CC_REGNUM)
ec24698e 1034 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
3e4be43f 1035 (match_operand:DI 1 "general_operand" "d,K,Os,T,BQ")))]
9602b6a1 1036 "s390_match_ccmode (insn, CCTmode) && TARGET_ZARCH"
575f7c2b
UW
1037 "@
1038 cgr\t%0,%1
f4f41b4e 1039 cghi\t%0,%h1
ec24698e 1040 cgfi\t%0,%1
575f7c2b 1041 cg\t%0,%1
19b63d8e 1042 #"
9381e3f1
WG
1043 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
1044 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
575f7c2b
UW
1045
1046(define_insn "*cmpsi_cct"
ae156f85 1047 [(set (reg CC_REGNUM)
ec24698e
UW
1048 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
1049 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
e221ef54 1050 "s390_match_ccmode (insn, CCTmode)"
575f7c2b
UW
1051 "@
1052 cr\t%0,%1
f4f41b4e 1053 chi\t%0,%h1
ec24698e 1054 cfi\t%0,%1
575f7c2b
UW
1055 c\t%0,%1
1056 cy\t%0,%1
19b63d8e 1057 #"
9381e3f1 1058 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
3e4be43f 1059 (set_attr "cpu_facility" "*,*,*,*,longdisp,*")
e3cba5e5 1060 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*")])
575f7c2b 1061
07893d4f 1062; Compare (signed) instructions
4023fb28 1063
07893d4f 1064(define_insn "*cmpdi_ccs_sign"
ae156f85 1065 [(set (reg CC_REGNUM)
963fc8d0 1066 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
3e4be43f 1067 "d,T,b"))
963fc8d0 1068 (match_operand:DI 0 "register_operand" "d, d,d")))]
9602b6a1 1069 "s390_match_ccmode(insn, CCSRmode) && TARGET_ZARCH"
4023fb28 1070 "@
d40c829f 1071 cgfr\t%0,%1
963fc8d0
AK
1072 cgf\t%0,%1
1073 cgfrl\t%0,%1"
1074 [(set_attr "op_type" "RRE,RXY,RIL")
9381e3f1 1075 (set_attr "z10prop" "z10_c,*,*")
963fc8d0 1076 (set_attr "type" "*,*,larl")])
4023fb28 1077
9381e3f1
WG
1078
1079
07893d4f 1080(define_insn "*cmpsi_ccs_sign"
ae156f85 1081 [(set (reg CC_REGNUM)
963fc8d0
AK
1082 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
1083 (match_operand:SI 0 "register_operand" "d,d,d")))]
07893d4f 1084 "s390_match_ccmode(insn, CCSRmode)"
d3632d41 1085 "@
d40c829f 1086 ch\t%0,%1
963fc8d0
AK
1087 chy\t%0,%1
1088 chrl\t%0,%1"
1089 [(set_attr "op_type" "RX,RXY,RIL")
3e4be43f 1090 (set_attr "cpu_facility" "*,longdisp,z10")
65b1d8ea
AK
1091 (set_attr "type" "*,*,larl")
1092 (set_attr "z196prop" "z196_cracked,z196_cracked,z196_cracked")])
963fc8d0
AK
1093
1094(define_insn "*cmphi_ccs_z10"
1095 [(set (reg CC_REGNUM)
1096 (compare (match_operand:HI 0 "s_operand" "Q")
1097 (match_operand:HI 1 "immediate_operand" "K")))]
1098 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
1099 "chhsi\t%0,%1"
65b1d8ea
AK
1100 [(set_attr "op_type" "SIL")
1101 (set_attr "z196prop" "z196_cracked")])
963fc8d0
AK
1102
1103(define_insn "*cmpdi_ccs_signhi_rl"
1104 [(set (reg CC_REGNUM)
3e4be43f 1105 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "T,b"))
963fc8d0
AK
1106 (match_operand:GPR 0 "register_operand" "d,d")))]
1107 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
1108 "@
1109 cgh\t%0,%1
1110 cghrl\t%0,%1"
1111 [(set_attr "op_type" "RXY,RIL")
1112 (set_attr "type" "*,larl")])
4023fb28 1113
963fc8d0 1114; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
3298c037 1115(define_insn "*cmp<mode>_ccs"
ae156f85 1116 [(set (reg CC_REGNUM)
963fc8d0
AK
1117 (compare (match_operand:GPR 0 "nonimmediate_operand"
1118 "d,d,Q, d,d,d,d")
1119 (match_operand:GPR 1 "general_operand"
1120 "d,K,K,Os,R,T,b")))]
9db1d521 1121 "s390_match_ccmode(insn, CCSmode)"
07893d4f 1122 "@
3298c037
AK
1123 c<g>r\t%0,%1
1124 c<g>hi\t%0,%h1
963fc8d0 1125 c<g>hsi\t%0,%h1
3298c037
AK
1126 c<g>fi\t%0,%1
1127 c<g>\t%0,%1
963fc8d0
AK
1128 c<y>\t%0,%1
1129 c<g>rl\t%0,%1"
1130 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
3e4be43f 1131 (set_attr "cpu_facility" "*,*,z10,extimm,*,longdisp,z10")
9381e3f1
WG
1132 (set_attr "type" "*,*,*,*,*,*,larl")
1133 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
c7453384 1134
07893d4f
UW
1135
1136; Compare (unsigned) instructions
9db1d521 1137
963fc8d0
AK
1138(define_insn "*cmpsi_ccu_zerohi_rlsi"
1139 [(set (reg CC_REGNUM)
1140 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
1141 "larl_operand" "X")))
1142 (match_operand:SI 0 "register_operand" "d")))]
1143 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
1144 "clhrl\t%0,%1"
1145 [(set_attr "op_type" "RIL")
729e750f
WG
1146 (set_attr "type" "larl")
1147 (set_attr "z10prop" "z10_super")])
963fc8d0
AK
1148
1149; clhrl, clghrl
1150(define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
1151 [(set (reg CC_REGNUM)
1152 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
1153 "larl_operand" "X")))
1154 (match_operand:GPR 0 "register_operand" "d")))]
1155 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
1156 "cl<g>hrl\t%0,%1"
1157 [(set_attr "op_type" "RIL")
9381e3f1
WG
1158 (set_attr "type" "larl")
1159 (set_attr "z10prop" "z10_super")])
963fc8d0 1160
07893d4f 1161(define_insn "*cmpdi_ccu_zero"
ae156f85 1162 [(set (reg CC_REGNUM)
963fc8d0 1163 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
3e4be43f
UW
1164 "d,T,b"))
1165 (match_operand:DI 0 "register_operand" "d,d,d")))]
9602b6a1 1166 "s390_match_ccmode (insn, CCURmode) && TARGET_ZARCH"
07893d4f 1167 "@
d40c829f 1168 clgfr\t%0,%1
963fc8d0
AK
1169 clgf\t%0,%1
1170 clgfrl\t%0,%1"
1171 [(set_attr "op_type" "RRE,RXY,RIL")
1172 (set_attr "cpu_facility" "*,*,z10")
9381e3f1
WG
1173 (set_attr "type" "*,*,larl")
1174 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
9db1d521 1175
07893d4f 1176(define_insn "*cmpdi_ccu"
ae156f85 1177 [(set (reg CC_REGNUM)
963fc8d0 1178 (compare (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 1179 "d, d,d,Q,d, Q,BQ")
963fc8d0 1180 (match_operand:DI 1 "general_operand"
3e4be43f 1181 "d,Op,b,D,T,BQ,Q")))]
9602b6a1 1182 "s390_match_ccmode (insn, CCUmode) && TARGET_ZARCH"
07893d4f 1183 "@
d40c829f 1184 clgr\t%0,%1
ec24698e 1185 clgfi\t%0,%1
963fc8d0
AK
1186 clgrl\t%0,%1
1187 clghsi\t%0,%x1
575f7c2b 1188 clg\t%0,%1
e221ef54 1189 #
19b63d8e 1190 #"
963fc8d0
AK
1191 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
1192 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
9381e3f1
WG
1193 (set_attr "type" "*,*,larl,*,*,*,*")
1194 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
9db1d521 1195
07893d4f 1196(define_insn "*cmpsi_ccu"
ae156f85 1197 [(set (reg CC_REGNUM)
963fc8d0
AK
1198 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
1199 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
e221ef54 1200 "s390_match_ccmode (insn, CCUmode)"
07893d4f 1201 "@
d40c829f 1202 clr\t%0,%1
ec24698e 1203 clfi\t%0,%o1
963fc8d0
AK
1204 clrl\t%0,%1
1205 clfhsi\t%0,%x1
d40c829f 1206 cl\t%0,%1
575f7c2b 1207 cly\t%0,%1
e221ef54 1208 #
19b63d8e 1209 #"
963fc8d0 1210 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
3e4be43f 1211 (set_attr "cpu_facility" "*,extimm,z10,z10,*,longdisp,*,*")
9381e3f1
WG
1212 (set_attr "type" "*,*,larl,*,*,*,*,*")
1213 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
9db1d521 1214
07893d4f 1215(define_insn "*cmphi_ccu"
ae156f85 1216 [(set (reg CC_REGNUM)
963fc8d0
AK
1217 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
1218 (match_operand:HI 1 "general_operand" "Q,S,D,BQ,Q")))]
575f7c2b 1219 "s390_match_ccmode (insn, CCUmode)
575f7c2b 1220 && !register_operand (operands[1], HImode)"
d3632d41 1221 "@
fc0ea003
UW
1222 clm\t%0,3,%S1
1223 clmy\t%0,3,%S1
963fc8d0 1224 clhhsi\t%0,%1
e221ef54 1225 #
19b63d8e 1226 #"
963fc8d0 1227 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
3e4be43f 1228 (set_attr "cpu_facility" "*,longdisp,z10,*,*")
9381e3f1 1229 (set_attr "z10prop" "*,*,z10_super,*,*")])
9db1d521
HP
1230
1231(define_insn "*cmpqi_ccu"
ae156f85 1232 [(set (reg CC_REGNUM)
e221ef54
UW
1233 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
1234 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
575f7c2b 1235 "s390_match_ccmode (insn, CCUmode)
575f7c2b 1236 && !register_operand (operands[1], QImode)"
d3632d41 1237 "@
fc0ea003
UW
1238 clm\t%0,1,%S1
1239 clmy\t%0,1,%S1
1240 cli\t%S0,%b1
1241 cliy\t%S0,%b1
e221ef54 1242 #
19b63d8e 1243 #"
9381e3f1 1244 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
3e4be43f 1245 (set_attr "cpu_facility" "*,longdisp,*,longdisp,*,*")
9381e3f1 1246 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
9db1d521
HP
1247
1248
19b63d8e
UW
1249; Block compare (CLC) instruction patterns.
1250
1251(define_insn "*clc"
ae156f85 1252 [(set (reg CC_REGNUM)
d4f52f0e 1253 (compare (match_operand:BLK 0 "memory_operand" "Q")
19b63d8e
UW
1254 (match_operand:BLK 1 "memory_operand" "Q")))
1255 (use (match_operand 2 "const_int_operand" "n"))]
1256 "s390_match_ccmode (insn, CCUmode)
1257 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 1258 "clc\t%O0(%2,%R0),%S1"
b628bd8e 1259 [(set_attr "op_type" "SS")])
19b63d8e
UW
1260
1261(define_split
ae156f85 1262 [(set (reg CC_REGNUM)
19b63d8e
UW
1263 (compare (match_operand 0 "memory_operand" "")
1264 (match_operand 1 "memory_operand" "")))]
1265 "reload_completed
1266 && s390_match_ccmode (insn, CCUmode)
1267 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1268 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1269 [(parallel
1270 [(set (match_dup 0) (match_dup 1))
1271 (use (match_dup 2))])]
1272{
1273 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1274 operands[0] = adjust_address (operands[0], BLKmode, 0);
1275 operands[1] = adjust_address (operands[1], BLKmode, 0);
1276
1277 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
1278 operands[0], operands[1]);
1279 operands[0] = SET_DEST (PATTERN (curr_insn));
1280})
1281
1282
609e7e80 1283; (TF|DF|SF|TD|DD|SD) instructions
9db1d521 1284
609e7e80 1285; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
f5905b37 1286(define_insn "*cmp<mode>_ccs_0"
ae156f85 1287 [(set (reg CC_REGNUM)
609e7e80
AK
1288 (compare (match_operand:FP 0 "register_operand" "f")
1289 (match_operand:FP 1 "const0_operand" "")))]
142cd70f 1290 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
609e7e80 1291 "lt<xde><bt>r\t%0,%0"
077dab3b 1292 [(set_attr "op_type" "RRE")
9381e3f1 1293 (set_attr "type" "fsimp<mode>")])
9db1d521 1294
be5de7a1 1295; cxtr, cxbr, cdtr, cdbr, cebr, cdb, ceb
f5905b37 1296(define_insn "*cmp<mode>_ccs"
ae156f85 1297 [(set (reg CC_REGNUM)
609e7e80 1298 (compare (match_operand:FP 0 "register_operand" "f,f")
62d3f261 1299 (match_operand:FP 1 "general_operand" "f,R")))]
142cd70f 1300 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
9db1d521 1301 "@
609e7e80 1302 c<xde><bt>r\t%0,%1
f61a2c7d 1303 c<xde>b\t%0,%1"
077dab3b 1304 [(set_attr "op_type" "RRE,RXE")
62d3f261
AK
1305 (set_attr "type" "fsimp<mode>")
1306 (set_attr "enabled" "*,<DSF>")])
9db1d521 1307
6e5b5de8
AK
1308; wfcedbs, wfchdbs, wfchedbs
1309(define_insn "*vec_cmp<insn_cmp>df_cconly"
1310 [(set (reg:VFCMP CC_REGNUM)
1311 (compare:VFCMP (match_operand:DF 0 "register_operand" "v")
1312 (match_operand:DF 1 "register_operand" "v")))
1313 (clobber (match_scratch:V2DI 2 "=v"))]
a579871b 1314 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
1315 "wfc<asm_fcmp>dbs\t%v2,%v0,%v1"
1316 [(set_attr "op_type" "VRR")])
963fc8d0
AK
1317
1318; Compare and Branch instructions
1319
1320; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
9381e3f1
WG
1321; The following instructions do a complementary access of their second
1322; operand (z01 only): crj_c, cgrjc, cr, cgr
963fc8d0
AK
1323(define_insn "*cmp_and_br_signed_<mode>"
1324 [(set (pc)
1325 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1326 [(match_operand:GPR 1 "register_operand" "d,d")
1327 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1328 (label_ref (match_operand 3 "" ""))
1329 (pc)))
1330 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1331 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
963fc8d0
AK
1332{
1333 if (get_attr_length (insn) == 6)
1334 return which_alternative ?
1335 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1336 else
1337 return which_alternative ?
1338 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1339}
1340 [(set_attr "op_type" "RIE")
1341 (set_attr "type" "branch")
e3cba5e5 1342 (set_attr "z10prop" "z10_super_c,z10_super")
963fc8d0
AK
1343 (set (attr "length")
1344 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1345 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1346 ; 10 byte for cgr/jg
1347
1348; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
9381e3f1
WG
1349; The following instructions do a complementary access of their second
1350; operand (z10 only): clrj, clgrj, clr, clgr
963fc8d0
AK
1351(define_insn "*cmp_and_br_unsigned_<mode>"
1352 [(set (pc)
1353 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1354 [(match_operand:GPR 1 "register_operand" "d,d")
1355 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1356 (label_ref (match_operand 3 "" ""))
1357 (pc)))
1358 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1359 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
963fc8d0
AK
1360{
1361 if (get_attr_length (insn) == 6)
1362 return which_alternative ?
1363 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1364 else
1365 return which_alternative ?
1366 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1367}
1368 [(set_attr "op_type" "RIE")
1369 (set_attr "type" "branch")
e3cba5e5 1370 (set_attr "z10prop" "z10_super_c,z10_super")
963fc8d0
AK
1371 (set (attr "length")
1372 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1373 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1374 ; 10 byte for clgr/jg
1375
b0f86a7e
AK
1376; And now the same two patterns as above but with a negated CC mask.
1377
1378; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1379; The following instructions do a complementary access of their second
1380; operand (z01 only): crj_c, cgrjc, cr, cgr
1381(define_insn "*icmp_and_br_signed_<mode>"
1382 [(set (pc)
1383 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1384 [(match_operand:GPR 1 "register_operand" "d,d")
1385 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1386 (pc)
1387 (label_ref (match_operand 3 "" ""))))
1388 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1389 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
b0f86a7e
AK
1390{
1391 if (get_attr_length (insn) == 6)
1392 return which_alternative ?
1393 "c<g>ij%D0\t%1,%c2,%l3" : "c<g>rj%D0\t%1,%2,%l3";
1394 else
1395 return which_alternative ?
1396 "c<g>fi\t%1,%c2\;jg%D0\t%l3" : "c<g>r\t%1,%2\;jg%D0\t%l3";
1397}
1398 [(set_attr "op_type" "RIE")
1399 (set_attr "type" "branch")
1400 (set_attr "z10prop" "z10_super_c,z10_super")
1401 (set (attr "length")
1402 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1403 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1404 ; 10 byte for cgr/jg
1405
1406; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1407; The following instructions do a complementary access of their second
1408; operand (z10 only): clrj, clgrj, clr, clgr
1409(define_insn "*icmp_and_br_unsigned_<mode>"
1410 [(set (pc)
1411 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1412 [(match_operand:GPR 1 "register_operand" "d,d")
1413 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1414 (pc)
1415 (label_ref (match_operand 3 "" ""))))
1416 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1417 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
b0f86a7e
AK
1418{
1419 if (get_attr_length (insn) == 6)
1420 return which_alternative ?
1421 "cl<g>ij%D0\t%1,%b2,%l3" : "cl<g>rj%D0\t%1,%2,%l3";
1422 else
1423 return which_alternative ?
1424 "cl<g>fi\t%1,%b2\;jg%D0\t%l3" : "cl<g>r\t%1,%2\;jg%D0\t%l3";
1425}
1426 [(set_attr "op_type" "RIE")
1427 (set_attr "type" "branch")
1428 (set_attr "z10prop" "z10_super_c,z10_super")
1429 (set (attr "length")
1430 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1431 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1432 ; 10 byte for clgr/jg
1433
9db1d521
HP
1434;;
1435;;- Move instructions.
1436;;
1437
1438;
1439; movti instruction pattern(s).
1440;
1441
085261c8
AK
1442; FIXME: More constants are possible by enabling jxx, jyy constraints
1443; for TImode (use double-int for the calculations)
9db1d521 1444(define_insn "movti"
3e4be43f
UW
1445 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,S,v, v, v,v,d,v,R, d,o")
1446 (match_operand:TI 1 "general_operand" " S,d,v,j00,jm1,d,v,R,v,dPT,d"))]
9602b6a1 1447 "TARGET_ZARCH"
4023fb28 1448 "@
fc0ea003
UW
1449 lmg\t%0,%N0,%S1
1450 stmg\t%1,%N1,%S0
085261c8
AK
1451 vlr\t%v0,%v1
1452 vzero\t%v0
1453 vone\t%v0
1454 vlvgp\t%v0,%1,%N1
1455 #
1456 vl\t%v0,%1
1457 vst\t%v1,%0
4023fb28 1458 #
19b63d8e 1459 #"
085261c8
AK
1460 [(set_attr "op_type" "RSY,RSY,VRR,VRI,VRI,VRR,*,VRX,VRX,*,*")
1461 (set_attr "type" "lm,stm,*,*,*,*,*,*,*,*,*")
1462 (set_attr "cpu_facility" "*,*,vec,vec,vec,vec,vec,vec,vec,*,*")])
4023fb28
UW
1463
1464(define_split
1465 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1466 (match_operand:TI 1 "general_operand" ""))]
9602b6a1 1467 "TARGET_ZARCH && reload_completed
dc65c307 1468 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
4023fb28
UW
1469 [(set (match_dup 2) (match_dup 4))
1470 (set (match_dup 3) (match_dup 5))]
9db1d521 1471{
dc65c307
UW
1472 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1473 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1474 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1475 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1476})
1477
1478(define_split
1479 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1480 (match_operand:TI 1 "general_operand" ""))]
9602b6a1 1481 "TARGET_ZARCH && reload_completed
dc65c307
UW
1482 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1483 [(set (match_dup 2) (match_dup 4))
1484 (set (match_dup 3) (match_dup 5))]
1485{
1486 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1487 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1488 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1489 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1490})
4023fb28 1491
085261c8
AK
1492; Use part of the TImode target reg to perform the address
1493; calculation. If the TImode value is supposed to be copied into a VR
1494; this splitter is not necessary.
4023fb28
UW
1495(define_split
1496 [(set (match_operand:TI 0 "register_operand" "")
1497 (match_operand:TI 1 "memory_operand" ""))]
9602b6a1 1498 "TARGET_ZARCH && reload_completed
085261c8 1499 && !VECTOR_REG_P (operands[0])
4023fb28 1500 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1501 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1502{
1503 rtx addr = operand_subword (operands[0], 1, 0, TImode);
9602b6a1 1504 addr = gen_lowpart (Pmode, addr);
a41c6c53
UW
1505 s390_load_address (addr, XEXP (operands[1], 0));
1506 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1507})
1508
833cd70a 1509
085261c8
AK
1510; Split a VR -> GPR TImode move into 2 vector load GR from VR element.
1511; For the higher order bits we do simply a DImode move while the
1512; second part is done via vec extract. Both will end up as vlgvg.
1513(define_split
1514 [(set (match_operand:TI 0 "register_operand" "")
1515 (match_operand:TI 1 "register_operand" ""))]
1516 "TARGET_VX && reload_completed
1517 && GENERAL_REG_P (operands[0])
1518 && VECTOR_REG_P (operands[1])"
1519 [(set (match_dup 2) (match_dup 4))
1520 (set (match_dup 3) (unspec:DI [(match_dup 5) (const_int 1)]
1521 UNSPEC_VEC_EXTRACT))]
1522{
1523 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1524 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1525 operands[4] = gen_rtx_REG (DImode, REGNO (operands[1]));
1526 operands[5] = gen_rtx_REG (V2DImode, REGNO (operands[1]));
1527})
1528
833cd70a
AK
1529;
1530; Patterns used for secondary reloads
1531;
1532
963fc8d0
AK
1533; z10 provides move instructions accepting larl memory operands.
1534; Unfortunately there is no such variant for QI, TI and FP mode moves.
1535; These patterns are also used for unaligned SI and DI accesses.
1536
085261c8
AK
1537(define_expand "reload<ALL:mode><P:mode>_tomem_z10"
1538 [(parallel [(match_operand:ALL 0 "memory_operand" "")
1539 (match_operand:ALL 1 "register_operand" "=d")
1540 (match_operand:P 2 "register_operand" "=&a")])]
963fc8d0
AK
1541 "TARGET_Z10"
1542{
1543 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1544 DONE;
1545})
1546
085261c8
AK
1547(define_expand "reload<ALL:mode><P:mode>_toreg_z10"
1548 [(parallel [(match_operand:ALL 0 "register_operand" "=d")
1549 (match_operand:ALL 1 "memory_operand" "")
1550 (match_operand:P 2 "register_operand" "=a")])]
963fc8d0
AK
1551 "TARGET_Z10"
1552{
1553 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1554 DONE;
1555})
1556
1557(define_expand "reload<P:mode>_larl_odd_addend_z10"
1558 [(parallel [(match_operand:P 0 "register_operand" "=d")
1559 (match_operand:P 1 "larl_operand" "")
1560 (match_operand:P 2 "register_operand" "=a")])]
1561 "TARGET_Z10"
1562{
1563 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1564 DONE;
1565})
1566
833cd70a
AK
1567; Handles loading a PLUS (load address) expression
1568
1569(define_expand "reload<mode>_plus"
1570 [(parallel [(match_operand:P 0 "register_operand" "=a")
1571 (match_operand:P 1 "s390_plus_operand" "")
1572 (match_operand:P 2 "register_operand" "=&a")])]
1573 ""
1574{
1575 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1576 DONE;
1577})
1578
085261c8
AK
1579; Not all the indirect memory access instructions support the full
1580; format (long disp + index + base). So whenever a move from/to such
1581; an address is required and the instruction cannot deal with it we do
1582; a load address into a scratch register first and use this as the new
1583; base register.
1584; This in particular is used for:
1585; - non-offsetable memory accesses for multiword moves
1586; - full vector reg moves with long displacements
833cd70a 1587
085261c8 1588(define_expand "reload<mode>_la_in"
833cd70a
AK
1589 [(parallel [(match_operand 0 "register_operand" "")
1590 (match_operand 1 "" "")
1591 (match_operand:P 2 "register_operand" "=&a")])]
1592 ""
1593{
1594 gcc_assert (MEM_P (operands[1]));
1595 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1596 operands[1] = replace_equiv_address (operands[1], operands[2]);
1597 emit_move_insn (operands[0], operands[1]);
1598 DONE;
1599})
1600
085261c8 1601(define_expand "reload<mode>_la_out"
833cd70a
AK
1602 [(parallel [(match_operand 0 "" "")
1603 (match_operand 1 "register_operand" "")
1604 (match_operand:P 2 "register_operand" "=&a")])]
1605 ""
dc65c307 1606{
9c3c3dcc 1607 gcc_assert (MEM_P (operands[0]));
9c90a97e 1608 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
dc65c307
UW
1609 operands[0] = replace_equiv_address (operands[0], operands[2]);
1610 emit_move_insn (operands[0], operands[1]);
1611 DONE;
1612})
9db1d521 1613
1f9e1fc6
AK
1614(define_expand "reload<mode>_PIC_addr"
1615 [(parallel [(match_operand 0 "register_operand" "=d")
1616 (match_operand 1 "larl_operand" "")
1617 (match_operand:P 2 "register_operand" "=a")])]
1618 ""
1619{
0a2aaacc
KG
1620 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1621 emit_move_insn (operands[0], new_rtx);
1f9e1fc6
AK
1622})
1623
9db1d521
HP
1624;
1625; movdi instruction pattern(s).
1626;
1627
9db1d521
HP
1628(define_expand "movdi"
1629 [(set (match_operand:DI 0 "general_operand" "")
1630 (match_operand:DI 1 "general_operand" ""))]
1631 ""
9db1d521 1632{
fd3cd001 1633 /* Handle symbolic constants. */
e4f2cd43
AK
1634 if (TARGET_64BIT
1635 && (SYMBOLIC_CONST (operands[1])
1636 || (GET_CODE (operands[1]) == PLUS
1637 && XEXP (operands[1], 0) == pic_offset_table_rtx
1638 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
fd3cd001 1639 emit_symbolic_move (operands);
10bbf137 1640})
9db1d521 1641
4023fb28
UW
1642(define_insn "*movdi_larl"
1643 [(set (match_operand:DI 0 "register_operand" "=d")
1644 (match_operand:DI 1 "larl_operand" "X"))]
1645 "TARGET_64BIT
8e509cf9 1646 && !FP_REG_P (operands[0])"
d40c829f 1647 "larl\t%0,%1"
4023fb28 1648 [(set_attr "op_type" "RIL")
9381e3f1
WG
1649 (set_attr "type" "larl")
1650 (set_attr "z10prop" "z10_super_A1")])
4023fb28 1651
3af8e996 1652(define_insn "*movdi_64"
85dae55a 1653 [(set (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 1654 "=d, d, d, d, d, d, d, d,f,d,d,d,d,d,T,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t,v,v,v,d,v,R")
85dae55a 1655 (match_operand:DI 1 "general_operand"
3e4be43f 1656 " K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,T,d, *f, R, T,*f,*f,d,K,t,d,t,Q,K,v,d,v,R,v"))]
9602b6a1 1657 "TARGET_ZARCH"
85dae55a
AK
1658 "@
1659 lghi\t%0,%h1
1660 llihh\t%0,%i1
1661 llihl\t%0,%i1
1662 llilh\t%0,%i1
1663 llill\t%0,%i1
1664 lgfi\t%0,%1
1665 llihf\t%0,%k1
1666 llilf\t%0,%k1
1667 ldgr\t%0,%1
1668 lgdr\t%0,%1
1669 lay\t%0,%a1
963fc8d0 1670 lgrl\t%0,%1
85dae55a
AK
1671 lgr\t%0,%1
1672 lg\t%0,%1
1673 stg\t%1,%0
1674 ldr\t%0,%1
1675 ld\t%0,%1
1676 ldy\t%0,%1
1677 std\t%1,%0
1678 stdy\t%1,%0
963fc8d0
AK
1679 stgrl\t%1,%0
1680 mvghi\t%0,%1
85dae55a
AK
1681 #
1682 #
1683 stam\t%1,%N1,%S0
085261c8
AK
1684 lam\t%0,%N0,%S1
1685 vleig\t%v0,%h1,0
1686 vlr\t%v0,%v1
1687 vlvgg\t%v0,%1,0
1688 vlgvg\t%0,%v1,0
1689 vleg\t%v0,%1,0
1690 vsteg\t%v1,%0,0"
963fc8d0 1691 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
085261c8 1692 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS,VRX,VRX")
963fc8d0 1693 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
085261c8
AK
1694 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,*,
1695 *,*,*,*,*,*,*")
3af8e996 1696 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
963fc8d0 1697 z10,*,*,*,*,*,longdisp,*,longdisp,
085261c8 1698 z10,z10,*,*,*,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
1699 (set_attr "z10prop" "z10_fwd_A1,
1700 z10_fwd_E1,
1701 z10_fwd_E1,
1702 z10_fwd_E1,
1703 z10_fwd_E1,
1704 z10_fwd_A1,
1705 z10_fwd_E1,
1706 z10_fwd_E1,
1707 *,
1708 *,
1709 z10_fwd_A1,
1710 z10_fwd_A3,
1711 z10_fr_E1,
1712 z10_fwd_A3,
1713 z10_rec,
1714 *,
1715 *,
1716 *,
1717 *,
1718 *,
1719 z10_rec,
1720 z10_super,
1721 *,
1722 *,
1723 *,
085261c8 1724 *,*,*,*,*,*,*")
9381e3f1 1725])
c5aa1d12
UW
1726
1727(define_split
1728 [(set (match_operand:DI 0 "register_operand" "")
1729 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1730 "TARGET_ZARCH && ACCESS_REG_P (operands[1])"
c5aa1d12
UW
1731 [(set (match_dup 2) (match_dup 3))
1732 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1733 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1734 "operands[2] = gen_lowpart (SImode, operands[0]);
1735 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1736
1737(define_split
1738 [(set (match_operand:DI 0 "register_operand" "")
1739 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1740 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
c5aa1d12
UW
1741 && dead_or_set_p (insn, operands[1])"
1742 [(set (match_dup 3) (match_dup 2))
1743 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1744 (set (match_dup 4) (match_dup 2))]
1745 "operands[2] = gen_lowpart (SImode, operands[1]);
1746 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1747
1748(define_split
1749 [(set (match_operand:DI 0 "register_operand" "")
1750 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1751 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
c5aa1d12
UW
1752 && !dead_or_set_p (insn, operands[1])"
1753 [(set (match_dup 3) (match_dup 2))
1754 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1755 (set (match_dup 4) (match_dup 2))
1756 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1757 "operands[2] = gen_lowpart (SImode, operands[1]);
1758 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
9db1d521
HP
1759
1760(define_insn "*movdi_31"
963fc8d0 1761 [(set (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 1762 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!R,!T,d")
963fc8d0 1763 (match_operand:DI 1 "general_operand"
3e4be43f 1764 " Q,S,d,d,dPT,d, *f, R, T,*f,*f,b"))]
9602b6a1 1765 "!TARGET_ZARCH"
4023fb28 1766 "@
fc0ea003 1767 lm\t%0,%N0,%S1
c4d50129 1768 lmy\t%0,%N0,%S1
fc0ea003 1769 stm\t%1,%N1,%S0
c4d50129 1770 stmy\t%1,%N1,%S0
4023fb28
UW
1771 #
1772 #
d40c829f
UW
1773 ldr\t%0,%1
1774 ld\t%0,%1
1775 ldy\t%0,%1
1776 std\t%1,%0
1777 stdy\t%1,%0
19b63d8e 1778 #"
f2dc2f86
AK
1779 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1780 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
3e4be43f 1781 (set_attr "cpu_facility" "*,longdisp,*,longdisp,*,*,*,*,longdisp,*,longdisp,z10")])
963fc8d0
AK
1782
1783; For a load from a symbol ref we can use one of the target registers
1784; together with larl to load the address.
1785(define_split
1786 [(set (match_operand:DI 0 "register_operand" "")
1787 (match_operand:DI 1 "memory_operand" ""))]
9602b6a1 1788 "!TARGET_ZARCH && reload_completed && TARGET_Z10
963fc8d0
AK
1789 && larl_operand (XEXP (operands[1], 0), SImode)"
1790 [(set (match_dup 2) (match_dup 3))
1791 (set (match_dup 0) (match_dup 1))]
1792{
1793 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1794 operands[3] = XEXP (operands[1], 0);
1795 operands[1] = replace_equiv_address (operands[1], operands[2]);
1796})
4023fb28
UW
1797
1798(define_split
1799 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1800 (match_operand:DI 1 "general_operand" ""))]
9602b6a1 1801 "!TARGET_ZARCH && reload_completed
dc65c307 1802 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
4023fb28
UW
1803 [(set (match_dup 2) (match_dup 4))
1804 (set (match_dup 3) (match_dup 5))]
9db1d521 1805{
dc65c307
UW
1806 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1807 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1808 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1809 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1810})
1811
1812(define_split
1813 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1814 (match_operand:DI 1 "general_operand" ""))]
9602b6a1 1815 "!TARGET_ZARCH && reload_completed
dc65c307
UW
1816 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1817 [(set (match_dup 2) (match_dup 4))
1818 (set (match_dup 3) (match_dup 5))]
1819{
1820 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1821 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1822 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1823 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1824})
9db1d521 1825
4023fb28
UW
1826(define_split
1827 [(set (match_operand:DI 0 "register_operand" "")
1828 (match_operand:DI 1 "memory_operand" ""))]
9602b6a1 1829 "!TARGET_ZARCH && reload_completed
8e509cf9 1830 && !FP_REG_P (operands[0])
4023fb28 1831 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1832 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1833{
1834 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1835 s390_load_address (addr, XEXP (operands[1], 0));
1836 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1837})
1838
84817c5d
UW
1839(define_peephole2
1840 [(set (match_operand:DI 0 "register_operand" "")
1841 (mem:DI (match_operand 1 "address_operand" "")))]
9602b6a1 1842 "TARGET_ZARCH
84817c5d
UW
1843 && !FP_REG_P (operands[0])
1844 && GET_CODE (operands[1]) == SYMBOL_REF
1845 && CONSTANT_POOL_ADDRESS_P (operands[1])
1846 && get_pool_mode (operands[1]) == DImode
1847 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1848 [(set (match_dup 0) (match_dup 2))]
1849 "operands[2] = get_pool_constant (operands[1]);")
1850
7bdff56f
UW
1851(define_insn "*la_64"
1852 [(set (match_operand:DI 0 "register_operand" "=d,d")
3e4be43f 1853 (match_operand:QI 1 "address_operand" "ZR,ZT"))]
7bdff56f
UW
1854 "TARGET_64BIT"
1855 "@
1856 la\t%0,%a1
1857 lay\t%0,%a1"
1858 [(set_attr "op_type" "RX,RXY")
9381e3f1 1859 (set_attr "type" "la")
3e4be43f 1860 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 1861 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
1862
1863(define_peephole2
1864 [(parallel
1865 [(set (match_operand:DI 0 "register_operand" "")
1866 (match_operand:QI 1 "address_operand" ""))
ae156f85 1867 (clobber (reg:CC CC_REGNUM))])]
7bdff56f 1868 "TARGET_64BIT
e1d5ee28 1869 && preferred_la_operand_p (operands[1], const0_rtx)"
7bdff56f
UW
1870 [(set (match_dup 0) (match_dup 1))]
1871 "")
1872
1873(define_peephole2
1874 [(set (match_operand:DI 0 "register_operand" "")
1875 (match_operand:DI 1 "register_operand" ""))
1876 (parallel
1877 [(set (match_dup 0)
1878 (plus:DI (match_dup 0)
1879 (match_operand:DI 2 "nonmemory_operand" "")))
ae156f85 1880 (clobber (reg:CC CC_REGNUM))])]
7bdff56f
UW
1881 "TARGET_64BIT
1882 && !reg_overlap_mentioned_p (operands[0], operands[2])
e1d5ee28 1883 && preferred_la_operand_p (operands[1], operands[2])"
7bdff56f
UW
1884 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1885 "")
1886
9db1d521
HP
1887;
1888; movsi instruction pattern(s).
1889;
1890
9db1d521
HP
1891(define_expand "movsi"
1892 [(set (match_operand:SI 0 "general_operand" "")
1893 (match_operand:SI 1 "general_operand" ""))]
1894 ""
9db1d521 1895{
fd3cd001 1896 /* Handle symbolic constants. */
e4f2cd43
AK
1897 if (!TARGET_64BIT
1898 && (SYMBOLIC_CONST (operands[1])
1899 || (GET_CODE (operands[1]) == PLUS
1900 && XEXP (operands[1], 0) == pic_offset_table_rtx
1901 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
fd3cd001 1902 emit_symbolic_move (operands);
10bbf137 1903})
9db1d521 1904
9e8327e3
UW
1905(define_insn "*movsi_larl"
1906 [(set (match_operand:SI 0 "register_operand" "=d")
1907 (match_operand:SI 1 "larl_operand" "X"))]
1908 "!TARGET_64BIT && TARGET_CPU_ZARCH
1909 && !FP_REG_P (operands[0])"
1910 "larl\t%0,%1"
1911 [(set_attr "op_type" "RIL")
9381e3f1 1912 (set_attr "type" "larl")
729e750f 1913 (set_attr "z10prop" "z10_fwd_A1")])
9e8327e3 1914
f19a9af7 1915(define_insn "*movsi_zarch"
2f7e5a0d 1916 [(set (match_operand:SI 0 "nonimmediate_operand"
3e4be43f 1917 "=d, d, d, d,d,d,d,d,d,R,T,!*f,!*f,!*f,!*f,!*f,!R,!T,d,t,Q,b,Q,t,v,v,v,d,v,R")
2f7e5a0d 1918 (match_operand:SI 1 "general_operand"
3e4be43f 1919 " K,N0HS0,N1HS0,Os,L,b,d,R,T,d,d, *f, *f, R, R, T,*f,*f,t,d,t,d,K,Q,K,v,d,v,R,v"))]
f19a9af7 1920 "TARGET_ZARCH"
9db1d521 1921 "@
f19a9af7
AK
1922 lhi\t%0,%h1
1923 llilh\t%0,%i1
1924 llill\t%0,%i1
ec24698e 1925 iilf\t%0,%o1
f19a9af7 1926 lay\t%0,%a1
963fc8d0 1927 lrl\t%0,%1
d40c829f
UW
1928 lr\t%0,%1
1929 l\t%0,%1
1930 ly\t%0,%1
1931 st\t%1,%0
1932 sty\t%1,%0
ae1c6198 1933 ldr\t%0,%1
d40c829f 1934 ler\t%0,%1
085261c8 1935 lde\t%0,%1
d40c829f
UW
1936 le\t%0,%1
1937 ley\t%0,%1
1938 ste\t%1,%0
1939 stey\t%1,%0
c5aa1d12
UW
1940 ear\t%0,%1
1941 sar\t%0,%1
1942 stam\t%1,%1,%S0
963fc8d0
AK
1943 strl\t%1,%0
1944 mvhi\t%0,%1
085261c8
AK
1945 lam\t%0,%0,%S1
1946 vleif\t%v0,%h1,0
1947 vlr\t%v0,%v1
1948 vlvgf\t%v0,%1,0
1949 vlgvf\t%0,%v1,0
1950 vlef\t%v0,%1,0
1951 vstef\t%v1,%0,0"
963fc8d0 1952 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
ae1c6198 1953 RR,RR,RXE,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS,VRI,VRR,VRS,VRS,VRX,VRX")
9381e3f1
WG
1954 (set_attr "type" "*,
1955 *,
1956 *,
1957 *,
1958 la,
1959 larl,
1960 lr,
1961 load,
1962 load,
1963 store,
1964 store,
1965 floadsf,
1966 floadsf,
1967 floadsf,
085261c8
AK
1968 floadsf,
1969 floadsf,
9381e3f1
WG
1970 fstoresf,
1971 fstoresf,
1972 *,
1973 *,
1974 *,
1975 larl,
1976 *,
085261c8 1977 *,*,*,*,*,*,*")
963fc8d0 1978 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
085261c8 1979 vec,*,vec,*,longdisp,*,longdisp,*,*,*,z10,z10,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
1980 (set_attr "z10prop" "z10_fwd_A1,
1981 z10_fwd_E1,
1982 z10_fwd_E1,
1983 z10_fwd_A1,
1984 z10_fwd_A1,
1985 z10_fwd_A3,
1986 z10_fr_E1,
1987 z10_fwd_A3,
1988 z10_fwd_A3,
729e750f 1989 z10_rec,
9381e3f1
WG
1990 z10_rec,
1991 *,
1992 *,
1993 *,
1994 *,
1995 *,
085261c8
AK
1996 *,
1997 *,
9381e3f1
WG
1998 z10_super_E1,
1999 z10_super,
2000 *,
2001 z10_rec,
2002 z10_super,
085261c8 2003 *,*,*,*,*,*,*")])
f19a9af7
AK
2004
2005(define_insn "*movsi_esa"
085261c8
AK
2006 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!*f,!*f,!R,d,t,Q,t")
2007 (match_operand:SI 1 "general_operand" "K,d,R,d, *f, *f, R, R,*f,t,d,t,Q"))]
f19a9af7
AK
2008 "!TARGET_ZARCH"
2009 "@
2010 lhi\t%0,%h1
2011 lr\t%0,%1
2012 l\t%0,%1
2013 st\t%1,%0
ae1c6198 2014 ldr\t%0,%1
f19a9af7 2015 ler\t%0,%1
085261c8 2016 lde\t%0,%1
f19a9af7
AK
2017 le\t%0,%1
2018 ste\t%1,%0
c5aa1d12
UW
2019 ear\t%0,%1
2020 sar\t%0,%1
2021 stam\t%1,%1,%S0
f2dc2f86 2022 lam\t%0,%0,%S1"
ae1c6198 2023 [(set_attr "op_type" "RI,RR,RX,RX,RR,RR,RXE,RX,RX,RRE,RRE,RS,RS")
085261c8
AK
2024 (set_attr "type" "*,lr,load,store,floadsf,floadsf,floadsf,floadsf,fstoresf,*,*,*,*")
2025 (set_attr "z10prop" "z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec,*,*,*,*,*,z10_super_E1,
2026 z10_super,*,*")
2027 (set_attr "cpu_facility" "*,*,*,*,vec,*,vec,*,*,*,*,*,*")
9381e3f1 2028])
9db1d521 2029
84817c5d
UW
2030(define_peephole2
2031 [(set (match_operand:SI 0 "register_operand" "")
2032 (mem:SI (match_operand 1 "address_operand" "")))]
2033 "!FP_REG_P (operands[0])
2034 && GET_CODE (operands[1]) == SYMBOL_REF
2035 && CONSTANT_POOL_ADDRESS_P (operands[1])
2036 && get_pool_mode (operands[1]) == SImode
2037 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
2038 [(set (match_dup 0) (match_dup 2))]
2039 "operands[2] = get_pool_constant (operands[1]);")
9db1d521 2040
7bdff56f
UW
2041(define_insn "*la_31"
2042 [(set (match_operand:SI 0 "register_operand" "=d,d")
3e4be43f 2043 (match_operand:QI 1 "address_operand" "ZR,ZT"))]
7bdff56f
UW
2044 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
2045 "@
2046 la\t%0,%a1
2047 lay\t%0,%a1"
2048 [(set_attr "op_type" "RX,RXY")
9381e3f1 2049 (set_attr "type" "la")
3e4be43f 2050 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 2051 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
2052
2053(define_peephole2
2054 [(parallel
2055 [(set (match_operand:SI 0 "register_operand" "")
2056 (match_operand:QI 1 "address_operand" ""))
ae156f85 2057 (clobber (reg:CC CC_REGNUM))])]
7bdff56f 2058 "!TARGET_64BIT
e1d5ee28 2059 && preferred_la_operand_p (operands[1], const0_rtx)"
7bdff56f
UW
2060 [(set (match_dup 0) (match_dup 1))]
2061 "")
2062
2063(define_peephole2
2064 [(set (match_operand:SI 0 "register_operand" "")
2065 (match_operand:SI 1 "register_operand" ""))
2066 (parallel
2067 [(set (match_dup 0)
2068 (plus:SI (match_dup 0)
2069 (match_operand:SI 2 "nonmemory_operand" "")))
ae156f85 2070 (clobber (reg:CC CC_REGNUM))])]
7bdff56f
UW
2071 "!TARGET_64BIT
2072 && !reg_overlap_mentioned_p (operands[0], operands[2])
e1d5ee28 2073 && preferred_la_operand_p (operands[1], operands[2])"
7bdff56f
UW
2074 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2075 "")
2076
2077(define_insn "*la_31_and"
2078 [(set (match_operand:SI 0 "register_operand" "=d,d")
3e4be43f 2079 (and:SI (match_operand:QI 1 "address_operand" "ZR,ZT")
7bdff56f
UW
2080 (const_int 2147483647)))]
2081 "!TARGET_64BIT"
2082 "@
2083 la\t%0,%a1
2084 lay\t%0,%a1"
2085 [(set_attr "op_type" "RX,RXY")
9381e3f1 2086 (set_attr "type" "la")
3e4be43f 2087 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 2088 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
2089
2090(define_insn_and_split "*la_31_and_cc"
2091 [(set (match_operand:SI 0 "register_operand" "=d")
2092 (and:SI (match_operand:QI 1 "address_operand" "p")
2093 (const_int 2147483647)))
ae156f85 2094 (clobber (reg:CC CC_REGNUM))]
7bdff56f
UW
2095 "!TARGET_64BIT"
2096 "#"
2097 "&& reload_completed"
2098 [(set (match_dup 0)
2099 (and:SI (match_dup 1) (const_int 2147483647)))]
2100 ""
2101 [(set_attr "op_type" "RX")
2102 (set_attr "type" "la")])
2103
2104(define_insn "force_la_31"
2105 [(set (match_operand:SI 0 "register_operand" "=d,d")
3e4be43f 2106 (match_operand:QI 1 "address_operand" "ZR,ZT"))
7bdff56f
UW
2107 (use (const_int 0))]
2108 "!TARGET_64BIT"
2109 "@
2110 la\t%0,%a1
2111 lay\t%0,%a1"
2112 [(set_attr "op_type" "RX")
9381e3f1 2113 (set_attr "type" "la")
3e4be43f 2114 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 2115 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f 2116
9db1d521
HP
2117;
2118; movhi instruction pattern(s).
2119;
2120
02ed3c5e
UW
2121(define_expand "movhi"
2122 [(set (match_operand:HI 0 "nonimmediate_operand" "")
2123 (match_operand:HI 1 "general_operand" ""))]
2124 ""
2125{
2f7e5a0d 2126 /* Make it explicit that loading a register from memory
02ed3c5e 2127 always sign-extends (at least) to SImode. */
b3a13419 2128 if (optimize && can_create_pseudo_p ()
02ed3c5e 2129 && register_operand (operands[0], VOIDmode)
8fff4fc1 2130 && GET_CODE (operands[1]) == MEM)
02ed3c5e
UW
2131 {
2132 rtx tmp = gen_reg_rtx (SImode);
2133 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
f7df4a84 2134 emit_insn (gen_rtx_SET (tmp, ext));
02ed3c5e
UW
2135 operands[1] = gen_lowpart (HImode, tmp);
2136 }
2137})
2138
2139(define_insn "*movhi"
3e4be43f
UW
2140 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q,v,v,v,d,v,R")
2141 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K,K,v,d,v,R,v"))]
9db1d521
HP
2142 ""
2143 "@
d40c829f
UW
2144 lr\t%0,%1
2145 lhi\t%0,%h1
2146 lh\t%0,%1
2147 lhy\t%0,%1
963fc8d0 2148 lhrl\t%0,%1
d40c829f
UW
2149 sth\t%1,%0
2150 sthy\t%1,%0
963fc8d0 2151 sthrl\t%1,%0
085261c8
AK
2152 mvhhi\t%0,%1
2153 vleih\t%v0,%h1,0
2154 vlr\t%v0,%v1
2155 vlvgh\t%v0,%1,0
2156 vlgvh\t%0,%v1,0
2157 vleh\t%v0,%1,0
2158 vsteh\t%v1,%0,0"
2159 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL,VRI,VRR,VRS,VRS,VRX,VRX")
2160 (set_attr "type" "lr,*,*,*,larl,store,store,store,*,*,*,*,*,*,*")
3e4be43f 2161 (set_attr "cpu_facility" "*,*,*,longdisp,z10,*,longdisp,z10,z10,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
2162 (set_attr "z10prop" "z10_fr_E1,
2163 z10_fwd_A1,
2164 z10_super_E1,
2165 z10_super_E1,
2166 z10_super_E1,
729e750f 2167 z10_rec,
9381e3f1
WG
2168 z10_rec,
2169 z10_rec,
085261c8 2170 z10_super,*,*,*,*,*,*")])
9db1d521 2171
84817c5d
UW
2172(define_peephole2
2173 [(set (match_operand:HI 0 "register_operand" "")
2174 (mem:HI (match_operand 1 "address_operand" "")))]
2175 "GET_CODE (operands[1]) == SYMBOL_REF
2176 && CONSTANT_POOL_ADDRESS_P (operands[1])
2177 && get_pool_mode (operands[1]) == HImode
2178 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2179 [(set (match_dup 0) (match_dup 2))]
2180 "operands[2] = get_pool_constant (operands[1]);")
4023fb28 2181
9db1d521
HP
2182;
2183; movqi instruction pattern(s).
2184;
2185
02ed3c5e
UW
2186(define_expand "movqi"
2187 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2188 (match_operand:QI 1 "general_operand" ""))]
2189 ""
2190{
c19ec8f9 2191 /* On z/Architecture, zero-extending from memory to register
02ed3c5e 2192 is just as fast as a QImode load. */
b3a13419 2193 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
02ed3c5e 2194 && register_operand (operands[0], VOIDmode)
8fff4fc1 2195 && GET_CODE (operands[1]) == MEM)
02ed3c5e 2196 {
9602b6a1
AK
2197 rtx tmp = gen_reg_rtx (DImode);
2198 rtx ext = gen_rtx_ZERO_EXTEND (DImode, operands[1]);
f7df4a84 2199 emit_insn (gen_rtx_SET (tmp, ext));
02ed3c5e
UW
2200 operands[1] = gen_lowpart (QImode, tmp);
2201 }
2202})
4023fb28 2203
02ed3c5e 2204(define_insn "*movqi"
3e4be43f
UW
2205 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q,v,v,v,d,v,R")
2206 (match_operand:QI 1 "general_operand" " d,n,R,T,d,d,n,n,?Q,K,v,d,v,R,v"))]
9db1d521
HP
2207 ""
2208 "@
d40c829f
UW
2209 lr\t%0,%1
2210 lhi\t%0,%b1
2211 ic\t%0,%1
2212 icy\t%0,%1
2213 stc\t%1,%0
2214 stcy\t%1,%0
fc0ea003 2215 mvi\t%S0,%b1
0a88561f 2216 mviy\t%S0,%b1
085261c8
AK
2217 #
2218 vleib\t%v0,%b1,0
2219 vlr\t%v0,%v1
2220 vlvgb\t%v0,%1,0
2221 vlgvb\t%0,%v1,0
2222 vleb\t%v0,%1,0
2223 vsteb\t%v1,%0,0"
2224 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS,VRI,VRR,VRS,VRS,VRX,VRX")
2225 (set_attr "type" "lr,*,*,*,store,store,store,store,*,*,*,*,*,*,*")
3e4be43f 2226 (set_attr "cpu_facility" "*,*,*,longdisp,*,longdisp,*,longdisp,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
2227 (set_attr "z10prop" "z10_fr_E1,
2228 z10_fwd_A1,
2229 z10_super_E1,
2230 z10_super_E1,
729e750f 2231 z10_rec,
9381e3f1
WG
2232 z10_rec,
2233 z10_super,
0a88561f 2234 z10_super,
085261c8 2235 *,*,*,*,*,*,*")])
9db1d521 2236
84817c5d
UW
2237(define_peephole2
2238 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2239 (mem:QI (match_operand 1 "address_operand" "")))]
2240 "GET_CODE (operands[1]) == SYMBOL_REF
2241 && CONSTANT_POOL_ADDRESS_P (operands[1])
2242 && get_pool_mode (operands[1]) == QImode
2243 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2244 [(set (match_dup 0) (match_dup 2))]
2245 "operands[2] = get_pool_constant (operands[1]);")
4023fb28 2246
9db1d521 2247;
05b9aaaa 2248; movstrictqi instruction pattern(s).
9db1d521
HP
2249;
2250
2251(define_insn "*movstrictqi"
d3632d41
UW
2252 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
2253 (match_operand:QI 1 "memory_operand" "R,T"))]
9db1d521 2254 ""
d3632d41 2255 "@
d40c829f
UW
2256 ic\t%0,%1
2257 icy\t%0,%1"
9381e3f1 2258 [(set_attr "op_type" "RX,RXY")
3e4be43f 2259 (set_attr "cpu_facility" "*,longdisp")
729e750f 2260 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521
HP
2261
2262;
2263; movstricthi instruction pattern(s).
2264;
2265
2266(define_insn "*movstricthi"
d3632d41 2267 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
575f7c2b 2268 (match_operand:HI 1 "memory_operand" "Q,S"))
ae156f85 2269 (clobber (reg:CC CC_REGNUM))]
9db1d521 2270 ""
d3632d41 2271 "@
fc0ea003
UW
2272 icm\t%0,3,%S1
2273 icmy\t%0,3,%S1"
9381e3f1 2274 [(set_attr "op_type" "RS,RSY")
3e4be43f 2275 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 2276 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521
HP
2277
2278;
2279; movstrictsi instruction pattern(s).
2280;
2281
05b9aaaa 2282(define_insn "movstrictsi"
c5aa1d12
UW
2283 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
2284 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
9602b6a1 2285 "TARGET_ZARCH"
9db1d521 2286 "@
d40c829f
UW
2287 lr\t%0,%1
2288 l\t%0,%1
c5aa1d12
UW
2289 ly\t%0,%1
2290 ear\t%0,%1"
2291 [(set_attr "op_type" "RR,RX,RXY,RRE")
9381e3f1 2292 (set_attr "type" "lr,load,load,*")
3e4be43f 2293 (set_attr "cpu_facility" "*,*,longdisp,*")
9381e3f1 2294 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
9db1d521 2295
f61a2c7d 2296;
609e7e80 2297; mov(tf|td) instruction pattern(s).
f61a2c7d
AK
2298;
2299
609e7e80
AK
2300(define_expand "mov<mode>"
2301 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2302 (match_operand:TD_TF 1 "general_operand" ""))]
f61a2c7d
AK
2303 ""
2304 "")
2305
609e7e80 2306(define_insn "*mov<mode>_64"
3e4be43f
UW
2307 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o,d,S, d,o")
2308 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,S,d,dT,d"))]
9602b6a1 2309 "TARGET_ZARCH"
f61a2c7d 2310 "@
65b1d8ea 2311 lzxr\t%0
f61a2c7d
AK
2312 lxr\t%0,%1
2313 #
2314 #
2315 lmg\t%0,%N0,%S1
2316 stmg\t%1,%N1,%S0
2317 #
f61a2c7d 2318 #"
65b1d8ea
AK
2319 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
2320 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")
2321 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*")])
f61a2c7d 2322
609e7e80 2323(define_insn "*mov<mode>_31"
65b1d8ea
AK
2324 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
2325 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
9602b6a1 2326 "!TARGET_ZARCH"
f61a2c7d 2327 "@
65b1d8ea 2328 lzxr\t%0
f61a2c7d
AK
2329 lxr\t%0,%1
2330 #
f61a2c7d 2331 #"
65b1d8ea
AK
2332 [(set_attr "op_type" "RRE,RRE,*,*")
2333 (set_attr "type" "fsimptf,fsimptf,*,*")
2334 (set_attr "cpu_facility" "z196,*,*,*")])
f61a2c7d
AK
2335
2336; TFmode in GPRs splitters
2337
2338(define_split
609e7e80
AK
2339 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2340 (match_operand:TD_TF 1 "general_operand" ""))]
9602b6a1 2341 "TARGET_ZARCH && reload_completed
609e7e80 2342 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
f61a2c7d
AK
2343 [(set (match_dup 2) (match_dup 4))
2344 (set (match_dup 3) (match_dup 5))]
2345{
609e7e80
AK
2346 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2347 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2348 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2349 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
f61a2c7d
AK
2350})
2351
2352(define_split
609e7e80
AK
2353 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2354 (match_operand:TD_TF 1 "general_operand" ""))]
9602b6a1 2355 "TARGET_ZARCH && reload_completed
609e7e80 2356 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
f61a2c7d
AK
2357 [(set (match_dup 2) (match_dup 4))
2358 (set (match_dup 3) (match_dup 5))]
2359{
609e7e80
AK
2360 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2361 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2362 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2363 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
f61a2c7d
AK
2364})
2365
2366(define_split
609e7e80
AK
2367 [(set (match_operand:TD_TF 0 "register_operand" "")
2368 (match_operand:TD_TF 1 "memory_operand" ""))]
9602b6a1 2369 "TARGET_ZARCH && reload_completed
085261c8 2370 && GENERAL_REG_P (operands[0])
f61a2c7d
AK
2371 && !s_operand (operands[1], VOIDmode)"
2372 [(set (match_dup 0) (match_dup 1))]
2373{
609e7e80 2374 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
a9e6994a 2375 addr = gen_lowpart (Pmode, addr);
f61a2c7d
AK
2376 s390_load_address (addr, XEXP (operands[1], 0));
2377 operands[1] = replace_equiv_address (operands[1], addr);
2378})
2379
7b6baae1 2380; TFmode in BFPs splitters
f61a2c7d
AK
2381
2382(define_split
609e7e80
AK
2383 [(set (match_operand:TD_TF 0 "register_operand" "")
2384 (match_operand:TD_TF 1 "memory_operand" ""))]
9381e3f1 2385 "reload_completed && offsettable_memref_p (operands[1])
f61a2c7d
AK
2386 && FP_REG_P (operands[0])"
2387 [(set (match_dup 2) (match_dup 4))
2388 (set (match_dup 3) (match_dup 5))]
2389{
609e7e80
AK
2390 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2391 <MODE>mode, 0);
2392 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2393 <MODE>mode, 8);
2394 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
2395 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
f61a2c7d
AK
2396})
2397
2398(define_split
609e7e80
AK
2399 [(set (match_operand:TD_TF 0 "memory_operand" "")
2400 (match_operand:TD_TF 1 "register_operand" ""))]
f61a2c7d
AK
2401 "reload_completed && offsettable_memref_p (operands[0])
2402 && FP_REG_P (operands[1])"
2403 [(set (match_dup 2) (match_dup 4))
2404 (set (match_dup 3) (match_dup 5))]
2405{
609e7e80
AK
2406 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
2407 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
2408 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2409 <MODE>mode, 0);
2410 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2411 <MODE>mode, 8);
f61a2c7d
AK
2412})
2413
9db1d521 2414;
609e7e80 2415; mov(df|dd) instruction pattern(s).
9db1d521
HP
2416;
2417
609e7e80
AK
2418(define_expand "mov<mode>"
2419 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2420 (match_operand:DD_DF 1 "general_operand" ""))]
9db1d521 2421 ""
13c025c1 2422 "")
9db1d521 2423
609e7e80
AK
2424(define_insn "*mov<mode>_64dfp"
2425 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
3e4be43f 2426 "=f,f,f,d,f,f,R,T,d,d,d,d,b,T,v,v,d,v,R")
609e7e80 2427 (match_operand:DD_DF 1 "general_operand"
3e4be43f 2428 " G,f,d,f,R,T,f,f,G,d,b,T,d,d,v,d,v,R,v"))]
9602b6a1 2429 "TARGET_DFP"
85dae55a 2430 "@
65b1d8ea 2431 lzdr\t%0
85dae55a
AK
2432 ldr\t%0,%1
2433 ldgr\t%0,%1
2434 lgdr\t%0,%1
2435 ld\t%0,%1
2436 ldy\t%0,%1
2437 std\t%1,%0
2438 stdy\t%1,%0
45e5214c 2439 lghi\t%0,0
85dae55a 2440 lgr\t%0,%1
085261c8 2441 lgrl\t%0,%1
85dae55a 2442 lg\t%0,%1
085261c8
AK
2443 stgrl\t%1,%0
2444 stg\t%1,%0
2445 vlr\t%v0,%v1
2446 vlvgg\t%v0,%1,0
2447 vlgvg\t%0,%v1,0
2448 vleg\t%0,%1,0
2449 vsteg\t%1,%0,0"
2450 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY,VRR,VRS,VRS,VRX,VRX")
65b1d8ea 2451 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
085261c8
AK
2452 fstoredf,fstoredf,*,lr,load,load,store,store,*,*,*,load,store")
2453 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,*,*,*,*,*")
3e4be43f 2454 (set_attr "cpu_facility" "z196,*,*,*,*,longdisp,*,longdisp,*,*,z10,*,z10,*,vec,vec,vec,vec,vec")])
85dae55a 2455
609e7e80 2456(define_insn "*mov<mode>_64"
3e4be43f
UW
2457 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,d,d,b,T,v,v,R")
2458 (match_operand:DD_DF 1 "general_operand" " G,f,R,T,f,f,G,d,b,T,d,d,v,R,v"))]
9602b6a1 2459 "TARGET_ZARCH"
9db1d521 2460 "@
65b1d8ea 2461 lzdr\t%0
d40c829f
UW
2462 ldr\t%0,%1
2463 ld\t%0,%1
2464 ldy\t%0,%1
2465 std\t%1,%0
2466 stdy\t%1,%0
45e5214c 2467 lghi\t%0,0
d40c829f 2468 lgr\t%0,%1
085261c8 2469 lgrl\t%0,%1
d40c829f 2470 lg\t%0,%1
085261c8
AK
2471 stgrl\t%1,%0
2472 stg\t%1,%0
2473 vlr\t%v0,%v1
2474 vleg\t%v0,%1,0
2475 vsteg\t%v1,%0,0"
2476 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY,VRR,VRX,VRX")
65b1d8ea 2477 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
085261c8
AK
2478 fstore<mode>,fstore<mode>,*,lr,load,load,store,store,*,load,store")
2479 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,*,*,*")
3e4be43f 2480 (set_attr "cpu_facility" "z196,*,*,longdisp,*,longdisp,*,*,z10,*,z10,*,vec,vec,vec")])
609e7e80
AK
2481
2482(define_insn "*mov<mode>_31"
2483 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
3e4be43f 2484 "=f,f,f,f,R,T,d,d,Q,S, d,o")
609e7e80 2485 (match_operand:DD_DF 1 "general_operand"
3e4be43f 2486 " G,f,R,T,f,f,Q,S,d,d,dPT,d"))]
9602b6a1 2487 "!TARGET_ZARCH"
9db1d521 2488 "@
65b1d8ea 2489 lzdr\t%0
d40c829f
UW
2490 ldr\t%0,%1
2491 ld\t%0,%1
2492 ldy\t%0,%1
2493 std\t%1,%0
2494 stdy\t%1,%0
fc0ea003 2495 lm\t%0,%N0,%S1
c4d50129 2496 lmy\t%0,%N0,%S1
fc0ea003 2497 stm\t%1,%N1,%S0
c4d50129 2498 stmy\t%1,%N1,%S0
4023fb28 2499 #
19b63d8e 2500 #"
65b1d8ea
AK
2501 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2502 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2503 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")
3e4be43f 2504 (set_attr "cpu_facility" "z196,*,*,longdisp,*,longdisp,*,longdisp,*,longdisp,*,*")])
4023fb28
UW
2505
2506(define_split
609e7e80
AK
2507 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2508 (match_operand:DD_DF 1 "general_operand" ""))]
9602b6a1 2509 "!TARGET_ZARCH && reload_completed
609e7e80 2510 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
4023fb28
UW
2511 [(set (match_dup 2) (match_dup 4))
2512 (set (match_dup 3) (match_dup 5))]
9db1d521 2513{
609e7e80
AK
2514 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2515 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2516 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2517 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
dc65c307
UW
2518})
2519
2520(define_split
609e7e80
AK
2521 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2522 (match_operand:DD_DF 1 "general_operand" ""))]
9602b6a1 2523 "!TARGET_ZARCH && reload_completed
609e7e80 2524 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
dc65c307
UW
2525 [(set (match_dup 2) (match_dup 4))
2526 (set (match_dup 3) (match_dup 5))]
2527{
609e7e80
AK
2528 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2529 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2530 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2531 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
dc65c307 2532})
9db1d521 2533
4023fb28 2534(define_split
609e7e80
AK
2535 [(set (match_operand:DD_DF 0 "register_operand" "")
2536 (match_operand:DD_DF 1 "memory_operand" ""))]
9602b6a1 2537 "!TARGET_ZARCH && reload_completed
8e509cf9 2538 && !FP_REG_P (operands[0])
4023fb28 2539 && !s_operand (operands[1], VOIDmode)"
a41c6c53 2540 [(set (match_dup 0) (match_dup 1))]
a41c6c53 2541{
609e7e80 2542 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
a41c6c53
UW
2543 s390_load_address (addr, XEXP (operands[1], 0));
2544 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
2545})
2546
9db1d521 2547;
609e7e80 2548; mov(sf|sd) instruction pattern(s).
9db1d521
HP
2549;
2550
609e7e80
AK
2551(define_insn "mov<mode>"
2552 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
3e4be43f 2553 "=f,f,f,f,f,f,R,T,d,d,d,d,d,b,R,T,v,v,v,d,v,R")
609e7e80 2554 (match_operand:SD_SF 1 "general_operand"
3e4be43f 2555 " G,f,f,R,R,T,f,f,G,d,b,R,T,d,d,d,v,G,d,v,R,v"))]
4023fb28 2556 ""
9db1d521 2557 "@
65b1d8ea 2558 lzer\t%0
ae1c6198 2559 ldr\t%0,%1
d40c829f 2560 ler\t%0,%1
085261c8 2561 lde\t%0,%1
d40c829f
UW
2562 le\t%0,%1
2563 ley\t%0,%1
2564 ste\t%1,%0
2565 stey\t%1,%0
45e5214c 2566 lhi\t%0,0
d40c829f 2567 lr\t%0,%1
085261c8 2568 lrl\t%0,%1
d40c829f
UW
2569 l\t%0,%1
2570 ly\t%0,%1
085261c8 2571 strl\t%1,%0
d40c829f 2572 st\t%1,%0
085261c8
AK
2573 sty\t%1,%0
2574 vlr\t%v0,%v1
2575 vleif\t%v0,0
2576 vlvgf\t%v0,%1,0
2577 vlgvf\t%0,%v1,0
2578 vleg\t%0,%1,0
2579 vsteg\t%1,%0,0"
ae1c6198 2580 [(set_attr "op_type" "RRE,RR,RR,RXE,RX,RXY,RX,RXY,RI,RR,RIL,RX,RXY,RIL,RX,RXY,VRR,VRI,VRS,VRS,VRX,VRX")
085261c8
AK
2581 (set_attr "type" "fsimpsf,fsimpsf,fload<mode>,fload<mode>,fload<mode>,fload<mode>,
2582 fstore<mode>,fstore<mode>,*,lr,load,load,load,store,store,store,*,*,*,*,load,store")
2583 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,z10_rec,*,*,*,*,*,*")
3e4be43f 2584 (set_attr "cpu_facility" "z196,vec,*,vec,*,longdisp,*,longdisp,*,*,z10,*,longdisp,z10,*,longdisp,vec,vec,vec,vec,vec,vec")])
4023fb28 2585
9dc62c00
AK
2586;
2587; movcc instruction pattern
2588;
2589
2590(define_insn "movcc"
2591 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
5a3fe9b6 2592 (match_operand:CC 1 "nonimmediate_operand" " d,d,c,R,T,d,d"))]
9dc62c00
AK
2593 ""
2594 "@
2595 lr\t%0,%1
2596 tmh\t%1,12288
2597 ipm\t%0
a71f0749
DV
2598 l\t%0,%1
2599 ly\t%0,%1
2600 st\t%1,%0
2601 sty\t%1,%0"
8dd3b235 2602 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
a71f0749 2603 (set_attr "type" "lr,*,*,load,load,store,store")
3e4be43f 2604 (set_attr "cpu_facility" "*,*,*,*,longdisp,*,longdisp")
a71f0749 2605 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
65b1d8ea 2606 (set_attr "z196prop" "*,*,z196_ends,*,*,*,*")])
9dc62c00 2607
19b63d8e
UW
2608;
2609; Block move (MVC) patterns.
2610;
2611
2612(define_insn "*mvc"
2613 [(set (match_operand:BLK 0 "memory_operand" "=Q")
2614 (match_operand:BLK 1 "memory_operand" "Q"))
2615 (use (match_operand 2 "const_int_operand" "n"))]
2616 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 2617 "mvc\t%O0(%2,%R0),%S1"
b628bd8e 2618 [(set_attr "op_type" "SS")])
19b63d8e 2619
0a88561f
AK
2620; This splitter converts a QI to QI mode copy into a BLK mode copy in
2621; order to have it implemented with mvc.
2622
2623(define_split
2624 [(set (match_operand:QI 0 "memory_operand" "")
2625 (match_operand:QI 1 "memory_operand" ""))]
2626 "reload_completed"
2627 [(parallel
2628 [(set (match_dup 0) (match_dup 1))
2629 (use (const_int 1))])]
2630{
2631 operands[0] = adjust_address (operands[0], BLKmode, 0);
2632 operands[1] = adjust_address (operands[1], BLKmode, 0);
2633})
2634
2635
19b63d8e
UW
2636(define_peephole2
2637 [(parallel
2638 [(set (match_operand:BLK 0 "memory_operand" "")
2639 (match_operand:BLK 1 "memory_operand" ""))
2640 (use (match_operand 2 "const_int_operand" ""))])
2641 (parallel
2642 [(set (match_operand:BLK 3 "memory_operand" "")
2643 (match_operand:BLK 4 "memory_operand" ""))
2644 (use (match_operand 5 "const_int_operand" ""))])]
2645 "s390_offset_p (operands[0], operands[3], operands[2])
2646 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 2647 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 2648 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
2649 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2650 [(parallel
2651 [(set (match_dup 6) (match_dup 7))
2652 (use (match_dup 8))])]
2653 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2654 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2655 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2656
2657
9db1d521
HP
2658;
2659; load_multiple pattern(s).
2660;
22ea6b4f
UW
2661; ??? Due to reload problems with replacing registers inside match_parallel
2662; we currently support load_multiple/store_multiple only after reload.
2663;
9db1d521
HP
2664
2665(define_expand "load_multiple"
2666 [(match_par_dup 3 [(set (match_operand 0 "" "")
2667 (match_operand 1 "" ""))
2668 (use (match_operand 2 "" ""))])]
22ea6b4f 2669 "reload_completed"
9db1d521 2670{
ef4bddc2 2671 machine_mode mode;
9db1d521
HP
2672 int regno;
2673 int count;
2674 rtx from;
4023fb28 2675 int i, off;
9db1d521
HP
2676
2677 /* Support only loading a constant number of fixed-point registers from
2678 memory and only bother with this if more than two */
2679 if (GET_CODE (operands[2]) != CONST_INT
4023fb28 2680 || INTVAL (operands[2]) < 2
9db1d521
HP
2681 || INTVAL (operands[2]) > 16
2682 || GET_CODE (operands[1]) != MEM
2683 || GET_CODE (operands[0]) != REG
2684 || REGNO (operands[0]) >= 16)
2685 FAIL;
2686
2687 count = INTVAL (operands[2]);
2688 regno = REGNO (operands[0]);
c19ec8f9 2689 mode = GET_MODE (operands[0]);
9602b6a1 2690 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
c19ec8f9 2691 FAIL;
9db1d521
HP
2692
2693 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
b3a13419 2694 if (!can_create_pseudo_p ())
4023fb28
UW
2695 {
2696 if (GET_CODE (XEXP (operands[1], 0)) == REG)
2697 {
2698 from = XEXP (operands[1], 0);
2699 off = 0;
2700 }
2701 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2702 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2703 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2704 {
2705 from = XEXP (XEXP (operands[1], 0), 0);
2706 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2707 }
2708 else
2709 FAIL;
4023fb28
UW
2710 }
2711 else
2712 {
2713 from = force_reg (Pmode, XEXP (operands[1], 0));
2714 off = 0;
2715 }
9db1d521
HP
2716
2717 for (i = 0; i < count; i++)
2718 XVECEXP (operands[3], 0, i)
f7df4a84 2719 = gen_rtx_SET (gen_rtx_REG (mode, regno + i),
c19ec8f9 2720 change_address (operands[1], mode,
0a81f074
RS
2721 plus_constant (Pmode, from,
2722 off + i * GET_MODE_SIZE (mode))));
10bbf137 2723})
9db1d521
HP
2724
2725(define_insn "*load_multiple_di"
2726 [(match_parallel 0 "load_multiple_operation"
2727 [(set (match_operand:DI 1 "register_operand" "=r")
3e4be43f 2728 (match_operand:DI 2 "s_operand" "S"))])]
9602b6a1 2729 "reload_completed && TARGET_ZARCH"
9db1d521
HP
2730{
2731 int words = XVECLEN (operands[0], 0);
9db1d521 2732 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
fc0ea003 2733 return "lmg\t%1,%0,%S2";
10bbf137 2734}
d3632d41 2735 [(set_attr "op_type" "RSY")
4023fb28 2736 (set_attr "type" "lm")])
9db1d521
HP
2737
2738(define_insn "*load_multiple_si"
2739 [(match_parallel 0 "load_multiple_operation"
d3632d41
UW
2740 [(set (match_operand:SI 1 "register_operand" "=r,r")
2741 (match_operand:SI 2 "s_operand" "Q,S"))])]
22ea6b4f 2742 "reload_completed"
9db1d521
HP
2743{
2744 int words = XVECLEN (operands[0], 0);
9db1d521 2745 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
fc0ea003 2746 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
10bbf137 2747}
d3632d41 2748 [(set_attr "op_type" "RS,RSY")
3e4be43f 2749 (set_attr "cpu_facility" "*,longdisp")
4023fb28 2750 (set_attr "type" "lm")])
9db1d521
HP
2751
2752;
c7453384 2753; store multiple pattern(s).
9db1d521
HP
2754;
2755
2756(define_expand "store_multiple"
2757 [(match_par_dup 3 [(set (match_operand 0 "" "")
2758 (match_operand 1 "" ""))
2759 (use (match_operand 2 "" ""))])]
22ea6b4f 2760 "reload_completed"
9db1d521 2761{
ef4bddc2 2762 machine_mode mode;
9db1d521
HP
2763 int regno;
2764 int count;
2765 rtx to;
4023fb28 2766 int i, off;
9db1d521
HP
2767
2768 /* Support only storing a constant number of fixed-point registers to
2769 memory and only bother with this if more than two. */
2770 if (GET_CODE (operands[2]) != CONST_INT
4023fb28 2771 || INTVAL (operands[2]) < 2
9db1d521
HP
2772 || INTVAL (operands[2]) > 16
2773 || GET_CODE (operands[0]) != MEM
2774 || GET_CODE (operands[1]) != REG
2775 || REGNO (operands[1]) >= 16)
2776 FAIL;
2777
2778 count = INTVAL (operands[2]);
2779 regno = REGNO (operands[1]);
c19ec8f9 2780 mode = GET_MODE (operands[1]);
9602b6a1 2781 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
c19ec8f9 2782 FAIL;
9db1d521
HP
2783
2784 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
4023fb28 2785
b3a13419 2786 if (!can_create_pseudo_p ())
4023fb28
UW
2787 {
2788 if (GET_CODE (XEXP (operands[0], 0)) == REG)
2789 {
2790 to = XEXP (operands[0], 0);
2791 off = 0;
2792 }
2793 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2794 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2795 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2796 {
2797 to = XEXP (XEXP (operands[0], 0), 0);
2798 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2799 }
2800 else
2801 FAIL;
4023fb28 2802 }
c7453384 2803 else
4023fb28
UW
2804 {
2805 to = force_reg (Pmode, XEXP (operands[0], 0));
2806 off = 0;
2807 }
9db1d521
HP
2808
2809 for (i = 0; i < count; i++)
2810 XVECEXP (operands[3], 0, i)
f7df4a84 2811 = gen_rtx_SET (change_address (operands[0], mode,
0a81f074
RS
2812 plus_constant (Pmode, to,
2813 off + i * GET_MODE_SIZE (mode))),
c19ec8f9 2814 gen_rtx_REG (mode, regno + i));
10bbf137 2815})
9db1d521
HP
2816
2817(define_insn "*store_multiple_di"
2818 [(match_parallel 0 "store_multiple_operation"
3e4be43f 2819 [(set (match_operand:DI 1 "s_operand" "=S")
9db1d521 2820 (match_operand:DI 2 "register_operand" "r"))])]
9602b6a1 2821 "reload_completed && TARGET_ZARCH"
9db1d521
HP
2822{
2823 int words = XVECLEN (operands[0], 0);
9db1d521 2824 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
fc0ea003 2825 return "stmg\t%2,%0,%S1";
10bbf137 2826}
d3632d41 2827 [(set_attr "op_type" "RSY")
4023fb28 2828 (set_attr "type" "stm")])
9db1d521
HP
2829
2830
2831(define_insn "*store_multiple_si"
2832 [(match_parallel 0 "store_multiple_operation"
d3632d41
UW
2833 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2834 (match_operand:SI 2 "register_operand" "r,r"))])]
22ea6b4f 2835 "reload_completed"
9db1d521
HP
2836{
2837 int words = XVECLEN (operands[0], 0);
9db1d521 2838 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
fc0ea003 2839 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
10bbf137 2840}
d3632d41 2841 [(set_attr "op_type" "RS,RSY")
3e4be43f 2842 (set_attr "cpu_facility" "*,longdisp")
4023fb28 2843 (set_attr "type" "stm")])
9db1d521
HP
2844
2845;;
2846;; String instructions.
2847;;
2848
963fc8d0 2849(define_insn "*execute_rl"
2771c2f9 2850 [(match_parallel 0 "execute_operation"
963fc8d0
AK
2851 [(unspec [(match_operand 1 "register_operand" "a")
2852 (match_operand 2 "" "")
2853 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2854 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2855 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2856 "exrl\t%1,%3"
2857 [(set_attr "op_type" "RIL")
2858 (set_attr "type" "cs")])
2859
9bb86f41 2860(define_insn "*execute"
2771c2f9 2861 [(match_parallel 0 "execute_operation"
9bb86f41
UW
2862 [(unspec [(match_operand 1 "register_operand" "a")
2863 (match_operand:BLK 2 "memory_operand" "R")
2864 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2865 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2866 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2867 "ex\t%1,%2"
29a74354
UW
2868 [(set_attr "op_type" "RX")
2869 (set_attr "type" "cs")])
9bb86f41
UW
2870
2871
91d39d71
UW
2872;
2873; strlenM instruction pattern(s).
2874;
2875
9db2f16d 2876(define_expand "strlen<mode>"
085261c8
AK
2877 [(match_operand:P 0 "register_operand" "") ; result
2878 (match_operand:BLK 1 "memory_operand" "") ; input string
2879 (match_operand:SI 2 "immediate_operand" "") ; search character
2880 (match_operand:SI 3 "immediate_operand" "")] ; known alignment
2881 ""
2882{
2883 if (!TARGET_VX || operands[2] != const0_rtx)
2884 emit_insn (gen_strlen_srst<mode> (operands[0], operands[1],
2885 operands[2], operands[3]));
2886 else
2887 s390_expand_vec_strlen (operands[0], operands[1], operands[3]);
2888
2889 DONE;
2890})
2891
2892(define_expand "strlen_srst<mode>"
ccbdc0d4 2893 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2f7e5a0d 2894 (parallel
91d39d71 2895 [(set (match_dup 4)
9db2f16d 2896 (unspec:P [(const_int 0)
91d39d71 2897 (match_operand:BLK 1 "memory_operand" "")
ccbdc0d4 2898 (reg:SI 0)
91d39d71 2899 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
9db2f16d 2900 (clobber (scratch:P))
ae156f85 2901 (clobber (reg:CC CC_REGNUM))])
91d39d71 2902 (parallel
9db2f16d
AS
2903 [(set (match_operand:P 0 "register_operand" "")
2904 (minus:P (match_dup 4) (match_dup 5)))
ae156f85 2905 (clobber (reg:CC CC_REGNUM))])]
9db2f16d 2906 ""
91d39d71 2907{
9db2f16d
AS
2908 operands[4] = gen_reg_rtx (Pmode);
2909 operands[5] = gen_reg_rtx (Pmode);
91d39d71
UW
2910 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2911 operands[1] = replace_equiv_address (operands[1], operands[5]);
2912})
2913
9db2f16d
AS
2914(define_insn "*strlen<mode>"
2915 [(set (match_operand:P 0 "register_operand" "=a")
2916 (unspec:P [(match_operand:P 2 "general_operand" "0")
2917 (mem:BLK (match_operand:P 3 "register_operand" "1"))
ccbdc0d4 2918 (reg:SI 0)
91d39d71 2919 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
9db2f16d 2920 (clobber (match_scratch:P 1 "=a"))
ae156f85 2921 (clobber (reg:CC CC_REGNUM))]
9db2f16d 2922 ""
91d39d71 2923 "srst\t%0,%1\;jo\t.-4"
b628bd8e
UW
2924 [(set_attr "length" "8")
2925 (set_attr "type" "vs")])
91d39d71 2926
ccbdc0d4
AS
2927;
2928; cmpstrM instruction pattern(s).
2929;
2930
2931(define_expand "cmpstrsi"
2932 [(set (reg:SI 0) (const_int 0))
2933 (parallel
2934 [(clobber (match_operand 3 "" ""))
2935 (clobber (match_dup 4))
2936 (set (reg:CCU CC_REGNUM)
2937 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2938 (match_operand:BLK 2 "memory_operand" "")))
2939 (use (reg:SI 0))])
2940 (parallel
2941 [(set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 2942 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_STRCMPCC_TO_INT))
ccbdc0d4
AS
2943 (clobber (reg:CC CC_REGNUM))])]
2944 ""
2945{
2946 /* As the result of CMPINT is inverted compared to what we need,
2947 we have to swap the operands. */
2948 rtx op1 = operands[2];
2949 rtx op2 = operands[1];
2950 rtx addr1 = gen_reg_rtx (Pmode);
2951 rtx addr2 = gen_reg_rtx (Pmode);
2952
2953 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2954 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2955 operands[1] = replace_equiv_address_nv (op1, addr1);
2956 operands[2] = replace_equiv_address_nv (op2, addr2);
2957 operands[3] = addr1;
2958 operands[4] = addr2;
2959})
2960
2961(define_insn "*cmpstr<mode>"
2962 [(clobber (match_operand:P 0 "register_operand" "=d"))
2963 (clobber (match_operand:P 1 "register_operand" "=d"))
2964 (set (reg:CCU CC_REGNUM)
2965 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2966 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2967 (use (reg:SI 0))]
2968 ""
2969 "clst\t%0,%1\;jo\t.-4"
2970 [(set_attr "length" "8")
2971 (set_attr "type" "vs")])
9381e3f1 2972
742090fc
AS
2973;
2974; movstr instruction pattern.
2975;
2976
2977(define_expand "movstr"
4a7dec25
DV
2978 [(match_operand 0 "register_operand" "")
2979 (match_operand 1 "memory_operand" "")
2980 (match_operand 2 "memory_operand" "")]
2981 ""
2982{
2983 if (TARGET_64BIT)
2984 emit_insn (gen_movstrdi (operands[0], operands[1], operands[2]));
2985 else
2986 emit_insn (gen_movstrsi (operands[0], operands[1], operands[2]));
2987 DONE;
2988})
2989
2990(define_expand "movstr<P:mode>"
742090fc 2991 [(set (reg:SI 0) (const_int 0))
9381e3f1 2992 (parallel
742090fc
AS
2993 [(clobber (match_dup 3))
2994 (set (match_operand:BLK 1 "memory_operand" "")
2995 (match_operand:BLK 2 "memory_operand" ""))
4a7dec25
DV
2996 (set (match_operand:P 0 "register_operand" "")
2997 (unspec:P [(match_dup 1)
742090fc
AS
2998 (match_dup 2)
2999 (reg:SI 0)] UNSPEC_MVST))
3000 (clobber (reg:CC CC_REGNUM))])]
3001 ""
3002{
859a4c0e
AK
3003 rtx addr1, addr2;
3004
3005 if (TARGET_VX && optimize_function_for_speed_p (cfun))
3006 {
3007 s390_expand_vec_movstr (operands[0], operands[1], operands[2]);
3008 DONE;
3009 }
3010
3011 addr1 = gen_reg_rtx (Pmode);
3012 addr2 = gen_reg_rtx (Pmode);
742090fc
AS
3013
3014 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3015 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
3016 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3017 operands[2] = replace_equiv_address_nv (operands[2], addr2);
3018 operands[3] = addr2;
3019})
3020
3021(define_insn "*movstr"
3022 [(clobber (match_operand:P 2 "register_operand" "=d"))
3023 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
3024 (mem:BLK (match_operand:P 3 "register_operand" "2")))
3025 (set (match_operand:P 0 "register_operand" "=d")
4a7dec25 3026 (unspec:P [(mem:BLK (match_dup 1))
742090fc
AS
3027 (mem:BLK (match_dup 3))
3028 (reg:SI 0)] UNSPEC_MVST))
3029 (clobber (reg:CC CC_REGNUM))]
3030 ""
3031 "mvst\t%1,%2\;jo\t.-4"
3032 [(set_attr "length" "8")
3033 (set_attr "type" "vs")])
9381e3f1 3034
742090fc 3035
9db1d521 3036;
70128ad9 3037; movmemM instruction pattern(s).
9db1d521
HP
3038;
3039
9db2f16d 3040(define_expand "movmem<mode>"
963fc8d0
AK
3041 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
3042 (match_operand:BLK 1 "memory_operand" "")) ; source
3043 (use (match_operand:GPR 2 "general_operand" "")) ; count
a41c6c53
UW
3044 (match_operand 3 "" "")]
3045 ""
367d32f3
AK
3046{
3047 if (s390_expand_movmem (operands[0], operands[1], operands[2]))
3048 DONE;
3049 else
3050 FAIL;
3051})
9db1d521 3052
ecbe845e
UW
3053; Move a block that is up to 256 bytes in length.
3054; The block length is taken as (operands[2] % 256) + 1.
9db1d521 3055
70128ad9 3056(define_expand "movmem_short"
b9404c99
UW
3057 [(parallel
3058 [(set (match_operand:BLK 0 "memory_operand" "")
3059 (match_operand:BLK 1 "memory_operand" ""))
3060 (use (match_operand 2 "nonmemory_operand" ""))
9bb86f41 3061 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99
UW
3062 (clobber (match_dup 3))])]
3063 ""
3064 "operands[3] = gen_rtx_SCRATCH (Pmode);")
ecbe845e 3065
70128ad9 3066(define_insn "*movmem_short"
963fc8d0
AK
3067 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
3068 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
3069 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3070 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
1eae36f0
AK
3071 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3072 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
9bb86f41 3073 "#"
963fc8d0 3074 [(set_attr "type" "cs")
b5e0425c 3075 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
ecbe845e 3076
9bb86f41
UW
3077(define_split
3078 [(set (match_operand:BLK 0 "memory_operand" "")
3079 (match_operand:BLK 1 "memory_operand" ""))
3080 (use (match_operand 2 "const_int_operand" ""))
3081 (use (match_operand 3 "immediate_operand" ""))
3082 (clobber (scratch))]
3083 "reload_completed"
3084 [(parallel
3085 [(set (match_dup 0) (match_dup 1))
3086 (use (match_dup 2))])]
3087 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
9db1d521 3088
9bb86f41
UW
3089(define_split
3090 [(set (match_operand:BLK 0 "memory_operand" "")
3091 (match_operand:BLK 1 "memory_operand" ""))
3092 (use (match_operand 2 "register_operand" ""))
3093 (use (match_operand 3 "memory_operand" ""))
3094 (clobber (scratch))]
3095 "reload_completed"
3096 [(parallel
3097 [(unspec [(match_dup 2) (match_dup 3)
3098 (const_int 0)] UNSPEC_EXECUTE)
3099 (set (match_dup 0) (match_dup 1))
3100 (use (const_int 1))])]
3101 "")
3102
963fc8d0
AK
3103(define_split
3104 [(set (match_operand:BLK 0 "memory_operand" "")
3105 (match_operand:BLK 1 "memory_operand" ""))
3106 (use (match_operand 2 "register_operand" ""))
3107 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3108 (clobber (scratch))]
3109 "TARGET_Z10 && reload_completed"
3110 [(parallel
3111 [(unspec [(match_dup 2) (const_int 0)
3112 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3113 (set (match_dup 0) (match_dup 1))
3114 (use (const_int 1))])]
3115 "operands[3] = gen_label_rtx ();")
3116
9bb86f41
UW
3117(define_split
3118 [(set (match_operand:BLK 0 "memory_operand" "")
3119 (match_operand:BLK 1 "memory_operand" ""))
3120 (use (match_operand 2 "register_operand" ""))
3121 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3122 (clobber (match_operand 3 "register_operand" ""))]
3123 "reload_completed && TARGET_CPU_ZARCH"
3124 [(set (match_dup 3) (label_ref (match_dup 4)))
3125 (parallel
9381e3f1 3126 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
9bb86f41
UW
3127 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3128 (set (match_dup 0) (match_dup 1))
3129 (use (const_int 1))])]
3130 "operands[4] = gen_label_rtx ();")
3131
a41c6c53 3132; Move a block of arbitrary length.
9db1d521 3133
70128ad9 3134(define_expand "movmem_long"
b9404c99
UW
3135 [(parallel
3136 [(clobber (match_dup 2))
3137 (clobber (match_dup 3))
3138 (set (match_operand:BLK 0 "memory_operand" "")
3139 (match_operand:BLK 1 "memory_operand" ""))
3140 (use (match_operand 2 "general_operand" ""))
3141 (use (match_dup 3))
ae156f85 3142 (clobber (reg:CC CC_REGNUM))])]
b9404c99
UW
3143 ""
3144{
ef4bddc2
RS
3145 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3146 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
3147 rtx reg0 = gen_reg_rtx (dreg_mode);
3148 rtx reg1 = gen_reg_rtx (dreg_mode);
3149 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3150 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
b9404c99
UW
3151 rtx len0 = gen_lowpart (Pmode, reg0);
3152 rtx len1 = gen_lowpart (Pmode, reg1);
3153
c41c1387 3154 emit_clobber (reg0);
b9404c99
UW
3155 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3156 emit_move_insn (len0, operands[2]);
3157
c41c1387 3158 emit_clobber (reg1);
b9404c99
UW
3159 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3160 emit_move_insn (len1, operands[2]);
3161
3162 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3163 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3164 operands[2] = reg0;
3165 operands[3] = reg1;
3166})
3167
a1aed706
AS
3168(define_insn "*movmem_long"
3169 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3170 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3171 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3172 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
b9404c99
UW
3173 (use (match_dup 2))
3174 (use (match_dup 3))
ae156f85 3175 (clobber (reg:CC CC_REGNUM))]
9602b6a1
AK
3176 "TARGET_64BIT || !TARGET_ZARCH"
3177 "mvcle\t%0,%1,0\;jo\t.-4"
3178 [(set_attr "length" "8")
3179 (set_attr "type" "vs")])
3180
3181(define_insn "*movmem_long_31z"
3182 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3183 (clobber (match_operand:TI 1 "register_operand" "=d"))
3184 (set (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3185 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4)))
3186 (use (match_dup 2))
3187 (use (match_dup 3))
3188 (clobber (reg:CC CC_REGNUM))]
3189 "!TARGET_64BIT && TARGET_ZARCH"
d40c829f 3190 "mvcle\t%0,%1,0\;jo\t.-4"
b628bd8e
UW
3191 [(set_attr "length" "8")
3192 (set_attr "type" "vs")])
9db1d521 3193
638e37c2
WG
3194
3195;
3196; Test data class.
3197;
3198
0f67fa83
WG
3199(define_expand "signbit<mode>2"
3200 [(set (reg:CCZ CC_REGNUM)
9381e3f1
WG
3201 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3202 (match_dup 2)]
0f67fa83
WG
3203 UNSPEC_TDC_INSN))
3204 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3205 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
0f67fa83
WG
3206 "TARGET_HARD_FLOAT"
3207{
3208 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
3209})
3210
638e37c2
WG
3211(define_expand "isinf<mode>2"
3212 [(set (reg:CCZ CC_REGNUM)
9381e3f1
WG
3213 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3214 (match_dup 2)]
638e37c2
WG
3215 UNSPEC_TDC_INSN))
3216 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3217 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
142cd70f 3218 "TARGET_HARD_FLOAT"
638e37c2
WG
3219{
3220 operands[2] = GEN_INT (S390_TDC_INFINITY);
3221})
3222
085261c8
AK
3223; This extracts CC into a GPR properly shifted. The actual IPM
3224; instruction will be issued by reload. The constraint of operand 1
3225; forces reload to use a GPR. So reload will issue a movcc insn for
3226; copying CC into a GPR first.
5a3fe9b6 3227(define_insn_and_split "*cc_to_int"
085261c8 3228 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5a3fe9b6
AK
3229 (unspec:SI [(match_operand 1 "register_operand" "0")]
3230 UNSPEC_CC_TO_INT))]
3231 "operands != NULL"
3232 "#"
3233 "reload_completed"
3234 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
3235
638e37c2
WG
3236; This insn is used to generate all variants of the Test Data Class
3237; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
3238; is the register to be tested and the second one is the bit mask
9381e3f1 3239; specifying the required test(s).
638e37c2 3240;
be5de7a1 3241; tcxb, tcdb, tceb, tdcxt, tdcdt, tdcet
638e37c2
WG
3242(define_insn "*TDC_insn_<mode>"
3243 [(set (reg:CCZ CC_REGNUM)
9381e3f1 3244 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
638e37c2 3245 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
142cd70f 3246 "TARGET_HARD_FLOAT"
0387c142 3247 "t<_d>c<xde><bt>\t%0,%1"
638e37c2 3248 [(set_attr "op_type" "RXE")
9381e3f1 3249 (set_attr "type" "fsimp<mode>")])
638e37c2 3250
638e37c2
WG
3251
3252
9db1d521 3253;
57e84f18 3254; setmemM instruction pattern(s).
9db1d521
HP
3255;
3256
57e84f18 3257(define_expand "setmem<mode>"
a41c6c53 3258 [(set (match_operand:BLK 0 "memory_operand" "")
6d057022 3259 (match_operand:QI 2 "general_operand" ""))
9db2f16d 3260 (use (match_operand:GPR 1 "general_operand" ""))
57e84f18 3261 (match_operand 3 "" "")]
a41c6c53 3262 ""
6d057022 3263 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
9db1d521 3264
a41c6c53 3265; Clear a block that is up to 256 bytes in length.
b9404c99
UW
3266; The block length is taken as (operands[1] % 256) + 1.
3267
70128ad9 3268(define_expand "clrmem_short"
b9404c99
UW
3269 [(parallel
3270 [(set (match_operand:BLK 0 "memory_operand" "")
3271 (const_int 0))
3272 (use (match_operand 1 "nonmemory_operand" ""))
9bb86f41 3273 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99 3274 (clobber (match_dup 2))
ae156f85 3275 (clobber (reg:CC CC_REGNUM))])]
b9404c99
UW
3276 ""
3277 "operands[2] = gen_rtx_SCRATCH (Pmode);")
9db1d521 3278
70128ad9 3279(define_insn "*clrmem_short"
963fc8d0 3280 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
a41c6c53 3281 (const_int 0))
963fc8d0
AK
3282 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
3283 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
1eae36f0 3284 (clobber (match_scratch:P 3 "=X,X,X,&a"))
ae156f85 3285 (clobber (reg:CC CC_REGNUM))]
1eae36f0 3286 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)"
9bb86f41 3287 "#"
963fc8d0 3288 [(set_attr "type" "cs")
b5e0425c 3289 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
9bb86f41
UW
3290
3291(define_split
3292 [(set (match_operand:BLK 0 "memory_operand" "")
3293 (const_int 0))
3294 (use (match_operand 1 "const_int_operand" ""))
3295 (use (match_operand 2 "immediate_operand" ""))
3296 (clobber (scratch))
ae156f85 3297 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3298 "reload_completed"
3299 [(parallel
3300 [(set (match_dup 0) (const_int 0))
3301 (use (match_dup 1))
ae156f85 3302 (clobber (reg:CC CC_REGNUM))])]
9bb86f41 3303 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
9db1d521 3304
9bb86f41
UW
3305(define_split
3306 [(set (match_operand:BLK 0 "memory_operand" "")
3307 (const_int 0))
3308 (use (match_operand 1 "register_operand" ""))
3309 (use (match_operand 2 "memory_operand" ""))
3310 (clobber (scratch))
ae156f85 3311 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3312 "reload_completed"
3313 [(parallel
3314 [(unspec [(match_dup 1) (match_dup 2)
3315 (const_int 0)] UNSPEC_EXECUTE)
3316 (set (match_dup 0) (const_int 0))
3317 (use (const_int 1))
ae156f85 3318 (clobber (reg:CC CC_REGNUM))])]
9bb86f41 3319 "")
9db1d521 3320
963fc8d0
AK
3321(define_split
3322 [(set (match_operand:BLK 0 "memory_operand" "")
3323 (const_int 0))
3324 (use (match_operand 1 "register_operand" ""))
3325 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3326 (clobber (scratch))
3327 (clobber (reg:CC CC_REGNUM))]
3328 "TARGET_Z10 && reload_completed"
3329 [(parallel
3330 [(unspec [(match_dup 1) (const_int 0)
3331 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3332 (set (match_dup 0) (const_int 0))
3333 (use (const_int 1))
3334 (clobber (reg:CC CC_REGNUM))])]
3335 "operands[3] = gen_label_rtx ();")
3336
9bb86f41
UW
3337(define_split
3338 [(set (match_operand:BLK 0 "memory_operand" "")
3339 (const_int 0))
3340 (use (match_operand 1 "register_operand" ""))
3341 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3342 (clobber (match_operand 2 "register_operand" ""))
ae156f85 3343 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3344 "reload_completed && TARGET_CPU_ZARCH"
3345 [(set (match_dup 2) (label_ref (match_dup 3)))
3346 (parallel
9381e3f1 3347 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
9bb86f41
UW
3348 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3349 (set (match_dup 0) (const_int 0))
3350 (use (const_int 1))
ae156f85 3351 (clobber (reg:CC CC_REGNUM))])]
9bb86f41
UW
3352 "operands[3] = gen_label_rtx ();")
3353
9381e3f1 3354; Initialize a block of arbitrary length with (operands[2] % 256).
b9404c99 3355
da0dcab1 3356(define_expand "setmem_long_<P:mode>"
b9404c99
UW
3357 [(parallel
3358 [(clobber (match_dup 1))
3359 (set (match_operand:BLK 0 "memory_operand" "")
dd95128b 3360 (unspec:BLK [(match_operand:P 2 "setmem_operand" "")
da0dcab1 3361 (match_dup 4)] UNSPEC_REPLICATE_BYTE))
6d057022 3362 (use (match_dup 3))
ae156f85 3363 (clobber (reg:CC CC_REGNUM))])]
b9404c99 3364 ""
a41c6c53 3365{
ef4bddc2
RS
3366 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3367 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
3368 rtx reg0 = gen_reg_rtx (dreg_mode);
3369 rtx reg1 = gen_reg_rtx (dreg_mode);
3370 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
b9404c99 3371 rtx len0 = gen_lowpart (Pmode, reg0);
9db1d521 3372
c41c1387 3373 emit_clobber (reg0);
b9404c99
UW
3374 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3375 emit_move_insn (len0, operands[1]);
9db1d521 3376
b9404c99 3377 emit_move_insn (reg1, const0_rtx);
a41c6c53 3378
b9404c99
UW
3379 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3380 operands[1] = reg0;
6d057022 3381 operands[3] = reg1;
da0dcab1 3382 operands[4] = gen_lowpart (Pmode, operands[1]);
b9404c99 3383})
a41c6c53 3384
da0dcab1
DV
3385; Patterns for 31 bit + Esa and 64 bit + Zarch.
3386
db340c73 3387(define_insn "*setmem_long"
a1aed706 3388 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
6d057022 3389 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
dd95128b 3390 (unspec:BLK [(match_operand:P 2 "setmem_operand" "Y")
da0dcab1
DV
3391 (subreg:P (match_dup 3) <modesize>)]
3392 UNSPEC_REPLICATE_BYTE))
a1aed706 3393 (use (match_operand:<DBL> 1 "register_operand" "d"))
ae156f85 3394 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3395 "TARGET_64BIT || !TARGET_ZARCH"
6d057022 3396 "mvcle\t%0,%1,%Y2\;jo\t.-4"
b628bd8e
UW
3397 [(set_attr "length" "8")
3398 (set_attr "type" "vs")])
9db1d521 3399
db340c73
AK
3400(define_insn "*setmem_long_and"
3401 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3402 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3403 (unspec:BLK [(and:P
dd95128b 3404 (match_operand:P 2 "setmem_operand" "Y")
db340c73
AK
3405 (match_operand:P 4 "const_int_operand" "n"))
3406 (subreg:P (match_dup 3) <modesize>)]
3407 UNSPEC_REPLICATE_BYTE))
3408 (use (match_operand:<DBL> 1 "register_operand" "d"))
3409 (clobber (reg:CC CC_REGNUM))]
3410 "(TARGET_64BIT || !TARGET_ZARCH) &&
3411 (INTVAL (operands[4]) & 255) == 255"
3412 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3413 [(set_attr "length" "8")
3414 (set_attr "type" "vs")])
3415
da0dcab1
DV
3416; Variants for 31 bit + Zarch, necessary because of the odd in-register offsets
3417; of the SImode subregs.
3418
db340c73 3419(define_insn "*setmem_long_31z"
9602b6a1
AK
3420 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3421 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
dd95128b 3422 (unspec:BLK [(match_operand:SI 2 "setmem_operand" "Y")
da0dcab1 3423 (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
9602b6a1
AK
3424 (use (match_operand:TI 1 "register_operand" "d"))
3425 (clobber (reg:CC CC_REGNUM))]
3426 "!TARGET_64BIT && TARGET_ZARCH"
4989e88a
AK
3427 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3428 [(set_attr "length" "8")
3429 (set_attr "type" "vs")])
9602b6a1 3430
db340c73
AK
3431(define_insn "*setmem_long_and_31z"
3432 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3433 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
3434 (unspec:BLK [(and:SI
dd95128b
AK
3435 (match_operand:SI 2 "setmem_operand" "Y")
3436 (match_operand:SI 4 "const_int_operand" "n"))
db340c73
AK
3437 (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
3438 (use (match_operand:TI 1 "register_operand" "d"))
3439 (clobber (reg:CC CC_REGNUM))]
3440 "(!TARGET_64BIT && TARGET_ZARCH) &&
3441 (INTVAL (operands[4]) & 255) == 255"
3442 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3443 [(set_attr "length" "8")
3444 (set_attr "type" "vs")])
3445
9db1d521 3446;
358b8f01 3447; cmpmemM instruction pattern(s).
9db1d521
HP
3448;
3449
358b8f01 3450(define_expand "cmpmemsi"
a41c6c53
UW
3451 [(set (match_operand:SI 0 "register_operand" "")
3452 (compare:SI (match_operand:BLK 1 "memory_operand" "")
3453 (match_operand:BLK 2 "memory_operand" "") ) )
3454 (use (match_operand:SI 3 "general_operand" ""))
3455 (use (match_operand:SI 4 "" ""))]
3456 ""
367d32f3
AK
3457{
3458 if (s390_expand_cmpmem (operands[0], operands[1],
3459 operands[2], operands[3]))
3460 DONE;
3461 else
3462 FAIL;
3463})
9db1d521 3464
a41c6c53
UW
3465; Compare a block that is up to 256 bytes in length.
3466; The block length is taken as (operands[2] % 256) + 1.
9db1d521 3467
b9404c99
UW
3468(define_expand "cmpmem_short"
3469 [(parallel
ae156f85 3470 [(set (reg:CCU CC_REGNUM)
5b022de5 3471 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
b9404c99
UW
3472 (match_operand:BLK 1 "memory_operand" "")))
3473 (use (match_operand 2 "nonmemory_operand" ""))
9bb86f41 3474 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99
UW
3475 (clobber (match_dup 3))])]
3476 ""
3477 "operands[3] = gen_rtx_SCRATCH (Pmode);")
9db1d521 3478
b9404c99 3479(define_insn "*cmpmem_short"
ae156f85 3480 [(set (reg:CCU CC_REGNUM)
963fc8d0
AK
3481 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
3482 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
3483 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3484 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
1eae36f0
AK
3485 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3486 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
9bb86f41 3487 "#"
963fc8d0 3488 [(set_attr "type" "cs")
b5e0425c 3489 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
9db1d521 3490
9bb86f41 3491(define_split
ae156f85 3492 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3493 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3494 (match_operand:BLK 1 "memory_operand" "")))
3495 (use (match_operand 2 "const_int_operand" ""))
3496 (use (match_operand 3 "immediate_operand" ""))
3497 (clobber (scratch))]
3498 "reload_completed"
3499 [(parallel
ae156f85 3500 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3501 (use (match_dup 2))])]
3502 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
9db1d521 3503
9bb86f41 3504(define_split
ae156f85 3505 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3506 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3507 (match_operand:BLK 1 "memory_operand" "")))
3508 (use (match_operand 2 "register_operand" ""))
3509 (use (match_operand 3 "memory_operand" ""))
3510 (clobber (scratch))]
3511 "reload_completed"
3512 [(parallel
3513 [(unspec [(match_dup 2) (match_dup 3)
3514 (const_int 0)] UNSPEC_EXECUTE)
ae156f85 3515 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3516 (use (const_int 1))])]
3517 "")
3518
963fc8d0
AK
3519(define_split
3520 [(set (reg:CCU CC_REGNUM)
3521 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3522 (match_operand:BLK 1 "memory_operand" "")))
3523 (use (match_operand 2 "register_operand" ""))
3524 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3525 (clobber (scratch))]
3526 "TARGET_Z10 && reload_completed"
3527 [(parallel
3528 [(unspec [(match_dup 2) (const_int 0)
3529 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3530 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3531 (use (const_int 1))])]
3532 "operands[4] = gen_label_rtx ();")
3533
9bb86f41 3534(define_split
ae156f85 3535 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3536 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3537 (match_operand:BLK 1 "memory_operand" "")))
3538 (use (match_operand 2 "register_operand" ""))
3539 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3540 (clobber (match_operand 3 "register_operand" ""))]
3541 "reload_completed && TARGET_CPU_ZARCH"
3542 [(set (match_dup 3) (label_ref (match_dup 4)))
3543 (parallel
9381e3f1 3544 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
9bb86f41 3545 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
ae156f85 3546 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3547 (use (const_int 1))])]
3548 "operands[4] = gen_label_rtx ();")
3549
a41c6c53 3550; Compare a block of arbitrary length.
9db1d521 3551
b9404c99
UW
3552(define_expand "cmpmem_long"
3553 [(parallel
3554 [(clobber (match_dup 2))
3555 (clobber (match_dup 3))
ae156f85 3556 (set (reg:CCU CC_REGNUM)
5b022de5 3557 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
b9404c99
UW
3558 (match_operand:BLK 1 "memory_operand" "")))
3559 (use (match_operand 2 "general_operand" ""))
3560 (use (match_dup 3))])]
3561 ""
3562{
ef4bddc2
RS
3563 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3564 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
3565 rtx reg0 = gen_reg_rtx (dreg_mode);
3566 rtx reg1 = gen_reg_rtx (dreg_mode);
3567 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3568 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
b9404c99
UW
3569 rtx len0 = gen_lowpart (Pmode, reg0);
3570 rtx len1 = gen_lowpart (Pmode, reg1);
3571
c41c1387 3572 emit_clobber (reg0);
b9404c99
UW
3573 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3574 emit_move_insn (len0, operands[2]);
3575
c41c1387 3576 emit_clobber (reg1);
b9404c99
UW
3577 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3578 emit_move_insn (len1, operands[2]);
3579
3580 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3581 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3582 operands[2] = reg0;
3583 operands[3] = reg1;
3584})
3585
a1aed706
AS
3586(define_insn "*cmpmem_long"
3587 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3588 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
ae156f85 3589 (set (reg:CCU CC_REGNUM)
a1aed706
AS
3590 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3591 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
f8766020
HP
3592 (use (match_dup 2))
3593 (use (match_dup 3))]
9602b6a1 3594 "TARGET_64BIT || !TARGET_ZARCH"
287ff198 3595 "clcle\t%0,%1,0\;jo\t.-4"
b628bd8e
UW
3596 [(set_attr "length" "8")
3597 (set_attr "type" "vs")])
9db1d521 3598
9602b6a1
AK
3599(define_insn "*cmpmem_long_31z"
3600 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3601 (clobber (match_operand:TI 1 "register_operand" "=d"))
3602 (set (reg:CCU CC_REGNUM)
3603 (compare:CCU (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3604 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4))))
3605 (use (match_dup 2))
3606 (use (match_dup 3))]
3607 "!TARGET_64BIT && TARGET_ZARCH"
3608 "clcle\t%0,%1,0\;jo\t.-4"
3609 [(set_attr "op_type" "NN")
3610 (set_attr "type" "vs")
3611 (set_attr "length" "8")])
3612
02887425
UW
3613; Convert CCUmode condition code to integer.
3614; Result is zero if EQ, positive if LTU, negative if GTU.
9db1d521 3615
02887425 3616(define_insn_and_split "cmpint"
9db1d521 3617 [(set (match_operand:SI 0 "register_operand" "=d")
02887425 3618 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3619 UNSPEC_STRCMPCC_TO_INT))
ae156f85 3620 (clobber (reg:CC CC_REGNUM))]
9db1d521 3621 ""
02887425
UW
3622 "#"
3623 "reload_completed"
3624 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3625 (parallel
3626 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
ae156f85 3627 (clobber (reg:CC CC_REGNUM))])])
02887425
UW
3628
3629(define_insn_and_split "*cmpint_cc"
ae156f85 3630 [(set (reg CC_REGNUM)
02887425 3631 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3632 UNSPEC_STRCMPCC_TO_INT)
02887425
UW
3633 (const_int 0)))
3634 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3635 (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT))]
02887425
UW
3636 "s390_match_ccmode (insn, CCSmode)"
3637 "#"
3638 "&& reload_completed"
3639 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3640 (parallel
3641 [(set (match_dup 2) (match_dup 3))
3642 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
9db1d521 3643{
02887425
UW
3644 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3645 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3646 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3647})
9db1d521 3648
02887425 3649(define_insn_and_split "*cmpint_sign"
9db1d521 3650 [(set (match_operand:DI 0 "register_operand" "=d")
02887425 3651 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3652 UNSPEC_STRCMPCC_TO_INT)))
ae156f85 3653 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3654 "TARGET_ZARCH"
02887425
UW
3655 "#"
3656 "&& reload_completed"
3657 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3658 (parallel
3659 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
ae156f85 3660 (clobber (reg:CC CC_REGNUM))])])
02887425
UW
3661
3662(define_insn_and_split "*cmpint_sign_cc"
ae156f85 3663 [(set (reg CC_REGNUM)
9381e3f1 3664 (compare (ashiftrt:DI (ashift:DI (subreg:DI
02887425 3665 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3666 UNSPEC_STRCMPCC_TO_INT) 0)
02887425
UW
3667 (const_int 32)) (const_int 32))
3668 (const_int 0)))
3669 (set (match_operand:DI 0 "register_operand" "=d")
5a3fe9b6 3670 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT)))]
9602b6a1 3671 "s390_match_ccmode (insn, CCSmode) && TARGET_ZARCH"
02887425
UW
3672 "#"
3673 "&& reload_completed"
3674 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3675 (parallel
3676 [(set (match_dup 2) (match_dup 3))
3677 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
9db1d521 3678{
02887425
UW
3679 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3680 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3681 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3682})
9db1d521 3683
4023fb28 3684
9db1d521
HP
3685;;
3686;;- Conversion instructions.
3687;;
3688
6fa05db6 3689(define_insn "*sethighpartsi"
d3632d41 3690 [(set (match_operand:SI 0 "register_operand" "=d,d")
6fa05db6
AS
3691 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3692 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
ae156f85 3693 (clobber (reg:CC CC_REGNUM))]
4023fb28 3694 ""
d3632d41 3695 "@
6fa05db6
AS
3696 icm\t%0,%2,%S1
3697 icmy\t%0,%2,%S1"
9381e3f1 3698 [(set_attr "op_type" "RS,RSY")
3e4be43f 3699 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 3700 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4023fb28 3701
6fa05db6 3702(define_insn "*sethighpartdi_64"
4023fb28 3703 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 3704 (unspec:DI [(match_operand:BLK 1 "s_operand" "S")
6fa05db6 3705 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
ae156f85 3706 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3707 "TARGET_ZARCH"
6fa05db6 3708 "icmh\t%0,%2,%S1"
729e750f
WG
3709 [(set_attr "op_type" "RSY")
3710 (set_attr "z10prop" "z10_super")])
4023fb28 3711
6fa05db6 3712(define_insn "*sethighpartdi_31"
d3632d41 3713 [(set (match_operand:DI 0 "register_operand" "=d,d")
6fa05db6
AS
3714 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3715 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
ae156f85 3716 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3717 "!TARGET_ZARCH"
d3632d41 3718 "@
6fa05db6
AS
3719 icm\t%0,%2,%S1
3720 icmy\t%0,%2,%S1"
9381e3f1 3721 [(set_attr "op_type" "RS,RSY")
3e4be43f 3722 (set_attr "cpu_facility" "*,longdisp")
9381e3f1
WG
3723 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3724
1a2e356e
RH
3725;
3726; extv instruction patterns
3727;
3728
3729; FIXME: This expander needs to be converted from DI to GPR as well
3730; after resolving some issues with it.
3731
3732(define_expand "extzv"
3733 [(parallel
3734 [(set (match_operand:DI 0 "register_operand" "=d")
3735 (zero_extract:DI
3736 (match_operand:DI 1 "register_operand" "d")
3737 (match_operand 2 "const_int_operand" "") ; size
3738 (match_operand 3 "const_int_operand" ""))) ; start
3739 (clobber (reg:CC CC_REGNUM))])]
3740 "TARGET_Z10"
3741{
3742 /* Starting with zEC12 there is risbgn not clobbering CC. */
3743 if (TARGET_ZEC12)
3744 {
3745 emit_move_insn (operands[0],
3746 gen_rtx_ZERO_EXTRACT (DImode,
3747 operands[1],
3748 operands[2],
3749 operands[3]));
3750 DONE;
3751 }
3752})
3753
64c744b9 3754(define_insn "*extzv<mode><clobbercc_or_nocc>"
1a2e356e
RH
3755 [(set (match_operand:GPR 0 "register_operand" "=d")
3756 (zero_extract:GPR
3757 (match_operand:GPR 1 "register_operand" "d")
3758 (match_operand 2 "const_int_operand" "") ; size
64c744b9
DV
3759 (match_operand 3 "const_int_operand" ""))) ; start
3760 ]
3761 "<z10_or_zEC12_cond>"
3762 "<risbg_n>\t%0,%1,64-%2,128+63,<bitoff_plus>%3+%2" ; dst, src, start, end, shift
3763 [(set_attr "op_type" "RIE")
3764 (set_attr "z10prop" "z10_super_E1")])
1a2e356e 3765
64c744b9
DV
3766; 64 bit: (a & -16) | ((b >> 8) & 15)
3767(define_insn "*extzvdi<clobbercc_or_nocc>_lshiftrt"
3768 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3769 (match_operand 1 "const_int_operand" "") ; size
3770 (match_operand 2 "const_int_operand" "")) ; start
3771 (lshiftrt:DI (match_operand:DI 3 "register_operand" "d")
3772 (match_operand:DI 4 "nonzero_shift_count_operand" "")))]
3773 "<z10_or_zEC12_cond>
3774 && 64 - UINTVAL (operands[4]) >= UINTVAL (operands[1])"
3775 "<risbg_n>\t%0,%3,%2,%2+%1-1,128-%2-%1-%4"
3776 [(set_attr "op_type" "RIE")
3777 (set_attr "z10prop" "z10_super_E1")])
3778
3779; 32 bit: (a & -16) | ((b >> 8) & 15)
3780(define_insn "*<risbg_n>_ior_and_sr_ze"
3781 [(set (match_operand:SI 0 "register_operand" "=d")
3782 (ior:SI (and:SI
3783 (match_operand:SI 1 "register_operand" "0")
3784 (match_operand:SI 2 "const_int_operand" ""))
3785 (subreg:SI
3786 (zero_extract:DI
3787 (match_operand:DI 3 "register_operand" "d")
3788 (match_operand 4 "const_int_operand" "") ; size
3789 (match_operand 5 "const_int_operand" "")) ; start
3790 4)))]
3791 "<z10_or_zEC12_cond>
3792 && UINTVAL (operands[2]) == (~(0ULL) << UINTVAL (operands[4]))"
3793 "<risbg_n>\t%0,%3,64-%4,63,%4+%5"
3794 [(set_attr "op_type" "RIE")
3795 (set_attr "z10prop" "z10_super_E1")])
3796
3797; ((int)foo >> 10) & 1;
3798(define_insn "*extract1bitdi<clobbercc_or_nocc>"
3799 [(set (match_operand:DI 0 "register_operand" "=d")
3800 (ne:DI (zero_extract:DI
3801 (match_operand:DI 1 "register_operand" "d")
3802 (const_int 1) ; size
3803 (match_operand 2 "const_int_operand" "")) ; start
3804 (const_int 0)))]
3805 "<z10_or_zEC12_cond>"
3806 "<risbg_n>\t%0,%1,64-1,128+63,%2+1" ; dst, src, start, end, shift
3807 [(set_attr "op_type" "RIE")
3808 (set_attr "z10prop" "z10_super_E1")])
3809
3810(define_insn "*<risbg_n>_and_subregdi_rotr"
3811 [(set (match_operand:DI 0 "register_operand" "=d")
3812 (and:DI (subreg:DI
3813 (rotate:SINT (match_operand:SINT 1 "register_operand" "d")
3814 (match_operand:SINT 2 "const_int_operand" "")) 0)
3815 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3816 "<z10_or_zEC12_cond>
3817 && UINTVAL (operands[3]) < (1ULL << (UINTVAL (operands[2]) & 0x3f))"
3818 "<risbg_n>\t%0,%1,%s3,128+%e3,<bitoff_plus>%2" ; dst, src, start, end, shift
3819 [(set_attr "op_type" "RIE")
3820 (set_attr "z10prop" "z10_super_E1")])
3821
3822(define_insn "*<risbg_n>_and_subregdi_rotl"
3823 [(set (match_operand:DI 0 "register_operand" "=d")
3824 (and:DI (subreg:DI
3825 (rotate:SINT (match_operand:SINT 1 "register_operand" "d")
3826 (match_operand:SINT 2 "const_int_operand" "")) 0)
3827 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3828 "<z10_or_zEC12_cond>
3829 && !(UINTVAL (operands[3]) & ((1ULL << (UINTVAL (operands[2]) & 0x3f)) - 1))"
3830 "<risbg_n>\t%0,%1,%s3,128+%e3,%2" ; dst, src, start, end, shift
3831 [(set_attr "op_type" "RIE")
3832 (set_attr "z10prop" "z10_super_E1")])
3833
3834(define_insn "*<risbg_n>_di_and_rot"
3835 [(set (match_operand:DI 0 "register_operand" "=d")
3836 (and:DI (rotate:DI (match_operand:DI 1 "register_operand" "d")
3837 (match_operand:DI 2 "const_int_operand" ""))
3838 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3839 "<z10_or_zEC12_cond>"
3840 "<risbg_n>\t%0,%1,%s3,128+%e3,%2" ; dst, src, start, end, shift
1a2e356e
RH
3841 [(set_attr "op_type" "RIE")
3842 (set_attr "z10prop" "z10_super_E1")])
4023fb28 3843
1a2e356e 3844(define_insn_and_split "*pre_z10_extzv<mode>"
6fa05db6 3845 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 3846 (zero_extract:GPR (match_operand:QI 1 "s_operand" "S")
1a2e356e 3847 (match_operand 2 "nonzero_shift_count_operand" "")
6fa05db6 3848 (const_int 0)))
ae156f85 3849 (clobber (reg:CC CC_REGNUM))]
1a2e356e 3850 "!TARGET_Z10"
cc7ab9b7
UW
3851 "#"
3852 "&& reload_completed"
4023fb28 3853 [(parallel
6fa05db6 3854 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
ae156f85 3855 (clobber (reg:CC CC_REGNUM))])
6fa05db6 3856 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
4023fb28 3857{
6fa05db6
AS
3858 int bitsize = INTVAL (operands[2]);
3859 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3860 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3861
3862 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 3863 set_mem_size (operands[1], size);
2542ef05 3864 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
6fa05db6 3865 operands[3] = GEN_INT (mask);
b628bd8e 3866})
4023fb28 3867
1a2e356e 3868(define_insn_and_split "*pre_z10_extv<mode>"
6fa05db6 3869 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 3870 (sign_extract:GPR (match_operand:QI 1 "s_operand" "S")
1a2e356e 3871 (match_operand 2 "nonzero_shift_count_operand" "")
6fa05db6 3872 (const_int 0)))
ae156f85 3873 (clobber (reg:CC CC_REGNUM))]
1a2e356e 3874 ""
cc7ab9b7
UW
3875 "#"
3876 "&& reload_completed"
4023fb28 3877 [(parallel
6fa05db6 3878 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
ae156f85 3879 (clobber (reg:CC CC_REGNUM))])
6fa05db6
AS
3880 (parallel
3881 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3882 (clobber (reg:CC CC_REGNUM))])]
3883{
3884 int bitsize = INTVAL (operands[2]);
3885 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3886 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3887
3888 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 3889 set_mem_size (operands[1], size);
2542ef05 3890 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
6fa05db6
AS
3891 operands[3] = GEN_INT (mask);
3892})
3893
3894;
3895; insv instruction patterns
3896;
3897
3898(define_expand "insv"
3899 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3900 (match_operand 1 "const_int_operand" "")
3901 (match_operand 2 "const_int_operand" ""))
3902 (match_operand 3 "general_operand" ""))]
3903 ""
4023fb28 3904{
6fa05db6
AS
3905 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3906 DONE;
3907 FAIL;
b628bd8e 3908})
4023fb28 3909
2542ef05
RH
3910
3911; The normal RTL expansion will never generate a zero_extract where
3912; the location operand isn't word mode. However, we do this in the
3913; back-end when generating atomic operations. See s390_two_part_insv.
64c744b9 3914(define_insn "*insv<mode><clobbercc_or_nocc>"
22ac2c2f 3915 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
2542ef05
RH
3916 (match_operand 1 "const_int_operand" "I") ; size
3917 (match_operand 2 "const_int_operand" "I")) ; pos
22ac2c2f 3918 (match_operand:GPR 3 "nonimmediate_operand" "d"))]
64c744b9 3919 "<z10_or_zEC12_cond>
2542ef05 3920 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
64c744b9 3921 "<risbg_n>\t%0,%3,<bitoff_plus>%2,<bitoff_plus>%2+%1-1,<bitsize>-%2-%1"
9381e3f1
WG
3922 [(set_attr "op_type" "RIE")
3923 (set_attr "z10prop" "z10_super_E1")])
963fc8d0 3924
22ac2c2f
AK
3925; and op1 with a mask being 1 for the selected bits and 0 for the rest
3926; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
64c744b9
DV
3927(define_insn "*insv<mode><clobbercc_or_nocc>_noshift"
3928 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d")
3929 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d,0")
75ca1b39 3930 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
64c744b9 3931 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0,d")
75ca1b39 3932 (match_operand:GPR 4 "const_int_operand" ""))))]
64c744b9
DV
3933 "<z10_or_zEC12_cond> && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3934 "@
3935 <risbg_n>\t%0,%1,%<bfstart>2,%<bfend>2,0
3936 <risbg_n>\t%0,%3,%<bfstart>4,%<bfend>4,0"
3937 [(set_attr "op_type" "RIE")
3938 (set_attr "z10prop" "z10_super_E1")])
22ac2c2f 3939
64c744b9
DV
3940(define_insn "*insv_z10_noshift_cc"
3941 [(set (reg CC_REGNUM)
3942 (compare
3943 (ior:DI
3944 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,0")
3945 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
3946 (and:DI (match_operand:DI 3 "nonimmediate_operand" "0,d")
3947 (match_operand:DI 4 "const_int_operand" "")))
3948 (const_int 0)))
3949 (set (match_operand:DI 0 "nonimmediate_operand" "=d,d")
3950 (ior:DI (and:DI (match_dup 1) (match_dup 2))
3951 (and:DI (match_dup 3) (match_dup 4))))]
3952 "TARGET_Z10 && s390_match_ccmode (insn, CCSmode)
3953 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3954 "@
3955 risbg\t%0,%1,%s2,%e2,0
3956 risbg\t%0,%3,%s4,%e4,0"
3957 [(set_attr "op_type" "RIE")
3958 (set_attr "z10prop" "z10_super_E1")])
3959
3960(define_insn "*insv_z10_noshift_cconly"
3961 [(set
3962 (reg CC_REGNUM)
3963 (compare
3964 (ior:DI
3965 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,0")
3966 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
3967 (and:DI (match_operand:DI 3 "nonimmediate_operand" "0,d")
3968 (match_operand:DI 4 "const_int_operand" "")))
3969 (const_int 0)))
3970 (clobber (match_scratch:DI 0 "=d,d"))]
3971 "TARGET_Z10 && s390_match_ccmode (insn, CCSmode)
3972 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3973 "@
3974 risbg\t%0,%1,%s2,%e2,0
3975 risbg\t%0,%3,%s4,%e4,0"
9381e3f1
WG
3976 [(set_attr "op_type" "RIE")
3977 (set_attr "z10prop" "z10_super_E1")])
963fc8d0 3978
3d44ff99
AK
3979; Implement appending Y on the left of S bits of X
3980; x = (y << s) | (x & ((1 << s) - 1))
64c744b9 3981(define_insn "*insv<mode><clobbercc_or_nocc>_appendbitsleft"
3d44ff99
AK
3982 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3983 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "0")
3984 (match_operand:GPR 2 "immediate_operand" ""))
3985 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "d")
3986 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
64c744b9
DV
3987 "<z10_or_zEC12_cond>
3988 && UINTVAL (operands[2]) == (1UL << UINTVAL (operands[4])) - 1"
3989 "<risbg_n>\t%0,%3,<bitoff>,64-%4-1,%4"
3d44ff99
AK
3990 [(set_attr "op_type" "RIE")
3991 (set_attr "z10prop" "z10_super_E1")])
3992
64c744b9
DV
3993; a = ((i32)a & -16777216) | (((ui32)b) >> 8)
3994(define_insn "*<risbg_n>_<mode>_ior_and_lshiftrt"
3995 [(set (match_operand:GPR 0 "register_operand" "=d")
3996 (ior:GPR (and:GPR
3997 (match_operand:GPR 1 "register_operand" "0")
3998 (match_operand:GPR 2 "const_int_operand" ""))
3999 (lshiftrt:GPR
4000 (match_operand:GPR 3 "register_operand" "d")
4001 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4002 "<z10_or_zEC12_cond> && UINTVAL (operands[2])
4003 == (~(0ULL) << (GET_MODE_BITSIZE (<MODE>mode) - UINTVAL (operands[4])))"
4004 "<risbg_n>\t%0,%3,<bitoff_plus>%4,63,64-%4"
4005 [(set_attr "op_type" "RIE")
4006 (set_attr "z10prop" "z10_super_E1")])
4007
4008; (ui32)(((ui64)x) >> 48) | ((i32)y & -65536);
4009(define_insn "*<risbg_n>_sidi_ior_and_lshiftrt"
4010 [(set (match_operand:SI 0 "register_operand" "=d")
4011 (ior:SI (and:SI
4012 (match_operand:SI 1 "register_operand" "0")
4013 (match_operand:SI 2 "const_int_operand" ""))
4014 (subreg:SI
4015 (lshiftrt:DI
4016 (match_operand:DI 3 "register_operand" "d")
4017 (match_operand:DI 4 "nonzero_shift_count_operand" "")) 4)))]
4018 "<z10_or_zEC12_cond>
4019 && UINTVAL (operands[2]) == ~(~(0ULL) >> UINTVAL (operands[4]))"
4020 "<risbg_n>\t%0,%3,%4,63,64-%4"
4021 [(set_attr "op_type" "RIE")
4022 (set_attr "z10prop" "z10_super_E1")])
4023
4024; (ui32)(((ui64)x) >> 12) & -4
4025(define_insn "*trunc_sidi_and_subreg_lshrt<clobbercc_or_nocc>"
4026 [(set (match_operand:SI 0 "register_operand" "=d")
4027 (and:SI
4028 (subreg:SI (lshiftrt:DI
4029 (match_operand:DI 1 "register_operand" "d")
4030 (match_operand:DI 2 "nonzero_shift_count_operand" "")) 4)
4031 (match_operand:SI 3 "contiguous_bitmask_nowrap_operand" "")))]
4032 "<z10_or_zEC12_cond>"
4033 "<risbg_n>\t%0,%1,%t3,128+%f3,64-%2"
3d44ff99
AK
4034 [(set_attr "op_type" "RIE")
4035 (set_attr "z10prop" "z10_super_E1")])
4036
4037; z = (x << c) | (y >> d) with (x << c) and (y >> d) not overlapping after shifting
4038; -> z = y >> d; z = (x << c) | (z & ((1 << c) - 1))
4039; -> z = y >> d; z = risbg;
4040
4041(define_split
4042 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
4043 (ior:GPR (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
4044 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4045 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "")
4046 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4047 "TARGET_ZEC12 && UINTVAL (operands[2]) + UINTVAL (operands[4]) >= <bitsize>"
1d11f7ce 4048 [(set (match_dup 6)
3d44ff99
AK
4049 (lshiftrt:GPR (match_dup 1) (match_dup 2)))
4050 (set (match_dup 0)
1d11f7ce 4051 (ior:GPR (and:GPR (match_dup 6) (match_dup 5))
3d44ff99
AK
4052 (ashift:GPR (match_dup 3) (match_dup 4))))]
4053{
4054 operands[5] = GEN_INT ((1UL << UINTVAL (operands[4])) - 1);
3168e073 4055 if (reg_overlap_mentioned_p (operands[0], operands[3]))
1d11f7ce
AK
4056 {
4057 if (!can_create_pseudo_p ())
4058 FAIL;
4059 operands[6] = gen_reg_rtx (<MODE>mode);
4060 }
4061 else
4062 operands[6] = operands[0];
3d44ff99
AK
4063})
4064
4065(define_split
4066 [(parallel
4067 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
4068 (ior:GPR (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
4069 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4070 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "")
4071 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))
4072 (clobber (reg:CC CC_REGNUM))])]
4073 "TARGET_Z10 && !TARGET_ZEC12 && UINTVAL (operands[2]) + UINTVAL (operands[4]) >= <bitsize>"
1d11f7ce 4074 [(set (match_dup 6)
3d44ff99
AK
4075 (lshiftrt:GPR (match_dup 1) (match_dup 2)))
4076 (parallel
4077 [(set (match_dup 0)
1d11f7ce 4078 (ior:GPR (and:GPR (match_dup 6) (match_dup 5))
3d44ff99
AK
4079 (ashift:GPR (match_dup 3) (match_dup 4))))
4080 (clobber (reg:CC CC_REGNUM))])]
4081{
4082 operands[5] = GEN_INT ((1UL << UINTVAL (operands[4])) - 1);
3168e073 4083 if (reg_overlap_mentioned_p (operands[0], operands[3]))
1d11f7ce
AK
4084 {
4085 if (!can_create_pseudo_p ())
4086 FAIL;
4087 operands[6] = gen_reg_rtx (<MODE>mode);
4088 }
4089 else
4090 operands[6] = operands[0];
3d44ff99
AK
4091})
4092
571e408a 4093(define_insn "*r<noxa>sbg_<mode>_noshift"
963fc8d0 4094 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
571e408a
RH
4095 (IXOR:GPR
4096 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
4097 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
4098 (match_operand:GPR 3 "nonimmediate_operand" "0")))
963fc8d0 4099 (clobber (reg:CC CC_REGNUM))]
75ca1b39 4100 "TARGET_Z10"
571e408a
RH
4101 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
4102 [(set_attr "op_type" "RIE")])
4103
4104(define_insn "*r<noxa>sbg_di_rotl"
4105 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4106 (IXOR:DI
4107 (and:DI
4108 (rotate:DI
4109 (match_operand:DI 1 "nonimmediate_operand" "d")
4110 (match_operand:DI 3 "const_int_operand" ""))
4111 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
4112 (match_operand:DI 4 "nonimmediate_operand" "0")))
4113 (clobber (reg:CC CC_REGNUM))]
4114 "TARGET_Z10"
4115 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%b3"
4116 [(set_attr "op_type" "RIE")])
4117
f3d90045 4118(define_insn "*r<noxa>sbg_<mode>_srl_bitmask"
571e408a
RH
4119 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4120 (IXOR:GPR
4121 (and:GPR
4122 (lshiftrt:GPR
4123 (match_operand:GPR 1 "nonimmediate_operand" "d")
4124 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
4125 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
4126 (match_operand:GPR 4 "nonimmediate_operand" "0")))
4127 (clobber (reg:CC CC_REGNUM))]
4128 "TARGET_Z10
4129 && s390_extzv_shift_ok (<bitsize>, 64 - INTVAL (operands[3]),
4130 INTVAL (operands[2]))"
4131 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,64-%3"
4132 [(set_attr "op_type" "RIE")])
4133
f3d90045 4134(define_insn "*r<noxa>sbg_<mode>_sll_bitmask"
571e408a
RH
4135 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4136 (IXOR:GPR
4137 (and:GPR
4138 (ashift:GPR
4139 (match_operand:GPR 1 "nonimmediate_operand" "d")
4140 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
4141 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
4142 (match_operand:GPR 4 "nonimmediate_operand" "0")))
4143 (clobber (reg:CC CC_REGNUM))]
4144 "TARGET_Z10
4145 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[3]),
4146 INTVAL (operands[2]))"
4147 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%3"
963fc8d0
AK
4148 [(set_attr "op_type" "RIE")])
4149
f3d90045
DV
4150;; unsigned {int,long} a, b
4151;; a = a | (b << const_int)
4152;; a = a ^ (b << const_int)
4153(define_insn "*r<noxa>sbg_<mode>_sll"
4154 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4155 (IXOR:GPR
4156 (ashift:GPR
4157 (match_operand:GPR 1 "nonimmediate_operand" "d")
4158 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4159 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4160 (clobber (reg:CC CC_REGNUM))]
4161 "TARGET_Z10"
576987fc 4162 "r<noxa>sbg\t%0,%1,<bitoff>,63-%2,%2"
f3d90045
DV
4163 [(set_attr "op_type" "RIE")])
4164
4165;; unsigned {int,long} a, b
4166;; a = a | (b >> const_int)
4167;; a = a ^ (b >> const_int)
4168(define_insn "*r<noxa>sbg_<mode>_srl"
4169 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4170 (IXOR:GPR
4171 (lshiftrt:GPR
4172 (match_operand:GPR 1 "nonimmediate_operand" "d")
4173 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4174 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4175 (clobber (reg:CC CC_REGNUM))]
4176 "TARGET_Z10"
576987fc 4177 "r<noxa>sbg\t%0,%1,<bitoff_plus>%2,63,64-%2"
f3d90045
DV
4178 [(set_attr "op_type" "RIE")])
4179
5bb33936
RH
4180;; These two are generated by combine for s.bf &= val.
4181;; ??? For bitfields smaller than 32-bits, we wind up with SImode
4182;; shifts and ands, which results in some truly awful patterns
4183;; including subregs of operations. Rather unnecessisarily, IMO.
4184;; Instead of
4185;;
4186;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
4187;; (const_int 24 [0x18])
4188;; (const_int 0 [0]))
4189;; (subreg:DI (and:SI (subreg:SI (lshiftrt:DI (reg/v:DI 50 [ s ])
4190;; (const_int 40 [0x28])) 4)
4191;; (reg:SI 4 %r4 [ y+4 ])) 0))
4192;;
4193;; we should instead generate
4194;;
4195;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
4196;; (const_int 24 [0x18])
4197;; (const_int 0 [0]))
4198;; (and:DI (lshiftrt:DI (reg/v:DI 50 [ s ])
4199;; (const_int 40 [0x28]))
4200;; (subreg:DI (reg:SI 4 %r4 [ y+4 ]) 0)))
4201;;
4202;; by noticing that we can push down the outer paradoxical subreg
4203;; into the operation.
4204
4205(define_insn "*insv_rnsbg_noshift"
4206 [(set (zero_extract:DI
4207 (match_operand:DI 0 "nonimmediate_operand" "+d")
4208 (match_operand 1 "const_int_operand" "")
4209 (match_operand 2 "const_int_operand" ""))
4210 (and:DI
4211 (match_dup 0)
4212 (match_operand:DI 3 "nonimmediate_operand" "d")))
4213 (clobber (reg:CC CC_REGNUM))]
4214 "TARGET_Z10
4215 && INTVAL (operands[1]) + INTVAL (operands[2]) == 64"
4216 "rnsbg\t%0,%3,%2,63,0"
4217 [(set_attr "op_type" "RIE")])
4218
4219(define_insn "*insv_rnsbg_srl"
4220 [(set (zero_extract:DI
4221 (match_operand:DI 0 "nonimmediate_operand" "+d")
4222 (match_operand 1 "const_int_operand" "")
4223 (match_operand 2 "const_int_operand" ""))
4224 (and:DI
4225 (lshiftrt:DI
4226 (match_dup 0)
4227 (match_operand 3 "const_int_operand" ""))
4228 (match_operand:DI 4 "nonimmediate_operand" "d")))
4229 (clobber (reg:CC CC_REGNUM))]
4230 "TARGET_Z10
4231 && INTVAL (operands[3]) == 64 - INTVAL (operands[1]) - INTVAL (operands[2])"
4232 "rnsbg\t%0,%4,%2,%2+%1-1,%3"
4233 [(set_attr "op_type" "RIE")])
4234
6fa05db6 4235(define_insn "*insv<mode>_mem_reg"
9602b6a1 4236 [(set (zero_extract:W (match_operand:QI 0 "memory_operand" "+Q,S")
6fa05db6
AS
4237 (match_operand 1 "const_int_operand" "n,n")
4238 (const_int 0))
9602b6a1 4239 (match_operand:W 2 "register_operand" "d,d"))]
6fa05db6
AS
4240 "INTVAL (operands[1]) > 0
4241 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
4242 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
4243{
4244 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
4245
4246 operands[1] = GEN_INT ((1ul << size) - 1);
9381e3f1 4247 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
6fa05db6
AS
4248 : "stcmy\t%2,%1,%S0";
4249}
9381e3f1 4250 [(set_attr "op_type" "RS,RSY")
3e4be43f 4251 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 4252 (set_attr "z10prop" "z10_super,z10_super")])
6fa05db6
AS
4253
4254(define_insn "*insvdi_mem_reghigh"
3e4be43f 4255 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+S")
6fa05db6
AS
4256 (match_operand 1 "const_int_operand" "n")
4257 (const_int 0))
4258 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
4259 (const_int 32)))]
9602b6a1 4260 "TARGET_ZARCH
6fa05db6
AS
4261 && INTVAL (operands[1]) > 0
4262 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
4263 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
4264{
4265 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
4266
4267 operands[1] = GEN_INT ((1ul << size) - 1);
4268 return "stcmh\t%2,%1,%S0";
4269}
9381e3f1
WG
4270[(set_attr "op_type" "RSY")
4271 (set_attr "z10prop" "z10_super")])
6fa05db6 4272
9602b6a1
AK
4273(define_insn "*insvdi_reg_imm"
4274 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4275 (const_int 16)
4276 (match_operand 1 "const_int_operand" "n"))
4277 (match_operand:DI 2 "const_int_operand" "n"))]
6fa05db6
AS
4278 "TARGET_ZARCH
4279 && INTVAL (operands[1]) >= 0
4280 && INTVAL (operands[1]) < BITS_PER_WORD
4281 && INTVAL (operands[1]) % 16 == 0"
4282{
4283 switch (BITS_PER_WORD - INTVAL (operands[1]))
4284 {
4285 case 64: return "iihh\t%0,%x2"; break;
4286 case 48: return "iihl\t%0,%x2"; break;
4287 case 32: return "iilh\t%0,%x2"; break;
4288 case 16: return "iill\t%0,%x2"; break;
4289 default: gcc_unreachable();
4290 }
4291}
9381e3f1
WG
4292 [(set_attr "op_type" "RI")
4293 (set_attr "z10prop" "z10_super_E1")])
4294
9fec758d
WG
4295; Update the left-most 32 bit of a DI.
4296(define_insn "*insv_h_di_reg_extimm"
4297 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4298 (const_int 32)
4299 (const_int 0))
4300 (match_operand:DI 1 "const_int_operand" "n"))]
4301 "TARGET_EXTIMM"
4302 "iihf\t%0,%o1"
4303 [(set_attr "op_type" "RIL")
4304 (set_attr "z10prop" "z10_fwd_E1")])
6fa05db6 4305
d378b983
RH
4306; Update the right-most 32 bit of a DI.
4307(define_insn "*insv_l_di_reg_extimm"
4308 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4309 (const_int 32)
4310 (const_int 32))
4311 (match_operand:DI 1 "const_int_operand" "n"))]
4312 "TARGET_EXTIMM"
4313 "iilf\t%0,%o1"
9381e3f1 4314 [(set_attr "op_type" "RIL")
9fec758d 4315 (set_attr "z10prop" "z10_fwd_A1")])
6fa05db6 4316
9db1d521
HP
4317;
4318; extendsidi2 instruction pattern(s).
4319;
4320
4023fb28
UW
4321(define_expand "extendsidi2"
4322 [(set (match_operand:DI 0 "register_operand" "")
4323 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
4324 ""
4023fb28 4325{
9602b6a1 4326 if (!TARGET_ZARCH)
4023fb28 4327 {
c41c1387 4328 emit_clobber (operands[0]);
9f37ccb1
UW
4329 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
4330 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
4331 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
4023fb28
UW
4332 DONE;
4333 }
ec24698e 4334})
4023fb28
UW
4335
4336(define_insn "*extendsidi2"
963fc8d0 4337 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3e4be43f 4338 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,T,b")))]
9602b6a1 4339 "TARGET_ZARCH"
9db1d521 4340 "@
d40c829f 4341 lgfr\t%0,%1
963fc8d0
AK
4342 lgf\t%0,%1
4343 lgfrl\t%0,%1"
4344 [(set_attr "op_type" "RRE,RXY,RIL")
4345 (set_attr "type" "*,*,larl")
9381e3f1
WG
4346 (set_attr "cpu_facility" "*,*,z10")
4347 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 4348
9db1d521 4349;
56477c21 4350; extend(hi|qi)(si|di)2 instruction pattern(s).
9db1d521
HP
4351;
4352
56477c21
AS
4353(define_expand "extend<HQI:mode><DSI:mode>2"
4354 [(set (match_operand:DSI 0 "register_operand" "")
4355 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4023fb28 4356 ""
4023fb28 4357{
9602b6a1 4358 if (<DSI:MODE>mode == DImode && !TARGET_ZARCH)
4023fb28
UW
4359 {
4360 rtx tmp = gen_reg_rtx (SImode);
56477c21 4361 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
4023fb28
UW
4362 emit_insn (gen_extendsidi2 (operands[0], tmp));
4363 DONE;
4364 }
ec24698e 4365 else if (!TARGET_EXTIMM)
4023fb28 4366 {
2542ef05 4367 rtx bitcount = GEN_INT (<DSI:bitsize> - <HQI:bitsize>);
56477c21
AS
4368
4369 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
4370 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
4371 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
4023fb28
UW
4372 DONE;
4373 }
ec24698e
UW
4374})
4375
56477c21
AS
4376;
4377; extendhidi2 instruction pattern(s).
4378;
4379
ec24698e 4380(define_insn "*extendhidi2_extimm"
963fc8d0 4381 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3e4be43f 4382 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,T,b")))]
9602b6a1 4383 "TARGET_ZARCH && TARGET_EXTIMM"
ec24698e
UW
4384 "@
4385 lghr\t%0,%1
963fc8d0
AK
4386 lgh\t%0,%1
4387 lghrl\t%0,%1"
4388 [(set_attr "op_type" "RRE,RXY,RIL")
4389 (set_attr "type" "*,*,larl")
9381e3f1
WG
4390 (set_attr "cpu_facility" "extimm,extimm,z10")
4391 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4023fb28
UW
4392
4393(define_insn "*extendhidi2"
9db1d521 4394 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 4395 (sign_extend:DI (match_operand:HI 1 "memory_operand" "T")))]
9602b6a1 4396 "TARGET_ZARCH"
d40c829f 4397 "lgh\t%0,%1"
9381e3f1
WG
4398 [(set_attr "op_type" "RXY")
4399 (set_attr "z10prop" "z10_super_E1")])
9db1d521 4400
9db1d521 4401;
56477c21 4402; extendhisi2 instruction pattern(s).
9db1d521
HP
4403;
4404
ec24698e 4405(define_insn "*extendhisi2_extimm"
963fc8d0
AK
4406 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4407 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
ec24698e
UW
4408 "TARGET_EXTIMM"
4409 "@
4410 lhr\t%0,%1
4411 lh\t%0,%1
963fc8d0
AK
4412 lhy\t%0,%1
4413 lhrl\t%0,%1"
4414 [(set_attr "op_type" "RRE,RX,RXY,RIL")
4415 (set_attr "type" "*,*,*,larl")
9381e3f1
WG
4416 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
4417 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 4418
4023fb28 4419(define_insn "*extendhisi2"
d3632d41
UW
4420 [(set (match_operand:SI 0 "register_operand" "=d,d")
4421 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
ec24698e 4422 "!TARGET_EXTIMM"
d3632d41 4423 "@
d40c829f
UW
4424 lh\t%0,%1
4425 lhy\t%0,%1"
9381e3f1 4426 [(set_attr "op_type" "RX,RXY")
3e4be43f 4427 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 4428 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521 4429
56477c21
AS
4430;
4431; extendqi(si|di)2 instruction pattern(s).
4432;
4433
43a09b63 4434; lbr, lgbr, lb, lgb
56477c21
AS
4435(define_insn "*extendqi<mode>2_extimm"
4436 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3e4be43f 4437 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,T")))]
ec24698e
UW
4438 "TARGET_EXTIMM"
4439 "@
56477c21
AS
4440 l<g>br\t%0,%1
4441 l<g>b\t%0,%1"
9381e3f1
WG
4442 [(set_attr "op_type" "RRE,RXY")
4443 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
ec24698e 4444
43a09b63 4445; lb, lgb
56477c21
AS
4446(define_insn "*extendqi<mode>2"
4447 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 4448 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "T")))]
56477c21
AS
4449 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
4450 "l<g>b\t%0,%1"
9381e3f1
WG
4451 [(set_attr "op_type" "RXY")
4452 (set_attr "z10prop" "z10_super_E1")])
d3632d41 4453
56477c21
AS
4454(define_insn_and_split "*extendqi<mode>2_short_displ"
4455 [(set (match_operand:GPR 0 "register_operand" "=d")
4456 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
ae156f85 4457 (clobber (reg:CC CC_REGNUM))]
56477c21 4458 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
19796784
AK
4459 "#"
4460 "&& reload_completed"
4023fb28 4461 [(parallel
56477c21 4462 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
ae156f85 4463 (clobber (reg:CC CC_REGNUM))])
4023fb28 4464 (parallel
56477c21 4465 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
ae156f85 4466 (clobber (reg:CC CC_REGNUM))])]
6fa05db6
AS
4467{
4468 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 4469 set_mem_size (operands[1], GET_MODE_SIZE (QImode));
2542ef05 4470 operands[2] = GEN_INT (<GPR:bitsize> - BITS_PER_UNIT);
6fa05db6 4471})
9db1d521 4472
9db1d521
HP
4473;
4474; zero_extendsidi2 instruction pattern(s).
4475;
4476
4023fb28
UW
4477(define_expand "zero_extendsidi2"
4478 [(set (match_operand:DI 0 "register_operand" "")
4479 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
4480 ""
4023fb28 4481{
9602b6a1 4482 if (!TARGET_ZARCH)
4023fb28 4483 {
c41c1387 4484 emit_clobber (operands[0]);
9f37ccb1
UW
4485 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
4486 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
4023fb28
UW
4487 DONE;
4488 }
ec24698e 4489})
4023fb28
UW
4490
4491(define_insn "*zero_extendsidi2"
963fc8d0 4492 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3e4be43f 4493 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,T,b")))]
9602b6a1 4494 "TARGET_ZARCH"
9db1d521 4495 "@
d40c829f 4496 llgfr\t%0,%1
963fc8d0
AK
4497 llgf\t%0,%1
4498 llgfrl\t%0,%1"
4499 [(set_attr "op_type" "RRE,RXY,RIL")
4500 (set_attr "type" "*,*,larl")
9381e3f1
WG
4501 (set_attr "cpu_facility" "*,*,z10")
4502 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
9db1d521 4503
288e517f
AK
4504;
4505; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
4506;
4507
d6083c7d
UW
4508(define_insn "*llgt_sidi"
4509 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 4510 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "T") 0)
d6083c7d 4511 (const_int 2147483647)))]
9602b6a1 4512 "TARGET_ZARCH"
d6083c7d 4513 "llgt\t%0,%1"
9381e3f1
WG
4514 [(set_attr "op_type" "RXE")
4515 (set_attr "z10prop" "z10_super_E1")])
d6083c7d
UW
4516
4517(define_insn_and_split "*llgt_sidi_split"
4518 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 4519 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "T") 0)
d6083c7d 4520 (const_int 2147483647)))
ae156f85 4521 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4522 "TARGET_ZARCH"
d6083c7d
UW
4523 "#"
4524 "&& reload_completed"
4525 [(set (match_dup 0)
4526 (and:DI (subreg:DI (match_dup 1) 0)
4527 (const_int 2147483647)))]
4528 "")
4529
288e517f
AK
4530(define_insn "*llgt_sisi"
4531 [(set (match_operand:SI 0 "register_operand" "=d,d")
3e4be43f 4532 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,T")
288e517f 4533 (const_int 2147483647)))]
c4d50129 4534 "TARGET_ZARCH"
288e517f
AK
4535 "@
4536 llgtr\t%0,%1
4537 llgt\t%0,%1"
9381e3f1
WG
4538 [(set_attr "op_type" "RRE,RXE")
4539 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
288e517f 4540
288e517f
AK
4541(define_insn "*llgt_didi"
4542 [(set (match_operand:DI 0 "register_operand" "=d,d")
4543 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
4544 (const_int 2147483647)))]
9602b6a1 4545 "TARGET_ZARCH"
288e517f
AK
4546 "@
4547 llgtr\t%0,%1
4548 llgt\t%0,%N1"
9381e3f1
WG
4549 [(set_attr "op_type" "RRE,RXE")
4550 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
288e517f 4551
f19a9af7 4552(define_split
9602b6a1
AK
4553 [(set (match_operand:DSI 0 "register_operand" "")
4554 (and:DSI (match_operand:DSI 1 "nonimmediate_operand" "")
f6ee577c 4555 (const_int 2147483647)))
ae156f85 4556 (clobber (reg:CC CC_REGNUM))]
c4d50129 4557 "TARGET_ZARCH && reload_completed"
288e517f 4558 [(set (match_dup 0)
9602b6a1 4559 (and:DSI (match_dup 1)
f6ee577c 4560 (const_int 2147483647)))]
288e517f
AK
4561 "")
4562
9db1d521 4563;
56477c21 4564; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
9db1d521
HP
4565;
4566
56477c21
AS
4567(define_expand "zero_extend<mode>di2"
4568 [(set (match_operand:DI 0 "register_operand" "")
4569 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4570 ""
4571{
9602b6a1 4572 if (!TARGET_ZARCH)
56477c21
AS
4573 {
4574 rtx tmp = gen_reg_rtx (SImode);
4575 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
4576 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
4577 DONE;
4578 }
4579 else if (!TARGET_EXTIMM)
4580 {
2542ef05 4581 rtx bitcount = GEN_INT (64 - <HQI:bitsize>);
56477c21
AS
4582 operands[1] = gen_lowpart (DImode, operands[1]);
4583 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
4584 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
4585 DONE;
4586 }
4587})
4588
f6ee577c 4589(define_expand "zero_extend<mode>si2"
4023fb28 4590 [(set (match_operand:SI 0 "register_operand" "")
ec24698e 4591 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
9db1d521 4592 ""
4023fb28 4593{
ec24698e
UW
4594 if (!TARGET_EXTIMM)
4595 {
4596 operands[1] = gen_lowpart (SImode, operands[1]);
9381e3f1 4597 emit_insn (gen_andsi3 (operands[0], operands[1],
2542ef05 4598 GEN_INT ((1 << <HQI:bitsize>) - 1)));
ec24698e 4599 DONE;
56477c21 4600 }
ec24698e
UW
4601})
4602
963fc8d0
AK
4603; llhrl, llghrl
4604(define_insn "*zero_extendhi<mode>2_z10"
4605 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
3e4be43f 4606 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,T,b")))]
963fc8d0
AK
4607 "TARGET_Z10"
4608 "@
4609 ll<g>hr\t%0,%1
4610 ll<g>h\t%0,%1
4611 ll<g>hrl\t%0,%1"
4612 [(set_attr "op_type" "RXY,RRE,RIL")
4613 (set_attr "type" "*,*,larl")
9381e3f1 4614 (set_attr "cpu_facility" "*,*,z10")
729e750f 4615 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
963fc8d0 4616
43a09b63 4617; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
56477c21
AS
4618(define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
4619 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3e4be43f 4620 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,T")))]
ec24698e
UW
4621 "TARGET_EXTIMM"
4622 "@
56477c21
AS
4623 ll<g><hc>r\t%0,%1
4624 ll<g><hc>\t%0,%1"
9381e3f1
WG
4625 [(set_attr "op_type" "RRE,RXY")
4626 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
9db1d521 4627
43a09b63 4628; llgh, llgc
56477c21
AS
4629(define_insn "*zero_extend<HQI:mode><GPR:mode>2"
4630 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 4631 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "T")))]
ec24698e 4632 "TARGET_ZARCH && !TARGET_EXTIMM"
f6ee577c 4633 "llg<hc>\t%0,%1"
9381e3f1
WG
4634 [(set_attr "op_type" "RXY")
4635 (set_attr "z10prop" "z10_fwd_A3")])
cc7ab9b7
UW
4636
4637(define_insn_and_split "*zero_extendhisi2_31"
4638 [(set (match_operand:SI 0 "register_operand" "=&d")
3e4be43f 4639 (zero_extend:SI (match_operand:HI 1 "s_operand" "S")))
ae156f85 4640 (clobber (reg:CC CC_REGNUM))]
f4f41b4e 4641 "!TARGET_ZARCH"
cc7ab9b7
UW
4642 "#"
4643 "&& reload_completed"
4644 [(set (match_dup 0) (const_int 0))
4645 (parallel
4646 [(set (strict_low_part (match_dup 2)) (match_dup 1))
ae156f85 4647 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 4648 "operands[2] = gen_lowpart (HImode, operands[0]);")
c7453384 4649
cc7ab9b7
UW
4650(define_insn_and_split "*zero_extendqisi2_31"
4651 [(set (match_operand:SI 0 "register_operand" "=&d")
3e4be43f 4652 (zero_extend:SI (match_operand:QI 1 "memory_operand" "T")))]
9e8327e3 4653 "!TARGET_ZARCH"
cc7ab9b7
UW
4654 "#"
4655 "&& reload_completed"
4656 [(set (match_dup 0) (const_int 0))
4657 (set (strict_low_part (match_dup 2)) (match_dup 1))]
b628bd8e 4658 "operands[2] = gen_lowpart (QImode, operands[0]);")
c7453384 4659
9db1d521
HP
4660;
4661; zero_extendqihi2 instruction pattern(s).
4662;
4663
9db1d521
HP
4664(define_expand "zero_extendqihi2"
4665 [(set (match_operand:HI 0 "register_operand" "")
4023fb28 4666 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
ec24698e 4667 "TARGET_ZARCH && !TARGET_EXTIMM"
9db1d521 4668{
4023fb28
UW
4669 operands[1] = gen_lowpart (HImode, operands[1]);
4670 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
4671 DONE;
ec24698e 4672})
9db1d521 4673
4023fb28 4674(define_insn "*zero_extendqihi2_64"
9db1d521 4675 [(set (match_operand:HI 0 "register_operand" "=d")
3e4be43f 4676 (zero_extend:HI (match_operand:QI 1 "memory_operand" "T")))]
ec24698e 4677 "TARGET_ZARCH && !TARGET_EXTIMM"
d40c829f 4678 "llgc\t%0,%1"
9381e3f1
WG
4679 [(set_attr "op_type" "RXY")
4680 (set_attr "z10prop" "z10_fwd_A3")])
9db1d521 4681
cc7ab9b7
UW
4682(define_insn_and_split "*zero_extendqihi2_31"
4683 [(set (match_operand:HI 0 "register_operand" "=&d")
3e4be43f 4684 (zero_extend:HI (match_operand:QI 1 "memory_operand" "T")))]
9e8327e3 4685 "!TARGET_ZARCH"
cc7ab9b7
UW
4686 "#"
4687 "&& reload_completed"
4688 [(set (match_dup 0) (const_int 0))
4689 (set (strict_low_part (match_dup 2)) (match_dup 1))]
b628bd8e 4690 "operands[2] = gen_lowpart (QImode, operands[0]);")
cc7ab9b7 4691
609e7e80
AK
4692;
4693; fixuns_trunc(dd|td)di2 instruction pattern(s).
4694;
4695
4696(define_expand "fixuns_truncdddi2"
4697 [(parallel
4698 [(set (match_operand:DI 0 "register_operand" "")
4699 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
ae8e301e 4700 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
65b1d8ea 4701 (clobber (reg:CC CC_REGNUM))])]
9381e3f1 4702
fb068247 4703 "TARGET_HARD_DFP"
609e7e80 4704{
65b1d8ea
AK
4705 if (!TARGET_Z196)
4706 {
19f8b229
TS
4707 rtx_code_label *label1 = gen_label_rtx ();
4708 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4709 rtx temp = gen_reg_rtx (TDmode);
4710 REAL_VALUE_TYPE cmp, sub;
4711
4712 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4713 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4714
4715 /* 2^63 can't be represented as 64bit DFP number with full precision. The
4716 solution is doing the check and the subtraction in TD mode and using a
4717 TD -> DI convert afterwards. */
4718 emit_insn (gen_extendddtd2 (temp, operands[1]));
4719 temp = force_reg (TDmode, temp);
4720 emit_cmp_and_jump_insns (temp,
555affd7 4721 const_double_from_real_value (cmp, TDmode),
65b1d8ea
AK
4722 LT, NULL_RTX, VOIDmode, 0, label1);
4723 emit_insn (gen_subtd3 (temp, temp,
555affd7 4724 const_double_from_real_value (sub, TDmode)));
ae8e301e
AK
4725 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp,
4726 GEN_INT (DFP_RND_TOWARD_MINF)));
65b1d8ea
AK
4727 emit_jump (label2);
4728
4729 emit_label (label1);
ae8e301e
AK
4730 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1],
4731 GEN_INT (DFP_RND_TOWARD_0)));
65b1d8ea
AK
4732 emit_label (label2);
4733 DONE;
4734 }
609e7e80
AK
4735})
4736
4737(define_expand "fixuns_trunctddi2"
65b1d8ea
AK
4738 [(parallel
4739 [(set (match_operand:DI 0 "register_operand" "")
4740 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))
ae8e301e 4741 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
65b1d8ea
AK
4742 (clobber (reg:CC CC_REGNUM))])]
4743
fb068247 4744 "TARGET_HARD_DFP"
609e7e80 4745{
65b1d8ea
AK
4746 if (!TARGET_Z196)
4747 {
19f8b229
TS
4748 rtx_code_label *label1 = gen_label_rtx ();
4749 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4750 rtx temp = gen_reg_rtx (TDmode);
4751 REAL_VALUE_TYPE cmp, sub;
4752
4753 operands[1] = force_reg (TDmode, operands[1]);
4754 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4755 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4756
4757 emit_cmp_and_jump_insns (operands[1],
555affd7 4758 const_double_from_real_value (cmp, TDmode),
65b1d8ea
AK
4759 LT, NULL_RTX, VOIDmode, 0, label1);
4760 emit_insn (gen_subtd3 (temp, operands[1],
555affd7 4761 const_double_from_real_value (sub, TDmode)));
ae8e301e
AK
4762 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp,
4763 GEN_INT (DFP_RND_TOWARD_MINF)));
65b1d8ea
AK
4764 emit_jump (label2);
4765
4766 emit_label (label1);
ae8e301e
AK
4767 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1],
4768 GEN_INT (DFP_RND_TOWARD_0)));
65b1d8ea
AK
4769 emit_label (label2);
4770 DONE;
4771 }
609e7e80 4772})
cc7ab9b7 4773
9db1d521 4774;
65b1d8ea 4775; fixuns_trunc(sf|df|tf)(si|di)2 and fix_trunc(sf|df|tf)(si|di)2
609e7e80 4776; instruction pattern(s).
9db1d521
HP
4777;
4778
7b6baae1 4779(define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
65b1d8ea
AK
4780 [(parallel
4781 [(set (match_operand:GPR 0 "register_operand" "")
4782 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))
ae8e301e 4783 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
65b1d8ea 4784 (clobber (reg:CC CC_REGNUM))])]
142cd70f 4785 "TARGET_HARD_FLOAT"
9db1d521 4786{
65b1d8ea
AK
4787 if (!TARGET_Z196)
4788 {
19f8b229
TS
4789 rtx_code_label *label1 = gen_label_rtx ();
4790 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4791 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
4792 REAL_VALUE_TYPE cmp, sub;
4793
4794 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
2542ef05
RH
4795 real_2expN (&cmp, <GPR:bitsize> - 1, <BFP:MODE>mode);
4796 real_2expN (&sub, <GPR:bitsize>, <BFP:MODE>mode);
65b1d8ea
AK
4797
4798 emit_cmp_and_jump_insns (operands[1],
555affd7 4799 const_double_from_real_value (cmp, <BFP:MODE>mode),
65b1d8ea
AK
4800 LT, NULL_RTX, VOIDmode, 0, label1);
4801 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
555affd7 4802 const_double_from_real_value (sub, <BFP:MODE>mode)));
65b1d8ea 4803 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
ae8e301e 4804 GEN_INT (BFP_RND_TOWARD_MINF)));
65b1d8ea
AK
4805 emit_jump (label2);
4806
4807 emit_label (label1);
4808 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
ae8e301e 4809 operands[1], GEN_INT (BFP_RND_TOWARD_0)));
65b1d8ea
AK
4810 emit_label (label2);
4811 DONE;
4812 }
10bbf137 4813})
9db1d521 4814
65b1d8ea
AK
4815; fixuns_trunc(td|dd)si2 expander
4816(define_expand "fixuns_trunc<mode>si2"
4817 [(parallel
4818 [(set (match_operand:SI 0 "register_operand" "")
4819 (unsigned_fix:SI (match_operand:DFP 1 "register_operand" "")))
ae8e301e 4820 (unspec:SI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
65b1d8ea 4821 (clobber (reg:CC CC_REGNUM))])]
8540e6e8 4822 "TARGET_Z196 && TARGET_HARD_DFP"
65b1d8ea
AK
4823 "")
4824
4825; fixuns_trunc(tf|df|sf|td|dd)(di|si)2 instruction patterns.
4826
6e5b5de8
AK
4827(define_insn "*fixuns_truncdfdi2_z13"
4828 [(set (match_operand:DI 0 "register_operand" "=d,v")
4829 (unsigned_fix:DI (match_operand:DF 1 "register_operand" "f,v")))
4830 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K,K")] UNSPEC_ROUND)
4831 (clobber (reg:CC CC_REGNUM))]
a579871b 4832 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
4833 "@
4834 clgdbr\t%0,%h2,%1,0
4835 wclgdb\t%v0,%v1,0,%h2"
4836 [(set_attr "op_type" "RRF,VRR")
4837 (set_attr "type" "ftoi")])
4838
65b1d8ea
AK
4839; clfebr, clfdbr, clfxbr, clgebr, clgdbr, clgxbr
4840; clfdtr, clfxtr, clgdtr, clgxtr
4841(define_insn "*fixuns_trunc<FP:mode><GPR:mode>2_z196"
6e5b5de8
AK
4842 [(set (match_operand:GPR 0 "register_operand" "=d")
4843 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "f")))
4844 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
65b1d8ea 4845 (clobber (reg:CC CC_REGNUM))]
6e5b5de8 4846 "TARGET_Z196 && TARGET_HARD_FLOAT
a579871b 4847 && (!TARGET_VX || <GPR:MODE>mode != DImode || <FP:MODE>mode != DFmode)"
65b1d8ea
AK
4848 "cl<GPR:gf><FP:xde><FP:bt>r\t%0,%h2,%1,0"
4849 [(set_attr "op_type" "RRF")
4850 (set_attr "type" "ftoi")])
4851
b60cb710
AK
4852(define_expand "fix_trunc<DSF:mode><GPR:mode>2"
4853 [(set (match_operand:GPR 0 "register_operand" "")
4854 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
4855 "TARGET_HARD_FLOAT"
9db1d521 4856{
b60cb710 4857 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
ae8e301e 4858 GEN_INT (BFP_RND_TOWARD_0)));
9db1d521 4859 DONE;
10bbf137 4860})
9db1d521 4861
6e5b5de8
AK
4862(define_insn "*fix_truncdfdi2_bfp_z13"
4863 [(set (match_operand:DI 0 "register_operand" "=d,v")
4864 (fix:DI (match_operand:DF 1 "register_operand" "f,v")))
4865 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K,K")] UNSPEC_ROUND)
4866 (clobber (reg:CC CC_REGNUM))]
a579871b 4867 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
4868 "@
4869 cgdbr\t%0,%h2,%1
4870 wcgdb\t%v0,%v1,0,%h2"
4871 [(set_attr "op_type" "RRE,VRR")
4872 (set_attr "type" "ftoi")])
4873
43a09b63 4874; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
6e5b5de8
AK
4875(define_insn "*fix_trunc<BFP:mode><GPR:mode>2_bfp"
4876 [(set (match_operand:GPR 0 "register_operand" "=d")
4877 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
4878 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
ae156f85 4879 (clobber (reg:CC CC_REGNUM))]
6e5b5de8
AK
4880 "TARGET_HARD_FLOAT
4881 && (!TARGET_VX || <GPR:MODE>mode != DImode || <BFP:MODE>mode != DFmode)"
7b6baae1 4882 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
9db1d521 4883 [(set_attr "op_type" "RRE")
077dab3b 4884 (set_attr "type" "ftoi")])
9db1d521 4885
6e5b5de8
AK
4886(define_expand "fix_trunc<BFP:mode><GPR:mode>2_bfp"
4887 [(parallel
4888 [(set (match_operand:GPR 0 "register_operand" "=d")
4889 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
4890 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4891 (clobber (reg:CC CC_REGNUM))])]
4892 "TARGET_HARD_FLOAT")
609e7e80
AK
4893;
4894; fix_trunc(td|dd)di2 instruction pattern(s).
4895;
4896
99cd7dd0
AK
4897(define_expand "fix_trunc<mode>di2"
4898 [(set (match_operand:DI 0 "register_operand" "")
4899 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
9602b6a1 4900 "TARGET_ZARCH && TARGET_HARD_DFP"
99cd7dd0
AK
4901{
4902 operands[1] = force_reg (<MODE>mode, operands[1]);
4903 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
ae8e301e 4904 GEN_INT (DFP_RND_TOWARD_0)));
99cd7dd0
AK
4905 DONE;
4906})
4907
609e7e80 4908; cgxtr, cgdtr
99cd7dd0 4909(define_insn "fix_trunc<DFP:mode>di2_dfp"
609e7e80
AK
4910 [(set (match_operand:DI 0 "register_operand" "=d")
4911 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
4912 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
4913 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4914 "TARGET_ZARCH && TARGET_HARD_DFP"
609e7e80
AK
4915 "cg<DFP:xde>tr\t%0,%h2,%1"
4916 [(set_attr "op_type" "RRF")
9381e3f1 4917 (set_attr "type" "ftoidfp")])
609e7e80
AK
4918
4919
f61a2c7d
AK
4920;
4921; fix_trunctf(si|di)2 instruction pattern(s).
4922;
4923
4924(define_expand "fix_trunctf<mode>2"
4925 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
4926 (fix:GPR (match_operand:TF 1 "register_operand" "")))
ae8e301e 4927 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
f61a2c7d 4928 (clobber (reg:CC CC_REGNUM))])]
9db1d521 4929 "TARGET_HARD_FLOAT"
142cd70f 4930 "")
9db1d521 4931
9db1d521 4932
9db1d521 4933;
142cd70f 4934; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
9db1d521
HP
4935;
4936
609e7e80 4937; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
f5905b37 4938(define_insn "floatdi<mode>2"
62d3f261
AK
4939 [(set (match_operand:FP 0 "register_operand" "=f,v")
4940 (float:FP (match_operand:DI 1 "register_operand" "d,v")))]
9602b6a1 4941 "TARGET_ZARCH && TARGET_HARD_FLOAT"
6e5b5de8
AK
4942 "@
4943 c<xde>g<bt>r\t%0,%1
4944 wcdgb\t%v0,%v1,0,0"
4945 [(set_attr "op_type" "RRE,VRR")
4946 (set_attr "type" "itof<mode>" )
62d3f261
AK
4947 (set_attr "cpu_facility" "*,vec")
4948 (set_attr "enabled" "*,<DFDI>")])
9db1d521 4949
43a09b63 4950; cxfbr, cdfbr, cefbr
142cd70f 4951(define_insn "floatsi<mode>2"
7b6baae1
AK
4952 [(set (match_operand:BFP 0 "register_operand" "=f")
4953 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
142cd70f 4954 "TARGET_HARD_FLOAT"
f61a2c7d
AK
4955 "c<xde>fbr\t%0,%1"
4956 [(set_attr "op_type" "RRE")
9381e3f1 4957 (set_attr "type" "itof<mode>" )])
f61a2c7d 4958
65b1d8ea
AK
4959; cxftr, cdftr
4960(define_insn "floatsi<mode>2"
4961 [(set (match_operand:DFP 0 "register_operand" "=f")
4962 (float:DFP (match_operand:SI 1 "register_operand" "d")))]
4963 "TARGET_Z196 && TARGET_HARD_FLOAT"
4964 "c<xde>ftr\t%0,0,%1,0"
4965 [(set_attr "op_type" "RRE")
4966 (set_attr "type" "itof<mode>" )])
4967
4968;
4969; floatuns(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
4970;
4971
6e5b5de8
AK
4972(define_insn "*floatunsdidf2_z13"
4973 [(set (match_operand:DF 0 "register_operand" "=f,v")
4974 (unsigned_float:DF (match_operand:DI 1 "register_operand" "d,v")))]
a579871b 4975 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
4976 "@
4977 cdlgbr\t%0,0,%1,0
4978 wcdlgb\t%v0,%v1,0,0"
4979 [(set_attr "op_type" "RRE,VRR")
4980 (set_attr "type" "itofdf")])
4981
65b1d8ea
AK
4982; cxlgbr, cdlgbr, celgbr, cxlgtr, cdlgtr
4983; cxlfbr, cdlfbr, celfbr, cxlftr, cdlftr
6e5b5de8
AK
4984(define_insn "*floatuns<GPR:mode><FP:mode>2"
4985 [(set (match_operand:FP 0 "register_operand" "=f")
4986 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "d")))]
4987 "TARGET_Z196 && TARGET_HARD_FLOAT
4988 && (!TARGET_VX || <FP:MODE>mode != DFmode || <GPR:MODE>mode != DImode)"
65b1d8ea
AK
4989 "c<FP:xde>l<GPR:gf><FP:bt>r\t%0,0,%1,0"
4990 [(set_attr "op_type" "RRE")
6e5b5de8
AK
4991 (set_attr "type" "itof<FP:mode>")])
4992
4993(define_expand "floatuns<GPR:mode><FP:mode>2"
4994 [(set (match_operand:FP 0 "register_operand" "")
4995 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "")))]
4996 "TARGET_Z196 && TARGET_HARD_FLOAT")
f61a2c7d 4997
9db1d521
HP
4998;
4999; truncdfsf2 instruction pattern(s).
5000;
5001
142cd70f 5002(define_insn "truncdfsf2"
6e5b5de8
AK
5003 [(set (match_operand:SF 0 "register_operand" "=f,v")
5004 (float_truncate:SF (match_operand:DF 1 "register_operand" "f,v")))]
142cd70f 5005 "TARGET_HARD_FLOAT"
6e5b5de8
AK
5006 "@
5007 ledbr\t%0,%1
5008 wledb\t%v0,%v1,0,0" ; IEEE inexact exception not suppressed
5009 ; According to BFP rounding mode
5010 [(set_attr "op_type" "RRE,VRR")
5011 (set_attr "type" "ftruncdf")
5012 (set_attr "cpu_facility" "*,vec")])
9db1d521 5013
f61a2c7d 5014;
142cd70f 5015; trunctf(df|sf)2 instruction pattern(s).
f61a2c7d
AK
5016;
5017
142cd70f
AK
5018; ldxbr, lexbr
5019(define_insn "trunctf<mode>2"
5020 [(set (match_operand:DSF 0 "register_operand" "=f")
5021 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
f61a2c7d 5022 (clobber (match_scratch:TF 2 "=f"))]
142cd70f
AK
5023 "TARGET_HARD_FLOAT"
5024 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
f61a2c7d 5025 [(set_attr "length" "6")
9381e3f1 5026 (set_attr "type" "ftrunctf")])
f61a2c7d 5027
609e7e80
AK
5028;
5029; trunctddd2 and truncddsd2 instruction pattern(s).
5030;
5031
432d4670
AK
5032
5033(define_expand "trunctddd2"
5034 [(parallel
5035 [(set (match_operand:DD 0 "register_operand" "")
5036 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
5037 (unspec:DI [(const_int DFP_RND_CURRENT)] UNSPEC_ROUND)
5038 (clobber (scratch:TD))])]
5039 "TARGET_HARD_DFP")
5040
5041(define_insn "*trunctddd2"
609e7e80 5042 [(set (match_operand:DD 0 "register_operand" "=f")
bf259a77 5043 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
432d4670
AK
5044 (unspec:DI [(match_operand:DI 2 "const_mask_operand" "I")] UNSPEC_ROUND)
5045 (clobber (match_scratch:TD 3 "=f"))]
fb068247 5046 "TARGET_HARD_DFP"
432d4670 5047 "ldxtr\t%3,%2,%1,0\;ldr\t%0,%3"
bf259a77 5048 [(set_attr "length" "6")
9381e3f1 5049 (set_attr "type" "ftruncdd")])
609e7e80
AK
5050
5051(define_insn "truncddsd2"
5052 [(set (match_operand:SD 0 "register_operand" "=f")
5053 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
fb068247 5054 "TARGET_HARD_DFP"
609e7e80
AK
5055 "ledtr\t%0,0,%1,0"
5056 [(set_attr "op_type" "RRF")
9381e3f1 5057 (set_attr "type" "ftruncsd")])
609e7e80 5058
feade5a8
AK
5059(define_expand "trunctdsd2"
5060 [(parallel
5061 [(set (match_dup 3)
5062 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
432d4670 5063 (unspec:DI [(const_int DFP_RND_PREP_FOR_SHORT_PREC)] UNSPEC_ROUND)
feade5a8
AK
5064 (clobber (match_scratch:TD 2 ""))])
5065 (set (match_operand:SD 0 "register_operand" "")
5066 (float_truncate:SD (match_dup 3)))]
5067 "TARGET_HARD_DFP"
5068{
5069 operands[3] = gen_reg_rtx (DDmode);
5070})
5071
9db1d521 5072;
142cd70f 5073; extend(sf|df)(df|tf)2 instruction pattern(s).
f61a2c7d
AK
5074;
5075
6e5b5de8
AK
5076(define_insn "*extendsfdf2_z13"
5077 [(set (match_operand:DF 0 "register_operand" "=f,f,v")
5078 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R,v")))]
a579871b 5079 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
5080 "@
5081 ldebr\t%0,%1
5082 ldeb\t%0,%1
5083 wldeb\t%v0,%v1"
5084 [(set_attr "op_type" "RRE,RXE,VRR")
5085 (set_attr "type" "fsimpdf, floaddf,fsimpdf")])
5086
142cd70f 5087; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
6e5b5de8
AK
5088(define_insn "*extend<DSF:mode><BFP:mode>2"
5089 [(set (match_operand:BFP 0 "register_operand" "=f,f")
142cd70f
AK
5090 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
5091 "TARGET_HARD_FLOAT
6e5b5de8
AK
5092 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)
5093 && (!TARGET_VX || <BFP:MODE>mode != DFmode || <DSF:MODE>mode != SFmode)"
f61a2c7d 5094 "@
142cd70f
AK
5095 l<BFP:xde><DSF:xde>br\t%0,%1
5096 l<BFP:xde><DSF:xde>b\t%0,%1"
6e5b5de8
AK
5097 [(set_attr "op_type" "RRE,RXE")
5098 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
5099
5100(define_expand "extend<DSF:mode><BFP:mode>2"
5101 [(set (match_operand:BFP 0 "register_operand" "")
5102 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "")))]
5103 "TARGET_HARD_FLOAT
5104 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)")
f61a2c7d 5105
609e7e80
AK
5106;
5107; extendddtd2 and extendsddd2 instruction pattern(s).
5108;
5109
5110(define_insn "extendddtd2"
5111 [(set (match_operand:TD 0 "register_operand" "=f")
5112 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
fb068247 5113 "TARGET_HARD_DFP"
609e7e80
AK
5114 "lxdtr\t%0,%1,0"
5115 [(set_attr "op_type" "RRF")
5116 (set_attr "type" "fsimptf")])
5117
5118(define_insn "extendsddd2"
5119 [(set (match_operand:DD 0 "register_operand" "=f")
5120 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
fb068247 5121 "TARGET_HARD_DFP"
609e7e80
AK
5122 "ldetr\t%0,%1,0"
5123 [(set_attr "op_type" "RRF")
5124 (set_attr "type" "fsimptf")])
9db1d521 5125
feade5a8
AK
5126(define_expand "extendsdtd2"
5127 [(set (match_dup 2)
5128 (float_extend:DD (match_operand:SD 1 "register_operand" "")))
5129 (set (match_operand:TD 0 "register_operand" "")
5130 (float_extend:TD (match_dup 2)))]
5131 "TARGET_HARD_DFP"
5132{
5133 operands[2] = gen_reg_rtx (DDmode);
5134})
5135
d12a76f3
AK
5136; Binary Floating Point - load fp integer
5137
5138; Expanders for: floor, btrunc, round, ceil, and nearbyint
5139; For all of them the inexact exceptions are suppressed.
5140
5141; fiebra, fidbra, fixbra
5142(define_insn "<FPINT:fpint_name><BFP:mode>2"
5143 [(set (match_operand:BFP 0 "register_operand" "=f")
5144 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
5145 FPINT))]
5146 "TARGET_Z196"
5147 "fi<BFP:xde>bra\t%0,<FPINT:fpint_roundingmode>,%1,4"
5148 [(set_attr "op_type" "RRF")
5149 (set_attr "type" "fsimp<BFP:mode>")])
5150
5151; rint is supposed to raise an inexact exception so we can use the
5152; older instructions.
5153
5154; fiebr, fidbr, fixbr
5155(define_insn "rint<BFP:mode>2"
5156 [(set (match_operand:BFP 0 "register_operand" "=f")
5157 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
5158 UNSPEC_FPINT_RINT))]
5159 ""
5160 "fi<BFP:xde>br\t%0,0,%1"
5161 [(set_attr "op_type" "RRF")
5162 (set_attr "type" "fsimp<BFP:mode>")])
5163
5164
5165; Decimal Floating Point - load fp integer
5166
5167; fidtr, fixtr
5168(define_insn "<FPINT:fpint_name><DFP:mode>2"
5169 [(set (match_operand:DFP 0 "register_operand" "=f")
5170 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
5171 FPINT))]
5172 "TARGET_HARD_DFP"
5173 "fi<DFP:xde>tr\t%0,<FPINT:fpint_roundingmode>,%1,4"
5174 [(set_attr "op_type" "RRF")
5175 (set_attr "type" "fsimp<DFP:mode>")])
5176
5177; fidtr, fixtr
5178(define_insn "rint<DFP:mode>2"
5179 [(set (match_operand:DFP 0 "register_operand" "=f")
5180 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
5181 UNSPEC_FPINT_RINT))]
5182 "TARGET_HARD_DFP"
5183 "fi<DFP:xde>tr\t%0,0,%1,0"
5184 [(set_attr "op_type" "RRF")
5185 (set_attr "type" "fsimp<DFP:mode>")])
5186
5187;
35dd9a0e
AK
5188; Binary <-> Decimal floating point trunc patterns
5189;
5190
5191(define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
5192 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 5193 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e 5194 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5195 (clobber (reg:CC CC_REGNUM))
5196 (clobber (reg:SI GPR1_REGNUM))]
fb068247 5197 "TARGET_HARD_DFP"
35dd9a0e
AK
5198 "pfpo")
5199
5200(define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
5201 [(set (reg:BFP FPR0_REGNUM)
2cf4c39e 5202 (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e 5203 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5204 (clobber (reg:CC CC_REGNUM))
5205 (clobber (reg:SI GPR1_REGNUM))]
fb068247 5206 "TARGET_HARD_DFP"
35dd9a0e
AK
5207 "pfpo")
5208
5209(define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 5210 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
35dd9a0e
AK
5211 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5212 (parallel
5213 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 5214 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e 5215 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5216 (clobber (reg:CC CC_REGNUM))
5217 (clobber (reg:SI GPR1_REGNUM))])
35dd9a0e
AK
5218 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
5219 (reg:DFP_ALL FPR0_REGNUM))]
fb068247 5220 "TARGET_HARD_DFP
35dd9a0e
AK
5221 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
5222{
5223 HOST_WIDE_INT flags;
5224
5225 flags = (PFPO_CONVERT |
5226 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
5227 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
5228
5229 operands[2] = GEN_INT (flags);
5230})
5231
5232(define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 5233 [(set (reg:DFP_ALL FPR4_REGNUM)
35dd9a0e
AK
5234 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
5235 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5236 (parallel
2cf4c39e 5237 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e 5238 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5239 (clobber (reg:CC CC_REGNUM))
5240 (clobber (reg:SI GPR1_REGNUM))])
35dd9a0e 5241 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
fb068247 5242 "TARGET_HARD_DFP
35dd9a0e
AK
5243 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
5244{
5245 HOST_WIDE_INT flags;
5246
5247 flags = (PFPO_CONVERT |
5248 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
5249 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
5250
5251 operands[2] = GEN_INT (flags);
5252})
5253
5254;
5255; Binary <-> Decimal floating point extend patterns
5256;
5257
5258(define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 5259 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e 5260 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5261 (clobber (reg:CC CC_REGNUM))
5262 (clobber (reg:SI GPR1_REGNUM))]
fb068247 5263 "TARGET_HARD_DFP"
35dd9a0e
AK
5264 "pfpo")
5265
5266(define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 5267 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e 5268 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5269 (clobber (reg:CC CC_REGNUM))
5270 (clobber (reg:SI GPR1_REGNUM))]
fb068247 5271 "TARGET_HARD_DFP"
35dd9a0e
AK
5272 "pfpo")
5273
5274(define_expand "extend<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 5275 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
35dd9a0e
AK
5276 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5277 (parallel
5278 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 5279 (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e 5280 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5281 (clobber (reg:CC CC_REGNUM))
5282 (clobber (reg:SI GPR1_REGNUM))])
35dd9a0e
AK
5283 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
5284 (reg:DFP_ALL FPR0_REGNUM))]
fb068247 5285 "TARGET_HARD_DFP
35dd9a0e
AK
5286 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
5287{
5288 HOST_WIDE_INT flags;
5289
5290 flags = (PFPO_CONVERT |
5291 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
5292 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
5293
5294 operands[2] = GEN_INT (flags);
5295})
5296
5297(define_expand "extend<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 5298 [(set (reg:DFP_ALL FPR4_REGNUM)
35dd9a0e
AK
5299 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
5300 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5301 (parallel
2cf4c39e 5302 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e 5303 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5304 (clobber (reg:CC CC_REGNUM))
5305 (clobber (reg:SI GPR1_REGNUM))])
35dd9a0e 5306 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
fb068247 5307 "TARGET_HARD_DFP
35dd9a0e
AK
5308 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
5309{
5310 HOST_WIDE_INT flags;
5311
5312 flags = (PFPO_CONVERT |
5313 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
5314 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
5315
5316 operands[2] = GEN_INT (flags);
5317})
5318
5319
9db1d521 5320;;
fae778eb 5321;; ARITHMETIC OPERATIONS
9db1d521 5322;;
fae778eb 5323; arithmetic operations set the ConditionCode,
9db1d521
HP
5324; because of unpredictable Bits in Register for Halfword and Byte
5325; the ConditionCode can be set wrong in operations for Halfword and Byte
5326
07893d4f
UW
5327;;
5328;;- Add instructions.
5329;;
5330
1c7b1b7e
UW
5331;
5332; addti3 instruction pattern(s).
5333;
5334
085261c8
AK
5335(define_expand "addti3"
5336 [(parallel
5337 [(set (match_operand:TI 0 "register_operand" "")
5338 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "")
5339 (match_operand:TI 2 "general_operand" "") ) )
5340 (clobber (reg:CC CC_REGNUM))])]
5341 "TARGET_ZARCH"
5342{
5343 /* For z13 we have vaq which doesn't set CC. */
5344 if (TARGET_VX)
5345 {
5346 emit_insn (gen_rtx_SET (operands[0],
5347 gen_rtx_PLUS (TImode,
5348 copy_to_mode_reg (TImode, operands[1]),
5349 copy_to_mode_reg (TImode, operands[2]))));
5350 DONE;
5351 }
5352})
5353
5354(define_insn_and_split "*addti3"
5355 [(set (match_operand:TI 0 "register_operand" "=&d")
1c7b1b7e 5356 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
085261c8 5357 (match_operand:TI 2 "general_operand" "do") ) )
ae156f85 5358 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5359 "TARGET_ZARCH"
1c7b1b7e
UW
5360 "#"
5361 "&& reload_completed"
5362 [(parallel
ae156f85 5363 [(set (reg:CCL1 CC_REGNUM)
1c7b1b7e
UW
5364 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
5365 (match_dup 7)))
5366 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
5367 (parallel
a94a76a7
UW
5368 [(set (match_dup 3) (plus:DI
5369 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
5370 (match_dup 4)) (match_dup 5)))
ae156f85 5371 (clobber (reg:CC CC_REGNUM))])]
1c7b1b7e
UW
5372 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
5373 operands[4] = operand_subword (operands[1], 0, 0, TImode);
5374 operands[5] = operand_subword (operands[2], 0, 0, TImode);
5375 operands[6] = operand_subword (operands[0], 1, 0, TImode);
5376 operands[7] = operand_subword (operands[1], 1, 0, TImode);
085261c8
AK
5377 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
5378 [(set_attr "op_type" "*")
5379 (set_attr "cpu_facility" "*")])
1c7b1b7e 5380
07893d4f
UW
5381;
5382; adddi3 instruction pattern(s).
5383;
5384
3298c037
AK
5385(define_expand "adddi3"
5386 [(parallel
963fc8d0 5387 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3298c037
AK
5388 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5389 (match_operand:DI 2 "general_operand" "")))
5390 (clobber (reg:CC CC_REGNUM))])]
5391 ""
5392 "")
5393
07893d4f
UW
5394(define_insn "*adddi3_sign"
5395 [(set (match_operand:DI 0 "register_operand" "=d,d")
3e4be43f 5396 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f 5397 (match_operand:DI 1 "register_operand" "0,0")))
ae156f85 5398 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5399 "TARGET_ZARCH"
07893d4f 5400 "@
d40c829f
UW
5401 agfr\t%0,%2
5402 agf\t%0,%2"
65b1d8ea
AK
5403 [(set_attr "op_type" "RRE,RXY")
5404 (set_attr "z196prop" "z196_cracked,z196_cracked")])
07893d4f
UW
5405
5406(define_insn "*adddi3_zero_cc"
ae156f85 5407 [(set (reg CC_REGNUM)
3e4be43f 5408 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f
UW
5409 (match_operand:DI 1 "register_operand" "0,0"))
5410 (const_int 0)))
5411 (set (match_operand:DI 0 "register_operand" "=d,d")
5412 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
9602b6a1 5413 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5414 "@
d40c829f
UW
5415 algfr\t%0,%2
5416 algf\t%0,%2"
9381e3f1
WG
5417 [(set_attr "op_type" "RRE,RXY")
5418 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f
UW
5419
5420(define_insn "*adddi3_zero_cconly"
ae156f85 5421 [(set (reg CC_REGNUM)
3e4be43f 5422 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f
UW
5423 (match_operand:DI 1 "register_operand" "0,0"))
5424 (const_int 0)))
5425 (clobber (match_scratch:DI 0 "=d,d"))]
9602b6a1 5426 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5427 "@
d40c829f
UW
5428 algfr\t%0,%2
5429 algf\t%0,%2"
9381e3f1
WG
5430 [(set_attr "op_type" "RRE,RXY")
5431 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f
UW
5432
5433(define_insn "*adddi3_zero"
5434 [(set (match_operand:DI 0 "register_operand" "=d,d")
3e4be43f 5435 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f 5436 (match_operand:DI 1 "register_operand" "0,0")))
ae156f85 5437 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5438 "TARGET_ZARCH"
07893d4f 5439 "@
d40c829f
UW
5440 algfr\t%0,%2
5441 algf\t%0,%2"
9381e3f1
WG
5442 [(set_attr "op_type" "RRE,RXY")
5443 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f 5444
e69166de 5445(define_insn_and_split "*adddi3_31z"
963fc8d0 5446 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
e69166de
UW
5447 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5448 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5449 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5450 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
e69166de
UW
5451 "#"
5452 "&& reload_completed"
5453 [(parallel
ae156f85 5454 [(set (reg:CCL1 CC_REGNUM)
e69166de
UW
5455 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
5456 (match_dup 7)))
5457 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
5458 (parallel
a94a76a7
UW
5459 [(set (match_dup 3) (plus:SI
5460 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
5461 (match_dup 4)) (match_dup 5)))
ae156f85 5462 (clobber (reg:CC CC_REGNUM))])]
e69166de
UW
5463 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5464 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5465 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5466 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5467 operands[7] = operand_subword (operands[1], 1, 0, DImode);
b628bd8e 5468 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
e69166de 5469
07893d4f 5470(define_insn_and_split "*adddi3_31"
963fc8d0 5471 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
96fd3851 5472 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
97c6f7ad 5473 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5474 (clobber (reg:CC CC_REGNUM))]
e69166de 5475 "!TARGET_CPU_ZARCH"
07893d4f
UW
5476 "#"
5477 "&& reload_completed"
5478 [(parallel
5479 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
ae156f85 5480 (clobber (reg:CC CC_REGNUM))])
07893d4f 5481 (parallel
ae156f85 5482 [(set (reg:CCL1 CC_REGNUM)
07893d4f
UW
5483 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
5484 (match_dup 7)))
5485 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
5486 (set (pc)
ae156f85 5487 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
07893d4f
UW
5488 (pc)
5489 (label_ref (match_dup 9))))
5490 (parallel
5491 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
ae156f85 5492 (clobber (reg:CC CC_REGNUM))])
07893d4f 5493 (match_dup 9)]
97c6f7ad
UW
5494 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5495 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5496 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5497 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5498 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5499 operands[8] = operand_subword (operands[2], 1, 0, DImode);
b628bd8e 5500 operands[9] = gen_label_rtx ();")
9db1d521 5501
3298c037
AK
5502;
5503; addsi3 instruction pattern(s).
5504;
5505
5506(define_expand "addsi3"
07893d4f 5507 [(parallel
963fc8d0 5508 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3298c037
AK
5509 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
5510 (match_operand:SI 2 "general_operand" "")))
ae156f85 5511 (clobber (reg:CC CC_REGNUM))])]
9db1d521 5512 ""
07893d4f 5513 "")
9db1d521 5514
3298c037
AK
5515(define_insn "*addsi3_sign"
5516 [(set (match_operand:SI 0 "register_operand" "=d,d")
5517 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5518 (match_operand:SI 1 "register_operand" "0,0")))
5519 (clobber (reg:CC CC_REGNUM))]
5520 ""
5521 "@
5522 ah\t%0,%2
5523 ahy\t%0,%2"
65b1d8ea 5524 [(set_attr "op_type" "RX,RXY")
3e4be43f 5525 (set_attr "cpu_facility" "*,longdisp")
65b1d8ea 5526 (set_attr "z196prop" "z196_cracked,z196_cracked")])
3298c037 5527
9db1d521 5528;
3298c037 5529; add(di|si)3 instruction pattern(s).
9db1d521 5530;
9db1d521 5531
65b1d8ea 5532; ark, agrk, ar, ahi, ahik, aghik, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
3298c037 5533(define_insn "*add<mode>3"
3e4be43f
UW
5534 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d, d, d,d,d,S")
5535 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,d, 0, 0,0,0,0")
5536 (match_operand:GPR 2 "general_operand" " d,d,K,K,Op,On,R,T,C") ) )
3298c037
AK
5537 (clobber (reg:CC CC_REGNUM))]
5538 ""
ec24698e 5539 "@
3298c037 5540 a<g>r\t%0,%2
65b1d8ea 5541 a<g>rk\t%0,%1,%2
3298c037 5542 a<g>hi\t%0,%h2
65b1d8ea 5543 a<g>hik\t%0,%1,%h2
3298c037
AK
5544 al<g>fi\t%0,%2
5545 sl<g>fi\t%0,%n2
5546 a<g>\t%0,%2
963fc8d0
AK
5547 a<y>\t%0,%2
5548 a<g>si\t%0,%c2"
65b1d8ea 5549 [(set_attr "op_type" "RR<E>,RRF,RI,RIE,RIL,RIL,RX<Y>,RXY,SIY")
3e4be43f 5550 (set_attr "cpu_facility" "*,z196,*,z196,extimm,extimm,*,longdisp,z10")
65b1d8ea
AK
5551 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,z10_super_E1,z10_super_E1,
5552 z10_super_E1,z10_super_E1,z10_super_E1")])
0a3bdf9d 5553
65b1d8ea 5554; alr, alfi, slfi, al, aly, alrk, alhsik, algr, algfi, slgfi, alg, alsi, algsi, algrk, alghsik
3298c037 5555(define_insn "*add<mode>3_carry1_cc"
ae156f85 5556 [(set (reg CC_REGNUM)
65b1d8ea
AK
5557 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5558 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
07893d4f 5559 (match_dup 1)))
65b1d8ea 5560 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,d")
3298c037 5561 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5562 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5563 "@
3298c037 5564 al<g>r\t%0,%2
65b1d8ea 5565 al<g>rk\t%0,%1,%2
3298c037
AK
5566 al<g>fi\t%0,%2
5567 sl<g>fi\t%0,%n2
65b1d8ea 5568 al<g>hsik\t%0,%1,%h2
3298c037 5569 al<g>\t%0,%2
963fc8d0
AK
5570 al<y>\t%0,%2
5571 al<g>si\t%0,%c2"
65b1d8ea 5572 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
3e4be43f 5573 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
65b1d8ea
AK
5574 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
5575 z10_super_E1,z10_super_E1,z10_super_E1")])
07893d4f 5576
65b1d8ea 5577; alr, al, aly, algr, alg, alrk, algrk
3298c037 5578(define_insn "*add<mode>3_carry1_cconly"
ae156f85 5579 [(set (reg CC_REGNUM)
65b1d8ea
AK
5580 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5581 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 5582 (match_dup 1)))
65b1d8ea 5583 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5584 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5585 "@
3298c037 5586 al<g>r\t%0,%2
65b1d8ea 5587 al<g>rk\t%0,%1,%2
3298c037
AK
5588 al<g>\t%0,%2
5589 al<y>\t%0,%2"
65b1d8ea 5590 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 5591 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 5592 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5593
65b1d8ea 5594; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
3298c037 5595(define_insn "*add<mode>3_carry2_cc"
ae156f85 5596 [(set (reg CC_REGNUM)
3e4be43f
UW
5597 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5598 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
07893d4f 5599 (match_dup 2)))
3e4be43f 5600 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,S")
3298c037 5601 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5602 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5603 "@
3298c037 5604 al<g>r\t%0,%2
65b1d8ea 5605 al<g>rk\t%0,%1,%2
3298c037
AK
5606 al<g>fi\t%0,%2
5607 sl<g>fi\t%0,%n2
65b1d8ea 5608 al<g>hsik\t%0,%1,%h2
3298c037 5609 al<g>\t%0,%2
963fc8d0
AK
5610 al<y>\t%0,%2
5611 al<g>si\t%0,%c2"
65b1d8ea 5612 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
3e4be43f 5613 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
65b1d8ea
AK
5614 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
5615 z10_super_E1,z10_super_E1,z10_super_E1")])
07893d4f 5616
65b1d8ea 5617; alr, al, aly, algr, alg, alrk, algrk
3298c037 5618(define_insn "*add<mode>3_carry2_cconly"
ae156f85 5619 [(set (reg CC_REGNUM)
65b1d8ea
AK
5620 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5621 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 5622 (match_dup 2)))
65b1d8ea 5623 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5624 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5625 "@
3298c037 5626 al<g>r\t%0,%2
65b1d8ea 5627 al<g>rk\t%0,%1,%2
3298c037
AK
5628 al<g>\t%0,%2
5629 al<y>\t%0,%2"
65b1d8ea 5630 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 5631 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 5632 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5633
65b1d8ea 5634; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
3298c037 5635(define_insn "*add<mode>3_cc"
ae156f85 5636 [(set (reg CC_REGNUM)
3e4be43f
UW
5637 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5638 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
9db1d521 5639 (const_int 0)))
3e4be43f 5640 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,S")
3298c037 5641 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5642 "s390_match_ccmode (insn, CCLmode)"
9db1d521 5643 "@
3298c037 5644 al<g>r\t%0,%2
65b1d8ea 5645 al<g>rk\t%0,%1,%2
3298c037
AK
5646 al<g>fi\t%0,%2
5647 sl<g>fi\t%0,%n2
65b1d8ea 5648 al<g>hsik\t%0,%1,%h2
3298c037 5649 al<g>\t%0,%2
963fc8d0
AK
5650 al<y>\t%0,%2
5651 al<g>si\t%0,%c2"
65b1d8ea 5652 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
3e4be43f 5653 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
65b1d8ea
AK
5654 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,
5655 *,z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 5656
65b1d8ea 5657; alr, al, aly, algr, alg, alrk, algrk
3298c037 5658(define_insn "*add<mode>3_cconly"
ae156f85 5659 [(set (reg CC_REGNUM)
65b1d8ea
AK
5660 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5661 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 5662 (const_int 0)))
65b1d8ea 5663 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5664 "s390_match_ccmode (insn, CCLmode)"
9db1d521 5665 "@
3298c037 5666 al<g>r\t%0,%2
65b1d8ea 5667 al<g>rk\t%0,%1,%2
3298c037
AK
5668 al<g>\t%0,%2
5669 al<y>\t%0,%2"
65b1d8ea 5670 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 5671 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 5672 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 5673
65b1d8ea 5674; alr, al, aly, algr, alg, alrk, algrk
3298c037 5675(define_insn "*add<mode>3_cconly2"
ae156f85 5676 [(set (reg CC_REGNUM)
65b1d8ea
AK
5677 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5678 (neg:GPR (match_operand:GPR 2 "general_operand" "d,d,R,T"))))
5679 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
3298c037 5680 "s390_match_ccmode(insn, CCLmode)"
d3632d41 5681 "@
3298c037 5682 al<g>r\t%0,%2
65b1d8ea 5683 al<g>rk\t%0,%1,%2
3298c037
AK
5684 al<g>\t%0,%2
5685 al<y>\t%0,%2"
65b1d8ea 5686 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 5687 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 5688 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5689
963fc8d0 5690; ahi, afi, aghi, agfi, asi, agsi
3298c037
AK
5691(define_insn "*add<mode>3_imm_cc"
5692 [(set (reg CC_REGNUM)
65b1d8ea 5693 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" " 0, d,0, 0")
3e4be43f 5694 (match_operand:GPR 2 "const_int_operand" " K, K,Os,C"))
3298c037 5695 (const_int 0)))
3e4be43f 5696 (set (match_operand:GPR 0 "nonimmediate_operand" "=d, d,d, S")
3298c037
AK
5697 (plus:GPR (match_dup 1) (match_dup 2)))]
5698 "s390_match_ccmode (insn, CCAmode)
5699 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
2542ef05
RH
5700 || (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
5701 /* Avoid INT32_MIN on 32 bit. */
5702 && (!TARGET_ZARCH || INTVAL (operands[2]) != -0x7fffffff - 1)))"
9db1d521 5703 "@
3298c037 5704 a<g>hi\t%0,%h2
65b1d8ea 5705 a<g>hik\t%0,%1,%h2
963fc8d0
AK
5706 a<g>fi\t%0,%2
5707 a<g>si\t%0,%c2"
65b1d8ea
AK
5708 [(set_attr "op_type" "RI,RIE,RIL,SIY")
5709 (set_attr "cpu_facility" "*,z196,extimm,z10")
5710 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 5711
9db1d521 5712;
609e7e80 5713; add(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
5714;
5715
609e7e80 5716; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
6e5b5de8 5717; FIXME: wfadb does not clobber cc
142cd70f 5718(define_insn "add<mode>3"
62d3f261
AK
5719 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
5720 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0,v")
5721 (match_operand:FP 2 "general_operand" "f,f,R,v")))
ae156f85 5722 (clobber (reg:CC CC_REGNUM))]
142cd70f 5723 "TARGET_HARD_FLOAT"
9db1d521 5724 "@
62d3f261
AK
5725 a<xde>tr\t%0,%1,%2
5726 a<xde>br\t%0,%2
6e5b5de8
AK
5727 a<xde>b\t%0,%2
5728 wfadb\t%v0,%v1,%v2"
62d3f261 5729 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6e5b5de8 5730 (set_attr "type" "fsimp<mode>")
62d3f261
AK
5731 (set_attr "cpu_facility" "*,*,*,vec")
5732 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
9db1d521 5733
609e7e80 5734; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
f5905b37 5735(define_insn "*add<mode>3_cc"
ae156f85 5736 [(set (reg CC_REGNUM)
62d3f261
AK
5737 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0")
5738 (match_operand:FP 2 "general_operand" "f,f,R"))
609e7e80 5739 (match_operand:FP 3 "const0_operand" "")))
62d3f261 5740 (set (match_operand:FP 0 "register_operand" "=f,f,f")
609e7e80 5741 (plus:FP (match_dup 1) (match_dup 2)))]
142cd70f 5742 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 5743 "@
62d3f261
AK
5744 a<xde>tr\t%0,%1,%2
5745 a<xde>br\t%0,%2
f61a2c7d 5746 a<xde>b\t%0,%2"
62d3f261
AK
5747 [(set_attr "op_type" "RRF,RRE,RXE")
5748 (set_attr "type" "fsimp<mode>")
5749 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
3ef093a8 5750
609e7e80 5751; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
f5905b37 5752(define_insn "*add<mode>3_cconly"
ae156f85 5753 [(set (reg CC_REGNUM)
62d3f261
AK
5754 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0")
5755 (match_operand:FP 2 "general_operand" "f,f,R"))
609e7e80 5756 (match_operand:FP 3 "const0_operand" "")))
62d3f261 5757 (clobber (match_scratch:FP 0 "=f,f,f"))]
142cd70f 5758 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 5759 "@
62d3f261
AK
5760 a<xde>tr\t%0,%1,%2
5761 a<xde>br\t%0,%2
f61a2c7d 5762 a<xde>b\t%0,%2"
62d3f261
AK
5763 [(set_attr "op_type" "RRF,RRE,RXE")
5764 (set_attr "type" "fsimp<mode>")
5765 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
3ef093a8 5766
72a4ddf2
AK
5767;
5768; Pointer add instruction patterns
5769;
5770
5771; This will match "*la_64"
5772(define_expand "addptrdi3"
5773 [(set (match_operand:DI 0 "register_operand" "")
5774 (plus:DI (match_operand:DI 1 "register_operand" "")
5775 (match_operand:DI 2 "nonmemory_operand" "")))]
5776 "TARGET_64BIT"
5777{
72a4ddf2
AK
5778 if (GET_CODE (operands[2]) == CONST_INT)
5779 {
357ddc7d
TV
5780 HOST_WIDE_INT c = INTVAL (operands[2]);
5781
72a4ddf2
AK
5782 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
5783 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
5784 {
5785 operands[2] = force_const_mem (DImode, operands[2]);
5786 operands[2] = force_reg (DImode, operands[2]);
5787 }
5788 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
5789 operands[2] = force_reg (DImode, operands[2]);
5790 }
5791})
5792
5793; For 31 bit we have to prevent the generated pattern from matching
5794; normal ADDs since la only does a 31 bit add. This is supposed to
5795; match "force_la_31".
5796(define_expand "addptrsi3"
5797 [(parallel
5798 [(set (match_operand:SI 0 "register_operand" "")
5799 (plus:SI (match_operand:SI 1 "register_operand" "")
5800 (match_operand:SI 2 "nonmemory_operand" "")))
5801 (use (const_int 0))])]
5802 "!TARGET_64BIT"
5803{
72a4ddf2
AK
5804 if (GET_CODE (operands[2]) == CONST_INT)
5805 {
357ddc7d
TV
5806 HOST_WIDE_INT c = INTVAL (operands[2]);
5807
72a4ddf2
AK
5808 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
5809 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
5810 {
5811 operands[2] = force_const_mem (SImode, operands[2]);
5812 operands[2] = force_reg (SImode, operands[2]);
5813 }
5814 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
5815 operands[2] = force_reg (SImode, operands[2]);
5816 }
5817})
9db1d521
HP
5818
5819;;
5820;;- Subtract instructions.
5821;;
5822
1c7b1b7e
UW
5823;
5824; subti3 instruction pattern(s).
5825;
5826
085261c8
AK
5827(define_expand "subti3"
5828 [(parallel
5829 [(set (match_operand:TI 0 "register_operand" "")
5830 (minus:TI (match_operand:TI 1 "register_operand" "")
5831 (match_operand:TI 2 "general_operand" "") ) )
5832 (clobber (reg:CC CC_REGNUM))])]
5833 "TARGET_ZARCH"
5834{
2d71f118 5835 /* For z13 we have vsq which doesn't set CC. */
085261c8
AK
5836 if (TARGET_VX)
5837 {
5838 emit_insn (gen_rtx_SET (operands[0],
5839 gen_rtx_MINUS (TImode,
5840 operands[1],
5841 copy_to_mode_reg (TImode, operands[2]))));
5842 DONE;
5843 }
5844})
5845
5846(define_insn_and_split "*subti3"
5847 [(set (match_operand:TI 0 "register_operand" "=&d")
5848 (minus:TI (match_operand:TI 1 "register_operand" "0")
5849 (match_operand:TI 2 "general_operand" "do") ) )
ae156f85 5850 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5851 "TARGET_ZARCH"
1c7b1b7e
UW
5852 "#"
5853 "&& reload_completed"
5854 [(parallel
ae156f85 5855 [(set (reg:CCL2 CC_REGNUM)
1c7b1b7e
UW
5856 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
5857 (match_dup 7)))
5858 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
5859 (parallel
5860 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
ae156f85
AS
5861 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
5862 (clobber (reg:CC CC_REGNUM))])]
1c7b1b7e
UW
5863 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
5864 operands[4] = operand_subword (operands[1], 0, 0, TImode);
5865 operands[5] = operand_subword (operands[2], 0, 0, TImode);
5866 operands[6] = operand_subword (operands[0], 1, 0, TImode);
5867 operands[7] = operand_subword (operands[1], 1, 0, TImode);
085261c8
AK
5868 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
5869 [(set_attr "op_type" "*")
5870 (set_attr "cpu_facility" "*")])
1c7b1b7e 5871
9db1d521
HP
5872;
5873; subdi3 instruction pattern(s).
5874;
5875
3298c037
AK
5876(define_expand "subdi3"
5877 [(parallel
5878 [(set (match_operand:DI 0 "register_operand" "")
5879 (minus:DI (match_operand:DI 1 "register_operand" "")
5880 (match_operand:DI 2 "general_operand" "")))
5881 (clobber (reg:CC CC_REGNUM))])]
5882 ""
5883 "")
5884
07893d4f
UW
5885(define_insn "*subdi3_sign"
5886 [(set (match_operand:DI 0 "register_operand" "=d,d")
5887 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 5888 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))))
ae156f85 5889 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5890 "TARGET_ZARCH"
07893d4f 5891 "@
d40c829f
UW
5892 sgfr\t%0,%2
5893 sgf\t%0,%2"
9381e3f1 5894 [(set_attr "op_type" "RRE,RXY")
65b1d8ea
AK
5895 (set_attr "z10prop" "z10_c,*")
5896 (set_attr "z196prop" "z196_cracked")])
07893d4f
UW
5897
5898(define_insn "*subdi3_zero_cc"
ae156f85 5899 [(set (reg CC_REGNUM)
07893d4f 5900 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 5901 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T")))
07893d4f
UW
5902 (const_int 0)))
5903 (set (match_operand:DI 0 "register_operand" "=d,d")
5904 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
9602b6a1 5905 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5906 "@
d40c829f
UW
5907 slgfr\t%0,%2
5908 slgf\t%0,%2"
9381e3f1
WG
5909 [(set_attr "op_type" "RRE,RXY")
5910 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f
UW
5911
5912(define_insn "*subdi3_zero_cconly"
ae156f85 5913 [(set (reg CC_REGNUM)
07893d4f 5914 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 5915 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T")))
07893d4f
UW
5916 (const_int 0)))
5917 (clobber (match_scratch:DI 0 "=d,d"))]
9602b6a1 5918 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5919 "@
d40c829f
UW
5920 slgfr\t%0,%2
5921 slgf\t%0,%2"
9381e3f1
WG
5922 [(set_attr "op_type" "RRE,RXY")
5923 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f
UW
5924
5925(define_insn "*subdi3_zero"
5926 [(set (match_operand:DI 0 "register_operand" "=d,d")
5927 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 5928 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))))
ae156f85 5929 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5930 "TARGET_ZARCH"
07893d4f 5931 "@
d40c829f
UW
5932 slgfr\t%0,%2
5933 slgf\t%0,%2"
9381e3f1
WG
5934 [(set_attr "op_type" "RRE,RXY")
5935 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f 5936
e69166de
UW
5937(define_insn_and_split "*subdi3_31z"
5938 [(set (match_operand:DI 0 "register_operand" "=&d")
5939 (minus:DI (match_operand:DI 1 "register_operand" "0")
5940 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5941 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5942 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
e69166de
UW
5943 "#"
5944 "&& reload_completed"
5945 [(parallel
ae156f85 5946 [(set (reg:CCL2 CC_REGNUM)
e69166de
UW
5947 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5948 (match_dup 7)))
5949 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5950 (parallel
5951 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
ae156f85
AS
5952 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
5953 (clobber (reg:CC CC_REGNUM))])]
e69166de
UW
5954 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5955 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5956 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5957 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5958 operands[7] = operand_subword (operands[1], 1, 0, DImode);
b628bd8e 5959 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
e69166de 5960
07893d4f
UW
5961(define_insn_and_split "*subdi3_31"
5962 [(set (match_operand:DI 0 "register_operand" "=&d")
5963 (minus:DI (match_operand:DI 1 "register_operand" "0")
97c6f7ad 5964 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5965 (clobber (reg:CC CC_REGNUM))]
e69166de 5966 "!TARGET_CPU_ZARCH"
07893d4f
UW
5967 "#"
5968 "&& reload_completed"
5969 [(parallel
5970 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
ae156f85 5971 (clobber (reg:CC CC_REGNUM))])
07893d4f 5972 (parallel
ae156f85 5973 [(set (reg:CCL2 CC_REGNUM)
07893d4f
UW
5974 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5975 (match_dup 7)))
5976 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5977 (set (pc)
ae156f85 5978 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
07893d4f
UW
5979 (pc)
5980 (label_ref (match_dup 9))))
5981 (parallel
5982 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
ae156f85 5983 (clobber (reg:CC CC_REGNUM))])
07893d4f 5984 (match_dup 9)]
97c6f7ad
UW
5985 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5986 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5987 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5988 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5989 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5990 operands[8] = operand_subword (operands[2], 1, 0, DImode);
b628bd8e 5991 operands[9] = gen_label_rtx ();")
07893d4f 5992
3298c037
AK
5993;
5994; subsi3 instruction pattern(s).
5995;
5996
5997(define_expand "subsi3"
07893d4f 5998 [(parallel
3298c037
AK
5999 [(set (match_operand:SI 0 "register_operand" "")
6000 (minus:SI (match_operand:SI 1 "register_operand" "")
6001 (match_operand:SI 2 "general_operand" "")))
ae156f85 6002 (clobber (reg:CC CC_REGNUM))])]
9db1d521 6003 ""
07893d4f 6004 "")
9db1d521 6005
3298c037
AK
6006(define_insn "*subsi3_sign"
6007 [(set (match_operand:SI 0 "register_operand" "=d,d")
6008 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
6009 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
6010 (clobber (reg:CC CC_REGNUM))]
6011 ""
6012 "@
6013 sh\t%0,%2
6014 shy\t%0,%2"
65b1d8ea 6015 [(set_attr "op_type" "RX,RXY")
3e4be43f 6016 (set_attr "cpu_facility" "*,longdisp")
65b1d8ea 6017 (set_attr "z196prop" "z196_cracked,z196_cracked")])
3298c037 6018
9db1d521 6019;
3298c037 6020; sub(di|si)3 instruction pattern(s).
9db1d521
HP
6021;
6022
65b1d8ea 6023; sr, s, sy, sgr, sg, srk, sgrk
3298c037 6024(define_insn "*sub<mode>3"
65b1d8ea
AK
6025 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6026 (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6027 (match_operand:GPR 2 "general_operand" "d,d,R,T") ) )
3298c037
AK
6028 (clobber (reg:CC CC_REGNUM))]
6029 ""
6030 "@
6031 s<g>r\t%0,%2
65b1d8ea 6032 s<g>rk\t%0,%1,%2
3298c037
AK
6033 s<g>\t%0,%2
6034 s<y>\t%0,%2"
65b1d8ea 6035 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6036 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6037 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
3298c037 6038
65b1d8ea 6039; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6040(define_insn "*sub<mode>3_borrow_cc"
ae156f85 6041 [(set (reg CC_REGNUM)
65b1d8ea
AK
6042 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6043 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 6044 (match_dup 1)))
65b1d8ea 6045 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 6046 (minus:GPR (match_dup 1) (match_dup 2)))]
b2ba71ca 6047 "s390_match_ccmode (insn, CCL2mode)"
07893d4f 6048 "@
3298c037 6049 sl<g>r\t%0,%2
65b1d8ea 6050 sl<g>rk\t%0,%1,%2
3298c037
AK
6051 sl<g>\t%0,%2
6052 sl<y>\t%0,%2"
65b1d8ea 6053 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6054 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6055 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 6056
65b1d8ea 6057; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6058(define_insn "*sub<mode>3_borrow_cconly"
ae156f85 6059 [(set (reg CC_REGNUM)
65b1d8ea
AK
6060 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6061 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 6062 (match_dup 1)))
65b1d8ea 6063 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
b2ba71ca 6064 "s390_match_ccmode (insn, CCL2mode)"
07893d4f 6065 "@
3298c037 6066 sl<g>r\t%0,%2
65b1d8ea 6067 sl<g>rk\t%0,%1,%2
3298c037
AK
6068 sl<g>\t%0,%2
6069 sl<y>\t%0,%2"
65b1d8ea 6070 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6071 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6072 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 6073
65b1d8ea 6074; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6075(define_insn "*sub<mode>3_cc"
ae156f85 6076 [(set (reg CC_REGNUM)
65b1d8ea
AK
6077 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6078 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 6079 (const_int 0)))
65b1d8ea 6080 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 6081 (minus:GPR (match_dup 1) (match_dup 2)))]
b2ba71ca 6082 "s390_match_ccmode (insn, CCLmode)"
9db1d521 6083 "@
3298c037 6084 sl<g>r\t%0,%2
65b1d8ea 6085 sl<g>rk\t%0,%1,%2
3298c037
AK
6086 sl<g>\t%0,%2
6087 sl<y>\t%0,%2"
65b1d8ea 6088 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6089 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6090 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 6091
65b1d8ea 6092; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6093(define_insn "*sub<mode>3_cc2"
ae156f85 6094 [(set (reg CC_REGNUM)
65b1d8ea
AK
6095 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
6096 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
6097 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 6098 (minus:GPR (match_dup 1) (match_dup 2)))]
5d880bd2
UW
6099 "s390_match_ccmode (insn, CCL3mode)"
6100 "@
3298c037 6101 sl<g>r\t%0,%2
65b1d8ea 6102 sl<g>rk\t%0,%1,%2
3298c037
AK
6103 sl<g>\t%0,%2
6104 sl<y>\t%0,%2"
65b1d8ea 6105 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6106 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6107 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5d880bd2 6108
65b1d8ea 6109; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6110(define_insn "*sub<mode>3_cconly"
ae156f85 6111 [(set (reg CC_REGNUM)
65b1d8ea
AK
6112 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6113 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 6114 (const_int 0)))
65b1d8ea 6115 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
b2ba71ca 6116 "s390_match_ccmode (insn, CCLmode)"
9db1d521 6117 "@
3298c037 6118 sl<g>r\t%0,%2
65b1d8ea 6119 sl<g>rk\t%0,%1,%2
3298c037
AK
6120 sl<g>\t%0,%2
6121 sl<y>\t%0,%2"
65b1d8ea 6122 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6123 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6124 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9381e3f1 6125
9db1d521 6126
65b1d8ea 6127; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6128(define_insn "*sub<mode>3_cconly2"
ae156f85 6129 [(set (reg CC_REGNUM)
65b1d8ea
AK
6130 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
6131 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
6132 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5d880bd2
UW
6133 "s390_match_ccmode (insn, CCL3mode)"
6134 "@
3298c037 6135 sl<g>r\t%0,%2
65b1d8ea 6136 sl<g>rk\t%0,%1,%2
3298c037
AK
6137 sl<g>\t%0,%2
6138 sl<y>\t%0,%2"
65b1d8ea 6139 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6140 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6141 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9381e3f1 6142
9db1d521
HP
6143
6144;
609e7e80 6145; sub(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
6146;
6147
d46f24b6 6148; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
142cd70f 6149(define_insn "sub<mode>3"
62d3f261
AK
6150 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
6151 (minus:FP (match_operand:FP 1 "register_operand" "f,0,0,v")
6152 (match_operand:FP 2 "general_operand" "f,f,R,v")))
ae156f85 6153 (clobber (reg:CC CC_REGNUM))]
142cd70f 6154 "TARGET_HARD_FLOAT"
9db1d521 6155 "@
62d3f261
AK
6156 s<xde>tr\t%0,%1,%2
6157 s<xde>br\t%0,%2
6e5b5de8
AK
6158 s<xde>b\t%0,%2
6159 wfsdb\t%v0,%v1,%v2"
62d3f261 6160 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6e5b5de8 6161 (set_attr "type" "fsimp<mode>")
62d3f261
AK
6162 (set_attr "cpu_facility" "*,*,*,vec")
6163 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
9db1d521 6164
d46f24b6 6165; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
f5905b37 6166(define_insn "*sub<mode>3_cc"
ae156f85 6167 [(set (reg CC_REGNUM)
62d3f261
AK
6168 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "f,0,0")
6169 (match_operand:FP 2 "general_operand" "f,f,R"))
609e7e80 6170 (match_operand:FP 3 "const0_operand" "")))
62d3f261 6171 (set (match_operand:FP 0 "register_operand" "=f,f,f")
609e7e80 6172 (minus:FP (match_dup 1) (match_dup 2)))]
142cd70f 6173 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 6174 "@
62d3f261
AK
6175 s<xde>tr\t%0,%1,%2
6176 s<xde>br\t%0,%2
f61a2c7d 6177 s<xde>b\t%0,%2"
62d3f261
AK
6178 [(set_attr "op_type" "RRF,RRE,RXE")
6179 (set_attr "type" "fsimp<mode>")
6180 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
3ef093a8 6181
d46f24b6 6182; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
f5905b37 6183(define_insn "*sub<mode>3_cconly"
ae156f85 6184 [(set (reg CC_REGNUM)
62d3f261
AK
6185 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "f,0,0")
6186 (match_operand:FP 2 "general_operand" "f,f,R"))
609e7e80 6187 (match_operand:FP 3 "const0_operand" "")))
62d3f261 6188 (clobber (match_scratch:FP 0 "=f,f,f"))]
142cd70f 6189 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 6190 "@
62d3f261
AK
6191 s<xde>tr\t%0,%1,%2
6192 s<xde>br\t%0,%2
f61a2c7d 6193 s<xde>b\t%0,%2"
62d3f261
AK
6194 [(set_attr "op_type" "RRF,RRE,RXE")
6195 (set_attr "type" "fsimp<mode>")
6196 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
3ef093a8 6197
9db1d521 6198
e69166de
UW
6199;;
6200;;- Conditional add/subtract instructions.
6201;;
6202
6203;
9a91a21f 6204; add(di|si)cc instruction pattern(s).
e69166de
UW
6205;
6206
a996720c
UW
6207; the following 4 patterns are used when the result of an add with
6208; carry is checked for an overflow condition
6209
6210; op1 + op2 + c < op1
6211
6212; alcr, alc, alcgr, alcg
6213(define_insn "*add<mode>3_alc_carry1_cc"
6214 [(set (reg CC_REGNUM)
6215 (compare
6216 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6217 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6218 (match_operand:GPR 2 "general_operand" "d,T"))
a996720c
UW
6219 (match_dup 1)))
6220 (set (match_operand:GPR 0 "register_operand" "=d,d")
6221 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
6222 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6223 "@
6224 alc<g>r\t%0,%2
6225 alc<g>\t%0,%2"
65b1d8ea
AK
6226 [(set_attr "op_type" "RRE,RXY")
6227 (set_attr "z196prop" "z196_alone,z196_alone")])
a996720c
UW
6228
6229; alcr, alc, alcgr, alcg
6230(define_insn "*add<mode>3_alc_carry1_cconly"
6231 [(set (reg CC_REGNUM)
6232 (compare
6233 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6234 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6235 (match_operand:GPR 2 "general_operand" "d,T"))
a996720c
UW
6236 (match_dup 1)))
6237 (clobber (match_scratch:GPR 0 "=d,d"))]
6238 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6239 "@
6240 alc<g>r\t%0,%2
6241 alc<g>\t%0,%2"
65b1d8ea
AK
6242 [(set_attr "op_type" "RRE,RXY")
6243 (set_attr "z196prop" "z196_alone,z196_alone")])
a996720c
UW
6244
6245; op1 + op2 + c < op2
6246
6247; alcr, alc, alcgr, alcg
6248(define_insn "*add<mode>3_alc_carry2_cc"
6249 [(set (reg CC_REGNUM)
6250 (compare
6251 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6252 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6253 (match_operand:GPR 2 "general_operand" "d,T"))
a996720c
UW
6254 (match_dup 2)))
6255 (set (match_operand:GPR 0 "register_operand" "=d,d")
6256 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
6257 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6258 "@
6259 alc<g>r\t%0,%2
6260 alc<g>\t%0,%2"
6261 [(set_attr "op_type" "RRE,RXY")])
6262
6263; alcr, alc, alcgr, alcg
6264(define_insn "*add<mode>3_alc_carry2_cconly"
6265 [(set (reg CC_REGNUM)
6266 (compare
6267 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6268 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6269 (match_operand:GPR 2 "general_operand" "d,T"))
a996720c
UW
6270 (match_dup 2)))
6271 (clobber (match_scratch:GPR 0 "=d,d"))]
6272 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6273 "@
6274 alc<g>r\t%0,%2
6275 alc<g>\t%0,%2"
6276 [(set_attr "op_type" "RRE,RXY")])
6277
43a09b63 6278; alcr, alc, alcgr, alcg
9a91a21f 6279(define_insn "*add<mode>3_alc_cc"
ae156f85 6280 [(set (reg CC_REGNUM)
e69166de 6281 (compare
a94a76a7
UW
6282 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6283 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6284 (match_operand:GPR 2 "general_operand" "d,T"))
e69166de 6285 (const_int 0)))
9a91a21f 6286 (set (match_operand:GPR 0 "register_operand" "=d,d")
a94a76a7 6287 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
2f7e5a0d 6288 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
e69166de 6289 "@
9a91a21f
AS
6290 alc<g>r\t%0,%2
6291 alc<g>\t%0,%2"
e69166de
UW
6292 [(set_attr "op_type" "RRE,RXY")])
6293
43a09b63 6294; alcr, alc, alcgr, alcg
9a91a21f
AS
6295(define_insn "*add<mode>3_alc"
6296 [(set (match_operand:GPR 0 "register_operand" "=d,d")
a94a76a7
UW
6297 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6298 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6299 (match_operand:GPR 2 "general_operand" "d,T")))
ae156f85 6300 (clobber (reg:CC CC_REGNUM))]
2f7e5a0d 6301 "TARGET_CPU_ZARCH"
e69166de 6302 "@
9a91a21f
AS
6303 alc<g>r\t%0,%2
6304 alc<g>\t%0,%2"
e69166de
UW
6305 [(set_attr "op_type" "RRE,RXY")])
6306
43a09b63 6307; slbr, slb, slbgr, slbg
9a91a21f 6308(define_insn "*sub<mode>3_slb_cc"
ae156f85 6309 [(set (reg CC_REGNUM)
e69166de 6310 (compare
9a91a21f 6311 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
3e4be43f 6312 (match_operand:GPR 2 "general_operand" "d,T"))
9a91a21f 6313 (match_operand:GPR 3 "s390_slb_comparison" ""))
e69166de 6314 (const_int 0)))
9a91a21f
AS
6315 (set (match_operand:GPR 0 "register_operand" "=d,d")
6316 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
2f7e5a0d 6317 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
e69166de 6318 "@
9a91a21f
AS
6319 slb<g>r\t%0,%2
6320 slb<g>\t%0,%2"
9381e3f1
WG
6321 [(set_attr "op_type" "RRE,RXY")
6322 (set_attr "z10prop" "z10_c,*")])
e69166de 6323
43a09b63 6324; slbr, slb, slbgr, slbg
9a91a21f
AS
6325(define_insn "*sub<mode>3_slb"
6326 [(set (match_operand:GPR 0 "register_operand" "=d,d")
6327 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
3e4be43f 6328 (match_operand:GPR 2 "general_operand" "d,T"))
9a91a21f 6329 (match_operand:GPR 3 "s390_slb_comparison" "")))
ae156f85 6330 (clobber (reg:CC CC_REGNUM))]
2f7e5a0d 6331 "TARGET_CPU_ZARCH"
e69166de 6332 "@
9a91a21f
AS
6333 slb<g>r\t%0,%2
6334 slb<g>\t%0,%2"
9381e3f1
WG
6335 [(set_attr "op_type" "RRE,RXY")
6336 (set_attr "z10prop" "z10_c,*")])
e69166de 6337
9a91a21f
AS
6338(define_expand "add<mode>cc"
6339 [(match_operand:GPR 0 "register_operand" "")
5d880bd2 6340 (match_operand 1 "comparison_operator" "")
9a91a21f
AS
6341 (match_operand:GPR 2 "register_operand" "")
6342 (match_operand:GPR 3 "const_int_operand" "")]
5d880bd2 6343 "TARGET_CPU_ZARCH"
9381e3f1 6344 "if (!s390_expand_addcc (GET_CODE (operands[1]),
f90b7a5a 6345 XEXP (operands[1], 0), XEXP (operands[1], 1),
9381e3f1 6346 operands[0], operands[2],
5d880bd2
UW
6347 operands[3])) FAIL; DONE;")
6348
6349;
6350; scond instruction pattern(s).
6351;
6352
9a91a21f
AS
6353(define_insn_and_split "*scond<mode>"
6354 [(set (match_operand:GPR 0 "register_operand" "=&d")
6355 (match_operand:GPR 1 "s390_alc_comparison" ""))
ae156f85 6356 (clobber (reg:CC CC_REGNUM))]
5d880bd2
UW
6357 "TARGET_CPU_ZARCH"
6358 "#"
6359 "&& reload_completed"
6360 [(set (match_dup 0) (const_int 0))
6361 (parallel
a94a76a7
UW
6362 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
6363 (match_dup 0)))
ae156f85 6364 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 6365 "")
5d880bd2 6366
9a91a21f
AS
6367(define_insn_and_split "*scond<mode>_neg"
6368 [(set (match_operand:GPR 0 "register_operand" "=&d")
6369 (match_operand:GPR 1 "s390_slb_comparison" ""))
ae156f85 6370 (clobber (reg:CC CC_REGNUM))]
5d880bd2
UW
6371 "TARGET_CPU_ZARCH"
6372 "#"
6373 "&& reload_completed"
6374 [(set (match_dup 0) (const_int 0))
6375 (parallel
9a91a21f
AS
6376 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
6377 (match_dup 1)))
ae156f85 6378 (clobber (reg:CC CC_REGNUM))])
5d880bd2 6379 (parallel
9a91a21f 6380 [(set (match_dup 0) (neg:GPR (match_dup 0)))
ae156f85 6381 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 6382 "")
5d880bd2 6383
5d880bd2 6384
f90b7a5a 6385(define_expand "cstore<mode>4"
9a91a21f 6386 [(set (match_operand:SI 0 "register_operand" "")
f90b7a5a
PB
6387 (match_operator:SI 1 "s390_scond_operator"
6388 [(match_operand:GPR 2 "register_operand" "")
6389 (match_operand:GPR 3 "general_operand" "")]))]
5d880bd2 6390 "TARGET_CPU_ZARCH"
f90b7a5a 6391 "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3],
5d880bd2
UW
6392 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
6393
f90b7a5a 6394(define_expand "cstorecc4"
69950452 6395 [(parallel
f90b7a5a
PB
6396 [(set (match_operand:SI 0 "register_operand" "")
6397 (match_operator:SI 1 "s390_eqne_operator"
6398 [(match_operand:CCZ1 2 "register_operand")
6399 (match_operand 3 "const0_operand")]))
69950452
AS
6400 (clobber (reg:CC CC_REGNUM))])]
6401 ""
f90b7a5a
PB
6402 "emit_insn (gen_sne (operands[0], operands[2]));
6403 if (GET_CODE (operands[1]) == EQ)
6404 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
6405 DONE;")
69950452 6406
f90b7a5a 6407(define_insn_and_split "sne"
69950452 6408 [(set (match_operand:SI 0 "register_operand" "=d")
9381e3f1 6409 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
69950452
AS
6410 (const_int 0)))
6411 (clobber (reg:CC CC_REGNUM))]
6412 ""
6413 "#"
6414 "reload_completed"
6415 [(parallel
6416 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
6417 (clobber (reg:CC CC_REGNUM))])])
6418
e69166de 6419
65b1d8ea
AK
6420;;
6421;; - Conditional move instructions (introduced with z196)
6422;;
6423
6424(define_expand "mov<mode>cc"
6425 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
6426 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
6427 (match_operand:GPR 2 "nonimmediate_operand" "")
6428 (match_operand:GPR 3 "nonimmediate_operand" "")))]
6429 "TARGET_Z196"
7477de01
AK
6430{
6431 /* Emit the comparison insn in case we do not already have a comparison result. */
6432 if (!s390_comparison (operands[1], VOIDmode))
6433 operands[1] = s390_emit_compare (GET_CODE (operands[1]),
6434 XEXP (operands[1], 0),
6435 XEXP (operands[1], 1));
6436})
65b1d8ea 6437
bf749919 6438; locr, loc, stoc, locgr, locg, stocg, lochi, locghi
65b1d8ea 6439(define_insn_and_split "*mov<mode>cc"
bf749919 6440 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,S,S,&d")
65b1d8ea
AK
6441 (if_then_else:GPR
6442 (match_operator 1 "s390_comparison"
bf749919 6443 [(match_operand 2 "cc_reg_operand" " c,c,c,c,c,c,c,c,c")
5a3fe9b6 6444 (match_operand 5 "const_int_operand" "")])
bf749919
DV
6445 (match_operand:GPR 3 "loc_operand" " d,0,S,0,K,0,d,0,S")
6446 (match_operand:GPR 4 "loc_operand" " 0,d,0,S,0,K,0,d,S")))]
65b1d8ea
AK
6447 "TARGET_Z196"
6448 "@
6449 loc<g>r%C1\t%0,%3
6450 loc<g>r%D1\t%0,%4
a6510374
AK
6451 loc<g>%C1\t%0,%3
6452 loc<g>%D1\t%0,%4
bf749919
DV
6453 loc<g>hi%C1\t%0,%h3
6454 loc<g>hi%D1\t%0,%h4
a6510374
AK
6455 stoc<g>%C1\t%3,%0
6456 stoc<g>%D1\t%4,%0
65b1d8ea
AK
6457 #"
6458 "&& reload_completed
6459 && MEM_P (operands[3]) && MEM_P (operands[4])"
6460 [(set (match_dup 0)
6461 (if_then_else:GPR
6462 (match_op_dup 1 [(match_dup 2) (const_int 0)])
6463 (match_dup 3)
6464 (match_dup 0)))
6465 (set (match_dup 0)
6466 (if_then_else:GPR
6467 (match_op_dup 1 [(match_dup 2) (const_int 0)])
6468 (match_dup 0)
6469 (match_dup 4)))]
6470 ""
bf749919
DV
6471 [(set_attr "op_type" "RRF,RRF,RSY,RSY,RIE,RIE,RSY,RSY,*")
6472 (set_attr "cpu_facility" "*,*,*,*,z13,z13,*,*,*")])
65b1d8ea 6473
9db1d521
HP
6474;;
6475;;- Multiply instructions.
6476;;
6477
4023fb28
UW
6478;
6479; muldi3 instruction pattern(s).
6480;
9db1d521 6481
07893d4f
UW
6482(define_insn "*muldi3_sign"
6483 [(set (match_operand:DI 0 "register_operand" "=d,d")
3e4be43f 6484 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f 6485 (match_operand:DI 1 "register_operand" "0,0")))]
9602b6a1 6486 "TARGET_ZARCH"
07893d4f 6487 "@
d40c829f
UW
6488 msgfr\t%0,%2
6489 msgf\t%0,%2"
963fc8d0
AK
6490 [(set_attr "op_type" "RRE,RXY")
6491 (set_attr "type" "imuldi")])
07893d4f 6492
4023fb28 6493(define_insn "muldi3"
963fc8d0
AK
6494 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
6495 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
3e4be43f 6496 (match_operand:DI 2 "general_operand" "d,K,T,Os")))]
9602b6a1 6497 "TARGET_ZARCH"
9db1d521 6498 "@
d40c829f
UW
6499 msgr\t%0,%2
6500 mghi\t%0,%h2
963fc8d0
AK
6501 msg\t%0,%2
6502 msgfi\t%0,%2"
6503 [(set_attr "op_type" "RRE,RI,RXY,RIL")
6504 (set_attr "type" "imuldi")
6505 (set_attr "cpu_facility" "*,*,*,z10")])
f2d3c02a 6506
9db1d521
HP
6507;
6508; mulsi3 instruction pattern(s).
6509;
6510
f1e77d83 6511(define_insn "*mulsi3_sign"
963fc8d0
AK
6512 [(set (match_operand:SI 0 "register_operand" "=d,d")
6513 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
6514 (match_operand:SI 1 "register_operand" "0,0")))]
f1e77d83 6515 ""
963fc8d0
AK
6516 "@
6517 mh\t%0,%2
6518 mhy\t%0,%2"
6519 [(set_attr "op_type" "RX,RXY")
6520 (set_attr "type" "imulhi")
6521 (set_attr "cpu_facility" "*,z10")])
f1e77d83 6522
9db1d521 6523(define_insn "mulsi3"
963fc8d0
AK
6524 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
6525 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
6526 (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
9db1d521
HP
6527 ""
6528 "@
d40c829f
UW
6529 msr\t%0,%2
6530 mhi\t%0,%h2
6531 ms\t%0,%2
963fc8d0
AK
6532 msy\t%0,%2
6533 msfi\t%0,%2"
6534 [(set_attr "op_type" "RRE,RI,RX,RXY,RIL")
6535 (set_attr "type" "imulsi,imulhi,imulsi,imulsi,imulsi")
3e4be43f 6536 (set_attr "cpu_facility" "*,*,*,longdisp,z10")])
9db1d521 6537
4023fb28
UW
6538;
6539; mulsidi3 instruction pattern(s).
6540;
6541
f1e77d83 6542(define_insn "mulsidi3"
963fc8d0 6543 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
f1e77d83 6544 (mult:DI (sign_extend:DI
963fc8d0 6545 (match_operand:SI 1 "register_operand" "%0,0,0"))
f1e77d83 6546 (sign_extend:DI
963fc8d0 6547 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
9602b6a1 6548 "!TARGET_ZARCH"
f1e77d83
UW
6549 "@
6550 mr\t%0,%2
963fc8d0
AK
6551 m\t%0,%2
6552 mfy\t%0,%2"
6553 [(set_attr "op_type" "RR,RX,RXY")
6554 (set_attr "type" "imulsi")
6555 (set_attr "cpu_facility" "*,*,z10")])
4023fb28 6556
f1e77d83 6557;
6e0d70c9 6558; umul instruction pattern(s).
f1e77d83 6559;
c7453384 6560
6e0d70c9
AK
6561; mlr, ml, mlgr, mlg
6562(define_insn "umul<dwh><mode>3"
3e4be43f 6563 [(set (match_operand:DW 0 "register_operand" "=d,d")
6e0d70c9 6564 (mult:DW (zero_extend:DW
3e4be43f 6565 (match_operand:<DWH> 1 "register_operand" "%0,0"))
6e0d70c9 6566 (zero_extend:DW
3e4be43f 6567 (match_operand:<DWH> 2 "nonimmediate_operand" " d,T"))))]
6e0d70c9 6568 "TARGET_CPU_ZARCH"
f1e77d83 6569 "@
6e0d70c9
AK
6570 ml<tg>r\t%0,%2
6571 ml<tg>\t%0,%2"
f1e77d83 6572 [(set_attr "op_type" "RRE,RXY")
6e0d70c9 6573 (set_attr "type" "imul<dwh>")])
c7453384 6574
9db1d521 6575;
609e7e80 6576; mul(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
6577;
6578
9381e3f1 6579; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
142cd70f 6580(define_insn "mul<mode>3"
62d3f261
AK
6581 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
6582 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0,v")
6583 (match_operand:FP 2 "general_operand" "f,f,R,v")))]
142cd70f 6584 "TARGET_HARD_FLOAT"
9db1d521 6585 "@
62d3f261
AK
6586 m<xdee>tr\t%0,%1,%2
6587 m<xdee>br\t%0,%2
6e5b5de8
AK
6588 m<xdee>b\t%0,%2
6589 wfmdb\t%v0,%v1,%v2"
62d3f261 6590 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6e5b5de8 6591 (set_attr "type" "fmul<mode>")
62d3f261
AK
6592 (set_attr "cpu_facility" "*,*,*,vec")
6593 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
9db1d521 6594
9381e3f1 6595; madbr, maebr, maxb, madb, maeb
d7ecb504 6596(define_insn "fma<mode>4"
62d3f261
AK
6597 [(set (match_operand:DSF 0 "register_operand" "=f,f,v")
6598 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f,v")
6599 (match_operand:DSF 2 "nonimmediate_operand" "f,R,v")
6600 (match_operand:DSF 3 "register_operand" "0,0,v")))]
d7ecb504 6601 "TARGET_HARD_FLOAT"
a1b892b5 6602 "@
f61a2c7d 6603 ma<xde>br\t%0,%1,%2
6e5b5de8
AK
6604 ma<xde>b\t%0,%1,%2
6605 wfmadb\t%v0,%v1,%v2,%v3"
6606 [(set_attr "op_type" "RRE,RXE,VRR")
6607 (set_attr "type" "fmadd<mode>")
62d3f261
AK
6608 (set_attr "cpu_facility" "*,*,vec")
6609 (set_attr "enabled" "*,*,<DFDI>")])
a1b892b5 6610
43a09b63 6611; msxbr, msdbr, msebr, msxb, msdb, mseb
d7ecb504 6612(define_insn "fms<mode>4"
62d3f261
AK
6613 [(set (match_operand:DSF 0 "register_operand" "=f,f,v")
6614 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f,v")
6615 (match_operand:DSF 2 "nonimmediate_operand" "f,R,v")
6616 (neg:DSF (match_operand:DSF 3 "register_operand" "0,0,v"))))]
d7ecb504 6617 "TARGET_HARD_FLOAT"
a1b892b5 6618 "@
f61a2c7d 6619 ms<xde>br\t%0,%1,%2
6e5b5de8
AK
6620 ms<xde>b\t%0,%1,%2
6621 wfmsdb\t%v0,%v1,%v2,%v3"
6622 [(set_attr "op_type" "RRE,RXE,VRR")
6623 (set_attr "type" "fmadd<mode>")
62d3f261
AK
6624 (set_attr "cpu_facility" "*,*,vec")
6625 (set_attr "enabled" "*,*,<DFDI>")])
9db1d521
HP
6626
6627;;
6628;;- Divide and modulo instructions.
6629;;
6630
6631;
4023fb28 6632; divmoddi4 instruction pattern(s).
9db1d521
HP
6633;
6634
4023fb28
UW
6635(define_expand "divmoddi4"
6636 [(parallel [(set (match_operand:DI 0 "general_operand" "")
f1e77d83 6637 (div:DI (match_operand:DI 1 "register_operand" "")
4023fb28
UW
6638 (match_operand:DI 2 "general_operand" "")))
6639 (set (match_operand:DI 3 "general_operand" "")
6640 (mod:DI (match_dup 1) (match_dup 2)))])
6641 (clobber (match_dup 4))]
9602b6a1 6642 "TARGET_ZARCH"
9db1d521 6643{
f1e77d83 6644 rtx insn, div_equal, mod_equal;
4023fb28
UW
6645
6646 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
6647 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4023fb28
UW
6648
6649 operands[4] = gen_reg_rtx(TImode);
f1e77d83 6650 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4023fb28
UW
6651
6652 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
bd94cb6e 6653 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6654
6655 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
bd94cb6e 6656 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6657
9db1d521 6658 DONE;
10bbf137 6659})
9db1d521
HP
6660
6661(define_insn "divmodtidi3"
4023fb28
UW
6662 [(set (match_operand:TI 0 "register_operand" "=d,d")
6663 (ior:TI
4023fb28
UW
6664 (ashift:TI
6665 (zero_extend:TI
5665e398 6666 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 6667 (match_operand:DI 2 "general_operand" "d,T")))
5665e398
UW
6668 (const_int 64))
6669 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
9602b6a1 6670 "TARGET_ZARCH"
9db1d521 6671 "@
d40c829f
UW
6672 dsgr\t%0,%2
6673 dsg\t%0,%2"
d3632d41 6674 [(set_attr "op_type" "RRE,RXY")
077dab3b 6675 (set_attr "type" "idiv")])
9db1d521 6676
4023fb28
UW
6677(define_insn "divmodtisi3"
6678 [(set (match_operand:TI 0 "register_operand" "=d,d")
6679 (ior:TI
4023fb28
UW
6680 (ashift:TI
6681 (zero_extend:TI
5665e398 6682 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
2f7e5a0d 6683 (sign_extend:DI
3e4be43f 6684 (match_operand:SI 2 "nonimmediate_operand" "d,T"))))
5665e398
UW
6685 (const_int 64))
6686 (zero_extend:TI
6687 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
9602b6a1 6688 "TARGET_ZARCH"
4023fb28 6689 "@
d40c829f
UW
6690 dsgfr\t%0,%2
6691 dsgf\t%0,%2"
d3632d41 6692 [(set_attr "op_type" "RRE,RXY")
077dab3b 6693 (set_attr "type" "idiv")])
9db1d521 6694
4023fb28
UW
6695;
6696; udivmoddi4 instruction pattern(s).
6697;
9db1d521 6698
4023fb28
UW
6699(define_expand "udivmoddi4"
6700 [(parallel [(set (match_operand:DI 0 "general_operand" "")
6701 (udiv:DI (match_operand:DI 1 "general_operand" "")
6702 (match_operand:DI 2 "nonimmediate_operand" "")))
6703 (set (match_operand:DI 3 "general_operand" "")
6704 (umod:DI (match_dup 1) (match_dup 2)))])
6705 (clobber (match_dup 4))]
9602b6a1 6706 "TARGET_ZARCH"
9db1d521 6707{
4023fb28
UW
6708 rtx insn, div_equal, mod_equal, equal;
6709
6710 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
6711 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
6712 equal = gen_rtx_IOR (TImode,
4023fb28
UW
6713 gen_rtx_ASHIFT (TImode,
6714 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
5665e398
UW
6715 GEN_INT (64)),
6716 gen_rtx_ZERO_EXTEND (TImode, div_equal));
4023fb28
UW
6717
6718 operands[4] = gen_reg_rtx(TImode);
c41c1387 6719 emit_clobber (operands[4]);
4023fb28
UW
6720 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
6721 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
bd94cb6e 6722
4023fb28 6723 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6724 set_unique_reg_note (insn, REG_EQUAL, equal);
4023fb28
UW
6725
6726 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
bd94cb6e 6727 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6728
6729 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
bd94cb6e 6730 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6731
9db1d521 6732 DONE;
10bbf137 6733})
9db1d521
HP
6734
6735(define_insn "udivmodtidi3"
4023fb28 6736 [(set (match_operand:TI 0 "register_operand" "=d,d")
2f7e5a0d 6737 (ior:TI
5665e398
UW
6738 (ashift:TI
6739 (zero_extend:TI
6740 (truncate:DI
2f7e5a0d
EC
6741 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
6742 (zero_extend:TI
3e4be43f 6743 (match_operand:DI 2 "nonimmediate_operand" "d,T")))))
5665e398
UW
6744 (const_int 64))
6745 (zero_extend:TI
6746 (truncate:DI
6747 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
9602b6a1 6748 "TARGET_ZARCH"
9db1d521 6749 "@
d40c829f
UW
6750 dlgr\t%0,%2
6751 dlg\t%0,%2"
d3632d41 6752 [(set_attr "op_type" "RRE,RXY")
077dab3b 6753 (set_attr "type" "idiv")])
9db1d521
HP
6754
6755;
4023fb28 6756; divmodsi4 instruction pattern(s).
9db1d521
HP
6757;
6758
4023fb28
UW
6759(define_expand "divmodsi4"
6760 [(parallel [(set (match_operand:SI 0 "general_operand" "")
6761 (div:SI (match_operand:SI 1 "general_operand" "")
6762 (match_operand:SI 2 "nonimmediate_operand" "")))
6763 (set (match_operand:SI 3 "general_operand" "")
6764 (mod:SI (match_dup 1) (match_dup 2)))])
6765 (clobber (match_dup 4))]
9602b6a1 6766 "!TARGET_ZARCH"
9db1d521 6767{
4023fb28
UW
6768 rtx insn, div_equal, mod_equal, equal;
6769
6770 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
6771 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
6772 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6773 gen_rtx_ASHIFT (DImode,
6774 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5665e398
UW
6775 GEN_INT (32)),
6776 gen_rtx_ZERO_EXTEND (DImode, div_equal));
4023fb28
UW
6777
6778 operands[4] = gen_reg_rtx(DImode);
6779 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
bd94cb6e 6780
4023fb28 6781 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6782 set_unique_reg_note (insn, REG_EQUAL, equal);
4023fb28
UW
6783
6784 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
bd94cb6e 6785 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6786
6787 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
bd94cb6e 6788 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6789
9db1d521 6790 DONE;
10bbf137 6791})
9db1d521
HP
6792
6793(define_insn "divmoddisi3"
4023fb28 6794 [(set (match_operand:DI 0 "register_operand" "=d,d")
2f7e5a0d 6795 (ior:DI
5665e398
UW
6796 (ashift:DI
6797 (zero_extend:DI
6798 (truncate:SI
2f7e5a0d
EC
6799 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
6800 (sign_extend:DI
5665e398
UW
6801 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
6802 (const_int 32))
6803 (zero_extend:DI
6804 (truncate:SI
6805 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
9602b6a1 6806 "!TARGET_ZARCH"
9db1d521 6807 "@
d40c829f
UW
6808 dr\t%0,%2
6809 d\t%0,%2"
9db1d521 6810 [(set_attr "op_type" "RR,RX")
077dab3b 6811 (set_attr "type" "idiv")])
9db1d521
HP
6812
6813;
6814; udivsi3 and umodsi3 instruction pattern(s).
6815;
6816
f1e77d83
UW
6817(define_expand "udivmodsi4"
6818 [(parallel [(set (match_operand:SI 0 "general_operand" "")
6819 (udiv:SI (match_operand:SI 1 "general_operand" "")
6820 (match_operand:SI 2 "nonimmediate_operand" "")))
6821 (set (match_operand:SI 3 "general_operand" "")
6822 (umod:SI (match_dup 1) (match_dup 2)))])
6823 (clobber (match_dup 4))]
9602b6a1 6824 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1e77d83
UW
6825{
6826 rtx insn, div_equal, mod_equal, equal;
6827
6828 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6829 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6830 equal = gen_rtx_IOR (DImode,
f1e77d83
UW
6831 gen_rtx_ASHIFT (DImode,
6832 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5665e398
UW
6833 GEN_INT (32)),
6834 gen_rtx_ZERO_EXTEND (DImode, div_equal));
f1e77d83
UW
6835
6836 operands[4] = gen_reg_rtx(DImode);
c41c1387 6837 emit_clobber (operands[4]);
f1e77d83
UW
6838 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
6839 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
bd94cb6e 6840
f1e77d83 6841 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6842 set_unique_reg_note (insn, REG_EQUAL, equal);
f1e77d83
UW
6843
6844 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
bd94cb6e 6845 set_unique_reg_note (insn, REG_EQUAL, div_equal);
f1e77d83
UW
6846
6847 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
bd94cb6e 6848 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
f1e77d83
UW
6849
6850 DONE;
6851})
6852
6853(define_insn "udivmoddisi3"
6854 [(set (match_operand:DI 0 "register_operand" "=d,d")
2f7e5a0d 6855 (ior:DI
5665e398
UW
6856 (ashift:DI
6857 (zero_extend:DI
6858 (truncate:SI
2f7e5a0d
EC
6859 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
6860 (zero_extend:DI
3e4be43f 6861 (match_operand:SI 2 "nonimmediate_operand" "d,T")))))
5665e398
UW
6862 (const_int 32))
6863 (zero_extend:DI
6864 (truncate:SI
6865 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
9602b6a1 6866 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1e77d83
UW
6867 "@
6868 dlr\t%0,%2
6869 dl\t%0,%2"
6870 [(set_attr "op_type" "RRE,RXY")
6871 (set_attr "type" "idiv")])
4023fb28 6872
9db1d521
HP
6873(define_expand "udivsi3"
6874 [(set (match_operand:SI 0 "register_operand" "=d")
6875 (udiv:SI (match_operand:SI 1 "general_operand" "")
4023fb28
UW
6876 (match_operand:SI 2 "general_operand" "")))
6877 (clobber (match_dup 3))]
9602b6a1 6878 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
9db1d521 6879{
4023fb28
UW
6880 rtx insn, udiv_equal, umod_equal, equal;
6881
6882 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6883 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6884 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6885 gen_rtx_ASHIFT (DImode,
6886 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5665e398
UW
6887 GEN_INT (32)),
6888 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
9db1d521 6889
4023fb28 6890 operands[3] = gen_reg_rtx (DImode);
9db1d521
HP
6891
6892 if (CONSTANT_P (operands[2]))
6893 {
6894 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
6895 {
19f8b229 6896 rtx_code_label *label1 = gen_label_rtx ();
9db1d521 6897
4023fb28
UW
6898 operands[1] = make_safe_from (operands[1], operands[0]);
6899 emit_move_insn (operands[0], const0_rtx);
f90b7a5a
PB
6900 emit_cmp_and_jump_insns (operands[1], operands[2], LT, NULL_RTX,
6901 SImode, 1, label1);
4023fb28 6902 emit_move_insn (operands[0], const1_rtx);
9db1d521
HP
6903 emit_label (label1);
6904 }
6905 else
6906 {
c7453384
EC
6907 operands[2] = force_reg (SImode, operands[2]);
6908 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
6909
6910 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6911 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6912 operands[2]));
bd94cb6e 6913 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
6914
6915 insn = emit_move_insn (operands[0],
4023fb28 6916 gen_lowpart (SImode, operands[3]));
bd94cb6e 6917 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
9db1d521
HP
6918 }
6919 }
6920 else
c7453384 6921 {
19f8b229
TS
6922 rtx_code_label *label1 = gen_label_rtx ();
6923 rtx_code_label *label2 = gen_label_rtx ();
6924 rtx_code_label *label3 = gen_label_rtx ();
9db1d521 6925
c7453384
EC
6926 operands[1] = force_reg (SImode, operands[1]);
6927 operands[1] = make_safe_from (operands[1], operands[0]);
6928 operands[2] = force_reg (SImode, operands[2]);
6929 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
6930
6931 emit_move_insn (operands[0], const0_rtx);
f90b7a5a
PB
6932 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
6933 SImode, 1, label3);
6934 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
6935 SImode, 0, label2);
6936 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
6937 SImode, 0, label1);
4023fb28
UW
6938 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6939 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6940 operands[2]));
bd94cb6e 6941 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
6942
6943 insn = emit_move_insn (operands[0],
4023fb28 6944 gen_lowpart (SImode, operands[3]));
bd94cb6e
SB
6945 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
6946
f314b9b1 6947 emit_jump (label3);
9db1d521 6948 emit_label (label1);
4023fb28 6949 emit_move_insn (operands[0], operands[1]);
f314b9b1 6950 emit_jump (label3);
9db1d521 6951 emit_label (label2);
4023fb28 6952 emit_move_insn (operands[0], const1_rtx);
9db1d521
HP
6953 emit_label (label3);
6954 }
c7453384 6955 emit_move_insn (operands[0], operands[0]);
9db1d521 6956 DONE;
10bbf137 6957})
9db1d521
HP
6958
6959(define_expand "umodsi3"
6960 [(set (match_operand:SI 0 "register_operand" "=d")
6961 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
4023fb28
UW
6962 (match_operand:SI 2 "nonimmediate_operand" "")))
6963 (clobber (match_dup 3))]
9602b6a1 6964 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
9db1d521 6965{
4023fb28
UW
6966 rtx insn, udiv_equal, umod_equal, equal;
6967
6968 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6969 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6970 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6971 gen_rtx_ASHIFT (DImode,
6972 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5665e398
UW
6973 GEN_INT (32)),
6974 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
9db1d521 6975
4023fb28 6976 operands[3] = gen_reg_rtx (DImode);
9db1d521
HP
6977
6978 if (CONSTANT_P (operands[2]))
6979 {
6980 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
6981 {
19f8b229 6982 rtx_code_label *label1 = gen_label_rtx ();
9db1d521 6983
4023fb28
UW
6984 operands[1] = make_safe_from (operands[1], operands[0]);
6985 emit_move_insn (operands[0], operands[1]);
f90b7a5a
PB
6986 emit_cmp_and_jump_insns (operands[0], operands[2], LT, NULL_RTX,
6987 SImode, 1, label1);
4023fb28
UW
6988 emit_insn (gen_abssi2 (operands[0], operands[2]));
6989 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
9db1d521
HP
6990 emit_label (label1);
6991 }
6992 else
6993 {
c7453384
EC
6994 operands[2] = force_reg (SImode, operands[2]);
6995 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
6996
6997 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6998 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6999 operands[2]));
bd94cb6e 7000 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
7001
7002 insn = emit_move_insn (operands[0],
4023fb28 7003 gen_highpart (SImode, operands[3]));
bd94cb6e 7004 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
9db1d521
HP
7005 }
7006 }
7007 else
7008 {
19f8b229
TS
7009 rtx_code_label *label1 = gen_label_rtx ();
7010 rtx_code_label *label2 = gen_label_rtx ();
7011 rtx_code_label *label3 = gen_label_rtx ();
9db1d521 7012
c7453384
EC
7013 operands[1] = force_reg (SImode, operands[1]);
7014 operands[1] = make_safe_from (operands[1], operands[0]);
7015 operands[2] = force_reg (SImode, operands[2]);
7016 operands[2] = make_safe_from (operands[2], operands[0]);
9db1d521 7017
c7453384 7018 emit_move_insn(operands[0], operands[1]);
f90b7a5a
PB
7019 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
7020 SImode, 1, label3);
7021 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
7022 SImode, 0, label2);
7023 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
7024 SImode, 0, label1);
4023fb28
UW
7025 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
7026 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
7027 operands[2]));
bd94cb6e 7028 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
7029
7030 insn = emit_move_insn (operands[0],
4023fb28 7031 gen_highpart (SImode, operands[3]));
bd94cb6e
SB
7032 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
7033
f314b9b1 7034 emit_jump (label3);
9db1d521 7035 emit_label (label1);
4023fb28 7036 emit_move_insn (operands[0], const0_rtx);
f314b9b1 7037 emit_jump (label3);
9db1d521 7038 emit_label (label2);
4023fb28 7039 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
9db1d521
HP
7040 emit_label (label3);
7041 }
9db1d521 7042 DONE;
10bbf137 7043})
9db1d521
HP
7044
7045;
f5905b37 7046; div(df|sf)3 instruction pattern(s).
9db1d521
HP
7047;
7048
609e7e80 7049; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
142cd70f 7050(define_insn "div<mode>3"
62d3f261
AK
7051 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
7052 (div:FP (match_operand:FP 1 "register_operand" "f,0,0,v")
7053 (match_operand:FP 2 "general_operand" "f,f,R,v")))]
142cd70f 7054 "TARGET_HARD_FLOAT"
9db1d521 7055 "@
62d3f261
AK
7056 d<xde>tr\t%0,%1,%2
7057 d<xde>br\t%0,%2
6e5b5de8
AK
7058 d<xde>b\t%0,%2
7059 wfddb\t%v0,%v1,%v2"
62d3f261 7060 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6e5b5de8 7061 (set_attr "type" "fdiv<mode>")
62d3f261
AK
7062 (set_attr "cpu_facility" "*,*,*,vec")
7063 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
9db1d521 7064
9db1d521
HP
7065
7066;;
7067;;- And instructions.
7068;;
7069
047d35ed
AS
7070(define_expand "and<mode>3"
7071 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7072 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
7073 (match_operand:INT 2 "general_operand" "")))
7074 (clobber (reg:CC CC_REGNUM))]
7075 ""
7076 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
7077
9db1d521
HP
7078;
7079; anddi3 instruction pattern(s).
7080;
7081
7082(define_insn "*anddi3_cc"
ae156f85 7083 [(set (reg CC_REGNUM)
e3140518 7084 (compare
3e4be43f 7085 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0, d")
c2586c82 7086 (match_operand:DI 2 "general_operand" " d,d,T,NxxDw"))
e3140518 7087 (const_int 0)))
3e4be43f 7088 (set (match_operand:DI 0 "register_operand" "=d,d,d, d")
9db1d521 7089 (and:DI (match_dup 1) (match_dup 2)))]
e3140518 7090 "TARGET_ZARCH && s390_match_ccmode(insn, CCTmode)"
9db1d521 7091 "@
d40c829f 7092 ngr\t%0,%2
65b1d8ea 7093 ngrk\t%0,%1,%2
e3140518
RH
7094 ng\t%0,%2
7095 risbg\t%0,%1,%s2,128+%e2,0"
7096 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
7097 (set_attr "cpu_facility" "*,z196,*,z10")
7098 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521
HP
7099
7100(define_insn "*anddi3_cconly"
ae156f85 7101 [(set (reg CC_REGNUM)
e3140518 7102 (compare
3e4be43f 7103 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0, d")
c2586c82 7104 (match_operand:DI 2 "general_operand" " d,d,T,NxxDw"))
9db1d521 7105 (const_int 0)))
3e4be43f 7106 (clobber (match_scratch:DI 0 "=d,d,d, d"))]
e3140518
RH
7107 "TARGET_ZARCH
7108 && s390_match_ccmode(insn, CCTmode)
68f9c5e2
UW
7109 /* Do not steal TM patterns. */
7110 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
9db1d521 7111 "@
d40c829f 7112 ngr\t%0,%2
65b1d8ea 7113 ngrk\t%0,%1,%2
e3140518
RH
7114 ng\t%0,%2
7115 risbg\t%0,%1,%s2,128+%e2,0"
7116 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
7117 (set_attr "cpu_facility" "*,z196,*,z10")
7118 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 7119
3af8e996 7120(define_insn "*anddi3"
65b1d8ea 7121 [(set (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 7122 "=d,d, d, d, d, d, d, d,d,d,d, d, AQ,Q")
e3140518
RH
7123 (and:DI
7124 (match_operand:DI 1 "nonimmediate_operand"
3e4be43f 7125 "%d,o, 0, 0, 0, 0, 0, 0,0,d,0, d, 0,0")
e3140518 7126 (match_operand:DI 2 "general_operand"
c2586c82 7127 "M, M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,d,T,NxxDw,NxQDF,Q")))
ec24698e 7128 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7129 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
7130 "@
7131 #
7132 #
7133 nihh\t%0,%j2
7134 nihl\t%0,%j2
7135 nilh\t%0,%j2
7136 nill\t%0,%j2
7137 nihf\t%0,%m2
7138 nilf\t%0,%m2
7139 ngr\t%0,%2
65b1d8ea 7140 ngrk\t%0,%1,%2
ec24698e 7141 ng\t%0,%2
e3140518 7142 risbg\t%0,%1,%s2,128+%e2,0
ec24698e
UW
7143 #
7144 #"
e3140518
RH
7145 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,RIE,SI,SS")
7146 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,z196,*,z10,*,*")
9381e3f1
WG
7147 (set_attr "z10prop" "*,
7148 *,
7149 z10_super_E1,
7150 z10_super_E1,
7151 z10_super_E1,
7152 z10_super_E1,
7153 z10_super_E1,
7154 z10_super_E1,
7155 z10_super_E1,
65b1d8ea 7156 *,
9381e3f1 7157 z10_super_E1,
e3140518 7158 z10_super_E1,
9381e3f1
WG
7159 *,
7160 *")])
0dfa6c5e
UW
7161
7162(define_split
7163 [(set (match_operand:DI 0 "s_operand" "")
7164 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 7165 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7166 "reload_completed"
7167 [(parallel
7168 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 7169 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7170 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
4023fb28 7171
1a2e356e 7172;; These two are what combine generates for (ashift (zero_extract)).
64c744b9 7173(define_insn "*extzv_<mode>_srl<clobbercc_or_nocc>"
1a2e356e
RH
7174 [(set (match_operand:GPR 0 "register_operand" "=d")
7175 (and:GPR (lshiftrt:GPR
7176 (match_operand:GPR 1 "register_operand" "d")
7177 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
64c744b9
DV
7178 (match_operand:GPR 3 "contiguous_bitmask_operand" "")))]
7179 "<z10_or_zEC12_cond>
1a2e356e
RH
7180 /* Note that even for the SImode pattern, the rotate is always DImode. */
7181 && s390_extzv_shift_ok (<bitsize>, -INTVAL (operands[2]),
7182 INTVAL (operands[3]))"
64c744b9 7183 "<risbg_n>\t%0,%1,%<bfstart>3,128+%<bfend>3,64-%2"
1a2e356e
RH
7184 [(set_attr "op_type" "RIE")
7185 (set_attr "z10prop" "z10_super_E1")])
7186
64c744b9 7187(define_insn "*extzv_<mode>_sll<clobbercc_or_nocc>"
1a2e356e
RH
7188 [(set (match_operand:GPR 0 "register_operand" "=d")
7189 (and:GPR (ashift:GPR
7190 (match_operand:GPR 1 "register_operand" "d")
7191 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
64c744b9
DV
7192 (match_operand:GPR 3 "contiguous_bitmask_operand" "")))]
7193 "<z10_or_zEC12_cond>
1a2e356e
RH
7194 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[2]),
7195 INTVAL (operands[3]))"
64c744b9 7196 "<risbg_n>\t%0,%1,%<bfstart>3,128+%<bfend>3,%2"
1a2e356e
RH
7197 [(set_attr "op_type" "RIE")
7198 (set_attr "z10prop" "z10_super_E1")])
7199
9db1d521
HP
7200
7201;
7202; andsi3 instruction pattern(s).
7203;
7204
7205(define_insn "*andsi3_cc"
ae156f85 7206 [(set (reg CC_REGNUM)
e3140518
RH
7207 (compare
7208 (and:SI
7209 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
7210 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
7211 (const_int 0)))
7212 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d, d")
9db1d521
HP
7213 (and:SI (match_dup 1) (match_dup 2)))]
7214 "s390_match_ccmode(insn, CCTmode)"
7215 "@
ec24698e 7216 nilf\t%0,%o2
d40c829f 7217 nr\t%0,%2
65b1d8ea 7218 nrk\t%0,%1,%2
d40c829f 7219 n\t%0,%2
e3140518
RH
7220 ny\t%0,%2
7221 risbg\t%0,%1,%t2,128+%f2,0"
7222 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
3e4be43f 7223 (set_attr "cpu_facility" "*,*,z196,*,longdisp,z10")
e3140518
RH
7224 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7225 z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521
HP
7226
7227(define_insn "*andsi3_cconly"
ae156f85 7228 [(set (reg CC_REGNUM)
e3140518
RH
7229 (compare
7230 (and:SI
7231 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
7232 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
7233 (const_int 0)))
7234 (clobber (match_scratch:SI 0 "=d,d,d,d,d, d"))]
68f9c5e2
UW
7235 "s390_match_ccmode(insn, CCTmode)
7236 /* Do not steal TM patterns. */
7237 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
9db1d521 7238 "@
ec24698e 7239 nilf\t%0,%o2
d40c829f 7240 nr\t%0,%2
65b1d8ea 7241 nrk\t%0,%1,%2
d40c829f 7242 n\t%0,%2
e3140518
RH
7243 ny\t%0,%2
7244 risbg\t%0,%1,%t2,128+%f2,0"
7245 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
3e4be43f 7246 (set_attr "cpu_facility" "*,*,z196,*,longdisp,z10")
65b1d8ea 7247 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
e3140518 7248 z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 7249
f19a9af7 7250(define_insn "*andsi3_zarch"
65b1d8ea 7251 [(set (match_operand:SI 0 "nonimmediate_operand"
e3140518 7252 "=d,d, d, d, d,d,d,d,d, d, AQ,Q")
0dfa6c5e 7253 (and:SI (match_operand:SI 1 "nonimmediate_operand"
e3140518 7254 "%d,o, 0, 0, 0,0,d,0,0, d, 0,0")
0dfa6c5e 7255 (match_operand:SI 2 "general_operand"
c2586c82 7256 " M,M,N0HSF,N1HSF,Os,d,d,R,T,NxxSw,NxQSF,Q")))
ae156f85 7257 (clobber (reg:CC CC_REGNUM))]
8cb66696 7258 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 7259 "@
f19a9af7
AK
7260 #
7261 #
7262 nilh\t%0,%j2
2f7e5a0d 7263 nill\t%0,%j2
ec24698e 7264 nilf\t%0,%o2
d40c829f 7265 nr\t%0,%2
65b1d8ea 7266 nrk\t%0,%1,%2
d40c829f 7267 n\t%0,%2
8cb66696 7268 ny\t%0,%2
e3140518 7269 risbg\t%0,%1,%t2,128+%f2,0
0dfa6c5e 7270 #
19b63d8e 7271 #"
e3140518 7272 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RRF,RX,RXY,RIE,SI,SS")
3e4be43f 7273 (set_attr "cpu_facility" "*,*,*,*,*,*,z196,*,longdisp,z10,*,*")
9381e3f1
WG
7274 (set_attr "z10prop" "*,
7275 *,
7276 z10_super_E1,
7277 z10_super_E1,
7278 z10_super_E1,
7279 z10_super_E1,
65b1d8ea 7280 *,
9381e3f1
WG
7281 z10_super_E1,
7282 z10_super_E1,
e3140518 7283 z10_super_E1,
9381e3f1
WG
7284 *,
7285 *")])
f19a9af7
AK
7286
7287(define_insn "*andsi3_esa"
65b1d8ea
AK
7288 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d, AQ,Q")
7289 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0, 0,0")
7290 (match_operand:SI 2 "general_operand" " d,R,NxQSF,Q")))
ae156f85 7291 (clobber (reg:CC CC_REGNUM))]
8cb66696 7292 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
f19a9af7
AK
7293 "@
7294 nr\t%0,%2
8cb66696 7295 n\t%0,%2
0dfa6c5e 7296 #
19b63d8e 7297 #"
9381e3f1
WG
7298 [(set_attr "op_type" "RR,RX,SI,SS")
7299 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
7300
0dfa6c5e
UW
7301
7302(define_split
7303 [(set (match_operand:SI 0 "s_operand" "")
7304 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 7305 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7306 "reload_completed"
7307 [(parallel
7308 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 7309 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7310 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
4023fb28 7311
9db1d521
HP
7312;
7313; andhi3 instruction pattern(s).
7314;
7315
8cb66696 7316(define_insn "*andhi3_zarch"
65b1d8ea
AK
7317 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7318 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
7319 (match_operand:HI 2 "general_operand" " d,d,n,NxQHF,Q")))
ae156f85 7320 (clobber (reg:CC CC_REGNUM))]
8cb66696 7321 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7322 "@
d40c829f 7323 nr\t%0,%2
65b1d8ea 7324 nrk\t%0,%1,%2
8cb66696 7325 nill\t%0,%x2
0dfa6c5e 7326 #
19b63d8e 7327 #"
65b1d8ea
AK
7328 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
7329 (set_attr "cpu_facility" "*,z196,*,*,*")
7330 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")
9381e3f1 7331])
8cb66696
UW
7332
7333(define_insn "*andhi3_esa"
0dfa6c5e
UW
7334 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
7335 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
7336 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
ae156f85 7337 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
7338 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7339 "@
7340 nr\t%0,%2
0dfa6c5e 7341 #
19b63d8e 7342 #"
9381e3f1
WG
7343 [(set_attr "op_type" "RR,SI,SS")
7344 (set_attr "z10prop" "z10_super_E1,*,*")
7345])
0dfa6c5e
UW
7346
7347(define_split
7348 [(set (match_operand:HI 0 "s_operand" "")
7349 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 7350 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7351 "reload_completed"
7352 [(parallel
7353 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 7354 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7355 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
9db1d521 7356
9db1d521
HP
7357;
7358; andqi3 instruction pattern(s).
7359;
7360
8cb66696 7361(define_insn "*andqi3_zarch"
65b1d8ea
AK
7362 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7363 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7364 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
ae156f85 7365 (clobber (reg:CC CC_REGNUM))]
8cb66696 7366 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7367 "@
d40c829f 7368 nr\t%0,%2
65b1d8ea 7369 nrk\t%0,%1,%2
8cb66696 7370 nill\t%0,%b2
fc0ea003
UW
7371 ni\t%S0,%b2
7372 niy\t%S0,%b2
19b63d8e 7373 #"
65b1d8ea 7374 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
3e4be43f 7375 (set_attr "cpu_facility" "*,z196,*,*,longdisp,*")
65b1d8ea 7376 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super,z10_super,*")])
8cb66696
UW
7377
7378(define_insn "*andqi3_esa"
7379 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
7380 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7381 (match_operand:QI 2 "general_operand" "d,n,Q")))
ae156f85 7382 (clobber (reg:CC CC_REGNUM))]
8cb66696 7383 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 7384 "@
8cb66696 7385 nr\t%0,%2
fc0ea003 7386 ni\t%S0,%b2
19b63d8e 7387 #"
9381e3f1
WG
7388 [(set_attr "op_type" "RR,SI,SS")
7389 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
4023fb28 7390
deb9351f
DV
7391;
7392; And with complement
7393;
7394; c = ~b & a = (b & a) ^ a
7395
7396(define_insn_and_split "*andc_split_<mode>"
7397 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
7398 (and:GPR (not:GPR (match_operand:GPR 1 "nonimmediate_operand" ""))
7399 (match_operand:GPR 2 "general_operand" "")))
7400 (clobber (reg:CC CC_REGNUM))]
7401 "! reload_completed && s390_logical_operator_ok_p (operands)"
7402 "#"
7403 "&& 1"
7404 [
7405 (parallel
7406 [(set (match_dup 3) (and:GPR (match_dup 1) (match_dup 2)))
7407 (clobber (reg:CC CC_REGNUM))])
7408 (parallel
7409 [(set (match_dup 0) (xor:GPR (match_dup 3) (match_dup 2)))
7410 (clobber (reg:CC CC_REGNUM))])]
7411{
7412 if (reg_overlap_mentioned_p (operands[0], operands[2]))
7413 operands[3] = gen_reg_rtx (<MODE>mode);
7414 else
7415 operands[3] = operands[0];
7416})
7417
19b63d8e
UW
7418;
7419; Block and (NC) patterns.
7420;
7421
7422(define_insn "*nc"
7423 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7424 (and:BLK (match_dup 0)
7425 (match_operand:BLK 1 "memory_operand" "Q")))
7426 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 7427 (clobber (reg:CC CC_REGNUM))]
19b63d8e 7428 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 7429 "nc\t%O0(%2,%R0),%S1"
65b1d8ea
AK
7430 [(set_attr "op_type" "SS")
7431 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
7432
7433(define_split
7434 [(set (match_operand 0 "memory_operand" "")
7435 (and (match_dup 0)
7436 (match_operand 1 "memory_operand" "")))
ae156f85 7437 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
7438 "reload_completed
7439 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7440 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7441 [(parallel
7442 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
7443 (use (match_dup 2))
ae156f85 7444 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7445{
7446 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7447 operands[0] = adjust_address (operands[0], BLKmode, 0);
7448 operands[1] = adjust_address (operands[1], BLKmode, 0);
7449})
7450
7451(define_peephole2
7452 [(parallel
7453 [(set (match_operand:BLK 0 "memory_operand" "")
7454 (and:BLK (match_dup 0)
7455 (match_operand:BLK 1 "memory_operand" "")))
7456 (use (match_operand 2 "const_int_operand" ""))
ae156f85 7457 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
7458 (parallel
7459 [(set (match_operand:BLK 3 "memory_operand" "")
7460 (and:BLK (match_dup 3)
7461 (match_operand:BLK 4 "memory_operand" "")))
7462 (use (match_operand 5 "const_int_operand" ""))
ae156f85 7463 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7464 "s390_offset_p (operands[0], operands[3], operands[2])
7465 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 7466 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 7467 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
7468 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7469 [(parallel
7470 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
7471 (use (match_dup 8))
ae156f85 7472 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7473 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7474 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7475 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7476
9db1d521
HP
7477
7478;;
7479;;- Bit set (inclusive or) instructions.
7480;;
7481
047d35ed
AS
7482(define_expand "ior<mode>3"
7483 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7484 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
7485 (match_operand:INT 2 "general_operand" "")))
7486 (clobber (reg:CC CC_REGNUM))]
7487 ""
7488 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
7489
9db1d521
HP
7490;
7491; iordi3 instruction pattern(s).
7492;
7493
4023fb28 7494(define_insn "*iordi3_cc"
ae156f85 7495 [(set (reg CC_REGNUM)
3e4be43f
UW
7496 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7497 (match_operand:DI 2 "general_operand" " d,d,T"))
4023fb28 7498 (const_int 0)))
3e4be43f 7499 (set (match_operand:DI 0 "register_operand" "=d,d,d")
4023fb28 7500 (ior:DI (match_dup 1) (match_dup 2)))]
9602b6a1 7501 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7502 "@
d40c829f 7503 ogr\t%0,%2
65b1d8ea 7504 ogrk\t%0,%1,%2
d40c829f 7505 og\t%0,%2"
65b1d8ea
AK
7506 [(set_attr "op_type" "RRE,RRF,RXY")
7507 (set_attr "cpu_facility" "*,z196,*")
7508 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28
UW
7509
7510(define_insn "*iordi3_cconly"
ae156f85 7511 [(set (reg CC_REGNUM)
65b1d8ea 7512 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
3e4be43f 7513 (match_operand:DI 2 "general_operand" " d,d,T"))
4023fb28 7514 (const_int 0)))
65b1d8ea 7515 (clobber (match_scratch:DI 0 "=d,d,d"))]
9602b6a1 7516 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7517 "@
d40c829f 7518 ogr\t%0,%2
65b1d8ea 7519 ogrk\t%0,%1,%2
d40c829f 7520 og\t%0,%2"
65b1d8ea
AK
7521 [(set_attr "op_type" "RRE,RRF,RXY")
7522 (set_attr "cpu_facility" "*,z196,*")
7523 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28 7524
3af8e996 7525(define_insn "*iordi3"
65b1d8ea 7526 [(set (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 7527 "=d, d, d, d, d, d,d,d,d, AQ,Q")
65b1d8ea 7528 (ior:DI (match_operand:DI 1 "nonimmediate_operand"
3e4be43f 7529 " %0, 0, 0, 0, 0, 0,0,d,0, 0,0")
ec24698e 7530 (match_operand:DI 2 "general_operand"
3e4be43f 7531 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,d,T,NxQD0,Q")))
ec24698e 7532 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7533 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
7534 "@
7535 oihh\t%0,%i2
7536 oihl\t%0,%i2
7537 oilh\t%0,%i2
7538 oill\t%0,%i2
7539 oihf\t%0,%k2
7540 oilf\t%0,%k2
7541 ogr\t%0,%2
65b1d8ea 7542 ogrk\t%0,%1,%2
ec24698e
UW
7543 og\t%0,%2
7544 #
7545 #"
65b1d8ea
AK
7546 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,SI,SS")
7547 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,z196,*,*,*")
9381e3f1
WG
7548 (set_attr "z10prop" "z10_super_E1,
7549 z10_super_E1,
7550 z10_super_E1,
7551 z10_super_E1,
7552 z10_super_E1,
7553 z10_super_E1,
7554 z10_super_E1,
65b1d8ea 7555 *,
9381e3f1
WG
7556 z10_super_E1,
7557 *,
7558 *")])
0dfa6c5e
UW
7559
7560(define_split
7561 [(set (match_operand:DI 0 "s_operand" "")
7562 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 7563 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7564 "reload_completed"
7565 [(parallel
7566 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 7567 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7568 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
4023fb28 7569
9db1d521
HP
7570;
7571; iorsi3 instruction pattern(s).
7572;
7573
4023fb28 7574(define_insn "*iorsi3_cc"
ae156f85 7575 [(set (reg CC_REGNUM)
65b1d8ea
AK
7576 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7577 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7578 (const_int 0)))
65b1d8ea 7579 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
4023fb28
UW
7580 (ior:SI (match_dup 1) (match_dup 2)))]
7581 "s390_match_ccmode(insn, CCTmode)"
7582 "@
ec24698e 7583 oilf\t%0,%o2
d40c829f 7584 or\t%0,%2
65b1d8ea 7585 ork\t%0,%1,%2
d40c829f
UW
7586 o\t%0,%2
7587 oy\t%0,%2"
65b1d8ea 7588 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
3e4be43f 7589 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
65b1d8ea 7590 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
4023fb28
UW
7591
7592(define_insn "*iorsi3_cconly"
ae156f85 7593 [(set (reg CC_REGNUM)
65b1d8ea
AK
7594 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7595 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7596 (const_int 0)))
65b1d8ea 7597 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
4023fb28
UW
7598 "s390_match_ccmode(insn, CCTmode)"
7599 "@
ec24698e 7600 oilf\t%0,%o2
d40c829f 7601 or\t%0,%2
65b1d8ea 7602 ork\t%0,%1,%2
d40c829f
UW
7603 o\t%0,%2
7604 oy\t%0,%2"
65b1d8ea 7605 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
3e4be43f 7606 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
65b1d8ea 7607 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
4023fb28 7608
8cb66696 7609(define_insn "*iorsi3_zarch"
65b1d8ea
AK
7610 [(set (match_operand:SI 0 "nonimmediate_operand" "=d, d, d,d,d,d,d, AQ,Q")
7611 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0, 0, 0,0,d,0,0, 0,0")
7612 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,d,R,T,NxQS0,Q")))
ae156f85 7613 (clobber (reg:CC CC_REGNUM))]
8cb66696 7614 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7615 "@
f19a9af7
AK
7616 oilh\t%0,%i2
7617 oill\t%0,%i2
ec24698e 7618 oilf\t%0,%o2
d40c829f 7619 or\t%0,%2
65b1d8ea 7620 ork\t%0,%1,%2
d40c829f 7621 o\t%0,%2
8cb66696 7622 oy\t%0,%2
0dfa6c5e 7623 #
19b63d8e 7624 #"
65b1d8ea 7625 [(set_attr "op_type" "RI,RI,RIL,RR,RRF,RX,RXY,SI,SS")
3e4be43f 7626 (set_attr "cpu_facility" "*,*,*,*,z196,*,longdisp,*,*")
9381e3f1
WG
7627 (set_attr "z10prop" "z10_super_E1,
7628 z10_super_E1,
7629 z10_super_E1,
7630 z10_super_E1,
65b1d8ea 7631 *,
9381e3f1
WG
7632 z10_super_E1,
7633 z10_super_E1,
7634 *,
7635 *")])
8cb66696
UW
7636
7637(define_insn "*iorsi3_esa"
0dfa6c5e 7638 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
bad82153 7639 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
0dfa6c5e 7640 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
ae156f85 7641 (clobber (reg:CC CC_REGNUM))]
8cb66696 7642 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
f19a9af7
AK
7643 "@
7644 or\t%0,%2
8cb66696 7645 o\t%0,%2
0dfa6c5e 7646 #
19b63d8e 7647 #"
9381e3f1
WG
7648 [(set_attr "op_type" "RR,RX,SI,SS")
7649 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
0dfa6c5e
UW
7650
7651(define_split
7652 [(set (match_operand:SI 0 "s_operand" "")
7653 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 7654 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7655 "reload_completed"
7656 [(parallel
7657 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 7658 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7659 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
4023fb28 7660
4023fb28
UW
7661;
7662; iorhi3 instruction pattern(s).
7663;
7664
8cb66696 7665(define_insn "*iorhi3_zarch"
65b1d8ea
AK
7666 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7667 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
7668 (match_operand:HI 2 "general_operand" " d,d,n,NxQH0,Q")))
ae156f85 7669 (clobber (reg:CC CC_REGNUM))]
8cb66696 7670 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7671 "@
d40c829f 7672 or\t%0,%2
65b1d8ea 7673 ork\t%0,%1,%2
8cb66696 7674 oill\t%0,%x2
0dfa6c5e 7675 #
19b63d8e 7676 #"
65b1d8ea
AK
7677 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
7678 (set_attr "cpu_facility" "*,z196,*,*,*")
7679 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")])
8cb66696
UW
7680
7681(define_insn "*iorhi3_esa"
0dfa6c5e
UW
7682 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
7683 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
7684 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
ae156f85 7685 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
7686 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7687 "@
7688 or\t%0,%2
0dfa6c5e 7689 #
19b63d8e 7690 #"
9381e3f1
WG
7691 [(set_attr "op_type" "RR,SI,SS")
7692 (set_attr "z10prop" "z10_super_E1,*,*")])
0dfa6c5e
UW
7693
7694(define_split
7695 [(set (match_operand:HI 0 "s_operand" "")
7696 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 7697 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7698 "reload_completed"
7699 [(parallel
7700 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 7701 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7702 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
9db1d521 7703
9db1d521 7704;
4023fb28 7705; iorqi3 instruction pattern(s).
9db1d521
HP
7706;
7707
8cb66696 7708(define_insn "*iorqi3_zarch"
65b1d8ea
AK
7709 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7710 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7711 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
ae156f85 7712 (clobber (reg:CC CC_REGNUM))]
8cb66696 7713 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7714 "@
d40c829f 7715 or\t%0,%2
65b1d8ea 7716 ork\t%0,%1,%2
8cb66696 7717 oill\t%0,%b2
fc0ea003
UW
7718 oi\t%S0,%b2
7719 oiy\t%S0,%b2
19b63d8e 7720 #"
65b1d8ea 7721 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
3e4be43f 7722 (set_attr "cpu_facility" "*,z196,*,*,longdisp,*")
65b1d8ea
AK
7723 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,
7724 z10_super,z10_super,*")])
8cb66696
UW
7725
7726(define_insn "*iorqi3_esa"
7727 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
7728 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7729 (match_operand:QI 2 "general_operand" "d,n,Q")))
ae156f85 7730 (clobber (reg:CC CC_REGNUM))]
8cb66696 7731 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 7732 "@
8cb66696 7733 or\t%0,%2
fc0ea003 7734 oi\t%S0,%b2
19b63d8e 7735 #"
9381e3f1
WG
7736 [(set_attr "op_type" "RR,SI,SS")
7737 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
9db1d521 7738
19b63d8e
UW
7739;
7740; Block inclusive or (OC) patterns.
7741;
7742
7743(define_insn "*oc"
7744 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7745 (ior:BLK (match_dup 0)
7746 (match_operand:BLK 1 "memory_operand" "Q")))
7747 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 7748 (clobber (reg:CC CC_REGNUM))]
19b63d8e 7749 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 7750 "oc\t%O0(%2,%R0),%S1"
65b1d8ea
AK
7751 [(set_attr "op_type" "SS")
7752 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
7753
7754(define_split
7755 [(set (match_operand 0 "memory_operand" "")
7756 (ior (match_dup 0)
7757 (match_operand 1 "memory_operand" "")))
ae156f85 7758 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
7759 "reload_completed
7760 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7761 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7762 [(parallel
7763 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
7764 (use (match_dup 2))
ae156f85 7765 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7766{
7767 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7768 operands[0] = adjust_address (operands[0], BLKmode, 0);
7769 operands[1] = adjust_address (operands[1], BLKmode, 0);
7770})
7771
7772(define_peephole2
7773 [(parallel
7774 [(set (match_operand:BLK 0 "memory_operand" "")
7775 (ior:BLK (match_dup 0)
7776 (match_operand:BLK 1 "memory_operand" "")))
7777 (use (match_operand 2 "const_int_operand" ""))
ae156f85 7778 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
7779 (parallel
7780 [(set (match_operand:BLK 3 "memory_operand" "")
7781 (ior:BLK (match_dup 3)
7782 (match_operand:BLK 4 "memory_operand" "")))
7783 (use (match_operand 5 "const_int_operand" ""))
ae156f85 7784 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7785 "s390_offset_p (operands[0], operands[3], operands[2])
7786 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 7787 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 7788 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
7789 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7790 [(parallel
7791 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
7792 (use (match_dup 8))
ae156f85 7793 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7794 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7795 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7796 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7797
9db1d521
HP
7798
7799;;
7800;;- Xor instructions.
7801;;
7802
047d35ed
AS
7803(define_expand "xor<mode>3"
7804 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7805 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
7806 (match_operand:INT 2 "general_operand" "")))
7807 (clobber (reg:CC CC_REGNUM))]
7808 ""
7809 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
7810
3c91f126
AK
7811; Combine replaces (xor (x) (const_int -1)) with (not (x)) when doing
7812; simplifications. So its better to have something matching.
7813(define_split
7814 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7815 (not:INT (match_operand:INT 1 "nonimmediate_operand" "")))]
7816 ""
7817 [(parallel
7818 [(set (match_dup 0) (xor:INT (match_dup 1) (match_dup 2)))
7819 (clobber (reg:CC CC_REGNUM))])]
7820{
7821 operands[2] = constm1_rtx;
7822 if (!s390_logical_operator_ok_p (operands))
7823 FAIL;
7824})
7825
9db1d521
HP
7826;
7827; xordi3 instruction pattern(s).
7828;
7829
4023fb28 7830(define_insn "*xordi3_cc"
ae156f85 7831 [(set (reg CC_REGNUM)
3e4be43f
UW
7832 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7833 (match_operand:DI 2 "general_operand" " d,d,T"))
4023fb28 7834 (const_int 0)))
3e4be43f 7835 (set (match_operand:DI 0 "register_operand" "=d,d,d")
4023fb28 7836 (xor:DI (match_dup 1) (match_dup 2)))]
9602b6a1 7837 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7838 "@
d40c829f 7839 xgr\t%0,%2
65b1d8ea 7840 xgrk\t%0,%1,%2
d40c829f 7841 xg\t%0,%2"
65b1d8ea 7842 [(set_attr "op_type" "RRE,RRF,RXY")
5490de28 7843 (set_attr "cpu_facility" "*,z196,*")
65b1d8ea 7844 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28
UW
7845
7846(define_insn "*xordi3_cconly"
ae156f85 7847 [(set (reg CC_REGNUM)
3e4be43f
UW
7848 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7849 (match_operand:DI 2 "general_operand" " d,d,T"))
4023fb28 7850 (const_int 0)))
3e4be43f 7851 (clobber (match_scratch:DI 0 "=d,d,d"))]
9602b6a1 7852 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7853 "@
d40c829f 7854 xgr\t%0,%2
65b1d8ea 7855 xgrk\t%0,%1,%2
c7fd8cd8 7856 xg\t%0,%2"
65b1d8ea
AK
7857 [(set_attr "op_type" "RRE,RRF,RXY")
7858 (set_attr "cpu_facility" "*,z196,*")
7859 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28 7860
3af8e996 7861(define_insn "*xordi3"
3e4be43f
UW
7862 [(set (match_operand:DI 0 "nonimmediate_operand" "=d, d,d,d,d, AQ,Q")
7863 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0, 0,0,d,0, 0,0")
7864 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,d,T,NxQD0,Q")))
ec24698e 7865 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7866 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
7867 "@
7868 xihf\t%0,%k2
7869 xilf\t%0,%k2
7870 xgr\t%0,%2
65b1d8ea 7871 xgrk\t%0,%1,%2
ec24698e
UW
7872 xg\t%0,%2
7873 #
7874 #"
65b1d8ea
AK
7875 [(set_attr "op_type" "RIL,RIL,RRE,RRF,RXY,SI,SS")
7876 (set_attr "cpu_facility" "extimm,extimm,*,z196,*,*,*")
7877 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,
7878 *,z10_super_E1,*,*")])
0dfa6c5e
UW
7879
7880(define_split
7881 [(set (match_operand:DI 0 "s_operand" "")
7882 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 7883 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7884 "reload_completed"
7885 [(parallel
7886 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 7887 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7888 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
4023fb28 7889
9db1d521
HP
7890;
7891; xorsi3 instruction pattern(s).
7892;
7893
4023fb28 7894(define_insn "*xorsi3_cc"
ae156f85 7895 [(set (reg CC_REGNUM)
65b1d8ea
AK
7896 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7897 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7898 (const_int 0)))
65b1d8ea 7899 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
4023fb28
UW
7900 (xor:SI (match_dup 1) (match_dup 2)))]
7901 "s390_match_ccmode(insn, CCTmode)"
7902 "@
ec24698e 7903 xilf\t%0,%o2
d40c829f 7904 xr\t%0,%2
65b1d8ea 7905 xrk\t%0,%1,%2
d40c829f
UW
7906 x\t%0,%2
7907 xy\t%0,%2"
65b1d8ea 7908 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
3e4be43f 7909 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
65b1d8ea
AK
7910 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7911 z10_super_E1,z10_super_E1")])
4023fb28
UW
7912
7913(define_insn "*xorsi3_cconly"
ae156f85 7914 [(set (reg CC_REGNUM)
65b1d8ea
AK
7915 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7916 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7917 (const_int 0)))
65b1d8ea 7918 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
4023fb28
UW
7919 "s390_match_ccmode(insn, CCTmode)"
7920 "@
ec24698e 7921 xilf\t%0,%o2
d40c829f 7922 xr\t%0,%2
65b1d8ea 7923 xrk\t%0,%1,%2
d40c829f
UW
7924 x\t%0,%2
7925 xy\t%0,%2"
65b1d8ea 7926 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
3e4be43f 7927 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
65b1d8ea
AK
7928 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7929 z10_super_E1,z10_super_E1")])
9db1d521 7930
8cb66696 7931(define_insn "*xorsi3"
65b1d8ea
AK
7932 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d, AQ,Q")
7933 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, 0,0")
7934 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxQS0,Q")))
ae156f85 7935 (clobber (reg:CC CC_REGNUM))]
8cb66696 7936 "s390_logical_operator_ok_p (operands)"
9db1d521 7937 "@
ec24698e 7938 xilf\t%0,%o2
d40c829f 7939 xr\t%0,%2
65b1d8ea 7940 xrk\t%0,%1,%2
d40c829f 7941 x\t%0,%2
8cb66696 7942 xy\t%0,%2
0dfa6c5e 7943 #
19b63d8e 7944 #"
65b1d8ea 7945 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,SI,SS")
3e4be43f 7946 (set_attr "cpu_facility" "*,*,z196,*,longdisp,*,*")
65b1d8ea
AK
7947 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7948 z10_super_E1,z10_super_E1,*,*")])
0dfa6c5e
UW
7949
7950(define_split
7951 [(set (match_operand:SI 0 "s_operand" "")
7952 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 7953 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7954 "reload_completed"
7955 [(parallel
7956 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 7957 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7958 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
8cb66696 7959
9db1d521
HP
7960;
7961; xorhi3 instruction pattern(s).
7962;
7963
8cb66696 7964(define_insn "*xorhi3"
65b1d8ea
AK
7965 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7966 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,d, 0,0")
7967 (match_operand:HI 2 "general_operand" "Os,d,d,NxQH0,Q")))
ae156f85 7968 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
7969 "s390_logical_operator_ok_p (operands)"
7970 "@
ec24698e 7971 xilf\t%0,%x2
8cb66696 7972 xr\t%0,%2
65b1d8ea 7973 xrk\t%0,%1,%2
0dfa6c5e 7974 #
19b63d8e 7975 #"
65b1d8ea
AK
7976 [(set_attr "op_type" "RIL,RR,RRF,SI,SS")
7977 (set_attr "cpu_facility" "*,*,z196,*,*")
7978 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*,*")])
0dfa6c5e
UW
7979
7980(define_split
7981 [(set (match_operand:HI 0 "s_operand" "")
7982 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 7983 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7984 "reload_completed"
7985 [(parallel
7986 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 7987 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7988 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
9db1d521 7989
9db1d521
HP
7990;
7991; xorqi3 instruction pattern(s).
7992;
7993
8cb66696 7994(define_insn "*xorqi3"
65b1d8ea
AK
7995 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7996 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,d,0,0,0")
7997 (match_operand:QI 2 "general_operand" "Os,d,d,n,n,Q")))
ae156f85 7998 (clobber (reg:CC CC_REGNUM))]
8cb66696 7999 "s390_logical_operator_ok_p (operands)"
9db1d521 8000 "@
ec24698e 8001 xilf\t%0,%b2
8cb66696 8002 xr\t%0,%2
65b1d8ea 8003 xrk\t%0,%1,%2
fc0ea003
UW
8004 xi\t%S0,%b2
8005 xiy\t%S0,%b2
19b63d8e 8006 #"
65b1d8ea 8007 [(set_attr "op_type" "RIL,RR,RRF,SI,SIY,SS")
3e4be43f 8008 (set_attr "cpu_facility" "*,*,z196,*,longdisp,*")
65b1d8ea 8009 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super,z10_super,*")])
9381e3f1 8010
4023fb28 8011
19b63d8e
UW
8012;
8013; Block exclusive or (XC) patterns.
8014;
8015
8016(define_insn "*xc"
8017 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8018 (xor:BLK (match_dup 0)
8019 (match_operand:BLK 1 "memory_operand" "Q")))
8020 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 8021 (clobber (reg:CC CC_REGNUM))]
19b63d8e 8022 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 8023 "xc\t%O0(%2,%R0),%S1"
b628bd8e 8024 [(set_attr "op_type" "SS")])
19b63d8e
UW
8025
8026(define_split
8027 [(set (match_operand 0 "memory_operand" "")
8028 (xor (match_dup 0)
8029 (match_operand 1 "memory_operand" "")))
ae156f85 8030 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
8031 "reload_completed
8032 && GET_MODE (operands[0]) == GET_MODE (operands[1])
8033 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
8034 [(parallel
8035 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
8036 (use (match_dup 2))
ae156f85 8037 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8038{
8039 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
8040 operands[0] = adjust_address (operands[0], BLKmode, 0);
8041 operands[1] = adjust_address (operands[1], BLKmode, 0);
8042})
8043
8044(define_peephole2
8045 [(parallel
8046 [(set (match_operand:BLK 0 "memory_operand" "")
8047 (xor:BLK (match_dup 0)
8048 (match_operand:BLK 1 "memory_operand" "")))
8049 (use (match_operand 2 "const_int_operand" ""))
ae156f85 8050 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
8051 (parallel
8052 [(set (match_operand:BLK 3 "memory_operand" "")
8053 (xor:BLK (match_dup 3)
8054 (match_operand:BLK 4 "memory_operand" "")))
8055 (use (match_operand 5 "const_int_operand" ""))
ae156f85 8056 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8057 "s390_offset_p (operands[0], operands[3], operands[2])
8058 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 8059 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 8060 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
8061 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
8062 [(parallel
8063 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
8064 (use (match_dup 8))
ae156f85 8065 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8066 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8067 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
8068 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
8069
8070;
8071; Block xor (XC) patterns with src == dest.
8072;
8073
8074(define_insn "*xc_zero"
8075 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8076 (const_int 0))
8077 (use (match_operand 1 "const_int_operand" "n"))
ae156f85 8078 (clobber (reg:CC CC_REGNUM))]
19b63d8e 8079 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
fc0ea003 8080 "xc\t%O0(%1,%R0),%S0"
65b1d8ea
AK
8081 [(set_attr "op_type" "SS")
8082 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
8083
8084(define_peephole2
8085 [(parallel
8086 [(set (match_operand:BLK 0 "memory_operand" "")
8087 (const_int 0))
8088 (use (match_operand 1 "const_int_operand" ""))
ae156f85 8089 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
8090 (parallel
8091 [(set (match_operand:BLK 2 "memory_operand" "")
8092 (const_int 0))
8093 (use (match_operand 3 "const_int_operand" ""))
ae156f85 8094 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8095 "s390_offset_p (operands[0], operands[2], operands[1])
8096 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
8097 [(parallel
8098 [(set (match_dup 4) (const_int 0))
8099 (use (match_dup 5))
ae156f85 8100 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8101 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8102 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
8103
9db1d521
HP
8104
8105;;
8106;;- Negate instructions.
8107;;
8108
8109;
9a91a21f 8110; neg(di|si)2 instruction pattern(s).
9db1d521
HP
8111;
8112
9a91a21f 8113(define_expand "neg<mode>2"
9db1d521 8114 [(parallel
9a91a21f
AS
8115 [(set (match_operand:DSI 0 "register_operand" "=d")
8116 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
ae156f85 8117 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8118 ""
8119 "")
8120
26a89301 8121(define_insn "*negdi2_sign_cc"
ae156f85 8122 [(set (reg CC_REGNUM)
26a89301
UW
8123 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
8124 (match_operand:SI 1 "register_operand" "d") 0)
8125 (const_int 32)) (const_int 32)))
8126 (const_int 0)))
8127 (set (match_operand:DI 0 "register_operand" "=d")
8128 (neg:DI (sign_extend:DI (match_dup 1))))]
9602b6a1 8129 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 8130 "lcgfr\t%0,%1"
729e750f
WG
8131 [(set_attr "op_type" "RRE")
8132 (set_attr "z10prop" "z10_c")])
9381e3f1 8133
26a89301
UW
8134(define_insn "*negdi2_sign"
8135 [(set (match_operand:DI 0 "register_operand" "=d")
8136 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
ae156f85 8137 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8138 "TARGET_ZARCH"
26a89301 8139 "lcgfr\t%0,%1"
729e750f
WG
8140 [(set_attr "op_type" "RRE")
8141 (set_attr "z10prop" "z10_c")])
26a89301 8142
43a09b63 8143; lcr, lcgr
9a91a21f 8144(define_insn "*neg<mode>2_cc"
ae156f85 8145 [(set (reg CC_REGNUM)
9a91a21f 8146 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 8147 (const_int 0)))
9a91a21f
AS
8148 (set (match_operand:GPR 0 "register_operand" "=d")
8149 (neg:GPR (match_dup 1)))]
8150 "s390_match_ccmode (insn, CCAmode)"
8151 "lc<g>r\t%0,%1"
9381e3f1
WG
8152 [(set_attr "op_type" "RR<E>")
8153 (set_attr "z10prop" "z10_super_c_E1")])
43a09b63
AK
8154
8155; lcr, lcgr
9a91a21f 8156(define_insn "*neg<mode>2_cconly"
ae156f85 8157 [(set (reg CC_REGNUM)
9a91a21f 8158 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 8159 (const_int 0)))
9a91a21f
AS
8160 (clobber (match_scratch:GPR 0 "=d"))]
8161 "s390_match_ccmode (insn, CCAmode)"
8162 "lc<g>r\t%0,%1"
9381e3f1
WG
8163 [(set_attr "op_type" "RR<E>")
8164 (set_attr "z10prop" "z10_super_c_E1")])
43a09b63
AK
8165
8166; lcr, lcgr
9a91a21f
AS
8167(define_insn "*neg<mode>2"
8168 [(set (match_operand:GPR 0 "register_operand" "=d")
8169 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
ae156f85 8170 (clobber (reg:CC CC_REGNUM))]
9a91a21f
AS
8171 ""
8172 "lc<g>r\t%0,%1"
9381e3f1
WG
8173 [(set_attr "op_type" "RR<E>")
8174 (set_attr "z10prop" "z10_super_c_E1")])
9db1d521 8175
b7d19263 8176(define_insn "*negdi2_31"
9db1d521
HP
8177 [(set (match_operand:DI 0 "register_operand" "=d")
8178 (neg:DI (match_operand:DI 1 "register_operand" "d")))
ae156f85 8179 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8180 "!TARGET_ZARCH"
b7d19263
AK
8181 "#")
8182
8183; Split a DImode NEG on 31bit into 2 SImode NEGs
8184
8185; Doing the twos complement separately on the SImode parts does an
8186; unwanted +1 on the high part which needs to be subtracted afterwards
8187; ... unless the +1 on the low part created an overflow.
8188
8189(define_split
8190 [(set (match_operand:DI 0 "register_operand" "")
8191 (neg:DI (match_operand:DI 1 "register_operand" "")))
8192 (clobber (reg:CC CC_REGNUM))]
8193 "!TARGET_ZARCH
8194 && (REGNO (operands[0]) == REGNO (operands[1])
8195 || s390_split_ok_p (operands[0], operands[1], DImode, 0))
8196 && reload_completed"
26a89301
UW
8197 [(parallel
8198 [(set (match_dup 2) (neg:SI (match_dup 3)))
ae156f85 8199 (clobber (reg:CC CC_REGNUM))])
26a89301 8200 (parallel
ae156f85 8201 [(set (reg:CCAP CC_REGNUM)
26a89301
UW
8202 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
8203 (set (match_dup 4) (neg:SI (match_dup 5)))])
8204 (set (pc)
ae156f85 8205 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
26a89301
UW
8206 (pc)
8207 (label_ref (match_dup 6))))
8208 (parallel
8209 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
ae156f85 8210 (clobber (reg:CC CC_REGNUM))])
26a89301
UW
8211 (match_dup 6)]
8212 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
8213 operands[3] = operand_subword (operands[1], 0, 0, DImode);
8214 operands[4] = operand_subword (operands[0], 1, 0, DImode);
8215 operands[5] = operand_subword (operands[1], 1, 0, DImode);
8216 operands[6] = gen_label_rtx ();")
9db1d521 8217
b7d19263
AK
8218; Like above but first make a copy of the low part of the src operand
8219; since it might overlap with the high part of the destination.
8220
8221(define_split
8222 [(set (match_operand:DI 0 "register_operand" "")
8223 (neg:DI (match_operand:DI 1 "register_operand" "")))
8224 (clobber (reg:CC CC_REGNUM))]
8225 "!TARGET_ZARCH
8226 && s390_split_ok_p (operands[0], operands[1], DImode, 1)
8227 && reload_completed"
8228 [; Make a backup of op5 first
8229 (set (match_dup 4) (match_dup 5))
8230 ; Setting op2 here might clobber op5
8231 (parallel
8232 [(set (match_dup 2) (neg:SI (match_dup 3)))
8233 (clobber (reg:CC CC_REGNUM))])
8234 (parallel
8235 [(set (reg:CCAP CC_REGNUM)
8236 (compare:CCAP (neg:SI (match_dup 4)) (const_int 0)))
8237 (set (match_dup 4) (neg:SI (match_dup 4)))])
8238 (set (pc)
8239 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
8240 (pc)
8241 (label_ref (match_dup 6))))
8242 (parallel
8243 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
8244 (clobber (reg:CC CC_REGNUM))])
8245 (match_dup 6)]
8246 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
8247 operands[3] = operand_subword (operands[1], 0, 0, DImode);
8248 operands[4] = operand_subword (operands[0], 1, 0, DImode);
8249 operands[5] = operand_subword (operands[1], 1, 0, DImode);
8250 operands[6] = gen_label_rtx ();")
8251
9db1d521 8252;
f5905b37 8253; neg(df|sf)2 instruction pattern(s).
9db1d521
HP
8254;
8255
f5905b37 8256(define_expand "neg<mode>2"
9db1d521 8257 [(parallel
7b6baae1
AK
8258 [(set (match_operand:BFP 0 "register_operand" "=f")
8259 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
ae156f85 8260 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8261 "TARGET_HARD_FLOAT"
8262 "")
8263
43a09b63 8264; lcxbr, lcdbr, lcebr
f5905b37 8265(define_insn "*neg<mode>2_cc"
ae156f85 8266 [(set (reg CC_REGNUM)
7b6baae1
AK
8267 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
8268 (match_operand:BFP 2 "const0_operand" "")))
8269 (set (match_operand:BFP 0 "register_operand" "=f")
8270 (neg:BFP (match_dup 1)))]
142cd70f 8271 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8272 "lc<xde>br\t%0,%1"
26a89301 8273 [(set_attr "op_type" "RRE")
f5905b37 8274 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
8275
8276; lcxbr, lcdbr, lcebr
f5905b37 8277(define_insn "*neg<mode>2_cconly"
ae156f85 8278 [(set (reg CC_REGNUM)
7b6baae1
AK
8279 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
8280 (match_operand:BFP 2 "const0_operand" "")))
8281 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 8282 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8283 "lc<xde>br\t%0,%1"
26a89301 8284 [(set_attr "op_type" "RRE")
f5905b37 8285 (set_attr "type" "fsimp<mode>")])
43a09b63 8286
85dae55a
AK
8287; lcdfr
8288(define_insn "*neg<mode>2_nocc"
609e7e80
AK
8289 [(set (match_operand:FP 0 "register_operand" "=f")
8290 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
fb068247 8291 "TARGET_DFP"
85dae55a
AK
8292 "lcdfr\t%0,%1"
8293 [(set_attr "op_type" "RRE")
9381e3f1 8294 (set_attr "type" "fsimp<mode>")])
85dae55a 8295
43a09b63 8296; lcxbr, lcdbr, lcebr
6e5b5de8 8297; FIXME: wflcdb does not clobber cc
f5905b37 8298(define_insn "*neg<mode>2"
62d3f261
AK
8299 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8300 (neg:BFP (match_operand:BFP 1 "register_operand" "f,v")))
ae156f85 8301 (clobber (reg:CC CC_REGNUM))]
142cd70f 8302 "TARGET_HARD_FLOAT"
6e5b5de8
AK
8303 "@
8304 lc<xde>br\t%0,%1
8305 wflcdb\t%0,%1"
8306 [(set_attr "op_type" "RRE,VRR")
8307 (set_attr "cpu_facility" "*,vec")
62d3f261
AK
8308 (set_attr "type" "fsimp<mode>,*")
8309 (set_attr "enabled" "*,<DFDI>")])
9db1d521 8310
9db1d521
HP
8311
8312;;
8313;;- Absolute value instructions.
8314;;
8315
8316;
9a91a21f 8317; abs(di|si)2 instruction pattern(s).
9db1d521
HP
8318;
8319
26a89301 8320(define_insn "*absdi2_sign_cc"
ae156f85 8321 [(set (reg CC_REGNUM)
26a89301
UW
8322 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
8323 (match_operand:SI 1 "register_operand" "d") 0)
8324 (const_int 32)) (const_int 32)))
8325 (const_int 0)))
8326 (set (match_operand:DI 0 "register_operand" "=d")
8327 (abs:DI (sign_extend:DI (match_dup 1))))]
9602b6a1 8328 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 8329 "lpgfr\t%0,%1"
729e750f
WG
8330 [(set_attr "op_type" "RRE")
8331 (set_attr "z10prop" "z10_c")])
26a89301
UW
8332
8333(define_insn "*absdi2_sign"
8334 [(set (match_operand:DI 0 "register_operand" "=d")
8335 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
ae156f85 8336 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8337 "TARGET_ZARCH"
26a89301 8338 "lpgfr\t%0,%1"
729e750f
WG
8339 [(set_attr "op_type" "RRE")
8340 (set_attr "z10prop" "z10_c")])
26a89301 8341
43a09b63 8342; lpr, lpgr
9a91a21f 8343(define_insn "*abs<mode>2_cc"
ae156f85 8344 [(set (reg CC_REGNUM)
9a91a21f 8345 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
26a89301 8346 (const_int 0)))
9a91a21f
AS
8347 (set (match_operand:GPR 0 "register_operand" "=d")
8348 (abs:GPR (match_dup 1)))]
26a89301 8349 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 8350 "lp<g>r\t%0,%1"
9381e3f1
WG
8351 [(set_attr "op_type" "RR<E>")
8352 (set_attr "z10prop" "z10_c")])
43a09b63 8353
9381e3f1 8354; lpr, lpgr
9a91a21f 8355(define_insn "*abs<mode>2_cconly"
ae156f85 8356 [(set (reg CC_REGNUM)
9a91a21f 8357 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 8358 (const_int 0)))
9a91a21f 8359 (clobber (match_scratch:GPR 0 "=d"))]
26a89301 8360 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 8361 "lp<g>r\t%0,%1"
9381e3f1
WG
8362 [(set_attr "op_type" "RR<E>")
8363 (set_attr "z10prop" "z10_c")])
43a09b63
AK
8364
8365; lpr, lpgr
9a91a21f
AS
8366(define_insn "abs<mode>2"
8367 [(set (match_operand:GPR 0 "register_operand" "=d")
8368 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
ae156f85 8369 (clobber (reg:CC CC_REGNUM))]
9db1d521 8370 ""
9a91a21f 8371 "lp<g>r\t%0,%1"
9381e3f1
WG
8372 [(set_attr "op_type" "RR<E>")
8373 (set_attr "z10prop" "z10_c")])
9db1d521 8374
9db1d521 8375;
f5905b37 8376; abs(df|sf)2 instruction pattern(s).
9db1d521
HP
8377;
8378
f5905b37 8379(define_expand "abs<mode>2"
9db1d521 8380 [(parallel
7b6baae1
AK
8381 [(set (match_operand:BFP 0 "register_operand" "=f")
8382 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
ae156f85 8383 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8384 "TARGET_HARD_FLOAT"
8385 "")
8386
43a09b63 8387; lpxbr, lpdbr, lpebr
f5905b37 8388(define_insn "*abs<mode>2_cc"
ae156f85 8389 [(set (reg CC_REGNUM)
7b6baae1
AK
8390 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
8391 (match_operand:BFP 2 "const0_operand" "")))
8392 (set (match_operand:BFP 0 "register_operand" "=f")
8393 (abs:BFP (match_dup 1)))]
142cd70f 8394 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8395 "lp<xde>br\t%0,%1"
26a89301 8396 [(set_attr "op_type" "RRE")
f5905b37 8397 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
8398
8399; lpxbr, lpdbr, lpebr
f5905b37 8400(define_insn "*abs<mode>2_cconly"
ae156f85 8401 [(set (reg CC_REGNUM)
7b6baae1
AK
8402 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
8403 (match_operand:BFP 2 "const0_operand" "")))
8404 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 8405 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8406 "lp<xde>br\t%0,%1"
26a89301 8407 [(set_attr "op_type" "RRE")
f5905b37 8408 (set_attr "type" "fsimp<mode>")])
43a09b63 8409
85dae55a
AK
8410; lpdfr
8411(define_insn "*abs<mode>2_nocc"
609e7e80
AK
8412 [(set (match_operand:FP 0 "register_operand" "=f")
8413 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
fb068247 8414 "TARGET_DFP"
85dae55a
AK
8415 "lpdfr\t%0,%1"
8416 [(set_attr "op_type" "RRE")
9381e3f1 8417 (set_attr "type" "fsimp<mode>")])
85dae55a 8418
43a09b63 8419; lpxbr, lpdbr, lpebr
6e5b5de8 8420; FIXME: wflpdb does not clobber cc
f5905b37 8421(define_insn "*abs<mode>2"
62d3f261
AK
8422 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8423 (abs:BFP (match_operand:BFP 1 "register_operand" "f,v")))
ae156f85 8424 (clobber (reg:CC CC_REGNUM))]
142cd70f 8425 "TARGET_HARD_FLOAT"
6e5b5de8
AK
8426 "@
8427 lp<xde>br\t%0,%1
8428 wflpdb\t%0,%1"
8429 [(set_attr "op_type" "RRE,VRR")
8430 (set_attr "cpu_facility" "*,vec")
62d3f261
AK
8431 (set_attr "type" "fsimp<mode>,*")
8432 (set_attr "enabled" "*,<DFDI>")])
9db1d521 8433
9db1d521 8434
3ef093a8
AK
8435;;
8436;;- Negated absolute value instructions
8437;;
8438
8439;
8440; Integer
8441;
8442
26a89301 8443(define_insn "*negabsdi2_sign_cc"
ae156f85 8444 [(set (reg CC_REGNUM)
26a89301
UW
8445 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
8446 (match_operand:SI 1 "register_operand" "d") 0)
8447 (const_int 32)) (const_int 32))))
8448 (const_int 0)))
8449 (set (match_operand:DI 0 "register_operand" "=d")
8450 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
9602b6a1 8451 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 8452 "lngfr\t%0,%1"
729e750f
WG
8453 [(set_attr "op_type" "RRE")
8454 (set_attr "z10prop" "z10_c")])
9381e3f1 8455
26a89301
UW
8456(define_insn "*negabsdi2_sign"
8457 [(set (match_operand:DI 0 "register_operand" "=d")
8458 (neg:DI (abs:DI (sign_extend:DI
8459 (match_operand:SI 1 "register_operand" "d")))))
ae156f85 8460 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8461 "TARGET_ZARCH"
26a89301 8462 "lngfr\t%0,%1"
729e750f
WG
8463 [(set_attr "op_type" "RRE")
8464 (set_attr "z10prop" "z10_c")])
3ef093a8 8465
43a09b63 8466; lnr, lngr
9a91a21f 8467(define_insn "*negabs<mode>2_cc"
ae156f85 8468 [(set (reg CC_REGNUM)
9a91a21f 8469 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
26a89301 8470 (const_int 0)))
9a91a21f
AS
8471 (set (match_operand:GPR 0 "register_operand" "=d")
8472 (neg:GPR (abs:GPR (match_dup 1))))]
26a89301 8473 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 8474 "ln<g>r\t%0,%1"
9381e3f1
WG
8475 [(set_attr "op_type" "RR<E>")
8476 (set_attr "z10prop" "z10_c")])
43a09b63
AK
8477
8478; lnr, lngr
9a91a21f 8479(define_insn "*negabs<mode>2_cconly"
ae156f85 8480 [(set (reg CC_REGNUM)
9a91a21f 8481 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
26a89301 8482 (const_int 0)))
9a91a21f 8483 (clobber (match_scratch:GPR 0 "=d"))]
26a89301 8484 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 8485 "ln<g>r\t%0,%1"
9381e3f1
WG
8486 [(set_attr "op_type" "RR<E>")
8487 (set_attr "z10prop" "z10_c")])
43a09b63
AK
8488
8489; lnr, lngr
9a91a21f
AS
8490(define_insn "*negabs<mode>2"
8491 [(set (match_operand:GPR 0 "register_operand" "=d")
8492 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
ae156f85 8493 (clobber (reg:CC CC_REGNUM))]
26a89301 8494 ""
9a91a21f 8495 "ln<g>r\t%0,%1"
9381e3f1
WG
8496 [(set_attr "op_type" "RR<E>")
8497 (set_attr "z10prop" "z10_c")])
26a89301 8498
3ef093a8
AK
8499;
8500; Floating point
8501;
8502
43a09b63 8503; lnxbr, lndbr, lnebr
f5905b37 8504(define_insn "*negabs<mode>2_cc"
ae156f85 8505 [(set (reg CC_REGNUM)
7b6baae1
AK
8506 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
8507 (match_operand:BFP 2 "const0_operand" "")))
8508 (set (match_operand:BFP 0 "register_operand" "=f")
8509 (neg:BFP (abs:BFP (match_dup 1))))]
142cd70f 8510 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8511 "ln<xde>br\t%0,%1"
26a89301 8512 [(set_attr "op_type" "RRE")
f5905b37 8513 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
8514
8515; lnxbr, lndbr, lnebr
f5905b37 8516(define_insn "*negabs<mode>2_cconly"
ae156f85 8517 [(set (reg CC_REGNUM)
7b6baae1
AK
8518 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
8519 (match_operand:BFP 2 "const0_operand" "")))
8520 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 8521 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8522 "ln<xde>br\t%0,%1"
26a89301 8523 [(set_attr "op_type" "RRE")
f5905b37 8524 (set_attr "type" "fsimp<mode>")])
43a09b63 8525
85dae55a
AK
8526; lndfr
8527(define_insn "*negabs<mode>2_nocc"
609e7e80
AK
8528 [(set (match_operand:FP 0 "register_operand" "=f")
8529 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
fb068247 8530 "TARGET_DFP"
85dae55a
AK
8531 "lndfr\t%0,%1"
8532 [(set_attr "op_type" "RRE")
9381e3f1 8533 (set_attr "type" "fsimp<mode>")])
85dae55a 8534
43a09b63 8535; lnxbr, lndbr, lnebr
6e5b5de8 8536; FIXME: wflndb does not clobber cc
f5905b37 8537(define_insn "*negabs<mode>2"
62d3f261
AK
8538 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8539 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f,v"))))
ae156f85 8540 (clobber (reg:CC CC_REGNUM))]
142cd70f 8541 "TARGET_HARD_FLOAT"
6e5b5de8
AK
8542 "@
8543 ln<xde>br\t%0,%1
8544 wflndb\t%0,%1"
8545 [(set_attr "op_type" "RRE,VRR")
8546 (set_attr "cpu_facility" "*,vec")
62d3f261
AK
8547 (set_attr "type" "fsimp<mode>,*")
8548 (set_attr "enabled" "*,<DFDI>")])
26a89301 8549
4023fb28
UW
8550;;
8551;;- Square root instructions.
8552;;
8553
8554;
f5905b37 8555; sqrt(df|sf)2 instruction pattern(s).
4023fb28
UW
8556;
8557
9381e3f1 8558; sqxbr, sqdbr, sqebr, sqdb, sqeb
f5905b37 8559(define_insn "sqrt<mode>2"
62d3f261
AK
8560 [(set (match_operand:BFP 0 "register_operand" "=f,f,v")
8561 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,R,v")))]
142cd70f 8562 "TARGET_HARD_FLOAT"
4023fb28 8563 "@
f61a2c7d 8564 sq<xde>br\t%0,%1
6e5b5de8
AK
8565 sq<xde>b\t%0,%1
8566 wfsqdb\t%v0,%v1"
8567 [(set_attr "op_type" "RRE,RXE,VRR")
8568 (set_attr "type" "fsqrt<mode>")
62d3f261
AK
8569 (set_attr "cpu_facility" "*,*,vec")
8570 (set_attr "enabled" "*,<DSF>,<DFDI>")])
4023fb28 8571
9db1d521
HP
8572
8573;;
8574;;- One complement instructions.
8575;;
8576
8577;
342cf42b 8578; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
9db1d521 8579;
c7453384 8580
342cf42b 8581(define_expand "one_cmpl<mode>2"
4023fb28 8582 [(parallel
342cf42b
AS
8583 [(set (match_operand:INT 0 "register_operand" "")
8584 (xor:INT (match_operand:INT 1 "register_operand" "")
8585 (const_int -1)))
ae156f85 8586 (clobber (reg:CC CC_REGNUM))])]
9db1d521 8587 ""
4023fb28 8588 "")
9db1d521
HP
8589
8590
ec24698e
UW
8591;;
8592;; Find leftmost bit instructions.
8593;;
8594
8595(define_expand "clzdi2"
8596 [(set (match_operand:DI 0 "register_operand" "=d")
8597 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
9602b6a1 8598 "TARGET_EXTIMM && TARGET_ZARCH"
ec24698e
UW
8599{
8600 rtx insn, clz_equal;
8601 rtx wide_reg = gen_reg_rtx (TImode);
8602 rtx msb = gen_rtx_CONST_INT (DImode, (unsigned HOST_WIDE_INT) 1 << 63);
8603
8604 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
8605
8606 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
8607
9381e3f1 8608 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
bd94cb6e 8609 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
ec24698e
UW
8610
8611 DONE;
8612})
8613
8614(define_insn "clztidi2"
8615 [(set (match_operand:TI 0 "register_operand" "=d")
8616 (ior:TI
9381e3f1
WG
8617 (ashift:TI
8618 (zero_extend:TI
ec24698e
UW
8619 (xor:DI (match_operand:DI 1 "register_operand" "d")
8620 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
8621 (subreg:SI (clz:DI (match_dup 1)) 4))))
9381e3f1 8622
ec24698e
UW
8623 (const_int 64))
8624 (zero_extend:TI (clz:DI (match_dup 1)))))
8625 (clobber (reg:CC CC_REGNUM))]
9381e3f1 8626 "(unsigned HOST_WIDE_INT) INTVAL (operands[2])
ec24698e 8627 == (unsigned HOST_WIDE_INT) 1 << 63
9602b6a1 8628 && TARGET_EXTIMM && TARGET_ZARCH"
ec24698e
UW
8629 "flogr\t%0,%1"
8630 [(set_attr "op_type" "RRE")])
8631
8632
9db1d521
HP
8633;;
8634;;- Rotate instructions.
8635;;
8636
8637;
9a91a21f 8638; rotl(di|si)3 instruction pattern(s).
9db1d521
HP
8639;
8640
191eb16d
AK
8641(define_expand "rotl<mode>3"
8642 [(set (match_operand:GPR 0 "register_operand" "")
8643 (rotate:GPR (match_operand:GPR 1 "register_operand" "")
8644 (match_operand:SI 2 "nonmemory_operand" "")))]
9e8327e3 8645 "TARGET_CPU_ZARCH"
191eb16d 8646 "")
9db1d521 8647
43a09b63 8648; rll, rllg
191eb16d
AK
8649(define_insn "*rotl<mode>3<addr_style_op><masked_op>"
8650 [(set (match_operand:GPR 0 "register_operand" "=d")
8651 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
8652 (match_operand:SI 2 "nonmemory_operand" "an")))]
8653 "TARGET_CPU_ZARCH"
8654 "rll<g>\t%0,%1,<addr_style_op_ops>"
4989e88a 8655 [(set_attr "op_type" "RSE")
9381e3f1 8656 (set_attr "atype" "reg")
191eb16d 8657 (set_attr "z10prop" "z10_super_E1")])
4989e88a 8658
9db1d521
HP
8659
8660;;
f337b930 8661;;- Shift instructions.
9db1d521 8662;;
9db1d521
HP
8663
8664;
1b48c8cc 8665; (ashl|lshr)(di|si)3 instruction pattern(s).
65b1d8ea 8666; Left shifts and logical right shifts
9db1d521 8667
1b48c8cc
AS
8668(define_expand "<shift><mode>3"
8669 [(set (match_operand:DSI 0 "register_operand" "")
8670 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
adf22b3f 8671 (match_operand:SI 2 "nonmemory_operand" "")))]
9db1d521
HP
8672 ""
8673 "")
8674
adf22b3f 8675; ESA 64 bit register pair shift with reg or imm shift count
43a09b63 8676; sldl, srdl
adf22b3f
AK
8677(define_insn "*<shift>di3_31<addr_style_op><masked_op>"
8678 [(set (match_operand:DI 0 "register_operand" "=d")
8679 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
8680 (match_operand:SI 2 "nonmemory_operand" "an")))]
9602b6a1 8681 "!TARGET_ZARCH"
adf22b3f 8682 "s<lr>dl\t%0,<addr_style_op_ops>"
077dab3b 8683 [(set_attr "op_type" "RS")
65b1d8ea
AK
8684 (set_attr "atype" "reg")
8685 (set_attr "z196prop" "z196_cracked")])
9db1d521 8686
adf22b3f
AK
8687
8688; 64 bit register shift with reg or imm shift count
65b1d8ea 8689; sll, srl, sllg, srlg, sllk, srlk
adf22b3f
AK
8690(define_insn "*<shift><mode>3<addr_style_op><masked_op>"
8691 [(set (match_operand:GPR 0 "register_operand" "=d, d")
8692 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>, d")
8693 (match_operand:SI 2 "nonmemory_operand" "an,an")))]
1b48c8cc 8694 ""
65b1d8ea 8695 "@
adf22b3f
AK
8696 s<lr>l<g>\t%0,<1><addr_style_op_ops>
8697 s<lr>l<gk>\t%0,%1,<addr_style_op_ops>"
65b1d8ea
AK
8698 [(set_attr "op_type" "RS<E>,RSY")
8699 (set_attr "atype" "reg,reg")
8700 (set_attr "cpu_facility" "*,z196")
adf22b3f 8701 (set_attr "z10prop" "z10_super_E1,*")])
4989e88a 8702
9db1d521 8703;
1b48c8cc 8704; ashr(di|si)3 instruction pattern(s).
65b1d8ea 8705; Arithmetic right shifts
9db1d521 8706
1b48c8cc 8707(define_expand "ashr<mode>3"
9db1d521 8708 [(parallel
1b48c8cc
AS
8709 [(set (match_operand:DSI 0 "register_operand" "")
8710 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
a9fcf821 8711 (match_operand:SI 2 "nonmemory_operand" "")))
ae156f85 8712 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8713 ""
8714 "")
8715
a9fcf821
AK
8716; FIXME: The number of alternatives is doubled here to match the fix
8717; number of 2 in the subst pattern for the (clobber (match_scratch...
8718; The right fix should be to support match_scratch in the output
8719; pattern of a define_subst.
8720(define_insn "*ashrdi3_31<addr_style_op_cc><masked_op_cc><setcc><cconly>"
8721 [(set (match_operand:DI 0 "register_operand" "=d, d")
8722 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0, 0")
8723 (match_operand:SI 2 "nonmemory_operand" "an,an")))
ae156f85 8724 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8725 "!TARGET_ZARCH"
65b1d8ea 8726 "@
a9fcf821
AK
8727 srda\t%0,<addr_style_op_cc_ops>
8728 srda\t%0,<addr_style_op_cc_ops>"
8729 [(set_attr "op_type" "RS")
8730 (set_attr "atype" "reg")])
ecbe845e 8731
ecbe845e 8732
43a09b63 8733; sra, srag
a9fcf821
AK
8734(define_insn "*ashr<mode>3<addr_style_op_cc><masked_op_cc><setcc><cconly>"
8735 [(set (match_operand:GPR 0 "register_operand" "=d, d")
8736 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>, d")
8737 (match_operand:SI 2 "nonmemory_operand" "an,an")))
ae156f85 8738 (clobber (reg:CC CC_REGNUM))]
1b48c8cc 8739 ""
65b1d8ea 8740 "@
a9fcf821
AK
8741 sra<g>\t%0,<1><addr_style_op_cc_ops>
8742 sra<gk>\t%0,%1,<addr_style_op_cc_ops>"
65b1d8ea 8743 [(set_attr "op_type" "RS<E>,RSY")
a9fcf821 8744 (set_attr "atype" "reg")
01496eca 8745 (set_attr "cpu_facility" "*,z196")
65b1d8ea 8746 (set_attr "z10prop" "z10_super_E1,*")])
4989e88a 8747
9db1d521 8748
9db1d521
HP
8749;;
8750;; Branch instruction patterns.
8751;;
8752
f90b7a5a 8753(define_expand "cbranch<mode>4"
fa77b251 8754 [(set (pc)
f90b7a5a
PB
8755 (if_then_else (match_operator 0 "comparison_operator"
8756 [(match_operand:GPR 1 "register_operand" "")
8757 (match_operand:GPR 2 "general_operand" "")])
8758 (label_ref (match_operand 3 "" ""))
fa77b251 8759 (pc)))]
ba956982 8760 ""
f90b7a5a
PB
8761 "s390_emit_jump (operands[3],
8762 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8763 DONE;")
8764
8765(define_expand "cbranch<mode>4"
8766 [(set (pc)
8767 (if_then_else (match_operator 0 "comparison_operator"
8768 [(match_operand:FP 1 "register_operand" "")
8769 (match_operand:FP 2 "general_operand" "")])
8770 (label_ref (match_operand 3 "" ""))
8771 (pc)))]
8772 "TARGET_HARD_FLOAT"
8773 "s390_emit_jump (operands[3],
8774 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8775 DONE;")
8776
8777(define_expand "cbranchcc4"
8778 [(set (pc)
de6fba39 8779 (if_then_else (match_operator 0 "s390_comparison"
f90b7a5a 8780 [(match_operand 1 "cc_reg_operand" "")
de6fba39 8781 (match_operand 2 "const_int_operand" "")])
f90b7a5a
PB
8782 (label_ref (match_operand 3 "" ""))
8783 (pc)))]
de6fba39
UW
8784 ""
8785 "")
ba956982 8786
9db1d521
HP
8787
8788;;
8789;;- Conditional jump instructions.
8790;;
8791
6590e19a
UW
8792(define_insn "*cjump_64"
8793 [(set (pc)
8794 (if_then_else
5a3fe9b6
AK
8795 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8796 (match_operand 2 "const_int_operand" "")])
6590e19a
UW
8797 (label_ref (match_operand 0 "" ""))
8798 (pc)))]
8799 "TARGET_CPU_ZARCH"
9db1d521 8800{
13e58269 8801 if (get_attr_length (insn) == 4)
d40c829f 8802 return "j%C1\t%l0";
6590e19a 8803 else
d40c829f 8804 return "jg%C1\t%l0";
6590e19a
UW
8805}
8806 [(set_attr "op_type" "RI")
8807 (set_attr "type" "branch")
8808 (set (attr "length")
8809 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8810 (const_int 4) (const_int 6)))])
8811
8812(define_insn "*cjump_31"
8813 [(set (pc)
8814 (if_then_else
5a3fe9b6
AK
8815 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8816 (match_operand 2 "const_int_operand" "")])
6590e19a
UW
8817 (label_ref (match_operand 0 "" ""))
8818 (pc)))]
8819 "!TARGET_CPU_ZARCH"
8820{
8d933e31
AS
8821 gcc_assert (get_attr_length (insn) == 4);
8822 return "j%C1\t%l0";
10bbf137 8823}
9db1d521 8824 [(set_attr "op_type" "RI")
077dab3b 8825 (set_attr "type" "branch")
13e58269 8826 (set (attr "length")
d7f99b2c 8827 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
8828 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8829 (const_int 4) (const_int 6))
8830 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8831 (const_int 4) (const_int 8))))])
9db1d521 8832
f314b9b1 8833(define_insn "*cjump_long"
6590e19a
UW
8834 [(set (pc)
8835 (if_then_else
ae156f85 8836 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
4fe6dea8 8837 (match_operand 0 "address_operand" "ZQZR")
6590e19a 8838 (pc)))]
9db1d521 8839 ""
f314b9b1
UW
8840{
8841 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8842 return "b%C1r\t%0";
f314b9b1 8843 else
d40c829f 8844 return "b%C1\t%a0";
10bbf137 8845}
c7453384 8846 [(set (attr "op_type")
f314b9b1
UW
8847 (if_then_else (match_operand 0 "register_operand" "")
8848 (const_string "RR") (const_string "RX")))
6590e19a 8849 (set_attr "type" "branch")
077dab3b 8850 (set_attr "atype" "agen")])
9db1d521 8851
177bc204
RS
8852;; A conditional return instruction.
8853(define_insn "*c<code>"
8854 [(set (pc)
8855 (if_then_else
8856 (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8857 (ANY_RETURN)
8858 (pc)))]
8859 "s390_can_use_<code>_insn ()"
8860 "b%C0r\t%%r14"
8861 [(set_attr "op_type" "RR")
8862 (set_attr "type" "jsr")
8863 (set_attr "atype" "agen")])
9db1d521
HP
8864
8865;;
8866;;- Negated conditional jump instructions.
8867;;
8868
6590e19a
UW
8869(define_insn "*icjump_64"
8870 [(set (pc)
8871 (if_then_else
ae156f85 8872 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a
UW
8873 (pc)
8874 (label_ref (match_operand 0 "" ""))))]
8875 "TARGET_CPU_ZARCH"
c7453384 8876{
13e58269 8877 if (get_attr_length (insn) == 4)
d40c829f 8878 return "j%D1\t%l0";
6590e19a 8879 else
d40c829f 8880 return "jg%D1\t%l0";
6590e19a
UW
8881}
8882 [(set_attr "op_type" "RI")
8883 (set_attr "type" "branch")
8884 (set (attr "length")
8885 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8886 (const_int 4) (const_int 6)))])
8887
8888(define_insn "*icjump_31"
8889 [(set (pc)
8890 (if_then_else
ae156f85 8891 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a
UW
8892 (pc)
8893 (label_ref (match_operand 0 "" ""))))]
8894 "!TARGET_CPU_ZARCH"
8895{
8d933e31
AS
8896 gcc_assert (get_attr_length (insn) == 4);
8897 return "j%D1\t%l0";
10bbf137 8898}
9db1d521 8899 [(set_attr "op_type" "RI")
077dab3b 8900 (set_attr "type" "branch")
13e58269 8901 (set (attr "length")
d7f99b2c 8902 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
8903 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8904 (const_int 4) (const_int 6))
8905 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8906 (const_int 4) (const_int 8))))])
9db1d521 8907
f314b9b1 8908(define_insn "*icjump_long"
6590e19a
UW
8909 [(set (pc)
8910 (if_then_else
ae156f85 8911 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a 8912 (pc)
4fe6dea8 8913 (match_operand 0 "address_operand" "ZQZR")))]
9db1d521 8914 ""
f314b9b1
UW
8915{
8916 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8917 return "b%D1r\t%0";
f314b9b1 8918 else
d40c829f 8919 return "b%D1\t%a0";
10bbf137 8920}
c7453384 8921 [(set (attr "op_type")
f314b9b1
UW
8922 (if_then_else (match_operand 0 "register_operand" "")
8923 (const_string "RR") (const_string "RX")))
077dab3b
HP
8924 (set_attr "type" "branch")
8925 (set_attr "atype" "agen")])
9db1d521 8926
4456530d
HP
8927;;
8928;;- Trap instructions.
8929;;
8930
8931(define_insn "trap"
8932 [(trap_if (const_int 1) (const_int 0))]
8933 ""
d40c829f 8934 "j\t.+2"
6590e19a 8935 [(set_attr "op_type" "RI")
077dab3b 8936 (set_attr "type" "branch")])
4456530d 8937
f90b7a5a
PB
8938(define_expand "ctrap<mode>4"
8939 [(trap_if (match_operator 0 "comparison_operator"
8940 [(match_operand:GPR 1 "register_operand" "")
8941 (match_operand:GPR 2 "general_operand" "")])
8942 (match_operand 3 "const0_operand" ""))]
4456530d 8943 ""
f90b7a5a
PB
8944 {
8945 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8946 operands[1], operands[2]);
8947 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8948 DONE;
8949 })
8950
8951(define_expand "ctrap<mode>4"
8952 [(trap_if (match_operator 0 "comparison_operator"
8953 [(match_operand:FP 1 "register_operand" "")
8954 (match_operand:FP 2 "general_operand" "")])
8955 (match_operand 3 "const0_operand" ""))]
8956 ""
8957 {
8958 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8959 operands[1], operands[2]);
8960 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8961 DONE;
8962 })
4456530d 8963
f90b7a5a
PB
8964(define_insn "condtrap"
8965 [(trap_if (match_operator 0 "s390_comparison"
8966 [(match_operand 1 "cc_reg_operand" "c")
8967 (const_int 0)])
4456530d
HP
8968 (const_int 0))]
8969 ""
d40c829f 8970 "j%C0\t.+2";
077dab3b
HP
8971 [(set_attr "op_type" "RI")
8972 (set_attr "type" "branch")])
9db1d521 8973
963fc8d0
AK
8974; crt, cgrt, cit, cgit
8975(define_insn "*cmp_and_trap_signed_int<mode>"
8976 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
8977 [(match_operand:GPR 1 "register_operand" "d,d")
8978 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
8979 (const_int 0))]
8980 "TARGET_Z10"
8981 "@
8982 c<g>rt%C0\t%1,%2
8983 c<g>it%C0\t%1,%h2"
8984 [(set_attr "op_type" "RRF,RIE")
9381e3f1 8985 (set_attr "type" "branch")
729e750f 8986 (set_attr "z10prop" "z10_super_c,z10_super")])
963fc8d0 8987
22ac2c2f 8988; clrt, clgrt, clfit, clgit, clt, clgt
963fc8d0
AK
8989(define_insn "*cmp_and_trap_unsigned_int<mode>"
8990 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
3e4be43f
UW
8991 [(match_operand:GPR 1 "register_operand" "d,d,d")
8992 (match_operand:GPR 2 "general_operand" "d,D,T")])
963fc8d0
AK
8993 (const_int 0))]
8994 "TARGET_Z10"
8995 "@
8996 cl<g>rt%C0\t%1,%2
22ac2c2f
AK
8997 cl<gf>it%C0\t%1,%x2
8998 cl<g>t%C0\t%1,%2"
8999 [(set_attr "op_type" "RRF,RIE,RSY")
9000 (set_attr "type" "branch")
9001 (set_attr "z10prop" "z10_super_c,z10_super,*")
9002 (set_attr "cpu_facility" "z10,z10,zEC12")])
9003
9004; lat, lgat
9005(define_insn "*load_and_trap<mode>"
3e4be43f 9006 [(trap_if (eq (match_operand:GPR 0 "memory_operand" "T")
22ac2c2f
AK
9007 (const_int 0))
9008 (const_int 0))
9009 (set (match_operand:GPR 1 "register_operand" "=d")
9010 (match_dup 0))]
9011 "TARGET_ZEC12"
9012 "l<g>at\t%1,%0"
9013 [(set_attr "op_type" "RXY")])
9014
963fc8d0 9015
9db1d521 9016;;
0a3bdf9d 9017;;- Loop instructions.
9db1d521 9018;;
0a3bdf9d
UW
9019;; This is all complicated by the fact that since this is a jump insn
9020;; we must handle our own output reloads.
c7453384 9021
f1149235
AK
9022;; branch on index
9023
9024; This splitter will be matched by combine and has to add the 2 moves
9025; necessary to load the compare and the increment values into a
9026; register pair as needed by brxle.
9027
9028(define_insn_and_split "*brx_stage1_<GPR:mode>"
9029 [(set (pc)
9030 (if_then_else
9031 (match_operator 6 "s390_brx_operator"
9032 [(plus:GPR (match_operand:GPR 1 "register_operand" "")
9033 (match_operand:GPR 2 "general_operand" ""))
9034 (match_operand:GPR 3 "register_operand" "")])
9035 (label_ref (match_operand 0 "" ""))
9036 (pc)))
9037 (set (match_operand:GPR 4 "nonimmediate_operand" "")
9038 (plus:GPR (match_dup 1) (match_dup 2)))
9039 (clobber (match_scratch:GPR 5 ""))]
9040 "TARGET_CPU_ZARCH"
9041 "#"
9042 "!reload_completed && !reload_in_progress"
9043 [(set (match_dup 7) (match_dup 2)) ; the increment
9044 (set (match_dup 8) (match_dup 3)) ; the comparison value
9045 (parallel [(set (pc)
9046 (if_then_else
9047 (match_op_dup 6
9048 [(plus:GPR (match_dup 1) (match_dup 7))
9049 (match_dup 8)])
9050 (label_ref (match_dup 0))
9051 (pc)))
9052 (set (match_dup 4)
9053 (plus:GPR (match_dup 1) (match_dup 7)))
9054 (clobber (match_dup 5))
9055 (clobber (reg:CC CC_REGNUM))])]
9056 {
9057 rtx dreg = gen_reg_rtx (word_mode == DImode ? TImode : DImode);
9058 operands[7] = gen_lowpart (<GPR:MODE>mode,
9059 gen_highpart (word_mode, dreg));
9060 operands[8] = gen_lowpart (<GPR:MODE>mode,
9061 gen_lowpart (word_mode, dreg));
9062 })
9063
9064; brxlg, brxhg
9065
9066(define_insn_and_split "*brxg_64bit"
9067 [(set (pc)
9068 (if_then_else
9069 (match_operator 5 "s390_brx_operator"
9070 [(plus:DI (match_operand:DI 1 "register_operand" "d,d,d")
9071 (subreg:DI (match_operand:TI 2 "register_operand" "d,d,d") 0))
9072 (subreg:DI (match_dup 2) 8)])
9073 (label_ref (match_operand 0 "" ""))
9074 (pc)))
9075 (set (match_operand:DI 3 "nonimmediate_operand" "=1,?X,?X")
9076 (plus:DI (match_dup 1)
9077 (subreg:DI (match_dup 2) 0)))
9078 (clobber (match_scratch:DI 4 "=X,&1,&?d"))
9079 (clobber (reg:CC CC_REGNUM))]
9602b6a1 9080 "TARGET_ZARCH"
f1149235
AK
9081{
9082 if (which_alternative != 0)
9083 return "#";
9084 else if (get_attr_length (insn) == 6)
9085 return "brx%E5g\t%1,%2,%l0";
9086 else
9087 return "agr\t%1,%2\;cgr\t%1,%M2\;jg%C5\t%l0";
9088}
9089 "&& reload_completed
9090 && (!REG_P (operands[3])
9091 || !rtx_equal_p (operands[1], operands[3]))"
9092 [(set (match_dup 4) (match_dup 1))
9093 (parallel [(set (match_dup 4) (plus:DI (match_dup 4) (subreg:DI (match_dup 2) 0)))
9094 (clobber (reg:CC CC_REGNUM))])
9095 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:DI (match_dup 2) 8)))
9096 (set (match_dup 3) (match_dup 4))
9097 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9098 (label_ref (match_dup 0))
9099 (pc)))]
9100 ""
9101 [(set_attr "op_type" "RIE")
9102 (set_attr "type" "branch")
9103 (set (attr "length")
9104 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9105 (const_int 6) (const_int 16)))])
9106
9107; brxle, brxh
9108
9109(define_insn_and_split "*brx_64bit"
9110 [(set (pc)
9111 (if_then_else
9112 (match_operator 5 "s390_brx_operator"
9113 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
9114 (subreg:SI (match_operand:TI 2 "register_operand" "d,d,d") 4))
9115 (subreg:SI (match_dup 2) 12)])
9116 (label_ref (match_operand 0 "" ""))
9117 (pc)))
9118 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
9119 (plus:SI (match_dup 1)
9120 (subreg:SI (match_dup 2) 4)))
9121 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
9122 (clobber (reg:CC CC_REGNUM))]
9602b6a1 9123 "TARGET_ZARCH"
f1149235
AK
9124{
9125 if (which_alternative != 0)
9126 return "#";
9127 else if (get_attr_length (insn) == 6)
9128 return "brx%C5\t%1,%2,%l0";
9129 else
9130 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
9131}
9132 "&& reload_completed
9133 && (!REG_P (operands[3])
9134 || !rtx_equal_p (operands[1], operands[3]))"
9135 [(set (match_dup 4) (match_dup 1))
9136 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 4)))
9137 (clobber (reg:CC CC_REGNUM))])
9138 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 12)))
9139 (set (match_dup 3) (match_dup 4))
9140 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9141 (label_ref (match_dup 0))
9142 (pc)))]
9143 ""
9144 [(set_attr "op_type" "RSI")
9145 (set_attr "type" "branch")
9146 (set (attr "length")
9147 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9148 (const_int 6) (const_int 14)))])
9149
9150; brxle, brxh
9151
9152(define_insn_and_split "*brx_31bit"
9153 [(set (pc)
9154 (if_then_else
9155 (match_operator 5 "s390_brx_operator"
9156 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
9157 (subreg:SI (match_operand:DI 2 "register_operand" "d,d,d") 0))
9158 (subreg:SI (match_dup 2) 4)])
9159 (label_ref (match_operand 0 "" ""))
9160 (pc)))
9161 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
9162 (plus:SI (match_dup 1)
9163 (subreg:SI (match_dup 2) 0)))
9164 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
9165 (clobber (reg:CC CC_REGNUM))]
9602b6a1 9166 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1149235
AK
9167{
9168 if (which_alternative != 0)
9169 return "#";
9170 else if (get_attr_length (insn) == 6)
9171 return "brx%C5\t%1,%2,%l0";
9172 else
9173 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
9174}
9175 "&& reload_completed
9176 && (!REG_P (operands[3])
9177 || !rtx_equal_p (operands[1], operands[3]))"
9178 [(set (match_dup 4) (match_dup 1))
9179 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 0)))
9180 (clobber (reg:CC CC_REGNUM))])
9181 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 4)))
9182 (set (match_dup 3) (match_dup 4))
9183 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9184 (label_ref (match_dup 0))
9185 (pc)))]
9186 ""
9187 [(set_attr "op_type" "RSI")
9188 (set_attr "type" "branch")
9189 (set (attr "length")
9190 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9191 (const_int 6) (const_int 14)))])
9192
9193
9194;; branch on count
9195
0a3bdf9d
UW
9196(define_expand "doloop_end"
9197 [(use (match_operand 0 "" "")) ; loop pseudo
1d0216c8 9198 (use (match_operand 1 "" ""))] ; label
0a3bdf9d 9199 ""
0a3bdf9d 9200{
6590e19a 9201 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
1d0216c8 9202 emit_jump_insn (gen_doloop_si31 (operands[1], operands[0], operands[0]));
6590e19a 9203 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
1d0216c8 9204 emit_jump_insn (gen_doloop_si64 (operands[1], operands[0], operands[0]));
9602b6a1 9205 else if (GET_MODE (operands[0]) == DImode && TARGET_ZARCH)
1d0216c8 9206 emit_jump_insn (gen_doloop_di (operands[1], operands[0], operands[0]));
0a3bdf9d
UW
9207 else
9208 FAIL;
9209
9210 DONE;
10bbf137 9211})
0a3bdf9d 9212
6590e19a 9213(define_insn_and_split "doloop_si64"
0a3bdf9d
UW
9214 [(set (pc)
9215 (if_then_else
7e665d18 9216 (ne (match_operand:SI 1 "register_operand" "d,d,d")
0a3bdf9d
UW
9217 (const_int 1))
9218 (label_ref (match_operand 0 "" ""))
9219 (pc)))
7e665d18 9220 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
0a3bdf9d 9221 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 9222 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
ae156f85 9223 (clobber (reg:CC CC_REGNUM))]
6590e19a 9224 "TARGET_CPU_ZARCH"
0a3bdf9d
UW
9225{
9226 if (which_alternative != 0)
10bbf137 9227 return "#";
0a3bdf9d 9228 else if (get_attr_length (insn) == 4)
d40c829f 9229 return "brct\t%1,%l0";
6590e19a 9230 else
545d16ff 9231 return "ahi\t%1,-1\;jgne\t%l0";
6590e19a
UW
9232}
9233 "&& reload_completed
9234 && (! REG_P (operands[2])
9235 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
9236 [(set (match_dup 3) (match_dup 1))
9237 (parallel [(set (reg:CCAN CC_REGNUM)
6590e19a
UW
9238 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
9239 (const_int 0)))
9240 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
9241 (set (match_dup 2) (match_dup 3))
ae156f85 9242 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a
UW
9243 (label_ref (match_dup 0))
9244 (pc)))]
9245 ""
9246 [(set_attr "op_type" "RI")
9381e3f1
WG
9247 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9248 ; hurt us in the (rare) case of ahi.
729e750f 9249 (set_attr "z10prop" "z10_super_E1")
6590e19a
UW
9250 (set_attr "type" "branch")
9251 (set (attr "length")
9252 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9253 (const_int 4) (const_int 10)))])
9254
9255(define_insn_and_split "doloop_si31"
9256 [(set (pc)
9257 (if_then_else
7e665d18 9258 (ne (match_operand:SI 1 "register_operand" "d,d,d")
6590e19a
UW
9259 (const_int 1))
9260 (label_ref (match_operand 0 "" ""))
9261 (pc)))
7e665d18 9262 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
6590e19a 9263 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 9264 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
ae156f85 9265 (clobber (reg:CC CC_REGNUM))]
6590e19a
UW
9266 "!TARGET_CPU_ZARCH"
9267{
9268 if (which_alternative != 0)
9269 return "#";
9270 else if (get_attr_length (insn) == 4)
9271 return "brct\t%1,%l0";
0a3bdf9d 9272 else
8d933e31 9273 gcc_unreachable ();
10bbf137 9274}
6590e19a
UW
9275 "&& reload_completed
9276 && (! REG_P (operands[2])
9277 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
9278 [(set (match_dup 3) (match_dup 1))
9279 (parallel [(set (reg:CCAN CC_REGNUM)
6590e19a
UW
9280 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
9281 (const_int 0)))
9282 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
9283 (set (match_dup 2) (match_dup 3))
ae156f85 9284 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a
UW
9285 (label_ref (match_dup 0))
9286 (pc)))]
9287 ""
0a3bdf9d 9288 [(set_attr "op_type" "RI")
9381e3f1
WG
9289 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9290 ; hurt us in the (rare) case of ahi.
729e750f 9291 (set_attr "z10prop" "z10_super_E1")
077dab3b 9292 (set_attr "type" "branch")
0a3bdf9d 9293 (set (attr "length")
d7f99b2c 9294 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
9295 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9296 (const_int 4) (const_int 6))
9297 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9298 (const_int 4) (const_int 8))))])
9db1d521 9299
0a3bdf9d
UW
9300(define_insn "*doloop_si_long"
9301 [(set (pc)
9302 (if_then_else
7e665d18 9303 (ne (match_operand:SI 1 "register_operand" "d")
0a3bdf9d 9304 (const_int 1))
3e4be43f 9305 (match_operand 0 "address_operand" "ZR")
0a3bdf9d 9306 (pc)))
7e665d18 9307 (set (match_operand:SI 2 "register_operand" "=1")
0a3bdf9d 9308 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 9309 (clobber (match_scratch:SI 3 "=X"))
ae156f85 9310 (clobber (reg:CC CC_REGNUM))]
6590e19a 9311 "!TARGET_CPU_ZARCH"
0a3bdf9d
UW
9312{
9313 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 9314 return "bctr\t%1,%0";
0a3bdf9d 9315 else
d40c829f 9316 return "bct\t%1,%a0";
10bbf137 9317}
c7453384 9318 [(set (attr "op_type")
0a3bdf9d
UW
9319 (if_then_else (match_operand 0 "register_operand" "")
9320 (const_string "RR") (const_string "RX")))
077dab3b 9321 (set_attr "type" "branch")
729e750f 9322 (set_attr "atype" "agen")
65b1d8ea
AK
9323 (set_attr "z10prop" "z10_c")
9324 (set_attr "z196prop" "z196_cracked")])
0a3bdf9d 9325
6590e19a 9326(define_insn_and_split "doloop_di"
0a3bdf9d
UW
9327 [(set (pc)
9328 (if_then_else
7e665d18 9329 (ne (match_operand:DI 1 "register_operand" "d,d,d")
0a3bdf9d
UW
9330 (const_int 1))
9331 (label_ref (match_operand 0 "" ""))
9332 (pc)))
7e665d18 9333 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
0a3bdf9d 9334 (plus:DI (match_dup 1) (const_int -1)))
7e665d18 9335 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
ae156f85 9336 (clobber (reg:CC CC_REGNUM))]
9602b6a1 9337 "TARGET_ZARCH"
0a3bdf9d
UW
9338{
9339 if (which_alternative != 0)
10bbf137 9340 return "#";
0a3bdf9d 9341 else if (get_attr_length (insn) == 4)
d40c829f 9342 return "brctg\t%1,%l0";
0a3bdf9d 9343 else
545d16ff 9344 return "aghi\t%1,-1\;jgne\t%l0";
10bbf137 9345}
6590e19a 9346 "&& reload_completed
0a3bdf9d
UW
9347 && (! REG_P (operands[2])
9348 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
9349 [(set (match_dup 3) (match_dup 1))
9350 (parallel [(set (reg:CCAN CC_REGNUM)
0a3bdf9d
UW
9351 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
9352 (const_int 0)))
9353 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
9354 (set (match_dup 2) (match_dup 3))
ae156f85 9355 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a 9356 (label_ref (match_dup 0))
0a3bdf9d 9357 (pc)))]
6590e19a
UW
9358 ""
9359 [(set_attr "op_type" "RI")
9381e3f1
WG
9360 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9361 ; hurt us in the (rare) case of ahi.
729e750f 9362 (set_attr "z10prop" "z10_super_E1")
6590e19a
UW
9363 (set_attr "type" "branch")
9364 (set (attr "length")
9365 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9366 (const_int 4) (const_int 10)))])
9db1d521
HP
9367
9368;;
9369;;- Unconditional jump instructions.
9370;;
9371
9372;
9373; jump instruction pattern(s).
9374;
9375
6590e19a
UW
9376(define_expand "jump"
9377 [(match_operand 0 "" "")]
9db1d521 9378 ""
6590e19a
UW
9379 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
9380
9381(define_insn "*jump64"
9382 [(set (pc) (label_ref (match_operand 0 "" "")))]
9383 "TARGET_CPU_ZARCH"
9db1d521 9384{
13e58269 9385 if (get_attr_length (insn) == 4)
d40c829f 9386 return "j\t%l0";
6590e19a 9387 else
d40c829f 9388 return "jg\t%l0";
6590e19a
UW
9389}
9390 [(set_attr "op_type" "RI")
9391 (set_attr "type" "branch")
9392 (set (attr "length")
9393 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9394 (const_int 4) (const_int 6)))])
9395
9396(define_insn "*jump31"
9397 [(set (pc) (label_ref (match_operand 0 "" "")))]
9398 "!TARGET_CPU_ZARCH"
9399{
8d933e31
AS
9400 gcc_assert (get_attr_length (insn) == 4);
9401 return "j\t%l0";
10bbf137 9402}
9db1d521 9403 [(set_attr "op_type" "RI")
077dab3b 9404 (set_attr "type" "branch")
13e58269 9405 (set (attr "length")
d7f99b2c 9406 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
9407 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9408 (const_int 4) (const_int 6))
9409 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9410 (const_int 4) (const_int 8))))])
9db1d521
HP
9411
9412;
9413; indirect-jump instruction pattern(s).
9414;
9415
9416(define_insn "indirect_jump"
3e4be43f 9417 [(set (pc) (match_operand 0 "address_operand" "ZR"))]
9db1d521 9418 ""
f314b9b1
UW
9419{
9420 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 9421 return "br\t%0";
f314b9b1 9422 else
d40c829f 9423 return "b\t%a0";
10bbf137 9424}
c7453384 9425 [(set (attr "op_type")
f314b9b1
UW
9426 (if_then_else (match_operand 0 "register_operand" "")
9427 (const_string "RR") (const_string "RX")))
077dab3b 9428 (set_attr "type" "branch")
729e750f 9429 (set_attr "atype" "agen")])
9db1d521
HP
9430
9431;
f314b9b1 9432; casesi instruction pattern(s).
9db1d521
HP
9433;
9434
f314b9b1 9435(define_insn "casesi_jump"
3e4be43f 9436 [(set (pc) (match_operand 0 "address_operand" "ZR"))
f314b9b1 9437 (use (label_ref (match_operand 1 "" "")))]
9db1d521 9438 ""
9db1d521 9439{
f314b9b1 9440 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 9441 return "br\t%0";
f314b9b1 9442 else
d40c829f 9443 return "b\t%a0";
10bbf137 9444}
c7453384 9445 [(set (attr "op_type")
f314b9b1
UW
9446 (if_then_else (match_operand 0 "register_operand" "")
9447 (const_string "RR") (const_string "RX")))
077dab3b
HP
9448 (set_attr "type" "branch")
9449 (set_attr "atype" "agen")])
9db1d521 9450
f314b9b1
UW
9451(define_expand "casesi"
9452 [(match_operand:SI 0 "general_operand" "")
9453 (match_operand:SI 1 "general_operand" "")
9454 (match_operand:SI 2 "general_operand" "")
9455 (label_ref (match_operand 3 "" ""))
9456 (label_ref (match_operand 4 "" ""))]
9db1d521 9457 ""
f314b9b1
UW
9458{
9459 rtx index = gen_reg_rtx (SImode);
9460 rtx base = gen_reg_rtx (Pmode);
9461 rtx target = gen_reg_rtx (Pmode);
9462
9463 emit_move_insn (index, operands[0]);
9464 emit_insn (gen_subsi3 (index, index, operands[1]));
9465 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
e790b36a 9466 operands[4]);
f314b9b1
UW
9467
9468 if (Pmode != SImode)
9469 index = convert_to_mode (Pmode, index, 1);
9470 if (GET_CODE (index) != REG)
9471 index = copy_to_mode_reg (Pmode, index);
9472
9473 if (TARGET_64BIT)
9474 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
9475 else
a556fd39 9476 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
9db1d521 9477
f314b9b1
UW
9478 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
9479
542a8afa 9480 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
f314b9b1
UW
9481 emit_move_insn (target, index);
9482
9483 if (flag_pic)
9484 target = gen_rtx_PLUS (Pmode, base, target);
9485 emit_jump_insn (gen_casesi_jump (target, operands[3]));
9486
9487 DONE;
10bbf137 9488})
9db1d521
HP
9489
9490
9491;;
9492;;- Jump to subroutine.
9493;;
9494;;
9495
9496;
9497; untyped call instruction pattern(s).
9498;
9499
9500;; Call subroutine returning any type.
9501(define_expand "untyped_call"
9502 [(parallel [(call (match_operand 0 "" "")
9503 (const_int 0))
9504 (match_operand 1 "" "")
9505 (match_operand 2 "" "")])]
9506 ""
9db1d521
HP
9507{
9508 int i;
9509
9510 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
9511
9512 for (i = 0; i < XVECLEN (operands[2], 0); i++)
9513 {
9514 rtx set = XVECEXP (operands[2], 0, i);
9515 emit_move_insn (SET_DEST (set), SET_SRC (set));
9516 }
9517
9518 /* The optimizer does not know that the call sets the function value
9519 registers we stored in the result block. We avoid problems by
9520 claiming that all hard registers are used and clobbered at this
9521 point. */
9522 emit_insn (gen_blockage ());
9523
9524 DONE;
10bbf137 9525})
9db1d521
HP
9526
9527;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
9528;; all of memory. This blocks insns from being moved across this point.
9529
9530(define_insn "blockage"
10bbf137 9531 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
9db1d521 9532 ""
4023fb28 9533 ""
d5869ca0
UW
9534 [(set_attr "type" "none")
9535 (set_attr "length" "0")])
4023fb28 9536
9db1d521 9537;
ed9676cf 9538; sibcall patterns
9db1d521
HP
9539;
9540
ed9676cf 9541(define_expand "sibcall"
44b8152b 9542 [(call (match_operand 0 "" "")
ed9676cf 9543 (match_operand 1 "" ""))]
9db1d521 9544 ""
9db1d521 9545{
ed9676cf
AK
9546 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
9547 DONE;
9548})
9db1d521 9549
ed9676cf 9550(define_insn "*sibcall_br"
ae156f85 9551 [(call (mem:QI (reg SIBCALL_REGNUM))
ed9676cf 9552 (match_operand 0 "const_int_operand" "n"))]
2f7e5a0d 9553 "SIBLING_CALL_P (insn)
ed9676cf
AK
9554 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
9555 "br\t%%r1"
9556 [(set_attr "op_type" "RR")
9557 (set_attr "type" "branch")
9558 (set_attr "atype" "agen")])
9db1d521 9559
ed9676cf
AK
9560(define_insn "*sibcall_brc"
9561 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9562 (match_operand 1 "const_int_operand" "n"))]
9563 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
9564 "j\t%0"
9565 [(set_attr "op_type" "RI")
9566 (set_attr "type" "branch")])
9db1d521 9567
ed9676cf
AK
9568(define_insn "*sibcall_brcl"
9569 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9570 (match_operand 1 "const_int_operand" "n"))]
9571 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
9572 "jg\t%0"
9573 [(set_attr "op_type" "RIL")
9574 (set_attr "type" "branch")])
44b8152b 9575
ed9676cf
AK
9576;
9577; sibcall_value patterns
9578;
9e8327e3 9579
ed9676cf
AK
9580(define_expand "sibcall_value"
9581 [(set (match_operand 0 "" "")
9582 (call (match_operand 1 "" "")
9583 (match_operand 2 "" "")))]
9584 ""
9585{
9586 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
44b8152b 9587 DONE;
10bbf137 9588})
9db1d521 9589
ed9676cf
AK
9590(define_insn "*sibcall_value_br"
9591 [(set (match_operand 0 "" "")
ae156f85 9592 (call (mem:QI (reg SIBCALL_REGNUM))
ed9676cf 9593 (match_operand 1 "const_int_operand" "n")))]
2f7e5a0d 9594 "SIBLING_CALL_P (insn)
ed9676cf
AK
9595 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
9596 "br\t%%r1"
9597 [(set_attr "op_type" "RR")
9598 (set_attr "type" "branch")
9599 (set_attr "atype" "agen")])
9600
9601(define_insn "*sibcall_value_brc"
9602 [(set (match_operand 0 "" "")
9603 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9604 (match_operand 2 "const_int_operand" "n")))]
9605 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
9606 "j\t%1"
9607 [(set_attr "op_type" "RI")
9608 (set_attr "type" "branch")])
9609
9610(define_insn "*sibcall_value_brcl"
9611 [(set (match_operand 0 "" "")
9612 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9613 (match_operand 2 "const_int_operand" "n")))]
9614 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
9615 "jg\t%1"
9616 [(set_attr "op_type" "RIL")
9617 (set_attr "type" "branch")])
9618
9619
9620;
9621; call instruction pattern(s).
9622;
9623
9624(define_expand "call"
9625 [(call (match_operand 0 "" "")
9626 (match_operand 1 "" ""))
9627 (use (match_operand 2 "" ""))]
44b8152b 9628 ""
ed9676cf 9629{
2f7e5a0d 9630 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
ed9676cf
AK
9631 gen_rtx_REG (Pmode, RETURN_REGNUM));
9632 DONE;
9633})
44b8152b 9634
9e8327e3
UW
9635(define_insn "*bras"
9636 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9637 (match_operand 1 "const_int_operand" "n"))
9638 (clobber (match_operand 2 "register_operand" "=r"))]
2f7e5a0d
EC
9639 "!SIBLING_CALL_P (insn)
9640 && TARGET_SMALL_EXEC
ed9676cf 9641 && GET_MODE (operands[2]) == Pmode"
d40c829f 9642 "bras\t%2,%0"
9db1d521 9643 [(set_attr "op_type" "RI")
65b1d8ea
AK
9644 (set_attr "type" "jsr")
9645 (set_attr "z196prop" "z196_cracked")])
9db1d521 9646
9e8327e3
UW
9647(define_insn "*brasl"
9648 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9649 (match_operand 1 "const_int_operand" "n"))
9650 (clobber (match_operand 2 "register_operand" "=r"))]
2f7e5a0d
EC
9651 "!SIBLING_CALL_P (insn)
9652 && TARGET_CPU_ZARCH
ed9676cf 9653 && GET_MODE (operands[2]) == Pmode"
9e8327e3
UW
9654 "brasl\t%2,%0"
9655 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9656 (set_attr "type" "jsr")
9657 (set_attr "z196prop" "z196_cracked")])
9db1d521 9658
9e8327e3 9659(define_insn "*basr"
3e4be43f 9660 [(call (mem:QI (match_operand 0 "address_operand" "ZR"))
9e8327e3
UW
9661 (match_operand 1 "const_int_operand" "n"))
9662 (clobber (match_operand 2 "register_operand" "=r"))]
ed9676cf 9663 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
9e8327e3
UW
9664{
9665 if (get_attr_op_type (insn) == OP_TYPE_RR)
9666 return "basr\t%2,%0";
9667 else
9668 return "bas\t%2,%a0";
9669}
9670 [(set (attr "op_type")
9671 (if_then_else (match_operand 0 "register_operand" "")
9672 (const_string "RR") (const_string "RX")))
9673 (set_attr "type" "jsr")
65b1d8ea
AK
9674 (set_attr "atype" "agen")
9675 (set_attr "z196prop" "z196_cracked")])
9db1d521
HP
9676
9677;
9678; call_value instruction pattern(s).
9679;
9680
9681(define_expand "call_value"
44b8152b
UW
9682 [(set (match_operand 0 "" "")
9683 (call (match_operand 1 "" "")
9684 (match_operand 2 "" "")))
9685 (use (match_operand 3 "" ""))]
9db1d521 9686 ""
9db1d521 9687{
2f7e5a0d 9688 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
ed9676cf 9689 gen_rtx_REG (Pmode, RETURN_REGNUM));
44b8152b 9690 DONE;
10bbf137 9691})
9db1d521 9692
9e8327e3 9693(define_insn "*bras_r"
c19ec8f9 9694 [(set (match_operand 0 "" "")
9e8327e3 9695 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9db1d521 9696 (match_operand:SI 2 "const_int_operand" "n")))
9e8327e3 9697 (clobber (match_operand 3 "register_operand" "=r"))]
2f7e5a0d
EC
9698 "!SIBLING_CALL_P (insn)
9699 && TARGET_SMALL_EXEC
ed9676cf 9700 && GET_MODE (operands[3]) == Pmode"
d40c829f 9701 "bras\t%3,%1"
9db1d521 9702 [(set_attr "op_type" "RI")
65b1d8ea
AK
9703 (set_attr "type" "jsr")
9704 (set_attr "z196prop" "z196_cracked")])
9db1d521 9705
9e8327e3 9706(define_insn "*brasl_r"
c19ec8f9 9707 [(set (match_operand 0 "" "")
9e8327e3
UW
9708 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9709 (match_operand 2 "const_int_operand" "n")))
9710 (clobber (match_operand 3 "register_operand" "=r"))]
2f7e5a0d
EC
9711 "!SIBLING_CALL_P (insn)
9712 && TARGET_CPU_ZARCH
ed9676cf 9713 && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9714 "brasl\t%3,%1"
9715 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9716 (set_attr "type" "jsr")
9717 (set_attr "z196prop" "z196_cracked")])
9db1d521 9718
9e8327e3 9719(define_insn "*basr_r"
c19ec8f9 9720 [(set (match_operand 0 "" "")
3e4be43f 9721 (call (mem:QI (match_operand 1 "address_operand" "ZR"))
9e8327e3
UW
9722 (match_operand 2 "const_int_operand" "n")))
9723 (clobber (match_operand 3 "register_operand" "=r"))]
ed9676cf 9724 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9725{
9726 if (get_attr_op_type (insn) == OP_TYPE_RR)
9727 return "basr\t%3,%1";
9728 else
9729 return "bas\t%3,%a1";
9730}
9731 [(set (attr "op_type")
9732 (if_then_else (match_operand 1 "register_operand" "")
9733 (const_string "RR") (const_string "RX")))
9734 (set_attr "type" "jsr")
65b1d8ea
AK
9735 (set_attr "atype" "agen")
9736 (set_attr "z196prop" "z196_cracked")])
9db1d521 9737
fd3cd001
UW
9738;;
9739;;- Thread-local storage support.
9740;;
9741
f959607b
CLT
9742(define_expand "get_thread_pointer<mode>"
9743 [(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))]
9744 ""
c5aa1d12 9745 "")
fd3cd001 9746
f959607b
CLT
9747(define_expand "set_thread_pointer<mode>"
9748 [(set (reg:P TP_REGNUM) (match_operand:P 0 "nonimmediate_operand" ""))
9749 (set (reg:P TP_REGNUM) (unspec_volatile:P [(reg:P TP_REGNUM)] UNSPECV_SET_TP))]
9750 ""
c5aa1d12
UW
9751 "")
9752
9753(define_insn "*set_tp"
ae156f85 9754 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
c5aa1d12
UW
9755 ""
9756 ""
9757 [(set_attr "type" "none")
9758 (set_attr "length" "0")])
c7453384 9759
fd3cd001
UW
9760(define_insn "*tls_load_64"
9761 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 9762 (unspec:DI [(match_operand:DI 1 "memory_operand" "T")
fd3cd001
UW
9763 (match_operand:DI 2 "" "")]
9764 UNSPEC_TLS_LOAD))]
9765 "TARGET_64BIT"
d40c829f 9766 "lg\t%0,%1%J2"
9381e3f1
WG
9767 [(set_attr "op_type" "RXE")
9768 (set_attr "z10prop" "z10_fwd_A3")])
fd3cd001
UW
9769
9770(define_insn "*tls_load_31"
d3632d41
UW
9771 [(set (match_operand:SI 0 "register_operand" "=d,d")
9772 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
fd3cd001
UW
9773 (match_operand:SI 2 "" "")]
9774 UNSPEC_TLS_LOAD))]
9775 "!TARGET_64BIT"
d3632d41 9776 "@
d40c829f
UW
9777 l\t%0,%1%J2
9778 ly\t%0,%1%J2"
9381e3f1 9779 [(set_attr "op_type" "RX,RXY")
cdc15d23 9780 (set_attr "type" "load")
3e4be43f 9781 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 9782 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
fd3cd001 9783
9e8327e3 9784(define_insn "*bras_tls"
c19ec8f9 9785 [(set (match_operand 0 "" "")
9e8327e3
UW
9786 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9787 (match_operand 2 "const_int_operand" "n")))
9788 (clobber (match_operand 3 "register_operand" "=r"))
9789 (use (match_operand 4 "" ""))]
2f7e5a0d
EC
9790 "!SIBLING_CALL_P (insn)
9791 && TARGET_SMALL_EXEC
ed9676cf 9792 && GET_MODE (operands[3]) == Pmode"
d40c829f 9793 "bras\t%3,%1%J4"
fd3cd001 9794 [(set_attr "op_type" "RI")
65b1d8ea
AK
9795 (set_attr "type" "jsr")
9796 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9797
9e8327e3 9798(define_insn "*brasl_tls"
c19ec8f9 9799 [(set (match_operand 0 "" "")
9e8327e3
UW
9800 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9801 (match_operand 2 "const_int_operand" "n")))
9802 (clobber (match_operand 3 "register_operand" "=r"))
9803 (use (match_operand 4 "" ""))]
2f7e5a0d
EC
9804 "!SIBLING_CALL_P (insn)
9805 && TARGET_CPU_ZARCH
ed9676cf 9806 && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9807 "brasl\t%3,%1%J4"
9808 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9809 (set_attr "type" "jsr")
9810 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9811
9e8327e3 9812(define_insn "*basr_tls"
c19ec8f9 9813 [(set (match_operand 0 "" "")
3e4be43f 9814 (call (mem:QI (match_operand 1 "address_operand" "ZR"))
9e8327e3
UW
9815 (match_operand 2 "const_int_operand" "n")))
9816 (clobber (match_operand 3 "register_operand" "=r"))
9817 (use (match_operand 4 "" ""))]
ed9676cf 9818 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9819{
9820 if (get_attr_op_type (insn) == OP_TYPE_RR)
9821 return "basr\t%3,%1%J4";
9822 else
9823 return "bas\t%3,%a1%J4";
9824}
9825 [(set (attr "op_type")
9826 (if_then_else (match_operand 1 "register_operand" "")
9827 (const_string "RR") (const_string "RX")))
9828 (set_attr "type" "jsr")
65b1d8ea
AK
9829 (set_attr "atype" "agen")
9830 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9831
e0374221
AS
9832;;
9833;;- Atomic operations
9834;;
9835
9836;
78ce265b 9837; memory barrier patterns.
e0374221
AS
9838;
9839
78ce265b
RH
9840(define_expand "mem_signal_fence"
9841 [(match_operand:SI 0 "const_int_operand")] ;; model
e0374221
AS
9842 ""
9843{
78ce265b
RH
9844 /* The s390 memory model is strong enough not to require any
9845 barrier in order to synchronize a thread with itself. */
9846 DONE;
9847})
9848
9849(define_expand "mem_thread_fence"
9850 [(match_operand:SI 0 "const_int_operand")] ;; model
9851 ""
9852{
9853 /* Unless this is a SEQ_CST fence, the s390 memory model is strong
9854 enough not to require barriers of any kind. */
46b35980 9855 if (is_mm_seq_cst (memmodel_from_int (INTVAL (operands[0]))))
78ce265b
RH
9856 {
9857 rtx mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
9858 MEM_VOLATILE_P (mem) = 1;
9859 emit_insn (gen_mem_thread_fence_1 (mem));
9860 }
9861 DONE;
e0374221
AS
9862})
9863
78ce265b
RH
9864; Although bcr is superscalar on Z10, this variant will never
9865; become part of an execution group.
a9cc3f58
AK
9866; With z196 we can make use of the fast-BCR-serialization facility.
9867; This allows for a slightly faster sync which is sufficient for our
9868; purposes.
78ce265b 9869(define_insn "mem_thread_fence_1"
e0374221 9870 [(set (match_operand:BLK 0 "" "")
1a8c13b3 9871 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
e0374221 9872 ""
a9cc3f58
AK
9873{
9874 if (TARGET_Z196)
9875 return "bcr\t14,0";
9876 else
9877 return "bcr\t15,0";
9878}
9879 [(set_attr "op_type" "RR")
9880 (set_attr "mnemonic" "bcr_flush")
9881 (set_attr "z196prop" "z196_alone")])
1a8c13b3 9882
78ce265b
RH
9883;
9884; atomic load/store operations
9885;
9886
9887; Atomic loads need not examine the memory model at all.
9888(define_expand "atomic_load<mode>"
9889 [(match_operand:DINT 0 "register_operand") ;; output
9890 (match_operand:DINT 1 "memory_operand") ;; memory
9891 (match_operand:SI 2 "const_int_operand")] ;; model
9892 ""
9893{
75cc21e2
AK
9894 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
9895 FAIL;
9896
78ce265b
RH
9897 if (<MODE>mode == TImode)
9898 emit_insn (gen_atomic_loadti_1 (operands[0], operands[1]));
9899 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9900 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
9901 else
9902 emit_move_insn (operands[0], operands[1]);
9903 DONE;
9904})
9905
9906; Different from movdi_31 in that we want no splitters.
9907(define_insn "atomic_loaddi_1"
9908 [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f")
9909 (unspec:DI [(match_operand:DI 1 "memory_operand" "Q,S,R,T")]
9910 UNSPEC_MOVA))]
9911 "!TARGET_ZARCH"
9912 "@
9913 lm\t%0,%M0,%S1
9914 lmy\t%0,%M0,%S1
9915 ld\t%0,%1
9916 ldy\t%0,%1"
9917 [(set_attr "op_type" "RS,RSY,RS,RSY")
3e4be43f 9918 (set_attr "cpu_facility" "*,longdisp,*,longdisp")
78ce265b
RH
9919 (set_attr "type" "lm,lm,floaddf,floaddf")])
9920
9921(define_insn "atomic_loadti_1"
9922 [(set (match_operand:TI 0 "register_operand" "=r")
3e4be43f 9923 (unspec:TI [(match_operand:TI 1 "memory_operand" "T")]
78ce265b
RH
9924 UNSPEC_MOVA))]
9925 "TARGET_ZARCH"
9926 "lpq\t%0,%1"
9927 [(set_attr "op_type" "RXY")
9928 (set_attr "type" "other")])
9929
9930; Atomic stores must(?) enforce sequential consistency.
9931(define_expand "atomic_store<mode>"
9932 [(match_operand:DINT 0 "memory_operand") ;; memory
9933 (match_operand:DINT 1 "register_operand") ;; input
9934 (match_operand:SI 2 "const_int_operand")] ;; model
9935 ""
9936{
46b35980 9937 enum memmodel model = memmodel_from_int (INTVAL (operands[2]));
78ce265b 9938
75cc21e2
AK
9939 if (MEM_ALIGN (operands[0]) < GET_MODE_BITSIZE (GET_MODE (operands[0])))
9940 FAIL;
9941
78ce265b
RH
9942 if (<MODE>mode == TImode)
9943 emit_insn (gen_atomic_storeti_1 (operands[0], operands[1]));
9944 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9945 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
9946 else
9947 emit_move_insn (operands[0], operands[1]);
46b35980 9948 if (is_mm_seq_cst (model))
78ce265b
RH
9949 emit_insn (gen_mem_thread_fence (operands[2]));
9950 DONE;
9951})
9952
9953; Different from movdi_31 in that we want no splitters.
9954(define_insn "atomic_storedi_1"
9955 [(set (match_operand:DI 0 "memory_operand" "=Q,S,R,T")
9956 (unspec:DI [(match_operand:DI 1 "register_operand" "d,d,!*f,!*f")]
9957 UNSPEC_MOVA))]
9958 "!TARGET_ZARCH"
9959 "@
9960 stm\t%1,%N1,%S0
9961 stmy\t%1,%N1,%S0
9962 std %1,%0
9963 stdy %1,%0"
9964 [(set_attr "op_type" "RS,RSY,RS,RSY")
3e4be43f 9965 (set_attr "cpu_facility" "*,longdisp,*,longdisp")
78ce265b
RH
9966 (set_attr "type" "stm,stm,fstoredf,fstoredf")])
9967
9968(define_insn "atomic_storeti_1"
3e4be43f 9969 [(set (match_operand:TI 0 "memory_operand" "=T")
78ce265b
RH
9970 (unspec:TI [(match_operand:TI 1 "register_operand" "r")]
9971 UNSPEC_MOVA))]
9972 "TARGET_ZARCH"
9973 "stpq\t%1,%0"
9974 [(set_attr "op_type" "RXY")
9975 (set_attr "type" "other")])
e0374221
AS
9976
9977;
9978; compare and swap patterns.
9979;
9980
78ce265b
RH
9981(define_expand "atomic_compare_and_swap<mode>"
9982 [(match_operand:SI 0 "register_operand") ;; bool success output
215770ad 9983 (match_operand:DGPR 1 "nonimmediate_operand");; oldval output
78ce265b
RH
9984 (match_operand:DGPR 2 "memory_operand") ;; memory
9985 (match_operand:DGPR 3 "register_operand") ;; expected intput
9986 (match_operand:DGPR 4 "register_operand") ;; newval intput
9987 (match_operand:SI 5 "const_int_operand") ;; is_weak
9988 (match_operand:SI 6 "const_int_operand") ;; success model
9989 (match_operand:SI 7 "const_int_operand")] ;; failure model
9990 ""
9991{
215770ad
UW
9992 rtx cc, cmp, output = operands[1];
9993
9994 if (!register_operand (output, <MODE>mode))
9995 output = gen_reg_rtx (<MODE>mode);
9996
75cc21e2
AK
9997 if (MEM_ALIGN (operands[2]) < GET_MODE_BITSIZE (GET_MODE (operands[2])))
9998 FAIL;
9999
78ce265b 10000 emit_insn (gen_atomic_compare_and_swap<mode>_internal
215770ad
UW
10001 (output, operands[2], operands[3], operands[4]));
10002
10003 /* We deliberately accept non-register operands in the predicate
10004 to ensure the write back to the output operand happens *before*
10005 the store-flags code below. This makes it easier for combine
10006 to merge the store-flags code with a potential test-and-branch
10007 pattern following (immediately!) afterwards. */
10008 if (output != operands[1])
10009 emit_move_insn (operands[1], output);
10010
78ce265b
RH
10011 cc = gen_rtx_REG (CCZ1mode, CC_REGNUM);
10012 cmp = gen_rtx_EQ (SImode, cc, const0_rtx);
10013 emit_insn (gen_cstorecc4 (operands[0], cmp, cc, const0_rtx));
10014 DONE;
10015})
e0374221 10016
78ce265b
RH
10017(define_expand "atomic_compare_and_swap<mode>"
10018 [(match_operand:SI 0 "register_operand") ;; bool success output
215770ad 10019 (match_operand:HQI 1 "nonimmediate_operand") ;; oldval output
78ce265b
RH
10020 (match_operand:HQI 2 "memory_operand") ;; memory
10021 (match_operand:HQI 3 "general_operand") ;; expected intput
10022 (match_operand:HQI 4 "general_operand") ;; newval intput
10023 (match_operand:SI 5 "const_int_operand") ;; is_weak
10024 (match_operand:SI 6 "const_int_operand") ;; success model
10025 (match_operand:SI 7 "const_int_operand")] ;; failure model
3093f076 10026 ""
78ce265b
RH
10027{
10028 s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1], operands[2],
10029 operands[3], operands[4], INTVAL (operands[5]));
10030 DONE;
10031})
3093f076 10032
78ce265b
RH
10033(define_expand "atomic_compare_and_swap<mode>_internal"
10034 [(parallel
10035 [(set (match_operand:DGPR 0 "register_operand")
10036 (match_operand:DGPR 1 "memory_operand"))
10037 (set (match_dup 1)
10038 (unspec_volatile:DGPR
10039 [(match_dup 1)
10040 (match_operand:DGPR 2 "register_operand")
10041 (match_operand:DGPR 3 "register_operand")]
10042 UNSPECV_CAS))
10043 (set (reg:CCZ1 CC_REGNUM)
10044 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
10045 "")
10046
10047; cdsg, csg
10048(define_insn "*atomic_compare_and_swap<mode>_1"
10049 [(set (match_operand:TDI 0 "register_operand" "=r")
3e4be43f 10050 (match_operand:TDI 1 "memory_operand" "+S"))
8006eaa6 10051 (set (match_dup 1)
78ce265b 10052 (unspec_volatile:TDI
8006eaa6 10053 [(match_dup 1)
78ce265b
RH
10054 (match_operand:TDI 2 "register_operand" "0")
10055 (match_operand:TDI 3 "register_operand" "r")]
8006eaa6
AS
10056 UNSPECV_CAS))
10057 (set (reg:CCZ1 CC_REGNUM)
10058 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
78ce265b
RH
10059 "TARGET_ZARCH"
10060 "c<td>sg\t%0,%3,%S1"
10061 [(set_attr "op_type" "RSY")
8006eaa6
AS
10062 (set_attr "type" "sem")])
10063
78ce265b
RH
10064; cds, cdsy
10065(define_insn "*atomic_compare_and_swapdi_2"
10066 [(set (match_operand:DI 0 "register_operand" "=r,r")
10067 (match_operand:DI 1 "memory_operand" "+Q,S"))
e0374221 10068 (set (match_dup 1)
78ce265b
RH
10069 (unspec_volatile:DI
10070 [(match_dup 1)
10071 (match_operand:DI 2 "register_operand" "0,0")
10072 (match_operand:DI 3 "register_operand" "r,r")]
10073 UNSPECV_CAS))
10074 (set (reg:CCZ1 CC_REGNUM)
10075 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
10076 "!TARGET_ZARCH"
10077 "@
10078 cds\t%0,%3,%S1
10079 cdsy\t%0,%3,%S1"
10080 [(set_attr "op_type" "RS,RSY")
3e4be43f 10081 (set_attr "cpu_facility" "*,longdisp")
78ce265b
RH
10082 (set_attr "type" "sem")])
10083
10084; cs, csy
10085(define_insn "*atomic_compare_and_swapsi_3"
10086 [(set (match_operand:SI 0 "register_operand" "=r,r")
10087 (match_operand:SI 1 "memory_operand" "+Q,S"))
10088 (set (match_dup 1)
10089 (unspec_volatile:SI
e0374221 10090 [(match_dup 1)
78ce265b
RH
10091 (match_operand:SI 2 "register_operand" "0,0")
10092 (match_operand:SI 3 "register_operand" "r,r")]
e0374221 10093 UNSPECV_CAS))
69950452
AS
10094 (set (reg:CCZ1 CC_REGNUM)
10095 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9381e3f1 10096 ""
78ce265b
RH
10097 "@
10098 cs\t%0,%3,%S1
10099 csy\t%0,%3,%S1"
10100 [(set_attr "op_type" "RS,RSY")
3e4be43f 10101 (set_attr "cpu_facility" "*,longdisp")
e0374221
AS
10102 (set_attr "type" "sem")])
10103
45d18331
AS
10104;
10105; Other atomic instruction patterns.
10106;
10107
65b1d8ea
AK
10108; z196 load and add, xor, or and and instructions
10109
78ce265b
RH
10110(define_expand "atomic_fetch_<atomic><mode>"
10111 [(match_operand:GPR 0 "register_operand") ;; val out
10112 (ATOMIC_Z196:GPR
10113 (match_operand:GPR 1 "memory_operand") ;; memory
10114 (match_operand:GPR 2 "register_operand")) ;; val in
10115 (match_operand:SI 3 "const_int_operand")] ;; model
65b1d8ea 10116 "TARGET_Z196"
78ce265b 10117{
75cc21e2
AK
10118 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
10119 FAIL;
10120
78ce265b
RH
10121 emit_insn (gen_atomic_fetch_<atomic><mode>_iaf
10122 (operands[0], operands[1], operands[2]));
10123 DONE;
10124})
65b1d8ea
AK
10125
10126; lan, lang, lao, laog, lax, laxg, laa, laag
78ce265b
RH
10127(define_insn "atomic_fetch_<atomic><mode>_iaf"
10128 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 10129 (match_operand:GPR 1 "memory_operand" "+S"))
78ce265b
RH
10130 (set (match_dup 1)
10131 (unspec_volatile:GPR
10132 [(ATOMIC_Z196:GPR (match_dup 1)
10133 (match_operand:GPR 2 "general_operand" "d"))]
10134 UNSPECV_ATOMIC_OP))
10135 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 10136 "TARGET_Z196"
78ce265b
RH
10137 "la<noxa><g>\t%0,%2,%1"
10138 [(set_attr "op_type" "RSY")
10139 (set_attr "type" "sem")])
65b1d8ea 10140
78ce265b
RH
10141;; For SImode and larger, the optabs.c code will do just fine in
10142;; expanding a compare-and-swap loop. For QI/HImode, we can do
10143;; better by expanding our own loop.
65b1d8ea 10144
78ce265b
RH
10145(define_expand "atomic_<atomic><mode>"
10146 [(ATOMIC:HQI
10147 (match_operand:HQI 0 "memory_operand") ;; memory
10148 (match_operand:HQI 1 "general_operand")) ;; val in
10149 (match_operand:SI 2 "const_int_operand")] ;; model
45d18331 10150 ""
78ce265b
RH
10151{
10152 s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
10153 operands[1], false);
10154 DONE;
10155})
45d18331 10156
78ce265b
RH
10157(define_expand "atomic_fetch_<atomic><mode>"
10158 [(match_operand:HQI 0 "register_operand") ;; val out
10159 (ATOMIC:HQI
10160 (match_operand:HQI 1 "memory_operand") ;; memory
10161 (match_operand:HQI 2 "general_operand")) ;; val in
10162 (match_operand:SI 3 "const_int_operand")] ;; model
45d18331 10163 ""
78ce265b
RH
10164{
10165 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
10166 operands[2], false);
10167 DONE;
10168})
10169
10170(define_expand "atomic_<atomic>_fetch<mode>"
10171 [(match_operand:HQI 0 "register_operand") ;; val out
10172 (ATOMIC:HQI
10173 (match_operand:HQI 1 "memory_operand") ;; memory
10174 (match_operand:HQI 2 "general_operand")) ;; val in
10175 (match_operand:SI 3 "const_int_operand")] ;; model
10176 ""
10177{
10178 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
10179 operands[2], true);
10180 DONE;
10181})
10182
10183(define_expand "atomic_exchange<mode>"
10184 [(match_operand:HQI 0 "register_operand") ;; val out
10185 (match_operand:HQI 1 "memory_operand") ;; memory
10186 (match_operand:HQI 2 "general_operand") ;; val in
10187 (match_operand:SI 3 "const_int_operand")] ;; model
45d18331 10188 ""
78ce265b
RH
10189{
10190 s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
10191 operands[2], false);
10192 DONE;
10193})
45d18331 10194
9db1d521
HP
10195;;
10196;;- Miscellaneous instructions.
10197;;
10198
10199;
10200; allocate stack instruction pattern(s).
10201;
10202
10203(define_expand "allocate_stack"
ef44a6ff
UW
10204 [(match_operand 0 "general_operand" "")
10205 (match_operand 1 "general_operand" "")]
b3d31392 10206 "TARGET_BACKCHAIN"
9db1d521 10207{
ef44a6ff 10208 rtx temp = gen_reg_rtx (Pmode);
9db1d521 10209
ef44a6ff
UW
10210 emit_move_insn (temp, s390_back_chain_rtx ());
10211 anti_adjust_stack (operands[1]);
10212 emit_move_insn (s390_back_chain_rtx (), temp);
9db1d521 10213
ef44a6ff
UW
10214 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10215 DONE;
10bbf137 10216})
9db1d521
HP
10217
10218
10219;
43ab026f 10220; setjmp instruction pattern.
9db1d521
HP
10221;
10222
9db1d521 10223(define_expand "builtin_setjmp_receiver"
fd7643fb 10224 [(match_operand 0 "" "")]
f314b9b1 10225 "flag_pic"
9db1d521 10226{
585539a1 10227 emit_insn (s390_load_got ());
c41c1387 10228 emit_use (pic_offset_table_rtx);
9db1d521 10229 DONE;
fd7643fb 10230})
9db1d521 10231
9db1d521
HP
10232;; These patterns say how to save and restore the stack pointer. We need not
10233;; save the stack pointer at function level since we are careful to
10234;; preserve the backchain. At block level, we have to restore the backchain
10235;; when we restore the stack pointer.
10236;;
10237;; For nonlocal gotos, we must save both the stack pointer and its
10238;; backchain and restore both. Note that in the nonlocal case, the
10239;; save area is a memory location.
10240
10241(define_expand "save_stack_function"
10242 [(match_operand 0 "general_operand" "")
10243 (match_operand 1 "general_operand" "")]
10244 ""
10245 "DONE;")
10246
10247(define_expand "restore_stack_function"
10248 [(match_operand 0 "general_operand" "")
10249 (match_operand 1 "general_operand" "")]
10250 ""
10251 "DONE;")
10252
10253(define_expand "restore_stack_block"
ef44a6ff
UW
10254 [(match_operand 0 "register_operand" "")
10255 (match_operand 1 "register_operand" "")]
b3d31392 10256 "TARGET_BACKCHAIN"
9db1d521 10257{
ef44a6ff
UW
10258 rtx temp = gen_reg_rtx (Pmode);
10259
10260 emit_move_insn (temp, s390_back_chain_rtx ());
10261 emit_move_insn (operands[0], operands[1]);
10262 emit_move_insn (s390_back_chain_rtx (), temp);
10263
10264 DONE;
10bbf137 10265})
9db1d521
HP
10266
10267(define_expand "save_stack_nonlocal"
10268 [(match_operand 0 "memory_operand" "")
10269 (match_operand 1 "register_operand" "")]
10270 ""
9db1d521 10271{
ef44a6ff
UW
10272 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
10273
10274 /* Copy the backchain to the first word, sp to the second and the
10275 literal pool base to the third. */
10276
9602b6a1
AK
10277 rtx save_bc = adjust_address (operands[0], Pmode, 0);
10278 rtx save_sp = adjust_address (operands[0], Pmode, GET_MODE_SIZE (Pmode));
10279 rtx save_bp = adjust_address (operands[0], Pmode, 2 * GET_MODE_SIZE (Pmode));
10280
b3d31392 10281 if (TARGET_BACKCHAIN)
9602b6a1 10282 emit_move_insn (save_bc, force_reg (Pmode, s390_back_chain_rtx ()));
ef44a6ff 10283
9602b6a1
AK
10284 emit_move_insn (save_sp, operands[1]);
10285 emit_move_insn (save_bp, base);
9db1d521 10286
9db1d521 10287 DONE;
10bbf137 10288})
9db1d521
HP
10289
10290(define_expand "restore_stack_nonlocal"
10291 [(match_operand 0 "register_operand" "")
10292 (match_operand 1 "memory_operand" "")]
10293 ""
9db1d521 10294{
490ceeb4 10295 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
ef44a6ff 10296 rtx temp = NULL_RTX;
9db1d521 10297
43ab026f 10298 /* Restore the backchain from the first word, sp from the second and the
ff482c8d 10299 literal pool base from the third. */
43ab026f 10300
9602b6a1
AK
10301 rtx save_bc = adjust_address (operands[1], Pmode, 0);
10302 rtx save_sp = adjust_address (operands[1], Pmode, GET_MODE_SIZE (Pmode));
10303 rtx save_bp = adjust_address (operands[1], Pmode, 2 * GET_MODE_SIZE (Pmode));
10304
b3d31392 10305 if (TARGET_BACKCHAIN)
9602b6a1 10306 temp = force_reg (Pmode, save_bc);
9381e3f1 10307
9602b6a1
AK
10308 emit_move_insn (base, save_bp);
10309 emit_move_insn (operands[0], save_sp);
ef44a6ff
UW
10310
10311 if (temp)
10312 emit_move_insn (s390_back_chain_rtx (), temp);
10313
c41c1387 10314 emit_use (base);
9db1d521 10315 DONE;
10bbf137 10316})
9db1d521 10317
7bcebb25
AK
10318(define_expand "exception_receiver"
10319 [(const_int 0)]
10320 ""
10321{
10322 s390_set_has_landing_pad_p (true);
10323 DONE;
10324})
9db1d521
HP
10325
10326;
10327; nop instruction pattern(s).
10328;
10329
10330(define_insn "nop"
10331 [(const_int 0)]
10332 ""
d40c829f 10333 "lr\t0,0"
729e750f
WG
10334 [(set_attr "op_type" "RR")
10335 (set_attr "z10prop" "z10_fr_E1")])
9db1d521 10336
d277db6b
WG
10337(define_insn "nop1"
10338 [(const_int 1)]
10339 ""
10340 "lr\t1,1"
10341 [(set_attr "op_type" "RR")])
10342
f8af0e30
DV
10343;;- Undeletable nops (used for hotpatching)
10344
10345(define_insn "nop_2_byte"
10346 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_2_BYTE)]
10347 ""
10348 "nopr\t%%r7"
10349 [(set_attr "op_type" "RR")])
10350
10351(define_insn "nop_4_byte"
10352 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_4_BYTE)]
10353 ""
10354 "nop\t0"
10355 [(set_attr "op_type" "RX")])
10356
10357(define_insn "nop_6_byte"
10358 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_6_BYTE)]
10359 "TARGET_CPU_ZARCH"
10360 "brcl\t0, 0"
10361 [(set_attr "op_type" "RIL")])
10362
9db1d521
HP
10363
10364;
10365; Special literal pool access instruction pattern(s).
10366;
10367
416cf582
UW
10368(define_insn "*pool_entry"
10369 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
10370 UNSPECV_POOL_ENTRY)]
9db1d521 10371 ""
9db1d521 10372{
ef4bddc2 10373 machine_mode mode = GET_MODE (PATTERN (insn));
416cf582 10374 unsigned int align = GET_MODE_BITSIZE (mode);
faeb9bb6 10375 s390_output_pool_entry (operands[0], mode, align);
fd7643fb
UW
10376 return "";
10377}
b628bd8e 10378 [(set (attr "length")
416cf582 10379 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
b2ccb744 10380
9bb86f41
UW
10381(define_insn "pool_align"
10382 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
10383 UNSPECV_POOL_ALIGN)]
10384 ""
10385 ".align\t%0"
b628bd8e 10386 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
b2ccb744 10387
9bb86f41
UW
10388(define_insn "pool_section_start"
10389 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
10390 ""
b929b470
MK
10391{
10392 switch_to_section (targetm.asm_out.function_rodata_section
10393 (current_function_decl));
10394 return "";
10395}
b628bd8e 10396 [(set_attr "length" "0")])
b2ccb744 10397
9bb86f41
UW
10398(define_insn "pool_section_end"
10399 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
10400 ""
b929b470
MK
10401{
10402 switch_to_section (current_function_section ());
10403 return "";
10404}
b628bd8e 10405 [(set_attr "length" "0")])
b2ccb744 10406
5af2f3d3 10407(define_insn "main_base_31_small"
9e8327e3
UW
10408 [(set (match_operand 0 "register_operand" "=a")
10409 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
10410 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
10411 "basr\t%0,0"
10412 [(set_attr "op_type" "RR")
65b1d8ea
AK
10413 (set_attr "type" "la")
10414 (set_attr "z196prop" "z196_cracked")])
5af2f3d3
UW
10415
10416(define_insn "main_base_31_large"
9e8327e3
UW
10417 [(set (match_operand 0 "register_operand" "=a")
10418 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
5af2f3d3 10419 (set (pc) (label_ref (match_operand 2 "" "")))]
9e8327e3 10420 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3 10421 "bras\t%0,%2"
65b1d8ea
AK
10422 [(set_attr "op_type" "RI")
10423 (set_attr "z196prop" "z196_cracked")])
5af2f3d3
UW
10424
10425(define_insn "main_base_64"
9e8327e3
UW
10426 [(set (match_operand 0 "register_operand" "=a")
10427 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
10428 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
10429 "larl\t%0,%1"
10430 [(set_attr "op_type" "RIL")
9381e3f1 10431 (set_attr "type" "larl")
729e750f 10432 (set_attr "z10prop" "z10_fwd_A1")])
5af2f3d3
UW
10433
10434(define_insn "main_pool"
585539a1
UW
10435 [(set (match_operand 0 "register_operand" "=a")
10436 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
10437 "GET_MODE (operands[0]) == Pmode"
8d933e31
AS
10438{
10439 gcc_unreachable ();
10440}
9381e3f1 10441 [(set (attr "type")
d7f99b2c 10442 (if_then_else (match_test "TARGET_CPU_ZARCH")
ea77e738 10443 (const_string "larl") (const_string "la")))])
5af2f3d3 10444
aee4e0db 10445(define_insn "reload_base_31"
9e8327e3
UW
10446 [(set (match_operand 0 "register_operand" "=a")
10447 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
10448 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
d40c829f 10449 "basr\t%0,0\;la\t%0,%1-.(%0)"
b628bd8e 10450 [(set_attr "length" "6")
65b1d8ea
AK
10451 (set_attr "type" "la")
10452 (set_attr "z196prop" "z196_cracked")])
b2ccb744 10453
aee4e0db 10454(define_insn "reload_base_64"
9e8327e3
UW
10455 [(set (match_operand 0 "register_operand" "=a")
10456 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
10457 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
d40c829f 10458 "larl\t%0,%1"
aee4e0db 10459 [(set_attr "op_type" "RIL")
9381e3f1 10460 (set_attr "type" "larl")
729e750f 10461 (set_attr "z10prop" "z10_fwd_A1")])
aee4e0db 10462
aee4e0db 10463(define_insn "pool"
fd7643fb 10464 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
aee4e0db 10465 ""
8d933e31
AS
10466{
10467 gcc_unreachable ();
10468}
b628bd8e 10469 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
9db1d521 10470
4023fb28
UW
10471;;
10472;; Insns related to generating the function prologue and epilogue.
10473;;
10474
10475
10476(define_expand "prologue"
10477 [(use (const_int 0))]
10478 ""
10bbf137 10479 "s390_emit_prologue (); DONE;")
4023fb28
UW
10480
10481(define_expand "epilogue"
10482 [(use (const_int 1))]
10483 ""
ed9676cf
AK
10484 "s390_emit_epilogue (false); DONE;")
10485
10486(define_expand "sibcall_epilogue"
10487 [(use (const_int 0))]
10488 ""
10489 "s390_emit_epilogue (true); DONE;")
4023fb28 10490
177bc204
RS
10491;; A direct return instruction, without using an epilogue.
10492(define_insn "<code>"
10493 [(ANY_RETURN)]
10494 "s390_can_use_<code>_insn ()"
10495 "br\t%%r14"
10496 [(set_attr "op_type" "RR")
10497 (set_attr "type" "jsr")
10498 (set_attr "atype" "agen")])
10499
9e8327e3 10500(define_insn "*return"
4023fb28 10501 [(return)
9e8327e3
UW
10502 (use (match_operand 0 "register_operand" "a"))]
10503 "GET_MODE (operands[0]) == Pmode"
d40c829f 10504 "br\t%0"
4023fb28 10505 [(set_attr "op_type" "RR")
c7453384 10506 (set_attr "type" "jsr")
077dab3b 10507 (set_attr "atype" "agen")])
4023fb28 10508
4023fb28 10509
c7453384 10510;; Instruction definition to extend a 31-bit pointer into a 64-bit
839a4992 10511;; pointer. This is used for compatibility.
c7453384
EC
10512
10513(define_expand "ptr_extend"
10514 [(set (match_operand:DI 0 "register_operand" "=r")
10515 (match_operand:SI 1 "register_operand" "r"))]
9e8327e3 10516 "TARGET_64BIT"
c7453384 10517{
c7453384
EC
10518 emit_insn (gen_anddi3 (operands[0],
10519 gen_lowpart (DImode, operands[1]),
10520 GEN_INT (0x7fffffff)));
c7453384 10521 DONE;
10bbf137 10522})
4798630c
D
10523
10524;; Instruction definition to expand eh_return macro to support
10525;; swapping in special linkage return addresses.
10526
10527(define_expand "eh_return"
10528 [(use (match_operand 0 "register_operand" ""))]
10529 "TARGET_TPF"
10530{
10531 s390_emit_tpf_eh_return (operands[0]);
10532 DONE;
10533})
10534
7b8acc34
AK
10535;
10536; Stack Protector Patterns
10537;
10538
10539(define_expand "stack_protect_set"
10540 [(set (match_operand 0 "memory_operand" "")
10541 (match_operand 1 "memory_operand" ""))]
10542 ""
10543{
10544#ifdef TARGET_THREAD_SSP_OFFSET
10545 operands[1]
10546 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
10547 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
10548#endif
10549 if (TARGET_64BIT)
10550 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
10551 else
10552 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
10553
10554 DONE;
10555})
10556
10557(define_insn "stack_protect_set<mode>"
10558 [(set (match_operand:DSI 0 "memory_operand" "=Q")
10559 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
10560 ""
10561 "mvc\t%O0(%G0,%R0),%S1"
10562 [(set_attr "op_type" "SS")])
10563
10564(define_expand "stack_protect_test"
10565 [(set (reg:CC CC_REGNUM)
10566 (compare (match_operand 0 "memory_operand" "")
10567 (match_operand 1 "memory_operand" "")))
10568 (match_operand 2 "" "")]
10569 ""
10570{
f90b7a5a 10571 rtx cc_reg, test;
7b8acc34
AK
10572#ifdef TARGET_THREAD_SSP_OFFSET
10573 operands[1]
10574 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
10575 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
10576#endif
7b8acc34
AK
10577 if (TARGET_64BIT)
10578 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
10579 else
10580 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
10581
f90b7a5a
PB
10582 cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM);
10583 test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx);
10584 emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2]));
7b8acc34
AK
10585 DONE;
10586})
10587
10588(define_insn "stack_protect_test<mode>"
10589 [(set (reg:CCZ CC_REGNUM)
10590 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
10591 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
10592 ""
10593 "clc\t%O0(%G0,%R0),%S1"
10594 [(set_attr "op_type" "SS")])
12959abe
AK
10595
10596; This is used in s390_emit_prologue in order to prevent insns
10597; adjusting the stack pointer to be moved over insns writing stack
10598; slots using a copy of the stack pointer in a different register.
10599(define_insn "stack_tie"
10600 [(set (match_operand:BLK 0 "memory_operand" "+m")
10601 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
10602 ""
10603 ""
10604 [(set_attr "length" "0")])
963fc8d0
AK
10605
10606
82c6f58a
AK
10607(define_insn "stack_restore_from_fpr"
10608 [(set (reg:DI STACK_REGNUM)
10609 (match_operand:DI 0 "register_operand" "f"))
10610 (clobber (mem:BLK (scratch)))]
10611 "TARGET_Z10"
10612 "lgdr\t%%r15,%0"
10613 [(set_attr "op_type" "RRE")])
10614
963fc8d0
AK
10615;
10616; Data prefetch patterns
10617;
10618
10619(define_insn "prefetch"
3e4be43f
UW
10620 [(prefetch (match_operand 0 "address_operand" "ZT,X")
10621 (match_operand:SI 1 "const_int_operand" " n,n")
10622 (match_operand:SI 2 "const_int_operand" " n,n"))]
22d72dbc 10623 "TARGET_Z10"
963fc8d0 10624{
4fe6dea8
AK
10625 switch (which_alternative)
10626 {
10627 case 0:
4fe6dea8 10628 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
22d72dbc 10629 case 1:
4fe6dea8
AK
10630 if (larl_operand (operands[0], Pmode))
10631 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
a65593a4 10632 /* fallthrough */
4fe6dea8
AK
10633 default:
10634
10635 /* This might be reached for symbolic operands with an odd
10636 addend. We simply omit the prefetch for such rare cases. */
10637
10638 return "";
10639 }
9381e3f1 10640}
22d72dbc
AK
10641 [(set_attr "type" "load,larl")
10642 (set_attr "op_type" "RXY,RIL")
65b1d8ea
AK
10643 (set_attr "z10prop" "z10_super")
10644 (set_attr "z196prop" "z196_alone")])
07da44ab
AK
10645
10646
10647;
10648; Byte swap instructions
10649;
10650
511f5bb1
AK
10651; FIXME: There is also mvcin but we cannot use it since src and target
10652; may overlap.
07da44ab 10653(define_insn "bswap<mode>2"
3e4be43f
UW
10654 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,T")
10655 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,T,d")))]
677fbff4 10656 "TARGET_CPU_ZARCH"
07da44ab
AK
10657 "@
10658 lrv<g>r\t%0,%1
6f5a59d1
AK
10659 lrv<g>\t%0,%1
10660 strv<g>\t%1,%0"
10661 [(set_attr "type" "*,load,store")
10662 (set_attr "op_type" "RRE,RXY,RXY")
07da44ab 10663 (set_attr "z10prop" "z10_super")])
65b1d8ea 10664
511f5bb1 10665(define_insn "bswaphi2"
3e4be43f
UW
10666 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,T")
10667 (bswap:HI (match_operand:HI 1 "nonimmediate_operand" " d,T,d")))]
511f5bb1 10668 "TARGET_CPU_ZARCH"
6f5a59d1
AK
10669 "@
10670 #
10671 lrvh\t%0,%1
10672 strvh\t%1,%0"
10673 [(set_attr "type" "*,load,store")
10674 (set_attr "op_type" "RRE,RXY,RXY")
511f5bb1 10675 (set_attr "z10prop" "z10_super")])
65b1d8ea 10676
6f5a59d1
AK
10677(define_split
10678 [(set (match_operand:HI 0 "register_operand" "")
10679 (bswap:HI (match_operand:HI 1 "register_operand" "")))]
10680 "TARGET_CPU_ZARCH"
10681 [(set (match_dup 2) (bswap:SI (match_dup 3)))
9060e335 10682 (set (match_dup 2) (lshiftrt:SI (match_dup 2) (const_int 16)))]
6f5a59d1 10683{
9060e335 10684 operands[2] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
6f5a59d1
AK
10685 operands[3] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
10686})
10687
10688
65b1d8ea
AK
10689;
10690; Population count instruction
10691;
10692
10693; The S/390 popcount instruction counts the bits of op1 in 8 byte
10694; portions and stores the result in the corresponding bytes in op0.
10695(define_insn "*popcount<mode>"
10696 [(set (match_operand:INT 0 "register_operand" "=d")
10697 (unspec:INT [(match_operand:INT 1 "register_operand" "d")] UNSPEC_POPCNT))
10698 (clobber (reg:CC CC_REGNUM))]
10699 "TARGET_Z196"
10700 "popcnt\t%0,%1"
10701 [(set_attr "op_type" "RRE")])
10702
10703(define_expand "popcountdi2"
10704 [; popcnt op0, op1
10705 (parallel [(set (match_operand:DI 0 "register_operand" "")
10706 (unspec:DI [(match_operand:DI 1 "register_operand")]
10707 UNSPEC_POPCNT))
10708 (clobber (reg:CC CC_REGNUM))])
10709 ; sllg op2, op0, 32
10710 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 32)))
10711 ; agr op0, op2
10712 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10713 (clobber (reg:CC CC_REGNUM))])
10714 ; sllg op2, op0, 16
17465c6e 10715 (set (match_dup 2)
65b1d8ea
AK
10716 (ashift:DI (match_dup 0) (const_int 16)))
10717 ; agr op0, op2
10718 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10719 (clobber (reg:CC CC_REGNUM))])
10720 ; sllg op2, op0, 8
10721 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 8)))
10722 ; agr op0, op2
10723 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10724 (clobber (reg:CC CC_REGNUM))])
10725 ; srlg op0, op0, 56
10726 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (const_int 56)))]
10727 "TARGET_Z196 && TARGET_64BIT"
10728 "operands[2] = gen_reg_rtx (DImode);")
10729
10730(define_expand "popcountsi2"
10731 [; popcnt op0, op1
10732 (parallel [(set (match_operand:SI 0 "register_operand" "")
10733 (unspec:SI [(match_operand:SI 1 "register_operand")]
10734 UNSPEC_POPCNT))
10735 (clobber (reg:CC CC_REGNUM))])
10736 ; sllk op2, op0, 16
17465c6e 10737 (set (match_dup 2)
65b1d8ea
AK
10738 (ashift:SI (match_dup 0) (const_int 16)))
10739 ; ar op0, op2
10740 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10741 (clobber (reg:CC CC_REGNUM))])
10742 ; sllk op2, op0, 8
10743 (set (match_dup 2) (ashift:SI (match_dup 0) (const_int 8)))
10744 ; ar op0, op2
10745 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10746 (clobber (reg:CC CC_REGNUM))])
10747 ; srl op0, op0, 24
10748 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 24)))]
10749 "TARGET_Z196"
10750 "operands[2] = gen_reg_rtx (SImode);")
10751
10752(define_expand "popcounthi2"
10753 [; popcnt op0, op1
10754 (parallel [(set (match_operand:HI 0 "register_operand" "")
10755 (unspec:HI [(match_operand:HI 1 "register_operand")]
10756 UNSPEC_POPCNT))
10757 (clobber (reg:CC CC_REGNUM))])
10758 ; sllk op2, op0, 8
17465c6e 10759 (set (match_dup 2)
65b1d8ea
AK
10760 (ashift:SI (match_dup 0) (const_int 8)))
10761 ; ar op0, op2
10762 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10763 (clobber (reg:CC CC_REGNUM))])
10764 ; srl op0, op0, 8
10765 (set (match_dup 0) (lshiftrt:HI (match_dup 0) (const_int 8)))]
10766 "TARGET_Z196"
10767 "operands[2] = gen_reg_rtx (SImode);")
10768
10769(define_expand "popcountqi2"
10770 [; popcnt op0, op1
10771 (parallel [(set (match_operand:QI 0 "register_operand" "")
10772 (unspec:QI [(match_operand:QI 1 "register_operand")]
10773 UNSPEC_POPCNT))
10774 (clobber (reg:CC CC_REGNUM))])]
10775 "TARGET_Z196"
10776 "")
10777
10778;;
10779;;- Copy sign instructions
10780;;
10781
10782(define_insn "copysign<mode>3"
10783 [(set (match_operand:FP 0 "register_operand" "=f")
10784 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
10785 (match_operand:FP 2 "register_operand" "f")]
10786 UNSPEC_COPYSIGN))]
10787 "TARGET_Z196"
10788 "cpsdr\t%0,%2,%1"
10789 [(set_attr "op_type" "RRF")
10790 (set_attr "type" "fsimp<mode>")])
5a3fe9b6
AK
10791
10792
10793;;
10794;;- Transactional execution instructions
10795;;
10796
10797; This splitter helps combine to make use of CC directly when
10798; comparing the integer result of a tbegin builtin with a constant.
10799; The unspec is already removed by canonicalize_comparison. So this
10800; splitters only job is to turn the PARALLEL into separate insns
10801; again. Unfortunately this only works with the very first cc/int
10802; compare since combine is not able to deal with data flow across
10803; basic block boundaries.
10804
10805; It needs to be an insn pattern as well since combine does not apply
10806; the splitter directly. Combine would only use it if it actually
10807; would reduce the number of instructions.
10808(define_insn_and_split "*ccraw_to_int"
10809 [(set (pc)
10810 (if_then_else
10811 (match_operator 0 "s390_eqne_operator"
10812 [(reg:CCRAW CC_REGNUM)
10813 (match_operand 1 "const_int_operand" "")])
10814 (label_ref (match_operand 2 "" ""))
10815 (pc)))
10816 (set (match_operand:SI 3 "register_operand" "=d")
10817 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
10818 ""
10819 "#"
10820 ""
10821 [(set (match_dup 3)
10822 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))
10823 (set (pc)
10824 (if_then_else (match_op_dup 0 [(reg:CCRAW CC_REGNUM) (match_dup 1)])
10825 (label_ref (match_dup 2))
10826 (pc)))]
10827 "")
10828
10829; Non-constrained transaction begin
10830
10831(define_expand "tbegin"
ee163e72
AK
10832 [(match_operand:SI 0 "register_operand" "")
10833 (match_operand:BLK 1 "memory_operand" "")]
5a3fe9b6
AK
10834 "TARGET_HTM"
10835{
10836 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, true);
10837 DONE;
10838})
10839
10840(define_expand "tbegin_nofloat"
ee163e72
AK
10841 [(match_operand:SI 0 "register_operand" "")
10842 (match_operand:BLK 1 "memory_operand" "")]
5a3fe9b6
AK
10843 "TARGET_HTM"
10844{
10845 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, false);
10846 DONE;
10847})
10848
10849(define_expand "tbegin_retry"
ee163e72
AK
10850 [(match_operand:SI 0 "register_operand" "")
10851 (match_operand:BLK 1 "memory_operand" "")
10852 (match_operand:SI 2 "general_operand" "")]
5a3fe9b6
AK
10853 "TARGET_HTM"
10854{
10855 s390_expand_tbegin (operands[0], operands[1], operands[2], true);
10856 DONE;
10857})
10858
10859(define_expand "tbegin_retry_nofloat"
ee163e72
AK
10860 [(match_operand:SI 0 "register_operand" "")
10861 (match_operand:BLK 1 "memory_operand" "")
10862 (match_operand:SI 2 "general_operand" "")]
5a3fe9b6
AK
10863 "TARGET_HTM"
10864{
10865 s390_expand_tbegin (operands[0], operands[1], operands[2], false);
10866 DONE;
10867})
10868
c914ac45
AK
10869; Clobber VRs since they don't get restored
10870(define_insn "tbegin_1_z13"
10871 [(set (reg:CCRAW CC_REGNUM)
10872 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10873 UNSPECV_TBEGIN))
10874 (set (match_operand:BLK 1 "memory_operand" "=Q")
10875 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
10876 (clobber (reg:TI 16)) (clobber (reg:TI 38))
10877 (clobber (reg:TI 17)) (clobber (reg:TI 39))
10878 (clobber (reg:TI 18)) (clobber (reg:TI 40))
10879 (clobber (reg:TI 19)) (clobber (reg:TI 41))
10880 (clobber (reg:TI 20)) (clobber (reg:TI 42))
10881 (clobber (reg:TI 21)) (clobber (reg:TI 43))
10882 (clobber (reg:TI 22)) (clobber (reg:TI 44))
10883 (clobber (reg:TI 23)) (clobber (reg:TI 45))
10884 (clobber (reg:TI 24)) (clobber (reg:TI 46))
10885 (clobber (reg:TI 25)) (clobber (reg:TI 47))
10886 (clobber (reg:TI 26)) (clobber (reg:TI 48))
10887 (clobber (reg:TI 27)) (clobber (reg:TI 49))
10888 (clobber (reg:TI 28)) (clobber (reg:TI 50))
10889 (clobber (reg:TI 29)) (clobber (reg:TI 51))
10890 (clobber (reg:TI 30)) (clobber (reg:TI 52))
10891 (clobber (reg:TI 31)) (clobber (reg:TI 53))]
10892; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
10893; not supposed to be used for immediates (see genpreds.c).
10894 "TARGET_VX && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10895 "tbegin\t%1,%x0"
10896 [(set_attr "op_type" "SIL")])
10897
5a3fe9b6
AK
10898(define_insn "tbegin_1"
10899 [(set (reg:CCRAW CC_REGNUM)
2561451d 10900 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
5a3fe9b6 10901 UNSPECV_TBEGIN))
2561451d
AK
10902 (set (match_operand:BLK 1 "memory_operand" "=Q")
10903 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
5a3fe9b6
AK
10904 (clobber (reg:DF 16))
10905 (clobber (reg:DF 17))
10906 (clobber (reg:DF 18))
10907 (clobber (reg:DF 19))
10908 (clobber (reg:DF 20))
10909 (clobber (reg:DF 21))
10910 (clobber (reg:DF 22))
10911 (clobber (reg:DF 23))
10912 (clobber (reg:DF 24))
10913 (clobber (reg:DF 25))
10914 (clobber (reg:DF 26))
10915 (clobber (reg:DF 27))
10916 (clobber (reg:DF 28))
10917 (clobber (reg:DF 29))
10918 (clobber (reg:DF 30))
10919 (clobber (reg:DF 31))]
10920; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
10921; not supposed to be used for immediates (see genpreds.c).
2561451d
AK
10922 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10923 "tbegin\t%1,%x0"
5a3fe9b6
AK
10924 [(set_attr "op_type" "SIL")])
10925
10926; Same as above but without the FPR clobbers
10927(define_insn "tbegin_nofloat_1"
10928 [(set (reg:CCRAW CC_REGNUM)
2561451d
AK
10929 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10930 UNSPECV_TBEGIN))
10931 (set (match_operand:BLK 1 "memory_operand" "=Q")
10932 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))]
10933 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10934 "tbegin\t%1,%x0"
5a3fe9b6
AK
10935 [(set_attr "op_type" "SIL")])
10936
10937
10938; Constrained transaction begin
10939
10940(define_expand "tbeginc"
10941 [(set (reg:CCRAW CC_REGNUM)
10942 (unspec_volatile:CCRAW [(const_int TBEGINC_MASK)]
10943 UNSPECV_TBEGINC))]
10944 "TARGET_HTM"
10945 "")
10946
10947(define_insn "*tbeginc_1"
10948 [(set (reg:CCRAW CC_REGNUM)
10949 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" " D")]
10950 UNSPECV_TBEGINC))]
10951 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10952 "tbeginc\t0,%x0"
10953 [(set_attr "op_type" "SIL")])
10954
10955; Transaction end
10956
10957(define_expand "tend"
10958 [(set (reg:CCRAW CC_REGNUM)
10959 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))
ee163e72 10960 (set (match_operand:SI 0 "register_operand" "")
5a3fe9b6
AK
10961 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
10962 "TARGET_HTM"
10963 "")
10964
10965(define_insn "*tend_1"
10966 [(set (reg:CCRAW CC_REGNUM)
10967 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))]
10968 "TARGET_HTM"
10969 "tend"
10970 [(set_attr "op_type" "S")])
10971
10972; Transaction abort
10973
10974(define_expand "tabort"
eae48192 10975 [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "")]
5a3fe9b6
AK
10976 UNSPECV_TABORT)]
10977 "TARGET_HTM && operands != NULL"
10978{
10979 if (CONST_INT_P (operands[0])
10980 && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 255)
10981 {
10982 error ("Invalid transaction abort code: " HOST_WIDE_INT_PRINT_DEC
10983 ". Values in range 0 through 255 are reserved.",
10984 INTVAL (operands[0]));
10985 FAIL;
10986 }
10987})
10988
10989(define_insn "*tabort_1"
eae48192 10990 [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "aJ")]
5a3fe9b6
AK
10991 UNSPECV_TABORT)]
10992 "TARGET_HTM && operands != NULL"
10993 "tabort\t%Y0"
10994 [(set_attr "op_type" "S")])
10995
eae48192
AK
10996(define_insn "*tabort_1_plus"
10997 [(unspec_volatile [(plus:SI (match_operand:SI 0 "register_operand" "a")
10998 (match_operand:SI 1 "const_int_operand" "J"))]
10999 UNSPECV_TABORT)]
11000 "TARGET_HTM && operands != NULL
11001 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'J', \"J\")"
11002 "tabort\t%1(%0)"
11003 [(set_attr "op_type" "S")])
11004
5a3fe9b6
AK
11005; Transaction extract nesting depth
11006
11007(define_insn "etnd"
11008 [(set (match_operand:SI 0 "register_operand" "=d")
11009 (unspec_volatile:SI [(const_int 0)] UNSPECV_ETND))]
11010 "TARGET_HTM"
11011 "etnd\t%0"
11012 [(set_attr "op_type" "RRE")])
11013
11014; Non-transactional store
11015
11016(define_insn "ntstg"
3e4be43f 11017 [(set (match_operand:DI 0 "memory_operand" "=T")
5a3fe9b6
AK
11018 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "d")]
11019 UNSPECV_NTSTG))]
11020 "TARGET_HTM"
11021 "ntstg\t%1,%0"
11022 [(set_attr "op_type" "RXY")])
11023
11024; Transaction perform processor assist
11025
11026(define_expand "tx_assist"
2561451d
AK
11027 [(unspec_volatile [(match_operand:SI 0 "register_operand" "")
11028 (reg:SI GPR0_REGNUM)
5a3fe9b6
AK
11029 (const_int 1)]
11030 UNSPECV_PPA)]
11031 "TARGET_HTM"
2561451d 11032 "")
5a3fe9b6
AK
11033
11034(define_insn "*ppa"
11035 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")
11036 (match_operand:SI 1 "register_operand" "d")
11037 (match_operand 2 "const_int_operand" "I")]
11038 UNSPECV_PPA)]
11039 "TARGET_HTM && INTVAL (operands[2]) < 16"
2561451d 11040 "ppa\t%0,%1,%2"
5a3fe9b6 11041 [(set_attr "op_type" "RRF")])
004f64e1
AK
11042
11043
11044; Set and get floating point control register
11045
3af82a61 11046(define_insn "sfpc"
004f64e1
AK
11047 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")]
11048 UNSPECV_SFPC)]
11049 "TARGET_HARD_FLOAT"
11050 "sfpc\t%0")
11051
3af82a61 11052(define_insn "efpc"
004f64e1
AK
11053 [(set (match_operand:SI 0 "register_operand" "=d")
11054 (unspec_volatile:SI [(const_int 0)] UNSPECV_EFPC))]
11055 "TARGET_HARD_FLOAT"
11056 "efpc\t%0")
3af82a61
AK
11057
11058
11059; Load count to block boundary
11060
11061(define_insn "lcbb"
11062 [(set (match_operand:SI 0 "register_operand" "=d")
3e4be43f 11063 (unspec:SI [(match_operand 1 "address_operand" "ZR")
3af82a61
AK
11064 (match_operand:SI 2 "immediate_operand" "C")] UNSPEC_LCBB))
11065 (clobber (reg:CC CC_REGNUM))]
11066 "TARGET_Z13"
9a36359e 11067 "lcbb\t%0,%a1,%b2"
3af82a61 11068 [(set_attr "op_type" "VRX")])
4cb4721f
MK
11069
11070; Handle -fsplit-stack.
11071
11072(define_expand "split_stack_prologue"
11073 [(const_int 0)]
11074 ""
11075{
11076 s390_expand_split_stack_prologue ();
11077 DONE;
11078})
11079
11080;; If there are operand 0 bytes available on the stack, jump to
11081;; operand 1.
11082
11083(define_expand "split_stack_space_check"
11084 [(set (pc) (if_then_else
11085 (ltu (minus (reg 15)
11086 (match_operand 0 "register_operand"))
11087 (unspec [(const_int 0)] UNSPEC_STACK_CHECK))
11088 (label_ref (match_operand 1))
11089 (pc)))]
11090 ""
11091{
11092 /* Offset from thread pointer to __private_ss. */
11093 int psso = TARGET_64BIT ? 0x38 : 0x20;
11094 rtx tp = s390_get_thread_pointer ();
11095 rtx guard = gen_rtx_MEM (Pmode, plus_constant (Pmode, tp, psso));
11096 rtx reg = gen_reg_rtx (Pmode);
11097 rtx cc;
11098 if (TARGET_64BIT)
11099 emit_insn (gen_subdi3 (reg, stack_pointer_rtx, operands[0]));
11100 else
11101 emit_insn (gen_subsi3 (reg, stack_pointer_rtx, operands[0]));
11102 cc = s390_emit_compare (GT, reg, guard);
11103 s390_emit_jump (operands[1], cc);
11104
11105 DONE;
11106})
11107
11108;; __morestack parameter block for split stack prologue. Parameters are:
11109;; parameter block label, label to be called by __morestack, frame size,
11110;; stack parameter size.
11111
11112(define_insn "split_stack_data"
11113 [(unspec_volatile [(match_operand 0 "" "X")
11114 (match_operand 1 "" "X")
11115 (match_operand 2 "const_int_operand" "X")
11116 (match_operand 3 "const_int_operand" "X")]
11117 UNSPECV_SPLIT_STACK_DATA)]
11118 "TARGET_CPU_ZARCH"
11119{
11120 switch_to_section (targetm.asm_out.function_rodata_section
11121 (current_function_decl));
11122
11123 if (TARGET_64BIT)
11124 output_asm_insn (".align\t8", operands);
11125 else
11126 output_asm_insn (".align\t4", operands);
11127 (*targetm.asm_out.internal_label) (asm_out_file, "L",
11128 CODE_LABEL_NUMBER (operands[0]));
11129 if (TARGET_64BIT)
11130 {
11131 output_asm_insn (".quad\t%2", operands);
11132 output_asm_insn (".quad\t%3", operands);
11133 output_asm_insn (".quad\t%1-%0", operands);
11134 }
11135 else
11136 {
11137 output_asm_insn (".long\t%2", operands);
11138 output_asm_insn (".long\t%3", operands);
11139 output_asm_insn (".long\t%1-%0", operands);
11140 }
11141
11142 switch_to_section (current_function_section ());
11143 return "";
11144}
11145 [(set_attr "length" "0")])
11146
11147
11148;; A jg with minimal fuss for use in split stack prologue.
11149
11150(define_expand "split_stack_call"
11151 [(match_operand 0 "bras_sym_operand" "X")
11152 (match_operand 1 "" "")]
11153 "TARGET_CPU_ZARCH"
11154{
11155 if (TARGET_64BIT)
11156 emit_jump_insn (gen_split_stack_call_di (operands[0], operands[1]));
11157 else
11158 emit_jump_insn (gen_split_stack_call_si (operands[0], operands[1]));
11159 DONE;
11160})
11161
11162(define_insn "split_stack_call_<mode>"
11163 [(set (pc) (label_ref (match_operand 1 "" "")))
11164 (set (reg:P 1) (unspec_volatile [(match_operand 0 "bras_sym_operand" "X")
11165 (reg:P 1)]
11166 UNSPECV_SPLIT_STACK_CALL))]
11167 "TARGET_CPU_ZARCH"
11168 "jg\t%0"
11169 [(set_attr "op_type" "RIL")
11170 (set_attr "type" "branch")])
11171
11172;; Also a conditional one.
11173
11174(define_expand "split_stack_cond_call"
11175 [(match_operand 0 "bras_sym_operand" "X")
11176 (match_operand 1 "" "")
11177 (match_operand 2 "" "")]
11178 "TARGET_CPU_ZARCH"
11179{
11180 if (TARGET_64BIT)
11181 emit_jump_insn (gen_split_stack_cond_call_di (operands[0], operands[1], operands[2]));
11182 else
11183 emit_jump_insn (gen_split_stack_cond_call_si (operands[0], operands[1], operands[2]));
11184 DONE;
11185})
11186
11187(define_insn "split_stack_cond_call_<mode>"
11188 [(set (pc)
11189 (if_then_else
11190 (match_operand 1 "" "")
11191 (label_ref (match_operand 2 "" ""))
11192 (pc)))
11193 (set (reg:P 1) (unspec_volatile [(match_operand 0 "bras_sym_operand" "X")
11194 (reg:P 1)]
11195 UNSPECV_SPLIT_STACK_CALL))]
11196 "TARGET_CPU_ZARCH"
11197 "jg%C1\t%0"
11198 [(set_attr "op_type" "RIL")
11199 (set_attr "type" "branch")])