]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/s390/s390.md
PR c++/80084 - wrong C++17 decomposition by reference of parameter.
[thirdparty/gcc.git] / gcc / config / s390 / s390.md
CommitLineData
9db1d521 1;;- Machine description for GNU compiler -- S/390 / zSeries version.
cbe34bb5 2;; Copyright (C) 1999-2017 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
539405d5
AK
283
284 UNSPECV_OSC_BREAK
fd3cd001
UW
285 ])
286
ae156f85
AS
287;;
288;; Registers
289;;
290
35dd9a0e
AK
291; Registers with special meaning
292
ae156f85
AS
293(define_constants
294 [
295 ; Sibling call register.
296 (SIBCALL_REGNUM 1)
297 ; Literal pool base register.
298 (BASE_REGNUM 13)
299 ; Return address register.
300 (RETURN_REGNUM 14)
82c6f58a
AK
301 ; Stack pointer register.
302 (STACK_REGNUM 15)
ae156f85
AS
303 ; Condition code register.
304 (CC_REGNUM 33)
f4aa3848 305 ; Thread local storage pointer register.
ae156f85
AS
306 (TP_REGNUM 36)
307 ])
308
35dd9a0e
AK
309; Hardware register names
310
311(define_constants
312 [
313 ; General purpose registers
314 (GPR0_REGNUM 0)
af344a30 315 (GPR1_REGNUM 1)
82379bdf
AK
316 (GPR2_REGNUM 2)
317 (GPR6_REGNUM 6)
35dd9a0e
AK
318 ; Floating point registers.
319 (FPR0_REGNUM 16)
2cf4c39e
AK
320 (FPR1_REGNUM 20)
321 (FPR2_REGNUM 17)
322 (FPR3_REGNUM 21)
323 (FPR4_REGNUM 18)
324 (FPR5_REGNUM 22)
325 (FPR6_REGNUM 19)
326 (FPR7_REGNUM 23)
327 (FPR8_REGNUM 24)
328 (FPR9_REGNUM 28)
329 (FPR10_REGNUM 25)
330 (FPR11_REGNUM 29)
331 (FPR12_REGNUM 26)
332 (FPR13_REGNUM 30)
333 (FPR14_REGNUM 27)
334 (FPR15_REGNUM 31)
085261c8
AK
335 (VR0_REGNUM 16)
336 (VR16_REGNUM 38)
337 (VR23_REGNUM 45)
338 (VR24_REGNUM 46)
339 (VR31_REGNUM 53)
35dd9a0e
AK
340 ])
341
ae8e301e
AK
342; Rounding modes for binary floating point numbers
343(define_constants
344 [(BFP_RND_CURRENT 0)
345 (BFP_RND_NEAREST_TIE_AWAY_FROM_0 1)
346 (BFP_RND_PREP_FOR_SHORT_PREC 3)
347 (BFP_RND_NEAREST_TIE_TO_EVEN 4)
348 (BFP_RND_TOWARD_0 5)
349 (BFP_RND_TOWARD_INF 6)
350 (BFP_RND_TOWARD_MINF 7)])
351
352; Rounding modes for decimal floating point numbers
353; 1-7 were introduced with the floating point extension facility
354; available with z196
355; With these rounding modes (1-7) a quantum exception might occur
356; which is suppressed for the other modes.
357(define_constants
358 [(DFP_RND_CURRENT 0)
359 (DFP_RND_NEAREST_TIE_AWAY_FROM_0_QUANTEXC 1)
360 (DFP_RND_CURRENT_QUANTEXC 2)
361 (DFP_RND_PREP_FOR_SHORT_PREC_QUANTEXC 3)
362 (DFP_RND_NEAREST_TIE_TO_EVEN_QUANTEXC 4)
363 (DFP_RND_TOWARD_0_QUANTEXC 5)
364 (DFP_RND_TOWARD_INF_QUANTEXC 6)
365 (DFP_RND_TOWARD_MINF_QUANTEXC 7)
366 (DFP_RND_NEAREST_TIE_TO_EVEN 8)
367 (DFP_RND_TOWARD_0 9)
368 (DFP_RND_TOWARD_INF 10)
369 (DFP_RND_TOWARD_MINF 11)
370 (DFP_RND_NEAREST_TIE_AWAY_FROM_0 12)
371 (DFP_RND_NEAREST_TIE_TO_0 13)
372 (DFP_RND_AWAY_FROM_0 14)
373 (DFP_RND_PREP_FOR_SHORT_PREC 15)])
374
35dd9a0e
AK
375;;
376;; PFPO GPR0 argument format
377;;
378
379(define_constants
380 [
381 ; PFPO operation type
382 (PFPO_CONVERT 0x1000000)
383 ; PFPO operand types
384 (PFPO_OP_TYPE_SF 0x5)
385 (PFPO_OP_TYPE_DF 0x6)
386 (PFPO_OP_TYPE_TF 0x7)
387 (PFPO_OP_TYPE_SD 0x8)
388 (PFPO_OP_TYPE_DD 0x9)
389 (PFPO_OP_TYPE_TD 0xa)
390 ; Bitposition of operand types
391 (PFPO_OP0_TYPE_SHIFT 16)
392 (PFPO_OP1_TYPE_SHIFT 8)
393 ])
394
5a3fe9b6
AK
395; Immediate operands for tbegin and tbeginc
396(define_constants [(TBEGIN_MASK 65292)]) ; 0xff0c
397(define_constants [(TBEGINC_MASK 65288)]) ; 0xff08
fd3cd001 398
29a74354
UW
399;; Instruction operand type as used in the Principles of Operation.
400;; Used to determine defaults for length and other attribute values.
1fec52be 401
29a74354 402(define_attr "op_type"
62d3f261 403 "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 404 (const_string "NN"))
9db1d521 405
29a74354 406;; Instruction type attribute used for scheduling.
9db1d521 407
077dab3b 408(define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
e0374221 409 cs,vs,store,sem,idiv,
ed0e512a 410 imulhi,imulsi,imuldi,
2cdece44 411 branch,jsr,fsimptf,fsimpdf,fsimpsf,fhex,
f61a2c7d
AK
412 floadtf,floaddf,floadsf,fstoredf,fstoresf,
413 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
9381e3f1 414 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
65b1d8ea 415 fmadddf,fmaddsf,
9381e3f1
WG
416 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
417 itoftf, itofdf, itofsf, itofdd, itoftd,
418 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
419 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
420 ftoidfp, other"
29a74354
UW
421 (cond [(eq_attr "op_type" "NN") (const_string "other")
422 (eq_attr "op_type" "SS") (const_string "cs")]
423 (const_string "integer")))
9db1d521 424
29a74354
UW
425;; Another attribute used for scheduling purposes:
426;; agen: Instruction uses the address generation unit
427;; reg: Instruction does not use the agen unit
077dab3b
HP
428
429(define_attr "atype" "agen,reg"
62d3f261 430 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF")
0101708c
AS
431 (const_string "reg")
432 (const_string "agen")))
9db1d521 433
9381e3f1
WG
434;; Properties concerning Z10 execution grouping and value forwarding.
435;; z10_super: instruction is superscalar.
436;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
437;; z10_fwd: The instruction reads the value of an operand and stores it into a
438;; target register. It can forward this value to a second instruction that reads
439;; the same register if that second instruction is issued in the same group.
440;; z10_rec: The instruction is in the T pipeline and reads a register. If the
441;; instruction in the S pipe writes to the register, then the T instruction
442;; can immediately read the new value.
443;; z10_fr: union of Z10_fwd and z10_rec.
444;; z10_c: second operand of instruction is a register and read with complemented bits.
9381e3f1
WG
445;;
446;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
447
448
449(define_attr "z10prop" "none,
450 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
451 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
452 z10_rec,
453 z10_fr, z10_fr_A3, z10_fr_E1,
e3cba5e5 454 z10_c"
9381e3f1
WG
455 (const_string "none"))
456
65b1d8ea
AK
457;; Properties concerning Z196 decoding
458;; z196_alone: must group alone
459;; z196_end: ends a group
460;; z196_cracked: instruction is cracked or expanded
461(define_attr "z196prop" "none,
462 z196_alone, z196_ends,
463 z196_cracked"
464 (const_string "none"))
9381e3f1 465
a9cc3f58 466(define_attr "mnemonic" "bcr_flush,unknown" (const_string "unknown"))
22ac2c2f 467
9db1d521
HP
468;; Length in bytes.
469
470(define_attr "length" ""
62d3f261
AK
471 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
472 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF") (const_int 4)]
b628bd8e 473 (const_int 6)))
9db1d521 474
29a74354
UW
475
476;; Processor type. This attribute must exactly match the processor_type
477;; enumeration in s390.h. The current machine description does not
478;; distinguish between g5 and g6, but there are differences between the two
479;; CPUs could in theory be modeled.
480
55ac540c 481(define_attr "cpu" "g5,g6,z900,z990,z9_109,z9_ec,z10,z196,zEC12,z13"
90c6fd8a 482 (const (symbol_ref "s390_tune_attr")))
29a74354 483
b5e0425c 484(define_attr "cpu_facility"
bf749919 485 "standard,ieee,zarch,cpu_zarch,longdisp,extimm,dfp,z10,z196,zEC12,vec,z13"
3af8e996
AK
486 (const_string "standard"))
487
488(define_attr "enabled" ""
489 (cond [(eq_attr "cpu_facility" "standard")
490 (const_int 1)
491
492 (and (eq_attr "cpu_facility" "ieee")
d7f99b2c 493 (match_test "TARGET_CPU_IEEE_FLOAT"))
3af8e996
AK
494 (const_int 1)
495
496 (and (eq_attr "cpu_facility" "zarch")
d7f99b2c 497 (match_test "TARGET_ZARCH"))
3af8e996
AK
498 (const_int 1)
499
500 (and (eq_attr "cpu_facility" "longdisp")
d7f99b2c 501 (match_test "TARGET_LONG_DISPLACEMENT"))
3af8e996
AK
502 (const_int 1)
503
504 (and (eq_attr "cpu_facility" "extimm")
d7f99b2c 505 (match_test "TARGET_EXTIMM"))
3af8e996
AK
506 (const_int 1)
507
508 (and (eq_attr "cpu_facility" "dfp")
d7f99b2c 509 (match_test "TARGET_DFP"))
93538e8e
AK
510 (const_int 1)
511
b5e0425c
AK
512 (and (eq_attr "cpu_facility" "cpu_zarch")
513 (match_test "TARGET_CPU_ZARCH"))
514 (const_int 1)
515
93538e8e 516 (and (eq_attr "cpu_facility" "z10")
d7f99b2c 517 (match_test "TARGET_Z10"))
65b1d8ea
AK
518 (const_int 1)
519
520 (and (eq_attr "cpu_facility" "z196")
d7f99b2c 521 (match_test "TARGET_Z196"))
22ac2c2f
AK
522 (const_int 1)
523
524 (and (eq_attr "cpu_facility" "zEC12")
525 (match_test "TARGET_ZEC12"))
55ac540c
AK
526 (const_int 1)
527
528 (and (eq_attr "cpu_facility" "vec")
529 (match_test "TARGET_VX"))
bf749919
DV
530 (const_int 1)
531
532 (and (eq_attr "cpu_facility" "z13")
533 (match_test "TARGET_Z13"))
534 (const_int 1)
535 ]
3af8e996
AK
536 (const_int 0)))
537
29a74354
UW
538;; Pipeline description for z900. For lack of anything better,
539;; this description is also used for the g5 and g6.
540(include "2064.md")
541
3443392a 542;; Pipeline description for z990, z9-109 and z9-ec.
29a74354
UW
543(include "2084.md")
544
9381e3f1
WG
545;; Pipeline description for z10
546(include "2097.md")
547
65b1d8ea
AK
548;; Pipeline description for z196
549(include "2817.md")
550
22ac2c2f
AK
551;; Pipeline description for zEC12
552(include "2827.md")
553
23902021
AK
554;; Pipeline description for z13
555(include "2964.md")
556
0bfc3f69
AS
557;; Predicates
558(include "predicates.md")
559
cd8dc1f9
WG
560;; Constraint definitions
561(include "constraints.md")
562
a8ba31f2
EC
563;; Other includes
564(include "tpf.md")
f52c81dd 565
3abcb3a7 566;; Iterators
f52c81dd 567
085261c8
AK
568(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])
569
3abcb3a7 570;; These mode iterators allow floating point patterns to be generated from the
f5905b37 571;; same template.
f4aa3848 572(define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
0387c142 573 (SD "TARGET_HARD_DFP")])
3abcb3a7
HPN
574(define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
575(define_mode_iterator BFP [TF DF SF])
576(define_mode_iterator DFP [TD DD])
577(define_mode_iterator DFP_ALL [TD DD SD])
578(define_mode_iterator DSF [DF SF])
579(define_mode_iterator SD_SF [SF SD])
580(define_mode_iterator DD_DF [DF DD])
581(define_mode_iterator TD_TF [TF TD])
582
3abcb3a7 583;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
9db2f16d 584;; from the same template.
9602b6a1 585(define_mode_iterator GPR [(DI "TARGET_ZARCH") SI])
78ce265b 586(define_mode_iterator DGPR [(TI "TARGET_ZARCH") DI SI])
3abcb3a7 587(define_mode_iterator DSI [DI SI])
78ce265b 588(define_mode_iterator TDI [TI DI])
9db2f16d 589
3abcb3a7 590;; These mode iterators allow :P to be used for patterns that operate on
9db2f16d 591;; pointer-sized quantities. Exactly one of the two alternatives will match.
3abcb3a7 592(define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
9db2f16d 593
78ce265b
RH
594;; These macros refer to the actual word_mode of the configuration.
595;; This is equal to Pmode except on 31-bit machines in zarch mode.
9602b6a1
AK
596(define_mode_iterator DW [(TI "TARGET_ZARCH") (DI "!TARGET_ZARCH")])
597(define_mode_iterator W [(DI "TARGET_ZARCH") (SI "!TARGET_ZARCH")])
598
6e0d70c9
AK
599;; Used by the umul pattern to express modes having half the size.
600(define_mode_attr DWH [(TI "DI") (DI "SI")])
601(define_mode_attr dwh [(TI "di") (DI "si")])
602
3abcb3a7 603;; This mode iterator allows the QI and HI patterns to be defined from
f52c81dd 604;; the same template.
3abcb3a7 605(define_mode_iterator HQI [HI QI])
f52c81dd 606
3abcb3a7 607;; This mode iterator allows the integer patterns to be defined from the
342cf42b 608;; same template.
9602b6a1 609(define_mode_iterator INT [(DI "TARGET_ZARCH") SI HI QI])
78ce265b 610(define_mode_iterator DINT [(TI "TARGET_ZARCH") DI SI HI QI])
64c744b9 611(define_mode_iterator SINT [SI HI QI])
342cf42b 612
3abcb3a7 613;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
f337b930 614;; the same template.
3abcb3a7 615(define_code_iterator SHIFT [ashift lshiftrt])
f337b930 616
d12a76f3 617;; This iterator allows r[ox]sbg to be defined with the same template
571e408a
RH
618(define_code_iterator IXOR [ior xor])
619
d12a76f3
AK
620;; This iterator is used to expand the patterns for the nearest
621;; integer functions.
622(define_int_iterator FPINT [UNSPEC_FPINT_FLOOR UNSPEC_FPINT_BTRUNC
623 UNSPEC_FPINT_ROUND UNSPEC_FPINT_CEIL
624 UNSPEC_FPINT_NEARBYINT])
625(define_int_attr fpint_name [(UNSPEC_FPINT_FLOOR "floor")
626 (UNSPEC_FPINT_BTRUNC "btrunc")
627 (UNSPEC_FPINT_ROUND "round")
628 (UNSPEC_FPINT_CEIL "ceil")
629 (UNSPEC_FPINT_NEARBYINT "nearbyint")])
630(define_int_attr fpint_roundingmode [(UNSPEC_FPINT_FLOOR "7")
631 (UNSPEC_FPINT_BTRUNC "5")
632 (UNSPEC_FPINT_ROUND "1")
633 (UNSPEC_FPINT_CEIL "6")
634 (UNSPEC_FPINT_NEARBYINT "0")])
635
3abcb3a7
HPN
636;; This iterator and attribute allow to combine most atomic operations.
637(define_code_iterator ATOMIC [and ior xor plus minus mult])
65b1d8ea 638(define_code_iterator ATOMIC_Z196 [and ior xor plus])
cf5b43b0 639(define_code_attr atomic [(and "and") (ior "or") (xor "xor")
45d18331 640 (plus "add") (minus "sub") (mult "nand")])
65b1d8ea 641(define_code_attr noxa [(and "n") (ior "o") (xor "x") (plus "a")])
45d18331 642
f4aa3848 643;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
609e7e80
AK
644;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
645(define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
f337b930 646
f4aa3848
AK
647;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
648;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
609e7e80
AK
649;; SDmode.
650(define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
f5905b37 651
609e7e80 652;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
f61a2c7d
AK
653;; Likewise for "<RXe>".
654(define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
655(define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
656
609e7e80 657;; The decimal floating point variants of add, sub, div and mul support 3
3abcb3a7 658;; fp register operands. The following attributes allow to merge the bfp and
609e7e80
AK
659;; dfp variants in a single insn definition.
660
62d3f261
AK
661;; These mode attributes are supposed to be used in the `enabled' insn
662;; attribute to disable certain alternatives for certain modes.
663(define_mode_attr nBFP [(TF "0") (DF "0") (SF "0") (TD "*") (DD "*") (DD "*")])
664(define_mode_attr nDFP [(TF "*") (DF "*") (SF "*") (TD "0") (DD "0") (DD "0")])
665(define_mode_attr DSF [(TF "0") (DF "*") (SF "*") (TD "0") (DD "0") (SD "0")])
666(define_mode_attr DFDI [(TF "0") (DF "*") (SF "0")
667 (TD "0") (DD "0") (DD "0")
668 (TI "0") (DI "*") (SI "0")])
f5905b37 669
85dae55a
AK
670;; This attribute is used in the operand constraint list
671;; for instructions dealing with the sign bit of 32 or 64bit fp values.
672;; TFmode values are represented by a fp register pair. Since the
673;; sign bit instructions only handle single source and target fp registers
674;; these instructions can only be used for TFmode values if the source and
675;; target operand uses the same fp register.
676(define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
677
3abcb3a7 678;; This attribute adds b for bfp instructions and t for dfp instructions and is used
609e7e80
AK
679;; within instruction mnemonics.
680(define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
681
0387c142
WG
682;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
683;; modes and to an empty string for bfp modes.
684(define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
685
1b48c8cc
AS
686;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
687;; and "0" in SImode. This allows to combine instructions of which the 31bit
688;; version only operates on one register.
689(define_mode_attr d0 [(DI "d") (SI "0")])
690
691;; In combination with d0 this allows to combine instructions of which the 31bit
692;; version only operates on one register. The DImode version needs an additional
693;; register for the assembler output.
694(define_mode_attr 1 [(DI "%1,") (SI "")])
9381e3f1
WG
695
696;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
f337b930
AS
697;; 'ashift' and "srdl" in 'lshiftrt'.
698(define_code_attr lr [(ashift "l") (lshiftrt "r")])
699
700;; In SHIFT templates, this attribute holds the correct standard name for the
9381e3f1 701;; pattern itself and the corresponding function calls.
f337b930 702(define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
9a91a21f
AS
703
704;; This attribute handles differences in the instruction 'type' and will result
705;; in "RRE" for DImode and "RR" for SImode.
706(define_mode_attr E [(DI "E") (SI "")])
707
3298c037
AK
708;; This attribute handles differences in the instruction 'type' and makes RX<Y>
709;; to result in "RXY" for DImode and "RX" for SImode.
710(define_mode_attr Y [(DI "Y") (SI "")])
711
8006eaa6
AS
712;; This attribute handles differences in the instruction 'type' and will result
713;; in "RSE" for TImode and "RS" for DImode.
714(define_mode_attr TE [(TI "E") (DI "")])
715
9a91a21f
AS
716;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
717;; and "lcr" in SImode.
718(define_mode_attr g [(DI "g") (SI "")])
f52c81dd 719
3298c037
AK
720;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
721;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
722;; were enhanced with long displacements whereas 31bit instructions got a ..y
723;; variant for long displacements.
724(define_mode_attr y [(DI "g") (SI "y")])
725
9602b6a1 726;; In DW templates, a string like "cds<g>" will expand to "cdsg" in TImode
8006eaa6
AS
727;; and "cds" in DImode.
728(define_mode_attr tg [(TI "g") (DI "")])
729
78ce265b
RH
730;; In TDI templates, a string like "c<d>sg".
731(define_mode_attr td [(TI "d") (DI "")])
732
2f8f8434
AS
733;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
734;; and "cfdbr" in SImode.
735(define_mode_attr gf [(DI "g") (SI "f")])
736
65b1d8ea
AK
737;; In GPR templates, a string like sll<gk> will expand to sllg for DI
738;; and sllk for SI. This way it is possible to merge the new z196 SI
739;; 3 operands shift instructions into the existing patterns.
740(define_mode_attr gk [(DI "g") (SI "k")])
741
f52c81dd
AS
742;; ICM mask required to load MODE value into the lowest subreg
743;; of a SImode register.
744(define_mode_attr icm_lo [(HI "3") (QI "1")])
745
f6ee577c
AS
746;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
747;; HImode and "llgc" in QImode.
748(define_mode_attr hc [(HI "h") (QI "c")])
749
a1aed706
AS
750;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
751;; in SImode.
752(define_mode_attr DBL [(DI "TI") (SI "DI")])
753
609e7e80
AK
754;; This attribute expands to DF for TFmode and to DD for TDmode . It is
755;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
756(define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
757
f52c81dd
AS
758;; Maximum unsigned integer that fits in MODE.
759(define_mode_attr max_uint [(HI "65535") (QI "255")])
760
75ca1b39
RH
761;; Start and end field computations for RISBG et al.
762(define_mode_attr bfstart [(DI "s") (SI "t")])
763(define_mode_attr bfend [(DI "e") (SI "f")])
764
2542ef05
RH
765;; In place of GET_MODE_BITSIZE (<MODE>mode)
766(define_mode_attr bitsize [(DI "64") (SI "32") (HI "16") (QI "8")])
576987fc
DV
767;; 64 - bitsize
768(define_mode_attr bitoff [(DI "0") (SI "32") (HI "48") (QI "56")])
769(define_mode_attr bitoff_plus [(DI "") (SI "32+") (HI "48+") (QI "56+")])
2542ef05 770
da0dcab1
DV
771;; In place of GET_MODE_SIZE (<MODE>mode)
772(define_mode_attr modesize [(DI "8") (SI "4")])
773
177bc204
RS
774;; Allow return and simple_return to be defined from a single template.
775(define_code_iterator ANY_RETURN [return simple_return])
776
6e5b5de8
AK
777
778
779; Condition code modes generated by vector fp comparisons. These will
780; be used also in single element mode.
781(define_mode_iterator VFCMP [CCVEQ CCVFH CCVFHE])
782; Used with VFCMP to expand part of the mnemonic
783; For fp we have a mismatch: eq in the insn name - e in asm
784(define_mode_attr asm_fcmp [(CCVEQ "e") (CCVFH "h") (CCVFHE "he")])
a6a2b532 785(define_mode_attr insn_cmp [(CCVEQ "eq") (CCVIH "h") (CCVIHU "hl") (CCVFH "h") (CCVFHE "he")])
6e5b5de8 786
191eb16d
AK
787;; Subst pattern definitions
788(include "subst.md")
6e5b5de8 789
085261c8
AK
790(include "vector.md")
791
9db1d521
HP
792;;
793;;- Compare instructions.
794;;
795
07893d4f 796; Test-under-Mask instructions
9db1d521 797
07893d4f 798(define_insn "*tmqi_mem"
ae156f85 799 [(set (reg CC_REGNUM)
68f9c5e2
UW
800 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
801 (match_operand:QI 1 "immediate_operand" "n,n"))
802 (match_operand:QI 2 "immediate_operand" "n,n")))]
3ed99cc9 803 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
d3632d41 804 "@
fc0ea003
UW
805 tm\t%S0,%b1
806 tmy\t%S0,%b1"
9381e3f1 807 [(set_attr "op_type" "SI,SIY")
3e4be43f 808 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 809 (set_attr "z10prop" "z10_super,z10_super")])
9db1d521 810
05b9aaaa 811(define_insn "*tmdi_reg"
ae156f85 812 [(set (reg CC_REGNUM)
f19a9af7 813 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
2f7e5a0d 814 (match_operand:DI 1 "immediate_operand"
f19a9af7
AK
815 "N0HD0,N1HD0,N2HD0,N3HD0"))
816 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
9602b6a1 817 "TARGET_ZARCH
3ed99cc9 818 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
f19a9af7
AK
819 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
820 "@
821 tmhh\t%0,%i1
822 tmhl\t%0,%i1
823 tmlh\t%0,%i1
824 tmll\t%0,%i1"
9381e3f1
WG
825 [(set_attr "op_type" "RI")
826 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
05b9aaaa
UW
827
828(define_insn "*tmsi_reg"
ae156f85 829 [(set (reg CC_REGNUM)
f19a9af7
AK
830 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
831 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
832 (match_operand:SI 2 "immediate_operand" "n,n")))]
3ed99cc9 833 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
f19a9af7
AK
834 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
835 "@
836 tmh\t%0,%i1
837 tml\t%0,%i1"
729e750f
WG
838 [(set_attr "op_type" "RI")
839 (set_attr "z10prop" "z10_super,z10_super")])
05b9aaaa 840
f52c81dd 841(define_insn "*tm<mode>_full"
ae156f85 842 [(set (reg CC_REGNUM)
f52c81dd
AS
843 (compare (match_operand:HQI 0 "register_operand" "d")
844 (match_operand:HQI 1 "immediate_operand" "n")))]
3ed99cc9 845 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
f52c81dd 846 "tml\t%0,<max_uint>"
729e750f
WG
847 [(set_attr "op_type" "RI")
848 (set_attr "z10prop" "z10_super")])
9db1d521 849
07893d4f 850
08a5aaa2 851;
07893d4f 852; Load-and-Test instructions
08a5aaa2
AS
853;
854
c0220ea4 855; tst(di|si) instruction pattern(s).
07893d4f
UW
856
857(define_insn "*tstdi_sign"
ae156f85 858 [(set (reg CC_REGNUM)
963fc8d0
AK
859 (compare
860 (ashiftrt:DI
861 (ashift:DI
3e4be43f 862 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,T") 0)
963fc8d0
AK
863 (const_int 32)) (const_int 32))
864 (match_operand:DI 1 "const0_operand" "")))
865 (set (match_operand:DI 2 "register_operand" "=d,d")
07893d4f 866 (sign_extend:DI (match_dup 0)))]
9602b6a1 867 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH"
963fc8d0
AK
868 "ltgfr\t%2,%0
869 ltgf\t%2,%0"
870 [(set_attr "op_type" "RRE,RXY")
9381e3f1
WG
871 (set_attr "cpu_facility" "*,z10")
872 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
07893d4f 873
43a09b63 874; ltr, lt, ltgr, ltg
08a5aaa2 875(define_insn "*tst<mode>_extimm"
ec24698e 876 [(set (reg CC_REGNUM)
3e4be43f 877 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,T")
08a5aaa2
AS
878 (match_operand:GPR 1 "const0_operand" "")))
879 (set (match_operand:GPR 2 "register_operand" "=d,d")
ec24698e 880 (match_dup 0))]
08a5aaa2 881 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
ec24698e 882 "@
08a5aaa2
AS
883 lt<g>r\t%2,%0
884 lt<g>\t%2,%0"
9381e3f1 885 [(set_attr "op_type" "RR<E>,RXY")
729e750f 886 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
ec24698e 887
43a09b63 888; ltr, lt, ltgr, ltg
08a5aaa2 889(define_insn "*tst<mode>_cconly_extimm"
ec24698e 890 [(set (reg CC_REGNUM)
3e4be43f 891 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,T")
08a5aaa2
AS
892 (match_operand:GPR 1 "const0_operand" "")))
893 (clobber (match_scratch:GPR 2 "=X,d"))]
894 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
ec24698e 895 "@
08a5aaa2
AS
896 lt<g>r\t%0,%0
897 lt<g>\t%2,%0"
9381e3f1 898 [(set_attr "op_type" "RR<E>,RXY")
729e750f 899 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
ec24698e 900
07893d4f 901(define_insn "*tstdi"
ae156f85 902 [(set (reg CC_REGNUM)
07893d4f
UW
903 (compare (match_operand:DI 0 "register_operand" "d")
904 (match_operand:DI 1 "const0_operand" "")))
905 (set (match_operand:DI 2 "register_operand" "=d")
906 (match_dup 0))]
9602b6a1 907 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH && !TARGET_EXTIMM"
d40c829f 908 "ltgr\t%2,%0"
9381e3f1
WG
909 [(set_attr "op_type" "RRE")
910 (set_attr "z10prop" "z10_fr_E1")])
9db1d521 911
07893d4f 912(define_insn "*tstsi"
ae156f85 913 [(set (reg CC_REGNUM)
d3632d41 914 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
07893d4f 915 (match_operand:SI 1 "const0_operand" "")))
d3632d41 916 (set (match_operand:SI 2 "register_operand" "=d,d,d")
07893d4f 917 (match_dup 0))]
ec24698e 918 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
07893d4f 919 "@
d40c829f 920 ltr\t%2,%0
fc0ea003
UW
921 icm\t%2,15,%S0
922 icmy\t%2,15,%S0"
9381e3f1 923 [(set_attr "op_type" "RR,RS,RSY")
3e4be43f 924 (set_attr "cpu_facility" "*,*,longdisp")
9381e3f1 925 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
9db1d521 926
07893d4f 927(define_insn "*tstsi_cconly"
ae156f85 928 [(set (reg CC_REGNUM)
d3632d41 929 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
07893d4f 930 (match_operand:SI 1 "const0_operand" "")))
d3632d41 931 (clobber (match_scratch:SI 2 "=X,d,d"))]
07893d4f
UW
932 "s390_match_ccmode(insn, CCSmode)"
933 "@
d40c829f 934 ltr\t%0,%0
fc0ea003
UW
935 icm\t%2,15,%S0
936 icmy\t%2,15,%S0"
9381e3f1 937 [(set_attr "op_type" "RR,RS,RSY")
3e4be43f 938 (set_attr "cpu_facility" "*,*,longdisp")
9381e3f1 939 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
4023fb28 940
08a5aaa2
AS
941(define_insn "*tstdi_cconly_31"
942 [(set (reg CC_REGNUM)
943 (compare (match_operand:DI 0 "register_operand" "d")
944 (match_operand:DI 1 "const0_operand" "")))]
9602b6a1 945 "s390_match_ccmode(insn, CCSmode) && !TARGET_ZARCH"
08a5aaa2
AS
946 "srda\t%0,0"
947 [(set_attr "op_type" "RS")
948 (set_attr "atype" "reg")])
949
43a09b63 950; ltr, ltgr
08a5aaa2 951(define_insn "*tst<mode>_cconly2"
ae156f85 952 [(set (reg CC_REGNUM)
08a5aaa2
AS
953 (compare (match_operand:GPR 0 "register_operand" "d")
954 (match_operand:GPR 1 "const0_operand" "")))]
07893d4f 955 "s390_match_ccmode(insn, CCSmode)"
08a5aaa2 956 "lt<g>r\t%0,%0"
9381e3f1
WG
957 [(set_attr "op_type" "RR<E>")
958 (set_attr "z10prop" "z10_fr_E1")])
08a5aaa2 959
c0220ea4 960; tst(hi|qi) instruction pattern(s).
4023fb28 961
f52c81dd 962(define_insn "*tst<mode>CCT"
ae156f85 963 [(set (reg CC_REGNUM)
f52c81dd
AS
964 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
965 (match_operand:HQI 1 "const0_operand" "")))
966 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
3af97654
UW
967 (match_dup 0))]
968 "s390_match_ccmode(insn, CCTmode)"
969 "@
f52c81dd
AS
970 icm\t%2,<icm_lo>,%S0
971 icmy\t%2,<icm_lo>,%S0
972 tml\t%0,<max_uint>"
9381e3f1 973 [(set_attr "op_type" "RS,RSY,RI")
3e4be43f 974 (set_attr "cpu_facility" "*,longdisp,*")
9381e3f1 975 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
3af97654
UW
976
977(define_insn "*tsthiCCT_cconly"
ae156f85 978 [(set (reg CC_REGNUM)
d3632d41 979 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
3af97654 980 (match_operand:HI 1 "const0_operand" "")))
d3632d41 981 (clobber (match_scratch:HI 2 "=d,d,X"))]
3af97654
UW
982 "s390_match_ccmode(insn, CCTmode)"
983 "@
fc0ea003
UW
984 icm\t%2,3,%S0
985 icmy\t%2,3,%S0
d40c829f 986 tml\t%0,65535"
9381e3f1 987 [(set_attr "op_type" "RS,RSY,RI")
3e4be43f 988 (set_attr "cpu_facility" "*,longdisp,*")
9381e3f1 989 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
3af97654 990
3af97654 991(define_insn "*tstqiCCT_cconly"
ae156f85 992 [(set (reg CC_REGNUM)
d3632d41 993 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
3af97654
UW
994 (match_operand:QI 1 "const0_operand" "")))]
995 "s390_match_ccmode(insn, CCTmode)"
996 "@
fc0ea003
UW
997 cli\t%S0,0
998 cliy\t%S0,0
d40c829f 999 tml\t%0,255"
9381e3f1 1000 [(set_attr "op_type" "SI,SIY,RI")
3e4be43f 1001 (set_attr "cpu_facility" "*,longdisp,*")
729e750f 1002 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
3af97654 1003
f52c81dd 1004(define_insn "*tst<mode>"
ae156f85 1005 [(set (reg CC_REGNUM)
f52c81dd
AS
1006 (compare (match_operand:HQI 0 "s_operand" "Q,S")
1007 (match_operand:HQI 1 "const0_operand" "")))
1008 (set (match_operand:HQI 2 "register_operand" "=d,d")
07893d4f
UW
1009 (match_dup 0))]
1010 "s390_match_ccmode(insn, CCSmode)"
d3632d41 1011 "@
f52c81dd
AS
1012 icm\t%2,<icm_lo>,%S0
1013 icmy\t%2,<icm_lo>,%S0"
9381e3f1 1014 [(set_attr "op_type" "RS,RSY")
3e4be43f 1015 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 1016 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521 1017
f52c81dd 1018(define_insn "*tst<mode>_cconly"
ae156f85 1019 [(set (reg CC_REGNUM)
f52c81dd
AS
1020 (compare (match_operand:HQI 0 "s_operand" "Q,S")
1021 (match_operand:HQI 1 "const0_operand" "")))
1022 (clobber (match_scratch:HQI 2 "=d,d"))]
07893d4f 1023 "s390_match_ccmode(insn, CCSmode)"
d3632d41 1024 "@
f52c81dd
AS
1025 icm\t%2,<icm_lo>,%S0
1026 icmy\t%2,<icm_lo>,%S0"
9381e3f1 1027 [(set_attr "op_type" "RS,RSY")
3e4be43f 1028 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 1029 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
d3632d41 1030
9db1d521 1031
575f7c2b
UW
1032; Compare (equality) instructions
1033
1034(define_insn "*cmpdi_cct"
ae156f85 1035 [(set (reg CC_REGNUM)
ec24698e 1036 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
3e4be43f 1037 (match_operand:DI 1 "general_operand" "d,K,Os,T,BQ")))]
9602b6a1 1038 "s390_match_ccmode (insn, CCTmode) && TARGET_ZARCH"
575f7c2b
UW
1039 "@
1040 cgr\t%0,%1
f4f41b4e 1041 cghi\t%0,%h1
ec24698e 1042 cgfi\t%0,%1
575f7c2b 1043 cg\t%0,%1
19b63d8e 1044 #"
9381e3f1
WG
1045 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
1046 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
575f7c2b
UW
1047
1048(define_insn "*cmpsi_cct"
ae156f85 1049 [(set (reg CC_REGNUM)
ec24698e
UW
1050 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
1051 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
e221ef54 1052 "s390_match_ccmode (insn, CCTmode)"
575f7c2b
UW
1053 "@
1054 cr\t%0,%1
f4f41b4e 1055 chi\t%0,%h1
ec24698e 1056 cfi\t%0,%1
575f7c2b
UW
1057 c\t%0,%1
1058 cy\t%0,%1
19b63d8e 1059 #"
9381e3f1 1060 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
3e4be43f 1061 (set_attr "cpu_facility" "*,*,*,*,longdisp,*")
e3cba5e5 1062 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*")])
575f7c2b 1063
07893d4f 1064; Compare (signed) instructions
4023fb28 1065
07893d4f 1066(define_insn "*cmpdi_ccs_sign"
ae156f85 1067 [(set (reg CC_REGNUM)
963fc8d0 1068 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
3e4be43f 1069 "d,T,b"))
963fc8d0 1070 (match_operand:DI 0 "register_operand" "d, d,d")))]
9602b6a1 1071 "s390_match_ccmode(insn, CCSRmode) && TARGET_ZARCH"
4023fb28 1072 "@
d40c829f 1073 cgfr\t%0,%1
963fc8d0
AK
1074 cgf\t%0,%1
1075 cgfrl\t%0,%1"
1076 [(set_attr "op_type" "RRE,RXY,RIL")
9381e3f1 1077 (set_attr "z10prop" "z10_c,*,*")
963fc8d0 1078 (set_attr "type" "*,*,larl")])
4023fb28 1079
9381e3f1
WG
1080
1081
07893d4f 1082(define_insn "*cmpsi_ccs_sign"
ae156f85 1083 [(set (reg CC_REGNUM)
963fc8d0
AK
1084 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
1085 (match_operand:SI 0 "register_operand" "d,d,d")))]
07893d4f 1086 "s390_match_ccmode(insn, CCSRmode)"
d3632d41 1087 "@
d40c829f 1088 ch\t%0,%1
963fc8d0
AK
1089 chy\t%0,%1
1090 chrl\t%0,%1"
1091 [(set_attr "op_type" "RX,RXY,RIL")
3e4be43f 1092 (set_attr "cpu_facility" "*,longdisp,z10")
65b1d8ea
AK
1093 (set_attr "type" "*,*,larl")
1094 (set_attr "z196prop" "z196_cracked,z196_cracked,z196_cracked")])
963fc8d0
AK
1095
1096(define_insn "*cmphi_ccs_z10"
1097 [(set (reg CC_REGNUM)
1098 (compare (match_operand:HI 0 "s_operand" "Q")
1099 (match_operand:HI 1 "immediate_operand" "K")))]
1100 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
1101 "chhsi\t%0,%1"
65b1d8ea
AK
1102 [(set_attr "op_type" "SIL")
1103 (set_attr "z196prop" "z196_cracked")])
963fc8d0
AK
1104
1105(define_insn "*cmpdi_ccs_signhi_rl"
1106 [(set (reg CC_REGNUM)
3e4be43f 1107 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "T,b"))
963fc8d0
AK
1108 (match_operand:GPR 0 "register_operand" "d,d")))]
1109 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
1110 "@
1111 cgh\t%0,%1
1112 cghrl\t%0,%1"
1113 [(set_attr "op_type" "RXY,RIL")
1114 (set_attr "type" "*,larl")])
4023fb28 1115
963fc8d0 1116; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
3298c037 1117(define_insn "*cmp<mode>_ccs"
ae156f85 1118 [(set (reg CC_REGNUM)
963fc8d0
AK
1119 (compare (match_operand:GPR 0 "nonimmediate_operand"
1120 "d,d,Q, d,d,d,d")
1121 (match_operand:GPR 1 "general_operand"
1122 "d,K,K,Os,R,T,b")))]
9db1d521 1123 "s390_match_ccmode(insn, CCSmode)"
07893d4f 1124 "@
3298c037
AK
1125 c<g>r\t%0,%1
1126 c<g>hi\t%0,%h1
963fc8d0 1127 c<g>hsi\t%0,%h1
3298c037
AK
1128 c<g>fi\t%0,%1
1129 c<g>\t%0,%1
963fc8d0
AK
1130 c<y>\t%0,%1
1131 c<g>rl\t%0,%1"
1132 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
3e4be43f 1133 (set_attr "cpu_facility" "*,*,z10,extimm,*,longdisp,z10")
9381e3f1
WG
1134 (set_attr "type" "*,*,*,*,*,*,larl")
1135 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
c7453384 1136
07893d4f
UW
1137
1138; Compare (unsigned) instructions
9db1d521 1139
963fc8d0
AK
1140(define_insn "*cmpsi_ccu_zerohi_rlsi"
1141 [(set (reg CC_REGNUM)
1142 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
1143 "larl_operand" "X")))
1144 (match_operand:SI 0 "register_operand" "d")))]
1145 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
1146 "clhrl\t%0,%1"
1147 [(set_attr "op_type" "RIL")
729e750f
WG
1148 (set_attr "type" "larl")
1149 (set_attr "z10prop" "z10_super")])
963fc8d0
AK
1150
1151; clhrl, clghrl
1152(define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
1153 [(set (reg CC_REGNUM)
1154 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
1155 "larl_operand" "X")))
1156 (match_operand:GPR 0 "register_operand" "d")))]
1157 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
1158 "cl<g>hrl\t%0,%1"
1159 [(set_attr "op_type" "RIL")
9381e3f1
WG
1160 (set_attr "type" "larl")
1161 (set_attr "z10prop" "z10_super")])
963fc8d0 1162
07893d4f 1163(define_insn "*cmpdi_ccu_zero"
ae156f85 1164 [(set (reg CC_REGNUM)
963fc8d0 1165 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
3e4be43f
UW
1166 "d,T,b"))
1167 (match_operand:DI 0 "register_operand" "d,d,d")))]
9602b6a1 1168 "s390_match_ccmode (insn, CCURmode) && TARGET_ZARCH"
07893d4f 1169 "@
d40c829f 1170 clgfr\t%0,%1
963fc8d0
AK
1171 clgf\t%0,%1
1172 clgfrl\t%0,%1"
1173 [(set_attr "op_type" "RRE,RXY,RIL")
1174 (set_attr "cpu_facility" "*,*,z10")
9381e3f1
WG
1175 (set_attr "type" "*,*,larl")
1176 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
9db1d521 1177
07893d4f 1178(define_insn "*cmpdi_ccu"
ae156f85 1179 [(set (reg CC_REGNUM)
963fc8d0 1180 (compare (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 1181 "d, d,d,Q,d, Q,BQ")
963fc8d0 1182 (match_operand:DI 1 "general_operand"
3e4be43f 1183 "d,Op,b,D,T,BQ,Q")))]
9602b6a1 1184 "s390_match_ccmode (insn, CCUmode) && TARGET_ZARCH"
07893d4f 1185 "@
d40c829f 1186 clgr\t%0,%1
ec24698e 1187 clgfi\t%0,%1
963fc8d0
AK
1188 clgrl\t%0,%1
1189 clghsi\t%0,%x1
575f7c2b 1190 clg\t%0,%1
e221ef54 1191 #
19b63d8e 1192 #"
963fc8d0
AK
1193 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
1194 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
9381e3f1
WG
1195 (set_attr "type" "*,*,larl,*,*,*,*")
1196 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
9db1d521 1197
07893d4f 1198(define_insn "*cmpsi_ccu"
ae156f85 1199 [(set (reg CC_REGNUM)
963fc8d0
AK
1200 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
1201 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
e221ef54 1202 "s390_match_ccmode (insn, CCUmode)"
07893d4f 1203 "@
d40c829f 1204 clr\t%0,%1
ec24698e 1205 clfi\t%0,%o1
963fc8d0
AK
1206 clrl\t%0,%1
1207 clfhsi\t%0,%x1
d40c829f 1208 cl\t%0,%1
575f7c2b 1209 cly\t%0,%1
e221ef54 1210 #
19b63d8e 1211 #"
963fc8d0 1212 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
3e4be43f 1213 (set_attr "cpu_facility" "*,extimm,z10,z10,*,longdisp,*,*")
9381e3f1
WG
1214 (set_attr "type" "*,*,larl,*,*,*,*,*")
1215 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
9db1d521 1216
07893d4f 1217(define_insn "*cmphi_ccu"
ae156f85 1218 [(set (reg CC_REGNUM)
963fc8d0
AK
1219 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
1220 (match_operand:HI 1 "general_operand" "Q,S,D,BQ,Q")))]
575f7c2b 1221 "s390_match_ccmode (insn, CCUmode)
575f7c2b 1222 && !register_operand (operands[1], HImode)"
d3632d41 1223 "@
fc0ea003
UW
1224 clm\t%0,3,%S1
1225 clmy\t%0,3,%S1
963fc8d0 1226 clhhsi\t%0,%1
e221ef54 1227 #
19b63d8e 1228 #"
963fc8d0 1229 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
3e4be43f 1230 (set_attr "cpu_facility" "*,longdisp,z10,*,*")
9381e3f1 1231 (set_attr "z10prop" "*,*,z10_super,*,*")])
9db1d521
HP
1232
1233(define_insn "*cmpqi_ccu"
ae156f85 1234 [(set (reg CC_REGNUM)
e221ef54
UW
1235 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
1236 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
575f7c2b 1237 "s390_match_ccmode (insn, CCUmode)
575f7c2b 1238 && !register_operand (operands[1], QImode)"
d3632d41 1239 "@
fc0ea003
UW
1240 clm\t%0,1,%S1
1241 clmy\t%0,1,%S1
1242 cli\t%S0,%b1
1243 cliy\t%S0,%b1
e221ef54 1244 #
19b63d8e 1245 #"
9381e3f1 1246 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
3e4be43f 1247 (set_attr "cpu_facility" "*,longdisp,*,longdisp,*,*")
9381e3f1 1248 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
9db1d521
HP
1249
1250
19b63d8e
UW
1251; Block compare (CLC) instruction patterns.
1252
1253(define_insn "*clc"
ae156f85 1254 [(set (reg CC_REGNUM)
d4f52f0e 1255 (compare (match_operand:BLK 0 "memory_operand" "Q")
19b63d8e
UW
1256 (match_operand:BLK 1 "memory_operand" "Q")))
1257 (use (match_operand 2 "const_int_operand" "n"))]
1258 "s390_match_ccmode (insn, CCUmode)
1259 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 1260 "clc\t%O0(%2,%R0),%S1"
b628bd8e 1261 [(set_attr "op_type" "SS")])
19b63d8e
UW
1262
1263(define_split
ae156f85 1264 [(set (reg CC_REGNUM)
19b63d8e
UW
1265 (compare (match_operand 0 "memory_operand" "")
1266 (match_operand 1 "memory_operand" "")))]
1267 "reload_completed
1268 && s390_match_ccmode (insn, CCUmode)
1269 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1270 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1271 [(parallel
1272 [(set (match_dup 0) (match_dup 1))
1273 (use (match_dup 2))])]
1274{
1275 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1276 operands[0] = adjust_address (operands[0], BLKmode, 0);
1277 operands[1] = adjust_address (operands[1], BLKmode, 0);
1278
1279 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
1280 operands[0], operands[1]);
1281 operands[0] = SET_DEST (PATTERN (curr_insn));
1282})
1283
1284
609e7e80 1285; (TF|DF|SF|TD|DD|SD) instructions
9db1d521 1286
609e7e80 1287; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
f5905b37 1288(define_insn "*cmp<mode>_ccs_0"
ae156f85 1289 [(set (reg CC_REGNUM)
609e7e80
AK
1290 (compare (match_operand:FP 0 "register_operand" "f")
1291 (match_operand:FP 1 "const0_operand" "")))]
142cd70f 1292 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
609e7e80 1293 "lt<xde><bt>r\t%0,%0"
077dab3b 1294 [(set_attr "op_type" "RRE")
9381e3f1 1295 (set_attr "type" "fsimp<mode>")])
9db1d521 1296
be5de7a1 1297; cxtr, cxbr, cdtr, cdbr, cebr, cdb, ceb
f5905b37 1298(define_insn "*cmp<mode>_ccs"
ae156f85 1299 [(set (reg CC_REGNUM)
609e7e80 1300 (compare (match_operand:FP 0 "register_operand" "f,f")
62d3f261 1301 (match_operand:FP 1 "general_operand" "f,R")))]
142cd70f 1302 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
9db1d521 1303 "@
609e7e80 1304 c<xde><bt>r\t%0,%1
f61a2c7d 1305 c<xde>b\t%0,%1"
077dab3b 1306 [(set_attr "op_type" "RRE,RXE")
62d3f261
AK
1307 (set_attr "type" "fsimp<mode>")
1308 (set_attr "enabled" "*,<DSF>")])
9db1d521 1309
6e5b5de8
AK
1310; wfcedbs, wfchdbs, wfchedbs
1311(define_insn "*vec_cmp<insn_cmp>df_cconly"
1312 [(set (reg:VFCMP CC_REGNUM)
1313 (compare:VFCMP (match_operand:DF 0 "register_operand" "v")
1314 (match_operand:DF 1 "register_operand" "v")))
1315 (clobber (match_scratch:V2DI 2 "=v"))]
a579871b 1316 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
1317 "wfc<asm_fcmp>dbs\t%v2,%v0,%v1"
1318 [(set_attr "op_type" "VRR")])
963fc8d0
AK
1319
1320; Compare and Branch instructions
1321
1322; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
9381e3f1
WG
1323; The following instructions do a complementary access of their second
1324; operand (z01 only): crj_c, cgrjc, cr, cgr
963fc8d0
AK
1325(define_insn "*cmp_and_br_signed_<mode>"
1326 [(set (pc)
1327 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1328 [(match_operand:GPR 1 "register_operand" "d,d")
1329 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1330 (label_ref (match_operand 3 "" ""))
1331 (pc)))
1332 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1333 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
963fc8d0
AK
1334{
1335 if (get_attr_length (insn) == 6)
1336 return which_alternative ?
1337 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1338 else
1339 return which_alternative ?
1340 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1341}
1342 [(set_attr "op_type" "RIE")
1343 (set_attr "type" "branch")
e3cba5e5 1344 (set_attr "z10prop" "z10_super_c,z10_super")
963fc8d0
AK
1345 (set (attr "length")
1346 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1347 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1348 ; 10 byte for cgr/jg
1349
1350; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
9381e3f1
WG
1351; The following instructions do a complementary access of their second
1352; operand (z10 only): clrj, clgrj, clr, clgr
963fc8d0
AK
1353(define_insn "*cmp_and_br_unsigned_<mode>"
1354 [(set (pc)
1355 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1356 [(match_operand:GPR 1 "register_operand" "d,d")
1357 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1358 (label_ref (match_operand 3 "" ""))
1359 (pc)))
1360 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1361 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
963fc8d0
AK
1362{
1363 if (get_attr_length (insn) == 6)
1364 return which_alternative ?
1365 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1366 else
1367 return which_alternative ?
1368 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1369}
1370 [(set_attr "op_type" "RIE")
1371 (set_attr "type" "branch")
e3cba5e5 1372 (set_attr "z10prop" "z10_super_c,z10_super")
963fc8d0
AK
1373 (set (attr "length")
1374 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1375 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1376 ; 10 byte for clgr/jg
1377
b0f86a7e
AK
1378; And now the same two patterns as above but with a negated CC mask.
1379
1380; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1381; The following instructions do a complementary access of their second
1382; operand (z01 only): crj_c, cgrjc, cr, cgr
1383(define_insn "*icmp_and_br_signed_<mode>"
1384 [(set (pc)
1385 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1386 [(match_operand:GPR 1 "register_operand" "d,d")
1387 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1388 (pc)
1389 (label_ref (match_operand 3 "" ""))))
1390 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1391 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
b0f86a7e
AK
1392{
1393 if (get_attr_length (insn) == 6)
1394 return which_alternative ?
1395 "c<g>ij%D0\t%1,%c2,%l3" : "c<g>rj%D0\t%1,%2,%l3";
1396 else
1397 return which_alternative ?
1398 "c<g>fi\t%1,%c2\;jg%D0\t%l3" : "c<g>r\t%1,%2\;jg%D0\t%l3";
1399}
1400 [(set_attr "op_type" "RIE")
1401 (set_attr "type" "branch")
1402 (set_attr "z10prop" "z10_super_c,z10_super")
1403 (set (attr "length")
1404 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1405 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1406 ; 10 byte for cgr/jg
1407
1408; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1409; The following instructions do a complementary access of their second
1410; operand (z10 only): clrj, clgrj, clr, clgr
1411(define_insn "*icmp_and_br_unsigned_<mode>"
1412 [(set (pc)
1413 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1414 [(match_operand:GPR 1 "register_operand" "d,d")
1415 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1416 (pc)
1417 (label_ref (match_operand 3 "" ""))))
1418 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1419 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
b0f86a7e
AK
1420{
1421 if (get_attr_length (insn) == 6)
1422 return which_alternative ?
1423 "cl<g>ij%D0\t%1,%b2,%l3" : "cl<g>rj%D0\t%1,%2,%l3";
1424 else
1425 return which_alternative ?
1426 "cl<g>fi\t%1,%b2\;jg%D0\t%l3" : "cl<g>r\t%1,%2\;jg%D0\t%l3";
1427}
1428 [(set_attr "op_type" "RIE")
1429 (set_attr "type" "branch")
1430 (set_attr "z10prop" "z10_super_c,z10_super")
1431 (set (attr "length")
1432 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1433 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1434 ; 10 byte for clgr/jg
1435
9db1d521
HP
1436;;
1437;;- Move instructions.
1438;;
1439
1440;
1441; movti instruction pattern(s).
1442;
1443
085261c8
AK
1444; FIXME: More constants are possible by enabling jxx, jyy constraints
1445; for TImode (use double-int for the calculations)
9db1d521 1446(define_insn "movti"
3e4be43f
UW
1447 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,S,v, v, v,v,d,v,R, d,o")
1448 (match_operand:TI 1 "general_operand" " S,d,v,j00,jm1,d,v,R,v,dPT,d"))]
9602b6a1 1449 "TARGET_ZARCH"
4023fb28 1450 "@
fc0ea003
UW
1451 lmg\t%0,%N0,%S1
1452 stmg\t%1,%N1,%S0
085261c8
AK
1453 vlr\t%v0,%v1
1454 vzero\t%v0
1455 vone\t%v0
1456 vlvgp\t%v0,%1,%N1
1457 #
1458 vl\t%v0,%1
1459 vst\t%v1,%0
4023fb28 1460 #
19b63d8e 1461 #"
085261c8
AK
1462 [(set_attr "op_type" "RSY,RSY,VRR,VRI,VRI,VRR,*,VRX,VRX,*,*")
1463 (set_attr "type" "lm,stm,*,*,*,*,*,*,*,*,*")
1464 (set_attr "cpu_facility" "*,*,vec,vec,vec,vec,vec,vec,vec,*,*")])
4023fb28
UW
1465
1466(define_split
1467 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1468 (match_operand:TI 1 "general_operand" ""))]
9602b6a1 1469 "TARGET_ZARCH && reload_completed
dc65c307 1470 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
4023fb28
UW
1471 [(set (match_dup 2) (match_dup 4))
1472 (set (match_dup 3) (match_dup 5))]
9db1d521 1473{
dc65c307
UW
1474 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1475 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1476 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1477 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1478})
1479
1480(define_split
1481 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1482 (match_operand:TI 1 "general_operand" ""))]
9602b6a1 1483 "TARGET_ZARCH && reload_completed
dc65c307
UW
1484 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1485 [(set (match_dup 2) (match_dup 4))
1486 (set (match_dup 3) (match_dup 5))]
1487{
1488 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1489 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1490 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1491 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1492})
4023fb28 1493
085261c8
AK
1494; Use part of the TImode target reg to perform the address
1495; calculation. If the TImode value is supposed to be copied into a VR
1496; this splitter is not necessary.
4023fb28
UW
1497(define_split
1498 [(set (match_operand:TI 0 "register_operand" "")
1499 (match_operand:TI 1 "memory_operand" ""))]
9602b6a1 1500 "TARGET_ZARCH && reload_completed
085261c8 1501 && !VECTOR_REG_P (operands[0])
4023fb28 1502 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1503 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1504{
1505 rtx addr = operand_subword (operands[0], 1, 0, TImode);
9602b6a1 1506 addr = gen_lowpart (Pmode, addr);
a41c6c53
UW
1507 s390_load_address (addr, XEXP (operands[1], 0));
1508 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1509})
1510
833cd70a 1511
085261c8
AK
1512; Split a VR -> GPR TImode move into 2 vector load GR from VR element.
1513; For the higher order bits we do simply a DImode move while the
1514; second part is done via vec extract. Both will end up as vlgvg.
1515(define_split
1516 [(set (match_operand:TI 0 "register_operand" "")
1517 (match_operand:TI 1 "register_operand" ""))]
1518 "TARGET_VX && reload_completed
1519 && GENERAL_REG_P (operands[0])
1520 && VECTOR_REG_P (operands[1])"
1521 [(set (match_dup 2) (match_dup 4))
1522 (set (match_dup 3) (unspec:DI [(match_dup 5) (const_int 1)]
1523 UNSPEC_VEC_EXTRACT))]
1524{
1525 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1526 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1527 operands[4] = gen_rtx_REG (DImode, REGNO (operands[1]));
1528 operands[5] = gen_rtx_REG (V2DImode, REGNO (operands[1]));
1529})
1530
833cd70a
AK
1531;
1532; Patterns used for secondary reloads
1533;
1534
963fc8d0
AK
1535; z10 provides move instructions accepting larl memory operands.
1536; Unfortunately there is no such variant for QI, TI and FP mode moves.
1537; These patterns are also used for unaligned SI and DI accesses.
1538
085261c8
AK
1539(define_expand "reload<ALL:mode><P:mode>_tomem_z10"
1540 [(parallel [(match_operand:ALL 0 "memory_operand" "")
1541 (match_operand:ALL 1 "register_operand" "=d")
1542 (match_operand:P 2 "register_operand" "=&a")])]
963fc8d0
AK
1543 "TARGET_Z10"
1544{
1545 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1546 DONE;
1547})
1548
085261c8
AK
1549(define_expand "reload<ALL:mode><P:mode>_toreg_z10"
1550 [(parallel [(match_operand:ALL 0 "register_operand" "=d")
1551 (match_operand:ALL 1 "memory_operand" "")
1552 (match_operand:P 2 "register_operand" "=a")])]
963fc8d0
AK
1553 "TARGET_Z10"
1554{
1555 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1556 DONE;
1557})
1558
1559(define_expand "reload<P:mode>_larl_odd_addend_z10"
1560 [(parallel [(match_operand:P 0 "register_operand" "=d")
1561 (match_operand:P 1 "larl_operand" "")
1562 (match_operand:P 2 "register_operand" "=a")])]
1563 "TARGET_Z10"
1564{
1565 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1566 DONE;
1567})
1568
833cd70a
AK
1569; Handles loading a PLUS (load address) expression
1570
1571(define_expand "reload<mode>_plus"
1572 [(parallel [(match_operand:P 0 "register_operand" "=a")
1573 (match_operand:P 1 "s390_plus_operand" "")
1574 (match_operand:P 2 "register_operand" "=&a")])]
1575 ""
1576{
1577 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1578 DONE;
1579})
1580
085261c8
AK
1581; Not all the indirect memory access instructions support the full
1582; format (long disp + index + base). So whenever a move from/to such
1583; an address is required and the instruction cannot deal with it we do
1584; a load address into a scratch register first and use this as the new
1585; base register.
1586; This in particular is used for:
1587; - non-offsetable memory accesses for multiword moves
1588; - full vector reg moves with long displacements
833cd70a 1589
085261c8 1590(define_expand "reload<mode>_la_in"
833cd70a
AK
1591 [(parallel [(match_operand 0 "register_operand" "")
1592 (match_operand 1 "" "")
1593 (match_operand:P 2 "register_operand" "=&a")])]
1594 ""
1595{
1596 gcc_assert (MEM_P (operands[1]));
1597 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1598 operands[1] = replace_equiv_address (operands[1], operands[2]);
1599 emit_move_insn (operands[0], operands[1]);
1600 DONE;
1601})
1602
085261c8 1603(define_expand "reload<mode>_la_out"
833cd70a
AK
1604 [(parallel [(match_operand 0 "" "")
1605 (match_operand 1 "register_operand" "")
1606 (match_operand:P 2 "register_operand" "=&a")])]
1607 ""
dc65c307 1608{
9c3c3dcc 1609 gcc_assert (MEM_P (operands[0]));
9c90a97e 1610 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
dc65c307
UW
1611 operands[0] = replace_equiv_address (operands[0], operands[2]);
1612 emit_move_insn (operands[0], operands[1]);
1613 DONE;
1614})
9db1d521 1615
1f9e1fc6
AK
1616(define_expand "reload<mode>_PIC_addr"
1617 [(parallel [(match_operand 0 "register_operand" "=d")
1618 (match_operand 1 "larl_operand" "")
1619 (match_operand:P 2 "register_operand" "=a")])]
1620 ""
1621{
0a2aaacc
KG
1622 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1623 emit_move_insn (operands[0], new_rtx);
1f9e1fc6
AK
1624})
1625
9db1d521
HP
1626;
1627; movdi instruction pattern(s).
1628;
1629
9db1d521
HP
1630(define_expand "movdi"
1631 [(set (match_operand:DI 0 "general_operand" "")
1632 (match_operand:DI 1 "general_operand" ""))]
1633 ""
9db1d521 1634{
fd3cd001 1635 /* Handle symbolic constants. */
e4f2cd43
AK
1636 if (TARGET_64BIT
1637 && (SYMBOLIC_CONST (operands[1])
1638 || (GET_CODE (operands[1]) == PLUS
1639 && XEXP (operands[1], 0) == pic_offset_table_rtx
1640 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
fd3cd001 1641 emit_symbolic_move (operands);
10bbf137 1642})
9db1d521 1643
4023fb28
UW
1644(define_insn "*movdi_larl"
1645 [(set (match_operand:DI 0 "register_operand" "=d")
1646 (match_operand:DI 1 "larl_operand" "X"))]
1647 "TARGET_64BIT
8e509cf9 1648 && !FP_REG_P (operands[0])"
d40c829f 1649 "larl\t%0,%1"
4023fb28 1650 [(set_attr "op_type" "RIL")
9381e3f1
WG
1651 (set_attr "type" "larl")
1652 (set_attr "z10prop" "z10_super_A1")])
4023fb28 1653
3af8e996 1654(define_insn "*movdi_64"
85dae55a 1655 [(set (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 1656 "=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 1657 (match_operand:DI 1 "general_operand"
3e4be43f 1658 " 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 1659 "TARGET_ZARCH"
85dae55a
AK
1660 "@
1661 lghi\t%0,%h1
1662 llihh\t%0,%i1
1663 llihl\t%0,%i1
1664 llilh\t%0,%i1
1665 llill\t%0,%i1
1666 lgfi\t%0,%1
1667 llihf\t%0,%k1
1668 llilf\t%0,%k1
1669 ldgr\t%0,%1
1670 lgdr\t%0,%1
1671 lay\t%0,%a1
963fc8d0 1672 lgrl\t%0,%1
85dae55a
AK
1673 lgr\t%0,%1
1674 lg\t%0,%1
1675 stg\t%1,%0
1676 ldr\t%0,%1
1677 ld\t%0,%1
1678 ldy\t%0,%1
1679 std\t%1,%0
1680 stdy\t%1,%0
963fc8d0
AK
1681 stgrl\t%1,%0
1682 mvghi\t%0,%1
85dae55a
AK
1683 #
1684 #
1685 stam\t%1,%N1,%S0
085261c8
AK
1686 lam\t%0,%N0,%S1
1687 vleig\t%v0,%h1,0
1688 vlr\t%v0,%v1
1689 vlvgg\t%v0,%1,0
1690 vlgvg\t%0,%v1,0
1691 vleg\t%v0,%1,0
1692 vsteg\t%v1,%0,0"
963fc8d0 1693 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
085261c8 1694 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS,VRX,VRX")
963fc8d0 1695 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
085261c8
AK
1696 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,*,
1697 *,*,*,*,*,*,*")
3af8e996 1698 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
963fc8d0 1699 z10,*,*,*,*,*,longdisp,*,longdisp,
085261c8 1700 z10,z10,*,*,*,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
1701 (set_attr "z10prop" "z10_fwd_A1,
1702 z10_fwd_E1,
1703 z10_fwd_E1,
1704 z10_fwd_E1,
1705 z10_fwd_E1,
1706 z10_fwd_A1,
1707 z10_fwd_E1,
1708 z10_fwd_E1,
1709 *,
1710 *,
1711 z10_fwd_A1,
1712 z10_fwd_A3,
1713 z10_fr_E1,
1714 z10_fwd_A3,
1715 z10_rec,
1716 *,
1717 *,
1718 *,
1719 *,
1720 *,
1721 z10_rec,
1722 z10_super,
1723 *,
1724 *,
1725 *,
085261c8 1726 *,*,*,*,*,*,*")
9381e3f1 1727])
c5aa1d12
UW
1728
1729(define_split
1730 [(set (match_operand:DI 0 "register_operand" "")
1731 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1732 "TARGET_ZARCH && ACCESS_REG_P (operands[1])"
c5aa1d12
UW
1733 [(set (match_dup 2) (match_dup 3))
1734 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1735 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1736 "operands[2] = gen_lowpart (SImode, operands[0]);
1737 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1738
1739(define_split
1740 [(set (match_operand:DI 0 "register_operand" "")
1741 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1742 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
c5aa1d12
UW
1743 && dead_or_set_p (insn, operands[1])"
1744 [(set (match_dup 3) (match_dup 2))
1745 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1746 (set (match_dup 4) (match_dup 2))]
1747 "operands[2] = gen_lowpart (SImode, operands[1]);
1748 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1749
1750(define_split
1751 [(set (match_operand:DI 0 "register_operand" "")
1752 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1753 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
c5aa1d12
UW
1754 && !dead_or_set_p (insn, operands[1])"
1755 [(set (match_dup 3) (match_dup 2))
1756 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1757 (set (match_dup 4) (match_dup 2))
1758 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1759 "operands[2] = gen_lowpart (SImode, operands[1]);
1760 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
9db1d521
HP
1761
1762(define_insn "*movdi_31"
963fc8d0 1763 [(set (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 1764 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!R,!T,d")
963fc8d0 1765 (match_operand:DI 1 "general_operand"
3e4be43f 1766 " Q,S,d,d,dPT,d, *f, R, T,*f,*f,b"))]
9602b6a1 1767 "!TARGET_ZARCH"
4023fb28 1768 "@
fc0ea003 1769 lm\t%0,%N0,%S1
c4d50129 1770 lmy\t%0,%N0,%S1
fc0ea003 1771 stm\t%1,%N1,%S0
c4d50129 1772 stmy\t%1,%N1,%S0
4023fb28
UW
1773 #
1774 #
d40c829f
UW
1775 ldr\t%0,%1
1776 ld\t%0,%1
1777 ldy\t%0,%1
1778 std\t%1,%0
1779 stdy\t%1,%0
19b63d8e 1780 #"
f2dc2f86
AK
1781 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1782 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
3e4be43f 1783 (set_attr "cpu_facility" "*,longdisp,*,longdisp,*,*,*,*,longdisp,*,longdisp,z10")])
963fc8d0
AK
1784
1785; For a load from a symbol ref we can use one of the target registers
1786; together with larl to load the address.
1787(define_split
1788 [(set (match_operand:DI 0 "register_operand" "")
1789 (match_operand:DI 1 "memory_operand" ""))]
9602b6a1 1790 "!TARGET_ZARCH && reload_completed && TARGET_Z10
963fc8d0
AK
1791 && larl_operand (XEXP (operands[1], 0), SImode)"
1792 [(set (match_dup 2) (match_dup 3))
1793 (set (match_dup 0) (match_dup 1))]
1794{
1795 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1796 operands[3] = XEXP (operands[1], 0);
1797 operands[1] = replace_equiv_address (operands[1], operands[2]);
1798})
4023fb28
UW
1799
1800(define_split
1801 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1802 (match_operand:DI 1 "general_operand" ""))]
9602b6a1 1803 "!TARGET_ZARCH && reload_completed
dc65c307 1804 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
4023fb28
UW
1805 [(set (match_dup 2) (match_dup 4))
1806 (set (match_dup 3) (match_dup 5))]
9db1d521 1807{
dc65c307
UW
1808 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1809 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1810 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1811 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1812})
1813
1814(define_split
1815 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1816 (match_operand:DI 1 "general_operand" ""))]
9602b6a1 1817 "!TARGET_ZARCH && reload_completed
dc65c307
UW
1818 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1819 [(set (match_dup 2) (match_dup 4))
1820 (set (match_dup 3) (match_dup 5))]
1821{
1822 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1823 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1824 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1825 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1826})
9db1d521 1827
4023fb28
UW
1828(define_split
1829 [(set (match_operand:DI 0 "register_operand" "")
1830 (match_operand:DI 1 "memory_operand" ""))]
9602b6a1 1831 "!TARGET_ZARCH && reload_completed
8e509cf9 1832 && !FP_REG_P (operands[0])
4023fb28 1833 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1834 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1835{
1836 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1837 s390_load_address (addr, XEXP (operands[1], 0));
1838 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1839})
1840
84817c5d
UW
1841(define_peephole2
1842 [(set (match_operand:DI 0 "register_operand" "")
1843 (mem:DI (match_operand 1 "address_operand" "")))]
9602b6a1 1844 "TARGET_ZARCH
84817c5d
UW
1845 && !FP_REG_P (operands[0])
1846 && GET_CODE (operands[1]) == SYMBOL_REF
1847 && CONSTANT_POOL_ADDRESS_P (operands[1])
1848 && get_pool_mode (operands[1]) == DImode
1849 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1850 [(set (match_dup 0) (match_dup 2))]
1851 "operands[2] = get_pool_constant (operands[1]);")
1852
7bdff56f
UW
1853(define_insn "*la_64"
1854 [(set (match_operand:DI 0 "register_operand" "=d,d")
3e4be43f 1855 (match_operand:QI 1 "address_operand" "ZR,ZT"))]
7bdff56f
UW
1856 "TARGET_64BIT"
1857 "@
1858 la\t%0,%a1
1859 lay\t%0,%a1"
1860 [(set_attr "op_type" "RX,RXY")
9381e3f1 1861 (set_attr "type" "la")
3e4be43f 1862 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 1863 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
1864
1865(define_peephole2
1866 [(parallel
1867 [(set (match_operand:DI 0 "register_operand" "")
1868 (match_operand:QI 1 "address_operand" ""))
ae156f85 1869 (clobber (reg:CC CC_REGNUM))])]
7bdff56f 1870 "TARGET_64BIT
e1d5ee28 1871 && preferred_la_operand_p (operands[1], const0_rtx)"
7bdff56f
UW
1872 [(set (match_dup 0) (match_dup 1))]
1873 "")
1874
1875(define_peephole2
1876 [(set (match_operand:DI 0 "register_operand" "")
1877 (match_operand:DI 1 "register_operand" ""))
1878 (parallel
1879 [(set (match_dup 0)
1880 (plus:DI (match_dup 0)
1881 (match_operand:DI 2 "nonmemory_operand" "")))
ae156f85 1882 (clobber (reg:CC CC_REGNUM))])]
7bdff56f
UW
1883 "TARGET_64BIT
1884 && !reg_overlap_mentioned_p (operands[0], operands[2])
e1d5ee28 1885 && preferred_la_operand_p (operands[1], operands[2])"
7bdff56f
UW
1886 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1887 "")
1888
9db1d521
HP
1889;
1890; movsi instruction pattern(s).
1891;
1892
9db1d521
HP
1893(define_expand "movsi"
1894 [(set (match_operand:SI 0 "general_operand" "")
1895 (match_operand:SI 1 "general_operand" ""))]
1896 ""
9db1d521 1897{
fd3cd001 1898 /* Handle symbolic constants. */
e4f2cd43
AK
1899 if (!TARGET_64BIT
1900 && (SYMBOLIC_CONST (operands[1])
1901 || (GET_CODE (operands[1]) == PLUS
1902 && XEXP (operands[1], 0) == pic_offset_table_rtx
1903 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
fd3cd001 1904 emit_symbolic_move (operands);
10bbf137 1905})
9db1d521 1906
9e8327e3
UW
1907(define_insn "*movsi_larl"
1908 [(set (match_operand:SI 0 "register_operand" "=d")
1909 (match_operand:SI 1 "larl_operand" "X"))]
1910 "!TARGET_64BIT && TARGET_CPU_ZARCH
1911 && !FP_REG_P (operands[0])"
1912 "larl\t%0,%1"
1913 [(set_attr "op_type" "RIL")
9381e3f1 1914 (set_attr "type" "larl")
729e750f 1915 (set_attr "z10prop" "z10_fwd_A1")])
9e8327e3 1916
f19a9af7 1917(define_insn "*movsi_zarch"
2f7e5a0d 1918 [(set (match_operand:SI 0 "nonimmediate_operand"
3e4be43f 1919 "=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 1920 (match_operand:SI 1 "general_operand"
3e4be43f 1921 " 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 1922 "TARGET_ZARCH"
9db1d521 1923 "@
f19a9af7
AK
1924 lhi\t%0,%h1
1925 llilh\t%0,%i1
1926 llill\t%0,%i1
ec24698e 1927 iilf\t%0,%o1
f19a9af7 1928 lay\t%0,%a1
963fc8d0 1929 lrl\t%0,%1
d40c829f
UW
1930 lr\t%0,%1
1931 l\t%0,%1
1932 ly\t%0,%1
1933 st\t%1,%0
1934 sty\t%1,%0
ae1c6198 1935 ldr\t%0,%1
d40c829f 1936 ler\t%0,%1
085261c8 1937 lde\t%0,%1
d40c829f
UW
1938 le\t%0,%1
1939 ley\t%0,%1
1940 ste\t%1,%0
1941 stey\t%1,%0
c5aa1d12
UW
1942 ear\t%0,%1
1943 sar\t%0,%1
1944 stam\t%1,%1,%S0
963fc8d0
AK
1945 strl\t%1,%0
1946 mvhi\t%0,%1
085261c8
AK
1947 lam\t%0,%0,%S1
1948 vleif\t%v0,%h1,0
1949 vlr\t%v0,%v1
1950 vlvgf\t%v0,%1,0
1951 vlgvf\t%0,%v1,0
1952 vlef\t%v0,%1,0
1953 vstef\t%v1,%0,0"
963fc8d0 1954 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
ae1c6198 1955 RR,RR,RXE,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS,VRI,VRR,VRS,VRS,VRX,VRX")
9381e3f1
WG
1956 (set_attr "type" "*,
1957 *,
1958 *,
1959 *,
1960 la,
1961 larl,
1962 lr,
1963 load,
1964 load,
1965 store,
1966 store,
1967 floadsf,
1968 floadsf,
1969 floadsf,
085261c8
AK
1970 floadsf,
1971 floadsf,
9381e3f1
WG
1972 fstoresf,
1973 fstoresf,
1974 *,
1975 *,
1976 *,
1977 larl,
1978 *,
085261c8 1979 *,*,*,*,*,*,*")
963fc8d0 1980 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
085261c8 1981 vec,*,vec,*,longdisp,*,longdisp,*,*,*,z10,z10,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
1982 (set_attr "z10prop" "z10_fwd_A1,
1983 z10_fwd_E1,
1984 z10_fwd_E1,
1985 z10_fwd_A1,
1986 z10_fwd_A1,
1987 z10_fwd_A3,
1988 z10_fr_E1,
1989 z10_fwd_A3,
1990 z10_fwd_A3,
729e750f 1991 z10_rec,
9381e3f1
WG
1992 z10_rec,
1993 *,
1994 *,
1995 *,
1996 *,
1997 *,
085261c8
AK
1998 *,
1999 *,
9381e3f1
WG
2000 z10_super_E1,
2001 z10_super,
2002 *,
2003 z10_rec,
2004 z10_super,
085261c8 2005 *,*,*,*,*,*,*")])
f19a9af7
AK
2006
2007(define_insn "*movsi_esa"
085261c8
AK
2008 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!*f,!*f,!R,d,t,Q,t")
2009 (match_operand:SI 1 "general_operand" "K,d,R,d, *f, *f, R, R,*f,t,d,t,Q"))]
f19a9af7
AK
2010 "!TARGET_ZARCH"
2011 "@
2012 lhi\t%0,%h1
2013 lr\t%0,%1
2014 l\t%0,%1
2015 st\t%1,%0
ae1c6198 2016 ldr\t%0,%1
f19a9af7 2017 ler\t%0,%1
085261c8 2018 lde\t%0,%1
f19a9af7
AK
2019 le\t%0,%1
2020 ste\t%1,%0
c5aa1d12
UW
2021 ear\t%0,%1
2022 sar\t%0,%1
2023 stam\t%1,%1,%S0
f2dc2f86 2024 lam\t%0,%0,%S1"
ae1c6198 2025 [(set_attr "op_type" "RI,RR,RX,RX,RR,RR,RXE,RX,RX,RRE,RRE,RS,RS")
085261c8
AK
2026 (set_attr "type" "*,lr,load,store,floadsf,floadsf,floadsf,floadsf,fstoresf,*,*,*,*")
2027 (set_attr "z10prop" "z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec,*,*,*,*,*,z10_super_E1,
2028 z10_super,*,*")
2029 (set_attr "cpu_facility" "*,*,*,*,vec,*,vec,*,*,*,*,*,*")
9381e3f1 2030])
9db1d521 2031
84817c5d
UW
2032(define_peephole2
2033 [(set (match_operand:SI 0 "register_operand" "")
2034 (mem:SI (match_operand 1 "address_operand" "")))]
2035 "!FP_REG_P (operands[0])
2036 && GET_CODE (operands[1]) == SYMBOL_REF
2037 && CONSTANT_POOL_ADDRESS_P (operands[1])
2038 && get_pool_mode (operands[1]) == SImode
2039 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
2040 [(set (match_dup 0) (match_dup 2))]
2041 "operands[2] = get_pool_constant (operands[1]);")
9db1d521 2042
7bdff56f
UW
2043(define_insn "*la_31"
2044 [(set (match_operand:SI 0 "register_operand" "=d,d")
3e4be43f 2045 (match_operand:QI 1 "address_operand" "ZR,ZT"))]
7bdff56f
UW
2046 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
2047 "@
2048 la\t%0,%a1
2049 lay\t%0,%a1"
2050 [(set_attr "op_type" "RX,RXY")
9381e3f1 2051 (set_attr "type" "la")
3e4be43f 2052 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 2053 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
2054
2055(define_peephole2
2056 [(parallel
2057 [(set (match_operand:SI 0 "register_operand" "")
2058 (match_operand:QI 1 "address_operand" ""))
ae156f85 2059 (clobber (reg:CC CC_REGNUM))])]
7bdff56f 2060 "!TARGET_64BIT
e1d5ee28 2061 && preferred_la_operand_p (operands[1], const0_rtx)"
7bdff56f
UW
2062 [(set (match_dup 0) (match_dup 1))]
2063 "")
2064
2065(define_peephole2
2066 [(set (match_operand:SI 0 "register_operand" "")
2067 (match_operand:SI 1 "register_operand" ""))
2068 (parallel
2069 [(set (match_dup 0)
2070 (plus:SI (match_dup 0)
2071 (match_operand:SI 2 "nonmemory_operand" "")))
ae156f85 2072 (clobber (reg:CC CC_REGNUM))])]
7bdff56f
UW
2073 "!TARGET_64BIT
2074 && !reg_overlap_mentioned_p (operands[0], operands[2])
e1d5ee28 2075 && preferred_la_operand_p (operands[1], operands[2])"
7bdff56f
UW
2076 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2077 "")
2078
2079(define_insn "*la_31_and"
2080 [(set (match_operand:SI 0 "register_operand" "=d,d")
3e4be43f 2081 (and:SI (match_operand:QI 1 "address_operand" "ZR,ZT")
7bdff56f
UW
2082 (const_int 2147483647)))]
2083 "!TARGET_64BIT"
2084 "@
2085 la\t%0,%a1
2086 lay\t%0,%a1"
2087 [(set_attr "op_type" "RX,RXY")
9381e3f1 2088 (set_attr "type" "la")
3e4be43f 2089 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 2090 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
2091
2092(define_insn_and_split "*la_31_and_cc"
2093 [(set (match_operand:SI 0 "register_operand" "=d")
2094 (and:SI (match_operand:QI 1 "address_operand" "p")
2095 (const_int 2147483647)))
ae156f85 2096 (clobber (reg:CC CC_REGNUM))]
7bdff56f
UW
2097 "!TARGET_64BIT"
2098 "#"
2099 "&& reload_completed"
2100 [(set (match_dup 0)
2101 (and:SI (match_dup 1) (const_int 2147483647)))]
2102 ""
2103 [(set_attr "op_type" "RX")
2104 (set_attr "type" "la")])
2105
2106(define_insn "force_la_31"
2107 [(set (match_operand:SI 0 "register_operand" "=d,d")
3e4be43f 2108 (match_operand:QI 1 "address_operand" "ZR,ZT"))
7bdff56f
UW
2109 (use (const_int 0))]
2110 "!TARGET_64BIT"
2111 "@
2112 la\t%0,%a1
2113 lay\t%0,%a1"
2114 [(set_attr "op_type" "RX")
9381e3f1 2115 (set_attr "type" "la")
3e4be43f 2116 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 2117 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f 2118
9db1d521
HP
2119;
2120; movhi instruction pattern(s).
2121;
2122
02ed3c5e
UW
2123(define_expand "movhi"
2124 [(set (match_operand:HI 0 "nonimmediate_operand" "")
2125 (match_operand:HI 1 "general_operand" ""))]
2126 ""
2127{
2f7e5a0d 2128 /* Make it explicit that loading a register from memory
02ed3c5e 2129 always sign-extends (at least) to SImode. */
b3a13419 2130 if (optimize && can_create_pseudo_p ()
02ed3c5e 2131 && register_operand (operands[0], VOIDmode)
8fff4fc1 2132 && GET_CODE (operands[1]) == MEM)
02ed3c5e
UW
2133 {
2134 rtx tmp = gen_reg_rtx (SImode);
2135 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
f7df4a84 2136 emit_insn (gen_rtx_SET (tmp, ext));
02ed3c5e
UW
2137 operands[1] = gen_lowpart (HImode, tmp);
2138 }
2139})
2140
2141(define_insn "*movhi"
3e4be43f
UW
2142 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q,v,v,v,d,v,R")
2143 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K,K,v,d,v,R,v"))]
9db1d521
HP
2144 ""
2145 "@
d40c829f
UW
2146 lr\t%0,%1
2147 lhi\t%0,%h1
2148 lh\t%0,%1
2149 lhy\t%0,%1
963fc8d0 2150 lhrl\t%0,%1
d40c829f
UW
2151 sth\t%1,%0
2152 sthy\t%1,%0
963fc8d0 2153 sthrl\t%1,%0
085261c8
AK
2154 mvhhi\t%0,%1
2155 vleih\t%v0,%h1,0
2156 vlr\t%v0,%v1
2157 vlvgh\t%v0,%1,0
2158 vlgvh\t%0,%v1,0
2159 vleh\t%v0,%1,0
2160 vsteh\t%v1,%0,0"
2161 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL,VRI,VRR,VRS,VRS,VRX,VRX")
2162 (set_attr "type" "lr,*,*,*,larl,store,store,store,*,*,*,*,*,*,*")
3e4be43f 2163 (set_attr "cpu_facility" "*,*,*,longdisp,z10,*,longdisp,z10,z10,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
2164 (set_attr "z10prop" "z10_fr_E1,
2165 z10_fwd_A1,
2166 z10_super_E1,
2167 z10_super_E1,
2168 z10_super_E1,
729e750f 2169 z10_rec,
9381e3f1
WG
2170 z10_rec,
2171 z10_rec,
085261c8 2172 z10_super,*,*,*,*,*,*")])
9db1d521 2173
84817c5d
UW
2174(define_peephole2
2175 [(set (match_operand:HI 0 "register_operand" "")
2176 (mem:HI (match_operand 1 "address_operand" "")))]
2177 "GET_CODE (operands[1]) == SYMBOL_REF
2178 && CONSTANT_POOL_ADDRESS_P (operands[1])
2179 && get_pool_mode (operands[1]) == HImode
2180 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2181 [(set (match_dup 0) (match_dup 2))]
2182 "operands[2] = get_pool_constant (operands[1]);")
4023fb28 2183
9db1d521
HP
2184;
2185; movqi instruction pattern(s).
2186;
2187
02ed3c5e
UW
2188(define_expand "movqi"
2189 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2190 (match_operand:QI 1 "general_operand" ""))]
2191 ""
2192{
c19ec8f9 2193 /* On z/Architecture, zero-extending from memory to register
02ed3c5e 2194 is just as fast as a QImode load. */
b3a13419 2195 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
02ed3c5e 2196 && register_operand (operands[0], VOIDmode)
8fff4fc1 2197 && GET_CODE (operands[1]) == MEM)
02ed3c5e 2198 {
9602b6a1
AK
2199 rtx tmp = gen_reg_rtx (DImode);
2200 rtx ext = gen_rtx_ZERO_EXTEND (DImode, operands[1]);
f7df4a84 2201 emit_insn (gen_rtx_SET (tmp, ext));
02ed3c5e
UW
2202 operands[1] = gen_lowpart (QImode, tmp);
2203 }
2204})
4023fb28 2205
02ed3c5e 2206(define_insn "*movqi"
3e4be43f
UW
2207 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q,v,v,v,d,v,R")
2208 (match_operand:QI 1 "general_operand" " d,n,R,T,d,d,n,n,?Q,K,v,d,v,R,v"))]
9db1d521
HP
2209 ""
2210 "@
d40c829f
UW
2211 lr\t%0,%1
2212 lhi\t%0,%b1
2213 ic\t%0,%1
2214 icy\t%0,%1
2215 stc\t%1,%0
2216 stcy\t%1,%0
fc0ea003 2217 mvi\t%S0,%b1
0a88561f 2218 mviy\t%S0,%b1
085261c8
AK
2219 #
2220 vleib\t%v0,%b1,0
2221 vlr\t%v0,%v1
2222 vlvgb\t%v0,%1,0
2223 vlgvb\t%0,%v1,0
2224 vleb\t%v0,%1,0
2225 vsteb\t%v1,%0,0"
2226 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS,VRI,VRR,VRS,VRS,VRX,VRX")
2227 (set_attr "type" "lr,*,*,*,store,store,store,store,*,*,*,*,*,*,*")
3e4be43f 2228 (set_attr "cpu_facility" "*,*,*,longdisp,*,longdisp,*,longdisp,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
2229 (set_attr "z10prop" "z10_fr_E1,
2230 z10_fwd_A1,
2231 z10_super_E1,
2232 z10_super_E1,
729e750f 2233 z10_rec,
9381e3f1
WG
2234 z10_rec,
2235 z10_super,
0a88561f 2236 z10_super,
085261c8 2237 *,*,*,*,*,*,*")])
9db1d521 2238
84817c5d
UW
2239(define_peephole2
2240 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2241 (mem:QI (match_operand 1 "address_operand" "")))]
2242 "GET_CODE (operands[1]) == SYMBOL_REF
2243 && CONSTANT_POOL_ADDRESS_P (operands[1])
2244 && get_pool_mode (operands[1]) == QImode
2245 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2246 [(set (match_dup 0) (match_dup 2))]
2247 "operands[2] = get_pool_constant (operands[1]);")
4023fb28 2248
9db1d521 2249;
05b9aaaa 2250; movstrictqi instruction pattern(s).
9db1d521
HP
2251;
2252
2253(define_insn "*movstrictqi"
d3632d41
UW
2254 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
2255 (match_operand:QI 1 "memory_operand" "R,T"))]
9db1d521 2256 ""
d3632d41 2257 "@
d40c829f
UW
2258 ic\t%0,%1
2259 icy\t%0,%1"
9381e3f1 2260 [(set_attr "op_type" "RX,RXY")
3e4be43f 2261 (set_attr "cpu_facility" "*,longdisp")
729e750f 2262 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521
HP
2263
2264;
2265; movstricthi instruction pattern(s).
2266;
2267
2268(define_insn "*movstricthi"
d3632d41 2269 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
575f7c2b 2270 (match_operand:HI 1 "memory_operand" "Q,S"))
ae156f85 2271 (clobber (reg:CC CC_REGNUM))]
9db1d521 2272 ""
d3632d41 2273 "@
fc0ea003
UW
2274 icm\t%0,3,%S1
2275 icmy\t%0,3,%S1"
9381e3f1 2276 [(set_attr "op_type" "RS,RSY")
3e4be43f 2277 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 2278 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521
HP
2279
2280;
2281; movstrictsi instruction pattern(s).
2282;
2283
05b9aaaa 2284(define_insn "movstrictsi"
c5aa1d12
UW
2285 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
2286 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
9602b6a1 2287 "TARGET_ZARCH"
9db1d521 2288 "@
d40c829f
UW
2289 lr\t%0,%1
2290 l\t%0,%1
c5aa1d12
UW
2291 ly\t%0,%1
2292 ear\t%0,%1"
2293 [(set_attr "op_type" "RR,RX,RXY,RRE")
9381e3f1 2294 (set_attr "type" "lr,load,load,*")
3e4be43f 2295 (set_attr "cpu_facility" "*,*,longdisp,*")
9381e3f1 2296 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
9db1d521 2297
f61a2c7d 2298;
609e7e80 2299; mov(tf|td) instruction pattern(s).
f61a2c7d
AK
2300;
2301
609e7e80
AK
2302(define_expand "mov<mode>"
2303 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2304 (match_operand:TD_TF 1 "general_operand" ""))]
f61a2c7d
AK
2305 ""
2306 "")
2307
609e7e80 2308(define_insn "*mov<mode>_64"
3e4be43f
UW
2309 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o,d,S, d,o")
2310 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,S,d,dT,d"))]
9602b6a1 2311 "TARGET_ZARCH"
f61a2c7d 2312 "@
65b1d8ea 2313 lzxr\t%0
f61a2c7d
AK
2314 lxr\t%0,%1
2315 #
2316 #
2317 lmg\t%0,%N0,%S1
2318 stmg\t%1,%N1,%S0
2319 #
f61a2c7d 2320 #"
65b1d8ea
AK
2321 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
2322 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")
2323 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*")])
f61a2c7d 2324
609e7e80 2325(define_insn "*mov<mode>_31"
65b1d8ea
AK
2326 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
2327 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
9602b6a1 2328 "!TARGET_ZARCH"
f61a2c7d 2329 "@
65b1d8ea 2330 lzxr\t%0
f61a2c7d
AK
2331 lxr\t%0,%1
2332 #
f61a2c7d 2333 #"
65b1d8ea
AK
2334 [(set_attr "op_type" "RRE,RRE,*,*")
2335 (set_attr "type" "fsimptf,fsimptf,*,*")
2336 (set_attr "cpu_facility" "z196,*,*,*")])
f61a2c7d
AK
2337
2338; TFmode in GPRs splitters
2339
2340(define_split
609e7e80
AK
2341 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2342 (match_operand:TD_TF 1 "general_operand" ""))]
9602b6a1 2343 "TARGET_ZARCH && reload_completed
609e7e80 2344 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
f61a2c7d
AK
2345 [(set (match_dup 2) (match_dup 4))
2346 (set (match_dup 3) (match_dup 5))]
2347{
609e7e80
AK
2348 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2349 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2350 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2351 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
f61a2c7d
AK
2352})
2353
2354(define_split
609e7e80
AK
2355 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2356 (match_operand:TD_TF 1 "general_operand" ""))]
9602b6a1 2357 "TARGET_ZARCH && reload_completed
609e7e80 2358 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
f61a2c7d
AK
2359 [(set (match_dup 2) (match_dup 4))
2360 (set (match_dup 3) (match_dup 5))]
2361{
609e7e80
AK
2362 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2363 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2364 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2365 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
f61a2c7d
AK
2366})
2367
2368(define_split
609e7e80
AK
2369 [(set (match_operand:TD_TF 0 "register_operand" "")
2370 (match_operand:TD_TF 1 "memory_operand" ""))]
9602b6a1 2371 "TARGET_ZARCH && reload_completed
085261c8 2372 && GENERAL_REG_P (operands[0])
f61a2c7d
AK
2373 && !s_operand (operands[1], VOIDmode)"
2374 [(set (match_dup 0) (match_dup 1))]
2375{
609e7e80 2376 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
a9e6994a 2377 addr = gen_lowpart (Pmode, addr);
f61a2c7d
AK
2378 s390_load_address (addr, XEXP (operands[1], 0));
2379 operands[1] = replace_equiv_address (operands[1], addr);
2380})
2381
7b6baae1 2382; TFmode in BFPs splitters
f61a2c7d
AK
2383
2384(define_split
609e7e80
AK
2385 [(set (match_operand:TD_TF 0 "register_operand" "")
2386 (match_operand:TD_TF 1 "memory_operand" ""))]
9381e3f1 2387 "reload_completed && offsettable_memref_p (operands[1])
f61a2c7d
AK
2388 && FP_REG_P (operands[0])"
2389 [(set (match_dup 2) (match_dup 4))
2390 (set (match_dup 3) (match_dup 5))]
2391{
609e7e80
AK
2392 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2393 <MODE>mode, 0);
2394 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2395 <MODE>mode, 8);
2396 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
2397 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
f61a2c7d
AK
2398})
2399
2400(define_split
609e7e80
AK
2401 [(set (match_operand:TD_TF 0 "memory_operand" "")
2402 (match_operand:TD_TF 1 "register_operand" ""))]
f61a2c7d
AK
2403 "reload_completed && offsettable_memref_p (operands[0])
2404 && FP_REG_P (operands[1])"
2405 [(set (match_dup 2) (match_dup 4))
2406 (set (match_dup 3) (match_dup 5))]
2407{
609e7e80
AK
2408 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
2409 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
2410 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2411 <MODE>mode, 0);
2412 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2413 <MODE>mode, 8);
f61a2c7d
AK
2414})
2415
9db1d521 2416;
609e7e80 2417; mov(df|dd) instruction pattern(s).
9db1d521
HP
2418;
2419
609e7e80
AK
2420(define_expand "mov<mode>"
2421 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2422 (match_operand:DD_DF 1 "general_operand" ""))]
9db1d521 2423 ""
13c025c1 2424 "")
9db1d521 2425
609e7e80
AK
2426(define_insn "*mov<mode>_64dfp"
2427 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
3e4be43f 2428 "=f,f,f,d,f,f,R,T,d,d,d,d,b,T,v,v,d,v,R")
609e7e80 2429 (match_operand:DD_DF 1 "general_operand"
3e4be43f 2430 " G,f,d,f,R,T,f,f,G,d,b,T,d,d,v,d,v,R,v"))]
9602b6a1 2431 "TARGET_DFP"
85dae55a 2432 "@
65b1d8ea 2433 lzdr\t%0
85dae55a
AK
2434 ldr\t%0,%1
2435 ldgr\t%0,%1
2436 lgdr\t%0,%1
2437 ld\t%0,%1
2438 ldy\t%0,%1
2439 std\t%1,%0
2440 stdy\t%1,%0
45e5214c 2441 lghi\t%0,0
85dae55a 2442 lgr\t%0,%1
085261c8 2443 lgrl\t%0,%1
85dae55a 2444 lg\t%0,%1
085261c8
AK
2445 stgrl\t%1,%0
2446 stg\t%1,%0
2447 vlr\t%v0,%v1
2448 vlvgg\t%v0,%1,0
2449 vlgvg\t%0,%v1,0
2450 vleg\t%0,%1,0
2451 vsteg\t%1,%0,0"
2452 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY,VRR,VRS,VRS,VRX,VRX")
65b1d8ea 2453 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
085261c8
AK
2454 fstoredf,fstoredf,*,lr,load,load,store,store,*,*,*,load,store")
2455 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,*,*,*,*,*")
3e4be43f 2456 (set_attr "cpu_facility" "z196,*,*,*,*,longdisp,*,longdisp,*,*,z10,*,z10,*,vec,vec,vec,vec,vec")])
85dae55a 2457
609e7e80 2458(define_insn "*mov<mode>_64"
3e4be43f
UW
2459 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,d,d,b,T,v,v,R")
2460 (match_operand:DD_DF 1 "general_operand" " G,f,R,T,f,f,G,d,b,T,d,d,v,R,v"))]
9602b6a1 2461 "TARGET_ZARCH"
9db1d521 2462 "@
65b1d8ea 2463 lzdr\t%0
d40c829f
UW
2464 ldr\t%0,%1
2465 ld\t%0,%1
2466 ldy\t%0,%1
2467 std\t%1,%0
2468 stdy\t%1,%0
45e5214c 2469 lghi\t%0,0
d40c829f 2470 lgr\t%0,%1
085261c8 2471 lgrl\t%0,%1
d40c829f 2472 lg\t%0,%1
085261c8
AK
2473 stgrl\t%1,%0
2474 stg\t%1,%0
2475 vlr\t%v0,%v1
2476 vleg\t%v0,%1,0
2477 vsteg\t%v1,%0,0"
2478 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY,VRR,VRX,VRX")
65b1d8ea 2479 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
085261c8
AK
2480 fstore<mode>,fstore<mode>,*,lr,load,load,store,store,*,load,store")
2481 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,*,*,*")
3e4be43f 2482 (set_attr "cpu_facility" "z196,*,*,longdisp,*,longdisp,*,*,z10,*,z10,*,vec,vec,vec")])
609e7e80
AK
2483
2484(define_insn "*mov<mode>_31"
2485 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
3e4be43f 2486 "=f,f,f,f,R,T,d,d,Q,S, d,o")
609e7e80 2487 (match_operand:DD_DF 1 "general_operand"
3e4be43f 2488 " G,f,R,T,f,f,Q,S,d,d,dPT,d"))]
9602b6a1 2489 "!TARGET_ZARCH"
9db1d521 2490 "@
65b1d8ea 2491 lzdr\t%0
d40c829f
UW
2492 ldr\t%0,%1
2493 ld\t%0,%1
2494 ldy\t%0,%1
2495 std\t%1,%0
2496 stdy\t%1,%0
fc0ea003 2497 lm\t%0,%N0,%S1
c4d50129 2498 lmy\t%0,%N0,%S1
fc0ea003 2499 stm\t%1,%N1,%S0
c4d50129 2500 stmy\t%1,%N1,%S0
4023fb28 2501 #
19b63d8e 2502 #"
65b1d8ea
AK
2503 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2504 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2505 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")
3e4be43f 2506 (set_attr "cpu_facility" "z196,*,*,longdisp,*,longdisp,*,longdisp,*,longdisp,*,*")])
4023fb28
UW
2507
2508(define_split
609e7e80
AK
2509 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2510 (match_operand:DD_DF 1 "general_operand" ""))]
9602b6a1 2511 "!TARGET_ZARCH && reload_completed
609e7e80 2512 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
4023fb28
UW
2513 [(set (match_dup 2) (match_dup 4))
2514 (set (match_dup 3) (match_dup 5))]
9db1d521 2515{
609e7e80
AK
2516 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2517 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2518 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2519 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
dc65c307
UW
2520})
2521
2522(define_split
609e7e80
AK
2523 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2524 (match_operand:DD_DF 1 "general_operand" ""))]
9602b6a1 2525 "!TARGET_ZARCH && reload_completed
609e7e80 2526 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
dc65c307
UW
2527 [(set (match_dup 2) (match_dup 4))
2528 (set (match_dup 3) (match_dup 5))]
2529{
609e7e80
AK
2530 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2531 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2532 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2533 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
dc65c307 2534})
9db1d521 2535
4023fb28 2536(define_split
609e7e80
AK
2537 [(set (match_operand:DD_DF 0 "register_operand" "")
2538 (match_operand:DD_DF 1 "memory_operand" ""))]
9602b6a1 2539 "!TARGET_ZARCH && reload_completed
8e509cf9 2540 && !FP_REG_P (operands[0])
4023fb28 2541 && !s_operand (operands[1], VOIDmode)"
a41c6c53 2542 [(set (match_dup 0) (match_dup 1))]
a41c6c53 2543{
609e7e80 2544 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
a41c6c53
UW
2545 s390_load_address (addr, XEXP (operands[1], 0));
2546 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
2547})
2548
9db1d521 2549;
609e7e80 2550; mov(sf|sd) instruction pattern(s).
9db1d521
HP
2551;
2552
609e7e80
AK
2553(define_insn "mov<mode>"
2554 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
3e4be43f 2555 "=f,f,f,f,f,f,R,T,d,d,d,d,d,b,R,T,v,v,v,d,v,R")
609e7e80 2556 (match_operand:SD_SF 1 "general_operand"
3e4be43f 2557 " G,f,f,R,R,T,f,f,G,d,b,R,T,d,d,d,v,G,d,v,R,v"))]
4023fb28 2558 ""
9db1d521 2559 "@
65b1d8ea 2560 lzer\t%0
ae1c6198 2561 ldr\t%0,%1
d40c829f 2562 ler\t%0,%1
085261c8 2563 lde\t%0,%1
d40c829f
UW
2564 le\t%0,%1
2565 ley\t%0,%1
2566 ste\t%1,%0
2567 stey\t%1,%0
45e5214c 2568 lhi\t%0,0
d40c829f 2569 lr\t%0,%1
085261c8 2570 lrl\t%0,%1
d40c829f
UW
2571 l\t%0,%1
2572 ly\t%0,%1
085261c8 2573 strl\t%1,%0
d40c829f 2574 st\t%1,%0
085261c8
AK
2575 sty\t%1,%0
2576 vlr\t%v0,%v1
2577 vleif\t%v0,0
2578 vlvgf\t%v0,%1,0
2579 vlgvf\t%0,%v1,0
2580 vleg\t%0,%1,0
2581 vsteg\t%1,%0,0"
ae1c6198 2582 [(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
2583 (set_attr "type" "fsimpsf,fsimpsf,fload<mode>,fload<mode>,fload<mode>,fload<mode>,
2584 fstore<mode>,fstore<mode>,*,lr,load,load,load,store,store,store,*,*,*,*,load,store")
2585 (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 2586 (set_attr "cpu_facility" "z196,vec,*,vec,*,longdisp,*,longdisp,*,*,z10,*,longdisp,z10,*,longdisp,vec,vec,vec,vec,vec,vec")])
4023fb28 2587
9dc62c00
AK
2588;
2589; movcc instruction pattern
2590;
2591
2592(define_insn "movcc"
2593 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
5a3fe9b6 2594 (match_operand:CC 1 "nonimmediate_operand" " d,d,c,R,T,d,d"))]
9dc62c00
AK
2595 ""
2596 "@
2597 lr\t%0,%1
2598 tmh\t%1,12288
2599 ipm\t%0
a71f0749
DV
2600 l\t%0,%1
2601 ly\t%0,%1
2602 st\t%1,%0
2603 sty\t%1,%0"
8dd3b235 2604 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
a71f0749 2605 (set_attr "type" "lr,*,*,load,load,store,store")
3e4be43f 2606 (set_attr "cpu_facility" "*,*,*,*,longdisp,*,longdisp")
a71f0749 2607 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
65b1d8ea 2608 (set_attr "z196prop" "*,*,z196_ends,*,*,*,*")])
9dc62c00 2609
19b63d8e
UW
2610;
2611; Block move (MVC) patterns.
2612;
2613
2614(define_insn "*mvc"
2615 [(set (match_operand:BLK 0 "memory_operand" "=Q")
2616 (match_operand:BLK 1 "memory_operand" "Q"))
2617 (use (match_operand 2 "const_int_operand" "n"))]
2618 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 2619 "mvc\t%O0(%2,%R0),%S1"
b628bd8e 2620 [(set_attr "op_type" "SS")])
19b63d8e 2621
0a88561f
AK
2622; This splitter converts a QI to QI mode copy into a BLK mode copy in
2623; order to have it implemented with mvc.
2624
2625(define_split
2626 [(set (match_operand:QI 0 "memory_operand" "")
2627 (match_operand:QI 1 "memory_operand" ""))]
2628 "reload_completed"
2629 [(parallel
2630 [(set (match_dup 0) (match_dup 1))
2631 (use (const_int 1))])]
2632{
2633 operands[0] = adjust_address (operands[0], BLKmode, 0);
2634 operands[1] = adjust_address (operands[1], BLKmode, 0);
2635})
2636
2637
19b63d8e
UW
2638(define_peephole2
2639 [(parallel
2640 [(set (match_operand:BLK 0 "memory_operand" "")
2641 (match_operand:BLK 1 "memory_operand" ""))
2642 (use (match_operand 2 "const_int_operand" ""))])
2643 (parallel
2644 [(set (match_operand:BLK 3 "memory_operand" "")
2645 (match_operand:BLK 4 "memory_operand" ""))
2646 (use (match_operand 5 "const_int_operand" ""))])]
2647 "s390_offset_p (operands[0], operands[3], operands[2])
2648 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 2649 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 2650 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
2651 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2652 [(parallel
2653 [(set (match_dup 6) (match_dup 7))
2654 (use (match_dup 8))])]
2655 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2656 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2657 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2658
2659
9db1d521
HP
2660;
2661; load_multiple pattern(s).
2662;
22ea6b4f
UW
2663; ??? Due to reload problems with replacing registers inside match_parallel
2664; we currently support load_multiple/store_multiple only after reload.
2665;
9db1d521
HP
2666
2667(define_expand "load_multiple"
2668 [(match_par_dup 3 [(set (match_operand 0 "" "")
2669 (match_operand 1 "" ""))
2670 (use (match_operand 2 "" ""))])]
22ea6b4f 2671 "reload_completed"
9db1d521 2672{
ef4bddc2 2673 machine_mode mode;
9db1d521
HP
2674 int regno;
2675 int count;
2676 rtx from;
4023fb28 2677 int i, off;
9db1d521
HP
2678
2679 /* Support only loading a constant number of fixed-point registers from
2680 memory and only bother with this if more than two */
2681 if (GET_CODE (operands[2]) != CONST_INT
4023fb28 2682 || INTVAL (operands[2]) < 2
9db1d521
HP
2683 || INTVAL (operands[2]) > 16
2684 || GET_CODE (operands[1]) != MEM
2685 || GET_CODE (operands[0]) != REG
2686 || REGNO (operands[0]) >= 16)
2687 FAIL;
2688
2689 count = INTVAL (operands[2]);
2690 regno = REGNO (operands[0]);
c19ec8f9 2691 mode = GET_MODE (operands[0]);
9602b6a1 2692 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
c19ec8f9 2693 FAIL;
9db1d521
HP
2694
2695 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
b3a13419 2696 if (!can_create_pseudo_p ())
4023fb28
UW
2697 {
2698 if (GET_CODE (XEXP (operands[1], 0)) == REG)
2699 {
2700 from = XEXP (operands[1], 0);
2701 off = 0;
2702 }
2703 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2704 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2705 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2706 {
2707 from = XEXP (XEXP (operands[1], 0), 0);
2708 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2709 }
2710 else
2711 FAIL;
4023fb28
UW
2712 }
2713 else
2714 {
2715 from = force_reg (Pmode, XEXP (operands[1], 0));
2716 off = 0;
2717 }
9db1d521
HP
2718
2719 for (i = 0; i < count; i++)
2720 XVECEXP (operands[3], 0, i)
f7df4a84 2721 = gen_rtx_SET (gen_rtx_REG (mode, regno + i),
c19ec8f9 2722 change_address (operands[1], mode,
0a81f074
RS
2723 plus_constant (Pmode, from,
2724 off + i * GET_MODE_SIZE (mode))));
10bbf137 2725})
9db1d521
HP
2726
2727(define_insn "*load_multiple_di"
2728 [(match_parallel 0 "load_multiple_operation"
2729 [(set (match_operand:DI 1 "register_operand" "=r")
3e4be43f 2730 (match_operand:DI 2 "s_operand" "S"))])]
9602b6a1 2731 "reload_completed && TARGET_ZARCH"
9db1d521
HP
2732{
2733 int words = XVECLEN (operands[0], 0);
9db1d521 2734 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
fc0ea003 2735 return "lmg\t%1,%0,%S2";
10bbf137 2736}
d3632d41 2737 [(set_attr "op_type" "RSY")
4023fb28 2738 (set_attr "type" "lm")])
9db1d521
HP
2739
2740(define_insn "*load_multiple_si"
2741 [(match_parallel 0 "load_multiple_operation"
d3632d41
UW
2742 [(set (match_operand:SI 1 "register_operand" "=r,r")
2743 (match_operand:SI 2 "s_operand" "Q,S"))])]
22ea6b4f 2744 "reload_completed"
9db1d521
HP
2745{
2746 int words = XVECLEN (operands[0], 0);
9db1d521 2747 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
fc0ea003 2748 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
10bbf137 2749}
d3632d41 2750 [(set_attr "op_type" "RS,RSY")
3e4be43f 2751 (set_attr "cpu_facility" "*,longdisp")
4023fb28 2752 (set_attr "type" "lm")])
9db1d521
HP
2753
2754;
c7453384 2755; store multiple pattern(s).
9db1d521
HP
2756;
2757
2758(define_expand "store_multiple"
2759 [(match_par_dup 3 [(set (match_operand 0 "" "")
2760 (match_operand 1 "" ""))
2761 (use (match_operand 2 "" ""))])]
22ea6b4f 2762 "reload_completed"
9db1d521 2763{
ef4bddc2 2764 machine_mode mode;
9db1d521
HP
2765 int regno;
2766 int count;
2767 rtx to;
4023fb28 2768 int i, off;
9db1d521
HP
2769
2770 /* Support only storing a constant number of fixed-point registers to
2771 memory and only bother with this if more than two. */
2772 if (GET_CODE (operands[2]) != CONST_INT
4023fb28 2773 || INTVAL (operands[2]) < 2
9db1d521
HP
2774 || INTVAL (operands[2]) > 16
2775 || GET_CODE (operands[0]) != MEM
2776 || GET_CODE (operands[1]) != REG
2777 || REGNO (operands[1]) >= 16)
2778 FAIL;
2779
2780 count = INTVAL (operands[2]);
2781 regno = REGNO (operands[1]);
c19ec8f9 2782 mode = GET_MODE (operands[1]);
9602b6a1 2783 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
c19ec8f9 2784 FAIL;
9db1d521
HP
2785
2786 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
4023fb28 2787
b3a13419 2788 if (!can_create_pseudo_p ())
4023fb28
UW
2789 {
2790 if (GET_CODE (XEXP (operands[0], 0)) == REG)
2791 {
2792 to = XEXP (operands[0], 0);
2793 off = 0;
2794 }
2795 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2796 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2797 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2798 {
2799 to = XEXP (XEXP (operands[0], 0), 0);
2800 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2801 }
2802 else
2803 FAIL;
4023fb28 2804 }
c7453384 2805 else
4023fb28
UW
2806 {
2807 to = force_reg (Pmode, XEXP (operands[0], 0));
2808 off = 0;
2809 }
9db1d521
HP
2810
2811 for (i = 0; i < count; i++)
2812 XVECEXP (operands[3], 0, i)
f7df4a84 2813 = gen_rtx_SET (change_address (operands[0], mode,
0a81f074
RS
2814 plus_constant (Pmode, to,
2815 off + i * GET_MODE_SIZE (mode))),
c19ec8f9 2816 gen_rtx_REG (mode, regno + i));
10bbf137 2817})
9db1d521
HP
2818
2819(define_insn "*store_multiple_di"
2820 [(match_parallel 0 "store_multiple_operation"
3e4be43f 2821 [(set (match_operand:DI 1 "s_operand" "=S")
9db1d521 2822 (match_operand:DI 2 "register_operand" "r"))])]
9602b6a1 2823 "reload_completed && TARGET_ZARCH"
9db1d521
HP
2824{
2825 int words = XVECLEN (operands[0], 0);
9db1d521 2826 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
fc0ea003 2827 return "stmg\t%2,%0,%S1";
10bbf137 2828}
d3632d41 2829 [(set_attr "op_type" "RSY")
4023fb28 2830 (set_attr "type" "stm")])
9db1d521
HP
2831
2832
2833(define_insn "*store_multiple_si"
2834 [(match_parallel 0 "store_multiple_operation"
d3632d41
UW
2835 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2836 (match_operand:SI 2 "register_operand" "r,r"))])]
22ea6b4f 2837 "reload_completed"
9db1d521
HP
2838{
2839 int words = XVECLEN (operands[0], 0);
9db1d521 2840 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
fc0ea003 2841 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
10bbf137 2842}
d3632d41 2843 [(set_attr "op_type" "RS,RSY")
3e4be43f 2844 (set_attr "cpu_facility" "*,longdisp")
4023fb28 2845 (set_attr "type" "stm")])
9db1d521
HP
2846
2847;;
2848;; String instructions.
2849;;
2850
963fc8d0 2851(define_insn "*execute_rl"
2771c2f9 2852 [(match_parallel 0 "execute_operation"
963fc8d0
AK
2853 [(unspec [(match_operand 1 "register_operand" "a")
2854 (match_operand 2 "" "")
2855 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2856 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2857 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2858 "exrl\t%1,%3"
2859 [(set_attr "op_type" "RIL")
2860 (set_attr "type" "cs")])
2861
9bb86f41 2862(define_insn "*execute"
2771c2f9 2863 [(match_parallel 0 "execute_operation"
9bb86f41
UW
2864 [(unspec [(match_operand 1 "register_operand" "a")
2865 (match_operand:BLK 2 "memory_operand" "R")
2866 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2867 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2868 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2869 "ex\t%1,%2"
29a74354
UW
2870 [(set_attr "op_type" "RX")
2871 (set_attr "type" "cs")])
9bb86f41
UW
2872
2873
91d39d71
UW
2874;
2875; strlenM instruction pattern(s).
2876;
2877
9db2f16d 2878(define_expand "strlen<mode>"
085261c8
AK
2879 [(match_operand:P 0 "register_operand" "") ; result
2880 (match_operand:BLK 1 "memory_operand" "") ; input string
2881 (match_operand:SI 2 "immediate_operand" "") ; search character
2882 (match_operand:SI 3 "immediate_operand" "")] ; known alignment
2883 ""
2884{
2885 if (!TARGET_VX || operands[2] != const0_rtx)
2886 emit_insn (gen_strlen_srst<mode> (operands[0], operands[1],
2887 operands[2], operands[3]));
2888 else
2889 s390_expand_vec_strlen (operands[0], operands[1], operands[3]);
2890
2891 DONE;
2892})
2893
2894(define_expand "strlen_srst<mode>"
ccbdc0d4 2895 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2f7e5a0d 2896 (parallel
91d39d71 2897 [(set (match_dup 4)
9db2f16d 2898 (unspec:P [(const_int 0)
91d39d71 2899 (match_operand:BLK 1 "memory_operand" "")
ccbdc0d4 2900 (reg:SI 0)
91d39d71 2901 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
9db2f16d 2902 (clobber (scratch:P))
ae156f85 2903 (clobber (reg:CC CC_REGNUM))])
91d39d71 2904 (parallel
9db2f16d
AS
2905 [(set (match_operand:P 0 "register_operand" "")
2906 (minus:P (match_dup 4) (match_dup 5)))
ae156f85 2907 (clobber (reg:CC CC_REGNUM))])]
9db2f16d 2908 ""
91d39d71 2909{
9db2f16d
AS
2910 operands[4] = gen_reg_rtx (Pmode);
2911 operands[5] = gen_reg_rtx (Pmode);
91d39d71
UW
2912 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2913 operands[1] = replace_equiv_address (operands[1], operands[5]);
2914})
2915
9db2f16d
AS
2916(define_insn "*strlen<mode>"
2917 [(set (match_operand:P 0 "register_operand" "=a")
2918 (unspec:P [(match_operand:P 2 "general_operand" "0")
2919 (mem:BLK (match_operand:P 3 "register_operand" "1"))
ccbdc0d4 2920 (reg:SI 0)
91d39d71 2921 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
9db2f16d 2922 (clobber (match_scratch:P 1 "=a"))
ae156f85 2923 (clobber (reg:CC CC_REGNUM))]
9db2f16d 2924 ""
91d39d71 2925 "srst\t%0,%1\;jo\t.-4"
b628bd8e
UW
2926 [(set_attr "length" "8")
2927 (set_attr "type" "vs")])
91d39d71 2928
ccbdc0d4
AS
2929;
2930; cmpstrM instruction pattern(s).
2931;
2932
2933(define_expand "cmpstrsi"
2934 [(set (reg:SI 0) (const_int 0))
2935 (parallel
2936 [(clobber (match_operand 3 "" ""))
2937 (clobber (match_dup 4))
2938 (set (reg:CCU CC_REGNUM)
2939 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2940 (match_operand:BLK 2 "memory_operand" "")))
2941 (use (reg:SI 0))])
2942 (parallel
2943 [(set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 2944 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_STRCMPCC_TO_INT))
ccbdc0d4
AS
2945 (clobber (reg:CC CC_REGNUM))])]
2946 ""
2947{
2948 /* As the result of CMPINT is inverted compared to what we need,
2949 we have to swap the operands. */
2950 rtx op1 = operands[2];
2951 rtx op2 = operands[1];
2952 rtx addr1 = gen_reg_rtx (Pmode);
2953 rtx addr2 = gen_reg_rtx (Pmode);
2954
2955 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2956 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2957 operands[1] = replace_equiv_address_nv (op1, addr1);
2958 operands[2] = replace_equiv_address_nv (op2, addr2);
2959 operands[3] = addr1;
2960 operands[4] = addr2;
2961})
2962
2963(define_insn "*cmpstr<mode>"
2964 [(clobber (match_operand:P 0 "register_operand" "=d"))
2965 (clobber (match_operand:P 1 "register_operand" "=d"))
2966 (set (reg:CCU CC_REGNUM)
2967 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2968 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2969 (use (reg:SI 0))]
2970 ""
2971 "clst\t%0,%1\;jo\t.-4"
2972 [(set_attr "length" "8")
2973 (set_attr "type" "vs")])
9381e3f1 2974
742090fc
AS
2975;
2976; movstr instruction pattern.
2977;
2978
2979(define_expand "movstr"
4a7dec25
DV
2980 [(match_operand 0 "register_operand" "")
2981 (match_operand 1 "memory_operand" "")
2982 (match_operand 2 "memory_operand" "")]
2983 ""
2984{
2985 if (TARGET_64BIT)
2986 emit_insn (gen_movstrdi (operands[0], operands[1], operands[2]));
2987 else
2988 emit_insn (gen_movstrsi (operands[0], operands[1], operands[2]));
2989 DONE;
2990})
2991
2992(define_expand "movstr<P:mode>"
742090fc 2993 [(set (reg:SI 0) (const_int 0))
9381e3f1 2994 (parallel
742090fc
AS
2995 [(clobber (match_dup 3))
2996 (set (match_operand:BLK 1 "memory_operand" "")
2997 (match_operand:BLK 2 "memory_operand" ""))
4a7dec25
DV
2998 (set (match_operand:P 0 "register_operand" "")
2999 (unspec:P [(match_dup 1)
742090fc
AS
3000 (match_dup 2)
3001 (reg:SI 0)] UNSPEC_MVST))
3002 (clobber (reg:CC CC_REGNUM))])]
3003 ""
3004{
859a4c0e
AK
3005 rtx addr1, addr2;
3006
3007 if (TARGET_VX && optimize_function_for_speed_p (cfun))
3008 {
3009 s390_expand_vec_movstr (operands[0], operands[1], operands[2]);
3010 DONE;
3011 }
3012
3013 addr1 = gen_reg_rtx (Pmode);
3014 addr2 = gen_reg_rtx (Pmode);
742090fc
AS
3015
3016 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3017 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
3018 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3019 operands[2] = replace_equiv_address_nv (operands[2], addr2);
3020 operands[3] = addr2;
3021})
3022
3023(define_insn "*movstr"
3024 [(clobber (match_operand:P 2 "register_operand" "=d"))
3025 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
3026 (mem:BLK (match_operand:P 3 "register_operand" "2")))
3027 (set (match_operand:P 0 "register_operand" "=d")
4a7dec25 3028 (unspec:P [(mem:BLK (match_dup 1))
742090fc
AS
3029 (mem:BLK (match_dup 3))
3030 (reg:SI 0)] UNSPEC_MVST))
3031 (clobber (reg:CC CC_REGNUM))]
3032 ""
3033 "mvst\t%1,%2\;jo\t.-4"
3034 [(set_attr "length" "8")
3035 (set_attr "type" "vs")])
9381e3f1 3036
742090fc 3037
9db1d521 3038;
70128ad9 3039; movmemM instruction pattern(s).
9db1d521
HP
3040;
3041
9db2f16d 3042(define_expand "movmem<mode>"
963fc8d0
AK
3043 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
3044 (match_operand:BLK 1 "memory_operand" "")) ; source
3045 (use (match_operand:GPR 2 "general_operand" "")) ; count
a41c6c53
UW
3046 (match_operand 3 "" "")]
3047 ""
367d32f3
AK
3048{
3049 if (s390_expand_movmem (operands[0], operands[1], operands[2]))
3050 DONE;
3051 else
3052 FAIL;
3053})
9db1d521 3054
ecbe845e
UW
3055; Move a block that is up to 256 bytes in length.
3056; The block length is taken as (operands[2] % 256) + 1.
9db1d521 3057
70128ad9 3058(define_expand "movmem_short"
b9404c99
UW
3059 [(parallel
3060 [(set (match_operand:BLK 0 "memory_operand" "")
3061 (match_operand:BLK 1 "memory_operand" ""))
3062 (use (match_operand 2 "nonmemory_operand" ""))
9bb86f41 3063 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99
UW
3064 (clobber (match_dup 3))])]
3065 ""
3066 "operands[3] = gen_rtx_SCRATCH (Pmode);")
ecbe845e 3067
70128ad9 3068(define_insn "*movmem_short"
963fc8d0
AK
3069 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
3070 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
3071 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3072 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
1eae36f0
AK
3073 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3074 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
9bb86f41 3075 "#"
963fc8d0 3076 [(set_attr "type" "cs")
b5e0425c 3077 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
ecbe845e 3078
9bb86f41
UW
3079(define_split
3080 [(set (match_operand:BLK 0 "memory_operand" "")
3081 (match_operand:BLK 1 "memory_operand" ""))
3082 (use (match_operand 2 "const_int_operand" ""))
3083 (use (match_operand 3 "immediate_operand" ""))
3084 (clobber (scratch))]
3085 "reload_completed"
3086 [(parallel
3087 [(set (match_dup 0) (match_dup 1))
3088 (use (match_dup 2))])]
3089 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
9db1d521 3090
9bb86f41
UW
3091(define_split
3092 [(set (match_operand:BLK 0 "memory_operand" "")
3093 (match_operand:BLK 1 "memory_operand" ""))
3094 (use (match_operand 2 "register_operand" ""))
3095 (use (match_operand 3 "memory_operand" ""))
3096 (clobber (scratch))]
3097 "reload_completed"
3098 [(parallel
3099 [(unspec [(match_dup 2) (match_dup 3)
3100 (const_int 0)] UNSPEC_EXECUTE)
3101 (set (match_dup 0) (match_dup 1))
3102 (use (const_int 1))])]
3103 "")
3104
963fc8d0
AK
3105(define_split
3106 [(set (match_operand:BLK 0 "memory_operand" "")
3107 (match_operand:BLK 1 "memory_operand" ""))
3108 (use (match_operand 2 "register_operand" ""))
3109 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3110 (clobber (scratch))]
3111 "TARGET_Z10 && reload_completed"
3112 [(parallel
3113 [(unspec [(match_dup 2) (const_int 0)
3114 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3115 (set (match_dup 0) (match_dup 1))
3116 (use (const_int 1))])]
3117 "operands[3] = gen_label_rtx ();")
3118
9bb86f41
UW
3119(define_split
3120 [(set (match_operand:BLK 0 "memory_operand" "")
3121 (match_operand:BLK 1 "memory_operand" ""))
3122 (use (match_operand 2 "register_operand" ""))
3123 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3124 (clobber (match_operand 3 "register_operand" ""))]
3125 "reload_completed && TARGET_CPU_ZARCH"
3126 [(set (match_dup 3) (label_ref (match_dup 4)))
3127 (parallel
9381e3f1 3128 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
9bb86f41
UW
3129 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3130 (set (match_dup 0) (match_dup 1))
3131 (use (const_int 1))])]
3132 "operands[4] = gen_label_rtx ();")
3133
a41c6c53 3134; Move a block of arbitrary length.
9db1d521 3135
70128ad9 3136(define_expand "movmem_long"
b9404c99
UW
3137 [(parallel
3138 [(clobber (match_dup 2))
3139 (clobber (match_dup 3))
3140 (set (match_operand:BLK 0 "memory_operand" "")
3141 (match_operand:BLK 1 "memory_operand" ""))
3142 (use (match_operand 2 "general_operand" ""))
3143 (use (match_dup 3))
ae156f85 3144 (clobber (reg:CC CC_REGNUM))])]
b9404c99
UW
3145 ""
3146{
ef4bddc2
RS
3147 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3148 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
3149 rtx reg0 = gen_reg_rtx (dreg_mode);
3150 rtx reg1 = gen_reg_rtx (dreg_mode);
3151 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3152 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
b9404c99
UW
3153 rtx len0 = gen_lowpart (Pmode, reg0);
3154 rtx len1 = gen_lowpart (Pmode, reg1);
3155
c41c1387 3156 emit_clobber (reg0);
b9404c99
UW
3157 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3158 emit_move_insn (len0, operands[2]);
3159
c41c1387 3160 emit_clobber (reg1);
b9404c99
UW
3161 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3162 emit_move_insn (len1, operands[2]);
3163
3164 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3165 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3166 operands[2] = reg0;
3167 operands[3] = reg1;
3168})
3169
a1aed706
AS
3170(define_insn "*movmem_long"
3171 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3172 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3173 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3174 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
b9404c99
UW
3175 (use (match_dup 2))
3176 (use (match_dup 3))
ae156f85 3177 (clobber (reg:CC CC_REGNUM))]
9602b6a1
AK
3178 "TARGET_64BIT || !TARGET_ZARCH"
3179 "mvcle\t%0,%1,0\;jo\t.-4"
3180 [(set_attr "length" "8")
3181 (set_attr "type" "vs")])
3182
3183(define_insn "*movmem_long_31z"
3184 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3185 (clobber (match_operand:TI 1 "register_operand" "=d"))
3186 (set (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3187 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4)))
3188 (use (match_dup 2))
3189 (use (match_dup 3))
3190 (clobber (reg:CC CC_REGNUM))]
3191 "!TARGET_64BIT && TARGET_ZARCH"
d40c829f 3192 "mvcle\t%0,%1,0\;jo\t.-4"
b628bd8e
UW
3193 [(set_attr "length" "8")
3194 (set_attr "type" "vs")])
9db1d521 3195
638e37c2
WG
3196
3197;
3198; Test data class.
3199;
3200
0f67fa83
WG
3201(define_expand "signbit<mode>2"
3202 [(set (reg:CCZ CC_REGNUM)
9381e3f1
WG
3203 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3204 (match_dup 2)]
0f67fa83
WG
3205 UNSPEC_TDC_INSN))
3206 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3207 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
0f67fa83
WG
3208 "TARGET_HARD_FLOAT"
3209{
3210 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
3211})
3212
638e37c2
WG
3213(define_expand "isinf<mode>2"
3214 [(set (reg:CCZ CC_REGNUM)
9381e3f1
WG
3215 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3216 (match_dup 2)]
638e37c2
WG
3217 UNSPEC_TDC_INSN))
3218 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3219 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
142cd70f 3220 "TARGET_HARD_FLOAT"
638e37c2
WG
3221{
3222 operands[2] = GEN_INT (S390_TDC_INFINITY);
3223})
3224
085261c8
AK
3225; This extracts CC into a GPR properly shifted. The actual IPM
3226; instruction will be issued by reload. The constraint of operand 1
3227; forces reload to use a GPR. So reload will issue a movcc insn for
3228; copying CC into a GPR first.
5a3fe9b6 3229(define_insn_and_split "*cc_to_int"
085261c8 3230 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5a3fe9b6
AK
3231 (unspec:SI [(match_operand 1 "register_operand" "0")]
3232 UNSPEC_CC_TO_INT))]
3233 "operands != NULL"
3234 "#"
3235 "reload_completed"
3236 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
3237
638e37c2
WG
3238; This insn is used to generate all variants of the Test Data Class
3239; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
3240; is the register to be tested and the second one is the bit mask
9381e3f1 3241; specifying the required test(s).
638e37c2 3242;
be5de7a1 3243; tcxb, tcdb, tceb, tdcxt, tdcdt, tdcet
638e37c2
WG
3244(define_insn "*TDC_insn_<mode>"
3245 [(set (reg:CCZ CC_REGNUM)
9381e3f1 3246 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
638e37c2 3247 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
142cd70f 3248 "TARGET_HARD_FLOAT"
0387c142 3249 "t<_d>c<xde><bt>\t%0,%1"
638e37c2 3250 [(set_attr "op_type" "RXE")
9381e3f1 3251 (set_attr "type" "fsimp<mode>")])
638e37c2 3252
638e37c2
WG
3253
3254
9db1d521 3255;
57e84f18 3256; setmemM instruction pattern(s).
9db1d521
HP
3257;
3258
57e84f18 3259(define_expand "setmem<mode>"
a41c6c53 3260 [(set (match_operand:BLK 0 "memory_operand" "")
6d057022 3261 (match_operand:QI 2 "general_operand" ""))
9db2f16d 3262 (use (match_operand:GPR 1 "general_operand" ""))
57e84f18 3263 (match_operand 3 "" "")]
a41c6c53 3264 ""
6d057022 3265 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
9db1d521 3266
a41c6c53 3267; Clear a block that is up to 256 bytes in length.
b9404c99
UW
3268; The block length is taken as (operands[1] % 256) + 1.
3269
70128ad9 3270(define_expand "clrmem_short"
b9404c99
UW
3271 [(parallel
3272 [(set (match_operand:BLK 0 "memory_operand" "")
3273 (const_int 0))
3274 (use (match_operand 1 "nonmemory_operand" ""))
9bb86f41 3275 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99 3276 (clobber (match_dup 2))
ae156f85 3277 (clobber (reg:CC CC_REGNUM))])]
b9404c99
UW
3278 ""
3279 "operands[2] = gen_rtx_SCRATCH (Pmode);")
9db1d521 3280
70128ad9 3281(define_insn "*clrmem_short"
963fc8d0 3282 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
a41c6c53 3283 (const_int 0))
963fc8d0
AK
3284 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
3285 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
1eae36f0 3286 (clobber (match_scratch:P 3 "=X,X,X,&a"))
ae156f85 3287 (clobber (reg:CC CC_REGNUM))]
1eae36f0 3288 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)"
9bb86f41 3289 "#"
963fc8d0 3290 [(set_attr "type" "cs")
b5e0425c 3291 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
9bb86f41
UW
3292
3293(define_split
3294 [(set (match_operand:BLK 0 "memory_operand" "")
3295 (const_int 0))
3296 (use (match_operand 1 "const_int_operand" ""))
3297 (use (match_operand 2 "immediate_operand" ""))
3298 (clobber (scratch))
ae156f85 3299 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3300 "reload_completed"
3301 [(parallel
3302 [(set (match_dup 0) (const_int 0))
3303 (use (match_dup 1))
ae156f85 3304 (clobber (reg:CC CC_REGNUM))])]
9bb86f41 3305 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
9db1d521 3306
9bb86f41
UW
3307(define_split
3308 [(set (match_operand:BLK 0 "memory_operand" "")
3309 (const_int 0))
3310 (use (match_operand 1 "register_operand" ""))
3311 (use (match_operand 2 "memory_operand" ""))
3312 (clobber (scratch))
ae156f85 3313 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3314 "reload_completed"
3315 [(parallel
3316 [(unspec [(match_dup 1) (match_dup 2)
3317 (const_int 0)] UNSPEC_EXECUTE)
3318 (set (match_dup 0) (const_int 0))
3319 (use (const_int 1))
ae156f85 3320 (clobber (reg:CC CC_REGNUM))])]
9bb86f41 3321 "")
9db1d521 3322
963fc8d0
AK
3323(define_split
3324 [(set (match_operand:BLK 0 "memory_operand" "")
3325 (const_int 0))
3326 (use (match_operand 1 "register_operand" ""))
3327 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3328 (clobber (scratch))
3329 (clobber (reg:CC CC_REGNUM))]
3330 "TARGET_Z10 && reload_completed"
3331 [(parallel
3332 [(unspec [(match_dup 1) (const_int 0)
3333 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3334 (set (match_dup 0) (const_int 0))
3335 (use (const_int 1))
3336 (clobber (reg:CC CC_REGNUM))])]
3337 "operands[3] = gen_label_rtx ();")
3338
9bb86f41
UW
3339(define_split
3340 [(set (match_operand:BLK 0 "memory_operand" "")
3341 (const_int 0))
3342 (use (match_operand 1 "register_operand" ""))
3343 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3344 (clobber (match_operand 2 "register_operand" ""))
ae156f85 3345 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3346 "reload_completed && TARGET_CPU_ZARCH"
3347 [(set (match_dup 2) (label_ref (match_dup 3)))
3348 (parallel
9381e3f1 3349 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
9bb86f41
UW
3350 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3351 (set (match_dup 0) (const_int 0))
3352 (use (const_int 1))
ae156f85 3353 (clobber (reg:CC CC_REGNUM))])]
9bb86f41
UW
3354 "operands[3] = gen_label_rtx ();")
3355
9381e3f1 3356; Initialize a block of arbitrary length with (operands[2] % 256).
b9404c99 3357
da0dcab1 3358(define_expand "setmem_long_<P:mode>"
b9404c99
UW
3359 [(parallel
3360 [(clobber (match_dup 1))
3361 (set (match_operand:BLK 0 "memory_operand" "")
dd95128b 3362 (unspec:BLK [(match_operand:P 2 "setmem_operand" "")
da0dcab1 3363 (match_dup 4)] UNSPEC_REPLICATE_BYTE))
6d057022 3364 (use (match_dup 3))
ae156f85 3365 (clobber (reg:CC CC_REGNUM))])]
b9404c99 3366 ""
a41c6c53 3367{
ef4bddc2
RS
3368 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3369 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
3370 rtx reg0 = gen_reg_rtx (dreg_mode);
3371 rtx reg1 = gen_reg_rtx (dreg_mode);
3372 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
b9404c99 3373 rtx len0 = gen_lowpart (Pmode, reg0);
9db1d521 3374
c41c1387 3375 emit_clobber (reg0);
b9404c99
UW
3376 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3377 emit_move_insn (len0, operands[1]);
9db1d521 3378
b9404c99 3379 emit_move_insn (reg1, const0_rtx);
a41c6c53 3380
b9404c99
UW
3381 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3382 operands[1] = reg0;
6d057022 3383 operands[3] = reg1;
da0dcab1 3384 operands[4] = gen_lowpart (Pmode, operands[1]);
b9404c99 3385})
a41c6c53 3386
da0dcab1
DV
3387; Patterns for 31 bit + Esa and 64 bit + Zarch.
3388
db340c73 3389(define_insn "*setmem_long"
a1aed706 3390 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
6d057022 3391 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
dd95128b 3392 (unspec:BLK [(match_operand:P 2 "setmem_operand" "Y")
da0dcab1
DV
3393 (subreg:P (match_dup 3) <modesize>)]
3394 UNSPEC_REPLICATE_BYTE))
a1aed706 3395 (use (match_operand:<DBL> 1 "register_operand" "d"))
ae156f85 3396 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3397 "TARGET_64BIT || !TARGET_ZARCH"
6d057022 3398 "mvcle\t%0,%1,%Y2\;jo\t.-4"
b628bd8e
UW
3399 [(set_attr "length" "8")
3400 (set_attr "type" "vs")])
9db1d521 3401
db340c73
AK
3402(define_insn "*setmem_long_and"
3403 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3404 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
d876f5cd 3405 (unspec:BLK [(zero_extend:P (match_operand:QI 2 "setmem_operand" "Y"))
db340c73
AK
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))]
d876f5cd 3410 "(TARGET_64BIT || !TARGET_ZARCH)"
db340c73
AK
3411 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3412 [(set_attr "length" "8")
3413 (set_attr "type" "vs")])
3414
da0dcab1
DV
3415; Variants for 31 bit + Zarch, necessary because of the odd in-register offsets
3416; of the SImode subregs.
3417
db340c73 3418(define_insn "*setmem_long_31z"
9602b6a1
AK
3419 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3420 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
dd95128b 3421 (unspec:BLK [(match_operand:SI 2 "setmem_operand" "Y")
da0dcab1 3422 (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
9602b6a1
AK
3423 (use (match_operand:TI 1 "register_operand" "d"))
3424 (clobber (reg:CC CC_REGNUM))]
3425 "!TARGET_64BIT && TARGET_ZARCH"
4989e88a
AK
3426 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3427 [(set_attr "length" "8")
3428 (set_attr "type" "vs")])
9602b6a1 3429
db340c73
AK
3430(define_insn "*setmem_long_and_31z"
3431 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3432 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
d876f5cd 3433 (unspec:BLK [(zero_extend:SI (match_operand:QI 2 "setmem_operand" "Y"))
db340c73
AK
3434 (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
3435 (use (match_operand:TI 1 "register_operand" "d"))
3436 (clobber (reg:CC CC_REGNUM))]
d876f5cd 3437 "(!TARGET_64BIT && TARGET_ZARCH)"
db340c73
AK
3438 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3439 [(set_attr "length" "8")
3440 (set_attr "type" "vs")])
3441
9db1d521 3442;
358b8f01 3443; cmpmemM instruction pattern(s).
9db1d521
HP
3444;
3445
358b8f01 3446(define_expand "cmpmemsi"
a41c6c53
UW
3447 [(set (match_operand:SI 0 "register_operand" "")
3448 (compare:SI (match_operand:BLK 1 "memory_operand" "")
3449 (match_operand:BLK 2 "memory_operand" "") ) )
3450 (use (match_operand:SI 3 "general_operand" ""))
3451 (use (match_operand:SI 4 "" ""))]
3452 ""
367d32f3
AK
3453{
3454 if (s390_expand_cmpmem (operands[0], operands[1],
3455 operands[2], operands[3]))
3456 DONE;
3457 else
3458 FAIL;
3459})
9db1d521 3460
a41c6c53
UW
3461; Compare a block that is up to 256 bytes in length.
3462; The block length is taken as (operands[2] % 256) + 1.
9db1d521 3463
b9404c99
UW
3464(define_expand "cmpmem_short"
3465 [(parallel
ae156f85 3466 [(set (reg:CCU CC_REGNUM)
5b022de5 3467 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
b9404c99
UW
3468 (match_operand:BLK 1 "memory_operand" "")))
3469 (use (match_operand 2 "nonmemory_operand" ""))
9bb86f41 3470 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99
UW
3471 (clobber (match_dup 3))])]
3472 ""
3473 "operands[3] = gen_rtx_SCRATCH (Pmode);")
9db1d521 3474
b9404c99 3475(define_insn "*cmpmem_short"
ae156f85 3476 [(set (reg:CCU CC_REGNUM)
963fc8d0
AK
3477 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
3478 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
3479 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3480 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
1eae36f0
AK
3481 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3482 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
9bb86f41 3483 "#"
963fc8d0 3484 [(set_attr "type" "cs")
b5e0425c 3485 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
9db1d521 3486
9bb86f41 3487(define_split
ae156f85 3488 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3489 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3490 (match_operand:BLK 1 "memory_operand" "")))
3491 (use (match_operand 2 "const_int_operand" ""))
3492 (use (match_operand 3 "immediate_operand" ""))
3493 (clobber (scratch))]
3494 "reload_completed"
3495 [(parallel
ae156f85 3496 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3497 (use (match_dup 2))])]
3498 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
9db1d521 3499
9bb86f41 3500(define_split
ae156f85 3501 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3502 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3503 (match_operand:BLK 1 "memory_operand" "")))
3504 (use (match_operand 2 "register_operand" ""))
3505 (use (match_operand 3 "memory_operand" ""))
3506 (clobber (scratch))]
3507 "reload_completed"
3508 [(parallel
3509 [(unspec [(match_dup 2) (match_dup 3)
3510 (const_int 0)] UNSPEC_EXECUTE)
ae156f85 3511 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3512 (use (const_int 1))])]
3513 "")
3514
963fc8d0
AK
3515(define_split
3516 [(set (reg:CCU CC_REGNUM)
3517 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3518 (match_operand:BLK 1 "memory_operand" "")))
3519 (use (match_operand 2 "register_operand" ""))
3520 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3521 (clobber (scratch))]
3522 "TARGET_Z10 && reload_completed"
3523 [(parallel
3524 [(unspec [(match_dup 2) (const_int 0)
3525 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3526 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3527 (use (const_int 1))])]
3528 "operands[4] = gen_label_rtx ();")
3529
9bb86f41 3530(define_split
ae156f85 3531 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3532 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3533 (match_operand:BLK 1 "memory_operand" "")))
3534 (use (match_operand 2 "register_operand" ""))
3535 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3536 (clobber (match_operand 3 "register_operand" ""))]
3537 "reload_completed && TARGET_CPU_ZARCH"
3538 [(set (match_dup 3) (label_ref (match_dup 4)))
3539 (parallel
9381e3f1 3540 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
9bb86f41 3541 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
ae156f85 3542 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3543 (use (const_int 1))])]
3544 "operands[4] = gen_label_rtx ();")
3545
a41c6c53 3546; Compare a block of arbitrary length.
9db1d521 3547
b9404c99
UW
3548(define_expand "cmpmem_long"
3549 [(parallel
3550 [(clobber (match_dup 2))
3551 (clobber (match_dup 3))
ae156f85 3552 (set (reg:CCU CC_REGNUM)
5b022de5 3553 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
b9404c99
UW
3554 (match_operand:BLK 1 "memory_operand" "")))
3555 (use (match_operand 2 "general_operand" ""))
3556 (use (match_dup 3))])]
3557 ""
3558{
ef4bddc2
RS
3559 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3560 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
3561 rtx reg0 = gen_reg_rtx (dreg_mode);
3562 rtx reg1 = gen_reg_rtx (dreg_mode);
3563 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3564 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
b9404c99
UW
3565 rtx len0 = gen_lowpart (Pmode, reg0);
3566 rtx len1 = gen_lowpart (Pmode, reg1);
3567
c41c1387 3568 emit_clobber (reg0);
b9404c99
UW
3569 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3570 emit_move_insn (len0, operands[2]);
3571
c41c1387 3572 emit_clobber (reg1);
b9404c99
UW
3573 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3574 emit_move_insn (len1, operands[2]);
3575
3576 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3577 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3578 operands[2] = reg0;
3579 operands[3] = reg1;
3580})
3581
a1aed706
AS
3582(define_insn "*cmpmem_long"
3583 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3584 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
ae156f85 3585 (set (reg:CCU CC_REGNUM)
a1aed706
AS
3586 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3587 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
f8766020
HP
3588 (use (match_dup 2))
3589 (use (match_dup 3))]
9602b6a1 3590 "TARGET_64BIT || !TARGET_ZARCH"
287ff198 3591 "clcle\t%0,%1,0\;jo\t.-4"
b628bd8e
UW
3592 [(set_attr "length" "8")
3593 (set_attr "type" "vs")])
9db1d521 3594
9602b6a1
AK
3595(define_insn "*cmpmem_long_31z"
3596 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3597 (clobber (match_operand:TI 1 "register_operand" "=d"))
3598 (set (reg:CCU CC_REGNUM)
3599 (compare:CCU (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3600 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4))))
3601 (use (match_dup 2))
3602 (use (match_dup 3))]
3603 "!TARGET_64BIT && TARGET_ZARCH"
3604 "clcle\t%0,%1,0\;jo\t.-4"
3605 [(set_attr "op_type" "NN")
3606 (set_attr "type" "vs")
3607 (set_attr "length" "8")])
3608
02887425
UW
3609; Convert CCUmode condition code to integer.
3610; Result is zero if EQ, positive if LTU, negative if GTU.
9db1d521 3611
02887425 3612(define_insn_and_split "cmpint"
9db1d521 3613 [(set (match_operand:SI 0 "register_operand" "=d")
02887425 3614 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3615 UNSPEC_STRCMPCC_TO_INT))
ae156f85 3616 (clobber (reg:CC CC_REGNUM))]
9db1d521 3617 ""
02887425
UW
3618 "#"
3619 "reload_completed"
3620 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3621 (parallel
3622 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
ae156f85 3623 (clobber (reg:CC CC_REGNUM))])])
02887425
UW
3624
3625(define_insn_and_split "*cmpint_cc"
ae156f85 3626 [(set (reg CC_REGNUM)
02887425 3627 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3628 UNSPEC_STRCMPCC_TO_INT)
02887425
UW
3629 (const_int 0)))
3630 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3631 (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT))]
02887425
UW
3632 "s390_match_ccmode (insn, CCSmode)"
3633 "#"
3634 "&& reload_completed"
3635 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3636 (parallel
3637 [(set (match_dup 2) (match_dup 3))
3638 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
9db1d521 3639{
02887425
UW
3640 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3641 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3642 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3643})
9db1d521 3644
02887425 3645(define_insn_and_split "*cmpint_sign"
9db1d521 3646 [(set (match_operand:DI 0 "register_operand" "=d")
02887425 3647 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3648 UNSPEC_STRCMPCC_TO_INT)))
ae156f85 3649 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3650 "TARGET_ZARCH"
02887425
UW
3651 "#"
3652 "&& reload_completed"
3653 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3654 (parallel
3655 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
ae156f85 3656 (clobber (reg:CC CC_REGNUM))])])
02887425
UW
3657
3658(define_insn_and_split "*cmpint_sign_cc"
ae156f85 3659 [(set (reg CC_REGNUM)
9381e3f1 3660 (compare (ashiftrt:DI (ashift:DI (subreg:DI
02887425 3661 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3662 UNSPEC_STRCMPCC_TO_INT) 0)
02887425
UW
3663 (const_int 32)) (const_int 32))
3664 (const_int 0)))
3665 (set (match_operand:DI 0 "register_operand" "=d")
5a3fe9b6 3666 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT)))]
9602b6a1 3667 "s390_match_ccmode (insn, CCSmode) && TARGET_ZARCH"
02887425
UW
3668 "#"
3669 "&& reload_completed"
3670 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3671 (parallel
3672 [(set (match_dup 2) (match_dup 3))
3673 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
9db1d521 3674{
02887425
UW
3675 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3676 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3677 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3678})
9db1d521 3679
4023fb28 3680
9db1d521
HP
3681;;
3682;;- Conversion instructions.
3683;;
3684
6fa05db6 3685(define_insn "*sethighpartsi"
d3632d41 3686 [(set (match_operand:SI 0 "register_operand" "=d,d")
6fa05db6
AS
3687 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3688 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
ae156f85 3689 (clobber (reg:CC CC_REGNUM))]
4023fb28 3690 ""
d3632d41 3691 "@
6fa05db6
AS
3692 icm\t%0,%2,%S1
3693 icmy\t%0,%2,%S1"
9381e3f1 3694 [(set_attr "op_type" "RS,RSY")
3e4be43f 3695 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 3696 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4023fb28 3697
6fa05db6 3698(define_insn "*sethighpartdi_64"
4023fb28 3699 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 3700 (unspec:DI [(match_operand:BLK 1 "s_operand" "S")
6fa05db6 3701 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
ae156f85 3702 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3703 "TARGET_ZARCH"
6fa05db6 3704 "icmh\t%0,%2,%S1"
729e750f
WG
3705 [(set_attr "op_type" "RSY")
3706 (set_attr "z10prop" "z10_super")])
4023fb28 3707
6fa05db6 3708(define_insn "*sethighpartdi_31"
d3632d41 3709 [(set (match_operand:DI 0 "register_operand" "=d,d")
6fa05db6
AS
3710 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3711 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
ae156f85 3712 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3713 "!TARGET_ZARCH"
d3632d41 3714 "@
6fa05db6
AS
3715 icm\t%0,%2,%S1
3716 icmy\t%0,%2,%S1"
9381e3f1 3717 [(set_attr "op_type" "RS,RSY")
3e4be43f 3718 (set_attr "cpu_facility" "*,longdisp")
9381e3f1
WG
3719 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3720
1a2e356e
RH
3721;
3722; extv instruction patterns
3723;
3724
3725; FIXME: This expander needs to be converted from DI to GPR as well
3726; after resolving some issues with it.
3727
3728(define_expand "extzv"
3729 [(parallel
3730 [(set (match_operand:DI 0 "register_operand" "=d")
3731 (zero_extract:DI
3732 (match_operand:DI 1 "register_operand" "d")
3733 (match_operand 2 "const_int_operand" "") ; size
3734 (match_operand 3 "const_int_operand" ""))) ; start
3735 (clobber (reg:CC CC_REGNUM))])]
3736 "TARGET_Z10"
3737{
0f6f72e8
DV
3738 if (! EXTRACT_ARGS_IN_RANGE (INTVAL (operands[2]), INTVAL (operands[3]), 64))
3739 FAIL;
1a2e356e
RH
3740 /* Starting with zEC12 there is risbgn not clobbering CC. */
3741 if (TARGET_ZEC12)
3742 {
3743 emit_move_insn (operands[0],
3744 gen_rtx_ZERO_EXTRACT (DImode,
3745 operands[1],
3746 operands[2],
3747 operands[3]));
3748 DONE;
3749 }
3750})
3751
64c744b9 3752(define_insn "*extzv<mode><clobbercc_or_nocc>"
1a2e356e
RH
3753 [(set (match_operand:GPR 0 "register_operand" "=d")
3754 (zero_extract:GPR
3755 (match_operand:GPR 1 "register_operand" "d")
3756 (match_operand 2 "const_int_operand" "") ; size
64c744b9
DV
3757 (match_operand 3 "const_int_operand" ""))) ; start
3758 ]
0f6f72e8
DV
3759 "<z10_or_zEC12_cond>
3760 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[2]), INTVAL (operands[3]),
3761 GET_MODE_BITSIZE (<MODE>mode))"
64c744b9
DV
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>
0f6f72e8 3774 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
64c744b9
DV
3775 && 64 - UINTVAL (operands[4]) >= UINTVAL (operands[1])"
3776 "<risbg_n>\t%0,%3,%2,%2+%1-1,128-%2-%1-%4"
3777 [(set_attr "op_type" "RIE")
3778 (set_attr "z10prop" "z10_super_E1")])
3779
3780; 32 bit: (a & -16) | ((b >> 8) & 15)
3781(define_insn "*<risbg_n>_ior_and_sr_ze"
3782 [(set (match_operand:SI 0 "register_operand" "=d")
3783 (ior:SI (and:SI
3784 (match_operand:SI 1 "register_operand" "0")
3785 (match_operand:SI 2 "const_int_operand" ""))
3786 (subreg:SI
3787 (zero_extract:DI
3788 (match_operand:DI 3 "register_operand" "d")
3789 (match_operand 4 "const_int_operand" "") ; size
3790 (match_operand 5 "const_int_operand" "")) ; start
3791 4)))]
3792 "<z10_or_zEC12_cond>
0f6f72e8 3793 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[4]), INTVAL (operands[5]), 64)
64c744b9
DV
3794 && UINTVAL (operands[2]) == (~(0ULL) << UINTVAL (operands[4]))"
3795 "<risbg_n>\t%0,%3,64-%4,63,%4+%5"
3796 [(set_attr "op_type" "RIE")
3797 (set_attr "z10prop" "z10_super_E1")])
3798
3799; ((int)foo >> 10) & 1;
3800(define_insn "*extract1bitdi<clobbercc_or_nocc>"
3801 [(set (match_operand:DI 0 "register_operand" "=d")
3802 (ne:DI (zero_extract:DI
3803 (match_operand:DI 1 "register_operand" "d")
3804 (const_int 1) ; size
3805 (match_operand 2 "const_int_operand" "")) ; start
3806 (const_int 0)))]
0f6f72e8
DV
3807 "<z10_or_zEC12_cond>
3808 && EXTRACT_ARGS_IN_RANGE (1, INTVAL (operands[2]), 64)"
64c744b9
DV
3809 "<risbg_n>\t%0,%1,64-1,128+63,%2+1" ; dst, src, start, end, shift
3810 [(set_attr "op_type" "RIE")
3811 (set_attr "z10prop" "z10_super_E1")])
3812
3813(define_insn "*<risbg_n>_and_subregdi_rotr"
3814 [(set (match_operand:DI 0 "register_operand" "=d")
3815 (and:DI (subreg:DI
3816 (rotate:SINT (match_operand:SINT 1 "register_operand" "d")
3817 (match_operand:SINT 2 "const_int_operand" "")) 0)
3818 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3819 "<z10_or_zEC12_cond>
3820 && UINTVAL (operands[3]) < (1ULL << (UINTVAL (operands[2]) & 0x3f))"
3821 "<risbg_n>\t%0,%1,%s3,128+%e3,<bitoff_plus>%2" ; dst, src, start, end, shift
3822 [(set_attr "op_type" "RIE")
3823 (set_attr "z10prop" "z10_super_E1")])
3824
3825(define_insn "*<risbg_n>_and_subregdi_rotl"
3826 [(set (match_operand:DI 0 "register_operand" "=d")
3827 (and:DI (subreg:DI
3828 (rotate:SINT (match_operand:SINT 1 "register_operand" "d")
3829 (match_operand:SINT 2 "const_int_operand" "")) 0)
3830 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3831 "<z10_or_zEC12_cond>
3832 && !(UINTVAL (operands[3]) & ((1ULL << (UINTVAL (operands[2]) & 0x3f)) - 1))"
3833 "<risbg_n>\t%0,%1,%s3,128+%e3,%2" ; dst, src, start, end, shift
3834 [(set_attr "op_type" "RIE")
3835 (set_attr "z10prop" "z10_super_E1")])
3836
3837(define_insn "*<risbg_n>_di_and_rot"
3838 [(set (match_operand:DI 0 "register_operand" "=d")
3839 (and:DI (rotate:DI (match_operand:DI 1 "register_operand" "d")
3840 (match_operand:DI 2 "const_int_operand" ""))
3841 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3842 "<z10_or_zEC12_cond>"
3843 "<risbg_n>\t%0,%1,%s3,128+%e3,%2" ; dst, src, start, end, shift
1a2e356e
RH
3844 [(set_attr "op_type" "RIE")
3845 (set_attr "z10prop" "z10_super_E1")])
4023fb28 3846
1a2e356e 3847(define_insn_and_split "*pre_z10_extzv<mode>"
6fa05db6 3848 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 3849 (zero_extract:GPR (match_operand:QI 1 "s_operand" "S")
1a2e356e 3850 (match_operand 2 "nonzero_shift_count_operand" "")
6fa05db6 3851 (const_int 0)))
ae156f85 3852 (clobber (reg:CC CC_REGNUM))]
1a2e356e 3853 "!TARGET_Z10"
cc7ab9b7
UW
3854 "#"
3855 "&& reload_completed"
4023fb28 3856 [(parallel
6fa05db6 3857 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
ae156f85 3858 (clobber (reg:CC CC_REGNUM))])
6fa05db6 3859 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
4023fb28 3860{
6fa05db6
AS
3861 int bitsize = INTVAL (operands[2]);
3862 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3863 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3864
3865 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 3866 set_mem_size (operands[1], size);
2542ef05 3867 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
6fa05db6 3868 operands[3] = GEN_INT (mask);
b628bd8e 3869})
4023fb28 3870
1a2e356e 3871(define_insn_and_split "*pre_z10_extv<mode>"
6fa05db6 3872 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 3873 (sign_extract:GPR (match_operand:QI 1 "s_operand" "S")
1a2e356e 3874 (match_operand 2 "nonzero_shift_count_operand" "")
6fa05db6 3875 (const_int 0)))
ae156f85 3876 (clobber (reg:CC CC_REGNUM))]
1a2e356e 3877 ""
cc7ab9b7
UW
3878 "#"
3879 "&& reload_completed"
4023fb28 3880 [(parallel
6fa05db6 3881 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
ae156f85 3882 (clobber (reg:CC CC_REGNUM))])
6fa05db6
AS
3883 (parallel
3884 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3885 (clobber (reg:CC CC_REGNUM))])]
3886{
3887 int bitsize = INTVAL (operands[2]);
3888 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3889 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3890
3891 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 3892 set_mem_size (operands[1], size);
2542ef05 3893 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
6fa05db6
AS
3894 operands[3] = GEN_INT (mask);
3895})
3896
3897;
3898; insv instruction patterns
3899;
3900
3901(define_expand "insv"
3902 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3903 (match_operand 1 "const_int_operand" "")
3904 (match_operand 2 "const_int_operand" ""))
3905 (match_operand 3 "general_operand" ""))]
3906 ""
4023fb28 3907{
6fa05db6
AS
3908 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3909 DONE;
3910 FAIL;
b628bd8e 3911})
4023fb28 3912
2542ef05
RH
3913
3914; The normal RTL expansion will never generate a zero_extract where
3915; the location operand isn't word mode. However, we do this in the
3916; back-end when generating atomic operations. See s390_two_part_insv.
64c744b9 3917(define_insn "*insv<mode><clobbercc_or_nocc>"
22ac2c2f 3918 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
2542ef05
RH
3919 (match_operand 1 "const_int_operand" "I") ; size
3920 (match_operand 2 "const_int_operand" "I")) ; pos
22ac2c2f 3921 (match_operand:GPR 3 "nonimmediate_operand" "d"))]
64c744b9 3922 "<z10_or_zEC12_cond>
0f6f72e8
DV
3923 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]),
3924 GET_MODE_BITSIZE (<MODE>mode))
2542ef05 3925 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
64c744b9 3926 "<risbg_n>\t%0,%3,<bitoff_plus>%2,<bitoff_plus>%2+%1-1,<bitsize>-%2-%1"
9381e3f1
WG
3927 [(set_attr "op_type" "RIE")
3928 (set_attr "z10prop" "z10_super_E1")])
963fc8d0 3929
22ac2c2f
AK
3930; and op1 with a mask being 1 for the selected bits and 0 for the rest
3931; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
64c744b9
DV
3932(define_insn "*insv<mode><clobbercc_or_nocc>_noshift"
3933 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d")
3934 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d,0")
75ca1b39 3935 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
64c744b9 3936 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0,d")
75ca1b39 3937 (match_operand:GPR 4 "const_int_operand" ""))))]
64c744b9
DV
3938 "<z10_or_zEC12_cond> && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3939 "@
3940 <risbg_n>\t%0,%1,%<bfstart>2,%<bfend>2,0
3941 <risbg_n>\t%0,%3,%<bfstart>4,%<bfend>4,0"
3942 [(set_attr "op_type" "RIE")
3943 (set_attr "z10prop" "z10_super_E1")])
22ac2c2f 3944
64c744b9
DV
3945(define_insn "*insv_z10_noshift_cc"
3946 [(set (reg CC_REGNUM)
3947 (compare
3948 (ior:DI
3949 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,0")
3950 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
3951 (and:DI (match_operand:DI 3 "nonimmediate_operand" "0,d")
3952 (match_operand:DI 4 "const_int_operand" "")))
3953 (const_int 0)))
3954 (set (match_operand:DI 0 "nonimmediate_operand" "=d,d")
3955 (ior:DI (and:DI (match_dup 1) (match_dup 2))
3956 (and:DI (match_dup 3) (match_dup 4))))]
3957 "TARGET_Z10 && s390_match_ccmode (insn, CCSmode)
3958 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3959 "@
3960 risbg\t%0,%1,%s2,%e2,0
3961 risbg\t%0,%3,%s4,%e4,0"
3962 [(set_attr "op_type" "RIE")
3963 (set_attr "z10prop" "z10_super_E1")])
3964
3965(define_insn "*insv_z10_noshift_cconly"
3966 [(set
3967 (reg CC_REGNUM)
3968 (compare
3969 (ior:DI
3970 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,0")
3971 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
3972 (and:DI (match_operand:DI 3 "nonimmediate_operand" "0,d")
3973 (match_operand:DI 4 "const_int_operand" "")))
3974 (const_int 0)))
3975 (clobber (match_scratch:DI 0 "=d,d"))]
3976 "TARGET_Z10 && s390_match_ccmode (insn, CCSmode)
3977 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3978 "@
3979 risbg\t%0,%1,%s2,%e2,0
3980 risbg\t%0,%3,%s4,%e4,0"
9381e3f1
WG
3981 [(set_attr "op_type" "RIE")
3982 (set_attr "z10prop" "z10_super_E1")])
963fc8d0 3983
3d44ff99
AK
3984; Implement appending Y on the left of S bits of X
3985; x = (y << s) | (x & ((1 << s) - 1))
64c744b9 3986(define_insn "*insv<mode><clobbercc_or_nocc>_appendbitsleft"
3d44ff99
AK
3987 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3988 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "0")
3989 (match_operand:GPR 2 "immediate_operand" ""))
3990 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "d")
3991 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
64c744b9
DV
3992 "<z10_or_zEC12_cond>
3993 && UINTVAL (operands[2]) == (1UL << UINTVAL (operands[4])) - 1"
3994 "<risbg_n>\t%0,%3,<bitoff>,64-%4-1,%4"
3d44ff99
AK
3995 [(set_attr "op_type" "RIE")
3996 (set_attr "z10prop" "z10_super_E1")])
3997
64c744b9
DV
3998; a = ((i32)a & -16777216) | (((ui32)b) >> 8)
3999(define_insn "*<risbg_n>_<mode>_ior_and_lshiftrt"
4000 [(set (match_operand:GPR 0 "register_operand" "=d")
4001 (ior:GPR (and:GPR
4002 (match_operand:GPR 1 "register_operand" "0")
4003 (match_operand:GPR 2 "const_int_operand" ""))
4004 (lshiftrt:GPR
4005 (match_operand:GPR 3 "register_operand" "d")
4006 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4007 "<z10_or_zEC12_cond> && UINTVAL (operands[2])
4008 == (~(0ULL) << (GET_MODE_BITSIZE (<MODE>mode) - UINTVAL (operands[4])))"
4009 "<risbg_n>\t%0,%3,<bitoff_plus>%4,63,64-%4"
4010 [(set_attr "op_type" "RIE")
4011 (set_attr "z10prop" "z10_super_E1")])
4012
4013; (ui32)(((ui64)x) >> 48) | ((i32)y & -65536);
4014(define_insn "*<risbg_n>_sidi_ior_and_lshiftrt"
4015 [(set (match_operand:SI 0 "register_operand" "=d")
4016 (ior:SI (and:SI
4017 (match_operand:SI 1 "register_operand" "0")
4018 (match_operand:SI 2 "const_int_operand" ""))
4019 (subreg:SI
4020 (lshiftrt:DI
4021 (match_operand:DI 3 "register_operand" "d")
4022 (match_operand:DI 4 "nonzero_shift_count_operand" "")) 4)))]
4023 "<z10_or_zEC12_cond>
4024 && UINTVAL (operands[2]) == ~(~(0ULL) >> UINTVAL (operands[4]))"
4025 "<risbg_n>\t%0,%3,%4,63,64-%4"
4026 [(set_attr "op_type" "RIE")
4027 (set_attr "z10prop" "z10_super_E1")])
4028
4029; (ui32)(((ui64)x) >> 12) & -4
4030(define_insn "*trunc_sidi_and_subreg_lshrt<clobbercc_or_nocc>"
4031 [(set (match_operand:SI 0 "register_operand" "=d")
4032 (and:SI
4033 (subreg:SI (lshiftrt:DI
4034 (match_operand:DI 1 "register_operand" "d")
4035 (match_operand:DI 2 "nonzero_shift_count_operand" "")) 4)
4036 (match_operand:SI 3 "contiguous_bitmask_nowrap_operand" "")))]
4037 "<z10_or_zEC12_cond>"
4038 "<risbg_n>\t%0,%1,%t3,128+%f3,64-%2"
3d44ff99
AK
4039 [(set_attr "op_type" "RIE")
4040 (set_attr "z10prop" "z10_super_E1")])
4041
4042; z = (x << c) | (y >> d) with (x << c) and (y >> d) not overlapping after shifting
4043; -> z = y >> d; z = (x << c) | (z & ((1 << c) - 1))
4044; -> z = y >> d; z = risbg;
4045
4046(define_split
4047 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
4048 (ior:GPR (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
4049 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4050 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "")
4051 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4052 "TARGET_ZEC12 && UINTVAL (operands[2]) + UINTVAL (operands[4]) >= <bitsize>"
1d11f7ce 4053 [(set (match_dup 6)
3d44ff99
AK
4054 (lshiftrt:GPR (match_dup 1) (match_dup 2)))
4055 (set (match_dup 0)
1d11f7ce 4056 (ior:GPR (and:GPR (match_dup 6) (match_dup 5))
3d44ff99
AK
4057 (ashift:GPR (match_dup 3) (match_dup 4))))]
4058{
4059 operands[5] = GEN_INT ((1UL << UINTVAL (operands[4])) - 1);
3168e073 4060 if (reg_overlap_mentioned_p (operands[0], operands[3]))
1d11f7ce
AK
4061 {
4062 if (!can_create_pseudo_p ())
4063 FAIL;
4064 operands[6] = gen_reg_rtx (<MODE>mode);
4065 }
4066 else
4067 operands[6] = operands[0];
3d44ff99
AK
4068})
4069
4070(define_split
4071 [(parallel
4072 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
4073 (ior:GPR (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
4074 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4075 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "")
4076 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))
4077 (clobber (reg:CC CC_REGNUM))])]
4078 "TARGET_Z10 && !TARGET_ZEC12 && UINTVAL (operands[2]) + UINTVAL (operands[4]) >= <bitsize>"
1d11f7ce 4079 [(set (match_dup 6)
3d44ff99
AK
4080 (lshiftrt:GPR (match_dup 1) (match_dup 2)))
4081 (parallel
4082 [(set (match_dup 0)
1d11f7ce 4083 (ior:GPR (and:GPR (match_dup 6) (match_dup 5))
3d44ff99
AK
4084 (ashift:GPR (match_dup 3) (match_dup 4))))
4085 (clobber (reg:CC CC_REGNUM))])]
4086{
4087 operands[5] = GEN_INT ((1UL << UINTVAL (operands[4])) - 1);
3168e073 4088 if (reg_overlap_mentioned_p (operands[0], operands[3]))
1d11f7ce
AK
4089 {
4090 if (!can_create_pseudo_p ())
4091 FAIL;
4092 operands[6] = gen_reg_rtx (<MODE>mode);
4093 }
4094 else
4095 operands[6] = operands[0];
3d44ff99
AK
4096})
4097
50dc4eed 4098; rosbg, rxsbg
571e408a 4099(define_insn "*r<noxa>sbg_<mode>_noshift"
963fc8d0 4100 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
571e408a
RH
4101 (IXOR:GPR
4102 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
4103 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
4104 (match_operand:GPR 3 "nonimmediate_operand" "0")))
963fc8d0 4105 (clobber (reg:CC CC_REGNUM))]
75ca1b39 4106 "TARGET_Z10"
571e408a
RH
4107 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
4108 [(set_attr "op_type" "RIE")])
4109
50dc4eed 4110; rosbg, rxsbg
571e408a
RH
4111(define_insn "*r<noxa>sbg_di_rotl"
4112 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4113 (IXOR:DI
4114 (and:DI
4115 (rotate:DI
4116 (match_operand:DI 1 "nonimmediate_operand" "d")
4117 (match_operand:DI 3 "const_int_operand" ""))
4118 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
4119 (match_operand:DI 4 "nonimmediate_operand" "0")))
4120 (clobber (reg:CC CC_REGNUM))]
4121 "TARGET_Z10"
4122 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%b3"
4123 [(set_attr "op_type" "RIE")])
4124
50dc4eed 4125; rosbg, rxsbg
f3d90045 4126(define_insn "*r<noxa>sbg_<mode>_srl_bitmask"
571e408a
RH
4127 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4128 (IXOR:GPR
4129 (and:GPR
4130 (lshiftrt:GPR
4131 (match_operand:GPR 1 "nonimmediate_operand" "d")
4132 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
ab4be5d1 4133 (match_operand:GPR 2 "contiguous_bitmask_nowrap_operand" ""))
571e408a
RH
4134 (match_operand:GPR 4 "nonimmediate_operand" "0")))
4135 (clobber (reg:CC CC_REGNUM))]
4136 "TARGET_Z10
4137 && s390_extzv_shift_ok (<bitsize>, 64 - INTVAL (operands[3]),
4138 INTVAL (operands[2]))"
4139 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,64-%3"
4140 [(set_attr "op_type" "RIE")])
4141
50dc4eed 4142; rosbg, rxsbg
f3d90045 4143(define_insn "*r<noxa>sbg_<mode>_sll_bitmask"
571e408a
RH
4144 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4145 (IXOR:GPR
4146 (and:GPR
4147 (ashift:GPR
4148 (match_operand:GPR 1 "nonimmediate_operand" "d")
4149 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
ab4be5d1 4150 (match_operand:GPR 2 "contiguous_bitmask_nowrap_operand" ""))
571e408a
RH
4151 (match_operand:GPR 4 "nonimmediate_operand" "0")))
4152 (clobber (reg:CC CC_REGNUM))]
4153 "TARGET_Z10
4154 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[3]),
4155 INTVAL (operands[2]))"
4156 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%3"
963fc8d0
AK
4157 [(set_attr "op_type" "RIE")])
4158
f3d90045
DV
4159;; unsigned {int,long} a, b
4160;; a = a | (b << const_int)
4161;; a = a ^ (b << const_int)
50dc4eed 4162; rosbg, rxsbg
f3d90045
DV
4163(define_insn "*r<noxa>sbg_<mode>_sll"
4164 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4165 (IXOR:GPR
4166 (ashift:GPR
4167 (match_operand:GPR 1 "nonimmediate_operand" "d")
4168 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4169 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4170 (clobber (reg:CC CC_REGNUM))]
4171 "TARGET_Z10"
576987fc 4172 "r<noxa>sbg\t%0,%1,<bitoff>,63-%2,%2"
f3d90045
DV
4173 [(set_attr "op_type" "RIE")])
4174
4175;; unsigned {int,long} a, b
4176;; a = a | (b >> const_int)
4177;; a = a ^ (b >> const_int)
50dc4eed 4178; rosbg, rxsbg
f3d90045
DV
4179(define_insn "*r<noxa>sbg_<mode>_srl"
4180 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4181 (IXOR:GPR
4182 (lshiftrt:GPR
4183 (match_operand:GPR 1 "nonimmediate_operand" "d")
4184 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4185 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4186 (clobber (reg:CC CC_REGNUM))]
4187 "TARGET_Z10"
576987fc 4188 "r<noxa>sbg\t%0,%1,<bitoff_plus>%2,63,64-%2"
f3d90045
DV
4189 [(set_attr "op_type" "RIE")])
4190
5bb33936
RH
4191;; These two are generated by combine for s.bf &= val.
4192;; ??? For bitfields smaller than 32-bits, we wind up with SImode
4193;; shifts and ands, which results in some truly awful patterns
4194;; including subregs of operations. Rather unnecessisarily, IMO.
4195;; Instead of
4196;;
4197;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
4198;; (const_int 24 [0x18])
4199;; (const_int 0 [0]))
4200;; (subreg:DI (and:SI (subreg:SI (lshiftrt:DI (reg/v:DI 50 [ s ])
4201;; (const_int 40 [0x28])) 4)
4202;; (reg:SI 4 %r4 [ y+4 ])) 0))
4203;;
4204;; we should instead generate
4205;;
4206;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
4207;; (const_int 24 [0x18])
4208;; (const_int 0 [0]))
4209;; (and:DI (lshiftrt:DI (reg/v:DI 50 [ s ])
4210;; (const_int 40 [0x28]))
4211;; (subreg:DI (reg:SI 4 %r4 [ y+4 ]) 0)))
4212;;
4213;; by noticing that we can push down the outer paradoxical subreg
4214;; into the operation.
4215
4216(define_insn "*insv_rnsbg_noshift"
4217 [(set (zero_extract:DI
4218 (match_operand:DI 0 "nonimmediate_operand" "+d")
4219 (match_operand 1 "const_int_operand" "")
4220 (match_operand 2 "const_int_operand" ""))
4221 (and:DI
4222 (match_dup 0)
4223 (match_operand:DI 3 "nonimmediate_operand" "d")))
4224 (clobber (reg:CC CC_REGNUM))]
4225 "TARGET_Z10
0f6f72e8 4226 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
5bb33936
RH
4227 && INTVAL (operands[1]) + INTVAL (operands[2]) == 64"
4228 "rnsbg\t%0,%3,%2,63,0"
4229 [(set_attr "op_type" "RIE")])
4230
4231(define_insn "*insv_rnsbg_srl"
4232 [(set (zero_extract:DI
4233 (match_operand:DI 0 "nonimmediate_operand" "+d")
4234 (match_operand 1 "const_int_operand" "")
4235 (match_operand 2 "const_int_operand" ""))
4236 (and:DI
4237 (lshiftrt:DI
4238 (match_dup 0)
4239 (match_operand 3 "const_int_operand" ""))
4240 (match_operand:DI 4 "nonimmediate_operand" "d")))
4241 (clobber (reg:CC CC_REGNUM))]
4242 "TARGET_Z10
0f6f72e8 4243 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
5bb33936
RH
4244 && INTVAL (operands[3]) == 64 - INTVAL (operands[1]) - INTVAL (operands[2])"
4245 "rnsbg\t%0,%4,%2,%2+%1-1,%3"
4246 [(set_attr "op_type" "RIE")])
4247
6fa05db6 4248(define_insn "*insv<mode>_mem_reg"
9602b6a1 4249 [(set (zero_extract:W (match_operand:QI 0 "memory_operand" "+Q,S")
6fa05db6
AS
4250 (match_operand 1 "const_int_operand" "n,n")
4251 (const_int 0))
9602b6a1 4252 (match_operand:W 2 "register_operand" "d,d"))]
0f6f72e8
DV
4253 "EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), 0, 64)
4254 && INTVAL (operands[1]) > 0
6fa05db6
AS
4255 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
4256 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
4257{
4258 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
4259
4260 operands[1] = GEN_INT ((1ul << size) - 1);
9381e3f1 4261 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
6fa05db6
AS
4262 : "stcmy\t%2,%1,%S0";
4263}
9381e3f1 4264 [(set_attr "op_type" "RS,RSY")
3e4be43f 4265 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 4266 (set_attr "z10prop" "z10_super,z10_super")])
6fa05db6
AS
4267
4268(define_insn "*insvdi_mem_reghigh"
3e4be43f 4269 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+S")
6fa05db6
AS
4270 (match_operand 1 "const_int_operand" "n")
4271 (const_int 0))
4272 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
4273 (const_int 32)))]
9602b6a1 4274 "TARGET_ZARCH
0f6f72e8 4275 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), 0, 64)
6fa05db6
AS
4276 && INTVAL (operands[1]) > 0
4277 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
4278 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
4279{
4280 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
4281
4282 operands[1] = GEN_INT ((1ul << size) - 1);
4283 return "stcmh\t%2,%1,%S0";
4284}
9381e3f1
WG
4285[(set_attr "op_type" "RSY")
4286 (set_attr "z10prop" "z10_super")])
6fa05db6 4287
9602b6a1
AK
4288(define_insn "*insvdi_reg_imm"
4289 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4290 (const_int 16)
4291 (match_operand 1 "const_int_operand" "n"))
4292 (match_operand:DI 2 "const_int_operand" "n"))]
6fa05db6 4293 "TARGET_ZARCH
0f6f72e8 4294 && EXTRACT_ARGS_IN_RANGE (16, INTVAL (operands[1]), 64)
6fa05db6
AS
4295 && INTVAL (operands[1]) >= 0
4296 && INTVAL (operands[1]) < BITS_PER_WORD
4297 && INTVAL (operands[1]) % 16 == 0"
4298{
4299 switch (BITS_PER_WORD - INTVAL (operands[1]))
4300 {
4301 case 64: return "iihh\t%0,%x2"; break;
4302 case 48: return "iihl\t%0,%x2"; break;
4303 case 32: return "iilh\t%0,%x2"; break;
4304 case 16: return "iill\t%0,%x2"; break;
4305 default: gcc_unreachable();
4306 }
4307}
9381e3f1
WG
4308 [(set_attr "op_type" "RI")
4309 (set_attr "z10prop" "z10_super_E1")])
4310
9fec758d
WG
4311; Update the left-most 32 bit of a DI.
4312(define_insn "*insv_h_di_reg_extimm"
4313 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4314 (const_int 32)
4315 (const_int 0))
4316 (match_operand:DI 1 "const_int_operand" "n"))]
4317 "TARGET_EXTIMM"
4318 "iihf\t%0,%o1"
4319 [(set_attr "op_type" "RIL")
4320 (set_attr "z10prop" "z10_fwd_E1")])
6fa05db6 4321
d378b983
RH
4322; Update the right-most 32 bit of a DI.
4323(define_insn "*insv_l_di_reg_extimm"
4324 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4325 (const_int 32)
4326 (const_int 32))
4327 (match_operand:DI 1 "const_int_operand" "n"))]
4328 "TARGET_EXTIMM"
4329 "iilf\t%0,%o1"
9381e3f1 4330 [(set_attr "op_type" "RIL")
9fec758d 4331 (set_attr "z10prop" "z10_fwd_A1")])
6fa05db6 4332
9db1d521
HP
4333;
4334; extendsidi2 instruction pattern(s).
4335;
4336
4023fb28
UW
4337(define_expand "extendsidi2"
4338 [(set (match_operand:DI 0 "register_operand" "")
4339 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
4340 ""
4023fb28 4341{
9602b6a1 4342 if (!TARGET_ZARCH)
4023fb28 4343 {
c41c1387 4344 emit_clobber (operands[0]);
9f37ccb1
UW
4345 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
4346 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
4347 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
4023fb28
UW
4348 DONE;
4349 }
ec24698e 4350})
4023fb28
UW
4351
4352(define_insn "*extendsidi2"
963fc8d0 4353 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3e4be43f 4354 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,T,b")))]
9602b6a1 4355 "TARGET_ZARCH"
9db1d521 4356 "@
d40c829f 4357 lgfr\t%0,%1
963fc8d0
AK
4358 lgf\t%0,%1
4359 lgfrl\t%0,%1"
4360 [(set_attr "op_type" "RRE,RXY,RIL")
4361 (set_attr "type" "*,*,larl")
9381e3f1
WG
4362 (set_attr "cpu_facility" "*,*,z10")
4363 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 4364
9db1d521 4365;
56477c21 4366; extend(hi|qi)(si|di)2 instruction pattern(s).
9db1d521
HP
4367;
4368
56477c21
AS
4369(define_expand "extend<HQI:mode><DSI:mode>2"
4370 [(set (match_operand:DSI 0 "register_operand" "")
4371 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4023fb28 4372 ""
4023fb28 4373{
9602b6a1 4374 if (<DSI:MODE>mode == DImode && !TARGET_ZARCH)
4023fb28
UW
4375 {
4376 rtx tmp = gen_reg_rtx (SImode);
56477c21 4377 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
4023fb28
UW
4378 emit_insn (gen_extendsidi2 (operands[0], tmp));
4379 DONE;
4380 }
ec24698e 4381 else if (!TARGET_EXTIMM)
4023fb28 4382 {
2542ef05 4383 rtx bitcount = GEN_INT (<DSI:bitsize> - <HQI:bitsize>);
56477c21
AS
4384
4385 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
4386 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
4387 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
4023fb28
UW
4388 DONE;
4389 }
ec24698e
UW
4390})
4391
56477c21
AS
4392;
4393; extendhidi2 instruction pattern(s).
4394;
4395
ec24698e 4396(define_insn "*extendhidi2_extimm"
963fc8d0 4397 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3e4be43f 4398 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,T,b")))]
9602b6a1 4399 "TARGET_ZARCH && TARGET_EXTIMM"
ec24698e
UW
4400 "@
4401 lghr\t%0,%1
963fc8d0
AK
4402 lgh\t%0,%1
4403 lghrl\t%0,%1"
4404 [(set_attr "op_type" "RRE,RXY,RIL")
4405 (set_attr "type" "*,*,larl")
9381e3f1
WG
4406 (set_attr "cpu_facility" "extimm,extimm,z10")
4407 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4023fb28
UW
4408
4409(define_insn "*extendhidi2"
9db1d521 4410 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 4411 (sign_extend:DI (match_operand:HI 1 "memory_operand" "T")))]
9602b6a1 4412 "TARGET_ZARCH"
d40c829f 4413 "lgh\t%0,%1"
9381e3f1
WG
4414 [(set_attr "op_type" "RXY")
4415 (set_attr "z10prop" "z10_super_E1")])
9db1d521 4416
9db1d521 4417;
56477c21 4418; extendhisi2 instruction pattern(s).
9db1d521
HP
4419;
4420
ec24698e 4421(define_insn "*extendhisi2_extimm"
963fc8d0
AK
4422 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4423 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
ec24698e
UW
4424 "TARGET_EXTIMM"
4425 "@
4426 lhr\t%0,%1
4427 lh\t%0,%1
963fc8d0
AK
4428 lhy\t%0,%1
4429 lhrl\t%0,%1"
4430 [(set_attr "op_type" "RRE,RX,RXY,RIL")
4431 (set_attr "type" "*,*,*,larl")
9381e3f1
WG
4432 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
4433 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 4434
4023fb28 4435(define_insn "*extendhisi2"
d3632d41
UW
4436 [(set (match_operand:SI 0 "register_operand" "=d,d")
4437 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
ec24698e 4438 "!TARGET_EXTIMM"
d3632d41 4439 "@
d40c829f
UW
4440 lh\t%0,%1
4441 lhy\t%0,%1"
9381e3f1 4442 [(set_attr "op_type" "RX,RXY")
3e4be43f 4443 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 4444 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521 4445
56477c21
AS
4446;
4447; extendqi(si|di)2 instruction pattern(s).
4448;
4449
43a09b63 4450; lbr, lgbr, lb, lgb
56477c21
AS
4451(define_insn "*extendqi<mode>2_extimm"
4452 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3e4be43f 4453 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,T")))]
ec24698e
UW
4454 "TARGET_EXTIMM"
4455 "@
56477c21
AS
4456 l<g>br\t%0,%1
4457 l<g>b\t%0,%1"
9381e3f1
WG
4458 [(set_attr "op_type" "RRE,RXY")
4459 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
ec24698e 4460
43a09b63 4461; lb, lgb
56477c21
AS
4462(define_insn "*extendqi<mode>2"
4463 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 4464 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "T")))]
56477c21
AS
4465 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
4466 "l<g>b\t%0,%1"
9381e3f1
WG
4467 [(set_attr "op_type" "RXY")
4468 (set_attr "z10prop" "z10_super_E1")])
d3632d41 4469
56477c21
AS
4470(define_insn_and_split "*extendqi<mode>2_short_displ"
4471 [(set (match_operand:GPR 0 "register_operand" "=d")
4472 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
ae156f85 4473 (clobber (reg:CC CC_REGNUM))]
56477c21 4474 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
19796784
AK
4475 "#"
4476 "&& reload_completed"
4023fb28 4477 [(parallel
56477c21 4478 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
ae156f85 4479 (clobber (reg:CC CC_REGNUM))])
4023fb28 4480 (parallel
56477c21 4481 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
ae156f85 4482 (clobber (reg:CC CC_REGNUM))])]
6fa05db6
AS
4483{
4484 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 4485 set_mem_size (operands[1], GET_MODE_SIZE (QImode));
2542ef05 4486 operands[2] = GEN_INT (<GPR:bitsize> - BITS_PER_UNIT);
6fa05db6 4487})
9db1d521 4488
9db1d521
HP
4489;
4490; zero_extendsidi2 instruction pattern(s).
4491;
4492
4023fb28
UW
4493(define_expand "zero_extendsidi2"
4494 [(set (match_operand:DI 0 "register_operand" "")
4495 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
4496 ""
4023fb28 4497{
9602b6a1 4498 if (!TARGET_ZARCH)
4023fb28 4499 {
c41c1387 4500 emit_clobber (operands[0]);
9f37ccb1
UW
4501 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
4502 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
4023fb28
UW
4503 DONE;
4504 }
ec24698e 4505})
4023fb28
UW
4506
4507(define_insn "*zero_extendsidi2"
963fc8d0 4508 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3e4be43f 4509 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,T,b")))]
9602b6a1 4510 "TARGET_ZARCH"
9db1d521 4511 "@
d40c829f 4512 llgfr\t%0,%1
963fc8d0
AK
4513 llgf\t%0,%1
4514 llgfrl\t%0,%1"
4515 [(set_attr "op_type" "RRE,RXY,RIL")
4516 (set_attr "type" "*,*,larl")
9381e3f1
WG
4517 (set_attr "cpu_facility" "*,*,z10")
4518 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
9db1d521 4519
288e517f
AK
4520;
4521; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
4522;
4523
d6083c7d
UW
4524(define_insn "*llgt_sidi"
4525 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 4526 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "T") 0)
d6083c7d 4527 (const_int 2147483647)))]
9602b6a1 4528 "TARGET_ZARCH"
d6083c7d 4529 "llgt\t%0,%1"
9381e3f1
WG
4530 [(set_attr "op_type" "RXE")
4531 (set_attr "z10prop" "z10_super_E1")])
d6083c7d
UW
4532
4533(define_insn_and_split "*llgt_sidi_split"
4534 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 4535 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "T") 0)
d6083c7d 4536 (const_int 2147483647)))
ae156f85 4537 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4538 "TARGET_ZARCH"
d6083c7d
UW
4539 "#"
4540 "&& reload_completed"
4541 [(set (match_dup 0)
4542 (and:DI (subreg:DI (match_dup 1) 0)
4543 (const_int 2147483647)))]
4544 "")
4545
288e517f
AK
4546(define_insn "*llgt_sisi"
4547 [(set (match_operand:SI 0 "register_operand" "=d,d")
3e4be43f 4548 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,T")
288e517f 4549 (const_int 2147483647)))]
c4d50129 4550 "TARGET_ZARCH"
288e517f
AK
4551 "@
4552 llgtr\t%0,%1
4553 llgt\t%0,%1"
9381e3f1
WG
4554 [(set_attr "op_type" "RRE,RXE")
4555 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
288e517f 4556
288e517f
AK
4557(define_insn "*llgt_didi"
4558 [(set (match_operand:DI 0 "register_operand" "=d,d")
4559 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
4560 (const_int 2147483647)))]
9602b6a1 4561 "TARGET_ZARCH"
288e517f
AK
4562 "@
4563 llgtr\t%0,%1
4564 llgt\t%0,%N1"
9381e3f1
WG
4565 [(set_attr "op_type" "RRE,RXE")
4566 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
288e517f 4567
f19a9af7 4568(define_split
9602b6a1
AK
4569 [(set (match_operand:DSI 0 "register_operand" "")
4570 (and:DSI (match_operand:DSI 1 "nonimmediate_operand" "")
f6ee577c 4571 (const_int 2147483647)))
ae156f85 4572 (clobber (reg:CC CC_REGNUM))]
c4d50129 4573 "TARGET_ZARCH && reload_completed"
288e517f 4574 [(set (match_dup 0)
9602b6a1 4575 (and:DSI (match_dup 1)
f6ee577c 4576 (const_int 2147483647)))]
288e517f
AK
4577 "")
4578
9db1d521 4579;
56477c21 4580; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
9db1d521
HP
4581;
4582
56477c21
AS
4583(define_expand "zero_extend<mode>di2"
4584 [(set (match_operand:DI 0 "register_operand" "")
4585 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4586 ""
4587{
9602b6a1 4588 if (!TARGET_ZARCH)
56477c21
AS
4589 {
4590 rtx tmp = gen_reg_rtx (SImode);
4591 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
4592 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
4593 DONE;
4594 }
4595 else if (!TARGET_EXTIMM)
4596 {
2542ef05 4597 rtx bitcount = GEN_INT (64 - <HQI:bitsize>);
56477c21
AS
4598 operands[1] = gen_lowpart (DImode, operands[1]);
4599 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
4600 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
4601 DONE;
4602 }
4603})
4604
f6ee577c 4605(define_expand "zero_extend<mode>si2"
4023fb28 4606 [(set (match_operand:SI 0 "register_operand" "")
ec24698e 4607 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
9db1d521 4608 ""
4023fb28 4609{
ec24698e
UW
4610 if (!TARGET_EXTIMM)
4611 {
4612 operands[1] = gen_lowpart (SImode, operands[1]);
9381e3f1 4613 emit_insn (gen_andsi3 (operands[0], operands[1],
2542ef05 4614 GEN_INT ((1 << <HQI:bitsize>) - 1)));
ec24698e 4615 DONE;
56477c21 4616 }
ec24698e
UW
4617})
4618
963fc8d0
AK
4619; llhrl, llghrl
4620(define_insn "*zero_extendhi<mode>2_z10"
4621 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
3e4be43f 4622 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,T,b")))]
963fc8d0
AK
4623 "TARGET_Z10"
4624 "@
4625 ll<g>hr\t%0,%1
4626 ll<g>h\t%0,%1
4627 ll<g>hrl\t%0,%1"
4628 [(set_attr "op_type" "RXY,RRE,RIL")
4629 (set_attr "type" "*,*,larl")
9381e3f1 4630 (set_attr "cpu_facility" "*,*,z10")
729e750f 4631 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
963fc8d0 4632
43a09b63 4633; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
56477c21
AS
4634(define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
4635 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3e4be43f 4636 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,T")))]
ec24698e
UW
4637 "TARGET_EXTIMM"
4638 "@
56477c21
AS
4639 ll<g><hc>r\t%0,%1
4640 ll<g><hc>\t%0,%1"
9381e3f1
WG
4641 [(set_attr "op_type" "RRE,RXY")
4642 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
9db1d521 4643
43a09b63 4644; llgh, llgc
56477c21
AS
4645(define_insn "*zero_extend<HQI:mode><GPR:mode>2"
4646 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 4647 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "T")))]
ec24698e 4648 "TARGET_ZARCH && !TARGET_EXTIMM"
f6ee577c 4649 "llg<hc>\t%0,%1"
9381e3f1
WG
4650 [(set_attr "op_type" "RXY")
4651 (set_attr "z10prop" "z10_fwd_A3")])
cc7ab9b7
UW
4652
4653(define_insn_and_split "*zero_extendhisi2_31"
4654 [(set (match_operand:SI 0 "register_operand" "=&d")
3e4be43f 4655 (zero_extend:SI (match_operand:HI 1 "s_operand" "S")))
ae156f85 4656 (clobber (reg:CC CC_REGNUM))]
f4f41b4e 4657 "!TARGET_ZARCH"
cc7ab9b7
UW
4658 "#"
4659 "&& reload_completed"
4660 [(set (match_dup 0) (const_int 0))
4661 (parallel
4662 [(set (strict_low_part (match_dup 2)) (match_dup 1))
ae156f85 4663 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 4664 "operands[2] = gen_lowpart (HImode, operands[0]);")
c7453384 4665
cc7ab9b7
UW
4666(define_insn_and_split "*zero_extendqisi2_31"
4667 [(set (match_operand:SI 0 "register_operand" "=&d")
3e4be43f 4668 (zero_extend:SI (match_operand:QI 1 "memory_operand" "T")))]
9e8327e3 4669 "!TARGET_ZARCH"
cc7ab9b7
UW
4670 "#"
4671 "&& reload_completed"
4672 [(set (match_dup 0) (const_int 0))
4673 (set (strict_low_part (match_dup 2)) (match_dup 1))]
b628bd8e 4674 "operands[2] = gen_lowpart (QImode, operands[0]);")
c7453384 4675
9db1d521
HP
4676;
4677; zero_extendqihi2 instruction pattern(s).
4678;
4679
9db1d521
HP
4680(define_expand "zero_extendqihi2"
4681 [(set (match_operand:HI 0 "register_operand" "")
4023fb28 4682 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
ec24698e 4683 "TARGET_ZARCH && !TARGET_EXTIMM"
9db1d521 4684{
4023fb28
UW
4685 operands[1] = gen_lowpart (HImode, operands[1]);
4686 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
4687 DONE;
ec24698e 4688})
9db1d521 4689
4023fb28 4690(define_insn "*zero_extendqihi2_64"
9db1d521 4691 [(set (match_operand:HI 0 "register_operand" "=d")
3e4be43f 4692 (zero_extend:HI (match_operand:QI 1 "memory_operand" "T")))]
ec24698e 4693 "TARGET_ZARCH && !TARGET_EXTIMM"
d40c829f 4694 "llgc\t%0,%1"
9381e3f1
WG
4695 [(set_attr "op_type" "RXY")
4696 (set_attr "z10prop" "z10_fwd_A3")])
9db1d521 4697
cc7ab9b7
UW
4698(define_insn_and_split "*zero_extendqihi2_31"
4699 [(set (match_operand:HI 0 "register_operand" "=&d")
3e4be43f 4700 (zero_extend:HI (match_operand:QI 1 "memory_operand" "T")))]
9e8327e3 4701 "!TARGET_ZARCH"
cc7ab9b7
UW
4702 "#"
4703 "&& reload_completed"
4704 [(set (match_dup 0) (const_int 0))
4705 (set (strict_low_part (match_dup 2)) (match_dup 1))]
b628bd8e 4706 "operands[2] = gen_lowpart (QImode, operands[0]);")
cc7ab9b7 4707
609e7e80
AK
4708;
4709; fixuns_trunc(dd|td)di2 instruction pattern(s).
4710;
4711
4712(define_expand "fixuns_truncdddi2"
4713 [(parallel
4714 [(set (match_operand:DI 0 "register_operand" "")
4715 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
ae8e301e 4716 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
65b1d8ea 4717 (clobber (reg:CC CC_REGNUM))])]
9381e3f1 4718
fb068247 4719 "TARGET_HARD_DFP"
609e7e80 4720{
65b1d8ea
AK
4721 if (!TARGET_Z196)
4722 {
19f8b229
TS
4723 rtx_code_label *label1 = gen_label_rtx ();
4724 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4725 rtx temp = gen_reg_rtx (TDmode);
4726 REAL_VALUE_TYPE cmp, sub;
4727
4728 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4729 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4730
4731 /* 2^63 can't be represented as 64bit DFP number with full precision. The
4732 solution is doing the check and the subtraction in TD mode and using a
4733 TD -> DI convert afterwards. */
4734 emit_insn (gen_extendddtd2 (temp, operands[1]));
4735 temp = force_reg (TDmode, temp);
4736 emit_cmp_and_jump_insns (temp,
555affd7 4737 const_double_from_real_value (cmp, TDmode),
65b1d8ea
AK
4738 LT, NULL_RTX, VOIDmode, 0, label1);
4739 emit_insn (gen_subtd3 (temp, temp,
555affd7 4740 const_double_from_real_value (sub, TDmode)));
ae8e301e
AK
4741 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp,
4742 GEN_INT (DFP_RND_TOWARD_MINF)));
65b1d8ea
AK
4743 emit_jump (label2);
4744
4745 emit_label (label1);
ae8e301e
AK
4746 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1],
4747 GEN_INT (DFP_RND_TOWARD_0)));
65b1d8ea
AK
4748 emit_label (label2);
4749 DONE;
4750 }
609e7e80
AK
4751})
4752
4753(define_expand "fixuns_trunctddi2"
65b1d8ea
AK
4754 [(parallel
4755 [(set (match_operand:DI 0 "register_operand" "")
4756 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))
ae8e301e 4757 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
65b1d8ea
AK
4758 (clobber (reg:CC CC_REGNUM))])]
4759
fb068247 4760 "TARGET_HARD_DFP"
609e7e80 4761{
65b1d8ea
AK
4762 if (!TARGET_Z196)
4763 {
19f8b229
TS
4764 rtx_code_label *label1 = gen_label_rtx ();
4765 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4766 rtx temp = gen_reg_rtx (TDmode);
4767 REAL_VALUE_TYPE cmp, sub;
4768
4769 operands[1] = force_reg (TDmode, operands[1]);
4770 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4771 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4772
4773 emit_cmp_and_jump_insns (operands[1],
555affd7 4774 const_double_from_real_value (cmp, TDmode),
65b1d8ea
AK
4775 LT, NULL_RTX, VOIDmode, 0, label1);
4776 emit_insn (gen_subtd3 (temp, operands[1],
555affd7 4777 const_double_from_real_value (sub, TDmode)));
ae8e301e
AK
4778 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp,
4779 GEN_INT (DFP_RND_TOWARD_MINF)));
65b1d8ea
AK
4780 emit_jump (label2);
4781
4782 emit_label (label1);
ae8e301e
AK
4783 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1],
4784 GEN_INT (DFP_RND_TOWARD_0)));
65b1d8ea
AK
4785 emit_label (label2);
4786 DONE;
4787 }
609e7e80 4788})
cc7ab9b7 4789
9db1d521 4790;
65b1d8ea 4791; fixuns_trunc(sf|df|tf)(si|di)2 and fix_trunc(sf|df|tf)(si|di)2
609e7e80 4792; instruction pattern(s).
9db1d521
HP
4793;
4794
7b6baae1 4795(define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
65b1d8ea
AK
4796 [(parallel
4797 [(set (match_operand:GPR 0 "register_operand" "")
4798 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))
ae8e301e 4799 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
65b1d8ea 4800 (clobber (reg:CC CC_REGNUM))])]
142cd70f 4801 "TARGET_HARD_FLOAT"
9db1d521 4802{
65b1d8ea
AK
4803 if (!TARGET_Z196)
4804 {
19f8b229
TS
4805 rtx_code_label *label1 = gen_label_rtx ();
4806 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4807 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
4808 REAL_VALUE_TYPE cmp, sub;
4809
4810 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
2542ef05
RH
4811 real_2expN (&cmp, <GPR:bitsize> - 1, <BFP:MODE>mode);
4812 real_2expN (&sub, <GPR:bitsize>, <BFP:MODE>mode);
65b1d8ea
AK
4813
4814 emit_cmp_and_jump_insns (operands[1],
555affd7 4815 const_double_from_real_value (cmp, <BFP:MODE>mode),
65b1d8ea
AK
4816 LT, NULL_RTX, VOIDmode, 0, label1);
4817 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
555affd7 4818 const_double_from_real_value (sub, <BFP:MODE>mode)));
65b1d8ea 4819 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
ae8e301e 4820 GEN_INT (BFP_RND_TOWARD_MINF)));
65b1d8ea
AK
4821 emit_jump (label2);
4822
4823 emit_label (label1);
4824 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
ae8e301e 4825 operands[1], GEN_INT (BFP_RND_TOWARD_0)));
65b1d8ea
AK
4826 emit_label (label2);
4827 DONE;
4828 }
10bbf137 4829})
9db1d521 4830
65b1d8ea
AK
4831; fixuns_trunc(td|dd)si2 expander
4832(define_expand "fixuns_trunc<mode>si2"
4833 [(parallel
4834 [(set (match_operand:SI 0 "register_operand" "")
4835 (unsigned_fix:SI (match_operand:DFP 1 "register_operand" "")))
ae8e301e 4836 (unspec:SI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
65b1d8ea 4837 (clobber (reg:CC CC_REGNUM))])]
8540e6e8 4838 "TARGET_Z196 && TARGET_HARD_DFP"
65b1d8ea
AK
4839 "")
4840
4841; fixuns_trunc(tf|df|sf|td|dd)(di|si)2 instruction patterns.
4842
6e5b5de8
AK
4843(define_insn "*fixuns_truncdfdi2_z13"
4844 [(set (match_operand:DI 0 "register_operand" "=d,v")
4845 (unsigned_fix:DI (match_operand:DF 1 "register_operand" "f,v")))
4846 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K,K")] UNSPEC_ROUND)
4847 (clobber (reg:CC CC_REGNUM))]
a579871b 4848 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
4849 "@
4850 clgdbr\t%0,%h2,%1,0
4851 wclgdb\t%v0,%v1,0,%h2"
4852 [(set_attr "op_type" "RRF,VRR")
4853 (set_attr "type" "ftoi")])
4854
65b1d8ea
AK
4855; clfebr, clfdbr, clfxbr, clgebr, clgdbr, clgxbr
4856; clfdtr, clfxtr, clgdtr, clgxtr
4857(define_insn "*fixuns_trunc<FP:mode><GPR:mode>2_z196"
6e5b5de8
AK
4858 [(set (match_operand:GPR 0 "register_operand" "=d")
4859 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "f")))
4860 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
65b1d8ea 4861 (clobber (reg:CC CC_REGNUM))]
6e5b5de8 4862 "TARGET_Z196 && TARGET_HARD_FLOAT
a579871b 4863 && (!TARGET_VX || <GPR:MODE>mode != DImode || <FP:MODE>mode != DFmode)"
65b1d8ea
AK
4864 "cl<GPR:gf><FP:xde><FP:bt>r\t%0,%h2,%1,0"
4865 [(set_attr "op_type" "RRF")
4866 (set_attr "type" "ftoi")])
4867
b60cb710
AK
4868(define_expand "fix_trunc<DSF:mode><GPR:mode>2"
4869 [(set (match_operand:GPR 0 "register_operand" "")
4870 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
4871 "TARGET_HARD_FLOAT"
9db1d521 4872{
b60cb710 4873 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
ae8e301e 4874 GEN_INT (BFP_RND_TOWARD_0)));
9db1d521 4875 DONE;
10bbf137 4876})
9db1d521 4877
6e5b5de8
AK
4878(define_insn "*fix_truncdfdi2_bfp_z13"
4879 [(set (match_operand:DI 0 "register_operand" "=d,v")
4880 (fix:DI (match_operand:DF 1 "register_operand" "f,v")))
4881 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K,K")] UNSPEC_ROUND)
4882 (clobber (reg:CC CC_REGNUM))]
a579871b 4883 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
4884 "@
4885 cgdbr\t%0,%h2,%1
4886 wcgdb\t%v0,%v1,0,%h2"
4887 [(set_attr "op_type" "RRE,VRR")
4888 (set_attr "type" "ftoi")])
4889
43a09b63 4890; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
6e5b5de8
AK
4891(define_insn "*fix_trunc<BFP:mode><GPR:mode>2_bfp"
4892 [(set (match_operand:GPR 0 "register_operand" "=d")
4893 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
4894 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
ae156f85 4895 (clobber (reg:CC CC_REGNUM))]
6e5b5de8
AK
4896 "TARGET_HARD_FLOAT
4897 && (!TARGET_VX || <GPR:MODE>mode != DImode || <BFP:MODE>mode != DFmode)"
7b6baae1 4898 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
9db1d521 4899 [(set_attr "op_type" "RRE")
077dab3b 4900 (set_attr "type" "ftoi")])
9db1d521 4901
6e5b5de8
AK
4902(define_expand "fix_trunc<BFP:mode><GPR:mode>2_bfp"
4903 [(parallel
4904 [(set (match_operand:GPR 0 "register_operand" "=d")
4905 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
4906 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4907 (clobber (reg:CC CC_REGNUM))])]
4908 "TARGET_HARD_FLOAT")
609e7e80
AK
4909;
4910; fix_trunc(td|dd)di2 instruction pattern(s).
4911;
4912
99cd7dd0
AK
4913(define_expand "fix_trunc<mode>di2"
4914 [(set (match_operand:DI 0 "register_operand" "")
4915 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
9602b6a1 4916 "TARGET_ZARCH && TARGET_HARD_DFP"
99cd7dd0
AK
4917{
4918 operands[1] = force_reg (<MODE>mode, operands[1]);
4919 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
ae8e301e 4920 GEN_INT (DFP_RND_TOWARD_0)));
99cd7dd0
AK
4921 DONE;
4922})
4923
609e7e80 4924; cgxtr, cgdtr
99cd7dd0 4925(define_insn "fix_trunc<DFP:mode>di2_dfp"
609e7e80
AK
4926 [(set (match_operand:DI 0 "register_operand" "=d")
4927 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
4928 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
4929 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4930 "TARGET_ZARCH && TARGET_HARD_DFP"
609e7e80
AK
4931 "cg<DFP:xde>tr\t%0,%h2,%1"
4932 [(set_attr "op_type" "RRF")
9381e3f1 4933 (set_attr "type" "ftoidfp")])
609e7e80
AK
4934
4935
f61a2c7d
AK
4936;
4937; fix_trunctf(si|di)2 instruction pattern(s).
4938;
4939
4940(define_expand "fix_trunctf<mode>2"
4941 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
4942 (fix:GPR (match_operand:TF 1 "register_operand" "")))
ae8e301e 4943 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
f61a2c7d 4944 (clobber (reg:CC CC_REGNUM))])]
9db1d521 4945 "TARGET_HARD_FLOAT"
142cd70f 4946 "")
9db1d521 4947
9db1d521 4948
9db1d521 4949;
142cd70f 4950; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
9db1d521
HP
4951;
4952
609e7e80 4953; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
f5905b37 4954(define_insn "floatdi<mode>2"
62d3f261
AK
4955 [(set (match_operand:FP 0 "register_operand" "=f,v")
4956 (float:FP (match_operand:DI 1 "register_operand" "d,v")))]
9602b6a1 4957 "TARGET_ZARCH && TARGET_HARD_FLOAT"
6e5b5de8
AK
4958 "@
4959 c<xde>g<bt>r\t%0,%1
4960 wcdgb\t%v0,%v1,0,0"
4961 [(set_attr "op_type" "RRE,VRR")
4962 (set_attr "type" "itof<mode>" )
62d3f261
AK
4963 (set_attr "cpu_facility" "*,vec")
4964 (set_attr "enabled" "*,<DFDI>")])
9db1d521 4965
43a09b63 4966; cxfbr, cdfbr, cefbr
142cd70f 4967(define_insn "floatsi<mode>2"
7b6baae1
AK
4968 [(set (match_operand:BFP 0 "register_operand" "=f")
4969 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
142cd70f 4970 "TARGET_HARD_FLOAT"
f61a2c7d
AK
4971 "c<xde>fbr\t%0,%1"
4972 [(set_attr "op_type" "RRE")
9381e3f1 4973 (set_attr "type" "itof<mode>" )])
f61a2c7d 4974
65b1d8ea
AK
4975; cxftr, cdftr
4976(define_insn "floatsi<mode>2"
4977 [(set (match_operand:DFP 0 "register_operand" "=f")
4978 (float:DFP (match_operand:SI 1 "register_operand" "d")))]
4979 "TARGET_Z196 && TARGET_HARD_FLOAT"
4980 "c<xde>ftr\t%0,0,%1,0"
4981 [(set_attr "op_type" "RRE")
4982 (set_attr "type" "itof<mode>" )])
4983
4984;
4985; floatuns(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
4986;
4987
6e5b5de8
AK
4988(define_insn "*floatunsdidf2_z13"
4989 [(set (match_operand:DF 0 "register_operand" "=f,v")
4990 (unsigned_float:DF (match_operand:DI 1 "register_operand" "d,v")))]
a579871b 4991 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
4992 "@
4993 cdlgbr\t%0,0,%1,0
4994 wcdlgb\t%v0,%v1,0,0"
4995 [(set_attr "op_type" "RRE,VRR")
4996 (set_attr "type" "itofdf")])
4997
65b1d8ea
AK
4998; cxlgbr, cdlgbr, celgbr, cxlgtr, cdlgtr
4999; cxlfbr, cdlfbr, celfbr, cxlftr, cdlftr
6e5b5de8
AK
5000(define_insn "*floatuns<GPR:mode><FP:mode>2"
5001 [(set (match_operand:FP 0 "register_operand" "=f")
5002 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "d")))]
5003 "TARGET_Z196 && TARGET_HARD_FLOAT
5004 && (!TARGET_VX || <FP:MODE>mode != DFmode || <GPR:MODE>mode != DImode)"
65b1d8ea
AK
5005 "c<FP:xde>l<GPR:gf><FP:bt>r\t%0,0,%1,0"
5006 [(set_attr "op_type" "RRE")
6e5b5de8
AK
5007 (set_attr "type" "itof<FP:mode>")])
5008
5009(define_expand "floatuns<GPR:mode><FP:mode>2"
5010 [(set (match_operand:FP 0 "register_operand" "")
5011 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "")))]
5012 "TARGET_Z196 && TARGET_HARD_FLOAT")
f61a2c7d 5013
9db1d521
HP
5014;
5015; truncdfsf2 instruction pattern(s).
5016;
5017
142cd70f 5018(define_insn "truncdfsf2"
6e5b5de8
AK
5019 [(set (match_operand:SF 0 "register_operand" "=f,v")
5020 (float_truncate:SF (match_operand:DF 1 "register_operand" "f,v")))]
142cd70f 5021 "TARGET_HARD_FLOAT"
6e5b5de8
AK
5022 "@
5023 ledbr\t%0,%1
5024 wledb\t%v0,%v1,0,0" ; IEEE inexact exception not suppressed
5025 ; According to BFP rounding mode
5026 [(set_attr "op_type" "RRE,VRR")
5027 (set_attr "type" "ftruncdf")
5028 (set_attr "cpu_facility" "*,vec")])
9db1d521 5029
f61a2c7d 5030;
142cd70f 5031; trunctf(df|sf)2 instruction pattern(s).
f61a2c7d
AK
5032;
5033
142cd70f
AK
5034; ldxbr, lexbr
5035(define_insn "trunctf<mode>2"
5036 [(set (match_operand:DSF 0 "register_operand" "=f")
5037 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
f61a2c7d 5038 (clobber (match_scratch:TF 2 "=f"))]
142cd70f
AK
5039 "TARGET_HARD_FLOAT"
5040 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
f61a2c7d 5041 [(set_attr "length" "6")
9381e3f1 5042 (set_attr "type" "ftrunctf")])
f61a2c7d 5043
609e7e80
AK
5044;
5045; trunctddd2 and truncddsd2 instruction pattern(s).
5046;
5047
432d4670
AK
5048
5049(define_expand "trunctddd2"
5050 [(parallel
5051 [(set (match_operand:DD 0 "register_operand" "")
5052 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
5053 (unspec:DI [(const_int DFP_RND_CURRENT)] UNSPEC_ROUND)
5054 (clobber (scratch:TD))])]
5055 "TARGET_HARD_DFP")
5056
5057(define_insn "*trunctddd2"
609e7e80 5058 [(set (match_operand:DD 0 "register_operand" "=f")
bf259a77 5059 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
432d4670
AK
5060 (unspec:DI [(match_operand:DI 2 "const_mask_operand" "I")] UNSPEC_ROUND)
5061 (clobber (match_scratch:TD 3 "=f"))]
fb068247 5062 "TARGET_HARD_DFP"
432d4670 5063 "ldxtr\t%3,%2,%1,0\;ldr\t%0,%3"
bf259a77 5064 [(set_attr "length" "6")
9381e3f1 5065 (set_attr "type" "ftruncdd")])
609e7e80
AK
5066
5067(define_insn "truncddsd2"
5068 [(set (match_operand:SD 0 "register_operand" "=f")
5069 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
fb068247 5070 "TARGET_HARD_DFP"
609e7e80
AK
5071 "ledtr\t%0,0,%1,0"
5072 [(set_attr "op_type" "RRF")
9381e3f1 5073 (set_attr "type" "ftruncsd")])
609e7e80 5074
feade5a8
AK
5075(define_expand "trunctdsd2"
5076 [(parallel
d5a216fa 5077 [(set (match_dup 2)
feade5a8 5078 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
432d4670 5079 (unspec:DI [(const_int DFP_RND_PREP_FOR_SHORT_PREC)] UNSPEC_ROUND)
d5a216fa 5080 (clobber (match_scratch:TD 3 ""))])
feade5a8 5081 (set (match_operand:SD 0 "register_operand" "")
d5a216fa 5082 (float_truncate:SD (match_dup 2)))]
feade5a8
AK
5083 "TARGET_HARD_DFP"
5084{
d5a216fa 5085 operands[2] = gen_reg_rtx (DDmode);
feade5a8
AK
5086})
5087
9db1d521 5088;
142cd70f 5089; extend(sf|df)(df|tf)2 instruction pattern(s).
f61a2c7d
AK
5090;
5091
6e5b5de8
AK
5092(define_insn "*extendsfdf2_z13"
5093 [(set (match_operand:DF 0 "register_operand" "=f,f,v")
5094 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R,v")))]
a579871b 5095 "TARGET_VX && TARGET_HARD_FLOAT"
6e5b5de8
AK
5096 "@
5097 ldebr\t%0,%1
5098 ldeb\t%0,%1
5099 wldeb\t%v0,%v1"
5100 [(set_attr "op_type" "RRE,RXE,VRR")
5101 (set_attr "type" "fsimpdf, floaddf,fsimpdf")])
5102
142cd70f 5103; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
6e5b5de8
AK
5104(define_insn "*extend<DSF:mode><BFP:mode>2"
5105 [(set (match_operand:BFP 0 "register_operand" "=f,f")
142cd70f
AK
5106 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
5107 "TARGET_HARD_FLOAT
6e5b5de8
AK
5108 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)
5109 && (!TARGET_VX || <BFP:MODE>mode != DFmode || <DSF:MODE>mode != SFmode)"
f61a2c7d 5110 "@
142cd70f
AK
5111 l<BFP:xde><DSF:xde>br\t%0,%1
5112 l<BFP:xde><DSF:xde>b\t%0,%1"
6e5b5de8
AK
5113 [(set_attr "op_type" "RRE,RXE")
5114 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
5115
5116(define_expand "extend<DSF:mode><BFP:mode>2"
5117 [(set (match_operand:BFP 0 "register_operand" "")
5118 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "")))]
5119 "TARGET_HARD_FLOAT
5120 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)")
f61a2c7d 5121
609e7e80
AK
5122;
5123; extendddtd2 and extendsddd2 instruction pattern(s).
5124;
5125
5126(define_insn "extendddtd2"
5127 [(set (match_operand:TD 0 "register_operand" "=f")
5128 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
fb068247 5129 "TARGET_HARD_DFP"
609e7e80
AK
5130 "lxdtr\t%0,%1,0"
5131 [(set_attr "op_type" "RRF")
5132 (set_attr "type" "fsimptf")])
5133
5134(define_insn "extendsddd2"
5135 [(set (match_operand:DD 0 "register_operand" "=f")
5136 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
fb068247 5137 "TARGET_HARD_DFP"
609e7e80
AK
5138 "ldetr\t%0,%1,0"
5139 [(set_attr "op_type" "RRF")
5140 (set_attr "type" "fsimptf")])
9db1d521 5141
feade5a8
AK
5142(define_expand "extendsdtd2"
5143 [(set (match_dup 2)
5144 (float_extend:DD (match_operand:SD 1 "register_operand" "")))
5145 (set (match_operand:TD 0 "register_operand" "")
5146 (float_extend:TD (match_dup 2)))]
5147 "TARGET_HARD_DFP"
5148{
5149 operands[2] = gen_reg_rtx (DDmode);
5150})
5151
d12a76f3
AK
5152; Binary Floating Point - load fp integer
5153
5154; Expanders for: floor, btrunc, round, ceil, and nearbyint
5155; For all of them the inexact exceptions are suppressed.
5156
5157; fiebra, fidbra, fixbra
5158(define_insn "<FPINT:fpint_name><BFP:mode>2"
5159 [(set (match_operand:BFP 0 "register_operand" "=f")
5160 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
5161 FPINT))]
5162 "TARGET_Z196"
5163 "fi<BFP:xde>bra\t%0,<FPINT:fpint_roundingmode>,%1,4"
5164 [(set_attr "op_type" "RRF")
5165 (set_attr "type" "fsimp<BFP:mode>")])
5166
5167; rint is supposed to raise an inexact exception so we can use the
5168; older instructions.
5169
5170; fiebr, fidbr, fixbr
5171(define_insn "rint<BFP:mode>2"
5172 [(set (match_operand:BFP 0 "register_operand" "=f")
5173 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
5174 UNSPEC_FPINT_RINT))]
5175 ""
5176 "fi<BFP:xde>br\t%0,0,%1"
5177 [(set_attr "op_type" "RRF")
5178 (set_attr "type" "fsimp<BFP:mode>")])
5179
5180
5181; Decimal Floating Point - load fp integer
5182
5183; fidtr, fixtr
5184(define_insn "<FPINT:fpint_name><DFP:mode>2"
5185 [(set (match_operand:DFP 0 "register_operand" "=f")
5186 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
5187 FPINT))]
5188 "TARGET_HARD_DFP"
5189 "fi<DFP:xde>tr\t%0,<FPINT:fpint_roundingmode>,%1,4"
5190 [(set_attr "op_type" "RRF")
5191 (set_attr "type" "fsimp<DFP:mode>")])
5192
5193; fidtr, fixtr
5194(define_insn "rint<DFP:mode>2"
5195 [(set (match_operand:DFP 0 "register_operand" "=f")
5196 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
5197 UNSPEC_FPINT_RINT))]
5198 "TARGET_HARD_DFP"
5199 "fi<DFP:xde>tr\t%0,0,%1,0"
5200 [(set_attr "op_type" "RRF")
5201 (set_attr "type" "fsimp<DFP:mode>")])
5202
5203;
35dd9a0e
AK
5204; Binary <-> Decimal floating point trunc patterns
5205;
5206
5207(define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
5208 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 5209 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e 5210 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5211 (clobber (reg:CC CC_REGNUM))
5212 (clobber (reg:SI GPR1_REGNUM))]
fb068247 5213 "TARGET_HARD_DFP"
35dd9a0e
AK
5214 "pfpo")
5215
5216(define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
5217 [(set (reg:BFP FPR0_REGNUM)
2cf4c39e 5218 (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e 5219 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5220 (clobber (reg:CC CC_REGNUM))
5221 (clobber (reg:SI GPR1_REGNUM))]
fb068247 5222 "TARGET_HARD_DFP"
35dd9a0e
AK
5223 "pfpo")
5224
5225(define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 5226 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
35dd9a0e
AK
5227 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5228 (parallel
5229 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 5230 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e 5231 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5232 (clobber (reg:CC CC_REGNUM))
5233 (clobber (reg:SI GPR1_REGNUM))])
35dd9a0e
AK
5234 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
5235 (reg:DFP_ALL FPR0_REGNUM))]
fb068247 5236 "TARGET_HARD_DFP
35dd9a0e
AK
5237 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
5238{
5239 HOST_WIDE_INT flags;
5240
5241 flags = (PFPO_CONVERT |
5242 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
5243 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
5244
5245 operands[2] = GEN_INT (flags);
5246})
5247
5248(define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 5249 [(set (reg:DFP_ALL FPR4_REGNUM)
35dd9a0e
AK
5250 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
5251 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5252 (parallel
2cf4c39e 5253 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e 5254 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5255 (clobber (reg:CC CC_REGNUM))
5256 (clobber (reg:SI GPR1_REGNUM))])
35dd9a0e 5257 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
fb068247 5258 "TARGET_HARD_DFP
35dd9a0e
AK
5259 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
5260{
5261 HOST_WIDE_INT flags;
5262
5263 flags = (PFPO_CONVERT |
5264 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
5265 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
5266
5267 operands[2] = GEN_INT (flags);
5268})
5269
5270;
5271; Binary <-> Decimal floating point extend patterns
5272;
5273
5274(define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 5275 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e 5276 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5277 (clobber (reg:CC CC_REGNUM))
5278 (clobber (reg:SI GPR1_REGNUM))]
fb068247 5279 "TARGET_HARD_DFP"
35dd9a0e
AK
5280 "pfpo")
5281
5282(define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 5283 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e 5284 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5285 (clobber (reg:CC CC_REGNUM))
5286 (clobber (reg:SI GPR1_REGNUM))]
fb068247 5287 "TARGET_HARD_DFP"
35dd9a0e
AK
5288 "pfpo")
5289
5290(define_expand "extend<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 5291 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
35dd9a0e
AK
5292 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5293 (parallel
5294 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 5295 (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e 5296 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5297 (clobber (reg:CC CC_REGNUM))
5298 (clobber (reg:SI GPR1_REGNUM))])
35dd9a0e
AK
5299 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
5300 (reg:DFP_ALL FPR0_REGNUM))]
fb068247 5301 "TARGET_HARD_DFP
35dd9a0e
AK
5302 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
5303{
5304 HOST_WIDE_INT flags;
5305
5306 flags = (PFPO_CONVERT |
5307 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
5308 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
5309
5310 operands[2] = GEN_INT (flags);
5311})
5312
5313(define_expand "extend<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 5314 [(set (reg:DFP_ALL FPR4_REGNUM)
35dd9a0e
AK
5315 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
5316 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5317 (parallel
2cf4c39e 5318 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e 5319 (use (reg:SI GPR0_REGNUM))
af344a30
DV
5320 (clobber (reg:CC CC_REGNUM))
5321 (clobber (reg:SI GPR1_REGNUM))])
35dd9a0e 5322 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
fb068247 5323 "TARGET_HARD_DFP
35dd9a0e
AK
5324 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
5325{
5326 HOST_WIDE_INT flags;
5327
5328 flags = (PFPO_CONVERT |
5329 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
5330 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
5331
5332 operands[2] = GEN_INT (flags);
5333})
5334
5335
9db1d521 5336;;
fae778eb 5337;; ARITHMETIC OPERATIONS
9db1d521 5338;;
fae778eb 5339; arithmetic operations set the ConditionCode,
9db1d521
HP
5340; because of unpredictable Bits in Register for Halfword and Byte
5341; the ConditionCode can be set wrong in operations for Halfword and Byte
5342
07893d4f
UW
5343;;
5344;;- Add instructions.
5345;;
5346
1c7b1b7e
UW
5347;
5348; addti3 instruction pattern(s).
5349;
5350
085261c8
AK
5351(define_expand "addti3"
5352 [(parallel
5353 [(set (match_operand:TI 0 "register_operand" "")
5354 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "")
5355 (match_operand:TI 2 "general_operand" "") ) )
5356 (clobber (reg:CC CC_REGNUM))])]
5357 "TARGET_ZARCH"
5358{
5359 /* For z13 we have vaq which doesn't set CC. */
5360 if (TARGET_VX)
5361 {
5362 emit_insn (gen_rtx_SET (operands[0],
5363 gen_rtx_PLUS (TImode,
5364 copy_to_mode_reg (TImode, operands[1]),
5365 copy_to_mode_reg (TImode, operands[2]))));
5366 DONE;
5367 }
5368})
5369
5370(define_insn_and_split "*addti3"
5371 [(set (match_operand:TI 0 "register_operand" "=&d")
1c7b1b7e 5372 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
085261c8 5373 (match_operand:TI 2 "general_operand" "do") ) )
ae156f85 5374 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5375 "TARGET_ZARCH"
1c7b1b7e
UW
5376 "#"
5377 "&& reload_completed"
5378 [(parallel
ae156f85 5379 [(set (reg:CCL1 CC_REGNUM)
1c7b1b7e
UW
5380 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
5381 (match_dup 7)))
5382 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
5383 (parallel
a94a76a7
UW
5384 [(set (match_dup 3) (plus:DI
5385 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
5386 (match_dup 4)) (match_dup 5)))
ae156f85 5387 (clobber (reg:CC CC_REGNUM))])]
1c7b1b7e
UW
5388 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
5389 operands[4] = operand_subword (operands[1], 0, 0, TImode);
5390 operands[5] = operand_subword (operands[2], 0, 0, TImode);
5391 operands[6] = operand_subword (operands[0], 1, 0, TImode);
5392 operands[7] = operand_subword (operands[1], 1, 0, TImode);
085261c8
AK
5393 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
5394 [(set_attr "op_type" "*")
5395 (set_attr "cpu_facility" "*")])
1c7b1b7e 5396
07893d4f
UW
5397;
5398; adddi3 instruction pattern(s).
5399;
5400
3298c037
AK
5401(define_expand "adddi3"
5402 [(parallel
963fc8d0 5403 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3298c037
AK
5404 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5405 (match_operand:DI 2 "general_operand" "")))
5406 (clobber (reg:CC CC_REGNUM))])]
5407 ""
5408 "")
5409
07893d4f
UW
5410(define_insn "*adddi3_sign"
5411 [(set (match_operand:DI 0 "register_operand" "=d,d")
3e4be43f 5412 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f 5413 (match_operand:DI 1 "register_operand" "0,0")))
ae156f85 5414 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5415 "TARGET_ZARCH"
07893d4f 5416 "@
d40c829f
UW
5417 agfr\t%0,%2
5418 agf\t%0,%2"
65b1d8ea
AK
5419 [(set_attr "op_type" "RRE,RXY")
5420 (set_attr "z196prop" "z196_cracked,z196_cracked")])
07893d4f
UW
5421
5422(define_insn "*adddi3_zero_cc"
ae156f85 5423 [(set (reg CC_REGNUM)
3e4be43f 5424 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f
UW
5425 (match_operand:DI 1 "register_operand" "0,0"))
5426 (const_int 0)))
5427 (set (match_operand:DI 0 "register_operand" "=d,d")
5428 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
9602b6a1 5429 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5430 "@
d40c829f
UW
5431 algfr\t%0,%2
5432 algf\t%0,%2"
9381e3f1
WG
5433 [(set_attr "op_type" "RRE,RXY")
5434 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f
UW
5435
5436(define_insn "*adddi3_zero_cconly"
ae156f85 5437 [(set (reg CC_REGNUM)
3e4be43f 5438 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f
UW
5439 (match_operand:DI 1 "register_operand" "0,0"))
5440 (const_int 0)))
5441 (clobber (match_scratch:DI 0 "=d,d"))]
9602b6a1 5442 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5443 "@
d40c829f
UW
5444 algfr\t%0,%2
5445 algf\t%0,%2"
9381e3f1
WG
5446 [(set_attr "op_type" "RRE,RXY")
5447 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f
UW
5448
5449(define_insn "*adddi3_zero"
5450 [(set (match_operand:DI 0 "register_operand" "=d,d")
3e4be43f 5451 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f 5452 (match_operand:DI 1 "register_operand" "0,0")))
ae156f85 5453 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5454 "TARGET_ZARCH"
07893d4f 5455 "@
d40c829f
UW
5456 algfr\t%0,%2
5457 algf\t%0,%2"
9381e3f1
WG
5458 [(set_attr "op_type" "RRE,RXY")
5459 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f 5460
e69166de 5461(define_insn_and_split "*adddi3_31z"
963fc8d0 5462 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
e69166de
UW
5463 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5464 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5465 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5466 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
e69166de
UW
5467 "#"
5468 "&& reload_completed"
5469 [(parallel
ae156f85 5470 [(set (reg:CCL1 CC_REGNUM)
e69166de
UW
5471 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
5472 (match_dup 7)))
5473 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
5474 (parallel
a94a76a7
UW
5475 [(set (match_dup 3) (plus:SI
5476 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
5477 (match_dup 4)) (match_dup 5)))
ae156f85 5478 (clobber (reg:CC CC_REGNUM))])]
e69166de
UW
5479 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5480 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5481 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5482 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5483 operands[7] = operand_subword (operands[1], 1, 0, DImode);
b628bd8e 5484 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
e69166de 5485
07893d4f 5486(define_insn_and_split "*adddi3_31"
963fc8d0 5487 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
96fd3851 5488 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
97c6f7ad 5489 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5490 (clobber (reg:CC CC_REGNUM))]
e69166de 5491 "!TARGET_CPU_ZARCH"
07893d4f
UW
5492 "#"
5493 "&& reload_completed"
5494 [(parallel
5495 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
ae156f85 5496 (clobber (reg:CC CC_REGNUM))])
07893d4f 5497 (parallel
ae156f85 5498 [(set (reg:CCL1 CC_REGNUM)
07893d4f
UW
5499 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
5500 (match_dup 7)))
5501 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
5502 (set (pc)
ae156f85 5503 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
07893d4f
UW
5504 (pc)
5505 (label_ref (match_dup 9))))
5506 (parallel
5507 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
ae156f85 5508 (clobber (reg:CC CC_REGNUM))])
07893d4f 5509 (match_dup 9)]
97c6f7ad
UW
5510 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5511 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5512 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5513 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5514 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5515 operands[8] = operand_subword (operands[2], 1, 0, DImode);
b628bd8e 5516 operands[9] = gen_label_rtx ();")
9db1d521 5517
3298c037
AK
5518;
5519; addsi3 instruction pattern(s).
5520;
5521
5522(define_expand "addsi3"
07893d4f 5523 [(parallel
963fc8d0 5524 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3298c037
AK
5525 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
5526 (match_operand:SI 2 "general_operand" "")))
ae156f85 5527 (clobber (reg:CC CC_REGNUM))])]
9db1d521 5528 ""
07893d4f 5529 "")
9db1d521 5530
3298c037
AK
5531(define_insn "*addsi3_sign"
5532 [(set (match_operand:SI 0 "register_operand" "=d,d")
5533 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5534 (match_operand:SI 1 "register_operand" "0,0")))
5535 (clobber (reg:CC CC_REGNUM))]
5536 ""
5537 "@
5538 ah\t%0,%2
5539 ahy\t%0,%2"
65b1d8ea 5540 [(set_attr "op_type" "RX,RXY")
3e4be43f 5541 (set_attr "cpu_facility" "*,longdisp")
65b1d8ea 5542 (set_attr "z196prop" "z196_cracked,z196_cracked")])
3298c037 5543
9db1d521 5544;
3298c037 5545; add(di|si)3 instruction pattern(s).
9db1d521 5546;
9db1d521 5547
65b1d8ea 5548; ark, agrk, ar, ahi, ahik, aghik, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
3298c037 5549(define_insn "*add<mode>3"
3e4be43f
UW
5550 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d, d, d,d,d,S")
5551 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,d, 0, 0,0,0,0")
5552 (match_operand:GPR 2 "general_operand" " d,d,K,K,Op,On,R,T,C") ) )
3298c037
AK
5553 (clobber (reg:CC CC_REGNUM))]
5554 ""
ec24698e 5555 "@
3298c037 5556 a<g>r\t%0,%2
65b1d8ea 5557 a<g>rk\t%0,%1,%2
3298c037 5558 a<g>hi\t%0,%h2
65b1d8ea 5559 a<g>hik\t%0,%1,%h2
3298c037
AK
5560 al<g>fi\t%0,%2
5561 sl<g>fi\t%0,%n2
5562 a<g>\t%0,%2
963fc8d0
AK
5563 a<y>\t%0,%2
5564 a<g>si\t%0,%c2"
65b1d8ea 5565 [(set_attr "op_type" "RR<E>,RRF,RI,RIE,RIL,RIL,RX<Y>,RXY,SIY")
3e4be43f 5566 (set_attr "cpu_facility" "*,z196,*,z196,extimm,extimm,*,longdisp,z10")
65b1d8ea
AK
5567 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,z10_super_E1,z10_super_E1,
5568 z10_super_E1,z10_super_E1,z10_super_E1")])
0a3bdf9d 5569
65b1d8ea 5570; alr, alfi, slfi, al, aly, alrk, alhsik, algr, algfi, slgfi, alg, alsi, algsi, algrk, alghsik
3298c037 5571(define_insn "*add<mode>3_carry1_cc"
ae156f85 5572 [(set (reg CC_REGNUM)
65b1d8ea
AK
5573 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5574 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
07893d4f 5575 (match_dup 1)))
65b1d8ea 5576 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,d")
3298c037 5577 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5578 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5579 "@
3298c037 5580 al<g>r\t%0,%2
65b1d8ea 5581 al<g>rk\t%0,%1,%2
3298c037
AK
5582 al<g>fi\t%0,%2
5583 sl<g>fi\t%0,%n2
65b1d8ea 5584 al<g>hsik\t%0,%1,%h2
3298c037 5585 al<g>\t%0,%2
963fc8d0
AK
5586 al<y>\t%0,%2
5587 al<g>si\t%0,%c2"
65b1d8ea 5588 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
3e4be43f 5589 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
65b1d8ea
AK
5590 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
5591 z10_super_E1,z10_super_E1,z10_super_E1")])
07893d4f 5592
65b1d8ea 5593; alr, al, aly, algr, alg, alrk, algrk
3298c037 5594(define_insn "*add<mode>3_carry1_cconly"
ae156f85 5595 [(set (reg CC_REGNUM)
65b1d8ea
AK
5596 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5597 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 5598 (match_dup 1)))
65b1d8ea 5599 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5600 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5601 "@
3298c037 5602 al<g>r\t%0,%2
65b1d8ea 5603 al<g>rk\t%0,%1,%2
3298c037
AK
5604 al<g>\t%0,%2
5605 al<y>\t%0,%2"
65b1d8ea 5606 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 5607 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 5608 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5609
65b1d8ea 5610; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
3298c037 5611(define_insn "*add<mode>3_carry2_cc"
ae156f85 5612 [(set (reg CC_REGNUM)
3e4be43f
UW
5613 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5614 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
07893d4f 5615 (match_dup 2)))
3e4be43f 5616 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,S")
3298c037 5617 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5618 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5619 "@
3298c037 5620 al<g>r\t%0,%2
65b1d8ea 5621 al<g>rk\t%0,%1,%2
3298c037
AK
5622 al<g>fi\t%0,%2
5623 sl<g>fi\t%0,%n2
65b1d8ea 5624 al<g>hsik\t%0,%1,%h2
3298c037 5625 al<g>\t%0,%2
963fc8d0
AK
5626 al<y>\t%0,%2
5627 al<g>si\t%0,%c2"
65b1d8ea 5628 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
3e4be43f 5629 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
65b1d8ea
AK
5630 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
5631 z10_super_E1,z10_super_E1,z10_super_E1")])
07893d4f 5632
65b1d8ea 5633; alr, al, aly, algr, alg, alrk, algrk
3298c037 5634(define_insn "*add<mode>3_carry2_cconly"
ae156f85 5635 [(set (reg CC_REGNUM)
65b1d8ea
AK
5636 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5637 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 5638 (match_dup 2)))
65b1d8ea 5639 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5640 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5641 "@
3298c037 5642 al<g>r\t%0,%2
65b1d8ea 5643 al<g>rk\t%0,%1,%2
3298c037
AK
5644 al<g>\t%0,%2
5645 al<y>\t%0,%2"
65b1d8ea 5646 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 5647 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 5648 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5649
65b1d8ea 5650; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
3298c037 5651(define_insn "*add<mode>3_cc"
ae156f85 5652 [(set (reg CC_REGNUM)
3e4be43f
UW
5653 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5654 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
9db1d521 5655 (const_int 0)))
3e4be43f 5656 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,S")
3298c037 5657 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5658 "s390_match_ccmode (insn, CCLmode)"
9db1d521 5659 "@
3298c037 5660 al<g>r\t%0,%2
65b1d8ea 5661 al<g>rk\t%0,%1,%2
3298c037
AK
5662 al<g>fi\t%0,%2
5663 sl<g>fi\t%0,%n2
65b1d8ea 5664 al<g>hsik\t%0,%1,%h2
3298c037 5665 al<g>\t%0,%2
963fc8d0
AK
5666 al<y>\t%0,%2
5667 al<g>si\t%0,%c2"
65b1d8ea 5668 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
3e4be43f 5669 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
65b1d8ea
AK
5670 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,
5671 *,z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 5672
65b1d8ea 5673; alr, al, aly, algr, alg, alrk, algrk
3298c037 5674(define_insn "*add<mode>3_cconly"
ae156f85 5675 [(set (reg CC_REGNUM)
65b1d8ea
AK
5676 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5677 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 5678 (const_int 0)))
65b1d8ea 5679 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5680 "s390_match_ccmode (insn, CCLmode)"
9db1d521 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")])
9db1d521 5689
65b1d8ea 5690; alr, al, aly, algr, alg, alrk, algrk
3298c037 5691(define_insn "*add<mode>3_cconly2"
ae156f85 5692 [(set (reg CC_REGNUM)
65b1d8ea
AK
5693 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5694 (neg:GPR (match_operand:GPR 2 "general_operand" "d,d,R,T"))))
5695 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
3298c037 5696 "s390_match_ccmode(insn, CCLmode)"
d3632d41 5697 "@
3298c037 5698 al<g>r\t%0,%2
65b1d8ea 5699 al<g>rk\t%0,%1,%2
3298c037
AK
5700 al<g>\t%0,%2
5701 al<y>\t%0,%2"
65b1d8ea 5702 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 5703 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 5704 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5705
963fc8d0 5706; ahi, afi, aghi, agfi, asi, agsi
3298c037
AK
5707(define_insn "*add<mode>3_imm_cc"
5708 [(set (reg CC_REGNUM)
65b1d8ea 5709 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" " 0, d,0, 0")
3e4be43f 5710 (match_operand:GPR 2 "const_int_operand" " K, K,Os,C"))
3298c037 5711 (const_int 0)))
3e4be43f 5712 (set (match_operand:GPR 0 "nonimmediate_operand" "=d, d,d, S")
3298c037
AK
5713 (plus:GPR (match_dup 1) (match_dup 2)))]
5714 "s390_match_ccmode (insn, CCAmode)
5715 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
2542ef05
RH
5716 || (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
5717 /* Avoid INT32_MIN on 32 bit. */
5718 && (!TARGET_ZARCH || INTVAL (operands[2]) != -0x7fffffff - 1)))"
9db1d521 5719 "@
3298c037 5720 a<g>hi\t%0,%h2
65b1d8ea 5721 a<g>hik\t%0,%1,%h2
963fc8d0
AK
5722 a<g>fi\t%0,%2
5723 a<g>si\t%0,%c2"
65b1d8ea
AK
5724 [(set_attr "op_type" "RI,RIE,RIL,SIY")
5725 (set_attr "cpu_facility" "*,z196,extimm,z10")
5726 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 5727
9db1d521 5728;
609e7e80 5729; add(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
5730;
5731
609e7e80 5732; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
6e5b5de8 5733; FIXME: wfadb does not clobber cc
142cd70f 5734(define_insn "add<mode>3"
62d3f261
AK
5735 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
5736 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0,v")
5737 (match_operand:FP 2 "general_operand" "f,f,R,v")))
ae156f85 5738 (clobber (reg:CC CC_REGNUM))]
142cd70f 5739 "TARGET_HARD_FLOAT"
9db1d521 5740 "@
62d3f261
AK
5741 a<xde>tr\t%0,%1,%2
5742 a<xde>br\t%0,%2
6e5b5de8
AK
5743 a<xde>b\t%0,%2
5744 wfadb\t%v0,%v1,%v2"
62d3f261 5745 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6e5b5de8 5746 (set_attr "type" "fsimp<mode>")
62d3f261
AK
5747 (set_attr "cpu_facility" "*,*,*,vec")
5748 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
9db1d521 5749
609e7e80 5750; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
f5905b37 5751(define_insn "*add<mode>3_cc"
ae156f85 5752 [(set (reg CC_REGNUM)
62d3f261
AK
5753 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0")
5754 (match_operand:FP 2 "general_operand" "f,f,R"))
609e7e80 5755 (match_operand:FP 3 "const0_operand" "")))
62d3f261 5756 (set (match_operand:FP 0 "register_operand" "=f,f,f")
609e7e80 5757 (plus:FP (match_dup 1) (match_dup 2)))]
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
609e7e80 5767; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
f5905b37 5768(define_insn "*add<mode>3_cconly"
ae156f85 5769 [(set (reg CC_REGNUM)
62d3f261
AK
5770 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0")
5771 (match_operand:FP 2 "general_operand" "f,f,R"))
609e7e80 5772 (match_operand:FP 3 "const0_operand" "")))
62d3f261 5773 (clobber (match_scratch:FP 0 "=f,f,f"))]
142cd70f 5774 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 5775 "@
62d3f261
AK
5776 a<xde>tr\t%0,%1,%2
5777 a<xde>br\t%0,%2
f61a2c7d 5778 a<xde>b\t%0,%2"
62d3f261
AK
5779 [(set_attr "op_type" "RRF,RRE,RXE")
5780 (set_attr "type" "fsimp<mode>")
5781 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
3ef093a8 5782
72a4ddf2
AK
5783;
5784; Pointer add instruction patterns
5785;
5786
5787; This will match "*la_64"
5788(define_expand "addptrdi3"
5789 [(set (match_operand:DI 0 "register_operand" "")
5790 (plus:DI (match_operand:DI 1 "register_operand" "")
5791 (match_operand:DI 2 "nonmemory_operand" "")))]
5792 "TARGET_64BIT"
5793{
72a4ddf2
AK
5794 if (GET_CODE (operands[2]) == CONST_INT)
5795 {
357ddc7d
TV
5796 HOST_WIDE_INT c = INTVAL (operands[2]);
5797
72a4ddf2
AK
5798 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
5799 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
5800 {
5801 operands[2] = force_const_mem (DImode, operands[2]);
5802 operands[2] = force_reg (DImode, operands[2]);
5803 }
5804 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
5805 operands[2] = force_reg (DImode, operands[2]);
5806 }
5807})
5808
5809; For 31 bit we have to prevent the generated pattern from matching
5810; normal ADDs since la only does a 31 bit add. This is supposed to
5811; match "force_la_31".
5812(define_expand "addptrsi3"
5813 [(parallel
5814 [(set (match_operand:SI 0 "register_operand" "")
5815 (plus:SI (match_operand:SI 1 "register_operand" "")
5816 (match_operand:SI 2 "nonmemory_operand" "")))
5817 (use (const_int 0))])]
5818 "!TARGET_64BIT"
5819{
72a4ddf2
AK
5820 if (GET_CODE (operands[2]) == CONST_INT)
5821 {
357ddc7d
TV
5822 HOST_WIDE_INT c = INTVAL (operands[2]);
5823
72a4ddf2
AK
5824 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
5825 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
5826 {
5827 operands[2] = force_const_mem (SImode, operands[2]);
5828 operands[2] = force_reg (SImode, operands[2]);
5829 }
5830 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
5831 operands[2] = force_reg (SImode, operands[2]);
5832 }
5833})
9db1d521
HP
5834
5835;;
5836;;- Subtract instructions.
5837;;
5838
1c7b1b7e
UW
5839;
5840; subti3 instruction pattern(s).
5841;
5842
085261c8
AK
5843(define_expand "subti3"
5844 [(parallel
5845 [(set (match_operand:TI 0 "register_operand" "")
5846 (minus:TI (match_operand:TI 1 "register_operand" "")
5847 (match_operand:TI 2 "general_operand" "") ) )
5848 (clobber (reg:CC CC_REGNUM))])]
5849 "TARGET_ZARCH"
5850{
2d71f118 5851 /* For z13 we have vsq which doesn't set CC. */
085261c8
AK
5852 if (TARGET_VX)
5853 {
5854 emit_insn (gen_rtx_SET (operands[0],
5855 gen_rtx_MINUS (TImode,
5856 operands[1],
5857 copy_to_mode_reg (TImode, operands[2]))));
5858 DONE;
5859 }
5860})
5861
5862(define_insn_and_split "*subti3"
5863 [(set (match_operand:TI 0 "register_operand" "=&d")
5864 (minus:TI (match_operand:TI 1 "register_operand" "0")
5865 (match_operand:TI 2 "general_operand" "do") ) )
ae156f85 5866 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5867 "TARGET_ZARCH"
1c7b1b7e
UW
5868 "#"
5869 "&& reload_completed"
5870 [(parallel
ae156f85 5871 [(set (reg:CCL2 CC_REGNUM)
1c7b1b7e
UW
5872 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
5873 (match_dup 7)))
5874 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
5875 (parallel
5876 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
ae156f85
AS
5877 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
5878 (clobber (reg:CC CC_REGNUM))])]
1c7b1b7e
UW
5879 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
5880 operands[4] = operand_subword (operands[1], 0, 0, TImode);
5881 operands[5] = operand_subword (operands[2], 0, 0, TImode);
5882 operands[6] = operand_subword (operands[0], 1, 0, TImode);
5883 operands[7] = operand_subword (operands[1], 1, 0, TImode);
085261c8
AK
5884 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
5885 [(set_attr "op_type" "*")
5886 (set_attr "cpu_facility" "*")])
1c7b1b7e 5887
9db1d521
HP
5888;
5889; subdi3 instruction pattern(s).
5890;
5891
3298c037
AK
5892(define_expand "subdi3"
5893 [(parallel
5894 [(set (match_operand:DI 0 "register_operand" "")
5895 (minus:DI (match_operand:DI 1 "register_operand" "")
5896 (match_operand:DI 2 "general_operand" "")))
5897 (clobber (reg:CC CC_REGNUM))])]
5898 ""
5899 "")
5900
07893d4f
UW
5901(define_insn "*subdi3_sign"
5902 [(set (match_operand:DI 0 "register_operand" "=d,d")
5903 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 5904 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))))
ae156f85 5905 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5906 "TARGET_ZARCH"
07893d4f 5907 "@
d40c829f
UW
5908 sgfr\t%0,%2
5909 sgf\t%0,%2"
9381e3f1 5910 [(set_attr "op_type" "RRE,RXY")
65b1d8ea
AK
5911 (set_attr "z10prop" "z10_c,*")
5912 (set_attr "z196prop" "z196_cracked")])
07893d4f
UW
5913
5914(define_insn "*subdi3_zero_cc"
ae156f85 5915 [(set (reg CC_REGNUM)
07893d4f 5916 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 5917 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T")))
07893d4f
UW
5918 (const_int 0)))
5919 (set (match_operand:DI 0 "register_operand" "=d,d")
5920 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
9602b6a1 5921 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5922 "@
d40c829f
UW
5923 slgfr\t%0,%2
5924 slgf\t%0,%2"
9381e3f1
WG
5925 [(set_attr "op_type" "RRE,RXY")
5926 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f
UW
5927
5928(define_insn "*subdi3_zero_cconly"
ae156f85 5929 [(set (reg CC_REGNUM)
07893d4f 5930 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 5931 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T")))
07893d4f
UW
5932 (const_int 0)))
5933 (clobber (match_scratch:DI 0 "=d,d"))]
9602b6a1 5934 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5935 "@
d40c829f
UW
5936 slgfr\t%0,%2
5937 slgf\t%0,%2"
9381e3f1
WG
5938 [(set_attr "op_type" "RRE,RXY")
5939 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f
UW
5940
5941(define_insn "*subdi3_zero"
5942 [(set (match_operand:DI 0 "register_operand" "=d,d")
5943 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 5944 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))))
ae156f85 5945 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5946 "TARGET_ZARCH"
07893d4f 5947 "@
d40c829f
UW
5948 slgfr\t%0,%2
5949 slgf\t%0,%2"
9381e3f1
WG
5950 [(set_attr "op_type" "RRE,RXY")
5951 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f 5952
e69166de
UW
5953(define_insn_and_split "*subdi3_31z"
5954 [(set (match_operand:DI 0 "register_operand" "=&d")
5955 (minus:DI (match_operand:DI 1 "register_operand" "0")
5956 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5957 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5958 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
e69166de
UW
5959 "#"
5960 "&& reload_completed"
5961 [(parallel
ae156f85 5962 [(set (reg:CCL2 CC_REGNUM)
e69166de
UW
5963 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5964 (match_dup 7)))
5965 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5966 (parallel
5967 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
ae156f85
AS
5968 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
5969 (clobber (reg:CC CC_REGNUM))])]
e69166de
UW
5970 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5971 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5972 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5973 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5974 operands[7] = operand_subword (operands[1], 1, 0, DImode);
b628bd8e 5975 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
e69166de 5976
07893d4f
UW
5977(define_insn_and_split "*subdi3_31"
5978 [(set (match_operand:DI 0 "register_operand" "=&d")
5979 (minus:DI (match_operand:DI 1 "register_operand" "0")
97c6f7ad 5980 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5981 (clobber (reg:CC CC_REGNUM))]
e69166de 5982 "!TARGET_CPU_ZARCH"
07893d4f
UW
5983 "#"
5984 "&& reload_completed"
5985 [(parallel
5986 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
ae156f85 5987 (clobber (reg:CC CC_REGNUM))])
07893d4f 5988 (parallel
ae156f85 5989 [(set (reg:CCL2 CC_REGNUM)
07893d4f
UW
5990 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5991 (match_dup 7)))
5992 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5993 (set (pc)
ae156f85 5994 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
07893d4f
UW
5995 (pc)
5996 (label_ref (match_dup 9))))
5997 (parallel
5998 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
ae156f85 5999 (clobber (reg:CC CC_REGNUM))])
07893d4f 6000 (match_dup 9)]
97c6f7ad
UW
6001 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
6002 operands[4] = operand_subword (operands[1], 0, 0, DImode);
6003 operands[5] = operand_subword (operands[2], 0, 0, DImode);
6004 operands[6] = operand_subword (operands[0], 1, 0, DImode);
6005 operands[7] = operand_subword (operands[1], 1, 0, DImode);
6006 operands[8] = operand_subword (operands[2], 1, 0, DImode);
b628bd8e 6007 operands[9] = gen_label_rtx ();")
07893d4f 6008
3298c037
AK
6009;
6010; subsi3 instruction pattern(s).
6011;
6012
6013(define_expand "subsi3"
07893d4f 6014 [(parallel
3298c037
AK
6015 [(set (match_operand:SI 0 "register_operand" "")
6016 (minus:SI (match_operand:SI 1 "register_operand" "")
6017 (match_operand:SI 2 "general_operand" "")))
ae156f85 6018 (clobber (reg:CC CC_REGNUM))])]
9db1d521 6019 ""
07893d4f 6020 "")
9db1d521 6021
3298c037
AK
6022(define_insn "*subsi3_sign"
6023 [(set (match_operand:SI 0 "register_operand" "=d,d")
6024 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
6025 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
6026 (clobber (reg:CC CC_REGNUM))]
6027 ""
6028 "@
6029 sh\t%0,%2
6030 shy\t%0,%2"
65b1d8ea 6031 [(set_attr "op_type" "RX,RXY")
3e4be43f 6032 (set_attr "cpu_facility" "*,longdisp")
65b1d8ea 6033 (set_attr "z196prop" "z196_cracked,z196_cracked")])
3298c037 6034
9db1d521 6035;
3298c037 6036; sub(di|si)3 instruction pattern(s).
9db1d521
HP
6037;
6038
65b1d8ea 6039; sr, s, sy, sgr, sg, srk, sgrk
3298c037 6040(define_insn "*sub<mode>3"
65b1d8ea
AK
6041 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6042 (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6043 (match_operand:GPR 2 "general_operand" "d,d,R,T") ) )
3298c037
AK
6044 (clobber (reg:CC CC_REGNUM))]
6045 ""
6046 "@
6047 s<g>r\t%0,%2
65b1d8ea 6048 s<g>rk\t%0,%1,%2
3298c037
AK
6049 s<g>\t%0,%2
6050 s<y>\t%0,%2"
65b1d8ea 6051 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6052 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6053 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
3298c037 6054
65b1d8ea 6055; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6056(define_insn "*sub<mode>3_borrow_cc"
ae156f85 6057 [(set (reg CC_REGNUM)
65b1d8ea
AK
6058 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6059 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 6060 (match_dup 1)))
65b1d8ea 6061 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 6062 (minus:GPR (match_dup 1) (match_dup 2)))]
b2ba71ca 6063 "s390_match_ccmode (insn, CCL2mode)"
07893d4f 6064 "@
3298c037 6065 sl<g>r\t%0,%2
65b1d8ea 6066 sl<g>rk\t%0,%1,%2
3298c037
AK
6067 sl<g>\t%0,%2
6068 sl<y>\t%0,%2"
65b1d8ea 6069 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6070 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6071 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 6072
65b1d8ea 6073; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6074(define_insn "*sub<mode>3_borrow_cconly"
ae156f85 6075 [(set (reg CC_REGNUM)
65b1d8ea
AK
6076 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6077 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 6078 (match_dup 1)))
65b1d8ea 6079 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
b2ba71ca 6080 "s390_match_ccmode (insn, CCL2mode)"
07893d4f 6081 "@
3298c037 6082 sl<g>r\t%0,%2
65b1d8ea 6083 sl<g>rk\t%0,%1,%2
3298c037
AK
6084 sl<g>\t%0,%2
6085 sl<y>\t%0,%2"
65b1d8ea 6086 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6087 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6088 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 6089
65b1d8ea 6090; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6091(define_insn "*sub<mode>3_cc"
ae156f85 6092 [(set (reg CC_REGNUM)
65b1d8ea
AK
6093 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6094 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 6095 (const_int 0)))
65b1d8ea 6096 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 6097 (minus:GPR (match_dup 1) (match_dup 2)))]
b2ba71ca 6098 "s390_match_ccmode (insn, CCLmode)"
9db1d521 6099 "@
3298c037 6100 sl<g>r\t%0,%2
65b1d8ea 6101 sl<g>rk\t%0,%1,%2
3298c037
AK
6102 sl<g>\t%0,%2
6103 sl<y>\t%0,%2"
65b1d8ea 6104 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6105 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6106 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 6107
65b1d8ea 6108; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6109(define_insn "*sub<mode>3_cc2"
ae156f85 6110 [(set (reg CC_REGNUM)
65b1d8ea
AK
6111 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
6112 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
6113 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 6114 (minus:GPR (match_dup 1) (match_dup 2)))]
5d880bd2
UW
6115 "s390_match_ccmode (insn, CCL3mode)"
6116 "@
3298c037 6117 sl<g>r\t%0,%2
65b1d8ea 6118 sl<g>rk\t%0,%1,%2
3298c037
AK
6119 sl<g>\t%0,%2
6120 sl<y>\t%0,%2"
65b1d8ea 6121 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6122 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6123 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5d880bd2 6124
65b1d8ea 6125; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6126(define_insn "*sub<mode>3_cconly"
ae156f85 6127 [(set (reg CC_REGNUM)
65b1d8ea
AK
6128 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6129 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 6130 (const_int 0)))
65b1d8ea 6131 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
b2ba71ca 6132 "s390_match_ccmode (insn, CCLmode)"
9db1d521 6133 "@
3298c037 6134 sl<g>r\t%0,%2
65b1d8ea 6135 sl<g>rk\t%0,%1,%2
3298c037
AK
6136 sl<g>\t%0,%2
6137 sl<y>\t%0,%2"
65b1d8ea 6138 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6139 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6140 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9381e3f1 6141
9db1d521 6142
65b1d8ea 6143; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 6144(define_insn "*sub<mode>3_cconly2"
ae156f85 6145 [(set (reg CC_REGNUM)
65b1d8ea
AK
6146 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
6147 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
6148 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5d880bd2
UW
6149 "s390_match_ccmode (insn, CCL3mode)"
6150 "@
3298c037 6151 sl<g>r\t%0,%2
65b1d8ea 6152 sl<g>rk\t%0,%1,%2
3298c037
AK
6153 sl<g>\t%0,%2
6154 sl<y>\t%0,%2"
65b1d8ea 6155 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
3e4be43f 6156 (set_attr "cpu_facility" "*,z196,*,longdisp")
65b1d8ea 6157 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9381e3f1 6158
9db1d521
HP
6159
6160;
609e7e80 6161; sub(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
6162;
6163
d46f24b6 6164; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
142cd70f 6165(define_insn "sub<mode>3"
62d3f261
AK
6166 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
6167 (minus:FP (match_operand:FP 1 "register_operand" "f,0,0,v")
6168 (match_operand:FP 2 "general_operand" "f,f,R,v")))
ae156f85 6169 (clobber (reg:CC CC_REGNUM))]
142cd70f 6170 "TARGET_HARD_FLOAT"
9db1d521 6171 "@
62d3f261
AK
6172 s<xde>tr\t%0,%1,%2
6173 s<xde>br\t%0,%2
6e5b5de8
AK
6174 s<xde>b\t%0,%2
6175 wfsdb\t%v0,%v1,%v2"
62d3f261 6176 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6e5b5de8 6177 (set_attr "type" "fsimp<mode>")
62d3f261
AK
6178 (set_attr "cpu_facility" "*,*,*,vec")
6179 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
9db1d521 6180
d46f24b6 6181; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
f5905b37 6182(define_insn "*sub<mode>3_cc"
ae156f85 6183 [(set (reg CC_REGNUM)
62d3f261
AK
6184 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "f,0,0")
6185 (match_operand:FP 2 "general_operand" "f,f,R"))
609e7e80 6186 (match_operand:FP 3 "const0_operand" "")))
62d3f261 6187 (set (match_operand:FP 0 "register_operand" "=f,f,f")
609e7e80 6188 (minus:FP (match_dup 1) (match_dup 2)))]
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
d46f24b6 6198; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
f5905b37 6199(define_insn "*sub<mode>3_cconly"
ae156f85 6200 [(set (reg CC_REGNUM)
62d3f261
AK
6201 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "f,0,0")
6202 (match_operand:FP 2 "general_operand" "f,f,R"))
609e7e80 6203 (match_operand:FP 3 "const0_operand" "")))
62d3f261 6204 (clobber (match_scratch:FP 0 "=f,f,f"))]
142cd70f 6205 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 6206 "@
62d3f261
AK
6207 s<xde>tr\t%0,%1,%2
6208 s<xde>br\t%0,%2
f61a2c7d 6209 s<xde>b\t%0,%2"
62d3f261
AK
6210 [(set_attr "op_type" "RRF,RRE,RXE")
6211 (set_attr "type" "fsimp<mode>")
6212 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
3ef093a8 6213
9db1d521 6214
e69166de
UW
6215;;
6216;;- Conditional add/subtract instructions.
6217;;
6218
6219;
9a91a21f 6220; add(di|si)cc instruction pattern(s).
e69166de
UW
6221;
6222
a996720c
UW
6223; the following 4 patterns are used when the result of an add with
6224; carry is checked for an overflow condition
6225
6226; op1 + op2 + c < op1
6227
6228; alcr, alc, alcgr, alcg
6229(define_insn "*add<mode>3_alc_carry1_cc"
6230 [(set (reg CC_REGNUM)
6231 (compare
6232 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6233 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6234 (match_operand:GPR 2 "general_operand" "d,T"))
a996720c
UW
6235 (match_dup 1)))
6236 (set (match_operand:GPR 0 "register_operand" "=d,d")
6237 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
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; alcr, alc, alcgr, alcg
6246(define_insn "*add<mode>3_alc_carry1_cconly"
6247 [(set (reg CC_REGNUM)
6248 (compare
6249 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6250 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6251 (match_operand:GPR 2 "general_operand" "d,T"))
a996720c
UW
6252 (match_dup 1)))
6253 (clobber (match_scratch:GPR 0 "=d,d"))]
6254 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6255 "@
6256 alc<g>r\t%0,%2
6257 alc<g>\t%0,%2"
65b1d8ea
AK
6258 [(set_attr "op_type" "RRE,RXY")
6259 (set_attr "z196prop" "z196_alone,z196_alone")])
a996720c
UW
6260
6261; op1 + op2 + c < op2
6262
6263; alcr, alc, alcgr, alcg
6264(define_insn "*add<mode>3_alc_carry2_cc"
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 (set (match_operand:GPR 0 "register_operand" "=d,d")
6272 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
6273 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6274 "@
6275 alc<g>r\t%0,%2
6276 alc<g>\t%0,%2"
6277 [(set_attr "op_type" "RRE,RXY")])
6278
6279; alcr, alc, alcgr, alcg
6280(define_insn "*add<mode>3_alc_carry2_cconly"
6281 [(set (reg CC_REGNUM)
6282 (compare
6283 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6284 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6285 (match_operand:GPR 2 "general_operand" "d,T"))
a996720c
UW
6286 (match_dup 2)))
6287 (clobber (match_scratch:GPR 0 "=d,d"))]
6288 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6289 "@
6290 alc<g>r\t%0,%2
6291 alc<g>\t%0,%2"
6292 [(set_attr "op_type" "RRE,RXY")])
6293
43a09b63 6294; alcr, alc, alcgr, alcg
9a91a21f 6295(define_insn "*add<mode>3_alc_cc"
ae156f85 6296 [(set (reg CC_REGNUM)
e69166de 6297 (compare
a94a76a7
UW
6298 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6299 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6300 (match_operand:GPR 2 "general_operand" "d,T"))
e69166de 6301 (const_int 0)))
9a91a21f 6302 (set (match_operand:GPR 0 "register_operand" "=d,d")
a94a76a7 6303 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
2f7e5a0d 6304 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
e69166de 6305 "@
9a91a21f
AS
6306 alc<g>r\t%0,%2
6307 alc<g>\t%0,%2"
e69166de
UW
6308 [(set_attr "op_type" "RRE,RXY")])
6309
43a09b63 6310; alcr, alc, alcgr, alcg
9a91a21f
AS
6311(define_insn "*add<mode>3_alc"
6312 [(set (match_operand:GPR 0 "register_operand" "=d,d")
a94a76a7
UW
6313 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6314 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
3e4be43f 6315 (match_operand:GPR 2 "general_operand" "d,T")))
ae156f85 6316 (clobber (reg:CC CC_REGNUM))]
2f7e5a0d 6317 "TARGET_CPU_ZARCH"
e69166de 6318 "@
9a91a21f
AS
6319 alc<g>r\t%0,%2
6320 alc<g>\t%0,%2"
e69166de
UW
6321 [(set_attr "op_type" "RRE,RXY")])
6322
43a09b63 6323; slbr, slb, slbgr, slbg
9a91a21f 6324(define_insn "*sub<mode>3_slb_cc"
ae156f85 6325 [(set (reg CC_REGNUM)
e69166de 6326 (compare
9a91a21f 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" ""))
e69166de 6330 (const_int 0)))
9a91a21f
AS
6331 (set (match_operand:GPR 0 "register_operand" "=d,d")
6332 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
2f7e5a0d 6333 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
e69166de 6334 "@
9a91a21f
AS
6335 slb<g>r\t%0,%2
6336 slb<g>\t%0,%2"
9381e3f1
WG
6337 [(set_attr "op_type" "RRE,RXY")
6338 (set_attr "z10prop" "z10_c,*")])
e69166de 6339
43a09b63 6340; slbr, slb, slbgr, slbg
9a91a21f
AS
6341(define_insn "*sub<mode>3_slb"
6342 [(set (match_operand:GPR 0 "register_operand" "=d,d")
6343 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
3e4be43f 6344 (match_operand:GPR 2 "general_operand" "d,T"))
9a91a21f 6345 (match_operand:GPR 3 "s390_slb_comparison" "")))
ae156f85 6346 (clobber (reg:CC CC_REGNUM))]
2f7e5a0d 6347 "TARGET_CPU_ZARCH"
e69166de 6348 "@
9a91a21f
AS
6349 slb<g>r\t%0,%2
6350 slb<g>\t%0,%2"
9381e3f1
WG
6351 [(set_attr "op_type" "RRE,RXY")
6352 (set_attr "z10prop" "z10_c,*")])
e69166de 6353
9a91a21f
AS
6354(define_expand "add<mode>cc"
6355 [(match_operand:GPR 0 "register_operand" "")
5d880bd2 6356 (match_operand 1 "comparison_operator" "")
9a91a21f
AS
6357 (match_operand:GPR 2 "register_operand" "")
6358 (match_operand:GPR 3 "const_int_operand" "")]
5d880bd2 6359 "TARGET_CPU_ZARCH"
9381e3f1 6360 "if (!s390_expand_addcc (GET_CODE (operands[1]),
f90b7a5a 6361 XEXP (operands[1], 0), XEXP (operands[1], 1),
9381e3f1 6362 operands[0], operands[2],
5d880bd2
UW
6363 operands[3])) FAIL; DONE;")
6364
6365;
6366; scond instruction pattern(s).
6367;
6368
9a91a21f
AS
6369(define_insn_and_split "*scond<mode>"
6370 [(set (match_operand:GPR 0 "register_operand" "=&d")
6371 (match_operand:GPR 1 "s390_alc_comparison" ""))
ae156f85 6372 (clobber (reg:CC CC_REGNUM))]
5d880bd2
UW
6373 "TARGET_CPU_ZARCH"
6374 "#"
6375 "&& reload_completed"
6376 [(set (match_dup 0) (const_int 0))
6377 (parallel
a94a76a7
UW
6378 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
6379 (match_dup 0)))
ae156f85 6380 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 6381 "")
5d880bd2 6382
9a91a21f
AS
6383(define_insn_and_split "*scond<mode>_neg"
6384 [(set (match_operand:GPR 0 "register_operand" "=&d")
6385 (match_operand:GPR 1 "s390_slb_comparison" ""))
ae156f85 6386 (clobber (reg:CC CC_REGNUM))]
5d880bd2
UW
6387 "TARGET_CPU_ZARCH"
6388 "#"
6389 "&& reload_completed"
6390 [(set (match_dup 0) (const_int 0))
6391 (parallel
9a91a21f
AS
6392 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
6393 (match_dup 1)))
ae156f85 6394 (clobber (reg:CC CC_REGNUM))])
5d880bd2 6395 (parallel
9a91a21f 6396 [(set (match_dup 0) (neg:GPR (match_dup 0)))
ae156f85 6397 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 6398 "")
5d880bd2 6399
5d880bd2 6400
f90b7a5a 6401(define_expand "cstore<mode>4"
9a91a21f 6402 [(set (match_operand:SI 0 "register_operand" "")
f90b7a5a
PB
6403 (match_operator:SI 1 "s390_scond_operator"
6404 [(match_operand:GPR 2 "register_operand" "")
6405 (match_operand:GPR 3 "general_operand" "")]))]
5d880bd2 6406 "TARGET_CPU_ZARCH"
f90b7a5a 6407 "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3],
5d880bd2
UW
6408 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
6409
f90b7a5a 6410(define_expand "cstorecc4"
69950452 6411 [(parallel
f90b7a5a
PB
6412 [(set (match_operand:SI 0 "register_operand" "")
6413 (match_operator:SI 1 "s390_eqne_operator"
6414 [(match_operand:CCZ1 2 "register_operand")
6415 (match_operand 3 "const0_operand")]))
69950452
AS
6416 (clobber (reg:CC CC_REGNUM))])]
6417 ""
f90b7a5a
PB
6418 "emit_insn (gen_sne (operands[0], operands[2]));
6419 if (GET_CODE (operands[1]) == EQ)
6420 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
6421 DONE;")
69950452 6422
f90b7a5a 6423(define_insn_and_split "sne"
69950452 6424 [(set (match_operand:SI 0 "register_operand" "=d")
9381e3f1 6425 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
69950452
AS
6426 (const_int 0)))
6427 (clobber (reg:CC CC_REGNUM))]
6428 ""
6429 "#"
6430 "reload_completed"
6431 [(parallel
6432 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
6433 (clobber (reg:CC CC_REGNUM))])])
6434
e69166de 6435
65b1d8ea
AK
6436;;
6437;; - Conditional move instructions (introduced with z196)
6438;;
6439
6440(define_expand "mov<mode>cc"
6441 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
6442 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
6443 (match_operand:GPR 2 "nonimmediate_operand" "")
6444 (match_operand:GPR 3 "nonimmediate_operand" "")))]
6445 "TARGET_Z196"
7477de01
AK
6446{
6447 /* Emit the comparison insn in case we do not already have a comparison result. */
6448 if (!s390_comparison (operands[1], VOIDmode))
6449 operands[1] = s390_emit_compare (GET_CODE (operands[1]),
6450 XEXP (operands[1], 0),
6451 XEXP (operands[1], 1));
6452})
65b1d8ea 6453
bf749919 6454; locr, loc, stoc, locgr, locg, stocg, lochi, locghi
65b1d8ea 6455(define_insn_and_split "*mov<mode>cc"
bf749919 6456 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,S,S,&d")
65b1d8ea
AK
6457 (if_then_else:GPR
6458 (match_operator 1 "s390_comparison"
bf749919 6459 [(match_operand 2 "cc_reg_operand" " c,c,c,c,c,c,c,c,c")
5a3fe9b6 6460 (match_operand 5 "const_int_operand" "")])
bf749919
DV
6461 (match_operand:GPR 3 "loc_operand" " d,0,S,0,K,0,d,0,S")
6462 (match_operand:GPR 4 "loc_operand" " 0,d,0,S,0,K,0,d,S")))]
65b1d8ea
AK
6463 "TARGET_Z196"
6464 "@
6465 loc<g>r%C1\t%0,%3
6466 loc<g>r%D1\t%0,%4
a6510374
AK
6467 loc<g>%C1\t%0,%3
6468 loc<g>%D1\t%0,%4
bf749919
DV
6469 loc<g>hi%C1\t%0,%h3
6470 loc<g>hi%D1\t%0,%h4
a6510374
AK
6471 stoc<g>%C1\t%3,%0
6472 stoc<g>%D1\t%4,%0
65b1d8ea
AK
6473 #"
6474 "&& reload_completed
6475 && MEM_P (operands[3]) && MEM_P (operands[4])"
6476 [(set (match_dup 0)
6477 (if_then_else:GPR
6478 (match_op_dup 1 [(match_dup 2) (const_int 0)])
6479 (match_dup 3)
6480 (match_dup 0)))
6481 (set (match_dup 0)
6482 (if_then_else:GPR
6483 (match_op_dup 1 [(match_dup 2) (const_int 0)])
6484 (match_dup 0)
6485 (match_dup 4)))]
6486 ""
bf749919
DV
6487 [(set_attr "op_type" "RRF,RRF,RSY,RSY,RIE,RIE,RSY,RSY,*")
6488 (set_attr "cpu_facility" "*,*,*,*,z13,z13,*,*,*")])
65b1d8ea 6489
9db1d521
HP
6490;;
6491;;- Multiply instructions.
6492;;
6493
4023fb28
UW
6494;
6495; muldi3 instruction pattern(s).
6496;
9db1d521 6497
07893d4f
UW
6498(define_insn "*muldi3_sign"
6499 [(set (match_operand:DI 0 "register_operand" "=d,d")
3e4be43f 6500 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
07893d4f 6501 (match_operand:DI 1 "register_operand" "0,0")))]
9602b6a1 6502 "TARGET_ZARCH"
07893d4f 6503 "@
d40c829f
UW
6504 msgfr\t%0,%2
6505 msgf\t%0,%2"
963fc8d0
AK
6506 [(set_attr "op_type" "RRE,RXY")
6507 (set_attr "type" "imuldi")])
07893d4f 6508
4023fb28 6509(define_insn "muldi3"
963fc8d0
AK
6510 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
6511 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
3e4be43f 6512 (match_operand:DI 2 "general_operand" "d,K,T,Os")))]
9602b6a1 6513 "TARGET_ZARCH"
9db1d521 6514 "@
d40c829f
UW
6515 msgr\t%0,%2
6516 mghi\t%0,%h2
963fc8d0
AK
6517 msg\t%0,%2
6518 msgfi\t%0,%2"
6519 [(set_attr "op_type" "RRE,RI,RXY,RIL")
6520 (set_attr "type" "imuldi")
6521 (set_attr "cpu_facility" "*,*,*,z10")])
f2d3c02a 6522
9db1d521
HP
6523;
6524; mulsi3 instruction pattern(s).
6525;
6526
f1e77d83 6527(define_insn "*mulsi3_sign"
963fc8d0
AK
6528 [(set (match_operand:SI 0 "register_operand" "=d,d")
6529 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
6530 (match_operand:SI 1 "register_operand" "0,0")))]
f1e77d83 6531 ""
963fc8d0
AK
6532 "@
6533 mh\t%0,%2
6534 mhy\t%0,%2"
6535 [(set_attr "op_type" "RX,RXY")
6536 (set_attr "type" "imulhi")
6537 (set_attr "cpu_facility" "*,z10")])
f1e77d83 6538
9db1d521 6539(define_insn "mulsi3"
963fc8d0
AK
6540 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
6541 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
6542 (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
9db1d521
HP
6543 ""
6544 "@
d40c829f
UW
6545 msr\t%0,%2
6546 mhi\t%0,%h2
6547 ms\t%0,%2
963fc8d0
AK
6548 msy\t%0,%2
6549 msfi\t%0,%2"
6550 [(set_attr "op_type" "RRE,RI,RX,RXY,RIL")
6551 (set_attr "type" "imulsi,imulhi,imulsi,imulsi,imulsi")
3e4be43f 6552 (set_attr "cpu_facility" "*,*,*,longdisp,z10")])
9db1d521 6553
4023fb28
UW
6554;
6555; mulsidi3 instruction pattern(s).
6556;
6557
f1e77d83 6558(define_insn "mulsidi3"
963fc8d0 6559 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
f1e77d83 6560 (mult:DI (sign_extend:DI
963fc8d0 6561 (match_operand:SI 1 "register_operand" "%0,0,0"))
f1e77d83 6562 (sign_extend:DI
963fc8d0 6563 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
9602b6a1 6564 "!TARGET_ZARCH"
f1e77d83
UW
6565 "@
6566 mr\t%0,%2
963fc8d0
AK
6567 m\t%0,%2
6568 mfy\t%0,%2"
6569 [(set_attr "op_type" "RR,RX,RXY")
6570 (set_attr "type" "imulsi")
6571 (set_attr "cpu_facility" "*,*,z10")])
4023fb28 6572
f1e77d83 6573;
6e0d70c9 6574; umul instruction pattern(s).
f1e77d83 6575;
c7453384 6576
6e0d70c9
AK
6577; mlr, ml, mlgr, mlg
6578(define_insn "umul<dwh><mode>3"
3e4be43f 6579 [(set (match_operand:DW 0 "register_operand" "=d,d")
6e0d70c9 6580 (mult:DW (zero_extend:DW
3e4be43f 6581 (match_operand:<DWH> 1 "register_operand" "%0,0"))
6e0d70c9 6582 (zero_extend:DW
3e4be43f 6583 (match_operand:<DWH> 2 "nonimmediate_operand" " d,T"))))]
6e0d70c9 6584 "TARGET_CPU_ZARCH"
f1e77d83 6585 "@
6e0d70c9
AK
6586 ml<tg>r\t%0,%2
6587 ml<tg>\t%0,%2"
f1e77d83 6588 [(set_attr "op_type" "RRE,RXY")
6e0d70c9 6589 (set_attr "type" "imul<dwh>")])
c7453384 6590
9db1d521 6591;
609e7e80 6592; mul(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
6593;
6594
9381e3f1 6595; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
142cd70f 6596(define_insn "mul<mode>3"
62d3f261
AK
6597 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
6598 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0,v")
6599 (match_operand:FP 2 "general_operand" "f,f,R,v")))]
142cd70f 6600 "TARGET_HARD_FLOAT"
9db1d521 6601 "@
62d3f261
AK
6602 m<xdee>tr\t%0,%1,%2
6603 m<xdee>br\t%0,%2
6e5b5de8
AK
6604 m<xdee>b\t%0,%2
6605 wfmdb\t%v0,%v1,%v2"
62d3f261 6606 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6e5b5de8 6607 (set_attr "type" "fmul<mode>")
62d3f261
AK
6608 (set_attr "cpu_facility" "*,*,*,vec")
6609 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
9db1d521 6610
9381e3f1 6611; madbr, maebr, maxb, madb, maeb
d7ecb504 6612(define_insn "fma<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 (match_operand:DSF 3 "register_operand" "0,0,v")))]
d7ecb504 6617 "TARGET_HARD_FLOAT"
a1b892b5 6618 "@
f61a2c7d 6619 ma<xde>br\t%0,%1,%2
6e5b5de8
AK
6620 ma<xde>b\t%0,%1,%2
6621 wfmadb\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>")])
a1b892b5 6626
43a09b63 6627; msxbr, msdbr, msebr, msxb, msdb, mseb
d7ecb504 6628(define_insn "fms<mode>4"
62d3f261
AK
6629 [(set (match_operand:DSF 0 "register_operand" "=f,f,v")
6630 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f,v")
6631 (match_operand:DSF 2 "nonimmediate_operand" "f,R,v")
6632 (neg:DSF (match_operand:DSF 3 "register_operand" "0,0,v"))))]
d7ecb504 6633 "TARGET_HARD_FLOAT"
a1b892b5 6634 "@
f61a2c7d 6635 ms<xde>br\t%0,%1,%2
6e5b5de8
AK
6636 ms<xde>b\t%0,%1,%2
6637 wfmsdb\t%v0,%v1,%v2,%v3"
6638 [(set_attr "op_type" "RRE,RXE,VRR")
6639 (set_attr "type" "fmadd<mode>")
62d3f261
AK
6640 (set_attr "cpu_facility" "*,*,vec")
6641 (set_attr "enabled" "*,*,<DFDI>")])
9db1d521
HP
6642
6643;;
6644;;- Divide and modulo instructions.
6645;;
6646
6647;
4023fb28 6648; divmoddi4 instruction pattern(s).
9db1d521
HP
6649;
6650
4023fb28
UW
6651(define_expand "divmoddi4"
6652 [(parallel [(set (match_operand:DI 0 "general_operand" "")
f1e77d83 6653 (div:DI (match_operand:DI 1 "register_operand" "")
4023fb28
UW
6654 (match_operand:DI 2 "general_operand" "")))
6655 (set (match_operand:DI 3 "general_operand" "")
6656 (mod:DI (match_dup 1) (match_dup 2)))])
6657 (clobber (match_dup 4))]
9602b6a1 6658 "TARGET_ZARCH"
9db1d521 6659{
d8485bdb
TS
6660 rtx div_equal, mod_equal;
6661 rtx_insn *insn;
4023fb28
UW
6662
6663 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
6664 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4023fb28
UW
6665
6666 operands[4] = gen_reg_rtx(TImode);
f1e77d83 6667 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4023fb28
UW
6668
6669 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
bd94cb6e 6670 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6671
6672 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
bd94cb6e 6673 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6674
9db1d521 6675 DONE;
10bbf137 6676})
9db1d521
HP
6677
6678(define_insn "divmodtidi3"
4023fb28
UW
6679 [(set (match_operand:TI 0 "register_operand" "=d,d")
6680 (ior:TI
4023fb28
UW
6681 (ashift:TI
6682 (zero_extend:TI
5665e398 6683 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
3e4be43f 6684 (match_operand:DI 2 "general_operand" "d,T")))
5665e398
UW
6685 (const_int 64))
6686 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
9602b6a1 6687 "TARGET_ZARCH"
9db1d521 6688 "@
d40c829f
UW
6689 dsgr\t%0,%2
6690 dsg\t%0,%2"
d3632d41 6691 [(set_attr "op_type" "RRE,RXY")
077dab3b 6692 (set_attr "type" "idiv")])
9db1d521 6693
4023fb28
UW
6694(define_insn "divmodtisi3"
6695 [(set (match_operand:TI 0 "register_operand" "=d,d")
6696 (ior:TI
4023fb28
UW
6697 (ashift:TI
6698 (zero_extend:TI
5665e398 6699 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
2f7e5a0d 6700 (sign_extend:DI
3e4be43f 6701 (match_operand:SI 2 "nonimmediate_operand" "d,T"))))
5665e398
UW
6702 (const_int 64))
6703 (zero_extend:TI
6704 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
9602b6a1 6705 "TARGET_ZARCH"
4023fb28 6706 "@
d40c829f
UW
6707 dsgfr\t%0,%2
6708 dsgf\t%0,%2"
d3632d41 6709 [(set_attr "op_type" "RRE,RXY")
077dab3b 6710 (set_attr "type" "idiv")])
9db1d521 6711
4023fb28
UW
6712;
6713; udivmoddi4 instruction pattern(s).
6714;
9db1d521 6715
4023fb28
UW
6716(define_expand "udivmoddi4"
6717 [(parallel [(set (match_operand:DI 0 "general_operand" "")
6718 (udiv:DI (match_operand:DI 1 "general_operand" "")
6719 (match_operand:DI 2 "nonimmediate_operand" "")))
6720 (set (match_operand:DI 3 "general_operand" "")
6721 (umod:DI (match_dup 1) (match_dup 2)))])
6722 (clobber (match_dup 4))]
9602b6a1 6723 "TARGET_ZARCH"
9db1d521 6724{
d8485bdb
TS
6725 rtx div_equal, mod_equal, equal;
6726 rtx_insn *insn;
4023fb28
UW
6727
6728 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
6729 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
6730 equal = gen_rtx_IOR (TImode,
4023fb28
UW
6731 gen_rtx_ASHIFT (TImode,
6732 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
5665e398
UW
6733 GEN_INT (64)),
6734 gen_rtx_ZERO_EXTEND (TImode, div_equal));
4023fb28
UW
6735
6736 operands[4] = gen_reg_rtx(TImode);
c41c1387 6737 emit_clobber (operands[4]);
4023fb28
UW
6738 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
6739 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
bd94cb6e 6740
4023fb28 6741 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6742 set_unique_reg_note (insn, REG_EQUAL, equal);
4023fb28
UW
6743
6744 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
bd94cb6e 6745 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6746
6747 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
bd94cb6e 6748 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6749
9db1d521 6750 DONE;
10bbf137 6751})
9db1d521
HP
6752
6753(define_insn "udivmodtidi3"
4023fb28 6754 [(set (match_operand:TI 0 "register_operand" "=d,d")
2f7e5a0d 6755 (ior:TI
5665e398
UW
6756 (ashift:TI
6757 (zero_extend:TI
6758 (truncate:DI
2f7e5a0d
EC
6759 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
6760 (zero_extend:TI
3e4be43f 6761 (match_operand:DI 2 "nonimmediate_operand" "d,T")))))
5665e398
UW
6762 (const_int 64))
6763 (zero_extend:TI
6764 (truncate:DI
6765 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
9602b6a1 6766 "TARGET_ZARCH"
9db1d521 6767 "@
d40c829f
UW
6768 dlgr\t%0,%2
6769 dlg\t%0,%2"
d3632d41 6770 [(set_attr "op_type" "RRE,RXY")
077dab3b 6771 (set_attr "type" "idiv")])
9db1d521
HP
6772
6773;
4023fb28 6774; divmodsi4 instruction pattern(s).
9db1d521
HP
6775;
6776
4023fb28
UW
6777(define_expand "divmodsi4"
6778 [(parallel [(set (match_operand:SI 0 "general_operand" "")
6779 (div:SI (match_operand:SI 1 "general_operand" "")
6780 (match_operand:SI 2 "nonimmediate_operand" "")))
6781 (set (match_operand:SI 3 "general_operand" "")
6782 (mod:SI (match_dup 1) (match_dup 2)))])
6783 (clobber (match_dup 4))]
9602b6a1 6784 "!TARGET_ZARCH"
9db1d521 6785{
d8485bdb
TS
6786 rtx div_equal, mod_equal, equal;
6787 rtx_insn *insn;
4023fb28
UW
6788
6789 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
6790 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
6791 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6792 gen_rtx_ASHIFT (DImode,
6793 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5665e398
UW
6794 GEN_INT (32)),
6795 gen_rtx_ZERO_EXTEND (DImode, div_equal));
4023fb28
UW
6796
6797 operands[4] = gen_reg_rtx(DImode);
6798 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
bd94cb6e 6799
4023fb28 6800 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6801 set_unique_reg_note (insn, REG_EQUAL, equal);
4023fb28
UW
6802
6803 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
bd94cb6e 6804 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6805
6806 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
bd94cb6e 6807 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6808
9db1d521 6809 DONE;
10bbf137 6810})
9db1d521
HP
6811
6812(define_insn "divmoddisi3"
4023fb28 6813 [(set (match_operand:DI 0 "register_operand" "=d,d")
2f7e5a0d 6814 (ior:DI
5665e398
UW
6815 (ashift:DI
6816 (zero_extend:DI
6817 (truncate:SI
2f7e5a0d
EC
6818 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
6819 (sign_extend:DI
5665e398
UW
6820 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
6821 (const_int 32))
6822 (zero_extend:DI
6823 (truncate:SI
6824 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
9602b6a1 6825 "!TARGET_ZARCH"
9db1d521 6826 "@
d40c829f
UW
6827 dr\t%0,%2
6828 d\t%0,%2"
9db1d521 6829 [(set_attr "op_type" "RR,RX")
077dab3b 6830 (set_attr "type" "idiv")])
9db1d521
HP
6831
6832;
6833; udivsi3 and umodsi3 instruction pattern(s).
6834;
6835
f1e77d83
UW
6836(define_expand "udivmodsi4"
6837 [(parallel [(set (match_operand:SI 0 "general_operand" "")
6838 (udiv:SI (match_operand:SI 1 "general_operand" "")
6839 (match_operand:SI 2 "nonimmediate_operand" "")))
6840 (set (match_operand:SI 3 "general_operand" "")
6841 (umod:SI (match_dup 1) (match_dup 2)))])
6842 (clobber (match_dup 4))]
9602b6a1 6843 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1e77d83 6844{
d8485bdb
TS
6845 rtx div_equal, mod_equal, equal;
6846 rtx_insn *insn;
f1e77d83
UW
6847
6848 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6849 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6850 equal = gen_rtx_IOR (DImode,
f1e77d83
UW
6851 gen_rtx_ASHIFT (DImode,
6852 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5665e398
UW
6853 GEN_INT (32)),
6854 gen_rtx_ZERO_EXTEND (DImode, div_equal));
f1e77d83
UW
6855
6856 operands[4] = gen_reg_rtx(DImode);
c41c1387 6857 emit_clobber (operands[4]);
f1e77d83
UW
6858 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
6859 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
bd94cb6e 6860
f1e77d83 6861 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6862 set_unique_reg_note (insn, REG_EQUAL, equal);
f1e77d83
UW
6863
6864 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
bd94cb6e 6865 set_unique_reg_note (insn, REG_EQUAL, div_equal);
f1e77d83
UW
6866
6867 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
bd94cb6e 6868 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
f1e77d83
UW
6869
6870 DONE;
6871})
6872
6873(define_insn "udivmoddisi3"
6874 [(set (match_operand:DI 0 "register_operand" "=d,d")
2f7e5a0d 6875 (ior:DI
5665e398
UW
6876 (ashift:DI
6877 (zero_extend:DI
6878 (truncate:SI
2f7e5a0d
EC
6879 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
6880 (zero_extend:DI
3e4be43f 6881 (match_operand:SI 2 "nonimmediate_operand" "d,T")))))
5665e398
UW
6882 (const_int 32))
6883 (zero_extend:DI
6884 (truncate:SI
6885 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
9602b6a1 6886 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1e77d83
UW
6887 "@
6888 dlr\t%0,%2
6889 dl\t%0,%2"
6890 [(set_attr "op_type" "RRE,RXY")
6891 (set_attr "type" "idiv")])
4023fb28 6892
9db1d521
HP
6893(define_expand "udivsi3"
6894 [(set (match_operand:SI 0 "register_operand" "=d")
6895 (udiv:SI (match_operand:SI 1 "general_operand" "")
4023fb28
UW
6896 (match_operand:SI 2 "general_operand" "")))
6897 (clobber (match_dup 3))]
9602b6a1 6898 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
9db1d521 6899{
d8485bdb
TS
6900 rtx udiv_equal, umod_equal, equal;
6901 rtx_insn *insn;
4023fb28
UW
6902
6903 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6904 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6905 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6906 gen_rtx_ASHIFT (DImode,
6907 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5665e398
UW
6908 GEN_INT (32)),
6909 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
9db1d521 6910
4023fb28 6911 operands[3] = gen_reg_rtx (DImode);
9db1d521
HP
6912
6913 if (CONSTANT_P (operands[2]))
6914 {
6915 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
6916 {
19f8b229 6917 rtx_code_label *label1 = gen_label_rtx ();
9db1d521 6918
4023fb28
UW
6919 operands[1] = make_safe_from (operands[1], operands[0]);
6920 emit_move_insn (operands[0], const0_rtx);
f90b7a5a
PB
6921 emit_cmp_and_jump_insns (operands[1], operands[2], LT, NULL_RTX,
6922 SImode, 1, label1);
4023fb28 6923 emit_move_insn (operands[0], const1_rtx);
9db1d521
HP
6924 emit_label (label1);
6925 }
6926 else
6927 {
c7453384
EC
6928 operands[2] = force_reg (SImode, operands[2]);
6929 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
6930
6931 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6932 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6933 operands[2]));
bd94cb6e 6934 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
6935
6936 insn = emit_move_insn (operands[0],
4023fb28 6937 gen_lowpart (SImode, operands[3]));
bd94cb6e 6938 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
9db1d521
HP
6939 }
6940 }
6941 else
c7453384 6942 {
19f8b229
TS
6943 rtx_code_label *label1 = gen_label_rtx ();
6944 rtx_code_label *label2 = gen_label_rtx ();
6945 rtx_code_label *label3 = gen_label_rtx ();
9db1d521 6946
c7453384
EC
6947 operands[1] = force_reg (SImode, operands[1]);
6948 operands[1] = make_safe_from (operands[1], operands[0]);
6949 operands[2] = force_reg (SImode, operands[2]);
6950 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
6951
6952 emit_move_insn (operands[0], const0_rtx);
f90b7a5a
PB
6953 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
6954 SImode, 1, label3);
6955 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
6956 SImode, 0, label2);
6957 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
6958 SImode, 0, label1);
4023fb28
UW
6959 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6960 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6961 operands[2]));
bd94cb6e 6962 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
6963
6964 insn = emit_move_insn (operands[0],
4023fb28 6965 gen_lowpart (SImode, operands[3]));
bd94cb6e
SB
6966 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
6967
f314b9b1 6968 emit_jump (label3);
9db1d521 6969 emit_label (label1);
4023fb28 6970 emit_move_insn (operands[0], operands[1]);
f314b9b1 6971 emit_jump (label3);
9db1d521 6972 emit_label (label2);
4023fb28 6973 emit_move_insn (operands[0], const1_rtx);
9db1d521
HP
6974 emit_label (label3);
6975 }
c7453384 6976 emit_move_insn (operands[0], operands[0]);
9db1d521 6977 DONE;
10bbf137 6978})
9db1d521
HP
6979
6980(define_expand "umodsi3"
6981 [(set (match_operand:SI 0 "register_operand" "=d")
6982 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
4023fb28
UW
6983 (match_operand:SI 2 "nonimmediate_operand" "")))
6984 (clobber (match_dup 3))]
9602b6a1 6985 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
9db1d521 6986{
d8485bdb
TS
6987 rtx udiv_equal, umod_equal, equal;
6988 rtx_insn *insn;
4023fb28
UW
6989
6990 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6991 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6992 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6993 gen_rtx_ASHIFT (DImode,
6994 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5665e398
UW
6995 GEN_INT (32)),
6996 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
9db1d521 6997
4023fb28 6998 operands[3] = gen_reg_rtx (DImode);
9db1d521
HP
6999
7000 if (CONSTANT_P (operands[2]))
7001 {
7002 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
7003 {
19f8b229 7004 rtx_code_label *label1 = gen_label_rtx ();
9db1d521 7005
4023fb28
UW
7006 operands[1] = make_safe_from (operands[1], operands[0]);
7007 emit_move_insn (operands[0], operands[1]);
f90b7a5a
PB
7008 emit_cmp_and_jump_insns (operands[0], operands[2], LT, NULL_RTX,
7009 SImode, 1, label1);
4023fb28
UW
7010 emit_insn (gen_abssi2 (operands[0], operands[2]));
7011 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
9db1d521
HP
7012 emit_label (label1);
7013 }
7014 else
7015 {
c7453384
EC
7016 operands[2] = force_reg (SImode, operands[2]);
7017 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
7018
7019 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
7020 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
7021 operands[2]));
bd94cb6e 7022 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
7023
7024 insn = emit_move_insn (operands[0],
4023fb28 7025 gen_highpart (SImode, operands[3]));
bd94cb6e 7026 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
9db1d521
HP
7027 }
7028 }
7029 else
7030 {
19f8b229
TS
7031 rtx_code_label *label1 = gen_label_rtx ();
7032 rtx_code_label *label2 = gen_label_rtx ();
7033 rtx_code_label *label3 = gen_label_rtx ();
9db1d521 7034
c7453384
EC
7035 operands[1] = force_reg (SImode, operands[1]);
7036 operands[1] = make_safe_from (operands[1], operands[0]);
7037 operands[2] = force_reg (SImode, operands[2]);
7038 operands[2] = make_safe_from (operands[2], operands[0]);
9db1d521 7039
c7453384 7040 emit_move_insn(operands[0], operands[1]);
f90b7a5a
PB
7041 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
7042 SImode, 1, label3);
7043 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
7044 SImode, 0, label2);
7045 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
7046 SImode, 0, label1);
4023fb28
UW
7047 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
7048 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
7049 operands[2]));
bd94cb6e 7050 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
7051
7052 insn = emit_move_insn (operands[0],
4023fb28 7053 gen_highpart (SImode, operands[3]));
bd94cb6e
SB
7054 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
7055
f314b9b1 7056 emit_jump (label3);
9db1d521 7057 emit_label (label1);
4023fb28 7058 emit_move_insn (operands[0], const0_rtx);
f314b9b1 7059 emit_jump (label3);
9db1d521 7060 emit_label (label2);
4023fb28 7061 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
9db1d521
HP
7062 emit_label (label3);
7063 }
9db1d521 7064 DONE;
10bbf137 7065})
9db1d521
HP
7066
7067;
f5905b37 7068; div(df|sf)3 instruction pattern(s).
9db1d521
HP
7069;
7070
609e7e80 7071; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
142cd70f 7072(define_insn "div<mode>3"
62d3f261
AK
7073 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
7074 (div:FP (match_operand:FP 1 "register_operand" "f,0,0,v")
7075 (match_operand:FP 2 "general_operand" "f,f,R,v")))]
142cd70f 7076 "TARGET_HARD_FLOAT"
9db1d521 7077 "@
62d3f261
AK
7078 d<xde>tr\t%0,%1,%2
7079 d<xde>br\t%0,%2
6e5b5de8
AK
7080 d<xde>b\t%0,%2
7081 wfddb\t%v0,%v1,%v2"
62d3f261 7082 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6e5b5de8 7083 (set_attr "type" "fdiv<mode>")
62d3f261
AK
7084 (set_attr "cpu_facility" "*,*,*,vec")
7085 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
9db1d521 7086
9db1d521
HP
7087
7088;;
7089;;- And instructions.
7090;;
7091
047d35ed
AS
7092(define_expand "and<mode>3"
7093 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7094 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
7095 (match_operand:INT 2 "general_operand" "")))
7096 (clobber (reg:CC CC_REGNUM))]
7097 ""
7098 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
7099
9db1d521
HP
7100;
7101; anddi3 instruction pattern(s).
7102;
7103
7104(define_insn "*anddi3_cc"
ae156f85 7105 [(set (reg CC_REGNUM)
e3140518 7106 (compare
3e4be43f 7107 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0, d")
c2586c82 7108 (match_operand:DI 2 "general_operand" " d,d,T,NxxDw"))
e3140518 7109 (const_int 0)))
3e4be43f 7110 (set (match_operand:DI 0 "register_operand" "=d,d,d, d")
9db1d521 7111 (and:DI (match_dup 1) (match_dup 2)))]
e3140518 7112 "TARGET_ZARCH && s390_match_ccmode(insn, CCTmode)"
9db1d521 7113 "@
d40c829f 7114 ngr\t%0,%2
65b1d8ea 7115 ngrk\t%0,%1,%2
e3140518
RH
7116 ng\t%0,%2
7117 risbg\t%0,%1,%s2,128+%e2,0"
7118 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
7119 (set_attr "cpu_facility" "*,z196,*,z10")
7120 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521
HP
7121
7122(define_insn "*anddi3_cconly"
ae156f85 7123 [(set (reg CC_REGNUM)
e3140518 7124 (compare
3e4be43f 7125 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0, d")
c2586c82 7126 (match_operand:DI 2 "general_operand" " d,d,T,NxxDw"))
9db1d521 7127 (const_int 0)))
3e4be43f 7128 (clobber (match_scratch:DI 0 "=d,d,d, d"))]
e3140518
RH
7129 "TARGET_ZARCH
7130 && s390_match_ccmode(insn, CCTmode)
68f9c5e2
UW
7131 /* Do not steal TM patterns. */
7132 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
9db1d521 7133 "@
d40c829f 7134 ngr\t%0,%2
65b1d8ea 7135 ngrk\t%0,%1,%2
e3140518
RH
7136 ng\t%0,%2
7137 risbg\t%0,%1,%s2,128+%e2,0"
7138 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
7139 (set_attr "cpu_facility" "*,z196,*,z10")
7140 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 7141
3af8e996 7142(define_insn "*anddi3"
65b1d8ea 7143 [(set (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 7144 "=d,d, d, d, d, d, d, d,d,d,d, d, AQ,Q")
e3140518
RH
7145 (and:DI
7146 (match_operand:DI 1 "nonimmediate_operand"
3e4be43f 7147 "%d,o, 0, 0, 0, 0, 0, 0,0,d,0, d, 0,0")
e3140518 7148 (match_operand:DI 2 "general_operand"
c2586c82 7149 "M, M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,d,T,NxxDw,NxQDF,Q")))
ec24698e 7150 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7151 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
7152 "@
7153 #
7154 #
7155 nihh\t%0,%j2
7156 nihl\t%0,%j2
7157 nilh\t%0,%j2
7158 nill\t%0,%j2
7159 nihf\t%0,%m2
7160 nilf\t%0,%m2
7161 ngr\t%0,%2
65b1d8ea 7162 ngrk\t%0,%1,%2
ec24698e 7163 ng\t%0,%2
e3140518 7164 risbg\t%0,%1,%s2,128+%e2,0
ec24698e
UW
7165 #
7166 #"
e3140518
RH
7167 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,RIE,SI,SS")
7168 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,z196,*,z10,*,*")
9381e3f1
WG
7169 (set_attr "z10prop" "*,
7170 *,
7171 z10_super_E1,
7172 z10_super_E1,
7173 z10_super_E1,
7174 z10_super_E1,
7175 z10_super_E1,
7176 z10_super_E1,
7177 z10_super_E1,
65b1d8ea 7178 *,
9381e3f1 7179 z10_super_E1,
e3140518 7180 z10_super_E1,
9381e3f1
WG
7181 *,
7182 *")])
0dfa6c5e
UW
7183
7184(define_split
7185 [(set (match_operand:DI 0 "s_operand" "")
7186 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 7187 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7188 "reload_completed"
7189 [(parallel
7190 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 7191 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7192 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
4023fb28 7193
1a2e356e 7194;; These two are what combine generates for (ashift (zero_extract)).
64c744b9 7195(define_insn "*extzv_<mode>_srl<clobbercc_or_nocc>"
1a2e356e
RH
7196 [(set (match_operand:GPR 0 "register_operand" "=d")
7197 (and:GPR (lshiftrt:GPR
7198 (match_operand:GPR 1 "register_operand" "d")
7199 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
ab4be5d1 7200 (match_operand:GPR 3 "contiguous_bitmask_nowrap_operand" "")))]
64c744b9 7201 "<z10_or_zEC12_cond>
1a2e356e
RH
7202 /* Note that even for the SImode pattern, the rotate is always DImode. */
7203 && s390_extzv_shift_ok (<bitsize>, -INTVAL (operands[2]),
7204 INTVAL (operands[3]))"
64c744b9 7205 "<risbg_n>\t%0,%1,%<bfstart>3,128+%<bfend>3,64-%2"
1a2e356e
RH
7206 [(set_attr "op_type" "RIE")
7207 (set_attr "z10prop" "z10_super_E1")])
7208
64c744b9 7209(define_insn "*extzv_<mode>_sll<clobbercc_or_nocc>"
1a2e356e
RH
7210 [(set (match_operand:GPR 0 "register_operand" "=d")
7211 (and:GPR (ashift:GPR
7212 (match_operand:GPR 1 "register_operand" "d")
7213 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
ab4be5d1 7214 (match_operand:GPR 3 "contiguous_bitmask_nowrap_operand" "")))]
64c744b9 7215 "<z10_or_zEC12_cond>
1a2e356e
RH
7216 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[2]),
7217 INTVAL (operands[3]))"
64c744b9 7218 "<risbg_n>\t%0,%1,%<bfstart>3,128+%<bfend>3,%2"
1a2e356e
RH
7219 [(set_attr "op_type" "RIE")
7220 (set_attr "z10prop" "z10_super_E1")])
7221
9db1d521
HP
7222
7223;
7224; andsi3 instruction pattern(s).
7225;
7226
7227(define_insn "*andsi3_cc"
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 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d, d")
9db1d521
HP
7235 (and:SI (match_dup 1) (match_dup 2)))]
7236 "s390_match_ccmode(insn, CCTmode)"
7237 "@
ec24698e 7238 nilf\t%0,%o2
d40c829f 7239 nr\t%0,%2
65b1d8ea 7240 nrk\t%0,%1,%2
d40c829f 7241 n\t%0,%2
e3140518
RH
7242 ny\t%0,%2
7243 risbg\t%0,%1,%t2,128+%f2,0"
7244 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
3e4be43f 7245 (set_attr "cpu_facility" "*,*,z196,*,longdisp,z10")
e3140518
RH
7246 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7247 z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521
HP
7248
7249(define_insn "*andsi3_cconly"
ae156f85 7250 [(set (reg CC_REGNUM)
e3140518
RH
7251 (compare
7252 (and:SI
7253 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
7254 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
7255 (const_int 0)))
7256 (clobber (match_scratch:SI 0 "=d,d,d,d,d, d"))]
68f9c5e2
UW
7257 "s390_match_ccmode(insn, CCTmode)
7258 /* Do not steal TM patterns. */
7259 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
9db1d521 7260 "@
ec24698e 7261 nilf\t%0,%o2
d40c829f 7262 nr\t%0,%2
65b1d8ea 7263 nrk\t%0,%1,%2
d40c829f 7264 n\t%0,%2
e3140518
RH
7265 ny\t%0,%2
7266 risbg\t%0,%1,%t2,128+%f2,0"
7267 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
3e4be43f 7268 (set_attr "cpu_facility" "*,*,z196,*,longdisp,z10")
65b1d8ea 7269 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
e3140518 7270 z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 7271
f19a9af7 7272(define_insn "*andsi3_zarch"
65b1d8ea 7273 [(set (match_operand:SI 0 "nonimmediate_operand"
e3140518 7274 "=d,d, d, d, d,d,d,d,d, d, AQ,Q")
0dfa6c5e 7275 (and:SI (match_operand:SI 1 "nonimmediate_operand"
e3140518 7276 "%d,o, 0, 0, 0,0,d,0,0, d, 0,0")
0dfa6c5e 7277 (match_operand:SI 2 "general_operand"
c2586c82 7278 " M,M,N0HSF,N1HSF,Os,d,d,R,T,NxxSw,NxQSF,Q")))
ae156f85 7279 (clobber (reg:CC CC_REGNUM))]
8cb66696 7280 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 7281 "@
f19a9af7
AK
7282 #
7283 #
7284 nilh\t%0,%j2
2f7e5a0d 7285 nill\t%0,%j2
ec24698e 7286 nilf\t%0,%o2
d40c829f 7287 nr\t%0,%2
65b1d8ea 7288 nrk\t%0,%1,%2
d40c829f 7289 n\t%0,%2
8cb66696 7290 ny\t%0,%2
e3140518 7291 risbg\t%0,%1,%t2,128+%f2,0
0dfa6c5e 7292 #
19b63d8e 7293 #"
e3140518 7294 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RRF,RX,RXY,RIE,SI,SS")
3e4be43f 7295 (set_attr "cpu_facility" "*,*,*,*,*,*,z196,*,longdisp,z10,*,*")
9381e3f1
WG
7296 (set_attr "z10prop" "*,
7297 *,
7298 z10_super_E1,
7299 z10_super_E1,
7300 z10_super_E1,
7301 z10_super_E1,
65b1d8ea 7302 *,
9381e3f1
WG
7303 z10_super_E1,
7304 z10_super_E1,
e3140518 7305 z10_super_E1,
9381e3f1
WG
7306 *,
7307 *")])
f19a9af7
AK
7308
7309(define_insn "*andsi3_esa"
65b1d8ea
AK
7310 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d, AQ,Q")
7311 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0, 0,0")
7312 (match_operand:SI 2 "general_operand" " d,R,NxQSF,Q")))
ae156f85 7313 (clobber (reg:CC CC_REGNUM))]
8cb66696 7314 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
f19a9af7
AK
7315 "@
7316 nr\t%0,%2
8cb66696 7317 n\t%0,%2
0dfa6c5e 7318 #
19b63d8e 7319 #"
9381e3f1
WG
7320 [(set_attr "op_type" "RR,RX,SI,SS")
7321 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
7322
0dfa6c5e
UW
7323
7324(define_split
7325 [(set (match_operand:SI 0 "s_operand" "")
7326 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 7327 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7328 "reload_completed"
7329 [(parallel
7330 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 7331 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7332 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
4023fb28 7333
9db1d521
HP
7334;
7335; andhi3 instruction pattern(s).
7336;
7337
8cb66696 7338(define_insn "*andhi3_zarch"
65b1d8ea
AK
7339 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7340 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
7341 (match_operand:HI 2 "general_operand" " d,d,n,NxQHF,Q")))
ae156f85 7342 (clobber (reg:CC CC_REGNUM))]
8cb66696 7343 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7344 "@
d40c829f 7345 nr\t%0,%2
65b1d8ea 7346 nrk\t%0,%1,%2
8cb66696 7347 nill\t%0,%x2
0dfa6c5e 7348 #
19b63d8e 7349 #"
65b1d8ea
AK
7350 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
7351 (set_attr "cpu_facility" "*,z196,*,*,*")
7352 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")
9381e3f1 7353])
8cb66696
UW
7354
7355(define_insn "*andhi3_esa"
0dfa6c5e
UW
7356 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
7357 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
7358 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
ae156f85 7359 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
7360 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7361 "@
7362 nr\t%0,%2
0dfa6c5e 7363 #
19b63d8e 7364 #"
9381e3f1
WG
7365 [(set_attr "op_type" "RR,SI,SS")
7366 (set_attr "z10prop" "z10_super_E1,*,*")
7367])
0dfa6c5e
UW
7368
7369(define_split
7370 [(set (match_operand:HI 0 "s_operand" "")
7371 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 7372 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7373 "reload_completed"
7374 [(parallel
7375 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 7376 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7377 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
9db1d521 7378
9db1d521
HP
7379;
7380; andqi3 instruction pattern(s).
7381;
7382
8cb66696 7383(define_insn "*andqi3_zarch"
65b1d8ea
AK
7384 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7385 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7386 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
ae156f85 7387 (clobber (reg:CC CC_REGNUM))]
8cb66696 7388 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7389 "@
d40c829f 7390 nr\t%0,%2
65b1d8ea 7391 nrk\t%0,%1,%2
8cb66696 7392 nill\t%0,%b2
fc0ea003
UW
7393 ni\t%S0,%b2
7394 niy\t%S0,%b2
19b63d8e 7395 #"
65b1d8ea 7396 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
3e4be43f 7397 (set_attr "cpu_facility" "*,z196,*,*,longdisp,*")
65b1d8ea 7398 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super,z10_super,*")])
8cb66696
UW
7399
7400(define_insn "*andqi3_esa"
7401 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
7402 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7403 (match_operand:QI 2 "general_operand" "d,n,Q")))
ae156f85 7404 (clobber (reg:CC CC_REGNUM))]
8cb66696 7405 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 7406 "@
8cb66696 7407 nr\t%0,%2
fc0ea003 7408 ni\t%S0,%b2
19b63d8e 7409 #"
9381e3f1
WG
7410 [(set_attr "op_type" "RR,SI,SS")
7411 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
4023fb28 7412
deb9351f
DV
7413;
7414; And with complement
7415;
7416; c = ~b & a = (b & a) ^ a
7417
7418(define_insn_and_split "*andc_split_<mode>"
7419 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
7420 (and:GPR (not:GPR (match_operand:GPR 1 "nonimmediate_operand" ""))
7421 (match_operand:GPR 2 "general_operand" "")))
7422 (clobber (reg:CC CC_REGNUM))]
ad7ab32e
DV
7423 "! reload_completed
7424 && (GET_CODE (operands[0]) != MEM
7425 /* Ensure that s390_logical_operator_ok_p will succeed even
7426 on the split xor if (b & a) is stored into a pseudo. */
7427 || rtx_equal_p (operands[0], operands[2]))"
deb9351f
DV
7428 "#"
7429 "&& 1"
7430 [
7431 (parallel
7432 [(set (match_dup 3) (and:GPR (match_dup 1) (match_dup 2)))
7433 (clobber (reg:CC CC_REGNUM))])
7434 (parallel
7435 [(set (match_dup 0) (xor:GPR (match_dup 3) (match_dup 2)))
7436 (clobber (reg:CC CC_REGNUM))])]
7437{
7438 if (reg_overlap_mentioned_p (operands[0], operands[2]))
7439 operands[3] = gen_reg_rtx (<MODE>mode);
7440 else
7441 operands[3] = operands[0];
7442})
7443
19b63d8e
UW
7444;
7445; Block and (NC) patterns.
7446;
7447
7448(define_insn "*nc"
7449 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7450 (and:BLK (match_dup 0)
7451 (match_operand:BLK 1 "memory_operand" "Q")))
7452 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 7453 (clobber (reg:CC CC_REGNUM))]
19b63d8e 7454 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 7455 "nc\t%O0(%2,%R0),%S1"
65b1d8ea
AK
7456 [(set_attr "op_type" "SS")
7457 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
7458
7459(define_split
7460 [(set (match_operand 0 "memory_operand" "")
7461 (and (match_dup 0)
7462 (match_operand 1 "memory_operand" "")))
ae156f85 7463 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
7464 "reload_completed
7465 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7466 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7467 [(parallel
7468 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
7469 (use (match_dup 2))
ae156f85 7470 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7471{
7472 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7473 operands[0] = adjust_address (operands[0], BLKmode, 0);
7474 operands[1] = adjust_address (operands[1], BLKmode, 0);
7475})
7476
7477(define_peephole2
7478 [(parallel
7479 [(set (match_operand:BLK 0 "memory_operand" "")
7480 (and:BLK (match_dup 0)
7481 (match_operand:BLK 1 "memory_operand" "")))
7482 (use (match_operand 2 "const_int_operand" ""))
ae156f85 7483 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
7484 (parallel
7485 [(set (match_operand:BLK 3 "memory_operand" "")
7486 (and:BLK (match_dup 3)
7487 (match_operand:BLK 4 "memory_operand" "")))
7488 (use (match_operand 5 "const_int_operand" ""))
ae156f85 7489 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7490 "s390_offset_p (operands[0], operands[3], operands[2])
7491 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 7492 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 7493 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
7494 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7495 [(parallel
7496 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
7497 (use (match_dup 8))
ae156f85 7498 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7499 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7500 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7501 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7502
9db1d521
HP
7503
7504;;
7505;;- Bit set (inclusive or) instructions.
7506;;
7507
047d35ed
AS
7508(define_expand "ior<mode>3"
7509 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7510 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
7511 (match_operand:INT 2 "general_operand" "")))
7512 (clobber (reg:CC CC_REGNUM))]
7513 ""
7514 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
7515
9db1d521
HP
7516;
7517; iordi3 instruction pattern(s).
7518;
7519
4023fb28 7520(define_insn "*iordi3_cc"
ae156f85 7521 [(set (reg CC_REGNUM)
3e4be43f
UW
7522 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7523 (match_operand:DI 2 "general_operand" " d,d,T"))
4023fb28 7524 (const_int 0)))
3e4be43f 7525 (set (match_operand:DI 0 "register_operand" "=d,d,d")
4023fb28 7526 (ior:DI (match_dup 1) (match_dup 2)))]
9602b6a1 7527 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7528 "@
d40c829f 7529 ogr\t%0,%2
65b1d8ea 7530 ogrk\t%0,%1,%2
d40c829f 7531 og\t%0,%2"
65b1d8ea
AK
7532 [(set_attr "op_type" "RRE,RRF,RXY")
7533 (set_attr "cpu_facility" "*,z196,*")
7534 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28
UW
7535
7536(define_insn "*iordi3_cconly"
ae156f85 7537 [(set (reg CC_REGNUM)
65b1d8ea 7538 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
3e4be43f 7539 (match_operand:DI 2 "general_operand" " d,d,T"))
4023fb28 7540 (const_int 0)))
65b1d8ea 7541 (clobber (match_scratch:DI 0 "=d,d,d"))]
9602b6a1 7542 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7543 "@
d40c829f 7544 ogr\t%0,%2
65b1d8ea 7545 ogrk\t%0,%1,%2
d40c829f 7546 og\t%0,%2"
65b1d8ea
AK
7547 [(set_attr "op_type" "RRE,RRF,RXY")
7548 (set_attr "cpu_facility" "*,z196,*")
7549 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28 7550
3af8e996 7551(define_insn "*iordi3"
65b1d8ea 7552 [(set (match_operand:DI 0 "nonimmediate_operand"
3e4be43f 7553 "=d, d, d, d, d, d,d,d,d, AQ,Q")
65b1d8ea 7554 (ior:DI (match_operand:DI 1 "nonimmediate_operand"
3e4be43f 7555 " %0, 0, 0, 0, 0, 0,0,d,0, 0,0")
ec24698e 7556 (match_operand:DI 2 "general_operand"
3e4be43f 7557 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,d,T,NxQD0,Q")))
ec24698e 7558 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7559 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
7560 "@
7561 oihh\t%0,%i2
7562 oihl\t%0,%i2
7563 oilh\t%0,%i2
7564 oill\t%0,%i2
7565 oihf\t%0,%k2
7566 oilf\t%0,%k2
7567 ogr\t%0,%2
65b1d8ea 7568 ogrk\t%0,%1,%2
ec24698e
UW
7569 og\t%0,%2
7570 #
7571 #"
65b1d8ea
AK
7572 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,SI,SS")
7573 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,z196,*,*,*")
9381e3f1
WG
7574 (set_attr "z10prop" "z10_super_E1,
7575 z10_super_E1,
7576 z10_super_E1,
7577 z10_super_E1,
7578 z10_super_E1,
7579 z10_super_E1,
7580 z10_super_E1,
65b1d8ea 7581 *,
9381e3f1
WG
7582 z10_super_E1,
7583 *,
7584 *")])
0dfa6c5e
UW
7585
7586(define_split
7587 [(set (match_operand:DI 0 "s_operand" "")
7588 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 7589 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7590 "reload_completed"
7591 [(parallel
7592 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 7593 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7594 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
4023fb28 7595
9db1d521
HP
7596;
7597; iorsi3 instruction pattern(s).
7598;
7599
4023fb28 7600(define_insn "*iorsi3_cc"
ae156f85 7601 [(set (reg CC_REGNUM)
65b1d8ea
AK
7602 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7603 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7604 (const_int 0)))
65b1d8ea 7605 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
4023fb28
UW
7606 (ior:SI (match_dup 1) (match_dup 2)))]
7607 "s390_match_ccmode(insn, CCTmode)"
7608 "@
ec24698e 7609 oilf\t%0,%o2
d40c829f 7610 or\t%0,%2
65b1d8ea 7611 ork\t%0,%1,%2
d40c829f
UW
7612 o\t%0,%2
7613 oy\t%0,%2"
65b1d8ea 7614 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
3e4be43f 7615 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
65b1d8ea 7616 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
4023fb28
UW
7617
7618(define_insn "*iorsi3_cconly"
ae156f85 7619 [(set (reg CC_REGNUM)
65b1d8ea
AK
7620 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7621 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7622 (const_int 0)))
65b1d8ea 7623 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
4023fb28
UW
7624 "s390_match_ccmode(insn, CCTmode)"
7625 "@
ec24698e 7626 oilf\t%0,%o2
d40c829f 7627 or\t%0,%2
65b1d8ea 7628 ork\t%0,%1,%2
d40c829f
UW
7629 o\t%0,%2
7630 oy\t%0,%2"
65b1d8ea 7631 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
3e4be43f 7632 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
65b1d8ea 7633 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
4023fb28 7634
8cb66696 7635(define_insn "*iorsi3_zarch"
65b1d8ea
AK
7636 [(set (match_operand:SI 0 "nonimmediate_operand" "=d, d, d,d,d,d,d, AQ,Q")
7637 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0, 0, 0,0,d,0,0, 0,0")
7638 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,d,R,T,NxQS0,Q")))
ae156f85 7639 (clobber (reg:CC CC_REGNUM))]
8cb66696 7640 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7641 "@
f19a9af7
AK
7642 oilh\t%0,%i2
7643 oill\t%0,%i2
ec24698e 7644 oilf\t%0,%o2
d40c829f 7645 or\t%0,%2
65b1d8ea 7646 ork\t%0,%1,%2
d40c829f 7647 o\t%0,%2
8cb66696 7648 oy\t%0,%2
0dfa6c5e 7649 #
19b63d8e 7650 #"
65b1d8ea 7651 [(set_attr "op_type" "RI,RI,RIL,RR,RRF,RX,RXY,SI,SS")
3e4be43f 7652 (set_attr "cpu_facility" "*,*,*,*,z196,*,longdisp,*,*")
9381e3f1
WG
7653 (set_attr "z10prop" "z10_super_E1,
7654 z10_super_E1,
7655 z10_super_E1,
7656 z10_super_E1,
65b1d8ea 7657 *,
9381e3f1
WG
7658 z10_super_E1,
7659 z10_super_E1,
7660 *,
7661 *")])
8cb66696
UW
7662
7663(define_insn "*iorsi3_esa"
0dfa6c5e 7664 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
bad82153 7665 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
0dfa6c5e 7666 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
ae156f85 7667 (clobber (reg:CC CC_REGNUM))]
8cb66696 7668 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
f19a9af7
AK
7669 "@
7670 or\t%0,%2
8cb66696 7671 o\t%0,%2
0dfa6c5e 7672 #
19b63d8e 7673 #"
9381e3f1
WG
7674 [(set_attr "op_type" "RR,RX,SI,SS")
7675 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
0dfa6c5e
UW
7676
7677(define_split
7678 [(set (match_operand:SI 0 "s_operand" "")
7679 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 7680 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7681 "reload_completed"
7682 [(parallel
7683 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 7684 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7685 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
4023fb28 7686
4023fb28
UW
7687;
7688; iorhi3 instruction pattern(s).
7689;
7690
8cb66696 7691(define_insn "*iorhi3_zarch"
65b1d8ea
AK
7692 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7693 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
7694 (match_operand:HI 2 "general_operand" " d,d,n,NxQH0,Q")))
ae156f85 7695 (clobber (reg:CC CC_REGNUM))]
8cb66696 7696 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7697 "@
d40c829f 7698 or\t%0,%2
65b1d8ea 7699 ork\t%0,%1,%2
8cb66696 7700 oill\t%0,%x2
0dfa6c5e 7701 #
19b63d8e 7702 #"
65b1d8ea
AK
7703 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
7704 (set_attr "cpu_facility" "*,z196,*,*,*")
7705 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")])
8cb66696
UW
7706
7707(define_insn "*iorhi3_esa"
0dfa6c5e
UW
7708 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
7709 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
7710 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
ae156f85 7711 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
7712 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7713 "@
7714 or\t%0,%2
0dfa6c5e 7715 #
19b63d8e 7716 #"
9381e3f1
WG
7717 [(set_attr "op_type" "RR,SI,SS")
7718 (set_attr "z10prop" "z10_super_E1,*,*")])
0dfa6c5e
UW
7719
7720(define_split
7721 [(set (match_operand:HI 0 "s_operand" "")
7722 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 7723 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7724 "reload_completed"
7725 [(parallel
7726 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 7727 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7728 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
9db1d521 7729
9db1d521 7730;
4023fb28 7731; iorqi3 instruction pattern(s).
9db1d521
HP
7732;
7733
8cb66696 7734(define_insn "*iorqi3_zarch"
65b1d8ea
AK
7735 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7736 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7737 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
ae156f85 7738 (clobber (reg:CC CC_REGNUM))]
8cb66696 7739 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7740 "@
d40c829f 7741 or\t%0,%2
65b1d8ea 7742 ork\t%0,%1,%2
8cb66696 7743 oill\t%0,%b2
fc0ea003
UW
7744 oi\t%S0,%b2
7745 oiy\t%S0,%b2
19b63d8e 7746 #"
65b1d8ea 7747 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
3e4be43f 7748 (set_attr "cpu_facility" "*,z196,*,*,longdisp,*")
65b1d8ea
AK
7749 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,
7750 z10_super,z10_super,*")])
8cb66696
UW
7751
7752(define_insn "*iorqi3_esa"
7753 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
7754 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7755 (match_operand:QI 2 "general_operand" "d,n,Q")))
ae156f85 7756 (clobber (reg:CC CC_REGNUM))]
8cb66696 7757 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 7758 "@
8cb66696 7759 or\t%0,%2
fc0ea003 7760 oi\t%S0,%b2
19b63d8e 7761 #"
9381e3f1
WG
7762 [(set_attr "op_type" "RR,SI,SS")
7763 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
9db1d521 7764
19b63d8e
UW
7765;
7766; Block inclusive or (OC) patterns.
7767;
7768
7769(define_insn "*oc"
7770 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7771 (ior:BLK (match_dup 0)
7772 (match_operand:BLK 1 "memory_operand" "Q")))
7773 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 7774 (clobber (reg:CC CC_REGNUM))]
19b63d8e 7775 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 7776 "oc\t%O0(%2,%R0),%S1"
65b1d8ea
AK
7777 [(set_attr "op_type" "SS")
7778 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
7779
7780(define_split
7781 [(set (match_operand 0 "memory_operand" "")
7782 (ior (match_dup 0)
7783 (match_operand 1 "memory_operand" "")))
ae156f85 7784 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
7785 "reload_completed
7786 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7787 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7788 [(parallel
7789 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
7790 (use (match_dup 2))
ae156f85 7791 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7792{
7793 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7794 operands[0] = adjust_address (operands[0], BLKmode, 0);
7795 operands[1] = adjust_address (operands[1], BLKmode, 0);
7796})
7797
7798(define_peephole2
7799 [(parallel
7800 [(set (match_operand:BLK 0 "memory_operand" "")
7801 (ior:BLK (match_dup 0)
7802 (match_operand:BLK 1 "memory_operand" "")))
7803 (use (match_operand 2 "const_int_operand" ""))
ae156f85 7804 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
7805 (parallel
7806 [(set (match_operand:BLK 3 "memory_operand" "")
7807 (ior:BLK (match_dup 3)
7808 (match_operand:BLK 4 "memory_operand" "")))
7809 (use (match_operand 5 "const_int_operand" ""))
ae156f85 7810 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7811 "s390_offset_p (operands[0], operands[3], operands[2])
7812 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 7813 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 7814 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
7815 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7816 [(parallel
7817 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
7818 (use (match_dup 8))
ae156f85 7819 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7820 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7821 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7822 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7823
9db1d521
HP
7824
7825;;
7826;;- Xor instructions.
7827;;
7828
047d35ed
AS
7829(define_expand "xor<mode>3"
7830 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7831 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
7832 (match_operand:INT 2 "general_operand" "")))
7833 (clobber (reg:CC CC_REGNUM))]
7834 ""
7835 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
7836
3c91f126
AK
7837; Combine replaces (xor (x) (const_int -1)) with (not (x)) when doing
7838; simplifications. So its better to have something matching.
7839(define_split
7840 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7841 (not:INT (match_operand:INT 1 "nonimmediate_operand" "")))]
7842 ""
7843 [(parallel
7844 [(set (match_dup 0) (xor:INT (match_dup 1) (match_dup 2)))
7845 (clobber (reg:CC CC_REGNUM))])]
7846{
7847 operands[2] = constm1_rtx;
7848 if (!s390_logical_operator_ok_p (operands))
7849 FAIL;
7850})
7851
9db1d521
HP
7852;
7853; xordi3 instruction pattern(s).
7854;
7855
4023fb28 7856(define_insn "*xordi3_cc"
ae156f85 7857 [(set (reg CC_REGNUM)
3e4be43f
UW
7858 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7859 (match_operand:DI 2 "general_operand" " d,d,T"))
4023fb28 7860 (const_int 0)))
3e4be43f 7861 (set (match_operand:DI 0 "register_operand" "=d,d,d")
4023fb28 7862 (xor:DI (match_dup 1) (match_dup 2)))]
9602b6a1 7863 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7864 "@
d40c829f 7865 xgr\t%0,%2
65b1d8ea 7866 xgrk\t%0,%1,%2
d40c829f 7867 xg\t%0,%2"
65b1d8ea 7868 [(set_attr "op_type" "RRE,RRF,RXY")
5490de28 7869 (set_attr "cpu_facility" "*,z196,*")
65b1d8ea 7870 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28
UW
7871
7872(define_insn "*xordi3_cconly"
ae156f85 7873 [(set (reg CC_REGNUM)
3e4be43f
UW
7874 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7875 (match_operand:DI 2 "general_operand" " d,d,T"))
4023fb28 7876 (const_int 0)))
3e4be43f 7877 (clobber (match_scratch:DI 0 "=d,d,d"))]
9602b6a1 7878 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7879 "@
d40c829f 7880 xgr\t%0,%2
65b1d8ea 7881 xgrk\t%0,%1,%2
c7fd8cd8 7882 xg\t%0,%2"
65b1d8ea
AK
7883 [(set_attr "op_type" "RRE,RRF,RXY")
7884 (set_attr "cpu_facility" "*,z196,*")
7885 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28 7886
3af8e996 7887(define_insn "*xordi3"
3e4be43f
UW
7888 [(set (match_operand:DI 0 "nonimmediate_operand" "=d, d,d,d,d, AQ,Q")
7889 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0, 0,0,d,0, 0,0")
7890 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,d,T,NxQD0,Q")))
ec24698e 7891 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7892 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
7893 "@
7894 xihf\t%0,%k2
7895 xilf\t%0,%k2
7896 xgr\t%0,%2
65b1d8ea 7897 xgrk\t%0,%1,%2
ec24698e
UW
7898 xg\t%0,%2
7899 #
7900 #"
65b1d8ea
AK
7901 [(set_attr "op_type" "RIL,RIL,RRE,RRF,RXY,SI,SS")
7902 (set_attr "cpu_facility" "extimm,extimm,*,z196,*,*,*")
7903 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,
7904 *,z10_super_E1,*,*")])
0dfa6c5e
UW
7905
7906(define_split
7907 [(set (match_operand:DI 0 "s_operand" "")
7908 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 7909 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7910 "reload_completed"
7911 [(parallel
7912 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 7913 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7914 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
4023fb28 7915
9db1d521
HP
7916;
7917; xorsi3 instruction pattern(s).
7918;
7919
4023fb28 7920(define_insn "*xorsi3_cc"
ae156f85 7921 [(set (reg CC_REGNUM)
65b1d8ea
AK
7922 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7923 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7924 (const_int 0)))
65b1d8ea 7925 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
4023fb28
UW
7926 (xor:SI (match_dup 1) (match_dup 2)))]
7927 "s390_match_ccmode(insn, CCTmode)"
7928 "@
ec24698e 7929 xilf\t%0,%o2
d40c829f 7930 xr\t%0,%2
65b1d8ea 7931 xrk\t%0,%1,%2
d40c829f
UW
7932 x\t%0,%2
7933 xy\t%0,%2"
65b1d8ea 7934 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
3e4be43f 7935 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
65b1d8ea
AK
7936 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7937 z10_super_E1,z10_super_E1")])
4023fb28
UW
7938
7939(define_insn "*xorsi3_cconly"
ae156f85 7940 [(set (reg CC_REGNUM)
65b1d8ea
AK
7941 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7942 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7943 (const_int 0)))
65b1d8ea 7944 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
4023fb28
UW
7945 "s390_match_ccmode(insn, CCTmode)"
7946 "@
ec24698e 7947 xilf\t%0,%o2
d40c829f 7948 xr\t%0,%2
65b1d8ea 7949 xrk\t%0,%1,%2
d40c829f
UW
7950 x\t%0,%2
7951 xy\t%0,%2"
65b1d8ea 7952 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
3e4be43f 7953 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
65b1d8ea
AK
7954 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7955 z10_super_E1,z10_super_E1")])
9db1d521 7956
8cb66696 7957(define_insn "*xorsi3"
65b1d8ea
AK
7958 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d, AQ,Q")
7959 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, 0,0")
7960 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxQS0,Q")))
ae156f85 7961 (clobber (reg:CC CC_REGNUM))]
8cb66696 7962 "s390_logical_operator_ok_p (operands)"
9db1d521 7963 "@
ec24698e 7964 xilf\t%0,%o2
d40c829f 7965 xr\t%0,%2
65b1d8ea 7966 xrk\t%0,%1,%2
d40c829f 7967 x\t%0,%2
8cb66696 7968 xy\t%0,%2
0dfa6c5e 7969 #
19b63d8e 7970 #"
65b1d8ea 7971 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,SI,SS")
3e4be43f 7972 (set_attr "cpu_facility" "*,*,z196,*,longdisp,*,*")
65b1d8ea
AK
7973 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7974 z10_super_E1,z10_super_E1,*,*")])
0dfa6c5e
UW
7975
7976(define_split
7977 [(set (match_operand:SI 0 "s_operand" "")
7978 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 7979 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7980 "reload_completed"
7981 [(parallel
7982 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 7983 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7984 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
8cb66696 7985
9db1d521
HP
7986;
7987; xorhi3 instruction pattern(s).
7988;
7989
8cb66696 7990(define_insn "*xorhi3"
65b1d8ea
AK
7991 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7992 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,d, 0,0")
7993 (match_operand:HI 2 "general_operand" "Os,d,d,NxQH0,Q")))
ae156f85 7994 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
7995 "s390_logical_operator_ok_p (operands)"
7996 "@
ec24698e 7997 xilf\t%0,%x2
8cb66696 7998 xr\t%0,%2
65b1d8ea 7999 xrk\t%0,%1,%2
0dfa6c5e 8000 #
19b63d8e 8001 #"
65b1d8ea
AK
8002 [(set_attr "op_type" "RIL,RR,RRF,SI,SS")
8003 (set_attr "cpu_facility" "*,*,z196,*,*")
8004 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*,*")])
0dfa6c5e
UW
8005
8006(define_split
8007 [(set (match_operand:HI 0 "s_operand" "")
8008 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 8009 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
8010 "reload_completed"
8011 [(parallel
8012 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 8013 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 8014 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
9db1d521 8015
9db1d521
HP
8016;
8017; xorqi3 instruction pattern(s).
8018;
8019
8cb66696 8020(define_insn "*xorqi3"
65b1d8ea
AK
8021 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
8022 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,d,0,0,0")
8023 (match_operand:QI 2 "general_operand" "Os,d,d,n,n,Q")))
ae156f85 8024 (clobber (reg:CC CC_REGNUM))]
8cb66696 8025 "s390_logical_operator_ok_p (operands)"
9db1d521 8026 "@
ec24698e 8027 xilf\t%0,%b2
8cb66696 8028 xr\t%0,%2
65b1d8ea 8029 xrk\t%0,%1,%2
fc0ea003
UW
8030 xi\t%S0,%b2
8031 xiy\t%S0,%b2
19b63d8e 8032 #"
65b1d8ea 8033 [(set_attr "op_type" "RIL,RR,RRF,SI,SIY,SS")
3e4be43f 8034 (set_attr "cpu_facility" "*,*,z196,*,longdisp,*")
65b1d8ea 8035 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super,z10_super,*")])
9381e3f1 8036
4023fb28 8037
19b63d8e
UW
8038;
8039; Block exclusive or (XC) patterns.
8040;
8041
8042(define_insn "*xc"
8043 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8044 (xor:BLK (match_dup 0)
8045 (match_operand:BLK 1 "memory_operand" "Q")))
8046 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 8047 (clobber (reg:CC CC_REGNUM))]
19b63d8e 8048 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 8049 "xc\t%O0(%2,%R0),%S1"
b628bd8e 8050 [(set_attr "op_type" "SS")])
19b63d8e
UW
8051
8052(define_split
8053 [(set (match_operand 0 "memory_operand" "")
8054 (xor (match_dup 0)
8055 (match_operand 1 "memory_operand" "")))
ae156f85 8056 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
8057 "reload_completed
8058 && GET_MODE (operands[0]) == GET_MODE (operands[1])
8059 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
8060 [(parallel
8061 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
8062 (use (match_dup 2))
ae156f85 8063 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8064{
8065 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
8066 operands[0] = adjust_address (operands[0], BLKmode, 0);
8067 operands[1] = adjust_address (operands[1], BLKmode, 0);
8068})
8069
8070(define_peephole2
8071 [(parallel
8072 [(set (match_operand:BLK 0 "memory_operand" "")
8073 (xor:BLK (match_dup 0)
8074 (match_operand:BLK 1 "memory_operand" "")))
8075 (use (match_operand 2 "const_int_operand" ""))
ae156f85 8076 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
8077 (parallel
8078 [(set (match_operand:BLK 3 "memory_operand" "")
8079 (xor:BLK (match_dup 3)
8080 (match_operand:BLK 4 "memory_operand" "")))
8081 (use (match_operand 5 "const_int_operand" ""))
ae156f85 8082 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8083 "s390_offset_p (operands[0], operands[3], operands[2])
8084 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 8085 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 8086 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
8087 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
8088 [(parallel
8089 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
8090 (use (match_dup 8))
ae156f85 8091 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8092 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8093 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
8094 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
8095
8096;
8097; Block xor (XC) patterns with src == dest.
8098;
8099
8100(define_insn "*xc_zero"
8101 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8102 (const_int 0))
8103 (use (match_operand 1 "const_int_operand" "n"))
ae156f85 8104 (clobber (reg:CC CC_REGNUM))]
19b63d8e 8105 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
fc0ea003 8106 "xc\t%O0(%1,%R0),%S0"
65b1d8ea
AK
8107 [(set_attr "op_type" "SS")
8108 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
8109
8110(define_peephole2
8111 [(parallel
8112 [(set (match_operand:BLK 0 "memory_operand" "")
8113 (const_int 0))
8114 (use (match_operand 1 "const_int_operand" ""))
ae156f85 8115 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
8116 (parallel
8117 [(set (match_operand:BLK 2 "memory_operand" "")
8118 (const_int 0))
8119 (use (match_operand 3 "const_int_operand" ""))
ae156f85 8120 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8121 "s390_offset_p (operands[0], operands[2], operands[1])
8122 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
8123 [(parallel
8124 [(set (match_dup 4) (const_int 0))
8125 (use (match_dup 5))
ae156f85 8126 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
8127 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8128 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
8129
9db1d521
HP
8130
8131;;
8132;;- Negate instructions.
8133;;
8134
8135;
9a91a21f 8136; neg(di|si)2 instruction pattern(s).
9db1d521
HP
8137;
8138
9a91a21f 8139(define_expand "neg<mode>2"
9db1d521 8140 [(parallel
9a91a21f
AS
8141 [(set (match_operand:DSI 0 "register_operand" "=d")
8142 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
ae156f85 8143 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8144 ""
8145 "")
8146
26a89301 8147(define_insn "*negdi2_sign_cc"
ae156f85 8148 [(set (reg CC_REGNUM)
26a89301
UW
8149 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
8150 (match_operand:SI 1 "register_operand" "d") 0)
8151 (const_int 32)) (const_int 32)))
8152 (const_int 0)))
8153 (set (match_operand:DI 0 "register_operand" "=d")
8154 (neg:DI (sign_extend:DI (match_dup 1))))]
9602b6a1 8155 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 8156 "lcgfr\t%0,%1"
729e750f
WG
8157 [(set_attr "op_type" "RRE")
8158 (set_attr "z10prop" "z10_c")])
9381e3f1 8159
26a89301
UW
8160(define_insn "*negdi2_sign"
8161 [(set (match_operand:DI 0 "register_operand" "=d")
8162 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
ae156f85 8163 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8164 "TARGET_ZARCH"
26a89301 8165 "lcgfr\t%0,%1"
729e750f
WG
8166 [(set_attr "op_type" "RRE")
8167 (set_attr "z10prop" "z10_c")])
26a89301 8168
43a09b63 8169; lcr, lcgr
9a91a21f 8170(define_insn "*neg<mode>2_cc"
ae156f85 8171 [(set (reg CC_REGNUM)
9a91a21f 8172 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 8173 (const_int 0)))
9a91a21f
AS
8174 (set (match_operand:GPR 0 "register_operand" "=d")
8175 (neg:GPR (match_dup 1)))]
8176 "s390_match_ccmode (insn, CCAmode)"
8177 "lc<g>r\t%0,%1"
9381e3f1
WG
8178 [(set_attr "op_type" "RR<E>")
8179 (set_attr "z10prop" "z10_super_c_E1")])
43a09b63
AK
8180
8181; lcr, lcgr
9a91a21f 8182(define_insn "*neg<mode>2_cconly"
ae156f85 8183 [(set (reg CC_REGNUM)
9a91a21f 8184 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 8185 (const_int 0)))
9a91a21f
AS
8186 (clobber (match_scratch:GPR 0 "=d"))]
8187 "s390_match_ccmode (insn, CCAmode)"
8188 "lc<g>r\t%0,%1"
9381e3f1
WG
8189 [(set_attr "op_type" "RR<E>")
8190 (set_attr "z10prop" "z10_super_c_E1")])
43a09b63
AK
8191
8192; lcr, lcgr
9a91a21f
AS
8193(define_insn "*neg<mode>2"
8194 [(set (match_operand:GPR 0 "register_operand" "=d")
8195 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
ae156f85 8196 (clobber (reg:CC CC_REGNUM))]
9a91a21f
AS
8197 ""
8198 "lc<g>r\t%0,%1"
9381e3f1
WG
8199 [(set_attr "op_type" "RR<E>")
8200 (set_attr "z10prop" "z10_super_c_E1")])
9db1d521 8201
b7d19263 8202(define_insn "*negdi2_31"
9db1d521
HP
8203 [(set (match_operand:DI 0 "register_operand" "=d")
8204 (neg:DI (match_operand:DI 1 "register_operand" "d")))
ae156f85 8205 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8206 "!TARGET_ZARCH"
b7d19263
AK
8207 "#")
8208
8209; Split a DImode NEG on 31bit into 2 SImode NEGs
8210
8211; Doing the twos complement separately on the SImode parts does an
8212; unwanted +1 on the high part which needs to be subtracted afterwards
8213; ... unless the +1 on the low part created an overflow.
8214
8215(define_split
8216 [(set (match_operand:DI 0 "register_operand" "")
8217 (neg:DI (match_operand:DI 1 "register_operand" "")))
8218 (clobber (reg:CC CC_REGNUM))]
8219 "!TARGET_ZARCH
8220 && (REGNO (operands[0]) == REGNO (operands[1])
8221 || s390_split_ok_p (operands[0], operands[1], DImode, 0))
8222 && reload_completed"
26a89301
UW
8223 [(parallel
8224 [(set (match_dup 2) (neg:SI (match_dup 3)))
ae156f85 8225 (clobber (reg:CC CC_REGNUM))])
26a89301 8226 (parallel
ae156f85 8227 [(set (reg:CCAP CC_REGNUM)
26a89301
UW
8228 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
8229 (set (match_dup 4) (neg:SI (match_dup 5)))])
8230 (set (pc)
ae156f85 8231 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
26a89301
UW
8232 (pc)
8233 (label_ref (match_dup 6))))
8234 (parallel
8235 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
ae156f85 8236 (clobber (reg:CC CC_REGNUM))])
26a89301
UW
8237 (match_dup 6)]
8238 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
8239 operands[3] = operand_subword (operands[1], 0, 0, DImode);
8240 operands[4] = operand_subword (operands[0], 1, 0, DImode);
8241 operands[5] = operand_subword (operands[1], 1, 0, DImode);
8242 operands[6] = gen_label_rtx ();")
9db1d521 8243
b7d19263
AK
8244; Like above but first make a copy of the low part of the src operand
8245; since it might overlap with the high part of the destination.
8246
8247(define_split
8248 [(set (match_operand:DI 0 "register_operand" "")
8249 (neg:DI (match_operand:DI 1 "register_operand" "")))
8250 (clobber (reg:CC CC_REGNUM))]
8251 "!TARGET_ZARCH
8252 && s390_split_ok_p (operands[0], operands[1], DImode, 1)
8253 && reload_completed"
8254 [; Make a backup of op5 first
8255 (set (match_dup 4) (match_dup 5))
8256 ; Setting op2 here might clobber op5
8257 (parallel
8258 [(set (match_dup 2) (neg:SI (match_dup 3)))
8259 (clobber (reg:CC CC_REGNUM))])
8260 (parallel
8261 [(set (reg:CCAP CC_REGNUM)
8262 (compare:CCAP (neg:SI (match_dup 4)) (const_int 0)))
8263 (set (match_dup 4) (neg:SI (match_dup 4)))])
8264 (set (pc)
8265 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
8266 (pc)
8267 (label_ref (match_dup 6))))
8268 (parallel
8269 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
8270 (clobber (reg:CC CC_REGNUM))])
8271 (match_dup 6)]
8272 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
8273 operands[3] = operand_subword (operands[1], 0, 0, DImode);
8274 operands[4] = operand_subword (operands[0], 1, 0, DImode);
8275 operands[5] = operand_subword (operands[1], 1, 0, DImode);
8276 operands[6] = gen_label_rtx ();")
8277
9db1d521 8278;
f5905b37 8279; neg(df|sf)2 instruction pattern(s).
9db1d521
HP
8280;
8281
f5905b37 8282(define_expand "neg<mode>2"
9db1d521 8283 [(parallel
7b6baae1
AK
8284 [(set (match_operand:BFP 0 "register_operand" "=f")
8285 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
ae156f85 8286 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8287 "TARGET_HARD_FLOAT"
8288 "")
8289
43a09b63 8290; lcxbr, lcdbr, lcebr
f5905b37 8291(define_insn "*neg<mode>2_cc"
ae156f85 8292 [(set (reg CC_REGNUM)
7b6baae1
AK
8293 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
8294 (match_operand:BFP 2 "const0_operand" "")))
8295 (set (match_operand:BFP 0 "register_operand" "=f")
8296 (neg:BFP (match_dup 1)))]
142cd70f 8297 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8298 "lc<xde>br\t%0,%1"
26a89301 8299 [(set_attr "op_type" "RRE")
f5905b37 8300 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
8301
8302; lcxbr, lcdbr, lcebr
f5905b37 8303(define_insn "*neg<mode>2_cconly"
ae156f85 8304 [(set (reg CC_REGNUM)
7b6baae1
AK
8305 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
8306 (match_operand:BFP 2 "const0_operand" "")))
8307 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 8308 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8309 "lc<xde>br\t%0,%1"
26a89301 8310 [(set_attr "op_type" "RRE")
f5905b37 8311 (set_attr "type" "fsimp<mode>")])
43a09b63 8312
85dae55a
AK
8313; lcdfr
8314(define_insn "*neg<mode>2_nocc"
609e7e80
AK
8315 [(set (match_operand:FP 0 "register_operand" "=f")
8316 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
fb068247 8317 "TARGET_DFP"
85dae55a
AK
8318 "lcdfr\t%0,%1"
8319 [(set_attr "op_type" "RRE")
9381e3f1 8320 (set_attr "type" "fsimp<mode>")])
85dae55a 8321
43a09b63 8322; lcxbr, lcdbr, lcebr
6e5b5de8 8323; FIXME: wflcdb does not clobber cc
f5905b37 8324(define_insn "*neg<mode>2"
62d3f261
AK
8325 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8326 (neg:BFP (match_operand:BFP 1 "register_operand" "f,v")))
ae156f85 8327 (clobber (reg:CC CC_REGNUM))]
142cd70f 8328 "TARGET_HARD_FLOAT"
6e5b5de8
AK
8329 "@
8330 lc<xde>br\t%0,%1
8331 wflcdb\t%0,%1"
8332 [(set_attr "op_type" "RRE,VRR")
8333 (set_attr "cpu_facility" "*,vec")
62d3f261
AK
8334 (set_attr "type" "fsimp<mode>,*")
8335 (set_attr "enabled" "*,<DFDI>")])
9db1d521 8336
9db1d521
HP
8337
8338;;
8339;;- Absolute value instructions.
8340;;
8341
8342;
9a91a21f 8343; abs(di|si)2 instruction pattern(s).
9db1d521
HP
8344;
8345
26a89301 8346(define_insn "*absdi2_sign_cc"
ae156f85 8347 [(set (reg CC_REGNUM)
26a89301
UW
8348 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
8349 (match_operand:SI 1 "register_operand" "d") 0)
8350 (const_int 32)) (const_int 32)))
8351 (const_int 0)))
8352 (set (match_operand:DI 0 "register_operand" "=d")
8353 (abs:DI (sign_extend:DI (match_dup 1))))]
9602b6a1 8354 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 8355 "lpgfr\t%0,%1"
729e750f
WG
8356 [(set_attr "op_type" "RRE")
8357 (set_attr "z10prop" "z10_c")])
26a89301
UW
8358
8359(define_insn "*absdi2_sign"
8360 [(set (match_operand:DI 0 "register_operand" "=d")
8361 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
ae156f85 8362 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8363 "TARGET_ZARCH"
26a89301 8364 "lpgfr\t%0,%1"
729e750f
WG
8365 [(set_attr "op_type" "RRE")
8366 (set_attr "z10prop" "z10_c")])
26a89301 8367
43a09b63 8368; lpr, lpgr
9a91a21f 8369(define_insn "*abs<mode>2_cc"
ae156f85 8370 [(set (reg CC_REGNUM)
9a91a21f 8371 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
26a89301 8372 (const_int 0)))
9a91a21f
AS
8373 (set (match_operand:GPR 0 "register_operand" "=d")
8374 (abs:GPR (match_dup 1)))]
26a89301 8375 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 8376 "lp<g>r\t%0,%1"
9381e3f1
WG
8377 [(set_attr "op_type" "RR<E>")
8378 (set_attr "z10prop" "z10_c")])
43a09b63 8379
9381e3f1 8380; lpr, lpgr
9a91a21f 8381(define_insn "*abs<mode>2_cconly"
ae156f85 8382 [(set (reg CC_REGNUM)
9a91a21f 8383 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 8384 (const_int 0)))
9a91a21f 8385 (clobber (match_scratch:GPR 0 "=d"))]
26a89301 8386 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 8387 "lp<g>r\t%0,%1"
9381e3f1
WG
8388 [(set_attr "op_type" "RR<E>")
8389 (set_attr "z10prop" "z10_c")])
43a09b63
AK
8390
8391; lpr, lpgr
9a91a21f
AS
8392(define_insn "abs<mode>2"
8393 [(set (match_operand:GPR 0 "register_operand" "=d")
8394 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
ae156f85 8395 (clobber (reg:CC CC_REGNUM))]
9db1d521 8396 ""
9a91a21f 8397 "lp<g>r\t%0,%1"
9381e3f1
WG
8398 [(set_attr "op_type" "RR<E>")
8399 (set_attr "z10prop" "z10_c")])
9db1d521 8400
9db1d521 8401;
f5905b37 8402; abs(df|sf)2 instruction pattern(s).
9db1d521
HP
8403;
8404
f5905b37 8405(define_expand "abs<mode>2"
9db1d521 8406 [(parallel
7b6baae1
AK
8407 [(set (match_operand:BFP 0 "register_operand" "=f")
8408 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
ae156f85 8409 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8410 "TARGET_HARD_FLOAT"
8411 "")
8412
43a09b63 8413; lpxbr, lpdbr, lpebr
f5905b37 8414(define_insn "*abs<mode>2_cc"
ae156f85 8415 [(set (reg CC_REGNUM)
7b6baae1
AK
8416 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
8417 (match_operand:BFP 2 "const0_operand" "")))
8418 (set (match_operand:BFP 0 "register_operand" "=f")
8419 (abs:BFP (match_dup 1)))]
142cd70f 8420 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8421 "lp<xde>br\t%0,%1"
26a89301 8422 [(set_attr "op_type" "RRE")
f5905b37 8423 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
8424
8425; lpxbr, lpdbr, lpebr
f5905b37 8426(define_insn "*abs<mode>2_cconly"
ae156f85 8427 [(set (reg CC_REGNUM)
7b6baae1
AK
8428 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
8429 (match_operand:BFP 2 "const0_operand" "")))
8430 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 8431 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8432 "lp<xde>br\t%0,%1"
26a89301 8433 [(set_attr "op_type" "RRE")
f5905b37 8434 (set_attr "type" "fsimp<mode>")])
43a09b63 8435
85dae55a
AK
8436; lpdfr
8437(define_insn "*abs<mode>2_nocc"
609e7e80
AK
8438 [(set (match_operand:FP 0 "register_operand" "=f")
8439 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
fb068247 8440 "TARGET_DFP"
85dae55a
AK
8441 "lpdfr\t%0,%1"
8442 [(set_attr "op_type" "RRE")
9381e3f1 8443 (set_attr "type" "fsimp<mode>")])
85dae55a 8444
43a09b63 8445; lpxbr, lpdbr, lpebr
6e5b5de8 8446; FIXME: wflpdb does not clobber cc
f5905b37 8447(define_insn "*abs<mode>2"
62d3f261
AK
8448 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8449 (abs:BFP (match_operand:BFP 1 "register_operand" "f,v")))
ae156f85 8450 (clobber (reg:CC CC_REGNUM))]
142cd70f 8451 "TARGET_HARD_FLOAT"
6e5b5de8
AK
8452 "@
8453 lp<xde>br\t%0,%1
8454 wflpdb\t%0,%1"
8455 [(set_attr "op_type" "RRE,VRR")
8456 (set_attr "cpu_facility" "*,vec")
62d3f261
AK
8457 (set_attr "type" "fsimp<mode>,*")
8458 (set_attr "enabled" "*,<DFDI>")])
9db1d521 8459
9db1d521 8460
3ef093a8
AK
8461;;
8462;;- Negated absolute value instructions
8463;;
8464
8465;
8466; Integer
8467;
8468
26a89301 8469(define_insn "*negabsdi2_sign_cc"
ae156f85 8470 [(set (reg CC_REGNUM)
26a89301
UW
8471 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
8472 (match_operand:SI 1 "register_operand" "d") 0)
8473 (const_int 32)) (const_int 32))))
8474 (const_int 0)))
8475 (set (match_operand:DI 0 "register_operand" "=d")
8476 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
9602b6a1 8477 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 8478 "lngfr\t%0,%1"
729e750f
WG
8479 [(set_attr "op_type" "RRE")
8480 (set_attr "z10prop" "z10_c")])
9381e3f1 8481
26a89301
UW
8482(define_insn "*negabsdi2_sign"
8483 [(set (match_operand:DI 0 "register_operand" "=d")
8484 (neg:DI (abs:DI (sign_extend:DI
8485 (match_operand:SI 1 "register_operand" "d")))))
ae156f85 8486 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8487 "TARGET_ZARCH"
26a89301 8488 "lngfr\t%0,%1"
729e750f
WG
8489 [(set_attr "op_type" "RRE")
8490 (set_attr "z10prop" "z10_c")])
3ef093a8 8491
43a09b63 8492; lnr, lngr
9a91a21f 8493(define_insn "*negabs<mode>2_cc"
ae156f85 8494 [(set (reg CC_REGNUM)
9a91a21f 8495 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
26a89301 8496 (const_int 0)))
9a91a21f
AS
8497 (set (match_operand:GPR 0 "register_operand" "=d")
8498 (neg:GPR (abs:GPR (match_dup 1))))]
26a89301 8499 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 8500 "ln<g>r\t%0,%1"
9381e3f1
WG
8501 [(set_attr "op_type" "RR<E>")
8502 (set_attr "z10prop" "z10_c")])
43a09b63
AK
8503
8504; lnr, lngr
9a91a21f 8505(define_insn "*negabs<mode>2_cconly"
ae156f85 8506 [(set (reg CC_REGNUM)
9a91a21f 8507 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
26a89301 8508 (const_int 0)))
9a91a21f 8509 (clobber (match_scratch:GPR 0 "=d"))]
26a89301 8510 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 8511 "ln<g>r\t%0,%1"
9381e3f1
WG
8512 [(set_attr "op_type" "RR<E>")
8513 (set_attr "z10prop" "z10_c")])
43a09b63
AK
8514
8515; lnr, lngr
9a91a21f
AS
8516(define_insn "*negabs<mode>2"
8517 [(set (match_operand:GPR 0 "register_operand" "=d")
8518 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
ae156f85 8519 (clobber (reg:CC CC_REGNUM))]
26a89301 8520 ""
9a91a21f 8521 "ln<g>r\t%0,%1"
9381e3f1
WG
8522 [(set_attr "op_type" "RR<E>")
8523 (set_attr "z10prop" "z10_c")])
26a89301 8524
3ef093a8
AK
8525;
8526; Floating point
8527;
8528
43a09b63 8529; lnxbr, lndbr, lnebr
f5905b37 8530(define_insn "*negabs<mode>2_cc"
ae156f85 8531 [(set (reg CC_REGNUM)
7b6baae1
AK
8532 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
8533 (match_operand:BFP 2 "const0_operand" "")))
8534 (set (match_operand:BFP 0 "register_operand" "=f")
8535 (neg:BFP (abs:BFP (match_dup 1))))]
142cd70f 8536 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8537 "ln<xde>br\t%0,%1"
26a89301 8538 [(set_attr "op_type" "RRE")
f5905b37 8539 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
8540
8541; lnxbr, lndbr, lnebr
f5905b37 8542(define_insn "*negabs<mode>2_cconly"
ae156f85 8543 [(set (reg CC_REGNUM)
7b6baae1
AK
8544 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
8545 (match_operand:BFP 2 "const0_operand" "")))
8546 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 8547 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 8548 "ln<xde>br\t%0,%1"
26a89301 8549 [(set_attr "op_type" "RRE")
f5905b37 8550 (set_attr "type" "fsimp<mode>")])
43a09b63 8551
85dae55a
AK
8552; lndfr
8553(define_insn "*negabs<mode>2_nocc"
609e7e80
AK
8554 [(set (match_operand:FP 0 "register_operand" "=f")
8555 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
fb068247 8556 "TARGET_DFP"
85dae55a
AK
8557 "lndfr\t%0,%1"
8558 [(set_attr "op_type" "RRE")
9381e3f1 8559 (set_attr "type" "fsimp<mode>")])
85dae55a 8560
43a09b63 8561; lnxbr, lndbr, lnebr
6e5b5de8 8562; FIXME: wflndb does not clobber cc
f5905b37 8563(define_insn "*negabs<mode>2"
62d3f261
AK
8564 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8565 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f,v"))))
ae156f85 8566 (clobber (reg:CC CC_REGNUM))]
142cd70f 8567 "TARGET_HARD_FLOAT"
6e5b5de8
AK
8568 "@
8569 ln<xde>br\t%0,%1
8570 wflndb\t%0,%1"
8571 [(set_attr "op_type" "RRE,VRR")
8572 (set_attr "cpu_facility" "*,vec")
62d3f261
AK
8573 (set_attr "type" "fsimp<mode>,*")
8574 (set_attr "enabled" "*,<DFDI>")])
26a89301 8575
4023fb28
UW
8576;;
8577;;- Square root instructions.
8578;;
8579
8580;
f5905b37 8581; sqrt(df|sf)2 instruction pattern(s).
4023fb28
UW
8582;
8583
9381e3f1 8584; sqxbr, sqdbr, sqebr, sqdb, sqeb
f5905b37 8585(define_insn "sqrt<mode>2"
62d3f261
AK
8586 [(set (match_operand:BFP 0 "register_operand" "=f,f,v")
8587 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,R,v")))]
142cd70f 8588 "TARGET_HARD_FLOAT"
4023fb28 8589 "@
f61a2c7d 8590 sq<xde>br\t%0,%1
6e5b5de8
AK
8591 sq<xde>b\t%0,%1
8592 wfsqdb\t%v0,%v1"
8593 [(set_attr "op_type" "RRE,RXE,VRR")
8594 (set_attr "type" "fsqrt<mode>")
62d3f261
AK
8595 (set_attr "cpu_facility" "*,*,vec")
8596 (set_attr "enabled" "*,<DSF>,<DFDI>")])
4023fb28 8597
9db1d521
HP
8598
8599;;
8600;;- One complement instructions.
8601;;
8602
8603;
342cf42b 8604; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
9db1d521 8605;
c7453384 8606
342cf42b 8607(define_expand "one_cmpl<mode>2"
4023fb28 8608 [(parallel
342cf42b
AS
8609 [(set (match_operand:INT 0 "register_operand" "")
8610 (xor:INT (match_operand:INT 1 "register_operand" "")
8611 (const_int -1)))
ae156f85 8612 (clobber (reg:CC CC_REGNUM))])]
9db1d521 8613 ""
4023fb28 8614 "")
9db1d521
HP
8615
8616
ec24698e
UW
8617;;
8618;; Find leftmost bit instructions.
8619;;
8620
8621(define_expand "clzdi2"
8622 [(set (match_operand:DI 0 "register_operand" "=d")
8623 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
9602b6a1 8624 "TARGET_EXTIMM && TARGET_ZARCH"
ec24698e 8625{
d8485bdb
TS
8626 rtx_insn *insn;
8627 rtx clz_equal;
ec24698e 8628 rtx wide_reg = gen_reg_rtx (TImode);
406fde6e 8629 rtx msb = gen_rtx_CONST_INT (DImode, HOST_WIDE_INT_1U << 63);
ec24698e
UW
8630
8631 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
8632
8633 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
8634
9381e3f1 8635 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
bd94cb6e 8636 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
ec24698e
UW
8637
8638 DONE;
8639})
8640
8641(define_insn "clztidi2"
8642 [(set (match_operand:TI 0 "register_operand" "=d")
8643 (ior:TI
9381e3f1
WG
8644 (ashift:TI
8645 (zero_extend:TI
ec24698e
UW
8646 (xor:DI (match_operand:DI 1 "register_operand" "d")
8647 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
8648 (subreg:SI (clz:DI (match_dup 1)) 4))))
9381e3f1 8649
ec24698e
UW
8650 (const_int 64))
8651 (zero_extend:TI (clz:DI (match_dup 1)))))
8652 (clobber (reg:CC CC_REGNUM))]
406fde6e 8653 "UINTVAL (operands[2]) == HOST_WIDE_INT_1U << 63
9602b6a1 8654 && TARGET_EXTIMM && TARGET_ZARCH"
ec24698e
UW
8655 "flogr\t%0,%1"
8656 [(set_attr "op_type" "RRE")])
8657
8658
9db1d521
HP
8659;;
8660;;- Rotate instructions.
8661;;
8662
8663;
9a91a21f 8664; rotl(di|si)3 instruction pattern(s).
9db1d521
HP
8665;
8666
191eb16d
AK
8667(define_expand "rotl<mode>3"
8668 [(set (match_operand:GPR 0 "register_operand" "")
8669 (rotate:GPR (match_operand:GPR 1 "register_operand" "")
8670 (match_operand:SI 2 "nonmemory_operand" "")))]
9e8327e3 8671 "TARGET_CPU_ZARCH"
191eb16d 8672 "")
9db1d521 8673
43a09b63 8674; rll, rllg
191eb16d
AK
8675(define_insn "*rotl<mode>3<addr_style_op><masked_op>"
8676 [(set (match_operand:GPR 0 "register_operand" "=d")
8677 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
8678 (match_operand:SI 2 "nonmemory_operand" "an")))]
8679 "TARGET_CPU_ZARCH"
8680 "rll<g>\t%0,%1,<addr_style_op_ops>"
4989e88a 8681 [(set_attr "op_type" "RSE")
9381e3f1 8682 (set_attr "atype" "reg")
191eb16d 8683 (set_attr "z10prop" "z10_super_E1")])
4989e88a 8684
9db1d521
HP
8685
8686;;
f337b930 8687;;- Shift instructions.
9db1d521 8688;;
9db1d521
HP
8689
8690;
1b48c8cc 8691; (ashl|lshr)(di|si)3 instruction pattern(s).
65b1d8ea 8692; Left shifts and logical right shifts
9db1d521 8693
1b48c8cc
AS
8694(define_expand "<shift><mode>3"
8695 [(set (match_operand:DSI 0 "register_operand" "")
8696 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
adf22b3f 8697 (match_operand:SI 2 "nonmemory_operand" "")))]
9db1d521
HP
8698 ""
8699 "")
8700
adf22b3f 8701; ESA 64 bit register pair shift with reg or imm shift count
43a09b63 8702; sldl, srdl
adf22b3f
AK
8703(define_insn "*<shift>di3_31<addr_style_op><masked_op>"
8704 [(set (match_operand:DI 0 "register_operand" "=d")
8705 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
8706 (match_operand:SI 2 "nonmemory_operand" "an")))]
9602b6a1 8707 "!TARGET_ZARCH"
adf22b3f 8708 "s<lr>dl\t%0,<addr_style_op_ops>"
077dab3b 8709 [(set_attr "op_type" "RS")
65b1d8ea
AK
8710 (set_attr "atype" "reg")
8711 (set_attr "z196prop" "z196_cracked")])
9db1d521 8712
adf22b3f
AK
8713
8714; 64 bit register shift with reg or imm shift count
65b1d8ea 8715; sll, srl, sllg, srlg, sllk, srlk
adf22b3f
AK
8716(define_insn "*<shift><mode>3<addr_style_op><masked_op>"
8717 [(set (match_operand:GPR 0 "register_operand" "=d, d")
8718 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>, d")
8719 (match_operand:SI 2 "nonmemory_operand" "an,an")))]
1b48c8cc 8720 ""
65b1d8ea 8721 "@
adf22b3f
AK
8722 s<lr>l<g>\t%0,<1><addr_style_op_ops>
8723 s<lr>l<gk>\t%0,%1,<addr_style_op_ops>"
65b1d8ea
AK
8724 [(set_attr "op_type" "RS<E>,RSY")
8725 (set_attr "atype" "reg,reg")
8726 (set_attr "cpu_facility" "*,z196")
adf22b3f 8727 (set_attr "z10prop" "z10_super_E1,*")])
4989e88a 8728
9db1d521 8729;
1b48c8cc 8730; ashr(di|si)3 instruction pattern(s).
65b1d8ea 8731; Arithmetic right shifts
9db1d521 8732
1b48c8cc 8733(define_expand "ashr<mode>3"
9db1d521 8734 [(parallel
1b48c8cc
AS
8735 [(set (match_operand:DSI 0 "register_operand" "")
8736 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
a9fcf821 8737 (match_operand:SI 2 "nonmemory_operand" "")))
ae156f85 8738 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8739 ""
8740 "")
8741
a9fcf821
AK
8742; FIXME: The number of alternatives is doubled here to match the fix
8743; number of 2 in the subst pattern for the (clobber (match_scratch...
8744; The right fix should be to support match_scratch in the output
8745; pattern of a define_subst.
8746(define_insn "*ashrdi3_31<addr_style_op_cc><masked_op_cc><setcc><cconly>"
8747 [(set (match_operand:DI 0 "register_operand" "=d, d")
8748 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0, 0")
8749 (match_operand:SI 2 "nonmemory_operand" "an,an")))
ae156f85 8750 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8751 "!TARGET_ZARCH"
65b1d8ea 8752 "@
a9fcf821
AK
8753 srda\t%0,<addr_style_op_cc_ops>
8754 srda\t%0,<addr_style_op_cc_ops>"
8755 [(set_attr "op_type" "RS")
8756 (set_attr "atype" "reg")])
ecbe845e 8757
ecbe845e 8758
43a09b63 8759; sra, srag
a9fcf821
AK
8760(define_insn "*ashr<mode>3<addr_style_op_cc><masked_op_cc><setcc><cconly>"
8761 [(set (match_operand:GPR 0 "register_operand" "=d, d")
8762 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>, d")
8763 (match_operand:SI 2 "nonmemory_operand" "an,an")))
ae156f85 8764 (clobber (reg:CC CC_REGNUM))]
1b48c8cc 8765 ""
65b1d8ea 8766 "@
a9fcf821
AK
8767 sra<g>\t%0,<1><addr_style_op_cc_ops>
8768 sra<gk>\t%0,%1,<addr_style_op_cc_ops>"
65b1d8ea 8769 [(set_attr "op_type" "RS<E>,RSY")
a9fcf821 8770 (set_attr "atype" "reg")
01496eca 8771 (set_attr "cpu_facility" "*,z196")
65b1d8ea 8772 (set_attr "z10prop" "z10_super_E1,*")])
4989e88a 8773
9db1d521 8774
9db1d521
HP
8775;;
8776;; Branch instruction patterns.
8777;;
8778
f90b7a5a 8779(define_expand "cbranch<mode>4"
fa77b251 8780 [(set (pc)
f90b7a5a
PB
8781 (if_then_else (match_operator 0 "comparison_operator"
8782 [(match_operand:GPR 1 "register_operand" "")
8783 (match_operand:GPR 2 "general_operand" "")])
8784 (label_ref (match_operand 3 "" ""))
fa77b251 8785 (pc)))]
ba956982 8786 ""
f90b7a5a
PB
8787 "s390_emit_jump (operands[3],
8788 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8789 DONE;")
8790
8791(define_expand "cbranch<mode>4"
8792 [(set (pc)
8793 (if_then_else (match_operator 0 "comparison_operator"
8794 [(match_operand:FP 1 "register_operand" "")
8795 (match_operand:FP 2 "general_operand" "")])
8796 (label_ref (match_operand 3 "" ""))
8797 (pc)))]
8798 "TARGET_HARD_FLOAT"
8799 "s390_emit_jump (operands[3],
8800 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8801 DONE;")
8802
8803(define_expand "cbranchcc4"
8804 [(set (pc)
de6fba39 8805 (if_then_else (match_operator 0 "s390_comparison"
f90b7a5a 8806 [(match_operand 1 "cc_reg_operand" "")
de6fba39 8807 (match_operand 2 "const_int_operand" "")])
f90b7a5a
PB
8808 (label_ref (match_operand 3 "" ""))
8809 (pc)))]
de6fba39
UW
8810 ""
8811 "")
ba956982 8812
9db1d521
HP
8813
8814;;
8815;;- Conditional jump instructions.
8816;;
8817
6590e19a
UW
8818(define_insn "*cjump_64"
8819 [(set (pc)
8820 (if_then_else
5a3fe9b6
AK
8821 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8822 (match_operand 2 "const_int_operand" "")])
6590e19a
UW
8823 (label_ref (match_operand 0 "" ""))
8824 (pc)))]
8825 "TARGET_CPU_ZARCH"
9db1d521 8826{
13e58269 8827 if (get_attr_length (insn) == 4)
d40c829f 8828 return "j%C1\t%l0";
6590e19a 8829 else
d40c829f 8830 return "jg%C1\t%l0";
6590e19a
UW
8831}
8832 [(set_attr "op_type" "RI")
8833 (set_attr "type" "branch")
8834 (set (attr "length")
8835 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8836 (const_int 4) (const_int 6)))])
8837
8838(define_insn "*cjump_31"
8839 [(set (pc)
8840 (if_then_else
5a3fe9b6
AK
8841 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8842 (match_operand 2 "const_int_operand" "")])
6590e19a
UW
8843 (label_ref (match_operand 0 "" ""))
8844 (pc)))]
8845 "!TARGET_CPU_ZARCH"
8846{
8d933e31
AS
8847 gcc_assert (get_attr_length (insn) == 4);
8848 return "j%C1\t%l0";
10bbf137 8849}
9db1d521 8850 [(set_attr "op_type" "RI")
077dab3b 8851 (set_attr "type" "branch")
13e58269 8852 (set (attr "length")
d7f99b2c 8853 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
8854 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8855 (const_int 4) (const_int 6))
8856 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8857 (const_int 4) (const_int 8))))])
9db1d521 8858
f314b9b1 8859(define_insn "*cjump_long"
6590e19a
UW
8860 [(set (pc)
8861 (if_then_else
ae156f85 8862 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
4fe6dea8 8863 (match_operand 0 "address_operand" "ZQZR")
6590e19a 8864 (pc)))]
9db1d521 8865 ""
f314b9b1
UW
8866{
8867 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8868 return "b%C1r\t%0";
f314b9b1 8869 else
d40c829f 8870 return "b%C1\t%a0";
10bbf137 8871}
c7453384 8872 [(set (attr "op_type")
f314b9b1
UW
8873 (if_then_else (match_operand 0 "register_operand" "")
8874 (const_string "RR") (const_string "RX")))
6590e19a 8875 (set_attr "type" "branch")
077dab3b 8876 (set_attr "atype" "agen")])
9db1d521 8877
177bc204
RS
8878;; A conditional return instruction.
8879(define_insn "*c<code>"
8880 [(set (pc)
8881 (if_then_else
8882 (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8883 (ANY_RETURN)
8884 (pc)))]
8885 "s390_can_use_<code>_insn ()"
8886 "b%C0r\t%%r14"
8887 [(set_attr "op_type" "RR")
8888 (set_attr "type" "jsr")
8889 (set_attr "atype" "agen")])
9db1d521
HP
8890
8891;;
8892;;- Negated conditional jump instructions.
8893;;
8894
6590e19a
UW
8895(define_insn "*icjump_64"
8896 [(set (pc)
8897 (if_then_else
ae156f85 8898 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a
UW
8899 (pc)
8900 (label_ref (match_operand 0 "" ""))))]
8901 "TARGET_CPU_ZARCH"
c7453384 8902{
13e58269 8903 if (get_attr_length (insn) == 4)
d40c829f 8904 return "j%D1\t%l0";
6590e19a 8905 else
d40c829f 8906 return "jg%D1\t%l0";
6590e19a
UW
8907}
8908 [(set_attr "op_type" "RI")
8909 (set_attr "type" "branch")
8910 (set (attr "length")
8911 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8912 (const_int 4) (const_int 6)))])
8913
8914(define_insn "*icjump_31"
8915 [(set (pc)
8916 (if_then_else
ae156f85 8917 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a
UW
8918 (pc)
8919 (label_ref (match_operand 0 "" ""))))]
8920 "!TARGET_CPU_ZARCH"
8921{
8d933e31
AS
8922 gcc_assert (get_attr_length (insn) == 4);
8923 return "j%D1\t%l0";
10bbf137 8924}
9db1d521 8925 [(set_attr "op_type" "RI")
077dab3b 8926 (set_attr "type" "branch")
13e58269 8927 (set (attr "length")
d7f99b2c 8928 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
8929 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8930 (const_int 4) (const_int 6))
8931 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8932 (const_int 4) (const_int 8))))])
9db1d521 8933
f314b9b1 8934(define_insn "*icjump_long"
6590e19a
UW
8935 [(set (pc)
8936 (if_then_else
ae156f85 8937 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a 8938 (pc)
4fe6dea8 8939 (match_operand 0 "address_operand" "ZQZR")))]
9db1d521 8940 ""
f314b9b1
UW
8941{
8942 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8943 return "b%D1r\t%0";
f314b9b1 8944 else
d40c829f 8945 return "b%D1\t%a0";
10bbf137 8946}
c7453384 8947 [(set (attr "op_type")
f314b9b1
UW
8948 (if_then_else (match_operand 0 "register_operand" "")
8949 (const_string "RR") (const_string "RX")))
077dab3b
HP
8950 (set_attr "type" "branch")
8951 (set_attr "atype" "agen")])
9db1d521 8952
4456530d
HP
8953;;
8954;;- Trap instructions.
8955;;
8956
8957(define_insn "trap"
8958 [(trap_if (const_int 1) (const_int 0))]
8959 ""
d40c829f 8960 "j\t.+2"
6590e19a 8961 [(set_attr "op_type" "RI")
077dab3b 8962 (set_attr "type" "branch")])
4456530d 8963
f90b7a5a
PB
8964(define_expand "ctrap<mode>4"
8965 [(trap_if (match_operator 0 "comparison_operator"
8966 [(match_operand:GPR 1 "register_operand" "")
8967 (match_operand:GPR 2 "general_operand" "")])
8968 (match_operand 3 "const0_operand" ""))]
4456530d 8969 ""
f90b7a5a
PB
8970 {
8971 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8972 operands[1], operands[2]);
8973 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8974 DONE;
8975 })
8976
8977(define_expand "ctrap<mode>4"
8978 [(trap_if (match_operator 0 "comparison_operator"
8979 [(match_operand:FP 1 "register_operand" "")
8980 (match_operand:FP 2 "general_operand" "")])
8981 (match_operand 3 "const0_operand" ""))]
8982 ""
8983 {
8984 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8985 operands[1], operands[2]);
8986 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8987 DONE;
8988 })
4456530d 8989
f90b7a5a
PB
8990(define_insn "condtrap"
8991 [(trap_if (match_operator 0 "s390_comparison"
8992 [(match_operand 1 "cc_reg_operand" "c")
8993 (const_int 0)])
4456530d
HP
8994 (const_int 0))]
8995 ""
d40c829f 8996 "j%C0\t.+2";
077dab3b
HP
8997 [(set_attr "op_type" "RI")
8998 (set_attr "type" "branch")])
9db1d521 8999
963fc8d0
AK
9000; crt, cgrt, cit, cgit
9001(define_insn "*cmp_and_trap_signed_int<mode>"
9002 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
9003 [(match_operand:GPR 1 "register_operand" "d,d")
9004 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
9005 (const_int 0))]
9006 "TARGET_Z10"
9007 "@
9008 c<g>rt%C0\t%1,%2
9009 c<g>it%C0\t%1,%h2"
9010 [(set_attr "op_type" "RRF,RIE")
9381e3f1 9011 (set_attr "type" "branch")
729e750f 9012 (set_attr "z10prop" "z10_super_c,z10_super")])
963fc8d0 9013
22ac2c2f 9014; clrt, clgrt, clfit, clgit, clt, clgt
963fc8d0
AK
9015(define_insn "*cmp_and_trap_unsigned_int<mode>"
9016 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
3e4be43f
UW
9017 [(match_operand:GPR 1 "register_operand" "d,d,d")
9018 (match_operand:GPR 2 "general_operand" "d,D,T")])
963fc8d0
AK
9019 (const_int 0))]
9020 "TARGET_Z10"
9021 "@
9022 cl<g>rt%C0\t%1,%2
22ac2c2f
AK
9023 cl<gf>it%C0\t%1,%x2
9024 cl<g>t%C0\t%1,%2"
9025 [(set_attr "op_type" "RRF,RIE,RSY")
9026 (set_attr "type" "branch")
9027 (set_attr "z10prop" "z10_super_c,z10_super,*")
9028 (set_attr "cpu_facility" "z10,z10,zEC12")])
9029
9030; lat, lgat
9031(define_insn "*load_and_trap<mode>"
3e4be43f 9032 [(trap_if (eq (match_operand:GPR 0 "memory_operand" "T")
22ac2c2f
AK
9033 (const_int 0))
9034 (const_int 0))
9035 (set (match_operand:GPR 1 "register_operand" "=d")
9036 (match_dup 0))]
9037 "TARGET_ZEC12"
9038 "l<g>at\t%1,%0"
9039 [(set_attr "op_type" "RXY")])
9040
963fc8d0 9041
9db1d521 9042;;
0a3bdf9d 9043;;- Loop instructions.
9db1d521 9044;;
0a3bdf9d
UW
9045;; This is all complicated by the fact that since this is a jump insn
9046;; we must handle our own output reloads.
c7453384 9047
f1149235
AK
9048;; branch on index
9049
9050; This splitter will be matched by combine and has to add the 2 moves
9051; necessary to load the compare and the increment values into a
9052; register pair as needed by brxle.
9053
9054(define_insn_and_split "*brx_stage1_<GPR:mode>"
9055 [(set (pc)
9056 (if_then_else
9057 (match_operator 6 "s390_brx_operator"
9058 [(plus:GPR (match_operand:GPR 1 "register_operand" "")
9059 (match_operand:GPR 2 "general_operand" ""))
9060 (match_operand:GPR 3 "register_operand" "")])
9061 (label_ref (match_operand 0 "" ""))
9062 (pc)))
9063 (set (match_operand:GPR 4 "nonimmediate_operand" "")
9064 (plus:GPR (match_dup 1) (match_dup 2)))
9065 (clobber (match_scratch:GPR 5 ""))]
9066 "TARGET_CPU_ZARCH"
9067 "#"
9068 "!reload_completed && !reload_in_progress"
9069 [(set (match_dup 7) (match_dup 2)) ; the increment
9070 (set (match_dup 8) (match_dup 3)) ; the comparison value
9071 (parallel [(set (pc)
9072 (if_then_else
9073 (match_op_dup 6
9074 [(plus:GPR (match_dup 1) (match_dup 7))
9075 (match_dup 8)])
9076 (label_ref (match_dup 0))
9077 (pc)))
9078 (set (match_dup 4)
9079 (plus:GPR (match_dup 1) (match_dup 7)))
9080 (clobber (match_dup 5))
9081 (clobber (reg:CC CC_REGNUM))])]
9082 {
9083 rtx dreg = gen_reg_rtx (word_mode == DImode ? TImode : DImode);
9084 operands[7] = gen_lowpart (<GPR:MODE>mode,
9085 gen_highpart (word_mode, dreg));
9086 operands[8] = gen_lowpart (<GPR:MODE>mode,
9087 gen_lowpart (word_mode, dreg));
9088 })
9089
9090; brxlg, brxhg
9091
9092(define_insn_and_split "*brxg_64bit"
9093 [(set (pc)
9094 (if_then_else
9095 (match_operator 5 "s390_brx_operator"
9096 [(plus:DI (match_operand:DI 1 "register_operand" "d,d,d")
9097 (subreg:DI (match_operand:TI 2 "register_operand" "d,d,d") 0))
9098 (subreg:DI (match_dup 2) 8)])
9099 (label_ref (match_operand 0 "" ""))
9100 (pc)))
9101 (set (match_operand:DI 3 "nonimmediate_operand" "=1,?X,?X")
9102 (plus:DI (match_dup 1)
9103 (subreg:DI (match_dup 2) 0)))
9104 (clobber (match_scratch:DI 4 "=X,&1,&?d"))
9105 (clobber (reg:CC CC_REGNUM))]
9602b6a1 9106 "TARGET_ZARCH"
f1149235
AK
9107{
9108 if (which_alternative != 0)
9109 return "#";
9110 else if (get_attr_length (insn) == 6)
9111 return "brx%E5g\t%1,%2,%l0";
9112 else
9113 return "agr\t%1,%2\;cgr\t%1,%M2\;jg%C5\t%l0";
9114}
9115 "&& reload_completed
9116 && (!REG_P (operands[3])
9117 || !rtx_equal_p (operands[1], operands[3]))"
9118 [(set (match_dup 4) (match_dup 1))
9119 (parallel [(set (match_dup 4) (plus:DI (match_dup 4) (subreg:DI (match_dup 2) 0)))
9120 (clobber (reg:CC CC_REGNUM))])
9121 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:DI (match_dup 2) 8)))
9122 (set (match_dup 3) (match_dup 4))
9123 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9124 (label_ref (match_dup 0))
9125 (pc)))]
9126 ""
9127 [(set_attr "op_type" "RIE")
9128 (set_attr "type" "branch")
9129 (set (attr "length")
9130 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9131 (const_int 6) (const_int 16)))])
9132
9133; brxle, brxh
9134
9135(define_insn_and_split "*brx_64bit"
9136 [(set (pc)
9137 (if_then_else
9138 (match_operator 5 "s390_brx_operator"
9139 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
9140 (subreg:SI (match_operand:TI 2 "register_operand" "d,d,d") 4))
9141 (subreg:SI (match_dup 2) 12)])
9142 (label_ref (match_operand 0 "" ""))
9143 (pc)))
9144 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
9145 (plus:SI (match_dup 1)
9146 (subreg:SI (match_dup 2) 4)))
9147 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
9148 (clobber (reg:CC CC_REGNUM))]
9602b6a1 9149 "TARGET_ZARCH"
f1149235
AK
9150{
9151 if (which_alternative != 0)
9152 return "#";
9153 else if (get_attr_length (insn) == 6)
9154 return "brx%C5\t%1,%2,%l0";
9155 else
9156 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
9157}
9158 "&& reload_completed
9159 && (!REG_P (operands[3])
9160 || !rtx_equal_p (operands[1], operands[3]))"
9161 [(set (match_dup 4) (match_dup 1))
9162 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 4)))
9163 (clobber (reg:CC CC_REGNUM))])
9164 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 12)))
9165 (set (match_dup 3) (match_dup 4))
9166 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9167 (label_ref (match_dup 0))
9168 (pc)))]
9169 ""
9170 [(set_attr "op_type" "RSI")
9171 (set_attr "type" "branch")
9172 (set (attr "length")
9173 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9174 (const_int 6) (const_int 14)))])
9175
9176; brxle, brxh
9177
9178(define_insn_and_split "*brx_31bit"
9179 [(set (pc)
9180 (if_then_else
9181 (match_operator 5 "s390_brx_operator"
9182 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
9183 (subreg:SI (match_operand:DI 2 "register_operand" "d,d,d") 0))
9184 (subreg:SI (match_dup 2) 4)])
9185 (label_ref (match_operand 0 "" ""))
9186 (pc)))
9187 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
9188 (plus:SI (match_dup 1)
9189 (subreg:SI (match_dup 2) 0)))
9190 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
9191 (clobber (reg:CC CC_REGNUM))]
9602b6a1 9192 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1149235
AK
9193{
9194 if (which_alternative != 0)
9195 return "#";
9196 else if (get_attr_length (insn) == 6)
9197 return "brx%C5\t%1,%2,%l0";
9198 else
9199 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
9200}
9201 "&& reload_completed
9202 && (!REG_P (operands[3])
9203 || !rtx_equal_p (operands[1], operands[3]))"
9204 [(set (match_dup 4) (match_dup 1))
9205 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 0)))
9206 (clobber (reg:CC CC_REGNUM))])
9207 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 4)))
9208 (set (match_dup 3) (match_dup 4))
9209 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9210 (label_ref (match_dup 0))
9211 (pc)))]
9212 ""
9213 [(set_attr "op_type" "RSI")
9214 (set_attr "type" "branch")
9215 (set (attr "length")
9216 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9217 (const_int 6) (const_int 14)))])
9218
9219
9220;; branch on count
9221
0a3bdf9d
UW
9222(define_expand "doloop_end"
9223 [(use (match_operand 0 "" "")) ; loop pseudo
1d0216c8 9224 (use (match_operand 1 "" ""))] ; label
0a3bdf9d 9225 ""
0a3bdf9d 9226{
6590e19a 9227 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
1d0216c8 9228 emit_jump_insn (gen_doloop_si31 (operands[1], operands[0], operands[0]));
6590e19a 9229 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
1d0216c8 9230 emit_jump_insn (gen_doloop_si64 (operands[1], operands[0], operands[0]));
9602b6a1 9231 else if (GET_MODE (operands[0]) == DImode && TARGET_ZARCH)
1d0216c8 9232 emit_jump_insn (gen_doloop_di (operands[1], operands[0], operands[0]));
0a3bdf9d
UW
9233 else
9234 FAIL;
9235
9236 DONE;
10bbf137 9237})
0a3bdf9d 9238
6590e19a 9239(define_insn_and_split "doloop_si64"
0a3bdf9d
UW
9240 [(set (pc)
9241 (if_then_else
7e665d18 9242 (ne (match_operand:SI 1 "register_operand" "d,d,d")
0a3bdf9d
UW
9243 (const_int 1))
9244 (label_ref (match_operand 0 "" ""))
9245 (pc)))
7e665d18 9246 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
0a3bdf9d 9247 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 9248 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
ae156f85 9249 (clobber (reg:CC CC_REGNUM))]
6590e19a 9250 "TARGET_CPU_ZARCH"
0a3bdf9d
UW
9251{
9252 if (which_alternative != 0)
10bbf137 9253 return "#";
0a3bdf9d 9254 else if (get_attr_length (insn) == 4)
d40c829f 9255 return "brct\t%1,%l0";
6590e19a 9256 else
545d16ff 9257 return "ahi\t%1,-1\;jgne\t%l0";
6590e19a
UW
9258}
9259 "&& reload_completed
9260 && (! REG_P (operands[2])
9261 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
9262 [(set (match_dup 3) (match_dup 1))
9263 (parallel [(set (reg:CCAN CC_REGNUM)
6590e19a
UW
9264 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
9265 (const_int 0)))
9266 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
9267 (set (match_dup 2) (match_dup 3))
ae156f85 9268 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a
UW
9269 (label_ref (match_dup 0))
9270 (pc)))]
9271 ""
9272 [(set_attr "op_type" "RI")
9381e3f1
WG
9273 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9274 ; hurt us in the (rare) case of ahi.
729e750f 9275 (set_attr "z10prop" "z10_super_E1")
6590e19a
UW
9276 (set_attr "type" "branch")
9277 (set (attr "length")
9278 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9279 (const_int 4) (const_int 10)))])
9280
9281(define_insn_and_split "doloop_si31"
9282 [(set (pc)
9283 (if_then_else
7e665d18 9284 (ne (match_operand:SI 1 "register_operand" "d,d,d")
6590e19a
UW
9285 (const_int 1))
9286 (label_ref (match_operand 0 "" ""))
9287 (pc)))
7e665d18 9288 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
6590e19a 9289 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 9290 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
ae156f85 9291 (clobber (reg:CC CC_REGNUM))]
6590e19a
UW
9292 "!TARGET_CPU_ZARCH"
9293{
9294 if (which_alternative != 0)
9295 return "#";
9296 else if (get_attr_length (insn) == 4)
9297 return "brct\t%1,%l0";
0a3bdf9d 9298 else
8d933e31 9299 gcc_unreachable ();
10bbf137 9300}
6590e19a
UW
9301 "&& reload_completed
9302 && (! REG_P (operands[2])
9303 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
9304 [(set (match_dup 3) (match_dup 1))
9305 (parallel [(set (reg:CCAN CC_REGNUM)
6590e19a
UW
9306 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
9307 (const_int 0)))
9308 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
9309 (set (match_dup 2) (match_dup 3))
ae156f85 9310 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a
UW
9311 (label_ref (match_dup 0))
9312 (pc)))]
9313 ""
0a3bdf9d 9314 [(set_attr "op_type" "RI")
9381e3f1
WG
9315 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9316 ; hurt us in the (rare) case of ahi.
729e750f 9317 (set_attr "z10prop" "z10_super_E1")
077dab3b 9318 (set_attr "type" "branch")
0a3bdf9d 9319 (set (attr "length")
d7f99b2c 9320 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
9321 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9322 (const_int 4) (const_int 6))
9323 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9324 (const_int 4) (const_int 8))))])
9db1d521 9325
0a3bdf9d
UW
9326(define_insn "*doloop_si_long"
9327 [(set (pc)
9328 (if_then_else
7e665d18 9329 (ne (match_operand:SI 1 "register_operand" "d")
0a3bdf9d 9330 (const_int 1))
3e4be43f 9331 (match_operand 0 "address_operand" "ZR")
0a3bdf9d 9332 (pc)))
7e665d18 9333 (set (match_operand:SI 2 "register_operand" "=1")
0a3bdf9d 9334 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 9335 (clobber (match_scratch:SI 3 "=X"))
ae156f85 9336 (clobber (reg:CC CC_REGNUM))]
6590e19a 9337 "!TARGET_CPU_ZARCH"
0a3bdf9d
UW
9338{
9339 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 9340 return "bctr\t%1,%0";
0a3bdf9d 9341 else
d40c829f 9342 return "bct\t%1,%a0";
10bbf137 9343}
c7453384 9344 [(set (attr "op_type")
0a3bdf9d
UW
9345 (if_then_else (match_operand 0 "register_operand" "")
9346 (const_string "RR") (const_string "RX")))
077dab3b 9347 (set_attr "type" "branch")
729e750f 9348 (set_attr "atype" "agen")
65b1d8ea
AK
9349 (set_attr "z10prop" "z10_c")
9350 (set_attr "z196prop" "z196_cracked")])
0a3bdf9d 9351
6590e19a 9352(define_insn_and_split "doloop_di"
0a3bdf9d
UW
9353 [(set (pc)
9354 (if_then_else
7e665d18 9355 (ne (match_operand:DI 1 "register_operand" "d,d,d")
0a3bdf9d
UW
9356 (const_int 1))
9357 (label_ref (match_operand 0 "" ""))
9358 (pc)))
7e665d18 9359 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
0a3bdf9d 9360 (plus:DI (match_dup 1) (const_int -1)))
7e665d18 9361 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
ae156f85 9362 (clobber (reg:CC CC_REGNUM))]
9602b6a1 9363 "TARGET_ZARCH"
0a3bdf9d
UW
9364{
9365 if (which_alternative != 0)
10bbf137 9366 return "#";
0a3bdf9d 9367 else if (get_attr_length (insn) == 4)
d40c829f 9368 return "brctg\t%1,%l0";
0a3bdf9d 9369 else
545d16ff 9370 return "aghi\t%1,-1\;jgne\t%l0";
10bbf137 9371}
6590e19a 9372 "&& reload_completed
0a3bdf9d
UW
9373 && (! REG_P (operands[2])
9374 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
9375 [(set (match_dup 3) (match_dup 1))
9376 (parallel [(set (reg:CCAN CC_REGNUM)
0a3bdf9d
UW
9377 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
9378 (const_int 0)))
9379 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
9380 (set (match_dup 2) (match_dup 3))
ae156f85 9381 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a 9382 (label_ref (match_dup 0))
0a3bdf9d 9383 (pc)))]
6590e19a
UW
9384 ""
9385 [(set_attr "op_type" "RI")
9381e3f1
WG
9386 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9387 ; hurt us in the (rare) case of ahi.
729e750f 9388 (set_attr "z10prop" "z10_super_E1")
6590e19a
UW
9389 (set_attr "type" "branch")
9390 (set (attr "length")
9391 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9392 (const_int 4) (const_int 10)))])
9db1d521
HP
9393
9394;;
9395;;- Unconditional jump instructions.
9396;;
9397
9398;
9399; jump instruction pattern(s).
9400;
9401
6590e19a
UW
9402(define_expand "jump"
9403 [(match_operand 0 "" "")]
9db1d521 9404 ""
6590e19a
UW
9405 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
9406
9407(define_insn "*jump64"
9408 [(set (pc) (label_ref (match_operand 0 "" "")))]
9409 "TARGET_CPU_ZARCH"
9db1d521 9410{
13e58269 9411 if (get_attr_length (insn) == 4)
d40c829f 9412 return "j\t%l0";
6590e19a 9413 else
d40c829f 9414 return "jg\t%l0";
6590e19a
UW
9415}
9416 [(set_attr "op_type" "RI")
9417 (set_attr "type" "branch")
9418 (set (attr "length")
9419 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9420 (const_int 4) (const_int 6)))])
9421
9422(define_insn "*jump31"
9423 [(set (pc) (label_ref (match_operand 0 "" "")))]
9424 "!TARGET_CPU_ZARCH"
9425{
8d933e31
AS
9426 gcc_assert (get_attr_length (insn) == 4);
9427 return "j\t%l0";
10bbf137 9428}
9db1d521 9429 [(set_attr "op_type" "RI")
077dab3b 9430 (set_attr "type" "branch")
13e58269 9431 (set (attr "length")
d7f99b2c 9432 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
9433 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9434 (const_int 4) (const_int 6))
9435 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9436 (const_int 4) (const_int 8))))])
9db1d521
HP
9437
9438;
9439; indirect-jump instruction pattern(s).
9440;
9441
9442(define_insn "indirect_jump"
3e4be43f 9443 [(set (pc) (match_operand 0 "address_operand" "ZR"))]
9db1d521 9444 ""
f314b9b1
UW
9445{
9446 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 9447 return "br\t%0";
f314b9b1 9448 else
d40c829f 9449 return "b\t%a0";
10bbf137 9450}
c7453384 9451 [(set (attr "op_type")
f314b9b1
UW
9452 (if_then_else (match_operand 0 "register_operand" "")
9453 (const_string "RR") (const_string "RX")))
077dab3b 9454 (set_attr "type" "branch")
729e750f 9455 (set_attr "atype" "agen")])
9db1d521
HP
9456
9457;
f314b9b1 9458; casesi instruction pattern(s).
9db1d521
HP
9459;
9460
f314b9b1 9461(define_insn "casesi_jump"
3e4be43f 9462 [(set (pc) (match_operand 0 "address_operand" "ZR"))
f314b9b1 9463 (use (label_ref (match_operand 1 "" "")))]
9db1d521 9464 ""
9db1d521 9465{
f314b9b1 9466 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 9467 return "br\t%0";
f314b9b1 9468 else
d40c829f 9469 return "b\t%a0";
10bbf137 9470}
c7453384 9471 [(set (attr "op_type")
f314b9b1
UW
9472 (if_then_else (match_operand 0 "register_operand" "")
9473 (const_string "RR") (const_string "RX")))
077dab3b
HP
9474 (set_attr "type" "branch")
9475 (set_attr "atype" "agen")])
9db1d521 9476
f314b9b1
UW
9477(define_expand "casesi"
9478 [(match_operand:SI 0 "general_operand" "")
9479 (match_operand:SI 1 "general_operand" "")
9480 (match_operand:SI 2 "general_operand" "")
9481 (label_ref (match_operand 3 "" ""))
9482 (label_ref (match_operand 4 "" ""))]
9db1d521 9483 ""
f314b9b1
UW
9484{
9485 rtx index = gen_reg_rtx (SImode);
9486 rtx base = gen_reg_rtx (Pmode);
9487 rtx target = gen_reg_rtx (Pmode);
9488
9489 emit_move_insn (index, operands[0]);
9490 emit_insn (gen_subsi3 (index, index, operands[1]));
9491 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
e790b36a 9492 operands[4]);
f314b9b1
UW
9493
9494 if (Pmode != SImode)
9495 index = convert_to_mode (Pmode, index, 1);
9496 if (GET_CODE (index) != REG)
9497 index = copy_to_mode_reg (Pmode, index);
9498
9499 if (TARGET_64BIT)
9500 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
9501 else
a556fd39 9502 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
9db1d521 9503
f314b9b1
UW
9504 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
9505
542a8afa 9506 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
f314b9b1
UW
9507 emit_move_insn (target, index);
9508
9509 if (flag_pic)
9510 target = gen_rtx_PLUS (Pmode, base, target);
9511 emit_jump_insn (gen_casesi_jump (target, operands[3]));
9512
9513 DONE;
10bbf137 9514})
9db1d521
HP
9515
9516
9517;;
9518;;- Jump to subroutine.
9519;;
9520;;
9521
9522;
9523; untyped call instruction pattern(s).
9524;
9525
9526;; Call subroutine returning any type.
9527(define_expand "untyped_call"
9528 [(parallel [(call (match_operand 0 "" "")
9529 (const_int 0))
9530 (match_operand 1 "" "")
9531 (match_operand 2 "" "")])]
9532 ""
9db1d521
HP
9533{
9534 int i;
9535
9536 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
9537
9538 for (i = 0; i < XVECLEN (operands[2], 0); i++)
9539 {
9540 rtx set = XVECEXP (operands[2], 0, i);
9541 emit_move_insn (SET_DEST (set), SET_SRC (set));
9542 }
9543
9544 /* The optimizer does not know that the call sets the function value
9545 registers we stored in the result block. We avoid problems by
9546 claiming that all hard registers are used and clobbered at this
9547 point. */
9548 emit_insn (gen_blockage ());
9549
9550 DONE;
10bbf137 9551})
9db1d521
HP
9552
9553;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
9554;; all of memory. This blocks insns from being moved across this point.
9555
9556(define_insn "blockage"
10bbf137 9557 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
9db1d521 9558 ""
4023fb28 9559 ""
d5869ca0
UW
9560 [(set_attr "type" "none")
9561 (set_attr "length" "0")])
4023fb28 9562
9db1d521 9563;
ed9676cf 9564; sibcall patterns
9db1d521
HP
9565;
9566
ed9676cf 9567(define_expand "sibcall"
44b8152b 9568 [(call (match_operand 0 "" "")
ed9676cf 9569 (match_operand 1 "" ""))]
9db1d521 9570 ""
9db1d521 9571{
ed9676cf
AK
9572 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
9573 DONE;
9574})
9db1d521 9575
ed9676cf 9576(define_insn "*sibcall_br"
ae156f85 9577 [(call (mem:QI (reg SIBCALL_REGNUM))
ed9676cf 9578 (match_operand 0 "const_int_operand" "n"))]
2f7e5a0d 9579 "SIBLING_CALL_P (insn)
ed9676cf
AK
9580 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
9581 "br\t%%r1"
9582 [(set_attr "op_type" "RR")
9583 (set_attr "type" "branch")
9584 (set_attr "atype" "agen")])
9db1d521 9585
ed9676cf
AK
9586(define_insn "*sibcall_brc"
9587 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9588 (match_operand 1 "const_int_operand" "n"))]
9589 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
9590 "j\t%0"
9591 [(set_attr "op_type" "RI")
9592 (set_attr "type" "branch")])
9db1d521 9593
ed9676cf
AK
9594(define_insn "*sibcall_brcl"
9595 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9596 (match_operand 1 "const_int_operand" "n"))]
9597 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
9598 "jg\t%0"
9599 [(set_attr "op_type" "RIL")
9600 (set_attr "type" "branch")])
44b8152b 9601
ed9676cf
AK
9602;
9603; sibcall_value patterns
9604;
9e8327e3 9605
ed9676cf
AK
9606(define_expand "sibcall_value"
9607 [(set (match_operand 0 "" "")
9608 (call (match_operand 1 "" "")
9609 (match_operand 2 "" "")))]
9610 ""
9611{
9612 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
44b8152b 9613 DONE;
10bbf137 9614})
9db1d521 9615
ed9676cf
AK
9616(define_insn "*sibcall_value_br"
9617 [(set (match_operand 0 "" "")
ae156f85 9618 (call (mem:QI (reg SIBCALL_REGNUM))
ed9676cf 9619 (match_operand 1 "const_int_operand" "n")))]
2f7e5a0d 9620 "SIBLING_CALL_P (insn)
ed9676cf
AK
9621 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
9622 "br\t%%r1"
9623 [(set_attr "op_type" "RR")
9624 (set_attr "type" "branch")
9625 (set_attr "atype" "agen")])
9626
9627(define_insn "*sibcall_value_brc"
9628 [(set (match_operand 0 "" "")
9629 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9630 (match_operand 2 "const_int_operand" "n")))]
9631 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
9632 "j\t%1"
9633 [(set_attr "op_type" "RI")
9634 (set_attr "type" "branch")])
9635
9636(define_insn "*sibcall_value_brcl"
9637 [(set (match_operand 0 "" "")
9638 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9639 (match_operand 2 "const_int_operand" "n")))]
9640 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
9641 "jg\t%1"
9642 [(set_attr "op_type" "RIL")
9643 (set_attr "type" "branch")])
9644
9645
9646;
9647; call instruction pattern(s).
9648;
9649
9650(define_expand "call"
9651 [(call (match_operand 0 "" "")
9652 (match_operand 1 "" ""))
9653 (use (match_operand 2 "" ""))]
44b8152b 9654 ""
ed9676cf 9655{
2f7e5a0d 9656 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
ed9676cf
AK
9657 gen_rtx_REG (Pmode, RETURN_REGNUM));
9658 DONE;
9659})
44b8152b 9660
9e8327e3
UW
9661(define_insn "*bras"
9662 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9663 (match_operand 1 "const_int_operand" "n"))
9664 (clobber (match_operand 2 "register_operand" "=r"))]
2f7e5a0d
EC
9665 "!SIBLING_CALL_P (insn)
9666 && TARGET_SMALL_EXEC
ed9676cf 9667 && GET_MODE (operands[2]) == Pmode"
d40c829f 9668 "bras\t%2,%0"
9db1d521 9669 [(set_attr "op_type" "RI")
65b1d8ea
AK
9670 (set_attr "type" "jsr")
9671 (set_attr "z196prop" "z196_cracked")])
9db1d521 9672
9e8327e3
UW
9673(define_insn "*brasl"
9674 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9675 (match_operand 1 "const_int_operand" "n"))
9676 (clobber (match_operand 2 "register_operand" "=r"))]
2f7e5a0d
EC
9677 "!SIBLING_CALL_P (insn)
9678 && TARGET_CPU_ZARCH
ed9676cf 9679 && GET_MODE (operands[2]) == Pmode"
9e8327e3
UW
9680 "brasl\t%2,%0"
9681 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9682 (set_attr "type" "jsr")
9683 (set_attr "z196prop" "z196_cracked")])
9db1d521 9684
9e8327e3 9685(define_insn "*basr"
3e4be43f 9686 [(call (mem:QI (match_operand 0 "address_operand" "ZR"))
9e8327e3
UW
9687 (match_operand 1 "const_int_operand" "n"))
9688 (clobber (match_operand 2 "register_operand" "=r"))]
ed9676cf 9689 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
9e8327e3
UW
9690{
9691 if (get_attr_op_type (insn) == OP_TYPE_RR)
9692 return "basr\t%2,%0";
9693 else
9694 return "bas\t%2,%a0";
9695}
9696 [(set (attr "op_type")
9697 (if_then_else (match_operand 0 "register_operand" "")
9698 (const_string "RR") (const_string "RX")))
9699 (set_attr "type" "jsr")
65b1d8ea
AK
9700 (set_attr "atype" "agen")
9701 (set_attr "z196prop" "z196_cracked")])
9db1d521
HP
9702
9703;
9704; call_value instruction pattern(s).
9705;
9706
9707(define_expand "call_value"
44b8152b
UW
9708 [(set (match_operand 0 "" "")
9709 (call (match_operand 1 "" "")
9710 (match_operand 2 "" "")))
9711 (use (match_operand 3 "" ""))]
9db1d521 9712 ""
9db1d521 9713{
2f7e5a0d 9714 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
ed9676cf 9715 gen_rtx_REG (Pmode, RETURN_REGNUM));
44b8152b 9716 DONE;
10bbf137 9717})
9db1d521 9718
9e8327e3 9719(define_insn "*bras_r"
c19ec8f9 9720 [(set (match_operand 0 "" "")
9e8327e3 9721 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9db1d521 9722 (match_operand:SI 2 "const_int_operand" "n")))
9e8327e3 9723 (clobber (match_operand 3 "register_operand" "=r"))]
2f7e5a0d
EC
9724 "!SIBLING_CALL_P (insn)
9725 && TARGET_SMALL_EXEC
ed9676cf 9726 && GET_MODE (operands[3]) == Pmode"
d40c829f 9727 "bras\t%3,%1"
9db1d521 9728 [(set_attr "op_type" "RI")
65b1d8ea
AK
9729 (set_attr "type" "jsr")
9730 (set_attr "z196prop" "z196_cracked")])
9db1d521 9731
9e8327e3 9732(define_insn "*brasl_r"
c19ec8f9 9733 [(set (match_operand 0 "" "")
9e8327e3
UW
9734 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9735 (match_operand 2 "const_int_operand" "n")))
9736 (clobber (match_operand 3 "register_operand" "=r"))]
2f7e5a0d
EC
9737 "!SIBLING_CALL_P (insn)
9738 && TARGET_CPU_ZARCH
ed9676cf 9739 && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9740 "brasl\t%3,%1"
9741 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9742 (set_attr "type" "jsr")
9743 (set_attr "z196prop" "z196_cracked")])
9db1d521 9744
9e8327e3 9745(define_insn "*basr_r"
c19ec8f9 9746 [(set (match_operand 0 "" "")
3e4be43f 9747 (call (mem:QI (match_operand 1 "address_operand" "ZR"))
9e8327e3
UW
9748 (match_operand 2 "const_int_operand" "n")))
9749 (clobber (match_operand 3 "register_operand" "=r"))]
ed9676cf 9750 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9751{
9752 if (get_attr_op_type (insn) == OP_TYPE_RR)
9753 return "basr\t%3,%1";
9754 else
9755 return "bas\t%3,%a1";
9756}
9757 [(set (attr "op_type")
9758 (if_then_else (match_operand 1 "register_operand" "")
9759 (const_string "RR") (const_string "RX")))
9760 (set_attr "type" "jsr")
65b1d8ea
AK
9761 (set_attr "atype" "agen")
9762 (set_attr "z196prop" "z196_cracked")])
9db1d521 9763
fd3cd001
UW
9764;;
9765;;- Thread-local storage support.
9766;;
9767
f959607b
CLT
9768(define_expand "get_thread_pointer<mode>"
9769 [(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))]
9770 ""
c5aa1d12 9771 "")
fd3cd001 9772
f959607b
CLT
9773(define_expand "set_thread_pointer<mode>"
9774 [(set (reg:P TP_REGNUM) (match_operand:P 0 "nonimmediate_operand" ""))
9775 (set (reg:P TP_REGNUM) (unspec_volatile:P [(reg:P TP_REGNUM)] UNSPECV_SET_TP))]
9776 ""
c5aa1d12
UW
9777 "")
9778
9779(define_insn "*set_tp"
ae156f85 9780 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
c5aa1d12
UW
9781 ""
9782 ""
9783 [(set_attr "type" "none")
9784 (set_attr "length" "0")])
c7453384 9785
fd3cd001
UW
9786(define_insn "*tls_load_64"
9787 [(set (match_operand:DI 0 "register_operand" "=d")
3e4be43f 9788 (unspec:DI [(match_operand:DI 1 "memory_operand" "T")
fd3cd001
UW
9789 (match_operand:DI 2 "" "")]
9790 UNSPEC_TLS_LOAD))]
9791 "TARGET_64BIT"
d40c829f 9792 "lg\t%0,%1%J2"
9381e3f1
WG
9793 [(set_attr "op_type" "RXE")
9794 (set_attr "z10prop" "z10_fwd_A3")])
fd3cd001
UW
9795
9796(define_insn "*tls_load_31"
d3632d41
UW
9797 [(set (match_operand:SI 0 "register_operand" "=d,d")
9798 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
fd3cd001
UW
9799 (match_operand:SI 2 "" "")]
9800 UNSPEC_TLS_LOAD))]
9801 "!TARGET_64BIT"
d3632d41 9802 "@
d40c829f
UW
9803 l\t%0,%1%J2
9804 ly\t%0,%1%J2"
9381e3f1 9805 [(set_attr "op_type" "RX,RXY")
cdc15d23 9806 (set_attr "type" "load")
3e4be43f 9807 (set_attr "cpu_facility" "*,longdisp")
9381e3f1 9808 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
fd3cd001 9809
9e8327e3 9810(define_insn "*bras_tls"
c19ec8f9 9811 [(set (match_operand 0 "" "")
9e8327e3
UW
9812 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9813 (match_operand 2 "const_int_operand" "n")))
9814 (clobber (match_operand 3 "register_operand" "=r"))
9815 (use (match_operand 4 "" ""))]
2f7e5a0d
EC
9816 "!SIBLING_CALL_P (insn)
9817 && TARGET_SMALL_EXEC
ed9676cf 9818 && GET_MODE (operands[3]) == Pmode"
d40c829f 9819 "bras\t%3,%1%J4"
fd3cd001 9820 [(set_attr "op_type" "RI")
65b1d8ea
AK
9821 (set_attr "type" "jsr")
9822 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9823
9e8327e3 9824(define_insn "*brasl_tls"
c19ec8f9 9825 [(set (match_operand 0 "" "")
9e8327e3
UW
9826 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9827 (match_operand 2 "const_int_operand" "n")))
9828 (clobber (match_operand 3 "register_operand" "=r"))
9829 (use (match_operand 4 "" ""))]
2f7e5a0d
EC
9830 "!SIBLING_CALL_P (insn)
9831 && TARGET_CPU_ZARCH
ed9676cf 9832 && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9833 "brasl\t%3,%1%J4"
9834 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9835 (set_attr "type" "jsr")
9836 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9837
9e8327e3 9838(define_insn "*basr_tls"
c19ec8f9 9839 [(set (match_operand 0 "" "")
3e4be43f 9840 (call (mem:QI (match_operand 1 "address_operand" "ZR"))
9e8327e3
UW
9841 (match_operand 2 "const_int_operand" "n")))
9842 (clobber (match_operand 3 "register_operand" "=r"))
9843 (use (match_operand 4 "" ""))]
ed9676cf 9844 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9845{
9846 if (get_attr_op_type (insn) == OP_TYPE_RR)
9847 return "basr\t%3,%1%J4";
9848 else
9849 return "bas\t%3,%a1%J4";
9850}
9851 [(set (attr "op_type")
9852 (if_then_else (match_operand 1 "register_operand" "")
9853 (const_string "RR") (const_string "RX")))
9854 (set_attr "type" "jsr")
65b1d8ea
AK
9855 (set_attr "atype" "agen")
9856 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9857
e0374221
AS
9858;;
9859;;- Atomic operations
9860;;
9861
9862;
78ce265b 9863; memory barrier patterns.
e0374221
AS
9864;
9865
78ce265b
RH
9866(define_expand "mem_signal_fence"
9867 [(match_operand:SI 0 "const_int_operand")] ;; model
e0374221
AS
9868 ""
9869{
78ce265b
RH
9870 /* The s390 memory model is strong enough not to require any
9871 barrier in order to synchronize a thread with itself. */
9872 DONE;
9873})
9874
9875(define_expand "mem_thread_fence"
9876 [(match_operand:SI 0 "const_int_operand")] ;; model
9877 ""
9878{
9879 /* Unless this is a SEQ_CST fence, the s390 memory model is strong
9880 enough not to require barriers of any kind. */
46b35980 9881 if (is_mm_seq_cst (memmodel_from_int (INTVAL (operands[0]))))
78ce265b
RH
9882 {
9883 rtx mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
9884 MEM_VOLATILE_P (mem) = 1;
9885 emit_insn (gen_mem_thread_fence_1 (mem));
9886 }
9887 DONE;
e0374221
AS
9888})
9889
78ce265b
RH
9890; Although bcr is superscalar on Z10, this variant will never
9891; become part of an execution group.
a9cc3f58
AK
9892; With z196 we can make use of the fast-BCR-serialization facility.
9893; This allows for a slightly faster sync which is sufficient for our
9894; purposes.
78ce265b 9895(define_insn "mem_thread_fence_1"
e0374221 9896 [(set (match_operand:BLK 0 "" "")
1a8c13b3 9897 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
e0374221 9898 ""
a9cc3f58
AK
9899{
9900 if (TARGET_Z196)
9901 return "bcr\t14,0";
9902 else
9903 return "bcr\t15,0";
9904}
9905 [(set_attr "op_type" "RR")
9906 (set_attr "mnemonic" "bcr_flush")
9907 (set_attr "z196prop" "z196_alone")])
1a8c13b3 9908
78ce265b
RH
9909;
9910; atomic load/store operations
9911;
9912
9913; Atomic loads need not examine the memory model at all.
9914(define_expand "atomic_load<mode>"
9915 [(match_operand:DINT 0 "register_operand") ;; output
9916 (match_operand:DINT 1 "memory_operand") ;; memory
9917 (match_operand:SI 2 "const_int_operand")] ;; model
9918 ""
9919{
75cc21e2
AK
9920 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
9921 FAIL;
9922
78ce265b
RH
9923 if (<MODE>mode == TImode)
9924 emit_insn (gen_atomic_loadti_1 (operands[0], operands[1]));
9925 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9926 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
9927 else
9928 emit_move_insn (operands[0], operands[1]);
9929 DONE;
9930})
9931
9932; Different from movdi_31 in that we want no splitters.
9933(define_insn "atomic_loaddi_1"
9934 [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f")
9935 (unspec:DI [(match_operand:DI 1 "memory_operand" "Q,S,R,T")]
9936 UNSPEC_MOVA))]
9937 "!TARGET_ZARCH"
9938 "@
9939 lm\t%0,%M0,%S1
9940 lmy\t%0,%M0,%S1
9941 ld\t%0,%1
9942 ldy\t%0,%1"
9943 [(set_attr "op_type" "RS,RSY,RS,RSY")
3e4be43f 9944 (set_attr "cpu_facility" "*,longdisp,*,longdisp")
78ce265b
RH
9945 (set_attr "type" "lm,lm,floaddf,floaddf")])
9946
9947(define_insn "atomic_loadti_1"
9948 [(set (match_operand:TI 0 "register_operand" "=r")
3e4be43f 9949 (unspec:TI [(match_operand:TI 1 "memory_operand" "T")]
78ce265b
RH
9950 UNSPEC_MOVA))]
9951 "TARGET_ZARCH"
9952 "lpq\t%0,%1"
9953 [(set_attr "op_type" "RXY")
9954 (set_attr "type" "other")])
9955
9956; Atomic stores must(?) enforce sequential consistency.
9957(define_expand "atomic_store<mode>"
9958 [(match_operand:DINT 0 "memory_operand") ;; memory
9959 (match_operand:DINT 1 "register_operand") ;; input
9960 (match_operand:SI 2 "const_int_operand")] ;; model
9961 ""
9962{
46b35980 9963 enum memmodel model = memmodel_from_int (INTVAL (operands[2]));
78ce265b 9964
75cc21e2
AK
9965 if (MEM_ALIGN (operands[0]) < GET_MODE_BITSIZE (GET_MODE (operands[0])))
9966 FAIL;
9967
78ce265b
RH
9968 if (<MODE>mode == TImode)
9969 emit_insn (gen_atomic_storeti_1 (operands[0], operands[1]));
9970 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9971 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
9972 else
9973 emit_move_insn (operands[0], operands[1]);
46b35980 9974 if (is_mm_seq_cst (model))
78ce265b
RH
9975 emit_insn (gen_mem_thread_fence (operands[2]));
9976 DONE;
9977})
9978
9979; Different from movdi_31 in that we want no splitters.
9980(define_insn "atomic_storedi_1"
9981 [(set (match_operand:DI 0 "memory_operand" "=Q,S,R,T")
9982 (unspec:DI [(match_operand:DI 1 "register_operand" "d,d,!*f,!*f")]
9983 UNSPEC_MOVA))]
9984 "!TARGET_ZARCH"
9985 "@
9986 stm\t%1,%N1,%S0
9987 stmy\t%1,%N1,%S0
9988 std %1,%0
9989 stdy %1,%0"
9990 [(set_attr "op_type" "RS,RSY,RS,RSY")
3e4be43f 9991 (set_attr "cpu_facility" "*,longdisp,*,longdisp")
78ce265b
RH
9992 (set_attr "type" "stm,stm,fstoredf,fstoredf")])
9993
9994(define_insn "atomic_storeti_1"
3e4be43f 9995 [(set (match_operand:TI 0 "memory_operand" "=T")
78ce265b
RH
9996 (unspec:TI [(match_operand:TI 1 "register_operand" "r")]
9997 UNSPEC_MOVA))]
9998 "TARGET_ZARCH"
9999 "stpq\t%1,%0"
10000 [(set_attr "op_type" "RXY")
10001 (set_attr "type" "other")])
e0374221
AS
10002
10003;
10004; compare and swap patterns.
10005;
10006
78ce265b
RH
10007(define_expand "atomic_compare_and_swap<mode>"
10008 [(match_operand:SI 0 "register_operand") ;; bool success output
215770ad 10009 (match_operand:DGPR 1 "nonimmediate_operand");; oldval output
78ce265b
RH
10010 (match_operand:DGPR 2 "memory_operand") ;; memory
10011 (match_operand:DGPR 3 "register_operand") ;; expected intput
10012 (match_operand:DGPR 4 "register_operand") ;; newval intput
10013 (match_operand:SI 5 "const_int_operand") ;; is_weak
10014 (match_operand:SI 6 "const_int_operand") ;; success model
10015 (match_operand:SI 7 "const_int_operand")] ;; failure model
10016 ""
10017{
215770ad
UW
10018 rtx cc, cmp, output = operands[1];
10019
10020 if (!register_operand (output, <MODE>mode))
10021 output = gen_reg_rtx (<MODE>mode);
10022
75cc21e2
AK
10023 if (MEM_ALIGN (operands[2]) < GET_MODE_BITSIZE (GET_MODE (operands[2])))
10024 FAIL;
10025
78ce265b 10026 emit_insn (gen_atomic_compare_and_swap<mode>_internal
215770ad
UW
10027 (output, operands[2], operands[3], operands[4]));
10028
10029 /* We deliberately accept non-register operands in the predicate
10030 to ensure the write back to the output operand happens *before*
10031 the store-flags code below. This makes it easier for combine
10032 to merge the store-flags code with a potential test-and-branch
10033 pattern following (immediately!) afterwards. */
10034 if (output != operands[1])
10035 emit_move_insn (operands[1], output);
10036
78ce265b
RH
10037 cc = gen_rtx_REG (CCZ1mode, CC_REGNUM);
10038 cmp = gen_rtx_EQ (SImode, cc, const0_rtx);
10039 emit_insn (gen_cstorecc4 (operands[0], cmp, cc, const0_rtx));
10040 DONE;
10041})
e0374221 10042
78ce265b
RH
10043(define_expand "atomic_compare_and_swap<mode>"
10044 [(match_operand:SI 0 "register_operand") ;; bool success output
215770ad 10045 (match_operand:HQI 1 "nonimmediate_operand") ;; oldval output
78ce265b
RH
10046 (match_operand:HQI 2 "memory_operand") ;; memory
10047 (match_operand:HQI 3 "general_operand") ;; expected intput
10048 (match_operand:HQI 4 "general_operand") ;; newval intput
10049 (match_operand:SI 5 "const_int_operand") ;; is_weak
10050 (match_operand:SI 6 "const_int_operand") ;; success model
10051 (match_operand:SI 7 "const_int_operand")] ;; failure model
3093f076 10052 ""
78ce265b
RH
10053{
10054 s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1], operands[2],
10055 operands[3], operands[4], INTVAL (operands[5]));
10056 DONE;
10057})
3093f076 10058
78ce265b
RH
10059(define_expand "atomic_compare_and_swap<mode>_internal"
10060 [(parallel
10061 [(set (match_operand:DGPR 0 "register_operand")
10062 (match_operand:DGPR 1 "memory_operand"))
10063 (set (match_dup 1)
10064 (unspec_volatile:DGPR
10065 [(match_dup 1)
10066 (match_operand:DGPR 2 "register_operand")
10067 (match_operand:DGPR 3 "register_operand")]
10068 UNSPECV_CAS))
10069 (set (reg:CCZ1 CC_REGNUM)
10070 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
10071 "")
10072
10073; cdsg, csg
10074(define_insn "*atomic_compare_and_swap<mode>_1"
10075 [(set (match_operand:TDI 0 "register_operand" "=r")
3e4be43f 10076 (match_operand:TDI 1 "memory_operand" "+S"))
8006eaa6 10077 (set (match_dup 1)
78ce265b 10078 (unspec_volatile:TDI
8006eaa6 10079 [(match_dup 1)
78ce265b
RH
10080 (match_operand:TDI 2 "register_operand" "0")
10081 (match_operand:TDI 3 "register_operand" "r")]
8006eaa6
AS
10082 UNSPECV_CAS))
10083 (set (reg:CCZ1 CC_REGNUM)
10084 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
78ce265b
RH
10085 "TARGET_ZARCH"
10086 "c<td>sg\t%0,%3,%S1"
10087 [(set_attr "op_type" "RSY")
8006eaa6
AS
10088 (set_attr "type" "sem")])
10089
78ce265b
RH
10090; cds, cdsy
10091(define_insn "*atomic_compare_and_swapdi_2"
10092 [(set (match_operand:DI 0 "register_operand" "=r,r")
10093 (match_operand:DI 1 "memory_operand" "+Q,S"))
e0374221 10094 (set (match_dup 1)
78ce265b
RH
10095 (unspec_volatile:DI
10096 [(match_dup 1)
10097 (match_operand:DI 2 "register_operand" "0,0")
10098 (match_operand:DI 3 "register_operand" "r,r")]
10099 UNSPECV_CAS))
10100 (set (reg:CCZ1 CC_REGNUM)
10101 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
10102 "!TARGET_ZARCH"
10103 "@
10104 cds\t%0,%3,%S1
10105 cdsy\t%0,%3,%S1"
10106 [(set_attr "op_type" "RS,RSY")
3e4be43f 10107 (set_attr "cpu_facility" "*,longdisp")
78ce265b
RH
10108 (set_attr "type" "sem")])
10109
10110; cs, csy
10111(define_insn "*atomic_compare_and_swapsi_3"
10112 [(set (match_operand:SI 0 "register_operand" "=r,r")
10113 (match_operand:SI 1 "memory_operand" "+Q,S"))
10114 (set (match_dup 1)
10115 (unspec_volatile:SI
e0374221 10116 [(match_dup 1)
78ce265b
RH
10117 (match_operand:SI 2 "register_operand" "0,0")
10118 (match_operand:SI 3 "register_operand" "r,r")]
e0374221 10119 UNSPECV_CAS))
69950452
AS
10120 (set (reg:CCZ1 CC_REGNUM)
10121 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9381e3f1 10122 ""
78ce265b
RH
10123 "@
10124 cs\t%0,%3,%S1
10125 csy\t%0,%3,%S1"
10126 [(set_attr "op_type" "RS,RSY")
3e4be43f 10127 (set_attr "cpu_facility" "*,longdisp")
e0374221
AS
10128 (set_attr "type" "sem")])
10129
45d18331
AS
10130;
10131; Other atomic instruction patterns.
10132;
10133
65b1d8ea
AK
10134; z196 load and add, xor, or and and instructions
10135
78ce265b
RH
10136(define_expand "atomic_fetch_<atomic><mode>"
10137 [(match_operand:GPR 0 "register_operand") ;; val out
10138 (ATOMIC_Z196:GPR
10139 (match_operand:GPR 1 "memory_operand") ;; memory
10140 (match_operand:GPR 2 "register_operand")) ;; val in
10141 (match_operand:SI 3 "const_int_operand")] ;; model
65b1d8ea 10142 "TARGET_Z196"
78ce265b 10143{
75cc21e2
AK
10144 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
10145 FAIL;
10146
78ce265b
RH
10147 emit_insn (gen_atomic_fetch_<atomic><mode>_iaf
10148 (operands[0], operands[1], operands[2]));
10149 DONE;
10150})
65b1d8ea
AK
10151
10152; lan, lang, lao, laog, lax, laxg, laa, laag
78ce265b
RH
10153(define_insn "atomic_fetch_<atomic><mode>_iaf"
10154 [(set (match_operand:GPR 0 "register_operand" "=d")
3e4be43f 10155 (match_operand:GPR 1 "memory_operand" "+S"))
78ce265b
RH
10156 (set (match_dup 1)
10157 (unspec_volatile:GPR
10158 [(ATOMIC_Z196:GPR (match_dup 1)
10159 (match_operand:GPR 2 "general_operand" "d"))]
10160 UNSPECV_ATOMIC_OP))
10161 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 10162 "TARGET_Z196"
78ce265b
RH
10163 "la<noxa><g>\t%0,%2,%1"
10164 [(set_attr "op_type" "RSY")
10165 (set_attr "type" "sem")])
65b1d8ea 10166
78ce265b
RH
10167;; For SImode and larger, the optabs.c code will do just fine in
10168;; expanding a compare-and-swap loop. For QI/HImode, we can do
10169;; better by expanding our own loop.
65b1d8ea 10170
78ce265b
RH
10171(define_expand "atomic_<atomic><mode>"
10172 [(ATOMIC:HQI
10173 (match_operand:HQI 0 "memory_operand") ;; memory
10174 (match_operand:HQI 1 "general_operand")) ;; val in
10175 (match_operand:SI 2 "const_int_operand")] ;; model
45d18331 10176 ""
78ce265b
RH
10177{
10178 s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
10179 operands[1], false);
10180 DONE;
10181})
45d18331 10182
78ce265b
RH
10183(define_expand "atomic_fetch_<atomic><mode>"
10184 [(match_operand:HQI 0 "register_operand") ;; val out
10185 (ATOMIC:HQI
10186 (match_operand:HQI 1 "memory_operand") ;; memory
10187 (match_operand:HQI 2 "general_operand")) ;; val in
10188 (match_operand:SI 3 "const_int_operand")] ;; model
45d18331 10189 ""
78ce265b
RH
10190{
10191 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
10192 operands[2], false);
10193 DONE;
10194})
10195
10196(define_expand "atomic_<atomic>_fetch<mode>"
10197 [(match_operand:HQI 0 "register_operand") ;; val out
10198 (ATOMIC:HQI
10199 (match_operand:HQI 1 "memory_operand") ;; memory
10200 (match_operand:HQI 2 "general_operand")) ;; val in
10201 (match_operand:SI 3 "const_int_operand")] ;; model
10202 ""
10203{
10204 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
10205 operands[2], true);
10206 DONE;
10207})
10208
10209(define_expand "atomic_exchange<mode>"
10210 [(match_operand:HQI 0 "register_operand") ;; val out
10211 (match_operand:HQI 1 "memory_operand") ;; memory
10212 (match_operand:HQI 2 "general_operand") ;; val in
10213 (match_operand:SI 3 "const_int_operand")] ;; model
45d18331 10214 ""
78ce265b
RH
10215{
10216 s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
10217 operands[2], false);
10218 DONE;
10219})
45d18331 10220
9db1d521
HP
10221;;
10222;;- Miscellaneous instructions.
10223;;
10224
10225;
10226; allocate stack instruction pattern(s).
10227;
10228
10229(define_expand "allocate_stack"
ef44a6ff
UW
10230 [(match_operand 0 "general_operand" "")
10231 (match_operand 1 "general_operand" "")]
b3d31392 10232 "TARGET_BACKCHAIN"
9db1d521 10233{
ef44a6ff 10234 rtx temp = gen_reg_rtx (Pmode);
9db1d521 10235
ef44a6ff
UW
10236 emit_move_insn (temp, s390_back_chain_rtx ());
10237 anti_adjust_stack (operands[1]);
10238 emit_move_insn (s390_back_chain_rtx (), temp);
9db1d521 10239
ef44a6ff
UW
10240 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10241 DONE;
10bbf137 10242})
9db1d521
HP
10243
10244
10245;
43ab026f 10246; setjmp instruction pattern.
9db1d521
HP
10247;
10248
9db1d521 10249(define_expand "builtin_setjmp_receiver"
fd7643fb 10250 [(match_operand 0 "" "")]
f314b9b1 10251 "flag_pic"
9db1d521 10252{
585539a1 10253 emit_insn (s390_load_got ());
c41c1387 10254 emit_use (pic_offset_table_rtx);
9db1d521 10255 DONE;
fd7643fb 10256})
9db1d521 10257
9db1d521
HP
10258;; These patterns say how to save and restore the stack pointer. We need not
10259;; save the stack pointer at function level since we are careful to
10260;; preserve the backchain. At block level, we have to restore the backchain
10261;; when we restore the stack pointer.
10262;;
10263;; For nonlocal gotos, we must save both the stack pointer and its
10264;; backchain and restore both. Note that in the nonlocal case, the
10265;; save area is a memory location.
10266
10267(define_expand "save_stack_function"
10268 [(match_operand 0 "general_operand" "")
10269 (match_operand 1 "general_operand" "")]
10270 ""
10271 "DONE;")
10272
10273(define_expand "restore_stack_function"
10274 [(match_operand 0 "general_operand" "")
10275 (match_operand 1 "general_operand" "")]
10276 ""
10277 "DONE;")
10278
10279(define_expand "restore_stack_block"
ef44a6ff
UW
10280 [(match_operand 0 "register_operand" "")
10281 (match_operand 1 "register_operand" "")]
b3d31392 10282 "TARGET_BACKCHAIN"
9db1d521 10283{
ef44a6ff
UW
10284 rtx temp = gen_reg_rtx (Pmode);
10285
10286 emit_move_insn (temp, s390_back_chain_rtx ());
10287 emit_move_insn (operands[0], operands[1]);
10288 emit_move_insn (s390_back_chain_rtx (), temp);
10289
10290 DONE;
10bbf137 10291})
9db1d521
HP
10292
10293(define_expand "save_stack_nonlocal"
10294 [(match_operand 0 "memory_operand" "")
10295 (match_operand 1 "register_operand" "")]
10296 ""
9db1d521 10297{
ef44a6ff
UW
10298 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
10299
10300 /* Copy the backchain to the first word, sp to the second and the
10301 literal pool base to the third. */
10302
9602b6a1
AK
10303 rtx save_bc = adjust_address (operands[0], Pmode, 0);
10304 rtx save_sp = adjust_address (operands[0], Pmode, GET_MODE_SIZE (Pmode));
10305 rtx save_bp = adjust_address (operands[0], Pmode, 2 * GET_MODE_SIZE (Pmode));
10306
b3d31392 10307 if (TARGET_BACKCHAIN)
9602b6a1 10308 emit_move_insn (save_bc, force_reg (Pmode, s390_back_chain_rtx ()));
ef44a6ff 10309
9602b6a1
AK
10310 emit_move_insn (save_sp, operands[1]);
10311 emit_move_insn (save_bp, base);
9db1d521 10312
9db1d521 10313 DONE;
10bbf137 10314})
9db1d521
HP
10315
10316(define_expand "restore_stack_nonlocal"
10317 [(match_operand 0 "register_operand" "")
10318 (match_operand 1 "memory_operand" "")]
10319 ""
9db1d521 10320{
490ceeb4 10321 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
ef44a6ff 10322 rtx temp = NULL_RTX;
9db1d521 10323
43ab026f 10324 /* Restore the backchain from the first word, sp from the second and the
ff482c8d 10325 literal pool base from the third. */
43ab026f 10326
9602b6a1
AK
10327 rtx save_bc = adjust_address (operands[1], Pmode, 0);
10328 rtx save_sp = adjust_address (operands[1], Pmode, GET_MODE_SIZE (Pmode));
10329 rtx save_bp = adjust_address (operands[1], Pmode, 2 * GET_MODE_SIZE (Pmode));
10330
b3d31392 10331 if (TARGET_BACKCHAIN)
9602b6a1 10332 temp = force_reg (Pmode, save_bc);
9381e3f1 10333
9602b6a1
AK
10334 emit_move_insn (base, save_bp);
10335 emit_move_insn (operands[0], save_sp);
ef44a6ff
UW
10336
10337 if (temp)
10338 emit_move_insn (s390_back_chain_rtx (), temp);
10339
c41c1387 10340 emit_use (base);
9db1d521 10341 DONE;
10bbf137 10342})
9db1d521 10343
7bcebb25
AK
10344(define_expand "exception_receiver"
10345 [(const_int 0)]
10346 ""
10347{
10348 s390_set_has_landing_pad_p (true);
10349 DONE;
10350})
9db1d521
HP
10351
10352;
10353; nop instruction pattern(s).
10354;
10355
10356(define_insn "nop"
10357 [(const_int 0)]
10358 ""
d40c829f 10359 "lr\t0,0"
729e750f
WG
10360 [(set_attr "op_type" "RR")
10361 (set_attr "z10prop" "z10_fr_E1")])
9db1d521 10362
d277db6b
WG
10363(define_insn "nop1"
10364 [(const_int 1)]
10365 ""
10366 "lr\t1,1"
10367 [(set_attr "op_type" "RR")])
10368
f8af0e30
DV
10369;;- Undeletable nops (used for hotpatching)
10370
10371(define_insn "nop_2_byte"
10372 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_2_BYTE)]
10373 ""
4bbc8970 10374 "nopr\t%%r0"
f8af0e30
DV
10375 [(set_attr "op_type" "RR")])
10376
10377(define_insn "nop_4_byte"
10378 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_4_BYTE)]
10379 ""
10380 "nop\t0"
10381 [(set_attr "op_type" "RX")])
10382
10383(define_insn "nop_6_byte"
10384 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_6_BYTE)]
10385 "TARGET_CPU_ZARCH"
10386 "brcl\t0, 0"
10387 [(set_attr "op_type" "RIL")])
10388
9db1d521
HP
10389
10390;
10391; Special literal pool access instruction pattern(s).
10392;
10393
416cf582
UW
10394(define_insn "*pool_entry"
10395 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
10396 UNSPECV_POOL_ENTRY)]
9db1d521 10397 ""
9db1d521 10398{
ef4bddc2 10399 machine_mode mode = GET_MODE (PATTERN (insn));
416cf582 10400 unsigned int align = GET_MODE_BITSIZE (mode);
faeb9bb6 10401 s390_output_pool_entry (operands[0], mode, align);
fd7643fb
UW
10402 return "";
10403}
b628bd8e 10404 [(set (attr "length")
416cf582 10405 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
b2ccb744 10406
9bb86f41
UW
10407(define_insn "pool_align"
10408 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
10409 UNSPECV_POOL_ALIGN)]
10410 ""
10411 ".align\t%0"
b628bd8e 10412 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
b2ccb744 10413
9bb86f41
UW
10414(define_insn "pool_section_start"
10415 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
10416 ""
b929b470
MK
10417{
10418 switch_to_section (targetm.asm_out.function_rodata_section
10419 (current_function_decl));
10420 return "";
10421}
b628bd8e 10422 [(set_attr "length" "0")])
b2ccb744 10423
9bb86f41
UW
10424(define_insn "pool_section_end"
10425 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
10426 ""
b929b470
MK
10427{
10428 switch_to_section (current_function_section ());
10429 return "";
10430}
b628bd8e 10431 [(set_attr "length" "0")])
b2ccb744 10432
5af2f3d3 10433(define_insn "main_base_31_small"
9e8327e3
UW
10434 [(set (match_operand 0 "register_operand" "=a")
10435 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
10436 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
10437 "basr\t%0,0"
10438 [(set_attr "op_type" "RR")
65b1d8ea
AK
10439 (set_attr "type" "la")
10440 (set_attr "z196prop" "z196_cracked")])
5af2f3d3
UW
10441
10442(define_insn "main_base_31_large"
9e8327e3
UW
10443 [(set (match_operand 0 "register_operand" "=a")
10444 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
5af2f3d3 10445 (set (pc) (label_ref (match_operand 2 "" "")))]
9e8327e3 10446 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3 10447 "bras\t%0,%2"
65b1d8ea
AK
10448 [(set_attr "op_type" "RI")
10449 (set_attr "z196prop" "z196_cracked")])
5af2f3d3
UW
10450
10451(define_insn "main_base_64"
9e8327e3
UW
10452 [(set (match_operand 0 "register_operand" "=a")
10453 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
10454 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
10455 "larl\t%0,%1"
10456 [(set_attr "op_type" "RIL")
9381e3f1 10457 (set_attr "type" "larl")
729e750f 10458 (set_attr "z10prop" "z10_fwd_A1")])
5af2f3d3
UW
10459
10460(define_insn "main_pool"
585539a1
UW
10461 [(set (match_operand 0 "register_operand" "=a")
10462 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
10463 "GET_MODE (operands[0]) == Pmode"
8d933e31
AS
10464{
10465 gcc_unreachable ();
10466}
9381e3f1 10467 [(set (attr "type")
d7f99b2c 10468 (if_then_else (match_test "TARGET_CPU_ZARCH")
ea77e738 10469 (const_string "larl") (const_string "la")))])
5af2f3d3 10470
aee4e0db 10471(define_insn "reload_base_31"
9e8327e3
UW
10472 [(set (match_operand 0 "register_operand" "=a")
10473 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
10474 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
d40c829f 10475 "basr\t%0,0\;la\t%0,%1-.(%0)"
b628bd8e 10476 [(set_attr "length" "6")
65b1d8ea
AK
10477 (set_attr "type" "la")
10478 (set_attr "z196prop" "z196_cracked")])
b2ccb744 10479
aee4e0db 10480(define_insn "reload_base_64"
9e8327e3
UW
10481 [(set (match_operand 0 "register_operand" "=a")
10482 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
10483 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
d40c829f 10484 "larl\t%0,%1"
aee4e0db 10485 [(set_attr "op_type" "RIL")
9381e3f1 10486 (set_attr "type" "larl")
729e750f 10487 (set_attr "z10prop" "z10_fwd_A1")])
aee4e0db 10488
aee4e0db 10489(define_insn "pool"
fd7643fb 10490 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
aee4e0db 10491 ""
8d933e31
AS
10492{
10493 gcc_unreachable ();
10494}
b628bd8e 10495 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
9db1d521 10496
4023fb28
UW
10497;;
10498;; Insns related to generating the function prologue and epilogue.
10499;;
10500
10501
10502(define_expand "prologue"
10503 [(use (const_int 0))]
10504 ""
10bbf137 10505 "s390_emit_prologue (); DONE;")
4023fb28
UW
10506
10507(define_expand "epilogue"
10508 [(use (const_int 1))]
10509 ""
ed9676cf
AK
10510 "s390_emit_epilogue (false); DONE;")
10511
10512(define_expand "sibcall_epilogue"
10513 [(use (const_int 0))]
10514 ""
10515 "s390_emit_epilogue (true); DONE;")
4023fb28 10516
177bc204
RS
10517;; A direct return instruction, without using an epilogue.
10518(define_insn "<code>"
10519 [(ANY_RETURN)]
10520 "s390_can_use_<code>_insn ()"
10521 "br\t%%r14"
10522 [(set_attr "op_type" "RR")
10523 (set_attr "type" "jsr")
10524 (set_attr "atype" "agen")])
10525
9e8327e3 10526(define_insn "*return"
4023fb28 10527 [(return)
9e8327e3
UW
10528 (use (match_operand 0 "register_operand" "a"))]
10529 "GET_MODE (operands[0]) == Pmode"
d40c829f 10530 "br\t%0"
4023fb28 10531 [(set_attr "op_type" "RR")
c7453384 10532 (set_attr "type" "jsr")
077dab3b 10533 (set_attr "atype" "agen")])
4023fb28 10534
4023fb28 10535
c7453384 10536;; Instruction definition to extend a 31-bit pointer into a 64-bit
839a4992 10537;; pointer. This is used for compatibility.
c7453384
EC
10538
10539(define_expand "ptr_extend"
10540 [(set (match_operand:DI 0 "register_operand" "=r")
10541 (match_operand:SI 1 "register_operand" "r"))]
9e8327e3 10542 "TARGET_64BIT"
c7453384 10543{
c7453384
EC
10544 emit_insn (gen_anddi3 (operands[0],
10545 gen_lowpart (DImode, operands[1]),
10546 GEN_INT (0x7fffffff)));
c7453384 10547 DONE;
10bbf137 10548})
4798630c
D
10549
10550;; Instruction definition to expand eh_return macro to support
10551;; swapping in special linkage return addresses.
10552
10553(define_expand "eh_return"
10554 [(use (match_operand 0 "register_operand" ""))]
10555 "TARGET_TPF"
10556{
10557 s390_emit_tpf_eh_return (operands[0]);
10558 DONE;
10559})
10560
7b8acc34
AK
10561;
10562; Stack Protector Patterns
10563;
10564
10565(define_expand "stack_protect_set"
10566 [(set (match_operand 0 "memory_operand" "")
10567 (match_operand 1 "memory_operand" ""))]
10568 ""
10569{
10570#ifdef TARGET_THREAD_SSP_OFFSET
10571 operands[1]
10572 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
10573 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
10574#endif
10575 if (TARGET_64BIT)
10576 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
10577 else
10578 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
10579
10580 DONE;
10581})
10582
10583(define_insn "stack_protect_set<mode>"
10584 [(set (match_operand:DSI 0 "memory_operand" "=Q")
10585 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
10586 ""
10587 "mvc\t%O0(%G0,%R0),%S1"
10588 [(set_attr "op_type" "SS")])
10589
10590(define_expand "stack_protect_test"
10591 [(set (reg:CC CC_REGNUM)
10592 (compare (match_operand 0 "memory_operand" "")
10593 (match_operand 1 "memory_operand" "")))
10594 (match_operand 2 "" "")]
10595 ""
10596{
f90b7a5a 10597 rtx cc_reg, test;
7b8acc34
AK
10598#ifdef TARGET_THREAD_SSP_OFFSET
10599 operands[1]
10600 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
10601 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
10602#endif
7b8acc34
AK
10603 if (TARGET_64BIT)
10604 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
10605 else
10606 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
10607
f90b7a5a
PB
10608 cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM);
10609 test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx);
10610 emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2]));
7b8acc34
AK
10611 DONE;
10612})
10613
10614(define_insn "stack_protect_test<mode>"
10615 [(set (reg:CCZ CC_REGNUM)
10616 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
10617 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
10618 ""
10619 "clc\t%O0(%G0,%R0),%S1"
10620 [(set_attr "op_type" "SS")])
12959abe
AK
10621
10622; This is used in s390_emit_prologue in order to prevent insns
10623; adjusting the stack pointer to be moved over insns writing stack
10624; slots using a copy of the stack pointer in a different register.
10625(define_insn "stack_tie"
10626 [(set (match_operand:BLK 0 "memory_operand" "+m")
10627 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
10628 ""
10629 ""
10630 [(set_attr "length" "0")])
963fc8d0
AK
10631
10632
82c6f58a
AK
10633(define_insn "stack_restore_from_fpr"
10634 [(set (reg:DI STACK_REGNUM)
10635 (match_operand:DI 0 "register_operand" "f"))
10636 (clobber (mem:BLK (scratch)))]
10637 "TARGET_Z10"
10638 "lgdr\t%%r15,%0"
10639 [(set_attr "op_type" "RRE")])
10640
963fc8d0
AK
10641;
10642; Data prefetch patterns
10643;
10644
10645(define_insn "prefetch"
3e4be43f
UW
10646 [(prefetch (match_operand 0 "address_operand" "ZT,X")
10647 (match_operand:SI 1 "const_int_operand" " n,n")
10648 (match_operand:SI 2 "const_int_operand" " n,n"))]
22d72dbc 10649 "TARGET_Z10"
963fc8d0 10650{
4fe6dea8
AK
10651 switch (which_alternative)
10652 {
10653 case 0:
4fe6dea8 10654 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
22d72dbc 10655 case 1:
4fe6dea8
AK
10656 if (larl_operand (operands[0], Pmode))
10657 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
a65593a4 10658 /* fallthrough */
4fe6dea8
AK
10659 default:
10660
10661 /* This might be reached for symbolic operands with an odd
10662 addend. We simply omit the prefetch for such rare cases. */
10663
10664 return "";
10665 }
9381e3f1 10666}
22d72dbc
AK
10667 [(set_attr "type" "load,larl")
10668 (set_attr "op_type" "RXY,RIL")
65b1d8ea
AK
10669 (set_attr "z10prop" "z10_super")
10670 (set_attr "z196prop" "z196_alone")])
07da44ab
AK
10671
10672
10673;
10674; Byte swap instructions
10675;
10676
511f5bb1
AK
10677; FIXME: There is also mvcin but we cannot use it since src and target
10678; may overlap.
50dc4eed 10679; lrvr, lrv, strv, lrvgr, lrvg, strvg
07da44ab 10680(define_insn "bswap<mode>2"
3e4be43f
UW
10681 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,T")
10682 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,T,d")))]
677fbff4 10683 "TARGET_CPU_ZARCH"
07da44ab
AK
10684 "@
10685 lrv<g>r\t%0,%1
6f5a59d1
AK
10686 lrv<g>\t%0,%1
10687 strv<g>\t%1,%0"
10688 [(set_attr "type" "*,load,store")
10689 (set_attr "op_type" "RRE,RXY,RXY")
07da44ab 10690 (set_attr "z10prop" "z10_super")])
65b1d8ea 10691
511f5bb1 10692(define_insn "bswaphi2"
3e4be43f
UW
10693 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,T")
10694 (bswap:HI (match_operand:HI 1 "nonimmediate_operand" " d,T,d")))]
511f5bb1 10695 "TARGET_CPU_ZARCH"
6f5a59d1
AK
10696 "@
10697 #
10698 lrvh\t%0,%1
10699 strvh\t%1,%0"
10700 [(set_attr "type" "*,load,store")
10701 (set_attr "op_type" "RRE,RXY,RXY")
511f5bb1 10702 (set_attr "z10prop" "z10_super")])
65b1d8ea 10703
6f5a59d1
AK
10704(define_split
10705 [(set (match_operand:HI 0 "register_operand" "")
10706 (bswap:HI (match_operand:HI 1 "register_operand" "")))]
10707 "TARGET_CPU_ZARCH"
10708 [(set (match_dup 2) (bswap:SI (match_dup 3)))
9060e335 10709 (set (match_dup 2) (lshiftrt:SI (match_dup 2) (const_int 16)))]
6f5a59d1 10710{
9060e335 10711 operands[2] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
6f5a59d1
AK
10712 operands[3] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
10713})
10714
10715
65b1d8ea
AK
10716;
10717; Population count instruction
10718;
10719
10720; The S/390 popcount instruction counts the bits of op1 in 8 byte
10721; portions and stores the result in the corresponding bytes in op0.
10722(define_insn "*popcount<mode>"
10723 [(set (match_operand:INT 0 "register_operand" "=d")
10724 (unspec:INT [(match_operand:INT 1 "register_operand" "d")] UNSPEC_POPCNT))
10725 (clobber (reg:CC CC_REGNUM))]
10726 "TARGET_Z196"
10727 "popcnt\t%0,%1"
10728 [(set_attr "op_type" "RRE")])
10729
10730(define_expand "popcountdi2"
10731 [; popcnt op0, op1
10732 (parallel [(set (match_operand:DI 0 "register_operand" "")
10733 (unspec:DI [(match_operand:DI 1 "register_operand")]
10734 UNSPEC_POPCNT))
10735 (clobber (reg:CC CC_REGNUM))])
10736 ; sllg op2, op0, 32
10737 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 32)))
10738 ; agr op0, op2
10739 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10740 (clobber (reg:CC CC_REGNUM))])
10741 ; sllg op2, op0, 16
17465c6e 10742 (set (match_dup 2)
65b1d8ea
AK
10743 (ashift:DI (match_dup 0) (const_int 16)))
10744 ; agr op0, op2
10745 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10746 (clobber (reg:CC CC_REGNUM))])
10747 ; sllg op2, op0, 8
10748 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 8)))
10749 ; agr op0, op2
10750 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10751 (clobber (reg:CC CC_REGNUM))])
10752 ; srlg op0, op0, 56
10753 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (const_int 56)))]
10754 "TARGET_Z196 && TARGET_64BIT"
10755 "operands[2] = gen_reg_rtx (DImode);")
10756
10757(define_expand "popcountsi2"
10758 [; popcnt op0, op1
10759 (parallel [(set (match_operand:SI 0 "register_operand" "")
10760 (unspec:SI [(match_operand:SI 1 "register_operand")]
10761 UNSPEC_POPCNT))
10762 (clobber (reg:CC CC_REGNUM))])
10763 ; sllk op2, op0, 16
17465c6e 10764 (set (match_dup 2)
65b1d8ea
AK
10765 (ashift:SI (match_dup 0) (const_int 16)))
10766 ; ar op0, op2
10767 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10768 (clobber (reg:CC CC_REGNUM))])
10769 ; sllk op2, op0, 8
10770 (set (match_dup 2) (ashift:SI (match_dup 0) (const_int 8)))
10771 ; ar op0, op2
10772 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10773 (clobber (reg:CC CC_REGNUM))])
10774 ; srl op0, op0, 24
10775 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 24)))]
10776 "TARGET_Z196"
10777 "operands[2] = gen_reg_rtx (SImode);")
10778
10779(define_expand "popcounthi2"
10780 [; popcnt op0, op1
10781 (parallel [(set (match_operand:HI 0 "register_operand" "")
10782 (unspec:HI [(match_operand:HI 1 "register_operand")]
10783 UNSPEC_POPCNT))
10784 (clobber (reg:CC CC_REGNUM))])
10785 ; sllk op2, op0, 8
17465c6e 10786 (set (match_dup 2)
65b1d8ea
AK
10787 (ashift:SI (match_dup 0) (const_int 8)))
10788 ; ar op0, op2
10789 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10790 (clobber (reg:CC CC_REGNUM))])
10791 ; srl op0, op0, 8
10792 (set (match_dup 0) (lshiftrt:HI (match_dup 0) (const_int 8)))]
10793 "TARGET_Z196"
10794 "operands[2] = gen_reg_rtx (SImode);")
10795
10796(define_expand "popcountqi2"
10797 [; popcnt op0, op1
10798 (parallel [(set (match_operand:QI 0 "register_operand" "")
10799 (unspec:QI [(match_operand:QI 1 "register_operand")]
10800 UNSPEC_POPCNT))
10801 (clobber (reg:CC CC_REGNUM))])]
10802 "TARGET_Z196"
10803 "")
10804
10805;;
10806;;- Copy sign instructions
10807;;
10808
10809(define_insn "copysign<mode>3"
10810 [(set (match_operand:FP 0 "register_operand" "=f")
10811 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
10812 (match_operand:FP 2 "register_operand" "f")]
10813 UNSPEC_COPYSIGN))]
10814 "TARGET_Z196"
10815 "cpsdr\t%0,%2,%1"
10816 [(set_attr "op_type" "RRF")
10817 (set_attr "type" "fsimp<mode>")])
5a3fe9b6
AK
10818
10819
10820;;
10821;;- Transactional execution instructions
10822;;
10823
10824; This splitter helps combine to make use of CC directly when
10825; comparing the integer result of a tbegin builtin with a constant.
10826; The unspec is already removed by canonicalize_comparison. So this
10827; splitters only job is to turn the PARALLEL into separate insns
10828; again. Unfortunately this only works with the very first cc/int
10829; compare since combine is not able to deal with data flow across
10830; basic block boundaries.
10831
10832; It needs to be an insn pattern as well since combine does not apply
10833; the splitter directly. Combine would only use it if it actually
10834; would reduce the number of instructions.
10835(define_insn_and_split "*ccraw_to_int"
10836 [(set (pc)
10837 (if_then_else
10838 (match_operator 0 "s390_eqne_operator"
10839 [(reg:CCRAW CC_REGNUM)
10840 (match_operand 1 "const_int_operand" "")])
10841 (label_ref (match_operand 2 "" ""))
10842 (pc)))
10843 (set (match_operand:SI 3 "register_operand" "=d")
10844 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
10845 ""
10846 "#"
10847 ""
10848 [(set (match_dup 3)
10849 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))
10850 (set (pc)
10851 (if_then_else (match_op_dup 0 [(reg:CCRAW CC_REGNUM) (match_dup 1)])
10852 (label_ref (match_dup 2))
10853 (pc)))]
10854 "")
10855
10856; Non-constrained transaction begin
10857
10858(define_expand "tbegin"
ee163e72
AK
10859 [(match_operand:SI 0 "register_operand" "")
10860 (match_operand:BLK 1 "memory_operand" "")]
5a3fe9b6
AK
10861 "TARGET_HTM"
10862{
10863 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, true);
10864 DONE;
10865})
10866
10867(define_expand "tbegin_nofloat"
ee163e72
AK
10868 [(match_operand:SI 0 "register_operand" "")
10869 (match_operand:BLK 1 "memory_operand" "")]
5a3fe9b6
AK
10870 "TARGET_HTM"
10871{
10872 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, false);
10873 DONE;
10874})
10875
10876(define_expand "tbegin_retry"
ee163e72
AK
10877 [(match_operand:SI 0 "register_operand" "")
10878 (match_operand:BLK 1 "memory_operand" "")
10879 (match_operand:SI 2 "general_operand" "")]
5a3fe9b6
AK
10880 "TARGET_HTM"
10881{
10882 s390_expand_tbegin (operands[0], operands[1], operands[2], true);
10883 DONE;
10884})
10885
10886(define_expand "tbegin_retry_nofloat"
ee163e72
AK
10887 [(match_operand:SI 0 "register_operand" "")
10888 (match_operand:BLK 1 "memory_operand" "")
10889 (match_operand:SI 2 "general_operand" "")]
5a3fe9b6
AK
10890 "TARGET_HTM"
10891{
10892 s390_expand_tbegin (operands[0], operands[1], operands[2], false);
10893 DONE;
10894})
10895
c914ac45
AK
10896; Clobber VRs since they don't get restored
10897(define_insn "tbegin_1_z13"
10898 [(set (reg:CCRAW CC_REGNUM)
10899 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10900 UNSPECV_TBEGIN))
10901 (set (match_operand:BLK 1 "memory_operand" "=Q")
10902 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
10903 (clobber (reg:TI 16)) (clobber (reg:TI 38))
10904 (clobber (reg:TI 17)) (clobber (reg:TI 39))
10905 (clobber (reg:TI 18)) (clobber (reg:TI 40))
10906 (clobber (reg:TI 19)) (clobber (reg:TI 41))
10907 (clobber (reg:TI 20)) (clobber (reg:TI 42))
10908 (clobber (reg:TI 21)) (clobber (reg:TI 43))
10909 (clobber (reg:TI 22)) (clobber (reg:TI 44))
10910 (clobber (reg:TI 23)) (clobber (reg:TI 45))
10911 (clobber (reg:TI 24)) (clobber (reg:TI 46))
10912 (clobber (reg:TI 25)) (clobber (reg:TI 47))
10913 (clobber (reg:TI 26)) (clobber (reg:TI 48))
10914 (clobber (reg:TI 27)) (clobber (reg:TI 49))
10915 (clobber (reg:TI 28)) (clobber (reg:TI 50))
10916 (clobber (reg:TI 29)) (clobber (reg:TI 51))
10917 (clobber (reg:TI 30)) (clobber (reg:TI 52))
10918 (clobber (reg:TI 31)) (clobber (reg:TI 53))]
10919; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
10920; not supposed to be used for immediates (see genpreds.c).
10921 "TARGET_VX && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10922 "tbegin\t%1,%x0"
10923 [(set_attr "op_type" "SIL")])
10924
5a3fe9b6
AK
10925(define_insn "tbegin_1"
10926 [(set (reg:CCRAW CC_REGNUM)
2561451d 10927 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
5a3fe9b6 10928 UNSPECV_TBEGIN))
2561451d
AK
10929 (set (match_operand:BLK 1 "memory_operand" "=Q")
10930 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
5a3fe9b6
AK
10931 (clobber (reg:DF 16))
10932 (clobber (reg:DF 17))
10933 (clobber (reg:DF 18))
10934 (clobber (reg:DF 19))
10935 (clobber (reg:DF 20))
10936 (clobber (reg:DF 21))
10937 (clobber (reg:DF 22))
10938 (clobber (reg:DF 23))
10939 (clobber (reg:DF 24))
10940 (clobber (reg:DF 25))
10941 (clobber (reg:DF 26))
10942 (clobber (reg:DF 27))
10943 (clobber (reg:DF 28))
10944 (clobber (reg:DF 29))
10945 (clobber (reg:DF 30))
10946 (clobber (reg:DF 31))]
10947; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
10948; not supposed to be used for immediates (see genpreds.c).
2561451d
AK
10949 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10950 "tbegin\t%1,%x0"
5a3fe9b6
AK
10951 [(set_attr "op_type" "SIL")])
10952
10953; Same as above but without the FPR clobbers
10954(define_insn "tbegin_nofloat_1"
10955 [(set (reg:CCRAW CC_REGNUM)
2561451d
AK
10956 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10957 UNSPECV_TBEGIN))
10958 (set (match_operand:BLK 1 "memory_operand" "=Q")
10959 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))]
10960 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10961 "tbegin\t%1,%x0"
5a3fe9b6
AK
10962 [(set_attr "op_type" "SIL")])
10963
10964
10965; Constrained transaction begin
10966
10967(define_expand "tbeginc"
10968 [(set (reg:CCRAW CC_REGNUM)
10969 (unspec_volatile:CCRAW [(const_int TBEGINC_MASK)]
10970 UNSPECV_TBEGINC))]
10971 "TARGET_HTM"
10972 "")
10973
10974(define_insn "*tbeginc_1"
10975 [(set (reg:CCRAW CC_REGNUM)
10976 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" " D")]
10977 UNSPECV_TBEGINC))]
10978 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10979 "tbeginc\t0,%x0"
10980 [(set_attr "op_type" "SIL")])
10981
10982; Transaction end
10983
10984(define_expand "tend"
10985 [(set (reg:CCRAW CC_REGNUM)
10986 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))
ee163e72 10987 (set (match_operand:SI 0 "register_operand" "")
5a3fe9b6
AK
10988 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
10989 "TARGET_HTM"
10990 "")
10991
10992(define_insn "*tend_1"
10993 [(set (reg:CCRAW CC_REGNUM)
10994 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))]
10995 "TARGET_HTM"
10996 "tend"
10997 [(set_attr "op_type" "S")])
10998
10999; Transaction abort
11000
11001(define_expand "tabort"
eae48192 11002 [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "")]
5a3fe9b6
AK
11003 UNSPECV_TABORT)]
11004 "TARGET_HTM && operands != NULL"
11005{
11006 if (CONST_INT_P (operands[0])
11007 && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 255)
11008 {
f3981e7e 11009 error ("invalid transaction abort code: " HOST_WIDE_INT_PRINT_DEC
5a3fe9b6
AK
11010 ". Values in range 0 through 255 are reserved.",
11011 INTVAL (operands[0]));
11012 FAIL;
11013 }
11014})
11015
11016(define_insn "*tabort_1"
eae48192 11017 [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "aJ")]
5a3fe9b6
AK
11018 UNSPECV_TABORT)]
11019 "TARGET_HTM && operands != NULL"
11020 "tabort\t%Y0"
11021 [(set_attr "op_type" "S")])
11022
eae48192
AK
11023(define_insn "*tabort_1_plus"
11024 [(unspec_volatile [(plus:SI (match_operand:SI 0 "register_operand" "a")
11025 (match_operand:SI 1 "const_int_operand" "J"))]
11026 UNSPECV_TABORT)]
11027 "TARGET_HTM && operands != NULL
11028 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'J', \"J\")"
11029 "tabort\t%1(%0)"
11030 [(set_attr "op_type" "S")])
11031
5a3fe9b6
AK
11032; Transaction extract nesting depth
11033
11034(define_insn "etnd"
11035 [(set (match_operand:SI 0 "register_operand" "=d")
11036 (unspec_volatile:SI [(const_int 0)] UNSPECV_ETND))]
11037 "TARGET_HTM"
11038 "etnd\t%0"
11039 [(set_attr "op_type" "RRE")])
11040
11041; Non-transactional store
11042
11043(define_insn "ntstg"
3e4be43f 11044 [(set (match_operand:DI 0 "memory_operand" "=T")
5a3fe9b6
AK
11045 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "d")]
11046 UNSPECV_NTSTG))]
11047 "TARGET_HTM"
11048 "ntstg\t%1,%0"
11049 [(set_attr "op_type" "RXY")])
11050
11051; Transaction perform processor assist
11052
11053(define_expand "tx_assist"
2561451d
AK
11054 [(unspec_volatile [(match_operand:SI 0 "register_operand" "")
11055 (reg:SI GPR0_REGNUM)
5a3fe9b6
AK
11056 (const_int 1)]
11057 UNSPECV_PPA)]
11058 "TARGET_HTM"
2561451d 11059 "")
5a3fe9b6
AK
11060
11061(define_insn "*ppa"
11062 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")
11063 (match_operand:SI 1 "register_operand" "d")
11064 (match_operand 2 "const_int_operand" "I")]
11065 UNSPECV_PPA)]
11066 "TARGET_HTM && INTVAL (operands[2]) < 16"
2561451d 11067 "ppa\t%0,%1,%2"
5a3fe9b6 11068 [(set_attr "op_type" "RRF")])
004f64e1
AK
11069
11070
11071; Set and get floating point control register
11072
3af82a61 11073(define_insn "sfpc"
004f64e1
AK
11074 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")]
11075 UNSPECV_SFPC)]
11076 "TARGET_HARD_FLOAT"
11077 "sfpc\t%0")
11078
3af82a61 11079(define_insn "efpc"
004f64e1
AK
11080 [(set (match_operand:SI 0 "register_operand" "=d")
11081 (unspec_volatile:SI [(const_int 0)] UNSPECV_EFPC))]
11082 "TARGET_HARD_FLOAT"
11083 "efpc\t%0")
3af82a61
AK
11084
11085
11086; Load count to block boundary
11087
11088(define_insn "lcbb"
11089 [(set (match_operand:SI 0 "register_operand" "=d")
3e4be43f 11090 (unspec:SI [(match_operand 1 "address_operand" "ZR")
3af82a61
AK
11091 (match_operand:SI 2 "immediate_operand" "C")] UNSPEC_LCBB))
11092 (clobber (reg:CC CC_REGNUM))]
11093 "TARGET_Z13"
9a36359e 11094 "lcbb\t%0,%a1,%b2"
3af82a61 11095 [(set_attr "op_type" "VRX")])
4cb4721f
MK
11096
11097; Handle -fsplit-stack.
11098
11099(define_expand "split_stack_prologue"
11100 [(const_int 0)]
11101 ""
11102{
11103 s390_expand_split_stack_prologue ();
11104 DONE;
11105})
11106
11107;; If there are operand 0 bytes available on the stack, jump to
11108;; operand 1.
11109
11110(define_expand "split_stack_space_check"
11111 [(set (pc) (if_then_else
11112 (ltu (minus (reg 15)
11113 (match_operand 0 "register_operand"))
11114 (unspec [(const_int 0)] UNSPEC_STACK_CHECK))
11115 (label_ref (match_operand 1))
11116 (pc)))]
11117 ""
11118{
11119 /* Offset from thread pointer to __private_ss. */
11120 int psso = TARGET_64BIT ? 0x38 : 0x20;
11121 rtx tp = s390_get_thread_pointer ();
11122 rtx guard = gen_rtx_MEM (Pmode, plus_constant (Pmode, tp, psso));
11123 rtx reg = gen_reg_rtx (Pmode);
11124 rtx cc;
11125 if (TARGET_64BIT)
11126 emit_insn (gen_subdi3 (reg, stack_pointer_rtx, operands[0]));
11127 else
11128 emit_insn (gen_subsi3 (reg, stack_pointer_rtx, operands[0]));
11129 cc = s390_emit_compare (GT, reg, guard);
11130 s390_emit_jump (operands[1], cc);
11131
11132 DONE;
11133})
11134
11135;; __morestack parameter block for split stack prologue. Parameters are:
11136;; parameter block label, label to be called by __morestack, frame size,
11137;; stack parameter size.
11138
11139(define_insn "split_stack_data"
11140 [(unspec_volatile [(match_operand 0 "" "X")
11141 (match_operand 1 "" "X")
11142 (match_operand 2 "const_int_operand" "X")
11143 (match_operand 3 "const_int_operand" "X")]
11144 UNSPECV_SPLIT_STACK_DATA)]
11145 "TARGET_CPU_ZARCH"
11146{
11147 switch_to_section (targetm.asm_out.function_rodata_section
11148 (current_function_decl));
11149
11150 if (TARGET_64BIT)
11151 output_asm_insn (".align\t8", operands);
11152 else
11153 output_asm_insn (".align\t4", operands);
11154 (*targetm.asm_out.internal_label) (asm_out_file, "L",
11155 CODE_LABEL_NUMBER (operands[0]));
11156 if (TARGET_64BIT)
11157 {
11158 output_asm_insn (".quad\t%2", operands);
11159 output_asm_insn (".quad\t%3", operands);
11160 output_asm_insn (".quad\t%1-%0", operands);
11161 }
11162 else
11163 {
11164 output_asm_insn (".long\t%2", operands);
11165 output_asm_insn (".long\t%3", operands);
11166 output_asm_insn (".long\t%1-%0", operands);
11167 }
11168
11169 switch_to_section (current_function_section ());
11170 return "";
11171}
11172 [(set_attr "length" "0")])
11173
11174
11175;; A jg with minimal fuss for use in split stack prologue.
11176
11177(define_expand "split_stack_call"
11178 [(match_operand 0 "bras_sym_operand" "X")
11179 (match_operand 1 "" "")]
11180 "TARGET_CPU_ZARCH"
11181{
11182 if (TARGET_64BIT)
11183 emit_jump_insn (gen_split_stack_call_di (operands[0], operands[1]));
11184 else
11185 emit_jump_insn (gen_split_stack_call_si (operands[0], operands[1]));
11186 DONE;
11187})
11188
11189(define_insn "split_stack_call_<mode>"
11190 [(set (pc) (label_ref (match_operand 1 "" "")))
11191 (set (reg:P 1) (unspec_volatile [(match_operand 0 "bras_sym_operand" "X")
11192 (reg:P 1)]
11193 UNSPECV_SPLIT_STACK_CALL))]
11194 "TARGET_CPU_ZARCH"
11195 "jg\t%0"
11196 [(set_attr "op_type" "RIL")
11197 (set_attr "type" "branch")])
11198
11199;; Also a conditional one.
11200
11201(define_expand "split_stack_cond_call"
11202 [(match_operand 0 "bras_sym_operand" "X")
11203 (match_operand 1 "" "")
11204 (match_operand 2 "" "")]
11205 "TARGET_CPU_ZARCH"
11206{
11207 if (TARGET_64BIT)
11208 emit_jump_insn (gen_split_stack_cond_call_di (operands[0], operands[1], operands[2]));
11209 else
11210 emit_jump_insn (gen_split_stack_cond_call_si (operands[0], operands[1], operands[2]));
11211 DONE;
11212})
11213
11214(define_insn "split_stack_cond_call_<mode>"
11215 [(set (pc)
11216 (if_then_else
11217 (match_operand 1 "" "")
11218 (label_ref (match_operand 2 "" ""))
11219 (pc)))
11220 (set (reg:P 1) (unspec_volatile [(match_operand 0 "bras_sym_operand" "X")
11221 (reg:P 1)]
11222 UNSPECV_SPLIT_STACK_CALL))]
11223 "TARGET_CPU_ZARCH"
11224 "jg%C1\t%0"
11225 [(set_attr "op_type" "RIL")
11226 (set_attr "type" "branch")])
539405d5
AK
11227
11228(define_insn "osc_break"
11229 [(unspec_volatile [(const_int 0)] UNSPECV_OSC_BREAK)]
11230 ""
11231 "bcr\t7,%%r0"
11232 [(set_attr "op_type" "RR")])