]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/s390/s390.md
S/390: Vector base support - testcases
[thirdparty/gcc.git] / gcc / config / s390 / s390.md
CommitLineData
9db1d521 1;;- Machine description for GNU compiler -- S/390 / zSeries version.
5624e564 2;; Copyright (C) 1999-2015 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
10bbf137 73 ; GOT/PLT and lt-relative accesses
30a49b23
AK
74 UNSPEC_LTREL_OFFSET
75 UNSPEC_LTREL_BASE
76 UNSPEC_POOL_OFFSET
77 UNSPEC_GOTENT
78 UNSPEC_GOT
79 UNSPEC_GOTOFF
80 UNSPEC_PLT
81 UNSPEC_PLTOFF
fd7643fb
UW
82
83 ; Literal pool
30a49b23
AK
84 UNSPEC_RELOAD_BASE
85 UNSPEC_MAIN_BASE
86 UNSPEC_LTREF
87 UNSPEC_INSN
88 UNSPEC_EXECUTE
fd7643fb 89
1a8c13b3 90 ; Atomic Support
30a49b23 91 UNSPEC_MB
78ce265b 92 UNSPEC_MOVA
1a8c13b3 93
fd7643fb 94 ; TLS relocation specifiers
30a49b23
AK
95 UNSPEC_TLSGD
96 UNSPEC_TLSLDM
97 UNSPEC_NTPOFF
98 UNSPEC_DTPOFF
99 UNSPEC_GOTNTPOFF
100 UNSPEC_INDNTPOFF
fd3cd001
UW
101
102 ; TLS support
30a49b23
AK
103 UNSPEC_TLSLDM_NTPOFF
104 UNSPEC_TLS_LOAD
91d39d71
UW
105
106 ; String Functions
30a49b23
AK
107 UNSPEC_SRST
108 UNSPEC_MVST
638e37c2 109
7b8acc34 110 ; Stack Smashing Protector
30a49b23
AK
111 UNSPEC_SP_SET
112 UNSPEC_SP_TEST
85dae55a 113
638e37c2 114 ; Test Data Class (TDC)
30a49b23 115 UNSPEC_TDC_INSN
65b1d8ea
AK
116
117 ; Population Count
30a49b23
AK
118 UNSPEC_POPCNT
119 UNSPEC_COPYSIGN
d12a76f3
AK
120
121 ; Load FP Integer
122 UNSPEC_FPINT_FLOOR
123 UNSPEC_FPINT_BTRUNC
124 UNSPEC_FPINT_ROUND
125 UNSPEC_FPINT_CEIL
126 UNSPEC_FPINT_NEARBYINT
127 UNSPEC_FPINT_RINT
085261c8
AK
128
129 ; Vector
130 UNSPEC_VEC_EXTRACT
131 UNSPEC_VEC_SET
132 UNSPEC_VEC_PERM
133 UNSPEC_VEC_SRLB
134 UNSPEC_VEC_GENBYTEMASK
135 UNSPEC_VEC_VSUM
136 UNSPEC_VEC_VSUMG
137 UNSPEC_VEC_SMULT_EVEN
138 UNSPEC_VEC_UMULT_EVEN
139 UNSPEC_VEC_SMULT_ODD
140 UNSPEC_VEC_UMULT_ODD
141 UNSPEC_VEC_LOAD_LEN
142 UNSPEC_VEC_VFENE
143 UNSPEC_VEC_VFENECC
144])
fd3cd001
UW
145
146;;
147;; UNSPEC_VOLATILE usage
148;;
149
30a49b23
AK
150(define_c_enum "unspecv" [
151 ; Blockage
152 UNSPECV_BLOCKAGE
10bbf137 153
2f7e5a0d 154 ; TPF Support
30a49b23
AK
155 UNSPECV_TPF_PROLOGUE
156 UNSPECV_TPF_EPILOGUE
2f7e5a0d 157
10bbf137 158 ; Literal pool
30a49b23
AK
159 UNSPECV_POOL
160 UNSPECV_POOL_SECTION
161 UNSPECV_POOL_ALIGN
162 UNSPECV_POOL_ENTRY
163 UNSPECV_MAIN_POOL
fd7643fb
UW
164
165 ; TLS support
30a49b23 166 UNSPECV_SET_TP
e0374221
AS
167
168 ; Atomic Support
30a49b23
AK
169 UNSPECV_CAS
170 UNSPECV_ATOMIC_OP
5a3fe9b6 171
f8af0e30
DV
172 ; Hotpatching (unremovable NOPs)
173 UNSPECV_NOP_2_BYTE
174 UNSPECV_NOP_4_BYTE
175 UNSPECV_NOP_6_BYTE
176
5a3fe9b6
AK
177 ; Transactional Execution support
178 UNSPECV_TBEGIN
2561451d 179 UNSPECV_TBEGIN_TDB
5a3fe9b6
AK
180 UNSPECV_TBEGINC
181 UNSPECV_TEND
182 UNSPECV_TABORT
183 UNSPECV_ETND
184 UNSPECV_NTSTG
185 UNSPECV_PPA
004f64e1
AK
186
187 ; Set and get floating point control register
188 UNSPECV_SFPC
189 UNSPECV_EFPC
fd3cd001
UW
190 ])
191
ae156f85
AS
192;;
193;; Registers
194;;
195
35dd9a0e
AK
196; Registers with special meaning
197
ae156f85
AS
198(define_constants
199 [
200 ; Sibling call register.
201 (SIBCALL_REGNUM 1)
202 ; Literal pool base register.
203 (BASE_REGNUM 13)
204 ; Return address register.
205 (RETURN_REGNUM 14)
206 ; Condition code register.
207 (CC_REGNUM 33)
f4aa3848 208 ; Thread local storage pointer register.
ae156f85
AS
209 (TP_REGNUM 36)
210 ])
211
35dd9a0e
AK
212; Hardware register names
213
214(define_constants
215 [
216 ; General purpose registers
217 (GPR0_REGNUM 0)
218 ; Floating point registers.
219 (FPR0_REGNUM 16)
2cf4c39e
AK
220 (FPR1_REGNUM 20)
221 (FPR2_REGNUM 17)
222 (FPR3_REGNUM 21)
223 (FPR4_REGNUM 18)
224 (FPR5_REGNUM 22)
225 (FPR6_REGNUM 19)
226 (FPR7_REGNUM 23)
227 (FPR8_REGNUM 24)
228 (FPR9_REGNUM 28)
229 (FPR10_REGNUM 25)
230 (FPR11_REGNUM 29)
231 (FPR12_REGNUM 26)
232 (FPR13_REGNUM 30)
233 (FPR14_REGNUM 27)
234 (FPR15_REGNUM 31)
085261c8
AK
235 (VR0_REGNUM 16)
236 (VR16_REGNUM 38)
237 (VR23_REGNUM 45)
238 (VR24_REGNUM 46)
239 (VR31_REGNUM 53)
35dd9a0e
AK
240 ])
241
242;;
243;; PFPO GPR0 argument format
244;;
245
246(define_constants
247 [
248 ; PFPO operation type
249 (PFPO_CONVERT 0x1000000)
250 ; PFPO operand types
251 (PFPO_OP_TYPE_SF 0x5)
252 (PFPO_OP_TYPE_DF 0x6)
253 (PFPO_OP_TYPE_TF 0x7)
254 (PFPO_OP_TYPE_SD 0x8)
255 (PFPO_OP_TYPE_DD 0x9)
256 (PFPO_OP_TYPE_TD 0xa)
257 ; Bitposition of operand types
258 (PFPO_OP0_TYPE_SHIFT 16)
259 (PFPO_OP1_TYPE_SHIFT 8)
260 ])
261
5a3fe9b6
AK
262; Immediate operands for tbegin and tbeginc
263(define_constants [(TBEGIN_MASK 65292)]) ; 0xff0c
264(define_constants [(TBEGINC_MASK 65288)]) ; 0xff08
fd3cd001 265
29a74354
UW
266;; Instruction operand type as used in the Principles of Operation.
267;; Used to determine defaults for length and other attribute values.
1fec52be 268
29a74354 269(define_attr "op_type"
085261c8 270 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR,SIL,RRS,RIS,VRI,VRR,VRS,VRV,VRX"
b628bd8e 271 (const_string "NN"))
9db1d521 272
29a74354 273;; Instruction type attribute used for scheduling.
9db1d521 274
077dab3b 275(define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
e0374221 276 cs,vs,store,sem,idiv,
ed0e512a 277 imulhi,imulsi,imuldi,
2cdece44 278 branch,jsr,fsimptf,fsimpdf,fsimpsf,fhex,
f61a2c7d
AK
279 floadtf,floaddf,floadsf,fstoredf,fstoresf,
280 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
9381e3f1 281 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
65b1d8ea 282 fmadddf,fmaddsf,
9381e3f1
WG
283 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
284 itoftf, itofdf, itofsf, itofdd, itoftd,
285 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
286 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
287 ftoidfp, other"
29a74354
UW
288 (cond [(eq_attr "op_type" "NN") (const_string "other")
289 (eq_attr "op_type" "SS") (const_string "cs")]
290 (const_string "integer")))
9db1d521 291
29a74354
UW
292;; Another attribute used for scheduling purposes:
293;; agen: Instruction uses the address generation unit
294;; reg: Instruction does not use the agen unit
077dab3b
HP
295
296(define_attr "atype" "agen,reg"
c68e7b86 297 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF,RRR")
0101708c
AS
298 (const_string "reg")
299 (const_string "agen")))
9db1d521 300
9381e3f1
WG
301;; Properties concerning Z10 execution grouping and value forwarding.
302;; z10_super: instruction is superscalar.
303;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
304;; z10_fwd: The instruction reads the value of an operand and stores it into a
305;; target register. It can forward this value to a second instruction that reads
306;; the same register if that second instruction is issued in the same group.
307;; z10_rec: The instruction is in the T pipeline and reads a register. If the
308;; instruction in the S pipe writes to the register, then the T instruction
309;; can immediately read the new value.
310;; z10_fr: union of Z10_fwd and z10_rec.
311;; z10_c: second operand of instruction is a register and read with complemented bits.
9381e3f1
WG
312;;
313;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
314
315
316(define_attr "z10prop" "none,
317 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
318 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
319 z10_rec,
320 z10_fr, z10_fr_A3, z10_fr_E1,
e3cba5e5 321 z10_c"
9381e3f1
WG
322 (const_string "none"))
323
65b1d8ea
AK
324;; Properties concerning Z196 decoding
325;; z196_alone: must group alone
326;; z196_end: ends a group
327;; z196_cracked: instruction is cracked or expanded
328(define_attr "z196prop" "none,
329 z196_alone, z196_ends,
330 z196_cracked"
331 (const_string "none"))
9381e3f1 332
a9cc3f58 333(define_attr "mnemonic" "bcr_flush,unknown" (const_string "unknown"))
22ac2c2f 334
9db1d521
HP
335;; Length in bytes.
336
337(define_attr "length" ""
963fc8d0
AK
338 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
339 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF,RRR") (const_int 4)]
b628bd8e 340 (const_int 6)))
9db1d521 341
29a74354
UW
342
343;; Processor type. This attribute must exactly match the processor_type
344;; enumeration in s390.h. The current machine description does not
345;; distinguish between g5 and g6, but there are differences between the two
346;; CPUs could in theory be modeled.
347
55ac540c 348(define_attr "cpu" "g5,g6,z900,z990,z9_109,z9_ec,z10,z196,zEC12,z13"
90c6fd8a 349 (const (symbol_ref "s390_tune_attr")))
29a74354 350
b5e0425c 351(define_attr "cpu_facility"
55ac540c 352 "standard,ieee,zarch,cpu_zarch,longdisp,extimm,dfp,z10,z196,zEC12,vec"
3af8e996
AK
353 (const_string "standard"))
354
355(define_attr "enabled" ""
356 (cond [(eq_attr "cpu_facility" "standard")
357 (const_int 1)
358
359 (and (eq_attr "cpu_facility" "ieee")
d7f99b2c 360 (match_test "TARGET_CPU_IEEE_FLOAT"))
3af8e996
AK
361 (const_int 1)
362
363 (and (eq_attr "cpu_facility" "zarch")
d7f99b2c 364 (match_test "TARGET_ZARCH"))
3af8e996
AK
365 (const_int 1)
366
367 (and (eq_attr "cpu_facility" "longdisp")
d7f99b2c 368 (match_test "TARGET_LONG_DISPLACEMENT"))
3af8e996
AK
369 (const_int 1)
370
371 (and (eq_attr "cpu_facility" "extimm")
d7f99b2c 372 (match_test "TARGET_EXTIMM"))
3af8e996
AK
373 (const_int 1)
374
375 (and (eq_attr "cpu_facility" "dfp")
d7f99b2c 376 (match_test "TARGET_DFP"))
93538e8e
AK
377 (const_int 1)
378
b5e0425c
AK
379 (and (eq_attr "cpu_facility" "cpu_zarch")
380 (match_test "TARGET_CPU_ZARCH"))
381 (const_int 1)
382
93538e8e 383 (and (eq_attr "cpu_facility" "z10")
d7f99b2c 384 (match_test "TARGET_Z10"))
65b1d8ea
AK
385 (const_int 1)
386
387 (and (eq_attr "cpu_facility" "z196")
d7f99b2c 388 (match_test "TARGET_Z196"))
22ac2c2f
AK
389 (const_int 1)
390
391 (and (eq_attr "cpu_facility" "zEC12")
392 (match_test "TARGET_ZEC12"))
55ac540c
AK
393 (const_int 1)
394
395 (and (eq_attr "cpu_facility" "vec")
396 (match_test "TARGET_VX"))
3af8e996
AK
397 (const_int 1)]
398 (const_int 0)))
399
29a74354
UW
400;; Pipeline description for z900. For lack of anything better,
401;; this description is also used for the g5 and g6.
402(include "2064.md")
403
3443392a 404;; Pipeline description for z990, z9-109 and z9-ec.
29a74354
UW
405(include "2084.md")
406
9381e3f1
WG
407;; Pipeline description for z10
408(include "2097.md")
409
65b1d8ea
AK
410;; Pipeline description for z196
411(include "2817.md")
412
22ac2c2f
AK
413;; Pipeline description for zEC12
414(include "2827.md")
415
0bfc3f69
AS
416;; Predicates
417(include "predicates.md")
418
cd8dc1f9
WG
419;; Constraint definitions
420(include "constraints.md")
421
a8ba31f2
EC
422;; Other includes
423(include "tpf.md")
f52c81dd 424
3abcb3a7 425;; Iterators
f52c81dd 426
085261c8
AK
427(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])
428
3abcb3a7 429;; These mode iterators allow floating point patterns to be generated from the
f5905b37 430;; same template.
f4aa3848 431(define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
0387c142 432 (SD "TARGET_HARD_DFP")])
3abcb3a7
HPN
433(define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
434(define_mode_iterator BFP [TF DF SF])
435(define_mode_iterator DFP [TD DD])
436(define_mode_iterator DFP_ALL [TD DD SD])
437(define_mode_iterator DSF [DF SF])
438(define_mode_iterator SD_SF [SF SD])
439(define_mode_iterator DD_DF [DF DD])
440(define_mode_iterator TD_TF [TF TD])
441
3abcb3a7 442;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
9db2f16d 443;; from the same template.
9602b6a1 444(define_mode_iterator GPR [(DI "TARGET_ZARCH") SI])
78ce265b 445(define_mode_iterator DGPR [(TI "TARGET_ZARCH") DI SI])
3abcb3a7 446(define_mode_iterator DSI [DI SI])
78ce265b 447(define_mode_iterator TDI [TI DI])
9db2f16d 448
3abcb3a7 449;; These mode iterators allow :P to be used for patterns that operate on
9db2f16d 450;; pointer-sized quantities. Exactly one of the two alternatives will match.
3abcb3a7 451(define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
9db2f16d 452
78ce265b
RH
453;; These macros refer to the actual word_mode of the configuration.
454;; This is equal to Pmode except on 31-bit machines in zarch mode.
9602b6a1
AK
455(define_mode_iterator DW [(TI "TARGET_ZARCH") (DI "!TARGET_ZARCH")])
456(define_mode_iterator W [(DI "TARGET_ZARCH") (SI "!TARGET_ZARCH")])
457
6e0d70c9
AK
458;; Used by the umul pattern to express modes having half the size.
459(define_mode_attr DWH [(TI "DI") (DI "SI")])
460(define_mode_attr dwh [(TI "di") (DI "si")])
461
3abcb3a7 462;; This mode iterator allows the QI and HI patterns to be defined from
f52c81dd 463;; the same template.
3abcb3a7 464(define_mode_iterator HQI [HI QI])
f52c81dd 465
3abcb3a7 466;; This mode iterator allows the integer patterns to be defined from the
342cf42b 467;; same template.
9602b6a1 468(define_mode_iterator INT [(DI "TARGET_ZARCH") SI HI QI])
78ce265b 469(define_mode_iterator DINT [(TI "TARGET_ZARCH") DI SI HI QI])
342cf42b 470
3abcb3a7 471;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
f337b930 472;; the same template.
3abcb3a7 473(define_code_iterator SHIFT [ashift lshiftrt])
f337b930 474
d12a76f3 475;; This iterator allows r[ox]sbg to be defined with the same template
571e408a
RH
476(define_code_iterator IXOR [ior xor])
477
d12a76f3
AK
478;; This iterator is used to expand the patterns for the nearest
479;; integer functions.
480(define_int_iterator FPINT [UNSPEC_FPINT_FLOOR UNSPEC_FPINT_BTRUNC
481 UNSPEC_FPINT_ROUND UNSPEC_FPINT_CEIL
482 UNSPEC_FPINT_NEARBYINT])
483(define_int_attr fpint_name [(UNSPEC_FPINT_FLOOR "floor")
484 (UNSPEC_FPINT_BTRUNC "btrunc")
485 (UNSPEC_FPINT_ROUND "round")
486 (UNSPEC_FPINT_CEIL "ceil")
487 (UNSPEC_FPINT_NEARBYINT "nearbyint")])
488(define_int_attr fpint_roundingmode [(UNSPEC_FPINT_FLOOR "7")
489 (UNSPEC_FPINT_BTRUNC "5")
490 (UNSPEC_FPINT_ROUND "1")
491 (UNSPEC_FPINT_CEIL "6")
492 (UNSPEC_FPINT_NEARBYINT "0")])
493
3abcb3a7
HPN
494;; This iterator and attribute allow to combine most atomic operations.
495(define_code_iterator ATOMIC [and ior xor plus minus mult])
65b1d8ea 496(define_code_iterator ATOMIC_Z196 [and ior xor plus])
cf5b43b0 497(define_code_attr atomic [(and "and") (ior "or") (xor "xor")
45d18331 498 (plus "add") (minus "sub") (mult "nand")])
65b1d8ea 499(define_code_attr noxa [(and "n") (ior "o") (xor "x") (plus "a")])
45d18331 500
f4aa3848 501;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
609e7e80
AK
502;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
503(define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
f337b930 504
f4aa3848
AK
505;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
506;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
609e7e80
AK
507;; SDmode.
508(define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
f5905b37 509
609e7e80 510;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
f61a2c7d
AK
511;; Likewise for "<RXe>".
512(define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
513(define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
514
609e7e80 515;; The decimal floating point variants of add, sub, div and mul support 3
3abcb3a7 516;; fp register operands. The following attributes allow to merge the bfp and
609e7e80
AK
517;; dfp variants in a single insn definition.
518
3abcb3a7 519;; This attribute is used to set op_type accordingly.
f4aa3848 520(define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
609e7e80
AK
521 (DD "RRR") (SD "RRR")])
522
f4aa3848 523;; This attribute is used in the operand constraint list in order to have the
609e7e80
AK
524;; first and the second operand match for bfp modes.
525(define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
526
f4aa3848 527;; This attribute is used in the operand list of the instruction to have an
609e7e80
AK
528;; additional operand for the dfp instructions.
529(define_mode_attr op1 [(TF "") (DF "") (SF "")
530 (TD "%1,") (DD "%1,") (SD "%1,")])
531
f5905b37 532
85dae55a
AK
533;; This attribute is used in the operand constraint list
534;; for instructions dealing with the sign bit of 32 or 64bit fp values.
535;; TFmode values are represented by a fp register pair. Since the
536;; sign bit instructions only handle single source and target fp registers
537;; these instructions can only be used for TFmode values if the source and
538;; target operand uses the same fp register.
539(define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
540
609e7e80
AK
541;; In FP templates, "<Rf>" will expand to "f" in TFmode and "R" otherwise.
542;; This is used to disable the memory alternative in TFmode patterns.
543(define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
544
3abcb3a7 545;; This attribute adds b for bfp instructions and t for dfp instructions and is used
609e7e80
AK
546;; within instruction mnemonics.
547(define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
548
0387c142
WG
549;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
550;; modes and to an empty string for bfp modes.
551(define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
552
1b48c8cc
AS
553;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
554;; and "0" in SImode. This allows to combine instructions of which the 31bit
555;; version only operates on one register.
556(define_mode_attr d0 [(DI "d") (SI "0")])
557
558;; In combination with d0 this allows to combine instructions of which the 31bit
559;; version only operates on one register. The DImode version needs an additional
560;; register for the assembler output.
561(define_mode_attr 1 [(DI "%1,") (SI "")])
9381e3f1
WG
562
563;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
f337b930
AS
564;; 'ashift' and "srdl" in 'lshiftrt'.
565(define_code_attr lr [(ashift "l") (lshiftrt "r")])
566
567;; In SHIFT templates, this attribute holds the correct standard name for the
9381e3f1 568;; pattern itself and the corresponding function calls.
f337b930 569(define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
9a91a21f
AS
570
571;; This attribute handles differences in the instruction 'type' and will result
572;; in "RRE" for DImode and "RR" for SImode.
573(define_mode_attr E [(DI "E") (SI "")])
574
3298c037
AK
575;; This attribute handles differences in the instruction 'type' and makes RX<Y>
576;; to result in "RXY" for DImode and "RX" for SImode.
577(define_mode_attr Y [(DI "Y") (SI "")])
578
8006eaa6
AS
579;; This attribute handles differences in the instruction 'type' and will result
580;; in "RSE" for TImode and "RS" for DImode.
581(define_mode_attr TE [(TI "E") (DI "")])
582
9a91a21f
AS
583;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
584;; and "lcr" in SImode.
585(define_mode_attr g [(DI "g") (SI "")])
f52c81dd 586
3298c037
AK
587;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
588;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
589;; were enhanced with long displacements whereas 31bit instructions got a ..y
590;; variant for long displacements.
591(define_mode_attr y [(DI "g") (SI "y")])
592
9602b6a1 593;; In DW templates, a string like "cds<g>" will expand to "cdsg" in TImode
8006eaa6
AS
594;; and "cds" in DImode.
595(define_mode_attr tg [(TI "g") (DI "")])
596
78ce265b
RH
597;; In TDI templates, a string like "c<d>sg".
598(define_mode_attr td [(TI "d") (DI "")])
599
2f8f8434
AS
600;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
601;; and "cfdbr" in SImode.
602(define_mode_attr gf [(DI "g") (SI "f")])
603
65b1d8ea
AK
604;; In GPR templates, a string like sll<gk> will expand to sllg for DI
605;; and sllk for SI. This way it is possible to merge the new z196 SI
606;; 3 operands shift instructions into the existing patterns.
607(define_mode_attr gk [(DI "g") (SI "k")])
608
f52c81dd
AS
609;; ICM mask required to load MODE value into the lowest subreg
610;; of a SImode register.
611(define_mode_attr icm_lo [(HI "3") (QI "1")])
612
f6ee577c
AS
613;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
614;; HImode and "llgc" in QImode.
615(define_mode_attr hc [(HI "h") (QI "c")])
616
a1aed706
AS
617;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
618;; in SImode.
619(define_mode_attr DBL [(DI "TI") (SI "DI")])
620
609e7e80
AK
621;; This attribute expands to DF for TFmode and to DD for TDmode . It is
622;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
623(define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
624
f52c81dd
AS
625;; Maximum unsigned integer that fits in MODE.
626(define_mode_attr max_uint [(HI "65535") (QI "255")])
627
75ca1b39
RH
628;; Start and end field computations for RISBG et al.
629(define_mode_attr bfstart [(DI "s") (SI "t")])
630(define_mode_attr bfend [(DI "e") (SI "f")])
631
2542ef05
RH
632;; In place of GET_MODE_BITSIZE (<MODE>mode)
633(define_mode_attr bitsize [(DI "64") (SI "32") (HI "16") (QI "8")])
634
177bc204
RS
635;; Allow return and simple_return to be defined from a single template.
636(define_code_iterator ANY_RETURN [return simple_return])
637
085261c8
AK
638(include "vector.md")
639
9db1d521
HP
640;;
641;;- Compare instructions.
642;;
643
07893d4f 644; Test-under-Mask instructions
9db1d521 645
07893d4f 646(define_insn "*tmqi_mem"
ae156f85 647 [(set (reg CC_REGNUM)
68f9c5e2
UW
648 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
649 (match_operand:QI 1 "immediate_operand" "n,n"))
650 (match_operand:QI 2 "immediate_operand" "n,n")))]
3ed99cc9 651 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
d3632d41 652 "@
fc0ea003
UW
653 tm\t%S0,%b1
654 tmy\t%S0,%b1"
9381e3f1
WG
655 [(set_attr "op_type" "SI,SIY")
656 (set_attr "z10prop" "z10_super,z10_super")])
9db1d521 657
05b9aaaa 658(define_insn "*tmdi_reg"
ae156f85 659 [(set (reg CC_REGNUM)
f19a9af7 660 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
2f7e5a0d 661 (match_operand:DI 1 "immediate_operand"
f19a9af7
AK
662 "N0HD0,N1HD0,N2HD0,N3HD0"))
663 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
9602b6a1 664 "TARGET_ZARCH
3ed99cc9 665 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
f19a9af7
AK
666 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
667 "@
668 tmhh\t%0,%i1
669 tmhl\t%0,%i1
670 tmlh\t%0,%i1
671 tmll\t%0,%i1"
9381e3f1
WG
672 [(set_attr "op_type" "RI")
673 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
05b9aaaa
UW
674
675(define_insn "*tmsi_reg"
ae156f85 676 [(set (reg CC_REGNUM)
f19a9af7
AK
677 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
678 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
679 (match_operand:SI 2 "immediate_operand" "n,n")))]
3ed99cc9 680 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
f19a9af7
AK
681 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
682 "@
683 tmh\t%0,%i1
684 tml\t%0,%i1"
729e750f
WG
685 [(set_attr "op_type" "RI")
686 (set_attr "z10prop" "z10_super,z10_super")])
05b9aaaa 687
f52c81dd 688(define_insn "*tm<mode>_full"
ae156f85 689 [(set (reg CC_REGNUM)
f52c81dd
AS
690 (compare (match_operand:HQI 0 "register_operand" "d")
691 (match_operand:HQI 1 "immediate_operand" "n")))]
3ed99cc9 692 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
f52c81dd 693 "tml\t%0,<max_uint>"
729e750f
WG
694 [(set_attr "op_type" "RI")
695 (set_attr "z10prop" "z10_super")])
9db1d521 696
07893d4f 697
08a5aaa2 698;
07893d4f 699; Load-and-Test instructions
08a5aaa2
AS
700;
701
c0220ea4 702; tst(di|si) instruction pattern(s).
07893d4f
UW
703
704(define_insn "*tstdi_sign"
ae156f85 705 [(set (reg CC_REGNUM)
963fc8d0
AK
706 (compare
707 (ashiftrt:DI
708 (ashift:DI
709 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,RT") 0)
710 (const_int 32)) (const_int 32))
711 (match_operand:DI 1 "const0_operand" "")))
712 (set (match_operand:DI 2 "register_operand" "=d,d")
07893d4f 713 (sign_extend:DI (match_dup 0)))]
9602b6a1 714 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH"
963fc8d0
AK
715 "ltgfr\t%2,%0
716 ltgf\t%2,%0"
717 [(set_attr "op_type" "RRE,RXY")
9381e3f1
WG
718 (set_attr "cpu_facility" "*,z10")
719 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
07893d4f 720
43a09b63 721; ltr, lt, ltgr, ltg
08a5aaa2 722(define_insn "*tst<mode>_extimm"
ec24698e 723 [(set (reg CC_REGNUM)
fb492564 724 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
08a5aaa2
AS
725 (match_operand:GPR 1 "const0_operand" "")))
726 (set (match_operand:GPR 2 "register_operand" "=d,d")
ec24698e 727 (match_dup 0))]
08a5aaa2 728 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
ec24698e 729 "@
08a5aaa2
AS
730 lt<g>r\t%2,%0
731 lt<g>\t%2,%0"
9381e3f1 732 [(set_attr "op_type" "RR<E>,RXY")
729e750f 733 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
ec24698e 734
43a09b63 735; ltr, lt, ltgr, ltg
08a5aaa2 736(define_insn "*tst<mode>_cconly_extimm"
ec24698e 737 [(set (reg CC_REGNUM)
fb492564 738 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
08a5aaa2
AS
739 (match_operand:GPR 1 "const0_operand" "")))
740 (clobber (match_scratch:GPR 2 "=X,d"))]
741 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
ec24698e 742 "@
08a5aaa2
AS
743 lt<g>r\t%0,%0
744 lt<g>\t%2,%0"
9381e3f1 745 [(set_attr "op_type" "RR<E>,RXY")
729e750f 746 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
ec24698e 747
07893d4f 748(define_insn "*tstdi"
ae156f85 749 [(set (reg CC_REGNUM)
07893d4f
UW
750 (compare (match_operand:DI 0 "register_operand" "d")
751 (match_operand:DI 1 "const0_operand" "")))
752 (set (match_operand:DI 2 "register_operand" "=d")
753 (match_dup 0))]
9602b6a1 754 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH && !TARGET_EXTIMM"
d40c829f 755 "ltgr\t%2,%0"
9381e3f1
WG
756 [(set_attr "op_type" "RRE")
757 (set_attr "z10prop" "z10_fr_E1")])
9db1d521 758
07893d4f 759(define_insn "*tstsi"
ae156f85 760 [(set (reg CC_REGNUM)
d3632d41 761 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
07893d4f 762 (match_operand:SI 1 "const0_operand" "")))
d3632d41 763 (set (match_operand:SI 2 "register_operand" "=d,d,d")
07893d4f 764 (match_dup 0))]
ec24698e 765 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
07893d4f 766 "@
d40c829f 767 ltr\t%2,%0
fc0ea003
UW
768 icm\t%2,15,%S0
769 icmy\t%2,15,%S0"
9381e3f1
WG
770 [(set_attr "op_type" "RR,RS,RSY")
771 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
9db1d521 772
07893d4f 773(define_insn "*tstsi_cconly"
ae156f85 774 [(set (reg CC_REGNUM)
d3632d41 775 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
07893d4f 776 (match_operand:SI 1 "const0_operand" "")))
d3632d41 777 (clobber (match_scratch:SI 2 "=X,d,d"))]
07893d4f
UW
778 "s390_match_ccmode(insn, CCSmode)"
779 "@
d40c829f 780 ltr\t%0,%0
fc0ea003
UW
781 icm\t%2,15,%S0
782 icmy\t%2,15,%S0"
9381e3f1
WG
783 [(set_attr "op_type" "RR,RS,RSY")
784 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
4023fb28 785
08a5aaa2
AS
786(define_insn "*tstdi_cconly_31"
787 [(set (reg CC_REGNUM)
788 (compare (match_operand:DI 0 "register_operand" "d")
789 (match_operand:DI 1 "const0_operand" "")))]
9602b6a1 790 "s390_match_ccmode(insn, CCSmode) && !TARGET_ZARCH"
08a5aaa2
AS
791 "srda\t%0,0"
792 [(set_attr "op_type" "RS")
793 (set_attr "atype" "reg")])
794
43a09b63 795; ltr, ltgr
08a5aaa2 796(define_insn "*tst<mode>_cconly2"
ae156f85 797 [(set (reg CC_REGNUM)
08a5aaa2
AS
798 (compare (match_operand:GPR 0 "register_operand" "d")
799 (match_operand:GPR 1 "const0_operand" "")))]
07893d4f 800 "s390_match_ccmode(insn, CCSmode)"
08a5aaa2 801 "lt<g>r\t%0,%0"
9381e3f1
WG
802 [(set_attr "op_type" "RR<E>")
803 (set_attr "z10prop" "z10_fr_E1")])
08a5aaa2 804
c0220ea4 805; tst(hi|qi) instruction pattern(s).
4023fb28 806
f52c81dd 807(define_insn "*tst<mode>CCT"
ae156f85 808 [(set (reg CC_REGNUM)
f52c81dd
AS
809 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
810 (match_operand:HQI 1 "const0_operand" "")))
811 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
3af97654
UW
812 (match_dup 0))]
813 "s390_match_ccmode(insn, CCTmode)"
814 "@
f52c81dd
AS
815 icm\t%2,<icm_lo>,%S0
816 icmy\t%2,<icm_lo>,%S0
817 tml\t%0,<max_uint>"
9381e3f1
WG
818 [(set_attr "op_type" "RS,RSY,RI")
819 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
3af97654
UW
820
821(define_insn "*tsthiCCT_cconly"
ae156f85 822 [(set (reg CC_REGNUM)
d3632d41 823 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
3af97654 824 (match_operand:HI 1 "const0_operand" "")))
d3632d41 825 (clobber (match_scratch:HI 2 "=d,d,X"))]
3af97654
UW
826 "s390_match_ccmode(insn, CCTmode)"
827 "@
fc0ea003
UW
828 icm\t%2,3,%S0
829 icmy\t%2,3,%S0
d40c829f 830 tml\t%0,65535"
9381e3f1
WG
831 [(set_attr "op_type" "RS,RSY,RI")
832 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
3af97654 833
3af97654 834(define_insn "*tstqiCCT_cconly"
ae156f85 835 [(set (reg CC_REGNUM)
d3632d41 836 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
3af97654
UW
837 (match_operand:QI 1 "const0_operand" "")))]
838 "s390_match_ccmode(insn, CCTmode)"
839 "@
fc0ea003
UW
840 cli\t%S0,0
841 cliy\t%S0,0
d40c829f 842 tml\t%0,255"
9381e3f1 843 [(set_attr "op_type" "SI,SIY,RI")
729e750f 844 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
3af97654 845
f52c81dd 846(define_insn "*tst<mode>"
ae156f85 847 [(set (reg CC_REGNUM)
f52c81dd
AS
848 (compare (match_operand:HQI 0 "s_operand" "Q,S")
849 (match_operand:HQI 1 "const0_operand" "")))
850 (set (match_operand:HQI 2 "register_operand" "=d,d")
07893d4f
UW
851 (match_dup 0))]
852 "s390_match_ccmode(insn, CCSmode)"
d3632d41 853 "@
f52c81dd
AS
854 icm\t%2,<icm_lo>,%S0
855 icmy\t%2,<icm_lo>,%S0"
9381e3f1
WG
856 [(set_attr "op_type" "RS,RSY")
857 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521 858
f52c81dd 859(define_insn "*tst<mode>_cconly"
ae156f85 860 [(set (reg CC_REGNUM)
f52c81dd
AS
861 (compare (match_operand:HQI 0 "s_operand" "Q,S")
862 (match_operand:HQI 1 "const0_operand" "")))
863 (clobber (match_scratch:HQI 2 "=d,d"))]
07893d4f 864 "s390_match_ccmode(insn, CCSmode)"
d3632d41 865 "@
f52c81dd
AS
866 icm\t%2,<icm_lo>,%S0
867 icmy\t%2,<icm_lo>,%S0"
9381e3f1
WG
868 [(set_attr "op_type" "RS,RSY")
869 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
d3632d41 870
9db1d521 871
575f7c2b
UW
872; Compare (equality) instructions
873
874(define_insn "*cmpdi_cct"
ae156f85 875 [(set (reg CC_REGNUM)
ec24698e 876 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
fb492564 877 (match_operand:DI 1 "general_operand" "d,K,Os,RT,BQ")))]
9602b6a1 878 "s390_match_ccmode (insn, CCTmode) && TARGET_ZARCH"
575f7c2b
UW
879 "@
880 cgr\t%0,%1
f4f41b4e 881 cghi\t%0,%h1
ec24698e 882 cgfi\t%0,%1
575f7c2b 883 cg\t%0,%1
19b63d8e 884 #"
9381e3f1
WG
885 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
886 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
575f7c2b
UW
887
888(define_insn "*cmpsi_cct"
ae156f85 889 [(set (reg CC_REGNUM)
ec24698e
UW
890 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
891 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
e221ef54 892 "s390_match_ccmode (insn, CCTmode)"
575f7c2b
UW
893 "@
894 cr\t%0,%1
f4f41b4e 895 chi\t%0,%h1
ec24698e 896 cfi\t%0,%1
575f7c2b
UW
897 c\t%0,%1
898 cy\t%0,%1
19b63d8e 899 #"
9381e3f1 900 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
e3cba5e5 901 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*")])
575f7c2b 902
07893d4f 903; Compare (signed) instructions
4023fb28 904
07893d4f 905(define_insn "*cmpdi_ccs_sign"
ae156f85 906 [(set (reg CC_REGNUM)
963fc8d0
AK
907 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
908 "d,RT,b"))
909 (match_operand:DI 0 "register_operand" "d, d,d")))]
9602b6a1 910 "s390_match_ccmode(insn, CCSRmode) && TARGET_ZARCH"
4023fb28 911 "@
d40c829f 912 cgfr\t%0,%1
963fc8d0
AK
913 cgf\t%0,%1
914 cgfrl\t%0,%1"
915 [(set_attr "op_type" "RRE,RXY,RIL")
9381e3f1 916 (set_attr "z10prop" "z10_c,*,*")
963fc8d0 917 (set_attr "type" "*,*,larl")])
4023fb28 918
9381e3f1
WG
919
920
07893d4f 921(define_insn "*cmpsi_ccs_sign"
ae156f85 922 [(set (reg CC_REGNUM)
963fc8d0
AK
923 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
924 (match_operand:SI 0 "register_operand" "d,d,d")))]
07893d4f 925 "s390_match_ccmode(insn, CCSRmode)"
d3632d41 926 "@
d40c829f 927 ch\t%0,%1
963fc8d0
AK
928 chy\t%0,%1
929 chrl\t%0,%1"
930 [(set_attr "op_type" "RX,RXY,RIL")
931 (set_attr "cpu_facility" "*,*,z10")
65b1d8ea
AK
932 (set_attr "type" "*,*,larl")
933 (set_attr "z196prop" "z196_cracked,z196_cracked,z196_cracked")])
963fc8d0
AK
934
935(define_insn "*cmphi_ccs_z10"
936 [(set (reg CC_REGNUM)
937 (compare (match_operand:HI 0 "s_operand" "Q")
938 (match_operand:HI 1 "immediate_operand" "K")))]
939 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
940 "chhsi\t%0,%1"
65b1d8ea
AK
941 [(set_attr "op_type" "SIL")
942 (set_attr "z196prop" "z196_cracked")])
963fc8d0
AK
943
944(define_insn "*cmpdi_ccs_signhi_rl"
945 [(set (reg CC_REGNUM)
946 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT,b"))
947 (match_operand:GPR 0 "register_operand" "d,d")))]
948 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
949 "@
950 cgh\t%0,%1
951 cghrl\t%0,%1"
952 [(set_attr "op_type" "RXY,RIL")
953 (set_attr "type" "*,larl")])
4023fb28 954
963fc8d0 955; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
3298c037 956(define_insn "*cmp<mode>_ccs"
ae156f85 957 [(set (reg CC_REGNUM)
963fc8d0
AK
958 (compare (match_operand:GPR 0 "nonimmediate_operand"
959 "d,d,Q, d,d,d,d")
960 (match_operand:GPR 1 "general_operand"
961 "d,K,K,Os,R,T,b")))]
9db1d521 962 "s390_match_ccmode(insn, CCSmode)"
07893d4f 963 "@
3298c037
AK
964 c<g>r\t%0,%1
965 c<g>hi\t%0,%h1
963fc8d0 966 c<g>hsi\t%0,%h1
3298c037
AK
967 c<g>fi\t%0,%1
968 c<g>\t%0,%1
963fc8d0
AK
969 c<y>\t%0,%1
970 c<g>rl\t%0,%1"
971 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
972 (set_attr "cpu_facility" "*,*,z10,extimm,*,*,z10")
9381e3f1
WG
973 (set_attr "type" "*,*,*,*,*,*,larl")
974 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
c7453384 975
07893d4f
UW
976
977; Compare (unsigned) instructions
9db1d521 978
963fc8d0
AK
979(define_insn "*cmpsi_ccu_zerohi_rlsi"
980 [(set (reg CC_REGNUM)
981 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
982 "larl_operand" "X")))
983 (match_operand:SI 0 "register_operand" "d")))]
984 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
985 "clhrl\t%0,%1"
986 [(set_attr "op_type" "RIL")
729e750f
WG
987 (set_attr "type" "larl")
988 (set_attr "z10prop" "z10_super")])
963fc8d0
AK
989
990; clhrl, clghrl
991(define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
992 [(set (reg CC_REGNUM)
993 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
994 "larl_operand" "X")))
995 (match_operand:GPR 0 "register_operand" "d")))]
996 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
997 "cl<g>hrl\t%0,%1"
998 [(set_attr "op_type" "RIL")
9381e3f1
WG
999 (set_attr "type" "larl")
1000 (set_attr "z10prop" "z10_super")])
963fc8d0 1001
07893d4f 1002(define_insn "*cmpdi_ccu_zero"
ae156f85 1003 [(set (reg CC_REGNUM)
963fc8d0
AK
1004 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
1005 "d,RT,b"))
1006 (match_operand:DI 0 "register_operand" "d, d,d")))]
9602b6a1 1007 "s390_match_ccmode (insn, CCURmode) && TARGET_ZARCH"
07893d4f 1008 "@
d40c829f 1009 clgfr\t%0,%1
963fc8d0
AK
1010 clgf\t%0,%1
1011 clgfrl\t%0,%1"
1012 [(set_attr "op_type" "RRE,RXY,RIL")
1013 (set_attr "cpu_facility" "*,*,z10")
9381e3f1
WG
1014 (set_attr "type" "*,*,larl")
1015 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
9db1d521 1016
07893d4f 1017(define_insn "*cmpdi_ccu"
ae156f85 1018 [(set (reg CC_REGNUM)
963fc8d0
AK
1019 (compare (match_operand:DI 0 "nonimmediate_operand"
1020 "d, d,d,Q, d, Q,BQ")
1021 (match_operand:DI 1 "general_operand"
1022 "d,Op,b,D,RT,BQ,Q")))]
9602b6a1 1023 "s390_match_ccmode (insn, CCUmode) && TARGET_ZARCH"
07893d4f 1024 "@
d40c829f 1025 clgr\t%0,%1
ec24698e 1026 clgfi\t%0,%1
963fc8d0
AK
1027 clgrl\t%0,%1
1028 clghsi\t%0,%x1
575f7c2b 1029 clg\t%0,%1
e221ef54 1030 #
19b63d8e 1031 #"
963fc8d0
AK
1032 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
1033 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
9381e3f1
WG
1034 (set_attr "type" "*,*,larl,*,*,*,*")
1035 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
9db1d521 1036
07893d4f 1037(define_insn "*cmpsi_ccu"
ae156f85 1038 [(set (reg CC_REGNUM)
963fc8d0
AK
1039 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
1040 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
e221ef54 1041 "s390_match_ccmode (insn, CCUmode)"
07893d4f 1042 "@
d40c829f 1043 clr\t%0,%1
ec24698e 1044 clfi\t%0,%o1
963fc8d0
AK
1045 clrl\t%0,%1
1046 clfhsi\t%0,%x1
d40c829f 1047 cl\t%0,%1
575f7c2b 1048 cly\t%0,%1
e221ef54 1049 #
19b63d8e 1050 #"
963fc8d0
AK
1051 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
1052 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*,*")
9381e3f1
WG
1053 (set_attr "type" "*,*,larl,*,*,*,*,*")
1054 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
9db1d521 1055
07893d4f 1056(define_insn "*cmphi_ccu"
ae156f85 1057 [(set (reg CC_REGNUM)
963fc8d0
AK
1058 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
1059 (match_operand:HI 1 "general_operand" "Q,S,D,BQ,Q")))]
575f7c2b 1060 "s390_match_ccmode (insn, CCUmode)
575f7c2b 1061 && !register_operand (operands[1], HImode)"
d3632d41 1062 "@
fc0ea003
UW
1063 clm\t%0,3,%S1
1064 clmy\t%0,3,%S1
963fc8d0 1065 clhhsi\t%0,%1
e221ef54 1066 #
19b63d8e 1067 #"
963fc8d0 1068 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
9381e3f1
WG
1069 (set_attr "cpu_facility" "*,*,z10,*,*")
1070 (set_attr "z10prop" "*,*,z10_super,*,*")])
9db1d521
HP
1071
1072(define_insn "*cmpqi_ccu"
ae156f85 1073 [(set (reg CC_REGNUM)
e221ef54
UW
1074 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
1075 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
575f7c2b 1076 "s390_match_ccmode (insn, CCUmode)
575f7c2b 1077 && !register_operand (operands[1], QImode)"
d3632d41 1078 "@
fc0ea003
UW
1079 clm\t%0,1,%S1
1080 clmy\t%0,1,%S1
1081 cli\t%S0,%b1
1082 cliy\t%S0,%b1
e221ef54 1083 #
19b63d8e 1084 #"
9381e3f1
WG
1085 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
1086 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
9db1d521
HP
1087
1088
19b63d8e
UW
1089; Block compare (CLC) instruction patterns.
1090
1091(define_insn "*clc"
ae156f85 1092 [(set (reg CC_REGNUM)
d4f52f0e 1093 (compare (match_operand:BLK 0 "memory_operand" "Q")
19b63d8e
UW
1094 (match_operand:BLK 1 "memory_operand" "Q")))
1095 (use (match_operand 2 "const_int_operand" "n"))]
1096 "s390_match_ccmode (insn, CCUmode)
1097 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 1098 "clc\t%O0(%2,%R0),%S1"
b628bd8e 1099 [(set_attr "op_type" "SS")])
19b63d8e
UW
1100
1101(define_split
ae156f85 1102 [(set (reg CC_REGNUM)
19b63d8e
UW
1103 (compare (match_operand 0 "memory_operand" "")
1104 (match_operand 1 "memory_operand" "")))]
1105 "reload_completed
1106 && s390_match_ccmode (insn, CCUmode)
1107 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1108 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1109 [(parallel
1110 [(set (match_dup 0) (match_dup 1))
1111 (use (match_dup 2))])]
1112{
1113 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1114 operands[0] = adjust_address (operands[0], BLKmode, 0);
1115 operands[1] = adjust_address (operands[1], BLKmode, 0);
1116
1117 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
1118 operands[0], operands[1]);
1119 operands[0] = SET_DEST (PATTERN (curr_insn));
1120})
1121
1122
609e7e80 1123; (TF|DF|SF|TD|DD|SD) instructions
9db1d521 1124
609e7e80 1125; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
f5905b37 1126(define_insn "*cmp<mode>_ccs_0"
ae156f85 1127 [(set (reg CC_REGNUM)
609e7e80
AK
1128 (compare (match_operand:FP 0 "register_operand" "f")
1129 (match_operand:FP 1 "const0_operand" "")))]
142cd70f 1130 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
609e7e80 1131 "lt<xde><bt>r\t%0,%0"
077dab3b 1132 [(set_attr "op_type" "RRE")
9381e3f1 1133 (set_attr "type" "fsimp<mode>")])
9db1d521 1134
be5de7a1 1135; cxtr, cxbr, cdtr, cdbr, cebr, cdb, ceb
f5905b37 1136(define_insn "*cmp<mode>_ccs"
ae156f85 1137 [(set (reg CC_REGNUM)
609e7e80
AK
1138 (compare (match_operand:FP 0 "register_operand" "f,f")
1139 (match_operand:FP 1 "general_operand" "f,<Rf>")))]
142cd70f 1140 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
9db1d521 1141 "@
609e7e80 1142 c<xde><bt>r\t%0,%1
f61a2c7d 1143 c<xde>b\t%0,%1"
077dab3b 1144 [(set_attr "op_type" "RRE,RXE")
9381e3f1 1145 (set_attr "type" "fsimp<mode>")])
9db1d521 1146
963fc8d0
AK
1147
1148; Compare and Branch instructions
1149
1150; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
9381e3f1
WG
1151; The following instructions do a complementary access of their second
1152; operand (z01 only): crj_c, cgrjc, cr, cgr
963fc8d0
AK
1153(define_insn "*cmp_and_br_signed_<mode>"
1154 [(set (pc)
1155 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1156 [(match_operand:GPR 1 "register_operand" "d,d")
1157 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1158 (label_ref (match_operand 3 "" ""))
1159 (pc)))
1160 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1161 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
963fc8d0
AK
1162{
1163 if (get_attr_length (insn) == 6)
1164 return which_alternative ?
1165 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1166 else
1167 return which_alternative ?
1168 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1169}
1170 [(set_attr "op_type" "RIE")
1171 (set_attr "type" "branch")
e3cba5e5 1172 (set_attr "z10prop" "z10_super_c,z10_super")
963fc8d0
AK
1173 (set (attr "length")
1174 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1175 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1176 ; 10 byte for cgr/jg
1177
1178; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
9381e3f1
WG
1179; The following instructions do a complementary access of their second
1180; operand (z10 only): clrj, clgrj, clr, clgr
963fc8d0
AK
1181(define_insn "*cmp_and_br_unsigned_<mode>"
1182 [(set (pc)
1183 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1184 [(match_operand:GPR 1 "register_operand" "d,d")
1185 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1186 (label_ref (match_operand 3 "" ""))
1187 (pc)))
1188 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1189 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
963fc8d0
AK
1190{
1191 if (get_attr_length (insn) == 6)
1192 return which_alternative ?
1193 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1194 else
1195 return which_alternative ?
1196 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1197}
1198 [(set_attr "op_type" "RIE")
1199 (set_attr "type" "branch")
e3cba5e5 1200 (set_attr "z10prop" "z10_super_c,z10_super")
963fc8d0
AK
1201 (set (attr "length")
1202 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1203 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1204 ; 10 byte for clgr/jg
1205
b0f86a7e
AK
1206; And now the same two patterns as above but with a negated CC mask.
1207
1208; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1209; The following instructions do a complementary access of their second
1210; operand (z01 only): crj_c, cgrjc, cr, cgr
1211(define_insn "*icmp_and_br_signed_<mode>"
1212 [(set (pc)
1213 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1214 [(match_operand:GPR 1 "register_operand" "d,d")
1215 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1216 (pc)
1217 (label_ref (match_operand 3 "" ""))))
1218 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1219 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
b0f86a7e
AK
1220{
1221 if (get_attr_length (insn) == 6)
1222 return which_alternative ?
1223 "c<g>ij%D0\t%1,%c2,%l3" : "c<g>rj%D0\t%1,%2,%l3";
1224 else
1225 return which_alternative ?
1226 "c<g>fi\t%1,%c2\;jg%D0\t%l3" : "c<g>r\t%1,%2\;jg%D0\t%l3";
1227}
1228 [(set_attr "op_type" "RIE")
1229 (set_attr "type" "branch")
1230 (set_attr "z10prop" "z10_super_c,z10_super")
1231 (set (attr "length")
1232 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1233 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1234 ; 10 byte for cgr/jg
1235
1236; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1237; The following instructions do a complementary access of their second
1238; operand (z10 only): clrj, clgrj, clr, clgr
1239(define_insn "*icmp_and_br_unsigned_<mode>"
1240 [(set (pc)
1241 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1242 [(match_operand:GPR 1 "register_operand" "d,d")
1243 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1244 (pc)
1245 (label_ref (match_operand 3 "" ""))))
1246 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 1247 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
b0f86a7e
AK
1248{
1249 if (get_attr_length (insn) == 6)
1250 return which_alternative ?
1251 "cl<g>ij%D0\t%1,%b2,%l3" : "cl<g>rj%D0\t%1,%2,%l3";
1252 else
1253 return which_alternative ?
1254 "cl<g>fi\t%1,%b2\;jg%D0\t%l3" : "cl<g>r\t%1,%2\;jg%D0\t%l3";
1255}
1256 [(set_attr "op_type" "RIE")
1257 (set_attr "type" "branch")
1258 (set_attr "z10prop" "z10_super_c,z10_super")
1259 (set (attr "length")
1260 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1261 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1262 ; 10 byte for clgr/jg
1263
9db1d521
HP
1264;;
1265;;- Move instructions.
1266;;
1267
1268;
1269; movti instruction pattern(s).
1270;
1271
085261c8
AK
1272; FIXME: More constants are possible by enabling jxx, jyy constraints
1273; for TImode (use double-int for the calculations)
9db1d521 1274(define_insn "movti"
085261c8
AK
1275 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,v, v, v,v,d, v,QR, d,o")
1276 (match_operand:TI 1 "general_operand" "QS, d,v,j00,jm1,d,v,QR, v,dPRT,d"))]
9602b6a1 1277 "TARGET_ZARCH"
4023fb28 1278 "@
fc0ea003
UW
1279 lmg\t%0,%N0,%S1
1280 stmg\t%1,%N1,%S0
085261c8
AK
1281 vlr\t%v0,%v1
1282 vzero\t%v0
1283 vone\t%v0
1284 vlvgp\t%v0,%1,%N1
1285 #
1286 vl\t%v0,%1
1287 vst\t%v1,%0
4023fb28 1288 #
19b63d8e 1289 #"
085261c8
AK
1290 [(set_attr "op_type" "RSY,RSY,VRR,VRI,VRI,VRR,*,VRX,VRX,*,*")
1291 (set_attr "type" "lm,stm,*,*,*,*,*,*,*,*,*")
1292 (set_attr "cpu_facility" "*,*,vec,vec,vec,vec,vec,vec,vec,*,*")])
4023fb28
UW
1293
1294(define_split
1295 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1296 (match_operand:TI 1 "general_operand" ""))]
9602b6a1 1297 "TARGET_ZARCH && reload_completed
dc65c307 1298 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
4023fb28
UW
1299 [(set (match_dup 2) (match_dup 4))
1300 (set (match_dup 3) (match_dup 5))]
9db1d521 1301{
dc65c307
UW
1302 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1303 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1304 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1305 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1306})
1307
1308(define_split
1309 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1310 (match_operand:TI 1 "general_operand" ""))]
9602b6a1 1311 "TARGET_ZARCH && reload_completed
dc65c307
UW
1312 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1313 [(set (match_dup 2) (match_dup 4))
1314 (set (match_dup 3) (match_dup 5))]
1315{
1316 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1317 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1318 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1319 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1320})
4023fb28 1321
085261c8
AK
1322; Use part of the TImode target reg to perform the address
1323; calculation. If the TImode value is supposed to be copied into a VR
1324; this splitter is not necessary.
4023fb28
UW
1325(define_split
1326 [(set (match_operand:TI 0 "register_operand" "")
1327 (match_operand:TI 1 "memory_operand" ""))]
9602b6a1 1328 "TARGET_ZARCH && reload_completed
085261c8 1329 && !VECTOR_REG_P (operands[0])
4023fb28 1330 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1331 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1332{
1333 rtx addr = operand_subword (operands[0], 1, 0, TImode);
9602b6a1 1334 addr = gen_lowpart (Pmode, addr);
a41c6c53
UW
1335 s390_load_address (addr, XEXP (operands[1], 0));
1336 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1337})
1338
833cd70a 1339
085261c8
AK
1340; Split a VR -> GPR TImode move into 2 vector load GR from VR element.
1341; For the higher order bits we do simply a DImode move while the
1342; second part is done via vec extract. Both will end up as vlgvg.
1343(define_split
1344 [(set (match_operand:TI 0 "register_operand" "")
1345 (match_operand:TI 1 "register_operand" ""))]
1346 "TARGET_VX && reload_completed
1347 && GENERAL_REG_P (operands[0])
1348 && VECTOR_REG_P (operands[1])"
1349 [(set (match_dup 2) (match_dup 4))
1350 (set (match_dup 3) (unspec:DI [(match_dup 5) (const_int 1)]
1351 UNSPEC_VEC_EXTRACT))]
1352{
1353 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1354 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1355 operands[4] = gen_rtx_REG (DImode, REGNO (operands[1]));
1356 operands[5] = gen_rtx_REG (V2DImode, REGNO (operands[1]));
1357})
1358
833cd70a
AK
1359;
1360; Patterns used for secondary reloads
1361;
1362
963fc8d0
AK
1363; z10 provides move instructions accepting larl memory operands.
1364; Unfortunately there is no such variant for QI, TI and FP mode moves.
1365; These patterns are also used for unaligned SI and DI accesses.
1366
085261c8
AK
1367(define_expand "reload<ALL:mode><P:mode>_tomem_z10"
1368 [(parallel [(match_operand:ALL 0 "memory_operand" "")
1369 (match_operand:ALL 1 "register_operand" "=d")
1370 (match_operand:P 2 "register_operand" "=&a")])]
963fc8d0
AK
1371 "TARGET_Z10"
1372{
1373 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1374 DONE;
1375})
1376
085261c8
AK
1377(define_expand "reload<ALL:mode><P:mode>_toreg_z10"
1378 [(parallel [(match_operand:ALL 0 "register_operand" "=d")
1379 (match_operand:ALL 1 "memory_operand" "")
1380 (match_operand:P 2 "register_operand" "=a")])]
963fc8d0
AK
1381 "TARGET_Z10"
1382{
1383 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1384 DONE;
1385})
1386
1387(define_expand "reload<P:mode>_larl_odd_addend_z10"
1388 [(parallel [(match_operand:P 0 "register_operand" "=d")
1389 (match_operand:P 1 "larl_operand" "")
1390 (match_operand:P 2 "register_operand" "=a")])]
1391 "TARGET_Z10"
1392{
1393 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1394 DONE;
1395})
1396
833cd70a
AK
1397; Handles loading a PLUS (load address) expression
1398
1399(define_expand "reload<mode>_plus"
1400 [(parallel [(match_operand:P 0 "register_operand" "=a")
1401 (match_operand:P 1 "s390_plus_operand" "")
1402 (match_operand:P 2 "register_operand" "=&a")])]
1403 ""
1404{
1405 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1406 DONE;
1407})
1408
085261c8
AK
1409; Not all the indirect memory access instructions support the full
1410; format (long disp + index + base). So whenever a move from/to such
1411; an address is required and the instruction cannot deal with it we do
1412; a load address into a scratch register first and use this as the new
1413; base register.
1414; This in particular is used for:
1415; - non-offsetable memory accesses for multiword moves
1416; - full vector reg moves with long displacements
833cd70a 1417
085261c8 1418(define_expand "reload<mode>_la_in"
833cd70a
AK
1419 [(parallel [(match_operand 0 "register_operand" "")
1420 (match_operand 1 "" "")
1421 (match_operand:P 2 "register_operand" "=&a")])]
1422 ""
1423{
1424 gcc_assert (MEM_P (operands[1]));
1425 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1426 operands[1] = replace_equiv_address (operands[1], operands[2]);
1427 emit_move_insn (operands[0], operands[1]);
1428 DONE;
1429})
1430
085261c8 1431(define_expand "reload<mode>_la_out"
833cd70a
AK
1432 [(parallel [(match_operand 0 "" "")
1433 (match_operand 1 "register_operand" "")
1434 (match_operand:P 2 "register_operand" "=&a")])]
1435 ""
dc65c307 1436{
9c3c3dcc 1437 gcc_assert (MEM_P (operands[0]));
9c90a97e 1438 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
dc65c307
UW
1439 operands[0] = replace_equiv_address (operands[0], operands[2]);
1440 emit_move_insn (operands[0], operands[1]);
1441 DONE;
1442})
9db1d521 1443
1f9e1fc6
AK
1444(define_expand "reload<mode>_PIC_addr"
1445 [(parallel [(match_operand 0 "register_operand" "=d")
1446 (match_operand 1 "larl_operand" "")
1447 (match_operand:P 2 "register_operand" "=a")])]
1448 ""
1449{
0a2aaacc
KG
1450 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1451 emit_move_insn (operands[0], new_rtx);
1f9e1fc6
AK
1452})
1453
9db1d521
HP
1454;
1455; movdi instruction pattern(s).
1456;
1457
9db1d521
HP
1458(define_expand "movdi"
1459 [(set (match_operand:DI 0 "general_operand" "")
1460 (match_operand:DI 1 "general_operand" ""))]
1461 ""
9db1d521 1462{
fd3cd001 1463 /* Handle symbolic constants. */
e4f2cd43
AK
1464 if (TARGET_64BIT
1465 && (SYMBOLIC_CONST (operands[1])
1466 || (GET_CODE (operands[1]) == PLUS
1467 && XEXP (operands[1], 0) == pic_offset_table_rtx
1468 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
fd3cd001 1469 emit_symbolic_move (operands);
10bbf137 1470})
9db1d521 1471
4023fb28
UW
1472(define_insn "*movdi_larl"
1473 [(set (match_operand:DI 0 "register_operand" "=d")
1474 (match_operand:DI 1 "larl_operand" "X"))]
1475 "TARGET_64BIT
8e509cf9 1476 && !FP_REG_P (operands[0])"
d40c829f 1477 "larl\t%0,%1"
4023fb28 1478 [(set_attr "op_type" "RIL")
9381e3f1
WG
1479 (set_attr "type" "larl")
1480 (set_attr "z10prop" "z10_super_A1")])
4023fb28 1481
3af8e996 1482(define_insn "*movdi_64"
85dae55a 1483 [(set (match_operand:DI 0 "nonimmediate_operand"
085261c8 1484 "=d, d, d, d, d, d, d, d,f,d,d,d,d, d,RT,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t,v,v,v,d, v,QR")
85dae55a 1485 (match_operand:DI 1 "general_operand"
085261c8 1486 " K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,RT, d, *f, R, T,*f,*f,d,K,t,d,t,Q,K,v,d,v,QR, v"))]
9602b6a1 1487 "TARGET_ZARCH"
85dae55a
AK
1488 "@
1489 lghi\t%0,%h1
1490 llihh\t%0,%i1
1491 llihl\t%0,%i1
1492 llilh\t%0,%i1
1493 llill\t%0,%i1
1494 lgfi\t%0,%1
1495 llihf\t%0,%k1
1496 llilf\t%0,%k1
1497 ldgr\t%0,%1
1498 lgdr\t%0,%1
1499 lay\t%0,%a1
963fc8d0 1500 lgrl\t%0,%1
85dae55a
AK
1501 lgr\t%0,%1
1502 lg\t%0,%1
1503 stg\t%1,%0
1504 ldr\t%0,%1
1505 ld\t%0,%1
1506 ldy\t%0,%1
1507 std\t%1,%0
1508 stdy\t%1,%0
963fc8d0
AK
1509 stgrl\t%1,%0
1510 mvghi\t%0,%1
85dae55a
AK
1511 #
1512 #
1513 stam\t%1,%N1,%S0
085261c8
AK
1514 lam\t%0,%N0,%S1
1515 vleig\t%v0,%h1,0
1516 vlr\t%v0,%v1
1517 vlvgg\t%v0,%1,0
1518 vlgvg\t%0,%v1,0
1519 vleg\t%v0,%1,0
1520 vsteg\t%v1,%0,0"
963fc8d0 1521 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
085261c8 1522 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS,VRX,VRX")
963fc8d0 1523 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
085261c8
AK
1524 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,*,
1525 *,*,*,*,*,*,*")
3af8e996 1526 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
963fc8d0 1527 z10,*,*,*,*,*,longdisp,*,longdisp,
085261c8 1528 z10,z10,*,*,*,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
1529 (set_attr "z10prop" "z10_fwd_A1,
1530 z10_fwd_E1,
1531 z10_fwd_E1,
1532 z10_fwd_E1,
1533 z10_fwd_E1,
1534 z10_fwd_A1,
1535 z10_fwd_E1,
1536 z10_fwd_E1,
1537 *,
1538 *,
1539 z10_fwd_A1,
1540 z10_fwd_A3,
1541 z10_fr_E1,
1542 z10_fwd_A3,
1543 z10_rec,
1544 *,
1545 *,
1546 *,
1547 *,
1548 *,
1549 z10_rec,
1550 z10_super,
1551 *,
1552 *,
1553 *,
085261c8 1554 *,*,*,*,*,*,*")
9381e3f1 1555])
c5aa1d12
UW
1556
1557(define_split
1558 [(set (match_operand:DI 0 "register_operand" "")
1559 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1560 "TARGET_ZARCH && ACCESS_REG_P (operands[1])"
c5aa1d12
UW
1561 [(set (match_dup 2) (match_dup 3))
1562 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1563 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1564 "operands[2] = gen_lowpart (SImode, operands[0]);
1565 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1566
1567(define_split
1568 [(set (match_operand:DI 0 "register_operand" "")
1569 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1570 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
c5aa1d12
UW
1571 && dead_or_set_p (insn, operands[1])"
1572 [(set (match_dup 3) (match_dup 2))
1573 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1574 (set (match_dup 4) (match_dup 2))]
1575 "operands[2] = gen_lowpart (SImode, operands[1]);
1576 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1577
1578(define_split
1579 [(set (match_operand:DI 0 "register_operand" "")
1580 (match_operand:DI 1 "register_operand" ""))]
9602b6a1 1581 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
c5aa1d12
UW
1582 && !dead_or_set_p (insn, operands[1])"
1583 [(set (match_dup 3) (match_dup 2))
1584 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1585 (set (match_dup 4) (match_dup 2))
1586 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1587 "operands[2] = gen_lowpart (SImode, operands[1]);
1588 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
9db1d521
HP
1589
1590(define_insn "*movdi_31"
963fc8d0 1591 [(set (match_operand:DI 0 "nonimmediate_operand"
f2dc2f86 1592 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!R,!T,d")
963fc8d0 1593 (match_operand:DI 1 "general_operand"
f2dc2f86 1594 " Q,S,d,d,dPRT,d, *f, R, T,*f,*f,b"))]
9602b6a1 1595 "!TARGET_ZARCH"
4023fb28 1596 "@
fc0ea003 1597 lm\t%0,%N0,%S1
c4d50129 1598 lmy\t%0,%N0,%S1
fc0ea003 1599 stm\t%1,%N1,%S0
c4d50129 1600 stmy\t%1,%N1,%S0
4023fb28
UW
1601 #
1602 #
d40c829f
UW
1603 ldr\t%0,%1
1604 ld\t%0,%1
1605 ldy\t%0,%1
1606 std\t%1,%0
1607 stdy\t%1,%0
19b63d8e 1608 #"
f2dc2f86
AK
1609 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1610 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
1611 (set_attr "cpu_facility" "*,*,*,*,*,*,*,*,*,*,*,z10")])
963fc8d0
AK
1612
1613; For a load from a symbol ref we can use one of the target registers
1614; together with larl to load the address.
1615(define_split
1616 [(set (match_operand:DI 0 "register_operand" "")
1617 (match_operand:DI 1 "memory_operand" ""))]
9602b6a1 1618 "!TARGET_ZARCH && reload_completed && TARGET_Z10
963fc8d0
AK
1619 && larl_operand (XEXP (operands[1], 0), SImode)"
1620 [(set (match_dup 2) (match_dup 3))
1621 (set (match_dup 0) (match_dup 1))]
1622{
1623 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1624 operands[3] = XEXP (operands[1], 0);
1625 operands[1] = replace_equiv_address (operands[1], operands[2]);
1626})
4023fb28
UW
1627
1628(define_split
1629 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1630 (match_operand:DI 1 "general_operand" ""))]
9602b6a1 1631 "!TARGET_ZARCH && reload_completed
dc65c307 1632 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
4023fb28
UW
1633 [(set (match_dup 2) (match_dup 4))
1634 (set (match_dup 3) (match_dup 5))]
9db1d521 1635{
dc65c307
UW
1636 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1637 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1638 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1639 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1640})
1641
1642(define_split
1643 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1644 (match_operand:DI 1 "general_operand" ""))]
9602b6a1 1645 "!TARGET_ZARCH && reload_completed
dc65c307
UW
1646 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1647 [(set (match_dup 2) (match_dup 4))
1648 (set (match_dup 3) (match_dup 5))]
1649{
1650 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1651 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1652 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1653 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1654})
9db1d521 1655
4023fb28
UW
1656(define_split
1657 [(set (match_operand:DI 0 "register_operand" "")
1658 (match_operand:DI 1 "memory_operand" ""))]
9602b6a1 1659 "!TARGET_ZARCH && reload_completed
8e509cf9 1660 && !FP_REG_P (operands[0])
4023fb28 1661 && !s_operand (operands[1], VOIDmode)"
a41c6c53 1662 [(set (match_dup 0) (match_dup 1))]
a41c6c53
UW
1663{
1664 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1665 s390_load_address (addr, XEXP (operands[1], 0));
1666 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
1667})
1668
84817c5d
UW
1669(define_peephole2
1670 [(set (match_operand:DI 0 "register_operand" "")
1671 (mem:DI (match_operand 1 "address_operand" "")))]
9602b6a1 1672 "TARGET_ZARCH
84817c5d
UW
1673 && !FP_REG_P (operands[0])
1674 && GET_CODE (operands[1]) == SYMBOL_REF
1675 && CONSTANT_POOL_ADDRESS_P (operands[1])
1676 && get_pool_mode (operands[1]) == DImode
1677 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1678 [(set (match_dup 0) (match_dup 2))]
1679 "operands[2] = get_pool_constant (operands[1]);")
1680
7bdff56f
UW
1681(define_insn "*la_64"
1682 [(set (match_operand:DI 0 "register_operand" "=d,d")
4fe6dea8 1683 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))]
7bdff56f
UW
1684 "TARGET_64BIT"
1685 "@
1686 la\t%0,%a1
1687 lay\t%0,%a1"
1688 [(set_attr "op_type" "RX,RXY")
9381e3f1
WG
1689 (set_attr "type" "la")
1690 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
1691
1692(define_peephole2
1693 [(parallel
1694 [(set (match_operand:DI 0 "register_operand" "")
1695 (match_operand:QI 1 "address_operand" ""))
ae156f85 1696 (clobber (reg:CC CC_REGNUM))])]
7bdff56f 1697 "TARGET_64BIT
e1d5ee28 1698 && preferred_la_operand_p (operands[1], const0_rtx)"
7bdff56f
UW
1699 [(set (match_dup 0) (match_dup 1))]
1700 "")
1701
1702(define_peephole2
1703 [(set (match_operand:DI 0 "register_operand" "")
1704 (match_operand:DI 1 "register_operand" ""))
1705 (parallel
1706 [(set (match_dup 0)
1707 (plus:DI (match_dup 0)
1708 (match_operand:DI 2 "nonmemory_operand" "")))
ae156f85 1709 (clobber (reg:CC CC_REGNUM))])]
7bdff56f
UW
1710 "TARGET_64BIT
1711 && !reg_overlap_mentioned_p (operands[0], operands[2])
e1d5ee28 1712 && preferred_la_operand_p (operands[1], operands[2])"
7bdff56f
UW
1713 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1714 "")
1715
9db1d521
HP
1716;
1717; movsi instruction pattern(s).
1718;
1719
9db1d521
HP
1720(define_expand "movsi"
1721 [(set (match_operand:SI 0 "general_operand" "")
1722 (match_operand:SI 1 "general_operand" ""))]
1723 ""
9db1d521 1724{
fd3cd001 1725 /* Handle symbolic constants. */
e4f2cd43
AK
1726 if (!TARGET_64BIT
1727 && (SYMBOLIC_CONST (operands[1])
1728 || (GET_CODE (operands[1]) == PLUS
1729 && XEXP (operands[1], 0) == pic_offset_table_rtx
1730 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
fd3cd001 1731 emit_symbolic_move (operands);
10bbf137 1732})
9db1d521 1733
9e8327e3
UW
1734(define_insn "*movsi_larl"
1735 [(set (match_operand:SI 0 "register_operand" "=d")
1736 (match_operand:SI 1 "larl_operand" "X"))]
1737 "!TARGET_64BIT && TARGET_CPU_ZARCH
1738 && !FP_REG_P (operands[0])"
1739 "larl\t%0,%1"
1740 [(set_attr "op_type" "RIL")
9381e3f1 1741 (set_attr "type" "larl")
729e750f 1742 (set_attr "z10prop" "z10_fwd_A1")])
9e8327e3 1743
f19a9af7 1744(define_insn "*movsi_zarch"
2f7e5a0d 1745 [(set (match_operand:SI 0 "nonimmediate_operand"
085261c8 1746 "=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,QR")
2f7e5a0d 1747 (match_operand:SI 1 "general_operand"
085261c8 1748 " 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,QR, v"))]
f19a9af7 1749 "TARGET_ZARCH"
9db1d521 1750 "@
f19a9af7
AK
1751 lhi\t%0,%h1
1752 llilh\t%0,%i1
1753 llill\t%0,%i1
ec24698e 1754 iilf\t%0,%o1
f19a9af7 1755 lay\t%0,%a1
963fc8d0 1756 lrl\t%0,%1
d40c829f
UW
1757 lr\t%0,%1
1758 l\t%0,%1
1759 ly\t%0,%1
1760 st\t%1,%0
1761 sty\t%1,%0
085261c8 1762 lder\t%0,%1
d40c829f 1763 ler\t%0,%1
085261c8 1764 lde\t%0,%1
d40c829f
UW
1765 le\t%0,%1
1766 ley\t%0,%1
1767 ste\t%1,%0
1768 stey\t%1,%0
c5aa1d12
UW
1769 ear\t%0,%1
1770 sar\t%0,%1
1771 stam\t%1,%1,%S0
963fc8d0
AK
1772 strl\t%1,%0
1773 mvhi\t%0,%1
085261c8
AK
1774 lam\t%0,%0,%S1
1775 vleif\t%v0,%h1,0
1776 vlr\t%v0,%v1
1777 vlvgf\t%v0,%1,0
1778 vlgvf\t%0,%v1,0
1779 vlef\t%v0,%1,0
1780 vstef\t%v1,%0,0"
963fc8d0 1781 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
085261c8 1782 RRE,RR,RXE,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS,VRI,VRR,VRS,VRS,VRX,VRX")
9381e3f1
WG
1783 (set_attr "type" "*,
1784 *,
1785 *,
1786 *,
1787 la,
1788 larl,
1789 lr,
1790 load,
1791 load,
1792 store,
1793 store,
1794 floadsf,
1795 floadsf,
1796 floadsf,
085261c8
AK
1797 floadsf,
1798 floadsf,
9381e3f1
WG
1799 fstoresf,
1800 fstoresf,
1801 *,
1802 *,
1803 *,
1804 larl,
1805 *,
085261c8 1806 *,*,*,*,*,*,*")
963fc8d0 1807 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
085261c8 1808 vec,*,vec,*,longdisp,*,longdisp,*,*,*,z10,z10,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
1809 (set_attr "z10prop" "z10_fwd_A1,
1810 z10_fwd_E1,
1811 z10_fwd_E1,
1812 z10_fwd_A1,
1813 z10_fwd_A1,
1814 z10_fwd_A3,
1815 z10_fr_E1,
1816 z10_fwd_A3,
1817 z10_fwd_A3,
729e750f 1818 z10_rec,
9381e3f1
WG
1819 z10_rec,
1820 *,
1821 *,
1822 *,
1823 *,
1824 *,
085261c8
AK
1825 *,
1826 *,
9381e3f1
WG
1827 z10_super_E1,
1828 z10_super,
1829 *,
1830 z10_rec,
1831 z10_super,
085261c8 1832 *,*,*,*,*,*,*")])
f19a9af7
AK
1833
1834(define_insn "*movsi_esa"
085261c8
AK
1835 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!*f,!*f,!R,d,t,Q,t")
1836 (match_operand:SI 1 "general_operand" "K,d,R,d, *f, *f, R, R,*f,t,d,t,Q"))]
f19a9af7
AK
1837 "!TARGET_ZARCH"
1838 "@
1839 lhi\t%0,%h1
1840 lr\t%0,%1
1841 l\t%0,%1
1842 st\t%1,%0
085261c8 1843 lder\t%0,%1
f19a9af7 1844 ler\t%0,%1
085261c8 1845 lde\t%0,%1
f19a9af7
AK
1846 le\t%0,%1
1847 ste\t%1,%0
c5aa1d12
UW
1848 ear\t%0,%1
1849 sar\t%0,%1
1850 stam\t%1,%1,%S0
f2dc2f86 1851 lam\t%0,%0,%S1"
085261c8
AK
1852 [(set_attr "op_type" "RI,RR,RX,RX,RRE,RR,RXE,RX,RX,RRE,RRE,RS,RS")
1853 (set_attr "type" "*,lr,load,store,floadsf,floadsf,floadsf,floadsf,fstoresf,*,*,*,*")
1854 (set_attr "z10prop" "z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec,*,*,*,*,*,z10_super_E1,
1855 z10_super,*,*")
1856 (set_attr "cpu_facility" "*,*,*,*,vec,*,vec,*,*,*,*,*,*")
9381e3f1 1857])
9db1d521 1858
84817c5d
UW
1859(define_peephole2
1860 [(set (match_operand:SI 0 "register_operand" "")
1861 (mem:SI (match_operand 1 "address_operand" "")))]
1862 "!FP_REG_P (operands[0])
1863 && GET_CODE (operands[1]) == SYMBOL_REF
1864 && CONSTANT_POOL_ADDRESS_P (operands[1])
1865 && get_pool_mode (operands[1]) == SImode
1866 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1867 [(set (match_dup 0) (match_dup 2))]
1868 "operands[2] = get_pool_constant (operands[1]);")
9db1d521 1869
7bdff56f
UW
1870(define_insn "*la_31"
1871 [(set (match_operand:SI 0 "register_operand" "=d,d")
4fe6dea8 1872 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))]
7bdff56f
UW
1873 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1874 "@
1875 la\t%0,%a1
1876 lay\t%0,%a1"
1877 [(set_attr "op_type" "RX,RXY")
9381e3f1
WG
1878 (set_attr "type" "la")
1879 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
1880
1881(define_peephole2
1882 [(parallel
1883 [(set (match_operand:SI 0 "register_operand" "")
1884 (match_operand:QI 1 "address_operand" ""))
ae156f85 1885 (clobber (reg:CC CC_REGNUM))])]
7bdff56f 1886 "!TARGET_64BIT
e1d5ee28 1887 && preferred_la_operand_p (operands[1], const0_rtx)"
7bdff56f
UW
1888 [(set (match_dup 0) (match_dup 1))]
1889 "")
1890
1891(define_peephole2
1892 [(set (match_operand:SI 0 "register_operand" "")
1893 (match_operand:SI 1 "register_operand" ""))
1894 (parallel
1895 [(set (match_dup 0)
1896 (plus:SI (match_dup 0)
1897 (match_operand:SI 2 "nonmemory_operand" "")))
ae156f85 1898 (clobber (reg:CC CC_REGNUM))])]
7bdff56f
UW
1899 "!TARGET_64BIT
1900 && !reg_overlap_mentioned_p (operands[0], operands[2])
e1d5ee28 1901 && preferred_la_operand_p (operands[1], operands[2])"
7bdff56f
UW
1902 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1903 "")
1904
1905(define_insn "*la_31_and"
1906 [(set (match_operand:SI 0 "register_operand" "=d,d")
4fe6dea8 1907 (and:SI (match_operand:QI 1 "address_operand" "ZQZR,ZSZT")
7bdff56f
UW
1908 (const_int 2147483647)))]
1909 "!TARGET_64BIT"
1910 "@
1911 la\t%0,%a1
1912 lay\t%0,%a1"
1913 [(set_attr "op_type" "RX,RXY")
9381e3f1
WG
1914 (set_attr "type" "la")
1915 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f
UW
1916
1917(define_insn_and_split "*la_31_and_cc"
1918 [(set (match_operand:SI 0 "register_operand" "=d")
1919 (and:SI (match_operand:QI 1 "address_operand" "p")
1920 (const_int 2147483647)))
ae156f85 1921 (clobber (reg:CC CC_REGNUM))]
7bdff56f
UW
1922 "!TARGET_64BIT"
1923 "#"
1924 "&& reload_completed"
1925 [(set (match_dup 0)
1926 (and:SI (match_dup 1) (const_int 2147483647)))]
1927 ""
1928 [(set_attr "op_type" "RX")
1929 (set_attr "type" "la")])
1930
1931(define_insn "force_la_31"
1932 [(set (match_operand:SI 0 "register_operand" "=d,d")
4fe6dea8 1933 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))
7bdff56f
UW
1934 (use (const_int 0))]
1935 "!TARGET_64BIT"
1936 "@
1937 la\t%0,%a1
1938 lay\t%0,%a1"
1939 [(set_attr "op_type" "RX")
9381e3f1
WG
1940 (set_attr "type" "la")
1941 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
7bdff56f 1942
9db1d521
HP
1943;
1944; movhi instruction pattern(s).
1945;
1946
02ed3c5e
UW
1947(define_expand "movhi"
1948 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1949 (match_operand:HI 1 "general_operand" ""))]
1950 ""
1951{
2f7e5a0d 1952 /* Make it explicit that loading a register from memory
02ed3c5e 1953 always sign-extends (at least) to SImode. */
b3a13419 1954 if (optimize && can_create_pseudo_p ()
02ed3c5e 1955 && register_operand (operands[0], VOIDmode)
8fff4fc1 1956 && GET_CODE (operands[1]) == MEM)
02ed3c5e
UW
1957 {
1958 rtx tmp = gen_reg_rtx (SImode);
1959 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
f7df4a84 1960 emit_insn (gen_rtx_SET (tmp, ext));
02ed3c5e
UW
1961 operands[1] = gen_lowpart (HImode, tmp);
1962 }
1963})
1964
1965(define_insn "*movhi"
085261c8
AK
1966 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q,v,v,v,d, v,QR")
1967 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K,K,v,d,v,QR, v"))]
9db1d521
HP
1968 ""
1969 "@
d40c829f
UW
1970 lr\t%0,%1
1971 lhi\t%0,%h1
1972 lh\t%0,%1
1973 lhy\t%0,%1
963fc8d0 1974 lhrl\t%0,%1
d40c829f
UW
1975 sth\t%1,%0
1976 sthy\t%1,%0
963fc8d0 1977 sthrl\t%1,%0
085261c8
AK
1978 mvhhi\t%0,%1
1979 vleih\t%v0,%h1,0
1980 vlr\t%v0,%v1
1981 vlvgh\t%v0,%1,0
1982 vlgvh\t%0,%v1,0
1983 vleh\t%v0,%1,0
1984 vsteh\t%v1,%0,0"
1985 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL,VRI,VRR,VRS,VRS,VRX,VRX")
1986 (set_attr "type" "lr,*,*,*,larl,store,store,store,*,*,*,*,*,*,*")
1987 (set_attr "cpu_facility" "*,*,*,*,z10,*,*,z10,z10,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
1988 (set_attr "z10prop" "z10_fr_E1,
1989 z10_fwd_A1,
1990 z10_super_E1,
1991 z10_super_E1,
1992 z10_super_E1,
729e750f 1993 z10_rec,
9381e3f1
WG
1994 z10_rec,
1995 z10_rec,
085261c8 1996 z10_super,*,*,*,*,*,*")])
9db1d521 1997
84817c5d
UW
1998(define_peephole2
1999 [(set (match_operand:HI 0 "register_operand" "")
2000 (mem:HI (match_operand 1 "address_operand" "")))]
2001 "GET_CODE (operands[1]) == SYMBOL_REF
2002 && CONSTANT_POOL_ADDRESS_P (operands[1])
2003 && get_pool_mode (operands[1]) == HImode
2004 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2005 [(set (match_dup 0) (match_dup 2))]
2006 "operands[2] = get_pool_constant (operands[1]);")
4023fb28 2007
9db1d521
HP
2008;
2009; movqi instruction pattern(s).
2010;
2011
02ed3c5e
UW
2012(define_expand "movqi"
2013 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2014 (match_operand:QI 1 "general_operand" ""))]
2015 ""
2016{
c19ec8f9 2017 /* On z/Architecture, zero-extending from memory to register
02ed3c5e 2018 is just as fast as a QImode load. */
b3a13419 2019 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
02ed3c5e 2020 && register_operand (operands[0], VOIDmode)
8fff4fc1 2021 && GET_CODE (operands[1]) == MEM)
02ed3c5e 2022 {
9602b6a1
AK
2023 rtx tmp = gen_reg_rtx (DImode);
2024 rtx ext = gen_rtx_ZERO_EXTEND (DImode, operands[1]);
f7df4a84 2025 emit_insn (gen_rtx_SET (tmp, ext));
02ed3c5e
UW
2026 operands[1] = gen_lowpart (QImode, tmp);
2027 }
2028})
4023fb28 2029
02ed3c5e 2030(define_insn "*movqi"
085261c8
AK
2031 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q,v,v,v,d, v,QR")
2032 (match_operand:QI 1 "general_operand" " d,n,R,T,d,d,n,n,?Q,K,v,d,v,QR, v"))]
9db1d521
HP
2033 ""
2034 "@
d40c829f
UW
2035 lr\t%0,%1
2036 lhi\t%0,%b1
2037 ic\t%0,%1
2038 icy\t%0,%1
2039 stc\t%1,%0
2040 stcy\t%1,%0
fc0ea003 2041 mvi\t%S0,%b1
0a88561f 2042 mviy\t%S0,%b1
085261c8
AK
2043 #
2044 vleib\t%v0,%b1,0
2045 vlr\t%v0,%v1
2046 vlvgb\t%v0,%1,0
2047 vlgvb\t%0,%v1,0
2048 vleb\t%v0,%1,0
2049 vsteb\t%v1,%0,0"
2050 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS,VRI,VRR,VRS,VRS,VRX,VRX")
2051 (set_attr "type" "lr,*,*,*,store,store,store,store,*,*,*,*,*,*,*")
2052 (set_attr "cpu_facility" "*,*,*,*,*,*,*,*,*,vec,vec,vec,vec,vec,vec")
9381e3f1
WG
2053 (set_attr "z10prop" "z10_fr_E1,
2054 z10_fwd_A1,
2055 z10_super_E1,
2056 z10_super_E1,
729e750f 2057 z10_rec,
9381e3f1
WG
2058 z10_rec,
2059 z10_super,
0a88561f 2060 z10_super,
085261c8 2061 *,*,*,*,*,*,*")])
9db1d521 2062
84817c5d
UW
2063(define_peephole2
2064 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2065 (mem:QI (match_operand 1 "address_operand" "")))]
2066 "GET_CODE (operands[1]) == SYMBOL_REF
2067 && CONSTANT_POOL_ADDRESS_P (operands[1])
2068 && get_pool_mode (operands[1]) == QImode
2069 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2070 [(set (match_dup 0) (match_dup 2))]
2071 "operands[2] = get_pool_constant (operands[1]);")
4023fb28 2072
9db1d521 2073;
05b9aaaa 2074; movstrictqi instruction pattern(s).
9db1d521
HP
2075;
2076
2077(define_insn "*movstrictqi"
d3632d41
UW
2078 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
2079 (match_operand:QI 1 "memory_operand" "R,T"))]
9db1d521 2080 ""
d3632d41 2081 "@
d40c829f
UW
2082 ic\t%0,%1
2083 icy\t%0,%1"
9381e3f1 2084 [(set_attr "op_type" "RX,RXY")
729e750f 2085 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521
HP
2086
2087;
2088; movstricthi instruction pattern(s).
2089;
2090
2091(define_insn "*movstricthi"
d3632d41 2092 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
575f7c2b 2093 (match_operand:HI 1 "memory_operand" "Q,S"))
ae156f85 2094 (clobber (reg:CC CC_REGNUM))]
9db1d521 2095 ""
d3632d41 2096 "@
fc0ea003
UW
2097 icm\t%0,3,%S1
2098 icmy\t%0,3,%S1"
9381e3f1
WG
2099 [(set_attr "op_type" "RS,RSY")
2100 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521
HP
2101
2102;
2103; movstrictsi instruction pattern(s).
2104;
2105
05b9aaaa 2106(define_insn "movstrictsi"
c5aa1d12
UW
2107 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
2108 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
9602b6a1 2109 "TARGET_ZARCH"
9db1d521 2110 "@
d40c829f
UW
2111 lr\t%0,%1
2112 l\t%0,%1
c5aa1d12
UW
2113 ly\t%0,%1
2114 ear\t%0,%1"
2115 [(set_attr "op_type" "RR,RX,RXY,RRE")
9381e3f1
WG
2116 (set_attr "type" "lr,load,load,*")
2117 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
9db1d521 2118
f61a2c7d 2119;
609e7e80 2120; mov(tf|td) instruction pattern(s).
f61a2c7d
AK
2121;
2122
609e7e80
AK
2123(define_expand "mov<mode>"
2124 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2125 (match_operand:TD_TF 1 "general_operand" ""))]
f61a2c7d
AK
2126 ""
2127 "")
2128
609e7e80 2129(define_insn "*mov<mode>_64"
65b1d8ea
AK
2130 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o, d,QS, d,o")
2131 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,QS, d,dRT,d"))]
9602b6a1 2132 "TARGET_ZARCH"
f61a2c7d 2133 "@
65b1d8ea 2134 lzxr\t%0
f61a2c7d
AK
2135 lxr\t%0,%1
2136 #
2137 #
2138 lmg\t%0,%N0,%S1
2139 stmg\t%1,%N1,%S0
2140 #
f61a2c7d 2141 #"
65b1d8ea
AK
2142 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
2143 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")
2144 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*")])
f61a2c7d 2145
609e7e80 2146(define_insn "*mov<mode>_31"
65b1d8ea
AK
2147 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
2148 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
9602b6a1 2149 "!TARGET_ZARCH"
f61a2c7d 2150 "@
65b1d8ea 2151 lzxr\t%0
f61a2c7d
AK
2152 lxr\t%0,%1
2153 #
f61a2c7d 2154 #"
65b1d8ea
AK
2155 [(set_attr "op_type" "RRE,RRE,*,*")
2156 (set_attr "type" "fsimptf,fsimptf,*,*")
2157 (set_attr "cpu_facility" "z196,*,*,*")])
f61a2c7d
AK
2158
2159; TFmode in GPRs splitters
2160
2161(define_split
609e7e80
AK
2162 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2163 (match_operand:TD_TF 1 "general_operand" ""))]
9602b6a1 2164 "TARGET_ZARCH && reload_completed
609e7e80 2165 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
f61a2c7d
AK
2166 [(set (match_dup 2) (match_dup 4))
2167 (set (match_dup 3) (match_dup 5))]
2168{
609e7e80
AK
2169 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2170 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2171 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2172 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
f61a2c7d
AK
2173})
2174
2175(define_split
609e7e80
AK
2176 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2177 (match_operand:TD_TF 1 "general_operand" ""))]
9602b6a1 2178 "TARGET_ZARCH && reload_completed
609e7e80 2179 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
f61a2c7d
AK
2180 [(set (match_dup 2) (match_dup 4))
2181 (set (match_dup 3) (match_dup 5))]
2182{
609e7e80
AK
2183 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2184 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2185 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2186 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
f61a2c7d
AK
2187})
2188
2189(define_split
609e7e80
AK
2190 [(set (match_operand:TD_TF 0 "register_operand" "")
2191 (match_operand:TD_TF 1 "memory_operand" ""))]
9602b6a1 2192 "TARGET_ZARCH && reload_completed
085261c8 2193 && GENERAL_REG_P (operands[0])
f61a2c7d
AK
2194 && !s_operand (operands[1], VOIDmode)"
2195 [(set (match_dup 0) (match_dup 1))]
2196{
609e7e80 2197 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
a9e6994a 2198 addr = gen_lowpart (Pmode, addr);
f61a2c7d
AK
2199 s390_load_address (addr, XEXP (operands[1], 0));
2200 operands[1] = replace_equiv_address (operands[1], addr);
2201})
2202
7b6baae1 2203; TFmode in BFPs splitters
f61a2c7d
AK
2204
2205(define_split
609e7e80
AK
2206 [(set (match_operand:TD_TF 0 "register_operand" "")
2207 (match_operand:TD_TF 1 "memory_operand" ""))]
9381e3f1 2208 "reload_completed && offsettable_memref_p (operands[1])
f61a2c7d
AK
2209 && FP_REG_P (operands[0])"
2210 [(set (match_dup 2) (match_dup 4))
2211 (set (match_dup 3) (match_dup 5))]
2212{
609e7e80
AK
2213 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2214 <MODE>mode, 0);
2215 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2216 <MODE>mode, 8);
2217 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
2218 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
f61a2c7d
AK
2219})
2220
2221(define_split
609e7e80
AK
2222 [(set (match_operand:TD_TF 0 "memory_operand" "")
2223 (match_operand:TD_TF 1 "register_operand" ""))]
f61a2c7d
AK
2224 "reload_completed && offsettable_memref_p (operands[0])
2225 && FP_REG_P (operands[1])"
2226 [(set (match_dup 2) (match_dup 4))
2227 (set (match_dup 3) (match_dup 5))]
2228{
609e7e80
AK
2229 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
2230 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
2231 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2232 <MODE>mode, 0);
2233 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2234 <MODE>mode, 8);
f61a2c7d
AK
2235})
2236
9db1d521 2237;
609e7e80 2238; mov(df|dd) instruction pattern(s).
9db1d521
HP
2239;
2240
609e7e80
AK
2241(define_expand "mov<mode>"
2242 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2243 (match_operand:DD_DF 1 "general_operand" ""))]
9db1d521 2244 ""
13c025c1 2245 "")
9db1d521 2246
609e7e80
AK
2247(define_insn "*mov<mode>_64dfp"
2248 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
085261c8 2249 "=f,f,f,d,f,f,R,T,d,d,d, d,b,RT,v,v,d,v,QR")
609e7e80 2250 (match_operand:DD_DF 1 "general_operand"
085261c8 2251 " G,f,d,f,R,T,f,f,G,d,b,RT,d, d,v,d,v,QR,v"))]
9602b6a1 2252 "TARGET_DFP"
85dae55a 2253 "@
65b1d8ea 2254 lzdr\t%0
85dae55a
AK
2255 ldr\t%0,%1
2256 ldgr\t%0,%1
2257 lgdr\t%0,%1
2258 ld\t%0,%1
2259 ldy\t%0,%1
2260 std\t%1,%0
2261 stdy\t%1,%0
45e5214c 2262 lghi\t%0,0
85dae55a 2263 lgr\t%0,%1
085261c8 2264 lgrl\t%0,%1
85dae55a 2265 lg\t%0,%1
085261c8
AK
2266 stgrl\t%1,%0
2267 stg\t%1,%0
2268 vlr\t%v0,%v1
2269 vlvgg\t%v0,%1,0
2270 vlgvg\t%0,%v1,0
2271 vleg\t%0,%1,0
2272 vsteg\t%1,%0,0"
2273 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY,VRR,VRS,VRS,VRX,VRX")
65b1d8ea 2274 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
085261c8
AK
2275 fstoredf,fstoredf,*,lr,load,load,store,store,*,*,*,load,store")
2276 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,*,*,*,*,*")
2277 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*,z10,*,z10,*,vec,vec,vec,vec,vec")])
85dae55a 2278
609e7e80 2279(define_insn "*mov<mode>_64"
085261c8
AK
2280 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,d, d,b,RT,v,v,QR")
2281 (match_operand:DD_DF 1 "general_operand" " G,f,R,T,f,f,G,d,b,RT,d, d,v,QR,v"))]
9602b6a1 2282 "TARGET_ZARCH"
9db1d521 2283 "@
65b1d8ea 2284 lzdr\t%0
d40c829f
UW
2285 ldr\t%0,%1
2286 ld\t%0,%1
2287 ldy\t%0,%1
2288 std\t%1,%0
2289 stdy\t%1,%0
45e5214c 2290 lghi\t%0,0
d40c829f 2291 lgr\t%0,%1
085261c8 2292 lgrl\t%0,%1
d40c829f 2293 lg\t%0,%1
085261c8
AK
2294 stgrl\t%1,%0
2295 stg\t%1,%0
2296 vlr\t%v0,%v1
2297 vleg\t%v0,%1,0
2298 vsteg\t%v1,%0,0"
2299 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY,VRR,VRX,VRX")
65b1d8ea 2300 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
085261c8
AK
2301 fstore<mode>,fstore<mode>,*,lr,load,load,store,store,*,load,store")
2302 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,*,*,*")
2303 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,z10,*,z10,*,vec,vec,vec")])
609e7e80
AK
2304
2305(define_insn "*mov<mode>_31"
2306 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
65b1d8ea 2307 "=f,f,f,f,R,T,d,d,Q,S, d,o")
609e7e80 2308 (match_operand:DD_DF 1 "general_operand"
65b1d8ea 2309 " G,f,R,T,f,f,Q,S,d,d,dPRT,d"))]
9602b6a1 2310 "!TARGET_ZARCH"
9db1d521 2311 "@
65b1d8ea 2312 lzdr\t%0
d40c829f
UW
2313 ldr\t%0,%1
2314 ld\t%0,%1
2315 ldy\t%0,%1
2316 std\t%1,%0
2317 stdy\t%1,%0
fc0ea003 2318 lm\t%0,%N0,%S1
c4d50129 2319 lmy\t%0,%N0,%S1
fc0ea003 2320 stm\t%1,%N1,%S0
c4d50129 2321 stmy\t%1,%N1,%S0
4023fb28 2322 #
19b63d8e 2323 #"
65b1d8ea
AK
2324 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2325 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2326 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")
2327 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*,*,*")])
4023fb28
UW
2328
2329(define_split
609e7e80
AK
2330 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2331 (match_operand:DD_DF 1 "general_operand" ""))]
9602b6a1 2332 "!TARGET_ZARCH && reload_completed
609e7e80 2333 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
4023fb28
UW
2334 [(set (match_dup 2) (match_dup 4))
2335 (set (match_dup 3) (match_dup 5))]
9db1d521 2336{
609e7e80
AK
2337 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2338 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2339 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2340 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
dc65c307
UW
2341})
2342
2343(define_split
609e7e80
AK
2344 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2345 (match_operand:DD_DF 1 "general_operand" ""))]
9602b6a1 2346 "!TARGET_ZARCH && reload_completed
609e7e80 2347 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
dc65c307
UW
2348 [(set (match_dup 2) (match_dup 4))
2349 (set (match_dup 3) (match_dup 5))]
2350{
609e7e80
AK
2351 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2352 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2353 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2354 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
dc65c307 2355})
9db1d521 2356
4023fb28 2357(define_split
609e7e80
AK
2358 [(set (match_operand:DD_DF 0 "register_operand" "")
2359 (match_operand:DD_DF 1 "memory_operand" ""))]
9602b6a1 2360 "!TARGET_ZARCH && reload_completed
8e509cf9 2361 && !FP_REG_P (operands[0])
4023fb28 2362 && !s_operand (operands[1], VOIDmode)"
a41c6c53 2363 [(set (match_dup 0) (match_dup 1))]
a41c6c53 2364{
609e7e80 2365 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
a41c6c53
UW
2366 s390_load_address (addr, XEXP (operands[1], 0));
2367 operands[1] = replace_equiv_address (operands[1], addr);
dc65c307
UW
2368})
2369
9db1d521 2370;
609e7e80 2371; mov(sf|sd) instruction pattern(s).
9db1d521
HP
2372;
2373
609e7e80
AK
2374(define_insn "mov<mode>"
2375 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
085261c8 2376 "=f,f,f,f,f,f,R,T,d,d,d,d,d,b,R,T,v,v,v,d,v,QR")
609e7e80 2377 (match_operand:SD_SF 1 "general_operand"
085261c8 2378 " G,f,f,R,R,T,f,f,G,d,b,R,T,d,d,d,v,G,d,v,QR,v"))]
4023fb28 2379 ""
9db1d521 2380 "@
65b1d8ea 2381 lzer\t%0
085261c8 2382 lder\t%0,%1
d40c829f 2383 ler\t%0,%1
085261c8 2384 lde\t%0,%1
d40c829f
UW
2385 le\t%0,%1
2386 ley\t%0,%1
2387 ste\t%1,%0
2388 stey\t%1,%0
45e5214c 2389 lhi\t%0,0
d40c829f 2390 lr\t%0,%1
085261c8 2391 lrl\t%0,%1
d40c829f
UW
2392 l\t%0,%1
2393 ly\t%0,%1
085261c8 2394 strl\t%1,%0
d40c829f 2395 st\t%1,%0
085261c8
AK
2396 sty\t%1,%0
2397 vlr\t%v0,%v1
2398 vleif\t%v0,0
2399 vlvgf\t%v0,%1,0
2400 vlgvf\t%0,%v1,0
2401 vleg\t%0,%1,0
2402 vsteg\t%1,%0,0"
2403 [(set_attr "op_type" "RRE,RRE,RR,RXE,RX,RXY,RX,RXY,RI,RR,RIL,RX,RXY,RIL,RX,RXY,VRR,VRI,VRS,VRS,VRX,VRX")
2404 (set_attr "type" "fsimpsf,fsimpsf,fload<mode>,fload<mode>,fload<mode>,fload<mode>,
2405 fstore<mode>,fstore<mode>,*,lr,load,load,load,store,store,store,*,*,*,*,load,store")
2406 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,z10_rec,*,*,*,*,*,*")
2407 (set_attr "cpu_facility" "z196,vec,*,vec,*,*,*,*,*,*,z10,*,*,z10,*,*,vec,vec,vec,vec,vec,vec")])
4023fb28 2408
9dc62c00
AK
2409;
2410; movcc instruction pattern
2411;
2412
2413(define_insn "movcc"
2414 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
5a3fe9b6 2415 (match_operand:CC 1 "nonimmediate_operand" " d,d,c,R,T,d,d"))]
9dc62c00
AK
2416 ""
2417 "@
2418 lr\t%0,%1
2419 tmh\t%1,12288
2420 ipm\t%0
a71f0749
DV
2421 l\t%0,%1
2422 ly\t%0,%1
2423 st\t%1,%0
2424 sty\t%1,%0"
8dd3b235 2425 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
a71f0749
DV
2426 (set_attr "type" "lr,*,*,load,load,store,store")
2427 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
65b1d8ea 2428 (set_attr "z196prop" "*,*,z196_ends,*,*,*,*")])
9dc62c00 2429
19b63d8e
UW
2430;
2431; Block move (MVC) patterns.
2432;
2433
2434(define_insn "*mvc"
2435 [(set (match_operand:BLK 0 "memory_operand" "=Q")
2436 (match_operand:BLK 1 "memory_operand" "Q"))
2437 (use (match_operand 2 "const_int_operand" "n"))]
2438 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 2439 "mvc\t%O0(%2,%R0),%S1"
b628bd8e 2440 [(set_attr "op_type" "SS")])
19b63d8e 2441
0a88561f
AK
2442; This splitter converts a QI to QI mode copy into a BLK mode copy in
2443; order to have it implemented with mvc.
2444
2445(define_split
2446 [(set (match_operand:QI 0 "memory_operand" "")
2447 (match_operand:QI 1 "memory_operand" ""))]
2448 "reload_completed"
2449 [(parallel
2450 [(set (match_dup 0) (match_dup 1))
2451 (use (const_int 1))])]
2452{
2453 operands[0] = adjust_address (operands[0], BLKmode, 0);
2454 operands[1] = adjust_address (operands[1], BLKmode, 0);
2455})
2456
2457
19b63d8e
UW
2458(define_peephole2
2459 [(parallel
2460 [(set (match_operand:BLK 0 "memory_operand" "")
2461 (match_operand:BLK 1 "memory_operand" ""))
2462 (use (match_operand 2 "const_int_operand" ""))])
2463 (parallel
2464 [(set (match_operand:BLK 3 "memory_operand" "")
2465 (match_operand:BLK 4 "memory_operand" ""))
2466 (use (match_operand 5 "const_int_operand" ""))])]
2467 "s390_offset_p (operands[0], operands[3], operands[2])
2468 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 2469 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 2470 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
2471 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2472 [(parallel
2473 [(set (match_dup 6) (match_dup 7))
2474 (use (match_dup 8))])]
2475 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2476 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2477 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2478
2479
9db1d521
HP
2480;
2481; load_multiple pattern(s).
2482;
22ea6b4f
UW
2483; ??? Due to reload problems with replacing registers inside match_parallel
2484; we currently support load_multiple/store_multiple only after reload.
2485;
9db1d521
HP
2486
2487(define_expand "load_multiple"
2488 [(match_par_dup 3 [(set (match_operand 0 "" "")
2489 (match_operand 1 "" ""))
2490 (use (match_operand 2 "" ""))])]
22ea6b4f 2491 "reload_completed"
9db1d521 2492{
ef4bddc2 2493 machine_mode mode;
9db1d521
HP
2494 int regno;
2495 int count;
2496 rtx from;
4023fb28 2497 int i, off;
9db1d521
HP
2498
2499 /* Support only loading a constant number of fixed-point registers from
2500 memory and only bother with this if more than two */
2501 if (GET_CODE (operands[2]) != CONST_INT
4023fb28 2502 || INTVAL (operands[2]) < 2
9db1d521
HP
2503 || INTVAL (operands[2]) > 16
2504 || GET_CODE (operands[1]) != MEM
2505 || GET_CODE (operands[0]) != REG
2506 || REGNO (operands[0]) >= 16)
2507 FAIL;
2508
2509 count = INTVAL (operands[2]);
2510 regno = REGNO (operands[0]);
c19ec8f9 2511 mode = GET_MODE (operands[0]);
9602b6a1 2512 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
c19ec8f9 2513 FAIL;
9db1d521
HP
2514
2515 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
b3a13419 2516 if (!can_create_pseudo_p ())
4023fb28
UW
2517 {
2518 if (GET_CODE (XEXP (operands[1], 0)) == REG)
2519 {
2520 from = XEXP (operands[1], 0);
2521 off = 0;
2522 }
2523 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2524 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2525 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2526 {
2527 from = XEXP (XEXP (operands[1], 0), 0);
2528 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2529 }
2530 else
2531 FAIL;
4023fb28
UW
2532 }
2533 else
2534 {
2535 from = force_reg (Pmode, XEXP (operands[1], 0));
2536 off = 0;
2537 }
9db1d521
HP
2538
2539 for (i = 0; i < count; i++)
2540 XVECEXP (operands[3], 0, i)
f7df4a84 2541 = gen_rtx_SET (gen_rtx_REG (mode, regno + i),
c19ec8f9 2542 change_address (operands[1], mode,
0a81f074
RS
2543 plus_constant (Pmode, from,
2544 off + i * GET_MODE_SIZE (mode))));
10bbf137 2545})
9db1d521
HP
2546
2547(define_insn "*load_multiple_di"
2548 [(match_parallel 0 "load_multiple_operation"
2549 [(set (match_operand:DI 1 "register_operand" "=r")
d3632d41 2550 (match_operand:DI 2 "s_operand" "QS"))])]
9602b6a1 2551 "reload_completed && TARGET_ZARCH"
9db1d521
HP
2552{
2553 int words = XVECLEN (operands[0], 0);
9db1d521 2554 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
fc0ea003 2555 return "lmg\t%1,%0,%S2";
10bbf137 2556}
d3632d41 2557 [(set_attr "op_type" "RSY")
4023fb28 2558 (set_attr "type" "lm")])
9db1d521
HP
2559
2560(define_insn "*load_multiple_si"
2561 [(match_parallel 0 "load_multiple_operation"
d3632d41
UW
2562 [(set (match_operand:SI 1 "register_operand" "=r,r")
2563 (match_operand:SI 2 "s_operand" "Q,S"))])]
22ea6b4f 2564 "reload_completed"
9db1d521
HP
2565{
2566 int words = XVECLEN (operands[0], 0);
9db1d521 2567 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
fc0ea003 2568 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
10bbf137 2569}
d3632d41 2570 [(set_attr "op_type" "RS,RSY")
4023fb28 2571 (set_attr "type" "lm")])
9db1d521
HP
2572
2573;
c7453384 2574; store multiple pattern(s).
9db1d521
HP
2575;
2576
2577(define_expand "store_multiple"
2578 [(match_par_dup 3 [(set (match_operand 0 "" "")
2579 (match_operand 1 "" ""))
2580 (use (match_operand 2 "" ""))])]
22ea6b4f 2581 "reload_completed"
9db1d521 2582{
ef4bddc2 2583 machine_mode mode;
9db1d521
HP
2584 int regno;
2585 int count;
2586 rtx to;
4023fb28 2587 int i, off;
9db1d521
HP
2588
2589 /* Support only storing a constant number of fixed-point registers to
2590 memory and only bother with this if more than two. */
2591 if (GET_CODE (operands[2]) != CONST_INT
4023fb28 2592 || INTVAL (operands[2]) < 2
9db1d521
HP
2593 || INTVAL (operands[2]) > 16
2594 || GET_CODE (operands[0]) != MEM
2595 || GET_CODE (operands[1]) != REG
2596 || REGNO (operands[1]) >= 16)
2597 FAIL;
2598
2599 count = INTVAL (operands[2]);
2600 regno = REGNO (operands[1]);
c19ec8f9 2601 mode = GET_MODE (operands[1]);
9602b6a1 2602 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
c19ec8f9 2603 FAIL;
9db1d521
HP
2604
2605 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
4023fb28 2606
b3a13419 2607 if (!can_create_pseudo_p ())
4023fb28
UW
2608 {
2609 if (GET_CODE (XEXP (operands[0], 0)) == REG)
2610 {
2611 to = XEXP (operands[0], 0);
2612 off = 0;
2613 }
2614 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2615 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2616 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2617 {
2618 to = XEXP (XEXP (operands[0], 0), 0);
2619 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2620 }
2621 else
2622 FAIL;
4023fb28 2623 }
c7453384 2624 else
4023fb28
UW
2625 {
2626 to = force_reg (Pmode, XEXP (operands[0], 0));
2627 off = 0;
2628 }
9db1d521
HP
2629
2630 for (i = 0; i < count; i++)
2631 XVECEXP (operands[3], 0, i)
f7df4a84 2632 = gen_rtx_SET (change_address (operands[0], mode,
0a81f074
RS
2633 plus_constant (Pmode, to,
2634 off + i * GET_MODE_SIZE (mode))),
c19ec8f9 2635 gen_rtx_REG (mode, regno + i));
10bbf137 2636})
9db1d521
HP
2637
2638(define_insn "*store_multiple_di"
2639 [(match_parallel 0 "store_multiple_operation"
d3632d41 2640 [(set (match_operand:DI 1 "s_operand" "=QS")
9db1d521 2641 (match_operand:DI 2 "register_operand" "r"))])]
9602b6a1 2642 "reload_completed && TARGET_ZARCH"
9db1d521
HP
2643{
2644 int words = XVECLEN (operands[0], 0);
9db1d521 2645 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
fc0ea003 2646 return "stmg\t%2,%0,%S1";
10bbf137 2647}
d3632d41 2648 [(set_attr "op_type" "RSY")
4023fb28 2649 (set_attr "type" "stm")])
9db1d521
HP
2650
2651
2652(define_insn "*store_multiple_si"
2653 [(match_parallel 0 "store_multiple_operation"
d3632d41
UW
2654 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2655 (match_operand:SI 2 "register_operand" "r,r"))])]
22ea6b4f 2656 "reload_completed"
9db1d521
HP
2657{
2658 int words = XVECLEN (operands[0], 0);
9db1d521 2659 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
fc0ea003 2660 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
10bbf137 2661}
d3632d41 2662 [(set_attr "op_type" "RS,RSY")
4023fb28 2663 (set_attr "type" "stm")])
9db1d521
HP
2664
2665;;
2666;; String instructions.
2667;;
2668
963fc8d0 2669(define_insn "*execute_rl"
2771c2f9 2670 [(match_parallel 0 "execute_operation"
963fc8d0
AK
2671 [(unspec [(match_operand 1 "register_operand" "a")
2672 (match_operand 2 "" "")
2673 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2674 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2675 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2676 "exrl\t%1,%3"
2677 [(set_attr "op_type" "RIL")
2678 (set_attr "type" "cs")])
2679
9bb86f41 2680(define_insn "*execute"
2771c2f9 2681 [(match_parallel 0 "execute_operation"
9bb86f41
UW
2682 [(unspec [(match_operand 1 "register_operand" "a")
2683 (match_operand:BLK 2 "memory_operand" "R")
2684 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2685 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2686 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2687 "ex\t%1,%2"
29a74354
UW
2688 [(set_attr "op_type" "RX")
2689 (set_attr "type" "cs")])
9bb86f41
UW
2690
2691
91d39d71
UW
2692;
2693; strlenM instruction pattern(s).
2694;
2695
9db2f16d 2696(define_expand "strlen<mode>"
085261c8
AK
2697 [(match_operand:P 0 "register_operand" "") ; result
2698 (match_operand:BLK 1 "memory_operand" "") ; input string
2699 (match_operand:SI 2 "immediate_operand" "") ; search character
2700 (match_operand:SI 3 "immediate_operand" "")] ; known alignment
2701 ""
2702{
2703 if (!TARGET_VX || operands[2] != const0_rtx)
2704 emit_insn (gen_strlen_srst<mode> (operands[0], operands[1],
2705 operands[2], operands[3]));
2706 else
2707 s390_expand_vec_strlen (operands[0], operands[1], operands[3]);
2708
2709 DONE;
2710})
2711
2712(define_expand "strlen_srst<mode>"
ccbdc0d4 2713 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2f7e5a0d 2714 (parallel
91d39d71 2715 [(set (match_dup 4)
9db2f16d 2716 (unspec:P [(const_int 0)
91d39d71 2717 (match_operand:BLK 1 "memory_operand" "")
ccbdc0d4 2718 (reg:SI 0)
91d39d71 2719 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
9db2f16d 2720 (clobber (scratch:P))
ae156f85 2721 (clobber (reg:CC CC_REGNUM))])
91d39d71 2722 (parallel
9db2f16d
AS
2723 [(set (match_operand:P 0 "register_operand" "")
2724 (minus:P (match_dup 4) (match_dup 5)))
ae156f85 2725 (clobber (reg:CC CC_REGNUM))])]
9db2f16d 2726 ""
91d39d71 2727{
9db2f16d
AS
2728 operands[4] = gen_reg_rtx (Pmode);
2729 operands[5] = gen_reg_rtx (Pmode);
91d39d71
UW
2730 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2731 operands[1] = replace_equiv_address (operands[1], operands[5]);
2732})
2733
9db2f16d
AS
2734(define_insn "*strlen<mode>"
2735 [(set (match_operand:P 0 "register_operand" "=a")
2736 (unspec:P [(match_operand:P 2 "general_operand" "0")
2737 (mem:BLK (match_operand:P 3 "register_operand" "1"))
ccbdc0d4 2738 (reg:SI 0)
91d39d71 2739 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
9db2f16d 2740 (clobber (match_scratch:P 1 "=a"))
ae156f85 2741 (clobber (reg:CC CC_REGNUM))]
9db2f16d 2742 ""
91d39d71 2743 "srst\t%0,%1\;jo\t.-4"
b628bd8e
UW
2744 [(set_attr "length" "8")
2745 (set_attr "type" "vs")])
91d39d71 2746
ccbdc0d4
AS
2747;
2748; cmpstrM instruction pattern(s).
2749;
2750
2751(define_expand "cmpstrsi"
2752 [(set (reg:SI 0) (const_int 0))
2753 (parallel
2754 [(clobber (match_operand 3 "" ""))
2755 (clobber (match_dup 4))
2756 (set (reg:CCU CC_REGNUM)
2757 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2758 (match_operand:BLK 2 "memory_operand" "")))
2759 (use (reg:SI 0))])
2760 (parallel
2761 [(set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 2762 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_STRCMPCC_TO_INT))
ccbdc0d4
AS
2763 (clobber (reg:CC CC_REGNUM))])]
2764 ""
2765{
2766 /* As the result of CMPINT is inverted compared to what we need,
2767 we have to swap the operands. */
2768 rtx op1 = operands[2];
2769 rtx op2 = operands[1];
2770 rtx addr1 = gen_reg_rtx (Pmode);
2771 rtx addr2 = gen_reg_rtx (Pmode);
2772
2773 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2774 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2775 operands[1] = replace_equiv_address_nv (op1, addr1);
2776 operands[2] = replace_equiv_address_nv (op2, addr2);
2777 operands[3] = addr1;
2778 operands[4] = addr2;
2779})
2780
2781(define_insn "*cmpstr<mode>"
2782 [(clobber (match_operand:P 0 "register_operand" "=d"))
2783 (clobber (match_operand:P 1 "register_operand" "=d"))
2784 (set (reg:CCU CC_REGNUM)
2785 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2786 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2787 (use (reg:SI 0))]
2788 ""
2789 "clst\t%0,%1\;jo\t.-4"
2790 [(set_attr "length" "8")
2791 (set_attr "type" "vs")])
9381e3f1 2792
742090fc
AS
2793;
2794; movstr instruction pattern.
2795;
2796
2797(define_expand "movstr"
2798 [(set (reg:SI 0) (const_int 0))
9381e3f1 2799 (parallel
742090fc
AS
2800 [(clobber (match_dup 3))
2801 (set (match_operand:BLK 1 "memory_operand" "")
2802 (match_operand:BLK 2 "memory_operand" ""))
2803 (set (match_operand 0 "register_operand" "")
9381e3f1 2804 (unspec [(match_dup 1)
742090fc
AS
2805 (match_dup 2)
2806 (reg:SI 0)] UNSPEC_MVST))
2807 (clobber (reg:CC CC_REGNUM))])]
2808 ""
2809{
2810 rtx addr1 = gen_reg_rtx (Pmode);
2811 rtx addr2 = gen_reg_rtx (Pmode);
2812
2813 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2814 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
2815 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2816 operands[2] = replace_equiv_address_nv (operands[2], addr2);
2817 operands[3] = addr2;
2818})
2819
2820(define_insn "*movstr"
2821 [(clobber (match_operand:P 2 "register_operand" "=d"))
2822 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
2823 (mem:BLK (match_operand:P 3 "register_operand" "2")))
2824 (set (match_operand:P 0 "register_operand" "=d")
9381e3f1 2825 (unspec [(mem:BLK (match_dup 1))
742090fc
AS
2826 (mem:BLK (match_dup 3))
2827 (reg:SI 0)] UNSPEC_MVST))
2828 (clobber (reg:CC CC_REGNUM))]
2829 ""
2830 "mvst\t%1,%2\;jo\t.-4"
2831 [(set_attr "length" "8")
2832 (set_attr "type" "vs")])
9381e3f1 2833
742090fc 2834
9db1d521 2835;
70128ad9 2836; movmemM instruction pattern(s).
9db1d521
HP
2837;
2838
9db2f16d 2839(define_expand "movmem<mode>"
963fc8d0
AK
2840 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
2841 (match_operand:BLK 1 "memory_operand" "")) ; source
2842 (use (match_operand:GPR 2 "general_operand" "")) ; count
a41c6c53
UW
2843 (match_operand 3 "" "")]
2844 ""
367d32f3
AK
2845{
2846 if (s390_expand_movmem (operands[0], operands[1], operands[2]))
2847 DONE;
2848 else
2849 FAIL;
2850})
9db1d521 2851
ecbe845e
UW
2852; Move a block that is up to 256 bytes in length.
2853; The block length is taken as (operands[2] % 256) + 1.
9db1d521 2854
70128ad9 2855(define_expand "movmem_short"
b9404c99
UW
2856 [(parallel
2857 [(set (match_operand:BLK 0 "memory_operand" "")
2858 (match_operand:BLK 1 "memory_operand" ""))
2859 (use (match_operand 2 "nonmemory_operand" ""))
9bb86f41 2860 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99
UW
2861 (clobber (match_dup 3))])]
2862 ""
2863 "operands[3] = gen_rtx_SCRATCH (Pmode);")
ecbe845e 2864
70128ad9 2865(define_insn "*movmem_short"
963fc8d0
AK
2866 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2867 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
2868 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2869 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
1eae36f0
AK
2870 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
2871 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
9bb86f41 2872 "#"
963fc8d0 2873 [(set_attr "type" "cs")
b5e0425c 2874 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
ecbe845e 2875
9bb86f41
UW
2876(define_split
2877 [(set (match_operand:BLK 0 "memory_operand" "")
2878 (match_operand:BLK 1 "memory_operand" ""))
2879 (use (match_operand 2 "const_int_operand" ""))
2880 (use (match_operand 3 "immediate_operand" ""))
2881 (clobber (scratch))]
2882 "reload_completed"
2883 [(parallel
2884 [(set (match_dup 0) (match_dup 1))
2885 (use (match_dup 2))])]
2886 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
9db1d521 2887
9bb86f41
UW
2888(define_split
2889 [(set (match_operand:BLK 0 "memory_operand" "")
2890 (match_operand:BLK 1 "memory_operand" ""))
2891 (use (match_operand 2 "register_operand" ""))
2892 (use (match_operand 3 "memory_operand" ""))
2893 (clobber (scratch))]
2894 "reload_completed"
2895 [(parallel
2896 [(unspec [(match_dup 2) (match_dup 3)
2897 (const_int 0)] UNSPEC_EXECUTE)
2898 (set (match_dup 0) (match_dup 1))
2899 (use (const_int 1))])]
2900 "")
2901
963fc8d0
AK
2902(define_split
2903 [(set (match_operand:BLK 0 "memory_operand" "")
2904 (match_operand:BLK 1 "memory_operand" ""))
2905 (use (match_operand 2 "register_operand" ""))
2906 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2907 (clobber (scratch))]
2908 "TARGET_Z10 && reload_completed"
2909 [(parallel
2910 [(unspec [(match_dup 2) (const_int 0)
2911 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2912 (set (match_dup 0) (match_dup 1))
2913 (use (const_int 1))])]
2914 "operands[3] = gen_label_rtx ();")
2915
9bb86f41
UW
2916(define_split
2917 [(set (match_operand:BLK 0 "memory_operand" "")
2918 (match_operand:BLK 1 "memory_operand" ""))
2919 (use (match_operand 2 "register_operand" ""))
2920 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2921 (clobber (match_operand 3 "register_operand" ""))]
2922 "reload_completed && TARGET_CPU_ZARCH"
2923 [(set (match_dup 3) (label_ref (match_dup 4)))
2924 (parallel
9381e3f1 2925 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
9bb86f41
UW
2926 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2927 (set (match_dup 0) (match_dup 1))
2928 (use (const_int 1))])]
2929 "operands[4] = gen_label_rtx ();")
2930
a41c6c53 2931; Move a block of arbitrary length.
9db1d521 2932
70128ad9 2933(define_expand "movmem_long"
b9404c99
UW
2934 [(parallel
2935 [(clobber (match_dup 2))
2936 (clobber (match_dup 3))
2937 (set (match_operand:BLK 0 "memory_operand" "")
2938 (match_operand:BLK 1 "memory_operand" ""))
2939 (use (match_operand 2 "general_operand" ""))
2940 (use (match_dup 3))
ae156f85 2941 (clobber (reg:CC CC_REGNUM))])]
b9404c99
UW
2942 ""
2943{
ef4bddc2
RS
2944 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
2945 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
2946 rtx reg0 = gen_reg_rtx (dreg_mode);
2947 rtx reg1 = gen_reg_rtx (dreg_mode);
2948 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
2949 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
b9404c99
UW
2950 rtx len0 = gen_lowpart (Pmode, reg0);
2951 rtx len1 = gen_lowpart (Pmode, reg1);
2952
c41c1387 2953 emit_clobber (reg0);
b9404c99
UW
2954 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2955 emit_move_insn (len0, operands[2]);
2956
c41c1387 2957 emit_clobber (reg1);
b9404c99
UW
2958 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2959 emit_move_insn (len1, operands[2]);
2960
2961 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2962 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2963 operands[2] = reg0;
2964 operands[3] = reg1;
2965})
2966
a1aed706
AS
2967(define_insn "*movmem_long"
2968 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2969 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2970 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2971 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
b9404c99
UW
2972 (use (match_dup 2))
2973 (use (match_dup 3))
ae156f85 2974 (clobber (reg:CC CC_REGNUM))]
9602b6a1
AK
2975 "TARGET_64BIT || !TARGET_ZARCH"
2976 "mvcle\t%0,%1,0\;jo\t.-4"
2977 [(set_attr "length" "8")
2978 (set_attr "type" "vs")])
2979
2980(define_insn "*movmem_long_31z"
2981 [(clobber (match_operand:TI 0 "register_operand" "=d"))
2982 (clobber (match_operand:TI 1 "register_operand" "=d"))
2983 (set (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
2984 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4)))
2985 (use (match_dup 2))
2986 (use (match_dup 3))
2987 (clobber (reg:CC CC_REGNUM))]
2988 "!TARGET_64BIT && TARGET_ZARCH"
d40c829f 2989 "mvcle\t%0,%1,0\;jo\t.-4"
b628bd8e
UW
2990 [(set_attr "length" "8")
2991 (set_attr "type" "vs")])
9db1d521 2992
638e37c2
WG
2993
2994;
2995; Test data class.
2996;
2997
0f67fa83
WG
2998(define_expand "signbit<mode>2"
2999 [(set (reg:CCZ CC_REGNUM)
9381e3f1
WG
3000 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3001 (match_dup 2)]
0f67fa83
WG
3002 UNSPEC_TDC_INSN))
3003 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3004 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
0f67fa83
WG
3005 "TARGET_HARD_FLOAT"
3006{
3007 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
3008})
3009
638e37c2
WG
3010(define_expand "isinf<mode>2"
3011 [(set (reg:CCZ CC_REGNUM)
9381e3f1
WG
3012 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3013 (match_dup 2)]
638e37c2
WG
3014 UNSPEC_TDC_INSN))
3015 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3016 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
142cd70f 3017 "TARGET_HARD_FLOAT"
638e37c2
WG
3018{
3019 operands[2] = GEN_INT (S390_TDC_INFINITY);
3020})
3021
085261c8
AK
3022; This extracts CC into a GPR properly shifted. The actual IPM
3023; instruction will be issued by reload. The constraint of operand 1
3024; forces reload to use a GPR. So reload will issue a movcc insn for
3025; copying CC into a GPR first.
5a3fe9b6 3026(define_insn_and_split "*cc_to_int"
085261c8 3027 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5a3fe9b6
AK
3028 (unspec:SI [(match_operand 1 "register_operand" "0")]
3029 UNSPEC_CC_TO_INT))]
3030 "operands != NULL"
3031 "#"
3032 "reload_completed"
3033 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
3034
638e37c2
WG
3035; This insn is used to generate all variants of the Test Data Class
3036; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
3037; is the register to be tested and the second one is the bit mask
9381e3f1 3038; specifying the required test(s).
638e37c2 3039;
be5de7a1 3040; tcxb, tcdb, tceb, tdcxt, tdcdt, tdcet
638e37c2
WG
3041(define_insn "*TDC_insn_<mode>"
3042 [(set (reg:CCZ CC_REGNUM)
9381e3f1 3043 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
638e37c2 3044 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
142cd70f 3045 "TARGET_HARD_FLOAT"
0387c142 3046 "t<_d>c<xde><bt>\t%0,%1"
638e37c2 3047 [(set_attr "op_type" "RXE")
9381e3f1 3048 (set_attr "type" "fsimp<mode>")])
638e37c2 3049
638e37c2
WG
3050
3051
9db1d521 3052;
57e84f18 3053; setmemM instruction pattern(s).
9db1d521
HP
3054;
3055
57e84f18 3056(define_expand "setmem<mode>"
a41c6c53 3057 [(set (match_operand:BLK 0 "memory_operand" "")
6d057022 3058 (match_operand:QI 2 "general_operand" ""))
9db2f16d 3059 (use (match_operand:GPR 1 "general_operand" ""))
57e84f18 3060 (match_operand 3 "" "")]
a41c6c53 3061 ""
6d057022 3062 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
9db1d521 3063
a41c6c53 3064; Clear a block that is up to 256 bytes in length.
b9404c99
UW
3065; The block length is taken as (operands[1] % 256) + 1.
3066
70128ad9 3067(define_expand "clrmem_short"
b9404c99
UW
3068 [(parallel
3069 [(set (match_operand:BLK 0 "memory_operand" "")
3070 (const_int 0))
3071 (use (match_operand 1 "nonmemory_operand" ""))
9bb86f41 3072 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99 3073 (clobber (match_dup 2))
ae156f85 3074 (clobber (reg:CC CC_REGNUM))])]
b9404c99
UW
3075 ""
3076 "operands[2] = gen_rtx_SCRATCH (Pmode);")
9db1d521 3077
70128ad9 3078(define_insn "*clrmem_short"
963fc8d0 3079 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
a41c6c53 3080 (const_int 0))
963fc8d0
AK
3081 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
3082 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
1eae36f0 3083 (clobber (match_scratch:P 3 "=X,X,X,&a"))
ae156f85 3084 (clobber (reg:CC CC_REGNUM))]
1eae36f0 3085 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)"
9bb86f41 3086 "#"
963fc8d0 3087 [(set_attr "type" "cs")
b5e0425c 3088 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
9bb86f41
UW
3089
3090(define_split
3091 [(set (match_operand:BLK 0 "memory_operand" "")
3092 (const_int 0))
3093 (use (match_operand 1 "const_int_operand" ""))
3094 (use (match_operand 2 "immediate_operand" ""))
3095 (clobber (scratch))
ae156f85 3096 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3097 "reload_completed"
3098 [(parallel
3099 [(set (match_dup 0) (const_int 0))
3100 (use (match_dup 1))
ae156f85 3101 (clobber (reg:CC CC_REGNUM))])]
9bb86f41 3102 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
9db1d521 3103
9bb86f41
UW
3104(define_split
3105 [(set (match_operand:BLK 0 "memory_operand" "")
3106 (const_int 0))
3107 (use (match_operand 1 "register_operand" ""))
3108 (use (match_operand 2 "memory_operand" ""))
3109 (clobber (scratch))
ae156f85 3110 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3111 "reload_completed"
3112 [(parallel
3113 [(unspec [(match_dup 1) (match_dup 2)
3114 (const_int 0)] UNSPEC_EXECUTE)
3115 (set (match_dup 0) (const_int 0))
3116 (use (const_int 1))
ae156f85 3117 (clobber (reg:CC CC_REGNUM))])]
9bb86f41 3118 "")
9db1d521 3119
963fc8d0
AK
3120(define_split
3121 [(set (match_operand:BLK 0 "memory_operand" "")
3122 (const_int 0))
3123 (use (match_operand 1 "register_operand" ""))
3124 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3125 (clobber (scratch))
3126 (clobber (reg:CC CC_REGNUM))]
3127 "TARGET_Z10 && reload_completed"
3128 [(parallel
3129 [(unspec [(match_dup 1) (const_int 0)
3130 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3131 (set (match_dup 0) (const_int 0))
3132 (use (const_int 1))
3133 (clobber (reg:CC CC_REGNUM))])]
3134 "operands[3] = gen_label_rtx ();")
3135
9bb86f41
UW
3136(define_split
3137 [(set (match_operand:BLK 0 "memory_operand" "")
3138 (const_int 0))
3139 (use (match_operand 1 "register_operand" ""))
3140 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3141 (clobber (match_operand 2 "register_operand" ""))
ae156f85 3142 (clobber (reg:CC CC_REGNUM))]
9bb86f41
UW
3143 "reload_completed && TARGET_CPU_ZARCH"
3144 [(set (match_dup 2) (label_ref (match_dup 3)))
3145 (parallel
9381e3f1 3146 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
9bb86f41
UW
3147 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3148 (set (match_dup 0) (const_int 0))
3149 (use (const_int 1))
ae156f85 3150 (clobber (reg:CC CC_REGNUM))])]
9bb86f41
UW
3151 "operands[3] = gen_label_rtx ();")
3152
9381e3f1 3153; Initialize a block of arbitrary length with (operands[2] % 256).
b9404c99 3154
6d057022 3155(define_expand "setmem_long"
b9404c99
UW
3156 [(parallel
3157 [(clobber (match_dup 1))
3158 (set (match_operand:BLK 0 "memory_operand" "")
4989e88a 3159 (match_operand 2 "shift_count_or_setmem_operand" ""))
b9404c99 3160 (use (match_operand 1 "general_operand" ""))
6d057022 3161 (use (match_dup 3))
ae156f85 3162 (clobber (reg:CC CC_REGNUM))])]
b9404c99 3163 ""
a41c6c53 3164{
ef4bddc2
RS
3165 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3166 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
3167 rtx reg0 = gen_reg_rtx (dreg_mode);
3168 rtx reg1 = gen_reg_rtx (dreg_mode);
3169 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
b9404c99 3170 rtx len0 = gen_lowpart (Pmode, reg0);
9db1d521 3171
c41c1387 3172 emit_clobber (reg0);
b9404c99
UW
3173 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3174 emit_move_insn (len0, operands[1]);
9db1d521 3175
b9404c99 3176 emit_move_insn (reg1, const0_rtx);
a41c6c53 3177
b9404c99
UW
3178 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3179 operands[1] = reg0;
6d057022 3180 operands[3] = reg1;
b9404c99 3181})
a41c6c53 3182
6d057022 3183(define_insn "*setmem_long"
a1aed706 3184 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
6d057022 3185 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
4989e88a 3186 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
6d057022 3187 (use (match_dup 3))
a1aed706 3188 (use (match_operand:<DBL> 1 "register_operand" "d"))
ae156f85 3189 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3190 "TARGET_64BIT || !TARGET_ZARCH"
6d057022 3191 "mvcle\t%0,%1,%Y2\;jo\t.-4"
b628bd8e
UW
3192 [(set_attr "length" "8")
3193 (set_attr "type" "vs")])
9db1d521 3194
4989e88a
AK
3195(define_insn "*setmem_long_and"
3196 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3197 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3198 (and (match_operand 2 "shift_count_or_setmem_operand" "Y")
3199 (match_operand 4 "const_int_operand" "n")))
3200 (use (match_dup 3))
3201 (use (match_operand:<DBL> 1 "register_operand" "d"))
3202 (clobber (reg:CC CC_REGNUM))]
9602b6a1
AK
3203 "(TARGET_64BIT || !TARGET_ZARCH) &&
3204 (INTVAL (operands[4]) & 255) == 255"
3205 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3206 [(set_attr "length" "8")
3207 (set_attr "type" "vs")])
3208
3209(define_insn "*setmem_long_31z"
3210 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3211 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
3212 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
3213 (use (match_dup 3))
3214 (use (match_operand:TI 1 "register_operand" "d"))
3215 (clobber (reg:CC CC_REGNUM))]
3216 "!TARGET_64BIT && TARGET_ZARCH"
4989e88a
AK
3217 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3218 [(set_attr "length" "8")
3219 (set_attr "type" "vs")])
9602b6a1 3220
9db1d521 3221;
358b8f01 3222; cmpmemM instruction pattern(s).
9db1d521
HP
3223;
3224
358b8f01 3225(define_expand "cmpmemsi"
a41c6c53
UW
3226 [(set (match_operand:SI 0 "register_operand" "")
3227 (compare:SI (match_operand:BLK 1 "memory_operand" "")
3228 (match_operand:BLK 2 "memory_operand" "") ) )
3229 (use (match_operand:SI 3 "general_operand" ""))
3230 (use (match_operand:SI 4 "" ""))]
3231 ""
367d32f3
AK
3232{
3233 if (s390_expand_cmpmem (operands[0], operands[1],
3234 operands[2], operands[3]))
3235 DONE;
3236 else
3237 FAIL;
3238})
9db1d521 3239
a41c6c53
UW
3240; Compare a block that is up to 256 bytes in length.
3241; The block length is taken as (operands[2] % 256) + 1.
9db1d521 3242
b9404c99
UW
3243(define_expand "cmpmem_short"
3244 [(parallel
ae156f85 3245 [(set (reg:CCU CC_REGNUM)
5b022de5 3246 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
b9404c99
UW
3247 (match_operand:BLK 1 "memory_operand" "")))
3248 (use (match_operand 2 "nonmemory_operand" ""))
9bb86f41 3249 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
b9404c99
UW
3250 (clobber (match_dup 3))])]
3251 ""
3252 "operands[3] = gen_rtx_SCRATCH (Pmode);")
9db1d521 3253
b9404c99 3254(define_insn "*cmpmem_short"
ae156f85 3255 [(set (reg:CCU CC_REGNUM)
963fc8d0
AK
3256 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
3257 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
3258 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3259 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
1eae36f0
AK
3260 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3261 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
9bb86f41 3262 "#"
963fc8d0 3263 [(set_attr "type" "cs")
b5e0425c 3264 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
9db1d521 3265
9bb86f41 3266(define_split
ae156f85 3267 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3268 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3269 (match_operand:BLK 1 "memory_operand" "")))
3270 (use (match_operand 2 "const_int_operand" ""))
3271 (use (match_operand 3 "immediate_operand" ""))
3272 (clobber (scratch))]
3273 "reload_completed"
3274 [(parallel
ae156f85 3275 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3276 (use (match_dup 2))])]
3277 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
9db1d521 3278
9bb86f41 3279(define_split
ae156f85 3280 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3281 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3282 (match_operand:BLK 1 "memory_operand" "")))
3283 (use (match_operand 2 "register_operand" ""))
3284 (use (match_operand 3 "memory_operand" ""))
3285 (clobber (scratch))]
3286 "reload_completed"
3287 [(parallel
3288 [(unspec [(match_dup 2) (match_dup 3)
3289 (const_int 0)] UNSPEC_EXECUTE)
ae156f85 3290 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3291 (use (const_int 1))])]
3292 "")
3293
963fc8d0
AK
3294(define_split
3295 [(set (reg:CCU CC_REGNUM)
3296 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3297 (match_operand:BLK 1 "memory_operand" "")))
3298 (use (match_operand 2 "register_operand" ""))
3299 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3300 (clobber (scratch))]
3301 "TARGET_Z10 && reload_completed"
3302 [(parallel
3303 [(unspec [(match_dup 2) (const_int 0)
3304 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3305 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3306 (use (const_int 1))])]
3307 "operands[4] = gen_label_rtx ();")
3308
9bb86f41 3309(define_split
ae156f85 3310 [(set (reg:CCU CC_REGNUM)
9bb86f41
UW
3311 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3312 (match_operand:BLK 1 "memory_operand" "")))
3313 (use (match_operand 2 "register_operand" ""))
3314 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3315 (clobber (match_operand 3 "register_operand" ""))]
3316 "reload_completed && TARGET_CPU_ZARCH"
3317 [(set (match_dup 3) (label_ref (match_dup 4)))
3318 (parallel
9381e3f1 3319 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
9bb86f41 3320 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
ae156f85 3321 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
9bb86f41
UW
3322 (use (const_int 1))])]
3323 "operands[4] = gen_label_rtx ();")
3324
a41c6c53 3325; Compare a block of arbitrary length.
9db1d521 3326
b9404c99
UW
3327(define_expand "cmpmem_long"
3328 [(parallel
3329 [(clobber (match_dup 2))
3330 (clobber (match_dup 3))
ae156f85 3331 (set (reg:CCU CC_REGNUM)
5b022de5 3332 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
b9404c99
UW
3333 (match_operand:BLK 1 "memory_operand" "")))
3334 (use (match_operand 2 "general_operand" ""))
3335 (use (match_dup 3))])]
3336 ""
3337{
ef4bddc2
RS
3338 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3339 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
9602b6a1
AK
3340 rtx reg0 = gen_reg_rtx (dreg_mode);
3341 rtx reg1 = gen_reg_rtx (dreg_mode);
3342 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3343 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
b9404c99
UW
3344 rtx len0 = gen_lowpart (Pmode, reg0);
3345 rtx len1 = gen_lowpart (Pmode, reg1);
3346
c41c1387 3347 emit_clobber (reg0);
b9404c99
UW
3348 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3349 emit_move_insn (len0, operands[2]);
3350
c41c1387 3351 emit_clobber (reg1);
b9404c99
UW
3352 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3353 emit_move_insn (len1, operands[2]);
3354
3355 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3356 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3357 operands[2] = reg0;
3358 operands[3] = reg1;
3359})
3360
a1aed706
AS
3361(define_insn "*cmpmem_long"
3362 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3363 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
ae156f85 3364 (set (reg:CCU CC_REGNUM)
a1aed706
AS
3365 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3366 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
f8766020
HP
3367 (use (match_dup 2))
3368 (use (match_dup 3))]
9602b6a1 3369 "TARGET_64BIT || !TARGET_ZARCH"
287ff198 3370 "clcle\t%0,%1,0\;jo\t.-4"
b628bd8e
UW
3371 [(set_attr "length" "8")
3372 (set_attr "type" "vs")])
9db1d521 3373
9602b6a1
AK
3374(define_insn "*cmpmem_long_31z"
3375 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3376 (clobber (match_operand:TI 1 "register_operand" "=d"))
3377 (set (reg:CCU CC_REGNUM)
3378 (compare:CCU (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3379 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4))))
3380 (use (match_dup 2))
3381 (use (match_dup 3))]
3382 "!TARGET_64BIT && TARGET_ZARCH"
3383 "clcle\t%0,%1,0\;jo\t.-4"
3384 [(set_attr "op_type" "NN")
3385 (set_attr "type" "vs")
3386 (set_attr "length" "8")])
3387
02887425
UW
3388; Convert CCUmode condition code to integer.
3389; Result is zero if EQ, positive if LTU, negative if GTU.
9db1d521 3390
02887425 3391(define_insn_and_split "cmpint"
9db1d521 3392 [(set (match_operand:SI 0 "register_operand" "=d")
02887425 3393 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3394 UNSPEC_STRCMPCC_TO_INT))
ae156f85 3395 (clobber (reg:CC CC_REGNUM))]
9db1d521 3396 ""
02887425
UW
3397 "#"
3398 "reload_completed"
3399 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3400 (parallel
3401 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
ae156f85 3402 (clobber (reg:CC CC_REGNUM))])])
02887425
UW
3403
3404(define_insn_and_split "*cmpint_cc"
ae156f85 3405 [(set (reg CC_REGNUM)
02887425 3406 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3407 UNSPEC_STRCMPCC_TO_INT)
02887425
UW
3408 (const_int 0)))
3409 (set (match_operand:SI 0 "register_operand" "=d")
5a3fe9b6 3410 (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT))]
02887425
UW
3411 "s390_match_ccmode (insn, CCSmode)"
3412 "#"
3413 "&& reload_completed"
3414 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3415 (parallel
3416 [(set (match_dup 2) (match_dup 3))
3417 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
9db1d521 3418{
02887425
UW
3419 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3420 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3421 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3422})
9db1d521 3423
02887425 3424(define_insn_and_split "*cmpint_sign"
9db1d521 3425 [(set (match_operand:DI 0 "register_operand" "=d")
02887425 3426 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3427 UNSPEC_STRCMPCC_TO_INT)))
ae156f85 3428 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3429 "TARGET_ZARCH"
02887425
UW
3430 "#"
3431 "&& reload_completed"
3432 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3433 (parallel
3434 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
ae156f85 3435 (clobber (reg:CC CC_REGNUM))])])
02887425
UW
3436
3437(define_insn_and_split "*cmpint_sign_cc"
ae156f85 3438 [(set (reg CC_REGNUM)
9381e3f1 3439 (compare (ashiftrt:DI (ashift:DI (subreg:DI
02887425 3440 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
5a3fe9b6 3441 UNSPEC_STRCMPCC_TO_INT) 0)
02887425
UW
3442 (const_int 32)) (const_int 32))
3443 (const_int 0)))
3444 (set (match_operand:DI 0 "register_operand" "=d")
5a3fe9b6 3445 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT)))]
9602b6a1 3446 "s390_match_ccmode (insn, CCSmode) && TARGET_ZARCH"
02887425
UW
3447 "#"
3448 "&& reload_completed"
3449 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3450 (parallel
3451 [(set (match_dup 2) (match_dup 3))
3452 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
9db1d521 3453{
02887425
UW
3454 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3455 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3456 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3457})
9db1d521 3458
4023fb28 3459
9db1d521
HP
3460;;
3461;;- Conversion instructions.
3462;;
3463
6fa05db6 3464(define_insn "*sethighpartsi"
d3632d41 3465 [(set (match_operand:SI 0 "register_operand" "=d,d")
6fa05db6
AS
3466 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3467 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
ae156f85 3468 (clobber (reg:CC CC_REGNUM))]
4023fb28 3469 ""
d3632d41 3470 "@
6fa05db6
AS
3471 icm\t%0,%2,%S1
3472 icmy\t%0,%2,%S1"
9381e3f1
WG
3473 [(set_attr "op_type" "RS,RSY")
3474 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4023fb28 3475
6fa05db6 3476(define_insn "*sethighpartdi_64"
4023fb28 3477 [(set (match_operand:DI 0 "register_operand" "=d")
6fa05db6
AS
3478 (unspec:DI [(match_operand:BLK 1 "s_operand" "QS")
3479 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
ae156f85 3480 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3481 "TARGET_ZARCH"
6fa05db6 3482 "icmh\t%0,%2,%S1"
729e750f
WG
3483 [(set_attr "op_type" "RSY")
3484 (set_attr "z10prop" "z10_super")])
4023fb28 3485
6fa05db6 3486(define_insn "*sethighpartdi_31"
d3632d41 3487 [(set (match_operand:DI 0 "register_operand" "=d,d")
6fa05db6
AS
3488 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3489 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
ae156f85 3490 (clobber (reg:CC CC_REGNUM))]
9602b6a1 3491 "!TARGET_ZARCH"
d3632d41 3492 "@
6fa05db6
AS
3493 icm\t%0,%2,%S1
3494 icmy\t%0,%2,%S1"
9381e3f1
WG
3495 [(set_attr "op_type" "RS,RSY")
3496 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3497
1a2e356e
RH
3498;
3499; extv instruction patterns
3500;
3501
3502; FIXME: This expander needs to be converted from DI to GPR as well
3503; after resolving some issues with it.
3504
3505(define_expand "extzv"
3506 [(parallel
3507 [(set (match_operand:DI 0 "register_operand" "=d")
3508 (zero_extract:DI
3509 (match_operand:DI 1 "register_operand" "d")
3510 (match_operand 2 "const_int_operand" "") ; size
3511 (match_operand 3 "const_int_operand" ""))) ; start
3512 (clobber (reg:CC CC_REGNUM))])]
3513 "TARGET_Z10"
3514{
3515 /* Starting with zEC12 there is risbgn not clobbering CC. */
3516 if (TARGET_ZEC12)
3517 {
3518 emit_move_insn (operands[0],
3519 gen_rtx_ZERO_EXTRACT (DImode,
3520 operands[1],
3521 operands[2],
3522 operands[3]));
3523 DONE;
3524 }
3525})
3526
3527(define_insn "*extzv<mode>_zEC12"
3528 [(set (match_operand:GPR 0 "register_operand" "=d")
3529 (zero_extract:GPR
3530 (match_operand:GPR 1 "register_operand" "d")
3531 (match_operand 2 "const_int_operand" "") ; size
3532 (match_operand 3 "const_int_operand" "")))] ; start]
3533 "TARGET_ZEC12"
3534 "risbgn\t%0,%1,64-%2,128+63,<bitsize>+%3+%2" ; dst, src, start, end, shift
3535 [(set_attr "op_type" "RIE")])
3536
3537(define_insn "*extzv<mode>_z10"
3538 [(set (match_operand:GPR 0 "register_operand" "=d")
3539 (zero_extract:GPR
3540 (match_operand:GPR 1 "register_operand" "d")
3541 (match_operand 2 "const_int_operand" "") ; size
3542 (match_operand 3 "const_int_operand" ""))) ; start
3543 (clobber (reg:CC CC_REGNUM))]
3544 "TARGET_Z10"
3545 "risbg\t%0,%1,64-%2,128+63,<bitsize>+%3+%2" ; dst, src, start, end, shift
3546 [(set_attr "op_type" "RIE")
3547 (set_attr "z10prop" "z10_super_E1")])
4023fb28 3548
1a2e356e 3549(define_insn_and_split "*pre_z10_extzv<mode>"
6fa05db6
AS
3550 [(set (match_operand:GPR 0 "register_operand" "=d")
3551 (zero_extract:GPR (match_operand:QI 1 "s_operand" "QS")
1a2e356e 3552 (match_operand 2 "nonzero_shift_count_operand" "")
6fa05db6 3553 (const_int 0)))
ae156f85 3554 (clobber (reg:CC CC_REGNUM))]
1a2e356e 3555 "!TARGET_Z10"
cc7ab9b7
UW
3556 "#"
3557 "&& reload_completed"
4023fb28 3558 [(parallel
6fa05db6 3559 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
ae156f85 3560 (clobber (reg:CC CC_REGNUM))])
6fa05db6 3561 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
4023fb28 3562{
6fa05db6
AS
3563 int bitsize = INTVAL (operands[2]);
3564 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3565 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3566
3567 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 3568 set_mem_size (operands[1], size);
2542ef05 3569 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
6fa05db6 3570 operands[3] = GEN_INT (mask);
b628bd8e 3571})
4023fb28 3572
1a2e356e 3573(define_insn_and_split "*pre_z10_extv<mode>"
6fa05db6
AS
3574 [(set (match_operand:GPR 0 "register_operand" "=d")
3575 (sign_extract:GPR (match_operand:QI 1 "s_operand" "QS")
1a2e356e 3576 (match_operand 2 "nonzero_shift_count_operand" "")
6fa05db6 3577 (const_int 0)))
ae156f85 3578 (clobber (reg:CC CC_REGNUM))]
1a2e356e 3579 ""
cc7ab9b7
UW
3580 "#"
3581 "&& reload_completed"
4023fb28 3582 [(parallel
6fa05db6 3583 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
ae156f85 3584 (clobber (reg:CC CC_REGNUM))])
6fa05db6
AS
3585 (parallel
3586 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3587 (clobber (reg:CC CC_REGNUM))])]
3588{
3589 int bitsize = INTVAL (operands[2]);
3590 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3591 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3592
3593 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 3594 set_mem_size (operands[1], size);
2542ef05 3595 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
6fa05db6
AS
3596 operands[3] = GEN_INT (mask);
3597})
3598
3599;
3600; insv instruction patterns
3601;
3602
3603(define_expand "insv"
3604 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3605 (match_operand 1 "const_int_operand" "")
3606 (match_operand 2 "const_int_operand" ""))
3607 (match_operand 3 "general_operand" ""))]
3608 ""
4023fb28 3609{
6fa05db6
AS
3610 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3611 DONE;
3612 FAIL;
b628bd8e 3613})
4023fb28 3614
2542ef05
RH
3615
3616; The normal RTL expansion will never generate a zero_extract where
3617; the location operand isn't word mode. However, we do this in the
3618; back-end when generating atomic operations. See s390_two_part_insv.
22ac2c2f
AK
3619(define_insn "*insv<mode>_zEC12"
3620 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
2542ef05
RH
3621 (match_operand 1 "const_int_operand" "I") ; size
3622 (match_operand 2 "const_int_operand" "I")) ; pos
22ac2c2f
AK
3623 (match_operand:GPR 3 "nonimmediate_operand" "d"))]
3624 "TARGET_ZEC12
2542ef05
RH
3625 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
3626 "risbgn\t%0,%3,64-<bitsize>+%2,64-<bitsize>+%2+%1-1,<bitsize>-%2-%1"
22ac2c2f
AK
3627 [(set_attr "op_type" "RIE")])
3628
963fc8d0
AK
3629(define_insn "*insv<mode>_z10"
3630 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
2542ef05
RH
3631 (match_operand 1 "const_int_operand" "I") ; size
3632 (match_operand 2 "const_int_operand" "I")) ; pos
963fc8d0
AK
3633 (match_operand:GPR 3 "nonimmediate_operand" "d"))
3634 (clobber (reg:CC CC_REGNUM))]
3635 "TARGET_Z10
2542ef05
RH
3636 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
3637 "risbg\t%0,%3,64-<bitsize>+%2,64-<bitsize>+%2+%1-1,<bitsize>-%2-%1"
9381e3f1
WG
3638 [(set_attr "op_type" "RIE")
3639 (set_attr "z10prop" "z10_super_E1")])
963fc8d0 3640
22ac2c2f
AK
3641; and op1 with a mask being 1 for the selected bits and 0 for the rest
3642; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
3643(define_insn "*insv<mode>_zEC12_noshift"
3644 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3645 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
75ca1b39 3646 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
22ac2c2f 3647 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
75ca1b39
RH
3648 (match_operand:GPR 4 "const_int_operand" ""))))]
3649 "TARGET_ZEC12 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3650 "risbgn\t%0,%1,%<bfstart>2,%<bfend>2,0"
22ac2c2f
AK
3651 [(set_attr "op_type" "RIE")])
3652
963fc8d0
AK
3653(define_insn "*insv<mode>_z10_noshift"
3654 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3655 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
75ca1b39 3656 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
963fc8d0 3657 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
75ca1b39 3658 (match_operand:GPR 4 "const_int_operand" ""))))
963fc8d0 3659 (clobber (reg:CC CC_REGNUM))]
75ca1b39
RH
3660 "TARGET_Z10 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3661 "risbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
9381e3f1
WG
3662 [(set_attr "op_type" "RIE")
3663 (set_attr "z10prop" "z10_super_E1")])
963fc8d0 3664
571e408a 3665(define_insn "*r<noxa>sbg_<mode>_noshift"
963fc8d0 3666 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
571e408a
RH
3667 (IXOR:GPR
3668 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3669 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3670 (match_operand:GPR 3 "nonimmediate_operand" "0")))
963fc8d0 3671 (clobber (reg:CC CC_REGNUM))]
75ca1b39 3672 "TARGET_Z10"
571e408a
RH
3673 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
3674 [(set_attr "op_type" "RIE")])
3675
3676(define_insn "*r<noxa>sbg_di_rotl"
3677 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3678 (IXOR:DI
3679 (and:DI
3680 (rotate:DI
3681 (match_operand:DI 1 "nonimmediate_operand" "d")
3682 (match_operand:DI 3 "const_int_operand" ""))
3683 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
3684 (match_operand:DI 4 "nonimmediate_operand" "0")))
3685 (clobber (reg:CC CC_REGNUM))]
3686 "TARGET_Z10"
3687 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%b3"
3688 [(set_attr "op_type" "RIE")])
3689
3690(define_insn "*r<noxa>sbg_<mode>_srl"
3691 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3692 (IXOR:GPR
3693 (and:GPR
3694 (lshiftrt:GPR
3695 (match_operand:GPR 1 "nonimmediate_operand" "d")
3696 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
3697 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3698 (match_operand:GPR 4 "nonimmediate_operand" "0")))
3699 (clobber (reg:CC CC_REGNUM))]
3700 "TARGET_Z10
3701 && s390_extzv_shift_ok (<bitsize>, 64 - INTVAL (operands[3]),
3702 INTVAL (operands[2]))"
3703 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,64-%3"
3704 [(set_attr "op_type" "RIE")])
3705
3706(define_insn "*r<noxa>sbg_<mode>_sll"
3707 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3708 (IXOR:GPR
3709 (and:GPR
3710 (ashift:GPR
3711 (match_operand:GPR 1 "nonimmediate_operand" "d")
3712 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
3713 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3714 (match_operand:GPR 4 "nonimmediate_operand" "0")))
3715 (clobber (reg:CC CC_REGNUM))]
3716 "TARGET_Z10
3717 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[3]),
3718 INTVAL (operands[2]))"
3719 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%3"
963fc8d0
AK
3720 [(set_attr "op_type" "RIE")])
3721
5bb33936
RH
3722;; These two are generated by combine for s.bf &= val.
3723;; ??? For bitfields smaller than 32-bits, we wind up with SImode
3724;; shifts and ands, which results in some truly awful patterns
3725;; including subregs of operations. Rather unnecessisarily, IMO.
3726;; Instead of
3727;;
3728;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
3729;; (const_int 24 [0x18])
3730;; (const_int 0 [0]))
3731;; (subreg:DI (and:SI (subreg:SI (lshiftrt:DI (reg/v:DI 50 [ s ])
3732;; (const_int 40 [0x28])) 4)
3733;; (reg:SI 4 %r4 [ y+4 ])) 0))
3734;;
3735;; we should instead generate
3736;;
3737;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
3738;; (const_int 24 [0x18])
3739;; (const_int 0 [0]))
3740;; (and:DI (lshiftrt:DI (reg/v:DI 50 [ s ])
3741;; (const_int 40 [0x28]))
3742;; (subreg:DI (reg:SI 4 %r4 [ y+4 ]) 0)))
3743;;
3744;; by noticing that we can push down the outer paradoxical subreg
3745;; into the operation.
3746
3747(define_insn "*insv_rnsbg_noshift"
3748 [(set (zero_extract:DI
3749 (match_operand:DI 0 "nonimmediate_operand" "+d")
3750 (match_operand 1 "const_int_operand" "")
3751 (match_operand 2 "const_int_operand" ""))
3752 (and:DI
3753 (match_dup 0)
3754 (match_operand:DI 3 "nonimmediate_operand" "d")))
3755 (clobber (reg:CC CC_REGNUM))]
3756 "TARGET_Z10
3757 && INTVAL (operands[1]) + INTVAL (operands[2]) == 64"
3758 "rnsbg\t%0,%3,%2,63,0"
3759 [(set_attr "op_type" "RIE")])
3760
3761(define_insn "*insv_rnsbg_srl"
3762 [(set (zero_extract:DI
3763 (match_operand:DI 0 "nonimmediate_operand" "+d")
3764 (match_operand 1 "const_int_operand" "")
3765 (match_operand 2 "const_int_operand" ""))
3766 (and:DI
3767 (lshiftrt:DI
3768 (match_dup 0)
3769 (match_operand 3 "const_int_operand" ""))
3770 (match_operand:DI 4 "nonimmediate_operand" "d")))
3771 (clobber (reg:CC CC_REGNUM))]
3772 "TARGET_Z10
3773 && INTVAL (operands[3]) == 64 - INTVAL (operands[1]) - INTVAL (operands[2])"
3774 "rnsbg\t%0,%4,%2,%2+%1-1,%3"
3775 [(set_attr "op_type" "RIE")])
3776
6fa05db6 3777(define_insn "*insv<mode>_mem_reg"
9602b6a1 3778 [(set (zero_extract:W (match_operand:QI 0 "memory_operand" "+Q,S")
6fa05db6
AS
3779 (match_operand 1 "const_int_operand" "n,n")
3780 (const_int 0))
9602b6a1 3781 (match_operand:W 2 "register_operand" "d,d"))]
6fa05db6
AS
3782 "INTVAL (operands[1]) > 0
3783 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3784 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3785{
3786 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3787
3788 operands[1] = GEN_INT ((1ul << size) - 1);
9381e3f1 3789 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
6fa05db6
AS
3790 : "stcmy\t%2,%1,%S0";
3791}
9381e3f1
WG
3792 [(set_attr "op_type" "RS,RSY")
3793 (set_attr "z10prop" "z10_super,z10_super")])
6fa05db6
AS
3794
3795(define_insn "*insvdi_mem_reghigh"
3796 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+QS")
3797 (match_operand 1 "const_int_operand" "n")
3798 (const_int 0))
3799 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
3800 (const_int 32)))]
9602b6a1 3801 "TARGET_ZARCH
6fa05db6
AS
3802 && INTVAL (operands[1]) > 0
3803 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3804 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3805{
3806 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3807
3808 operands[1] = GEN_INT ((1ul << size) - 1);
3809 return "stcmh\t%2,%1,%S0";
3810}
9381e3f1
WG
3811[(set_attr "op_type" "RSY")
3812 (set_attr "z10prop" "z10_super")])
6fa05db6 3813
9602b6a1
AK
3814(define_insn "*insvdi_reg_imm"
3815 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3816 (const_int 16)
3817 (match_operand 1 "const_int_operand" "n"))
3818 (match_operand:DI 2 "const_int_operand" "n"))]
6fa05db6
AS
3819 "TARGET_ZARCH
3820 && INTVAL (operands[1]) >= 0
3821 && INTVAL (operands[1]) < BITS_PER_WORD
3822 && INTVAL (operands[1]) % 16 == 0"
3823{
3824 switch (BITS_PER_WORD - INTVAL (operands[1]))
3825 {
3826 case 64: return "iihh\t%0,%x2"; break;
3827 case 48: return "iihl\t%0,%x2"; break;
3828 case 32: return "iilh\t%0,%x2"; break;
3829 case 16: return "iill\t%0,%x2"; break;
3830 default: gcc_unreachable();
3831 }
3832}
9381e3f1
WG
3833 [(set_attr "op_type" "RI")
3834 (set_attr "z10prop" "z10_super_E1")])
3835
9fec758d
WG
3836; Update the left-most 32 bit of a DI.
3837(define_insn "*insv_h_di_reg_extimm"
3838 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3839 (const_int 32)
3840 (const_int 0))
3841 (match_operand:DI 1 "const_int_operand" "n"))]
3842 "TARGET_EXTIMM"
3843 "iihf\t%0,%o1"
3844 [(set_attr "op_type" "RIL")
3845 (set_attr "z10prop" "z10_fwd_E1")])
6fa05db6 3846
d378b983
RH
3847; Update the right-most 32 bit of a DI.
3848(define_insn "*insv_l_di_reg_extimm"
3849 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3850 (const_int 32)
3851 (const_int 32))
3852 (match_operand:DI 1 "const_int_operand" "n"))]
3853 "TARGET_EXTIMM"
3854 "iilf\t%0,%o1"
9381e3f1 3855 [(set_attr "op_type" "RIL")
9fec758d 3856 (set_attr "z10prop" "z10_fwd_A1")])
6fa05db6 3857
9db1d521
HP
3858;
3859; extendsidi2 instruction pattern(s).
3860;
3861
4023fb28
UW
3862(define_expand "extendsidi2"
3863 [(set (match_operand:DI 0 "register_operand" "")
3864 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3865 ""
4023fb28 3866{
9602b6a1 3867 if (!TARGET_ZARCH)
4023fb28 3868 {
c41c1387 3869 emit_clobber (operands[0]);
9f37ccb1
UW
3870 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
3871 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
3872 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
4023fb28
UW
3873 DONE;
3874 }
ec24698e 3875})
4023fb28
UW
3876
3877(define_insn "*extendsidi2"
963fc8d0
AK
3878 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3879 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
9602b6a1 3880 "TARGET_ZARCH"
9db1d521 3881 "@
d40c829f 3882 lgfr\t%0,%1
963fc8d0
AK
3883 lgf\t%0,%1
3884 lgfrl\t%0,%1"
3885 [(set_attr "op_type" "RRE,RXY,RIL")
3886 (set_attr "type" "*,*,larl")
9381e3f1
WG
3887 (set_attr "cpu_facility" "*,*,z10")
3888 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 3889
9db1d521 3890;
56477c21 3891; extend(hi|qi)(si|di)2 instruction pattern(s).
9db1d521
HP
3892;
3893
56477c21
AS
3894(define_expand "extend<HQI:mode><DSI:mode>2"
3895 [(set (match_operand:DSI 0 "register_operand" "")
3896 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4023fb28 3897 ""
4023fb28 3898{
9602b6a1 3899 if (<DSI:MODE>mode == DImode && !TARGET_ZARCH)
4023fb28
UW
3900 {
3901 rtx tmp = gen_reg_rtx (SImode);
56477c21 3902 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
4023fb28
UW
3903 emit_insn (gen_extendsidi2 (operands[0], tmp));
3904 DONE;
3905 }
ec24698e 3906 else if (!TARGET_EXTIMM)
4023fb28 3907 {
2542ef05 3908 rtx bitcount = GEN_INT (<DSI:bitsize> - <HQI:bitsize>);
56477c21
AS
3909
3910 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
3911 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
3912 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
4023fb28
UW
3913 DONE;
3914 }
ec24698e
UW
3915})
3916
56477c21
AS
3917;
3918; extendhidi2 instruction pattern(s).
3919;
3920
ec24698e 3921(define_insn "*extendhidi2_extimm"
963fc8d0
AK
3922 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3923 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,RT,b")))]
9602b6a1 3924 "TARGET_ZARCH && TARGET_EXTIMM"
ec24698e
UW
3925 "@
3926 lghr\t%0,%1
963fc8d0
AK
3927 lgh\t%0,%1
3928 lghrl\t%0,%1"
3929 [(set_attr "op_type" "RRE,RXY,RIL")
3930 (set_attr "type" "*,*,larl")
9381e3f1
WG
3931 (set_attr "cpu_facility" "extimm,extimm,z10")
3932 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4023fb28
UW
3933
3934(define_insn "*extendhidi2"
9db1d521 3935 [(set (match_operand:DI 0 "register_operand" "=d")
fb492564 3936 (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT")))]
9602b6a1 3937 "TARGET_ZARCH"
d40c829f 3938 "lgh\t%0,%1"
9381e3f1
WG
3939 [(set_attr "op_type" "RXY")
3940 (set_attr "z10prop" "z10_super_E1")])
9db1d521 3941
9db1d521 3942;
56477c21 3943; extendhisi2 instruction pattern(s).
9db1d521
HP
3944;
3945
ec24698e 3946(define_insn "*extendhisi2_extimm"
963fc8d0
AK
3947 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3948 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
ec24698e
UW
3949 "TARGET_EXTIMM"
3950 "@
3951 lhr\t%0,%1
3952 lh\t%0,%1
963fc8d0
AK
3953 lhy\t%0,%1
3954 lhrl\t%0,%1"
3955 [(set_attr "op_type" "RRE,RX,RXY,RIL")
3956 (set_attr "type" "*,*,*,larl")
9381e3f1
WG
3957 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
3958 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 3959
4023fb28 3960(define_insn "*extendhisi2"
d3632d41
UW
3961 [(set (match_operand:SI 0 "register_operand" "=d,d")
3962 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
ec24698e 3963 "!TARGET_EXTIMM"
d3632d41 3964 "@
d40c829f
UW
3965 lh\t%0,%1
3966 lhy\t%0,%1"
9381e3f1
WG
3967 [(set_attr "op_type" "RX,RXY")
3968 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
9db1d521 3969
56477c21
AS
3970;
3971; extendqi(si|di)2 instruction pattern(s).
3972;
3973
43a09b63 3974; lbr, lgbr, lb, lgb
56477c21
AS
3975(define_insn "*extendqi<mode>2_extimm"
3976 [(set (match_operand:GPR 0 "register_operand" "=d,d")
fb492564 3977 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,RT")))]
ec24698e
UW
3978 "TARGET_EXTIMM"
3979 "@
56477c21
AS
3980 l<g>br\t%0,%1
3981 l<g>b\t%0,%1"
9381e3f1
WG
3982 [(set_attr "op_type" "RRE,RXY")
3983 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
ec24698e 3984
43a09b63 3985; lb, lgb
56477c21
AS
3986(define_insn "*extendqi<mode>2"
3987 [(set (match_operand:GPR 0 "register_operand" "=d")
fb492564 3988 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "RT")))]
56477c21
AS
3989 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
3990 "l<g>b\t%0,%1"
9381e3f1
WG
3991 [(set_attr "op_type" "RXY")
3992 (set_attr "z10prop" "z10_super_E1")])
d3632d41 3993
56477c21
AS
3994(define_insn_and_split "*extendqi<mode>2_short_displ"
3995 [(set (match_operand:GPR 0 "register_operand" "=d")
3996 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
ae156f85 3997 (clobber (reg:CC CC_REGNUM))]
56477c21 3998 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
19796784
AK
3999 "#"
4000 "&& reload_completed"
4023fb28 4001 [(parallel
56477c21 4002 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
ae156f85 4003 (clobber (reg:CC CC_REGNUM))])
4023fb28 4004 (parallel
56477c21 4005 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
ae156f85 4006 (clobber (reg:CC CC_REGNUM))])]
6fa05db6
AS
4007{
4008 operands[1] = adjust_address (operands[1], BLKmode, 0);
f5541398 4009 set_mem_size (operands[1], GET_MODE_SIZE (QImode));
2542ef05 4010 operands[2] = GEN_INT (<GPR:bitsize> - BITS_PER_UNIT);
6fa05db6 4011})
9db1d521 4012
9db1d521
HP
4013;
4014; zero_extendsidi2 instruction pattern(s).
4015;
4016
4023fb28
UW
4017(define_expand "zero_extendsidi2"
4018 [(set (match_operand:DI 0 "register_operand" "")
4019 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
4020 ""
4023fb28 4021{
9602b6a1 4022 if (!TARGET_ZARCH)
4023fb28 4023 {
c41c1387 4024 emit_clobber (operands[0]);
9f37ccb1
UW
4025 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
4026 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
4023fb28
UW
4027 DONE;
4028 }
ec24698e 4029})
4023fb28
UW
4030
4031(define_insn "*zero_extendsidi2"
963fc8d0
AK
4032 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4033 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
9602b6a1 4034 "TARGET_ZARCH"
9db1d521 4035 "@
d40c829f 4036 llgfr\t%0,%1
963fc8d0
AK
4037 llgf\t%0,%1
4038 llgfrl\t%0,%1"
4039 [(set_attr "op_type" "RRE,RXY,RIL")
4040 (set_attr "type" "*,*,larl")
9381e3f1
WG
4041 (set_attr "cpu_facility" "*,*,z10")
4042 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
9db1d521 4043
288e517f
AK
4044;
4045; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
4046;
4047
d6083c7d
UW
4048(define_insn "*llgt_sidi"
4049 [(set (match_operand:DI 0 "register_operand" "=d")
fb492564 4050 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
d6083c7d 4051 (const_int 2147483647)))]
9602b6a1 4052 "TARGET_ZARCH"
d6083c7d 4053 "llgt\t%0,%1"
9381e3f1
WG
4054 [(set_attr "op_type" "RXE")
4055 (set_attr "z10prop" "z10_super_E1")])
d6083c7d
UW
4056
4057(define_insn_and_split "*llgt_sidi_split"
4058 [(set (match_operand:DI 0 "register_operand" "=d")
fb492564 4059 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
d6083c7d 4060 (const_int 2147483647)))
ae156f85 4061 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4062 "TARGET_ZARCH"
d6083c7d
UW
4063 "#"
4064 "&& reload_completed"
4065 [(set (match_dup 0)
4066 (and:DI (subreg:DI (match_dup 1) 0)
4067 (const_int 2147483647)))]
4068 "")
4069
288e517f
AK
4070(define_insn "*llgt_sisi"
4071 [(set (match_operand:SI 0 "register_operand" "=d,d")
fb492564 4072 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,RT")
288e517f 4073 (const_int 2147483647)))]
c4d50129 4074 "TARGET_ZARCH"
288e517f
AK
4075 "@
4076 llgtr\t%0,%1
4077 llgt\t%0,%1"
9381e3f1
WG
4078 [(set_attr "op_type" "RRE,RXE")
4079 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
288e517f 4080
288e517f
AK
4081(define_insn "*llgt_didi"
4082 [(set (match_operand:DI 0 "register_operand" "=d,d")
4083 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
4084 (const_int 2147483647)))]
9602b6a1 4085 "TARGET_ZARCH"
288e517f
AK
4086 "@
4087 llgtr\t%0,%1
4088 llgt\t%0,%N1"
9381e3f1
WG
4089 [(set_attr "op_type" "RRE,RXE")
4090 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
288e517f 4091
f19a9af7 4092(define_split
9602b6a1
AK
4093 [(set (match_operand:DSI 0 "register_operand" "")
4094 (and:DSI (match_operand:DSI 1 "nonimmediate_operand" "")
f6ee577c 4095 (const_int 2147483647)))
ae156f85 4096 (clobber (reg:CC CC_REGNUM))]
c4d50129 4097 "TARGET_ZARCH && reload_completed"
288e517f 4098 [(set (match_dup 0)
9602b6a1 4099 (and:DSI (match_dup 1)
f6ee577c 4100 (const_int 2147483647)))]
288e517f
AK
4101 "")
4102
9db1d521 4103;
56477c21 4104; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
9db1d521
HP
4105;
4106
56477c21
AS
4107(define_expand "zero_extend<mode>di2"
4108 [(set (match_operand:DI 0 "register_operand" "")
4109 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4110 ""
4111{
9602b6a1 4112 if (!TARGET_ZARCH)
56477c21
AS
4113 {
4114 rtx tmp = gen_reg_rtx (SImode);
4115 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
4116 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
4117 DONE;
4118 }
4119 else if (!TARGET_EXTIMM)
4120 {
2542ef05 4121 rtx bitcount = GEN_INT (64 - <HQI:bitsize>);
56477c21
AS
4122 operands[1] = gen_lowpart (DImode, operands[1]);
4123 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
4124 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
4125 DONE;
4126 }
4127})
4128
f6ee577c 4129(define_expand "zero_extend<mode>si2"
4023fb28 4130 [(set (match_operand:SI 0 "register_operand" "")
ec24698e 4131 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
9db1d521 4132 ""
4023fb28 4133{
ec24698e
UW
4134 if (!TARGET_EXTIMM)
4135 {
4136 operands[1] = gen_lowpart (SImode, operands[1]);
9381e3f1 4137 emit_insn (gen_andsi3 (operands[0], operands[1],
2542ef05 4138 GEN_INT ((1 << <HQI:bitsize>) - 1)));
ec24698e 4139 DONE;
56477c21 4140 }
ec24698e
UW
4141})
4142
963fc8d0
AK
4143; llhrl, llghrl
4144(define_insn "*zero_extendhi<mode>2_z10"
4145 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
4146 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,RT,b")))]
4147 "TARGET_Z10"
4148 "@
4149 ll<g>hr\t%0,%1
4150 ll<g>h\t%0,%1
4151 ll<g>hrl\t%0,%1"
4152 [(set_attr "op_type" "RXY,RRE,RIL")
4153 (set_attr "type" "*,*,larl")
9381e3f1 4154 (set_attr "cpu_facility" "*,*,z10")
729e750f 4155 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
963fc8d0 4156
43a09b63 4157; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
56477c21
AS
4158(define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
4159 [(set (match_operand:GPR 0 "register_operand" "=d,d")
fb492564 4160 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,RT")))]
ec24698e
UW
4161 "TARGET_EXTIMM"
4162 "@
56477c21
AS
4163 ll<g><hc>r\t%0,%1
4164 ll<g><hc>\t%0,%1"
9381e3f1
WG
4165 [(set_attr "op_type" "RRE,RXY")
4166 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
9db1d521 4167
43a09b63 4168; llgh, llgc
56477c21
AS
4169(define_insn "*zero_extend<HQI:mode><GPR:mode>2"
4170 [(set (match_operand:GPR 0 "register_operand" "=d")
fb492564 4171 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "RT")))]
ec24698e 4172 "TARGET_ZARCH && !TARGET_EXTIMM"
f6ee577c 4173 "llg<hc>\t%0,%1"
9381e3f1
WG
4174 [(set_attr "op_type" "RXY")
4175 (set_attr "z10prop" "z10_fwd_A3")])
cc7ab9b7
UW
4176
4177(define_insn_and_split "*zero_extendhisi2_31"
4178 [(set (match_operand:SI 0 "register_operand" "=&d")
02ed3c5e 4179 (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
ae156f85 4180 (clobber (reg:CC CC_REGNUM))]
f4f41b4e 4181 "!TARGET_ZARCH"
cc7ab9b7
UW
4182 "#"
4183 "&& reload_completed"
4184 [(set (match_dup 0) (const_int 0))
4185 (parallel
4186 [(set (strict_low_part (match_dup 2)) (match_dup 1))
ae156f85 4187 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 4188 "operands[2] = gen_lowpart (HImode, operands[0]);")
c7453384 4189
cc7ab9b7
UW
4190(define_insn_and_split "*zero_extendqisi2_31"
4191 [(set (match_operand:SI 0 "register_operand" "=&d")
fb492564 4192 (zero_extend:SI (match_operand:QI 1 "memory_operand" "RT")))]
9e8327e3 4193 "!TARGET_ZARCH"
cc7ab9b7
UW
4194 "#"
4195 "&& reload_completed"
4196 [(set (match_dup 0) (const_int 0))
4197 (set (strict_low_part (match_dup 2)) (match_dup 1))]
b628bd8e 4198 "operands[2] = gen_lowpart (QImode, operands[0]);")
c7453384 4199
9db1d521
HP
4200;
4201; zero_extendqihi2 instruction pattern(s).
4202;
4203
9db1d521
HP
4204(define_expand "zero_extendqihi2"
4205 [(set (match_operand:HI 0 "register_operand" "")
4023fb28 4206 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
ec24698e 4207 "TARGET_ZARCH && !TARGET_EXTIMM"
9db1d521 4208{
4023fb28
UW
4209 operands[1] = gen_lowpart (HImode, operands[1]);
4210 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
4211 DONE;
ec24698e 4212})
9db1d521 4213
4023fb28 4214(define_insn "*zero_extendqihi2_64"
9db1d521 4215 [(set (match_operand:HI 0 "register_operand" "=d")
fb492564 4216 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
ec24698e 4217 "TARGET_ZARCH && !TARGET_EXTIMM"
d40c829f 4218 "llgc\t%0,%1"
9381e3f1
WG
4219 [(set_attr "op_type" "RXY")
4220 (set_attr "z10prop" "z10_fwd_A3")])
9db1d521 4221
cc7ab9b7
UW
4222(define_insn_and_split "*zero_extendqihi2_31"
4223 [(set (match_operand:HI 0 "register_operand" "=&d")
fb492564 4224 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
9e8327e3 4225 "!TARGET_ZARCH"
cc7ab9b7
UW
4226 "#"
4227 "&& reload_completed"
4228 [(set (match_dup 0) (const_int 0))
4229 (set (strict_low_part (match_dup 2)) (match_dup 1))]
b628bd8e 4230 "operands[2] = gen_lowpart (QImode, operands[0]);")
cc7ab9b7 4231
609e7e80
AK
4232;
4233; fixuns_trunc(dd|td)di2 instruction pattern(s).
4234;
4235
4236(define_expand "fixuns_truncdddi2"
4237 [(parallel
4238 [(set (match_operand:DI 0 "register_operand" "")
4239 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
65b1d8ea
AK
4240 (unspec:DI [(const_int 5)] UNSPEC_ROUND)
4241 (clobber (reg:CC CC_REGNUM))])]
9381e3f1 4242
fb068247 4243 "TARGET_HARD_DFP"
609e7e80 4244{
65b1d8ea
AK
4245 if (!TARGET_Z196)
4246 {
19f8b229
TS
4247 rtx_code_label *label1 = gen_label_rtx ();
4248 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4249 rtx temp = gen_reg_rtx (TDmode);
4250 REAL_VALUE_TYPE cmp, sub;
4251
4252 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4253 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4254
4255 /* 2^63 can't be represented as 64bit DFP number with full precision. The
4256 solution is doing the check and the subtraction in TD mode and using a
4257 TD -> DI convert afterwards. */
4258 emit_insn (gen_extendddtd2 (temp, operands[1]));
4259 temp = force_reg (TDmode, temp);
4260 emit_cmp_and_jump_insns (temp,
4261 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode),
4262 LT, NULL_RTX, VOIDmode, 0, label1);
4263 emit_insn (gen_subtd3 (temp, temp,
4264 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
4265 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
4266 emit_jump (label2);
4267
4268 emit_label (label1);
4269 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1], GEN_INT (9)));
4270 emit_label (label2);
4271 DONE;
4272 }
609e7e80
AK
4273})
4274
4275(define_expand "fixuns_trunctddi2"
65b1d8ea
AK
4276 [(parallel
4277 [(set (match_operand:DI 0 "register_operand" "")
4278 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))
4279 (unspec:DI [(const_int 5)] UNSPEC_ROUND)
4280 (clobber (reg:CC CC_REGNUM))])]
4281
fb068247 4282 "TARGET_HARD_DFP"
609e7e80 4283{
65b1d8ea
AK
4284 if (!TARGET_Z196)
4285 {
19f8b229
TS
4286 rtx_code_label *label1 = gen_label_rtx ();
4287 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4288 rtx temp = gen_reg_rtx (TDmode);
4289 REAL_VALUE_TYPE cmp, sub;
4290
4291 operands[1] = force_reg (TDmode, operands[1]);
4292 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4293 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4294
4295 emit_cmp_and_jump_insns (operands[1],
4296 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode),
4297 LT, NULL_RTX, VOIDmode, 0, label1);
4298 emit_insn (gen_subtd3 (temp, operands[1],
4299 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
4300 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
4301 emit_jump (label2);
4302
4303 emit_label (label1);
4304 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1], GEN_INT (9)));
4305 emit_label (label2);
4306 DONE;
4307 }
609e7e80 4308})
cc7ab9b7 4309
9db1d521 4310;
65b1d8ea 4311; fixuns_trunc(sf|df|tf)(si|di)2 and fix_trunc(sf|df|tf)(si|di)2
609e7e80 4312; instruction pattern(s).
9db1d521
HP
4313;
4314
7b6baae1 4315(define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
65b1d8ea
AK
4316 [(parallel
4317 [(set (match_operand:GPR 0 "register_operand" "")
4318 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))
4319 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
4320 (clobber (reg:CC CC_REGNUM))])]
142cd70f 4321 "TARGET_HARD_FLOAT"
9db1d521 4322{
65b1d8ea
AK
4323 if (!TARGET_Z196)
4324 {
19f8b229
TS
4325 rtx_code_label *label1 = gen_label_rtx ();
4326 rtx_code_label *label2 = gen_label_rtx ();
65b1d8ea
AK
4327 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
4328 REAL_VALUE_TYPE cmp, sub;
4329
4330 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
2542ef05
RH
4331 real_2expN (&cmp, <GPR:bitsize> - 1, <BFP:MODE>mode);
4332 real_2expN (&sub, <GPR:bitsize>, <BFP:MODE>mode);
65b1d8ea
AK
4333
4334 emit_cmp_and_jump_insns (operands[1],
4335 CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode),
4336 LT, NULL_RTX, VOIDmode, 0, label1);
4337 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
4338 CONST_DOUBLE_FROM_REAL_VALUE (sub, <BFP:MODE>mode)));
4339 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
4340 GEN_INT (7)));
4341 emit_jump (label2);
4342
4343 emit_label (label1);
4344 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
4345 operands[1], GEN_INT (5)));
4346 emit_label (label2);
4347 DONE;
4348 }
10bbf137 4349})
9db1d521 4350
65b1d8ea
AK
4351; fixuns_trunc(td|dd)si2 expander
4352(define_expand "fixuns_trunc<mode>si2"
4353 [(parallel
4354 [(set (match_operand:SI 0 "register_operand" "")
4355 (unsigned_fix:SI (match_operand:DFP 1 "register_operand" "")))
4356 (unspec:SI [(const_int 5)] UNSPEC_ROUND)
4357 (clobber (reg:CC CC_REGNUM))])]
8540e6e8 4358 "TARGET_Z196 && TARGET_HARD_DFP"
65b1d8ea
AK
4359 "")
4360
4361; fixuns_trunc(tf|df|sf|td|dd)(di|si)2 instruction patterns.
4362
4363; clfebr, clfdbr, clfxbr, clgebr, clgdbr, clgxbr
4364; clfdtr, clfxtr, clgdtr, clgxtr
4365(define_insn "*fixuns_trunc<FP:mode><GPR:mode>2_z196"
4366 [(set (match_operand:GPR 0 "register_operand" "=r")
4367 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "f")))
4368 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4369 (clobber (reg:CC CC_REGNUM))]
4370 "TARGET_Z196"
4371 "cl<GPR:gf><FP:xde><FP:bt>r\t%0,%h2,%1,0"
4372 [(set_attr "op_type" "RRF")
4373 (set_attr "type" "ftoi")])
4374
b60cb710
AK
4375(define_expand "fix_trunc<DSF:mode><GPR:mode>2"
4376 [(set (match_operand:GPR 0 "register_operand" "")
4377 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
4378 "TARGET_HARD_FLOAT"
9db1d521 4379{
b60cb710
AK
4380 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
4381 GEN_INT (5)));
9db1d521 4382 DONE;
10bbf137 4383})
9db1d521 4384
43a09b63 4385; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
142cd70f 4386(define_insn "fix_trunc<BFP:mode><GPR:mode>2_bfp"
2f8f8434 4387 [(set (match_operand:GPR 0 "register_operand" "=d")
7b6baae1 4388 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
2f8f8434 4389 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
ae156f85 4390 (clobber (reg:CC CC_REGNUM))]
142cd70f 4391 "TARGET_HARD_FLOAT"
7b6baae1 4392 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
9db1d521 4393 [(set_attr "op_type" "RRE")
077dab3b 4394 (set_attr "type" "ftoi")])
9db1d521 4395
609e7e80
AK
4396
4397;
4398; fix_trunc(td|dd)di2 instruction pattern(s).
4399;
4400
99cd7dd0
AK
4401(define_expand "fix_trunc<mode>di2"
4402 [(set (match_operand:DI 0 "register_operand" "")
4403 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
9602b6a1 4404 "TARGET_ZARCH && TARGET_HARD_DFP"
99cd7dd0
AK
4405{
4406 operands[1] = force_reg (<MODE>mode, operands[1]);
4407 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
4408 GEN_INT (9)));
4409 DONE;
4410})
4411
609e7e80 4412; cgxtr, cgdtr
99cd7dd0 4413(define_insn "fix_trunc<DFP:mode>di2_dfp"
609e7e80
AK
4414 [(set (match_operand:DI 0 "register_operand" "=d")
4415 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
4416 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
4417 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4418 "TARGET_ZARCH && TARGET_HARD_DFP"
609e7e80
AK
4419 "cg<DFP:xde>tr\t%0,%h2,%1"
4420 [(set_attr "op_type" "RRF")
9381e3f1 4421 (set_attr "type" "ftoidfp")])
609e7e80
AK
4422
4423
f61a2c7d
AK
4424;
4425; fix_trunctf(si|di)2 instruction pattern(s).
4426;
4427
4428(define_expand "fix_trunctf<mode>2"
4429 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
4430 (fix:GPR (match_operand:TF 1 "register_operand" "")))
4431 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
4432 (clobber (reg:CC CC_REGNUM))])]
9db1d521 4433 "TARGET_HARD_FLOAT"
142cd70f 4434 "")
9db1d521 4435
9db1d521 4436
9db1d521 4437;
142cd70f 4438; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
9db1d521
HP
4439;
4440
609e7e80 4441; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
f5905b37 4442(define_insn "floatdi<mode>2"
609e7e80
AK
4443 [(set (match_operand:FP 0 "register_operand" "=f")
4444 (float:FP (match_operand:DI 1 "register_operand" "d")))]
9602b6a1 4445 "TARGET_ZARCH && TARGET_HARD_FLOAT"
609e7e80 4446 "c<xde>g<bt>r\t%0,%1"
9db1d521 4447 [(set_attr "op_type" "RRE")
9381e3f1 4448 (set_attr "type" "itof<mode>" )])
9db1d521 4449
43a09b63 4450; cxfbr, cdfbr, cefbr
142cd70f 4451(define_insn "floatsi<mode>2"
7b6baae1
AK
4452 [(set (match_operand:BFP 0 "register_operand" "=f")
4453 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
142cd70f 4454 "TARGET_HARD_FLOAT"
f61a2c7d
AK
4455 "c<xde>fbr\t%0,%1"
4456 [(set_attr "op_type" "RRE")
9381e3f1 4457 (set_attr "type" "itof<mode>" )])
f61a2c7d 4458
65b1d8ea
AK
4459; cxftr, cdftr
4460(define_insn "floatsi<mode>2"
4461 [(set (match_operand:DFP 0 "register_operand" "=f")
4462 (float:DFP (match_operand:SI 1 "register_operand" "d")))]
4463 "TARGET_Z196 && TARGET_HARD_FLOAT"
4464 "c<xde>ftr\t%0,0,%1,0"
4465 [(set_attr "op_type" "RRE")
4466 (set_attr "type" "itof<mode>" )])
4467
4468;
4469; floatuns(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
4470;
4471
4472; cxlgbr, cdlgbr, celgbr, cxlgtr, cdlgtr
4473; cxlfbr, cdlfbr, celfbr, cxlftr, cdlftr
4474(define_insn "floatuns<GPR:mode><FP:mode>2"
4475 [(set (match_operand:FP 0 "register_operand" "=f")
4476 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "d")))]
4477 "TARGET_Z196 && TARGET_HARD_FLOAT"
4478 "c<FP:xde>l<GPR:gf><FP:bt>r\t%0,0,%1,0"
4479 [(set_attr "op_type" "RRE")
4480 (set_attr "type" "itof<FP:mode>" )])
f61a2c7d 4481
9db1d521
HP
4482;
4483; truncdfsf2 instruction pattern(s).
4484;
4485
142cd70f 4486(define_insn "truncdfsf2"
9db1d521 4487 [(set (match_operand:SF 0 "register_operand" "=f")
a036c6f7 4488 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
142cd70f 4489 "TARGET_HARD_FLOAT"
d40c829f 4490 "ledbr\t%0,%1"
f61a2c7d
AK
4491 [(set_attr "op_type" "RRE")
4492 (set_attr "type" "ftruncdf")])
9db1d521 4493
f61a2c7d 4494;
142cd70f 4495; trunctf(df|sf)2 instruction pattern(s).
f61a2c7d
AK
4496;
4497
142cd70f
AK
4498; ldxbr, lexbr
4499(define_insn "trunctf<mode>2"
4500 [(set (match_operand:DSF 0 "register_operand" "=f")
4501 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
f61a2c7d 4502 (clobber (match_scratch:TF 2 "=f"))]
142cd70f
AK
4503 "TARGET_HARD_FLOAT"
4504 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
f61a2c7d 4505 [(set_attr "length" "6")
9381e3f1 4506 (set_attr "type" "ftrunctf")])
f61a2c7d 4507
609e7e80
AK
4508;
4509; trunctddd2 and truncddsd2 instruction pattern(s).
4510;
4511
4512(define_insn "trunctddd2"
4513 [(set (match_operand:DD 0 "register_operand" "=f")
bf259a77
AK
4514 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
4515 (clobber (match_scratch:TD 2 "=f"))]
fb068247 4516 "TARGET_HARD_DFP"
bf259a77
AK
4517 "ldxtr\t%2,0,%1,0\;ldr\t%0,%2"
4518 [(set_attr "length" "6")
9381e3f1 4519 (set_attr "type" "ftruncdd")])
609e7e80
AK
4520
4521(define_insn "truncddsd2"
4522 [(set (match_operand:SD 0 "register_operand" "=f")
4523 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
fb068247 4524 "TARGET_HARD_DFP"
609e7e80
AK
4525 "ledtr\t%0,0,%1,0"
4526 [(set_attr "op_type" "RRF")
9381e3f1 4527 (set_attr "type" "ftruncsd")])
609e7e80 4528
feade5a8
AK
4529(define_expand "trunctdsd2"
4530 [(parallel
4531 [(set (match_dup 3)
4532 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
4533 (clobber (match_scratch:TD 2 ""))])
4534 (set (match_operand:SD 0 "register_operand" "")
4535 (float_truncate:SD (match_dup 3)))]
4536 "TARGET_HARD_DFP"
4537{
4538 operands[3] = gen_reg_rtx (DDmode);
4539})
4540
9db1d521 4541;
142cd70f 4542; extend(sf|df)(df|tf)2 instruction pattern(s).
f61a2c7d
AK
4543;
4544
142cd70f
AK
4545; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
4546(define_insn "extend<DSF:mode><BFP:mode>2"
4547 [(set (match_operand:BFP 0 "register_operand" "=f,f")
4548 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
4549 "TARGET_HARD_FLOAT
4550 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)"
f61a2c7d 4551 "@
142cd70f
AK
4552 l<BFP:xde><DSF:xde>br\t%0,%1
4553 l<BFP:xde><DSF:xde>b\t%0,%1"
f61a2c7d 4554 [(set_attr "op_type" "RRE,RXE")
142cd70f 4555 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
f61a2c7d 4556
609e7e80
AK
4557;
4558; extendddtd2 and extendsddd2 instruction pattern(s).
4559;
4560
4561(define_insn "extendddtd2"
4562 [(set (match_operand:TD 0 "register_operand" "=f")
4563 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
fb068247 4564 "TARGET_HARD_DFP"
609e7e80
AK
4565 "lxdtr\t%0,%1,0"
4566 [(set_attr "op_type" "RRF")
4567 (set_attr "type" "fsimptf")])
4568
4569(define_insn "extendsddd2"
4570 [(set (match_operand:DD 0 "register_operand" "=f")
4571 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
fb068247 4572 "TARGET_HARD_DFP"
609e7e80
AK
4573 "ldetr\t%0,%1,0"
4574 [(set_attr "op_type" "RRF")
4575 (set_attr "type" "fsimptf")])
9db1d521 4576
feade5a8
AK
4577(define_expand "extendsdtd2"
4578 [(set (match_dup 2)
4579 (float_extend:DD (match_operand:SD 1 "register_operand" "")))
4580 (set (match_operand:TD 0 "register_operand" "")
4581 (float_extend:TD (match_dup 2)))]
4582 "TARGET_HARD_DFP"
4583{
4584 operands[2] = gen_reg_rtx (DDmode);
4585})
4586
d12a76f3
AK
4587; Binary Floating Point - load fp integer
4588
4589; Expanders for: floor, btrunc, round, ceil, and nearbyint
4590; For all of them the inexact exceptions are suppressed.
4591
4592; fiebra, fidbra, fixbra
4593(define_insn "<FPINT:fpint_name><BFP:mode>2"
4594 [(set (match_operand:BFP 0 "register_operand" "=f")
4595 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
4596 FPINT))]
4597 "TARGET_Z196"
4598 "fi<BFP:xde>bra\t%0,<FPINT:fpint_roundingmode>,%1,4"
4599 [(set_attr "op_type" "RRF")
4600 (set_attr "type" "fsimp<BFP:mode>")])
4601
4602; rint is supposed to raise an inexact exception so we can use the
4603; older instructions.
4604
4605; fiebr, fidbr, fixbr
4606(define_insn "rint<BFP:mode>2"
4607 [(set (match_operand:BFP 0 "register_operand" "=f")
4608 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
4609 UNSPEC_FPINT_RINT))]
4610 ""
4611 "fi<BFP:xde>br\t%0,0,%1"
4612 [(set_attr "op_type" "RRF")
4613 (set_attr "type" "fsimp<BFP:mode>")])
4614
4615
4616; Decimal Floating Point - load fp integer
4617
4618; fidtr, fixtr
4619(define_insn "<FPINT:fpint_name><DFP:mode>2"
4620 [(set (match_operand:DFP 0 "register_operand" "=f")
4621 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
4622 FPINT))]
4623 "TARGET_HARD_DFP"
4624 "fi<DFP:xde>tr\t%0,<FPINT:fpint_roundingmode>,%1,4"
4625 [(set_attr "op_type" "RRF")
4626 (set_attr "type" "fsimp<DFP:mode>")])
4627
4628; fidtr, fixtr
4629(define_insn "rint<DFP:mode>2"
4630 [(set (match_operand:DFP 0 "register_operand" "=f")
4631 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
4632 UNSPEC_FPINT_RINT))]
4633 "TARGET_HARD_DFP"
4634 "fi<DFP:xde>tr\t%0,0,%1,0"
4635 [(set_attr "op_type" "RRF")
4636 (set_attr "type" "fsimp<DFP:mode>")])
4637
4638;
35dd9a0e
AK
4639; Binary <-> Decimal floating point trunc patterns
4640;
4641
4642(define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
4643 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 4644 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e
AK
4645 (use (reg:SI GPR0_REGNUM))
4646 (clobber (reg:CC CC_REGNUM))]
fb068247 4647 "TARGET_HARD_DFP"
35dd9a0e
AK
4648 "pfpo")
4649
4650(define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
4651 [(set (reg:BFP FPR0_REGNUM)
2cf4c39e 4652 (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e
AK
4653 (use (reg:SI GPR0_REGNUM))
4654 (clobber (reg:CC CC_REGNUM))]
fb068247 4655 "TARGET_HARD_DFP"
35dd9a0e
AK
4656 "pfpo")
4657
4658(define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 4659 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
35dd9a0e
AK
4660 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4661 (parallel
4662 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 4663 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e
AK
4664 (use (reg:SI GPR0_REGNUM))
4665 (clobber (reg:CC CC_REGNUM))])
4666 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4667 (reg:DFP_ALL FPR0_REGNUM))]
fb068247 4668 "TARGET_HARD_DFP
35dd9a0e
AK
4669 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4670{
4671 HOST_WIDE_INT flags;
4672
4673 flags = (PFPO_CONVERT |
4674 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4675 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4676
4677 operands[2] = GEN_INT (flags);
4678})
4679
4680(define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 4681 [(set (reg:DFP_ALL FPR4_REGNUM)
35dd9a0e
AK
4682 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4683 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4684 (parallel
2cf4c39e 4685 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e
AK
4686 (use (reg:SI GPR0_REGNUM))
4687 (clobber (reg:CC CC_REGNUM))])
4688 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
fb068247 4689 "TARGET_HARD_DFP
35dd9a0e
AK
4690 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
4691{
4692 HOST_WIDE_INT flags;
4693
4694 flags = (PFPO_CONVERT |
4695 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4696 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4697
4698 operands[2] = GEN_INT (flags);
4699})
4700
4701;
4702; Binary <-> Decimal floating point extend patterns
4703;
4704
4705(define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 4706 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e
AK
4707 (use (reg:SI GPR0_REGNUM))
4708 (clobber (reg:CC CC_REGNUM))]
fb068247 4709 "TARGET_HARD_DFP"
35dd9a0e
AK
4710 "pfpo")
4711
4712(define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 4713 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e
AK
4714 (use (reg:SI GPR0_REGNUM))
4715 (clobber (reg:CC CC_REGNUM))]
fb068247 4716 "TARGET_HARD_DFP"
35dd9a0e
AK
4717 "pfpo")
4718
4719(define_expand "extend<BFP:mode><DFP_ALL:mode>2"
2cf4c39e 4720 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
35dd9a0e
AK
4721 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4722 (parallel
4723 [(set (reg:DFP_ALL FPR0_REGNUM)
2cf4c39e 4724 (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
35dd9a0e
AK
4725 (use (reg:SI GPR0_REGNUM))
4726 (clobber (reg:CC CC_REGNUM))])
4727 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4728 (reg:DFP_ALL FPR0_REGNUM))]
fb068247 4729 "TARGET_HARD_DFP
35dd9a0e
AK
4730 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4731{
4732 HOST_WIDE_INT flags;
4733
4734 flags = (PFPO_CONVERT |
4735 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4736 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4737
4738 operands[2] = GEN_INT (flags);
4739})
4740
4741(define_expand "extend<DFP_ALL:mode><BFP:mode>2"
2cf4c39e 4742 [(set (reg:DFP_ALL FPR4_REGNUM)
35dd9a0e
AK
4743 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4744 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4745 (parallel
2cf4c39e 4746 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
35dd9a0e
AK
4747 (use (reg:SI GPR0_REGNUM))
4748 (clobber (reg:CC CC_REGNUM))])
4749 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
fb068247 4750 "TARGET_HARD_DFP
35dd9a0e
AK
4751 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
4752{
4753 HOST_WIDE_INT flags;
4754
4755 flags = (PFPO_CONVERT |
4756 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4757 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4758
4759 operands[2] = GEN_INT (flags);
4760})
4761
4762
9db1d521 4763;;
fae778eb 4764;; ARITHMETIC OPERATIONS
9db1d521 4765;;
fae778eb 4766; arithmetic operations set the ConditionCode,
9db1d521
HP
4767; because of unpredictable Bits in Register for Halfword and Byte
4768; the ConditionCode can be set wrong in operations for Halfword and Byte
4769
07893d4f
UW
4770;;
4771;;- Add instructions.
4772;;
4773
1c7b1b7e
UW
4774;
4775; addti3 instruction pattern(s).
4776;
4777
085261c8
AK
4778(define_expand "addti3"
4779 [(parallel
4780 [(set (match_operand:TI 0 "register_operand" "")
4781 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "")
4782 (match_operand:TI 2 "general_operand" "") ) )
4783 (clobber (reg:CC CC_REGNUM))])]
4784 "TARGET_ZARCH"
4785{
4786 /* For z13 we have vaq which doesn't set CC. */
4787 if (TARGET_VX)
4788 {
4789 emit_insn (gen_rtx_SET (operands[0],
4790 gen_rtx_PLUS (TImode,
4791 copy_to_mode_reg (TImode, operands[1]),
4792 copy_to_mode_reg (TImode, operands[2]))));
4793 DONE;
4794 }
4795})
4796
4797(define_insn_and_split "*addti3"
4798 [(set (match_operand:TI 0 "register_operand" "=&d")
1c7b1b7e 4799 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
085261c8 4800 (match_operand:TI 2 "general_operand" "do") ) )
ae156f85 4801 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4802 "TARGET_ZARCH"
1c7b1b7e
UW
4803 "#"
4804 "&& reload_completed"
4805 [(parallel
ae156f85 4806 [(set (reg:CCL1 CC_REGNUM)
1c7b1b7e
UW
4807 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
4808 (match_dup 7)))
4809 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
4810 (parallel
a94a76a7
UW
4811 [(set (match_dup 3) (plus:DI
4812 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
4813 (match_dup 4)) (match_dup 5)))
ae156f85 4814 (clobber (reg:CC CC_REGNUM))])]
1c7b1b7e
UW
4815 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4816 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4817 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4818 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4819 operands[7] = operand_subword (operands[1], 1, 0, TImode);
085261c8
AK
4820 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
4821 [(set_attr "op_type" "*")
4822 (set_attr "cpu_facility" "*")])
1c7b1b7e 4823
07893d4f
UW
4824;
4825; adddi3 instruction pattern(s).
4826;
4827
3298c037
AK
4828(define_expand "adddi3"
4829 [(parallel
963fc8d0 4830 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3298c037
AK
4831 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4832 (match_operand:DI 2 "general_operand" "")))
4833 (clobber (reg:CC CC_REGNUM))])]
4834 ""
4835 "")
4836
07893d4f
UW
4837(define_insn "*adddi3_sign"
4838 [(set (match_operand:DI 0 "register_operand" "=d,d")
fb492564 4839 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
07893d4f 4840 (match_operand:DI 1 "register_operand" "0,0")))
ae156f85 4841 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4842 "TARGET_ZARCH"
07893d4f 4843 "@
d40c829f
UW
4844 agfr\t%0,%2
4845 agf\t%0,%2"
65b1d8ea
AK
4846 [(set_attr "op_type" "RRE,RXY")
4847 (set_attr "z196prop" "z196_cracked,z196_cracked")])
07893d4f
UW
4848
4849(define_insn "*adddi3_zero_cc"
ae156f85 4850 [(set (reg CC_REGNUM)
fb492564 4851 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
07893d4f
UW
4852 (match_operand:DI 1 "register_operand" "0,0"))
4853 (const_int 0)))
4854 (set (match_operand:DI 0 "register_operand" "=d,d")
4855 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
9602b6a1 4856 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 4857 "@
d40c829f
UW
4858 algfr\t%0,%2
4859 algf\t%0,%2"
9381e3f1
WG
4860 [(set_attr "op_type" "RRE,RXY")
4861 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f
UW
4862
4863(define_insn "*adddi3_zero_cconly"
ae156f85 4864 [(set (reg CC_REGNUM)
fb492564 4865 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
07893d4f
UW
4866 (match_operand:DI 1 "register_operand" "0,0"))
4867 (const_int 0)))
4868 (clobber (match_scratch:DI 0 "=d,d"))]
9602b6a1 4869 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 4870 "@
d40c829f
UW
4871 algfr\t%0,%2
4872 algf\t%0,%2"
9381e3f1
WG
4873 [(set_attr "op_type" "RRE,RXY")
4874 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f
UW
4875
4876(define_insn "*adddi3_zero"
4877 [(set (match_operand:DI 0 "register_operand" "=d,d")
fb492564 4878 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
07893d4f 4879 (match_operand:DI 1 "register_operand" "0,0")))
ae156f85 4880 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4881 "TARGET_ZARCH"
07893d4f 4882 "@
d40c829f
UW
4883 algfr\t%0,%2
4884 algf\t%0,%2"
9381e3f1
WG
4885 [(set_attr "op_type" "RRE,RXY")
4886 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
07893d4f 4887
e69166de 4888(define_insn_and_split "*adddi3_31z"
963fc8d0 4889 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
e69166de
UW
4890 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4891 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 4892 (clobber (reg:CC CC_REGNUM))]
9602b6a1 4893 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
e69166de
UW
4894 "#"
4895 "&& reload_completed"
4896 [(parallel
ae156f85 4897 [(set (reg:CCL1 CC_REGNUM)
e69166de
UW
4898 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4899 (match_dup 7)))
4900 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4901 (parallel
a94a76a7
UW
4902 [(set (match_dup 3) (plus:SI
4903 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
4904 (match_dup 4)) (match_dup 5)))
ae156f85 4905 (clobber (reg:CC CC_REGNUM))])]
e69166de
UW
4906 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4907 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4908 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4909 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4910 operands[7] = operand_subword (operands[1], 1, 0, DImode);
b628bd8e 4911 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
e69166de 4912
07893d4f 4913(define_insn_and_split "*adddi3_31"
963fc8d0 4914 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
96fd3851 4915 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
97c6f7ad 4916 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 4917 (clobber (reg:CC CC_REGNUM))]
e69166de 4918 "!TARGET_CPU_ZARCH"
07893d4f
UW
4919 "#"
4920 "&& reload_completed"
4921 [(parallel
4922 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
ae156f85 4923 (clobber (reg:CC CC_REGNUM))])
07893d4f 4924 (parallel
ae156f85 4925 [(set (reg:CCL1 CC_REGNUM)
07893d4f
UW
4926 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4927 (match_dup 7)))
4928 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4929 (set (pc)
ae156f85 4930 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
07893d4f
UW
4931 (pc)
4932 (label_ref (match_dup 9))))
4933 (parallel
4934 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
ae156f85 4935 (clobber (reg:CC CC_REGNUM))])
07893d4f 4936 (match_dup 9)]
97c6f7ad
UW
4937 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4938 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4939 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4940 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4941 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4942 operands[8] = operand_subword (operands[2], 1, 0, DImode);
b628bd8e 4943 operands[9] = gen_label_rtx ();")
9db1d521 4944
3298c037
AK
4945;
4946; addsi3 instruction pattern(s).
4947;
4948
4949(define_expand "addsi3"
07893d4f 4950 [(parallel
963fc8d0 4951 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3298c037
AK
4952 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
4953 (match_operand:SI 2 "general_operand" "")))
ae156f85 4954 (clobber (reg:CC CC_REGNUM))])]
9db1d521 4955 ""
07893d4f 4956 "")
9db1d521 4957
3298c037
AK
4958(define_insn "*addsi3_sign"
4959 [(set (match_operand:SI 0 "register_operand" "=d,d")
4960 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
4961 (match_operand:SI 1 "register_operand" "0,0")))
4962 (clobber (reg:CC CC_REGNUM))]
4963 ""
4964 "@
4965 ah\t%0,%2
4966 ahy\t%0,%2"
65b1d8ea
AK
4967 [(set_attr "op_type" "RX,RXY")
4968 (set_attr "z196prop" "z196_cracked,z196_cracked")])
3298c037 4969
9db1d521 4970;
3298c037 4971; add(di|si)3 instruction pattern(s).
9db1d521 4972;
9db1d521 4973
65b1d8ea 4974; ark, agrk, ar, ahi, ahik, aghik, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
3298c037 4975(define_insn "*add<mode>3"
65b1d8ea
AK
4976 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d, d, d,d,d,QS")
4977 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,d, 0, 0,0,0, 0")
4978 (match_operand:GPR 2 "general_operand" " d,d,K,K,Op,On,R,T, C") ) )
3298c037
AK
4979 (clobber (reg:CC CC_REGNUM))]
4980 ""
ec24698e 4981 "@
3298c037 4982 a<g>r\t%0,%2
65b1d8ea 4983 a<g>rk\t%0,%1,%2
3298c037 4984 a<g>hi\t%0,%h2
65b1d8ea 4985 a<g>hik\t%0,%1,%h2
3298c037
AK
4986 al<g>fi\t%0,%2
4987 sl<g>fi\t%0,%n2
4988 a<g>\t%0,%2
963fc8d0
AK
4989 a<y>\t%0,%2
4990 a<g>si\t%0,%c2"
65b1d8ea
AK
4991 [(set_attr "op_type" "RR<E>,RRF,RI,RIE,RIL,RIL,RX<Y>,RXY,SIY")
4992 (set_attr "cpu_facility" "*,z196,*,z196,extimm,extimm,*,*,z10")
4993 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,z10_super_E1,z10_super_E1,
4994 z10_super_E1,z10_super_E1,z10_super_E1")])
0a3bdf9d 4995
65b1d8ea 4996; alr, alfi, slfi, al, aly, alrk, alhsik, algr, algfi, slgfi, alg, alsi, algsi, algrk, alghsik
3298c037 4997(define_insn "*add<mode>3_carry1_cc"
ae156f85 4998 [(set (reg CC_REGNUM)
65b1d8ea
AK
4999 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5000 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
07893d4f 5001 (match_dup 1)))
65b1d8ea 5002 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,d")
3298c037 5003 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5004 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5005 "@
3298c037 5006 al<g>r\t%0,%2
65b1d8ea 5007 al<g>rk\t%0,%1,%2
3298c037
AK
5008 al<g>fi\t%0,%2
5009 sl<g>fi\t%0,%n2
65b1d8ea 5010 al<g>hsik\t%0,%1,%h2
3298c037 5011 al<g>\t%0,%2
963fc8d0
AK
5012 al<y>\t%0,%2
5013 al<g>si\t%0,%c2"
65b1d8ea
AK
5014 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
5015 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
5016 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
5017 z10_super_E1,z10_super_E1,z10_super_E1")])
07893d4f 5018
65b1d8ea 5019; alr, al, aly, algr, alg, alrk, algrk
3298c037 5020(define_insn "*add<mode>3_carry1_cconly"
ae156f85 5021 [(set (reg CC_REGNUM)
65b1d8ea
AK
5022 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5023 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 5024 (match_dup 1)))
65b1d8ea 5025 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5026 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5027 "@
3298c037 5028 al<g>r\t%0,%2
65b1d8ea 5029 al<g>rk\t%0,%1,%2
3298c037
AK
5030 al<g>\t%0,%2
5031 al<y>\t%0,%2"
65b1d8ea
AK
5032 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5033 (set_attr "cpu_facility" "*,z196,*,*")
5034 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5035
65b1d8ea 5036; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
3298c037 5037(define_insn "*add<mode>3_carry2_cc"
ae156f85 5038 [(set (reg CC_REGNUM)
65b1d8ea
AK
5039 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0, 0")
5040 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T, C"))
07893d4f 5041 (match_dup 2)))
65b1d8ea 5042 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,RS")
3298c037 5043 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5044 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5045 "@
3298c037 5046 al<g>r\t%0,%2
65b1d8ea 5047 al<g>rk\t%0,%1,%2
3298c037
AK
5048 al<g>fi\t%0,%2
5049 sl<g>fi\t%0,%n2
65b1d8ea 5050 al<g>hsik\t%0,%1,%h2
3298c037 5051 al<g>\t%0,%2
963fc8d0
AK
5052 al<y>\t%0,%2
5053 al<g>si\t%0,%c2"
65b1d8ea
AK
5054 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
5055 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
5056 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
5057 z10_super_E1,z10_super_E1,z10_super_E1")])
07893d4f 5058
65b1d8ea 5059; alr, al, aly, algr, alg, alrk, algrk
3298c037 5060(define_insn "*add<mode>3_carry2_cconly"
ae156f85 5061 [(set (reg CC_REGNUM)
65b1d8ea
AK
5062 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5063 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 5064 (match_dup 2)))
65b1d8ea 5065 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5066 "s390_match_ccmode (insn, CCL1mode)"
07893d4f 5067 "@
3298c037 5068 al<g>r\t%0,%2
65b1d8ea 5069 al<g>rk\t%0,%1,%2
3298c037
AK
5070 al<g>\t%0,%2
5071 al<y>\t%0,%2"
65b1d8ea
AK
5072 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5073 (set_attr "cpu_facility" "*,z196,*,*")
5074 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5075
65b1d8ea 5076; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
3298c037 5077(define_insn "*add<mode>3_cc"
ae156f85 5078 [(set (reg CC_REGNUM)
65b1d8ea
AK
5079 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0, 0")
5080 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T, C"))
9db1d521 5081 (const_int 0)))
65b1d8ea 5082 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,RS")
3298c037 5083 (plus:GPR (match_dup 1) (match_dup 2)))]
c7453384 5084 "s390_match_ccmode (insn, CCLmode)"
9db1d521 5085 "@
3298c037 5086 al<g>r\t%0,%2
65b1d8ea 5087 al<g>rk\t%0,%1,%2
3298c037
AK
5088 al<g>fi\t%0,%2
5089 sl<g>fi\t%0,%n2
65b1d8ea 5090 al<g>hsik\t%0,%1,%h2
3298c037 5091 al<g>\t%0,%2
963fc8d0
AK
5092 al<y>\t%0,%2
5093 al<g>si\t%0,%c2"
65b1d8ea
AK
5094 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
5095 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
5096 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,
5097 *,z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 5098
65b1d8ea 5099; alr, al, aly, algr, alg, alrk, algrk
3298c037 5100(define_insn "*add<mode>3_cconly"
ae156f85 5101 [(set (reg CC_REGNUM)
65b1d8ea
AK
5102 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5103 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 5104 (const_int 0)))
65b1d8ea 5105 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
c7453384 5106 "s390_match_ccmode (insn, CCLmode)"
9db1d521 5107 "@
3298c037 5108 al<g>r\t%0,%2
65b1d8ea 5109 al<g>rk\t%0,%1,%2
3298c037
AK
5110 al<g>\t%0,%2
5111 al<y>\t%0,%2"
65b1d8ea
AK
5112 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5113 (set_attr "cpu_facility" "*,z196,*,*")
5114 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 5115
65b1d8ea 5116; alr, al, aly, algr, alg, alrk, algrk
3298c037 5117(define_insn "*add<mode>3_cconly2"
ae156f85 5118 [(set (reg CC_REGNUM)
65b1d8ea
AK
5119 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5120 (neg:GPR (match_operand:GPR 2 "general_operand" "d,d,R,T"))))
5121 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
3298c037 5122 "s390_match_ccmode(insn, CCLmode)"
d3632d41 5123 "@
3298c037 5124 al<g>r\t%0,%2
65b1d8ea 5125 al<g>rk\t%0,%1,%2
3298c037
AK
5126 al<g>\t%0,%2
5127 al<y>\t%0,%2"
65b1d8ea
AK
5128 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5129 (set_attr "cpu_facility" "*,z196,*,*")
5130 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5131
963fc8d0 5132; ahi, afi, aghi, agfi, asi, agsi
3298c037
AK
5133(define_insn "*add<mode>3_imm_cc"
5134 [(set (reg CC_REGNUM)
65b1d8ea
AK
5135 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" " 0, d,0, 0")
5136 (match_operand:GPR 2 "const_int_operand" " K, K,Os, C"))
3298c037 5137 (const_int 0)))
65b1d8ea 5138 (set (match_operand:GPR 0 "nonimmediate_operand" "=d, d,d,QS")
3298c037
AK
5139 (plus:GPR (match_dup 1) (match_dup 2)))]
5140 "s390_match_ccmode (insn, CCAmode)
5141 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
2542ef05
RH
5142 || (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
5143 /* Avoid INT32_MIN on 32 bit. */
5144 && (!TARGET_ZARCH || INTVAL (operands[2]) != -0x7fffffff - 1)))"
9db1d521 5145 "@
3298c037 5146 a<g>hi\t%0,%h2
65b1d8ea 5147 a<g>hik\t%0,%1,%h2
963fc8d0
AK
5148 a<g>fi\t%0,%2
5149 a<g>si\t%0,%c2"
65b1d8ea
AK
5150 [(set_attr "op_type" "RI,RIE,RIL,SIY")
5151 (set_attr "cpu_facility" "*,z196,extimm,z10")
5152 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 5153
9db1d521 5154;
609e7e80 5155; add(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
5156;
5157
609e7e80 5158; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
142cd70f 5159(define_insn "add<mode>3"
609e7e80
AK
5160 [(set (match_operand:FP 0 "register_operand" "=f, f")
5161 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5162 (match_operand:FP 2 "general_operand" " f,<Rf>")))
ae156f85 5163 (clobber (reg:CC CC_REGNUM))]
142cd70f 5164 "TARGET_HARD_FLOAT"
9db1d521 5165 "@
609e7e80 5166 a<xde><bt>r\t%0,<op1>%2
f61a2c7d 5167 a<xde>b\t%0,%2"
609e7e80 5168 [(set_attr "op_type" "<RRer>,RXE")
9381e3f1 5169 (set_attr "type" "fsimp<mode>")])
9db1d521 5170
609e7e80 5171; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
f5905b37 5172(define_insn "*add<mode>3_cc"
ae156f85 5173 [(set (reg CC_REGNUM)
609e7e80
AK
5174 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5175 (match_operand:FP 2 "general_operand" " f,<Rf>"))
5176 (match_operand:FP 3 "const0_operand" "")))
5177 (set (match_operand:FP 0 "register_operand" "=f,f")
5178 (plus:FP (match_dup 1) (match_dup 2)))]
142cd70f 5179 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 5180 "@
609e7e80 5181 a<xde><bt>r\t%0,<op1>%2
f61a2c7d 5182 a<xde>b\t%0,%2"
609e7e80 5183 [(set_attr "op_type" "<RRer>,RXE")
9381e3f1 5184 (set_attr "type" "fsimp<mode>")])
3ef093a8 5185
609e7e80 5186; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
f5905b37 5187(define_insn "*add<mode>3_cconly"
ae156f85 5188 [(set (reg CC_REGNUM)
609e7e80
AK
5189 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5190 (match_operand:FP 2 "general_operand" " f,<Rf>"))
5191 (match_operand:FP 3 "const0_operand" "")))
5192 (clobber (match_scratch:FP 0 "=f,f"))]
142cd70f 5193 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 5194 "@
609e7e80 5195 a<xde><bt>r\t%0,<op1>%2
f61a2c7d 5196 a<xde>b\t%0,%2"
609e7e80 5197 [(set_attr "op_type" "<RRer>,RXE")
9381e3f1 5198 (set_attr "type" "fsimp<mode>")])
3ef093a8 5199
72a4ddf2
AK
5200;
5201; Pointer add instruction patterns
5202;
5203
5204; This will match "*la_64"
5205(define_expand "addptrdi3"
5206 [(set (match_operand:DI 0 "register_operand" "")
5207 (plus:DI (match_operand:DI 1 "register_operand" "")
5208 (match_operand:DI 2 "nonmemory_operand" "")))]
5209 "TARGET_64BIT"
5210{
72a4ddf2
AK
5211 if (GET_CODE (operands[2]) == CONST_INT)
5212 {
357ddc7d
TV
5213 HOST_WIDE_INT c = INTVAL (operands[2]);
5214
72a4ddf2
AK
5215 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
5216 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
5217 {
5218 operands[2] = force_const_mem (DImode, operands[2]);
5219 operands[2] = force_reg (DImode, operands[2]);
5220 }
5221 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
5222 operands[2] = force_reg (DImode, operands[2]);
5223 }
5224})
5225
5226; For 31 bit we have to prevent the generated pattern from matching
5227; normal ADDs since la only does a 31 bit add. This is supposed to
5228; match "force_la_31".
5229(define_expand "addptrsi3"
5230 [(parallel
5231 [(set (match_operand:SI 0 "register_operand" "")
5232 (plus:SI (match_operand:SI 1 "register_operand" "")
5233 (match_operand:SI 2 "nonmemory_operand" "")))
5234 (use (const_int 0))])]
5235 "!TARGET_64BIT"
5236{
72a4ddf2
AK
5237 if (GET_CODE (operands[2]) == CONST_INT)
5238 {
357ddc7d
TV
5239 HOST_WIDE_INT c = INTVAL (operands[2]);
5240
72a4ddf2
AK
5241 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
5242 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
5243 {
5244 operands[2] = force_const_mem (SImode, operands[2]);
5245 operands[2] = force_reg (SImode, operands[2]);
5246 }
5247 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
5248 operands[2] = force_reg (SImode, operands[2]);
5249 }
5250})
9db1d521
HP
5251
5252;;
5253;;- Subtract instructions.
5254;;
5255
1c7b1b7e
UW
5256;
5257; subti3 instruction pattern(s).
5258;
5259
085261c8
AK
5260(define_expand "subti3"
5261 [(parallel
5262 [(set (match_operand:TI 0 "register_operand" "")
5263 (minus:TI (match_operand:TI 1 "register_operand" "")
5264 (match_operand:TI 2 "general_operand" "") ) )
5265 (clobber (reg:CC CC_REGNUM))])]
5266 "TARGET_ZARCH"
5267{
5268 /* For z13 we have vaq which doesn't set CC. */
5269 if (TARGET_VX)
5270 {
5271 emit_insn (gen_rtx_SET (operands[0],
5272 gen_rtx_MINUS (TImode,
5273 operands[1],
5274 copy_to_mode_reg (TImode, operands[2]))));
5275 DONE;
5276 }
5277})
5278
5279(define_insn_and_split "*subti3"
5280 [(set (match_operand:TI 0 "register_operand" "=&d")
5281 (minus:TI (match_operand:TI 1 "register_operand" "0")
5282 (match_operand:TI 2 "general_operand" "do") ) )
ae156f85 5283 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5284 "TARGET_ZARCH"
1c7b1b7e
UW
5285 "#"
5286 "&& reload_completed"
5287 [(parallel
ae156f85 5288 [(set (reg:CCL2 CC_REGNUM)
1c7b1b7e
UW
5289 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
5290 (match_dup 7)))
5291 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
5292 (parallel
5293 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
ae156f85
AS
5294 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
5295 (clobber (reg:CC CC_REGNUM))])]
1c7b1b7e
UW
5296 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
5297 operands[4] = operand_subword (operands[1], 0, 0, TImode);
5298 operands[5] = operand_subword (operands[2], 0, 0, TImode);
5299 operands[6] = operand_subword (operands[0], 1, 0, TImode);
5300 operands[7] = operand_subword (operands[1], 1, 0, TImode);
085261c8
AK
5301 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
5302 [(set_attr "op_type" "*")
5303 (set_attr "cpu_facility" "*")])
1c7b1b7e 5304
9db1d521
HP
5305;
5306; subdi3 instruction pattern(s).
5307;
5308
3298c037
AK
5309(define_expand "subdi3"
5310 [(parallel
5311 [(set (match_operand:DI 0 "register_operand" "")
5312 (minus:DI (match_operand:DI 1 "register_operand" "")
5313 (match_operand:DI 2 "general_operand" "")))
5314 (clobber (reg:CC CC_REGNUM))])]
5315 ""
5316 "")
5317
07893d4f
UW
5318(define_insn "*subdi3_sign"
5319 [(set (match_operand:DI 0 "register_operand" "=d,d")
5320 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
fb492564 5321 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
ae156f85 5322 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5323 "TARGET_ZARCH"
07893d4f 5324 "@
d40c829f
UW
5325 sgfr\t%0,%2
5326 sgf\t%0,%2"
9381e3f1 5327 [(set_attr "op_type" "RRE,RXY")
65b1d8ea
AK
5328 (set_attr "z10prop" "z10_c,*")
5329 (set_attr "z196prop" "z196_cracked")])
07893d4f
UW
5330
5331(define_insn "*subdi3_zero_cc"
ae156f85 5332 [(set (reg CC_REGNUM)
07893d4f 5333 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
fb492564 5334 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
07893d4f
UW
5335 (const_int 0)))
5336 (set (match_operand:DI 0 "register_operand" "=d,d")
5337 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
9602b6a1 5338 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5339 "@
d40c829f
UW
5340 slgfr\t%0,%2
5341 slgf\t%0,%2"
9381e3f1
WG
5342 [(set_attr "op_type" "RRE,RXY")
5343 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f
UW
5344
5345(define_insn "*subdi3_zero_cconly"
ae156f85 5346 [(set (reg CC_REGNUM)
07893d4f 5347 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
fb492564 5348 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
07893d4f
UW
5349 (const_int 0)))
5350 (clobber (match_scratch:DI 0 "=d,d"))]
9602b6a1 5351 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
07893d4f 5352 "@
d40c829f
UW
5353 slgfr\t%0,%2
5354 slgf\t%0,%2"
9381e3f1
WG
5355 [(set_attr "op_type" "RRE,RXY")
5356 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f
UW
5357
5358(define_insn "*subdi3_zero"
5359 [(set (match_operand:DI 0 "register_operand" "=d,d")
5360 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
fb492564 5361 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
ae156f85 5362 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5363 "TARGET_ZARCH"
07893d4f 5364 "@
d40c829f
UW
5365 slgfr\t%0,%2
5366 slgf\t%0,%2"
9381e3f1
WG
5367 [(set_attr "op_type" "RRE,RXY")
5368 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
07893d4f 5369
e69166de
UW
5370(define_insn_and_split "*subdi3_31z"
5371 [(set (match_operand:DI 0 "register_operand" "=&d")
5372 (minus:DI (match_operand:DI 1 "register_operand" "0")
5373 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5374 (clobber (reg:CC CC_REGNUM))]
9602b6a1 5375 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
e69166de
UW
5376 "#"
5377 "&& reload_completed"
5378 [(parallel
ae156f85 5379 [(set (reg:CCL2 CC_REGNUM)
e69166de
UW
5380 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5381 (match_dup 7)))
5382 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5383 (parallel
5384 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
ae156f85
AS
5385 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
5386 (clobber (reg:CC CC_REGNUM))])]
e69166de
UW
5387 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5388 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5389 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5390 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5391 operands[7] = operand_subword (operands[1], 1, 0, DImode);
b628bd8e 5392 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
e69166de 5393
07893d4f
UW
5394(define_insn_and_split "*subdi3_31"
5395 [(set (match_operand:DI 0 "register_operand" "=&d")
5396 (minus:DI (match_operand:DI 1 "register_operand" "0")
97c6f7ad 5397 (match_operand:DI 2 "general_operand" "do") ) )
ae156f85 5398 (clobber (reg:CC CC_REGNUM))]
e69166de 5399 "!TARGET_CPU_ZARCH"
07893d4f
UW
5400 "#"
5401 "&& reload_completed"
5402 [(parallel
5403 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
ae156f85 5404 (clobber (reg:CC CC_REGNUM))])
07893d4f 5405 (parallel
ae156f85 5406 [(set (reg:CCL2 CC_REGNUM)
07893d4f
UW
5407 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5408 (match_dup 7)))
5409 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5410 (set (pc)
ae156f85 5411 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
07893d4f
UW
5412 (pc)
5413 (label_ref (match_dup 9))))
5414 (parallel
5415 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
ae156f85 5416 (clobber (reg:CC CC_REGNUM))])
07893d4f 5417 (match_dup 9)]
97c6f7ad
UW
5418 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5419 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5420 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5421 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5422 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5423 operands[8] = operand_subword (operands[2], 1, 0, DImode);
b628bd8e 5424 operands[9] = gen_label_rtx ();")
07893d4f 5425
3298c037
AK
5426;
5427; subsi3 instruction pattern(s).
5428;
5429
5430(define_expand "subsi3"
07893d4f 5431 [(parallel
3298c037
AK
5432 [(set (match_operand:SI 0 "register_operand" "")
5433 (minus:SI (match_operand:SI 1 "register_operand" "")
5434 (match_operand:SI 2 "general_operand" "")))
ae156f85 5435 (clobber (reg:CC CC_REGNUM))])]
9db1d521 5436 ""
07893d4f 5437 "")
9db1d521 5438
3298c037
AK
5439(define_insn "*subsi3_sign"
5440 [(set (match_operand:SI 0 "register_operand" "=d,d")
5441 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
5442 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
5443 (clobber (reg:CC CC_REGNUM))]
5444 ""
5445 "@
5446 sh\t%0,%2
5447 shy\t%0,%2"
65b1d8ea
AK
5448 [(set_attr "op_type" "RX,RXY")
5449 (set_attr "z196prop" "z196_cracked,z196_cracked")])
3298c037 5450
9db1d521 5451;
3298c037 5452; sub(di|si)3 instruction pattern(s).
9db1d521
HP
5453;
5454
65b1d8ea 5455; sr, s, sy, sgr, sg, srk, sgrk
3298c037 5456(define_insn "*sub<mode>3"
65b1d8ea
AK
5457 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5458 (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5459 (match_operand:GPR 2 "general_operand" "d,d,R,T") ) )
3298c037
AK
5460 (clobber (reg:CC CC_REGNUM))]
5461 ""
5462 "@
5463 s<g>r\t%0,%2
65b1d8ea 5464 s<g>rk\t%0,%1,%2
3298c037
AK
5465 s<g>\t%0,%2
5466 s<y>\t%0,%2"
65b1d8ea
AK
5467 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5468 (set_attr "cpu_facility" "*,z196,*,*")
5469 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
3298c037 5470
65b1d8ea 5471; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 5472(define_insn "*sub<mode>3_borrow_cc"
ae156f85 5473 [(set (reg CC_REGNUM)
65b1d8ea
AK
5474 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5475 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 5476 (match_dup 1)))
65b1d8ea 5477 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 5478 (minus:GPR (match_dup 1) (match_dup 2)))]
b2ba71ca 5479 "s390_match_ccmode (insn, CCL2mode)"
07893d4f 5480 "@
3298c037 5481 sl<g>r\t%0,%2
65b1d8ea 5482 sl<g>rk\t%0,%1,%2
3298c037
AK
5483 sl<g>\t%0,%2
5484 sl<y>\t%0,%2"
65b1d8ea
AK
5485 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5486 (set_attr "cpu_facility" "*,z196,*,*")
5487 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5488
65b1d8ea 5489; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 5490(define_insn "*sub<mode>3_borrow_cconly"
ae156f85 5491 [(set (reg CC_REGNUM)
65b1d8ea
AK
5492 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5493 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
07893d4f 5494 (match_dup 1)))
65b1d8ea 5495 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
b2ba71ca 5496 "s390_match_ccmode (insn, CCL2mode)"
07893d4f 5497 "@
3298c037 5498 sl<g>r\t%0,%2
65b1d8ea 5499 sl<g>rk\t%0,%1,%2
3298c037
AK
5500 sl<g>\t%0,%2
5501 sl<y>\t%0,%2"
65b1d8ea
AK
5502 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5503 (set_attr "cpu_facility" "*,z196,*,*")
5504 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
07893d4f 5505
65b1d8ea 5506; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 5507(define_insn "*sub<mode>3_cc"
ae156f85 5508 [(set (reg CC_REGNUM)
65b1d8ea
AK
5509 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5510 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 5511 (const_int 0)))
65b1d8ea 5512 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 5513 (minus:GPR (match_dup 1) (match_dup 2)))]
b2ba71ca 5514 "s390_match_ccmode (insn, CCLmode)"
9db1d521 5515 "@
3298c037 5516 sl<g>r\t%0,%2
65b1d8ea 5517 sl<g>rk\t%0,%1,%2
3298c037
AK
5518 sl<g>\t%0,%2
5519 sl<y>\t%0,%2"
65b1d8ea
AK
5520 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5521 (set_attr "cpu_facility" "*,z196,*,*")
5522 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 5523
65b1d8ea 5524; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 5525(define_insn "*sub<mode>3_cc2"
ae156f85 5526 [(set (reg CC_REGNUM)
65b1d8ea
AK
5527 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
5528 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
5529 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
3298c037 5530 (minus:GPR (match_dup 1) (match_dup 2)))]
5d880bd2
UW
5531 "s390_match_ccmode (insn, CCL3mode)"
5532 "@
3298c037 5533 sl<g>r\t%0,%2
65b1d8ea 5534 sl<g>rk\t%0,%1,%2
3298c037
AK
5535 sl<g>\t%0,%2
5536 sl<y>\t%0,%2"
65b1d8ea
AK
5537 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5538 (set_attr "cpu_facility" "*,z196,*,*")
5539 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5d880bd2 5540
65b1d8ea 5541; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 5542(define_insn "*sub<mode>3_cconly"
ae156f85 5543 [(set (reg CC_REGNUM)
65b1d8ea
AK
5544 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5545 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
9db1d521 5546 (const_int 0)))
65b1d8ea 5547 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
b2ba71ca 5548 "s390_match_ccmode (insn, CCLmode)"
9db1d521 5549 "@
3298c037 5550 sl<g>r\t%0,%2
65b1d8ea 5551 sl<g>rk\t%0,%1,%2
3298c037
AK
5552 sl<g>\t%0,%2
5553 sl<y>\t%0,%2"
65b1d8ea
AK
5554 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5555 (set_attr "cpu_facility" "*,z196,*,*")
5556 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9381e3f1 5557
9db1d521 5558
65b1d8ea 5559; slr, sl, sly, slgr, slg, slrk, slgrk
3298c037 5560(define_insn "*sub<mode>3_cconly2"
ae156f85 5561 [(set (reg CC_REGNUM)
65b1d8ea
AK
5562 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
5563 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
5564 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5d880bd2
UW
5565 "s390_match_ccmode (insn, CCL3mode)"
5566 "@
3298c037 5567 sl<g>r\t%0,%2
65b1d8ea 5568 sl<g>rk\t%0,%1,%2
3298c037
AK
5569 sl<g>\t%0,%2
5570 sl<y>\t%0,%2"
65b1d8ea
AK
5571 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5572 (set_attr "cpu_facility" "*,z196,*,*")
5573 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
9381e3f1 5574
9db1d521
HP
5575
5576;
609e7e80 5577; sub(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
5578;
5579
d46f24b6 5580; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
142cd70f 5581(define_insn "sub<mode>3"
609e7e80
AK
5582 [(set (match_operand:FP 0 "register_operand" "=f, f")
5583 (minus:FP (match_operand:FP 1 "register_operand" "<f0>,0")
142cd70f 5584 (match_operand:FP 2 "general_operand" "f,<Rf>")))
ae156f85 5585 (clobber (reg:CC CC_REGNUM))]
142cd70f 5586 "TARGET_HARD_FLOAT"
9db1d521 5587 "@
609e7e80 5588 s<xde><bt>r\t%0,<op1>%2
f61a2c7d 5589 s<xde>b\t%0,%2"
609e7e80 5590 [(set_attr "op_type" "<RRer>,RXE")
9381e3f1 5591 (set_attr "type" "fsimp<mode>")])
9db1d521 5592
d46f24b6 5593; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
f5905b37 5594(define_insn "*sub<mode>3_cc"
ae156f85 5595 [(set (reg CC_REGNUM)
609e7e80 5596 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
142cd70f 5597 (match_operand:FP 2 "general_operand" "f,<Rf>"))
609e7e80
AK
5598 (match_operand:FP 3 "const0_operand" "")))
5599 (set (match_operand:FP 0 "register_operand" "=f,f")
5600 (minus:FP (match_dup 1) (match_dup 2)))]
142cd70f 5601 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 5602 "@
609e7e80 5603 s<xde><bt>r\t%0,<op1>%2
f61a2c7d 5604 s<xde>b\t%0,%2"
609e7e80 5605 [(set_attr "op_type" "<RRer>,RXE")
9381e3f1 5606 (set_attr "type" "fsimp<mode>")])
3ef093a8 5607
d46f24b6 5608; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
f5905b37 5609(define_insn "*sub<mode>3_cconly"
ae156f85 5610 [(set (reg CC_REGNUM)
609e7e80
AK
5611 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
5612 (match_operand:FP 2 "general_operand" "f,<Rf>"))
5613 (match_operand:FP 3 "const0_operand" "")))
5614 (clobber (match_scratch:FP 0 "=f,f"))]
142cd70f 5615 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
3ef093a8 5616 "@
609e7e80 5617 s<xde><bt>r\t%0,<op1>%2
f61a2c7d 5618 s<xde>b\t%0,%2"
609e7e80 5619 [(set_attr "op_type" "<RRer>,RXE")
9381e3f1 5620 (set_attr "type" "fsimp<mode>")])
3ef093a8 5621
9db1d521 5622
e69166de
UW
5623;;
5624;;- Conditional add/subtract instructions.
5625;;
5626
5627;
9a91a21f 5628; add(di|si)cc instruction pattern(s).
e69166de
UW
5629;
5630
a996720c
UW
5631; the following 4 patterns are used when the result of an add with
5632; carry is checked for an overflow condition
5633
5634; op1 + op2 + c < op1
5635
5636; alcr, alc, alcgr, alcg
5637(define_insn "*add<mode>3_alc_carry1_cc"
5638 [(set (reg CC_REGNUM)
5639 (compare
5640 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5641 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
fb492564 5642 (match_operand:GPR 2 "general_operand" "d,RT"))
a996720c
UW
5643 (match_dup 1)))
5644 (set (match_operand:GPR 0 "register_operand" "=d,d")
5645 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5646 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5647 "@
5648 alc<g>r\t%0,%2
5649 alc<g>\t%0,%2"
65b1d8ea
AK
5650 [(set_attr "op_type" "RRE,RXY")
5651 (set_attr "z196prop" "z196_alone,z196_alone")])
a996720c
UW
5652
5653; alcr, alc, alcgr, alcg
5654(define_insn "*add<mode>3_alc_carry1_cconly"
5655 [(set (reg CC_REGNUM)
5656 (compare
5657 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5658 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
fb492564 5659 (match_operand:GPR 2 "general_operand" "d,RT"))
a996720c
UW
5660 (match_dup 1)))
5661 (clobber (match_scratch:GPR 0 "=d,d"))]
5662 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5663 "@
5664 alc<g>r\t%0,%2
5665 alc<g>\t%0,%2"
65b1d8ea
AK
5666 [(set_attr "op_type" "RRE,RXY")
5667 (set_attr "z196prop" "z196_alone,z196_alone")])
a996720c
UW
5668
5669; op1 + op2 + c < op2
5670
5671; alcr, alc, alcgr, alcg
5672(define_insn "*add<mode>3_alc_carry2_cc"
5673 [(set (reg CC_REGNUM)
5674 (compare
5675 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5676 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
fb492564 5677 (match_operand:GPR 2 "general_operand" "d,RT"))
a996720c
UW
5678 (match_dup 2)))
5679 (set (match_operand:GPR 0 "register_operand" "=d,d")
5680 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5681 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5682 "@
5683 alc<g>r\t%0,%2
5684 alc<g>\t%0,%2"
5685 [(set_attr "op_type" "RRE,RXY")])
5686
5687; alcr, alc, alcgr, alcg
5688(define_insn "*add<mode>3_alc_carry2_cconly"
5689 [(set (reg CC_REGNUM)
5690 (compare
5691 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5692 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
fb492564 5693 (match_operand:GPR 2 "general_operand" "d,RT"))
a996720c
UW
5694 (match_dup 2)))
5695 (clobber (match_scratch:GPR 0 "=d,d"))]
5696 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5697 "@
5698 alc<g>r\t%0,%2
5699 alc<g>\t%0,%2"
5700 [(set_attr "op_type" "RRE,RXY")])
5701
43a09b63 5702; alcr, alc, alcgr, alcg
9a91a21f 5703(define_insn "*add<mode>3_alc_cc"
ae156f85 5704 [(set (reg CC_REGNUM)
e69166de 5705 (compare
a94a76a7
UW
5706 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5707 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
fb492564 5708 (match_operand:GPR 2 "general_operand" "d,RT"))
e69166de 5709 (const_int 0)))
9a91a21f 5710 (set (match_operand:GPR 0 "register_operand" "=d,d")
a94a76a7 5711 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
2f7e5a0d 5712 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
e69166de 5713 "@
9a91a21f
AS
5714 alc<g>r\t%0,%2
5715 alc<g>\t%0,%2"
e69166de
UW
5716 [(set_attr "op_type" "RRE,RXY")])
5717
43a09b63 5718; alcr, alc, alcgr, alcg
9a91a21f
AS
5719(define_insn "*add<mode>3_alc"
5720 [(set (match_operand:GPR 0 "register_operand" "=d,d")
a94a76a7
UW
5721 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5722 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
fb492564 5723 (match_operand:GPR 2 "general_operand" "d,RT")))
ae156f85 5724 (clobber (reg:CC CC_REGNUM))]
2f7e5a0d 5725 "TARGET_CPU_ZARCH"
e69166de 5726 "@
9a91a21f
AS
5727 alc<g>r\t%0,%2
5728 alc<g>\t%0,%2"
e69166de
UW
5729 [(set_attr "op_type" "RRE,RXY")])
5730
43a09b63 5731; slbr, slb, slbgr, slbg
9a91a21f 5732(define_insn "*sub<mode>3_slb_cc"
ae156f85 5733 [(set (reg CC_REGNUM)
e69166de 5734 (compare
9a91a21f 5735 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
fb492564 5736 (match_operand:GPR 2 "general_operand" "d,RT"))
9a91a21f 5737 (match_operand:GPR 3 "s390_slb_comparison" ""))
e69166de 5738 (const_int 0)))
9a91a21f
AS
5739 (set (match_operand:GPR 0 "register_operand" "=d,d")
5740 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
2f7e5a0d 5741 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
e69166de 5742 "@
9a91a21f
AS
5743 slb<g>r\t%0,%2
5744 slb<g>\t%0,%2"
9381e3f1
WG
5745 [(set_attr "op_type" "RRE,RXY")
5746 (set_attr "z10prop" "z10_c,*")])
e69166de 5747
43a09b63 5748; slbr, slb, slbgr, slbg
9a91a21f
AS
5749(define_insn "*sub<mode>3_slb"
5750 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5751 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
fb492564 5752 (match_operand:GPR 2 "general_operand" "d,RT"))
9a91a21f 5753 (match_operand:GPR 3 "s390_slb_comparison" "")))
ae156f85 5754 (clobber (reg:CC CC_REGNUM))]
2f7e5a0d 5755 "TARGET_CPU_ZARCH"
e69166de 5756 "@
9a91a21f
AS
5757 slb<g>r\t%0,%2
5758 slb<g>\t%0,%2"
9381e3f1
WG
5759 [(set_attr "op_type" "RRE,RXY")
5760 (set_attr "z10prop" "z10_c,*")])
e69166de 5761
9a91a21f
AS
5762(define_expand "add<mode>cc"
5763 [(match_operand:GPR 0 "register_operand" "")
5d880bd2 5764 (match_operand 1 "comparison_operator" "")
9a91a21f
AS
5765 (match_operand:GPR 2 "register_operand" "")
5766 (match_operand:GPR 3 "const_int_operand" "")]
5d880bd2 5767 "TARGET_CPU_ZARCH"
9381e3f1 5768 "if (!s390_expand_addcc (GET_CODE (operands[1]),
f90b7a5a 5769 XEXP (operands[1], 0), XEXP (operands[1], 1),
9381e3f1 5770 operands[0], operands[2],
5d880bd2
UW
5771 operands[3])) FAIL; DONE;")
5772
5773;
5774; scond instruction pattern(s).
5775;
5776
9a91a21f
AS
5777(define_insn_and_split "*scond<mode>"
5778 [(set (match_operand:GPR 0 "register_operand" "=&d")
5779 (match_operand:GPR 1 "s390_alc_comparison" ""))
ae156f85 5780 (clobber (reg:CC CC_REGNUM))]
5d880bd2
UW
5781 "TARGET_CPU_ZARCH"
5782 "#"
5783 "&& reload_completed"
5784 [(set (match_dup 0) (const_int 0))
5785 (parallel
a94a76a7
UW
5786 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
5787 (match_dup 0)))
ae156f85 5788 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 5789 "")
5d880bd2 5790
9a91a21f
AS
5791(define_insn_and_split "*scond<mode>_neg"
5792 [(set (match_operand:GPR 0 "register_operand" "=&d")
5793 (match_operand:GPR 1 "s390_slb_comparison" ""))
ae156f85 5794 (clobber (reg:CC CC_REGNUM))]
5d880bd2
UW
5795 "TARGET_CPU_ZARCH"
5796 "#"
5797 "&& reload_completed"
5798 [(set (match_dup 0) (const_int 0))
5799 (parallel
9a91a21f
AS
5800 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
5801 (match_dup 1)))
ae156f85 5802 (clobber (reg:CC CC_REGNUM))])
5d880bd2 5803 (parallel
9a91a21f 5804 [(set (match_dup 0) (neg:GPR (match_dup 0)))
ae156f85 5805 (clobber (reg:CC CC_REGNUM))])]
b628bd8e 5806 "")
5d880bd2 5807
5d880bd2 5808
f90b7a5a 5809(define_expand "cstore<mode>4"
9a91a21f 5810 [(set (match_operand:SI 0 "register_operand" "")
f90b7a5a
PB
5811 (match_operator:SI 1 "s390_scond_operator"
5812 [(match_operand:GPR 2 "register_operand" "")
5813 (match_operand:GPR 3 "general_operand" "")]))]
5d880bd2 5814 "TARGET_CPU_ZARCH"
f90b7a5a 5815 "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3],
5d880bd2
UW
5816 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
5817
f90b7a5a 5818(define_expand "cstorecc4"
69950452 5819 [(parallel
f90b7a5a
PB
5820 [(set (match_operand:SI 0 "register_operand" "")
5821 (match_operator:SI 1 "s390_eqne_operator"
5822 [(match_operand:CCZ1 2 "register_operand")
5823 (match_operand 3 "const0_operand")]))
69950452
AS
5824 (clobber (reg:CC CC_REGNUM))])]
5825 ""
f90b7a5a
PB
5826 "emit_insn (gen_sne (operands[0], operands[2]));
5827 if (GET_CODE (operands[1]) == EQ)
5828 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
5829 DONE;")
69950452 5830
f90b7a5a 5831(define_insn_and_split "sne"
69950452 5832 [(set (match_operand:SI 0 "register_operand" "=d")
9381e3f1 5833 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
69950452
AS
5834 (const_int 0)))
5835 (clobber (reg:CC CC_REGNUM))]
5836 ""
5837 "#"
5838 "reload_completed"
5839 [(parallel
5840 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
5841 (clobber (reg:CC CC_REGNUM))])])
5842
e69166de 5843
65b1d8ea
AK
5844;;
5845;; - Conditional move instructions (introduced with z196)
5846;;
5847
5848(define_expand "mov<mode>cc"
5849 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
5850 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
5851 (match_operand:GPR 2 "nonimmediate_operand" "")
5852 (match_operand:GPR 3 "nonimmediate_operand" "")))]
5853 "TARGET_Z196"
5854 "operands[1] = s390_emit_compare (GET_CODE (operands[1]),
5855 XEXP (operands[1], 0), XEXP (operands[1], 1));")
5856
27037b5f 5857; locr, loc, stoc, locgr, locg, stocg
65b1d8ea
AK
5858(define_insn_and_split "*mov<mode>cc"
5859 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,QS,QS,&d")
5860 (if_then_else:GPR
5861 (match_operator 1 "s390_comparison"
5862 [(match_operand 2 "cc_reg_operand" " c,c, c, c, c, c, c")
5a3fe9b6 5863 (match_operand 5 "const_int_operand" "")])
65b1d8ea
AK
5864 (match_operand:GPR 3 "nonimmediate_operand" " d,0,QS, 0, d, 0,QS")
5865 (match_operand:GPR 4 "nonimmediate_operand" " 0,d, 0,QS, 0, d,QS")))]
5866 "TARGET_Z196"
5867 "@
5868 loc<g>r%C1\t%0,%3
5869 loc<g>r%D1\t%0,%4
a6510374
AK
5870 loc<g>%C1\t%0,%3
5871 loc<g>%D1\t%0,%4
5872 stoc<g>%C1\t%3,%0
5873 stoc<g>%D1\t%4,%0
65b1d8ea
AK
5874 #"
5875 "&& reload_completed
5876 && MEM_P (operands[3]) && MEM_P (operands[4])"
5877 [(set (match_dup 0)
5878 (if_then_else:GPR
5879 (match_op_dup 1 [(match_dup 2) (const_int 0)])
5880 (match_dup 3)
5881 (match_dup 0)))
5882 (set (match_dup 0)
5883 (if_then_else:GPR
5884 (match_op_dup 1 [(match_dup 2) (const_int 0)])
5885 (match_dup 0)
5886 (match_dup 4)))]
5887 ""
5888 [(set_attr "op_type" "RRF,RRF,RSY,RSY,RSY,RSY,*")])
5889
9db1d521
HP
5890;;
5891;;- Multiply instructions.
5892;;
5893
4023fb28
UW
5894;
5895; muldi3 instruction pattern(s).
5896;
9db1d521 5897
07893d4f
UW
5898(define_insn "*muldi3_sign"
5899 [(set (match_operand:DI 0 "register_operand" "=d,d")
963fc8d0 5900 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
07893d4f 5901 (match_operand:DI 1 "register_operand" "0,0")))]
9602b6a1 5902 "TARGET_ZARCH"
07893d4f 5903 "@
d40c829f
UW
5904 msgfr\t%0,%2
5905 msgf\t%0,%2"
963fc8d0
AK
5906 [(set_attr "op_type" "RRE,RXY")
5907 (set_attr "type" "imuldi")])
07893d4f 5908
4023fb28 5909(define_insn "muldi3"
963fc8d0
AK
5910 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
5911 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5912 (match_operand:DI 2 "general_operand" "d,K,RT,Os")))]
9602b6a1 5913 "TARGET_ZARCH"
9db1d521 5914 "@
d40c829f
UW
5915 msgr\t%0,%2
5916 mghi\t%0,%h2
963fc8d0
AK
5917 msg\t%0,%2
5918 msgfi\t%0,%2"
5919 [(set_attr "op_type" "RRE,RI,RXY,RIL")
5920 (set_attr "type" "imuldi")
5921 (set_attr "cpu_facility" "*,*,*,z10")])
f2d3c02a 5922
9db1d521
HP
5923;
5924; mulsi3 instruction pattern(s).
5925;
5926
f1e77d83 5927(define_insn "*mulsi3_sign"
963fc8d0
AK
5928 [(set (match_operand:SI 0 "register_operand" "=d,d")
5929 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5930 (match_operand:SI 1 "register_operand" "0,0")))]
f1e77d83 5931 ""
963fc8d0
AK
5932 "@
5933 mh\t%0,%2
5934 mhy\t%0,%2"
5935 [(set_attr "op_type" "RX,RXY")
5936 (set_attr "type" "imulhi")
5937 (set_attr "cpu_facility" "*,z10")])
f1e77d83 5938
9db1d521 5939(define_insn "mulsi3"
963fc8d0
AK
5940 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
5941 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
5942 (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
9db1d521
HP
5943 ""
5944 "@
d40c829f
UW
5945 msr\t%0,%2
5946 mhi\t%0,%h2
5947 ms\t%0,%2
963fc8d0
AK
5948 msy\t%0,%2
5949 msfi\t%0,%2"
5950 [(set_attr "op_type" "RRE,RI,RX,RXY,RIL")
5951 (set_attr "type" "imulsi,imulhi,imulsi,imulsi,imulsi")
5952 (set_attr "cpu_facility" "*,*,*,*,z10")])
9db1d521 5953
4023fb28
UW
5954;
5955; mulsidi3 instruction pattern(s).
5956;
5957
f1e77d83 5958(define_insn "mulsidi3"
963fc8d0 5959 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
f1e77d83 5960 (mult:DI (sign_extend:DI
963fc8d0 5961 (match_operand:SI 1 "register_operand" "%0,0,0"))
f1e77d83 5962 (sign_extend:DI
963fc8d0 5963 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
9602b6a1 5964 "!TARGET_ZARCH"
f1e77d83
UW
5965 "@
5966 mr\t%0,%2
963fc8d0
AK
5967 m\t%0,%2
5968 mfy\t%0,%2"
5969 [(set_attr "op_type" "RR,RX,RXY")
5970 (set_attr "type" "imulsi")
5971 (set_attr "cpu_facility" "*,*,z10")])
4023fb28 5972
f1e77d83 5973;
6e0d70c9 5974; umul instruction pattern(s).
f1e77d83 5975;
c7453384 5976
6e0d70c9
AK
5977; mlr, ml, mlgr, mlg
5978(define_insn "umul<dwh><mode>3"
5979 [(set (match_operand:DW 0 "register_operand" "=d, d")
5980 (mult:DW (zero_extend:DW
5981 (match_operand:<DWH> 1 "register_operand" "%0, 0"))
5982 (zero_extend:DW
5983 (match_operand:<DWH> 2 "nonimmediate_operand" " d,RT"))))]
5984 "TARGET_CPU_ZARCH"
f1e77d83 5985 "@
6e0d70c9
AK
5986 ml<tg>r\t%0,%2
5987 ml<tg>\t%0,%2"
f1e77d83 5988 [(set_attr "op_type" "RRE,RXY")
6e0d70c9 5989 (set_attr "type" "imul<dwh>")])
c7453384 5990
9db1d521 5991;
609e7e80 5992; mul(tf|df|sf|td|dd)3 instruction pattern(s).
9db1d521
HP
5993;
5994
9381e3f1 5995; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
142cd70f 5996(define_insn "mul<mode>3"
609e7e80
AK
5997 [(set (match_operand:FP 0 "register_operand" "=f,f")
5998 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5999 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
142cd70f 6000 "TARGET_HARD_FLOAT"
9db1d521 6001 "@
609e7e80 6002 m<xdee><bt>r\t%0,<op1>%2
f61a2c7d 6003 m<xdee>b\t%0,%2"
609e7e80 6004 [(set_attr "op_type" "<RRer>,RXE")
9381e3f1 6005 (set_attr "type" "fmul<mode>")])
9db1d521 6006
9381e3f1 6007; madbr, maebr, maxb, madb, maeb
d7ecb504 6008(define_insn "fma<mode>4"
f61a2c7d 6009 [(set (match_operand:DSF 0 "register_operand" "=f,f")
d7ecb504
RH
6010 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f")
6011 (match_operand:DSF 2 "nonimmediate_operand" "f,R")
f61a2c7d 6012 (match_operand:DSF 3 "register_operand" "0,0")))]
d7ecb504 6013 "TARGET_HARD_FLOAT"
a1b892b5 6014 "@
f61a2c7d
AK
6015 ma<xde>br\t%0,%1,%2
6016 ma<xde>b\t%0,%1,%2"
a1b892b5 6017 [(set_attr "op_type" "RRE,RXE")
65b1d8ea 6018 (set_attr "type" "fmadd<mode>")])
a1b892b5 6019
43a09b63 6020; msxbr, msdbr, msebr, msxb, msdb, mseb
d7ecb504 6021(define_insn "fms<mode>4"
f61a2c7d 6022 [(set (match_operand:DSF 0 "register_operand" "=f,f")
d7ecb504
RH
6023 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f")
6024 (match_operand:DSF 2 "nonimmediate_operand" "f,R")
6025 (neg:DSF (match_operand:DSF 3 "register_operand" "0,0"))))]
6026 "TARGET_HARD_FLOAT"
a1b892b5 6027 "@
f61a2c7d
AK
6028 ms<xde>br\t%0,%1,%2
6029 ms<xde>b\t%0,%1,%2"
ce50cae8 6030 [(set_attr "op_type" "RRE,RXE")
65b1d8ea 6031 (set_attr "type" "fmadd<mode>")])
9db1d521
HP
6032
6033;;
6034;;- Divide and modulo instructions.
6035;;
6036
6037;
4023fb28 6038; divmoddi4 instruction pattern(s).
9db1d521
HP
6039;
6040
4023fb28
UW
6041(define_expand "divmoddi4"
6042 [(parallel [(set (match_operand:DI 0 "general_operand" "")
f1e77d83 6043 (div:DI (match_operand:DI 1 "register_operand" "")
4023fb28
UW
6044 (match_operand:DI 2 "general_operand" "")))
6045 (set (match_operand:DI 3 "general_operand" "")
6046 (mod:DI (match_dup 1) (match_dup 2)))])
6047 (clobber (match_dup 4))]
9602b6a1 6048 "TARGET_ZARCH"
9db1d521 6049{
f1e77d83 6050 rtx insn, div_equal, mod_equal;
4023fb28
UW
6051
6052 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
6053 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
4023fb28
UW
6054
6055 operands[4] = gen_reg_rtx(TImode);
f1e77d83 6056 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
4023fb28
UW
6057
6058 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
bd94cb6e 6059 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6060
6061 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
bd94cb6e 6062 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6063
9db1d521 6064 DONE;
10bbf137 6065})
9db1d521
HP
6066
6067(define_insn "divmodtidi3"
4023fb28
UW
6068 [(set (match_operand:TI 0 "register_operand" "=d,d")
6069 (ior:TI
4023fb28
UW
6070 (ashift:TI
6071 (zero_extend:TI
5665e398 6072 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
fb492564 6073 (match_operand:DI 2 "general_operand" "d,RT")))
5665e398
UW
6074 (const_int 64))
6075 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
9602b6a1 6076 "TARGET_ZARCH"
9db1d521 6077 "@
d40c829f
UW
6078 dsgr\t%0,%2
6079 dsg\t%0,%2"
d3632d41 6080 [(set_attr "op_type" "RRE,RXY")
077dab3b 6081 (set_attr "type" "idiv")])
9db1d521 6082
4023fb28
UW
6083(define_insn "divmodtisi3"
6084 [(set (match_operand:TI 0 "register_operand" "=d,d")
6085 (ior:TI
4023fb28
UW
6086 (ashift:TI
6087 (zero_extend:TI
5665e398 6088 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
2f7e5a0d 6089 (sign_extend:DI
fb492564 6090 (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))
5665e398
UW
6091 (const_int 64))
6092 (zero_extend:TI
6093 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
9602b6a1 6094 "TARGET_ZARCH"
4023fb28 6095 "@
d40c829f
UW
6096 dsgfr\t%0,%2
6097 dsgf\t%0,%2"
d3632d41 6098 [(set_attr "op_type" "RRE,RXY")
077dab3b 6099 (set_attr "type" "idiv")])
9db1d521 6100
4023fb28
UW
6101;
6102; udivmoddi4 instruction pattern(s).
6103;
9db1d521 6104
4023fb28
UW
6105(define_expand "udivmoddi4"
6106 [(parallel [(set (match_operand:DI 0 "general_operand" "")
6107 (udiv:DI (match_operand:DI 1 "general_operand" "")
6108 (match_operand:DI 2 "nonimmediate_operand" "")))
6109 (set (match_operand:DI 3 "general_operand" "")
6110 (umod:DI (match_dup 1) (match_dup 2)))])
6111 (clobber (match_dup 4))]
9602b6a1 6112 "TARGET_ZARCH"
9db1d521 6113{
4023fb28
UW
6114 rtx insn, div_equal, mod_equal, equal;
6115
6116 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
6117 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
6118 equal = gen_rtx_IOR (TImode,
4023fb28
UW
6119 gen_rtx_ASHIFT (TImode,
6120 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
5665e398
UW
6121 GEN_INT (64)),
6122 gen_rtx_ZERO_EXTEND (TImode, div_equal));
4023fb28
UW
6123
6124 operands[4] = gen_reg_rtx(TImode);
c41c1387 6125 emit_clobber (operands[4]);
4023fb28
UW
6126 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
6127 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
bd94cb6e 6128
4023fb28 6129 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6130 set_unique_reg_note (insn, REG_EQUAL, equal);
4023fb28
UW
6131
6132 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
bd94cb6e 6133 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6134
6135 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
bd94cb6e 6136 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6137
9db1d521 6138 DONE;
10bbf137 6139})
9db1d521
HP
6140
6141(define_insn "udivmodtidi3"
4023fb28 6142 [(set (match_operand:TI 0 "register_operand" "=d,d")
2f7e5a0d 6143 (ior:TI
5665e398
UW
6144 (ashift:TI
6145 (zero_extend:TI
6146 (truncate:DI
2f7e5a0d
EC
6147 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
6148 (zero_extend:TI
fb492564 6149 (match_operand:DI 2 "nonimmediate_operand" "d,RT")))))
5665e398
UW
6150 (const_int 64))
6151 (zero_extend:TI
6152 (truncate:DI
6153 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
9602b6a1 6154 "TARGET_ZARCH"
9db1d521 6155 "@
d40c829f
UW
6156 dlgr\t%0,%2
6157 dlg\t%0,%2"
d3632d41 6158 [(set_attr "op_type" "RRE,RXY")
077dab3b 6159 (set_attr "type" "idiv")])
9db1d521
HP
6160
6161;
4023fb28 6162; divmodsi4 instruction pattern(s).
9db1d521
HP
6163;
6164
4023fb28
UW
6165(define_expand "divmodsi4"
6166 [(parallel [(set (match_operand:SI 0 "general_operand" "")
6167 (div:SI (match_operand:SI 1 "general_operand" "")
6168 (match_operand:SI 2 "nonimmediate_operand" "")))
6169 (set (match_operand:SI 3 "general_operand" "")
6170 (mod:SI (match_dup 1) (match_dup 2)))])
6171 (clobber (match_dup 4))]
9602b6a1 6172 "!TARGET_ZARCH"
9db1d521 6173{
4023fb28
UW
6174 rtx insn, div_equal, mod_equal, equal;
6175
6176 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
6177 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
6178 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6179 gen_rtx_ASHIFT (DImode,
6180 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5665e398
UW
6181 GEN_INT (32)),
6182 gen_rtx_ZERO_EXTEND (DImode, div_equal));
4023fb28
UW
6183
6184 operands[4] = gen_reg_rtx(DImode);
6185 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
bd94cb6e 6186
4023fb28 6187 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6188 set_unique_reg_note (insn, REG_EQUAL, equal);
4023fb28
UW
6189
6190 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
bd94cb6e 6191 set_unique_reg_note (insn, REG_EQUAL, div_equal);
4023fb28
UW
6192
6193 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
bd94cb6e 6194 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
9db1d521 6195
9db1d521 6196 DONE;
10bbf137 6197})
9db1d521
HP
6198
6199(define_insn "divmoddisi3"
4023fb28 6200 [(set (match_operand:DI 0 "register_operand" "=d,d")
2f7e5a0d 6201 (ior:DI
5665e398
UW
6202 (ashift:DI
6203 (zero_extend:DI
6204 (truncate:SI
2f7e5a0d
EC
6205 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
6206 (sign_extend:DI
5665e398
UW
6207 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
6208 (const_int 32))
6209 (zero_extend:DI
6210 (truncate:SI
6211 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
9602b6a1 6212 "!TARGET_ZARCH"
9db1d521 6213 "@
d40c829f
UW
6214 dr\t%0,%2
6215 d\t%0,%2"
9db1d521 6216 [(set_attr "op_type" "RR,RX")
077dab3b 6217 (set_attr "type" "idiv")])
9db1d521
HP
6218
6219;
6220; udivsi3 and umodsi3 instruction pattern(s).
6221;
6222
f1e77d83
UW
6223(define_expand "udivmodsi4"
6224 [(parallel [(set (match_operand:SI 0 "general_operand" "")
6225 (udiv:SI (match_operand:SI 1 "general_operand" "")
6226 (match_operand:SI 2 "nonimmediate_operand" "")))
6227 (set (match_operand:SI 3 "general_operand" "")
6228 (umod:SI (match_dup 1) (match_dup 2)))])
6229 (clobber (match_dup 4))]
9602b6a1 6230 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1e77d83
UW
6231{
6232 rtx insn, div_equal, mod_equal, equal;
6233
6234 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6235 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6236 equal = gen_rtx_IOR (DImode,
f1e77d83
UW
6237 gen_rtx_ASHIFT (DImode,
6238 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5665e398
UW
6239 GEN_INT (32)),
6240 gen_rtx_ZERO_EXTEND (DImode, div_equal));
f1e77d83
UW
6241
6242 operands[4] = gen_reg_rtx(DImode);
c41c1387 6243 emit_clobber (operands[4]);
f1e77d83
UW
6244 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
6245 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
bd94cb6e 6246
f1e77d83 6247 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
bd94cb6e 6248 set_unique_reg_note (insn, REG_EQUAL, equal);
f1e77d83
UW
6249
6250 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
bd94cb6e 6251 set_unique_reg_note (insn, REG_EQUAL, div_equal);
f1e77d83
UW
6252
6253 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
bd94cb6e 6254 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
f1e77d83
UW
6255
6256 DONE;
6257})
6258
6259(define_insn "udivmoddisi3"
6260 [(set (match_operand:DI 0 "register_operand" "=d,d")
2f7e5a0d 6261 (ior:DI
5665e398
UW
6262 (ashift:DI
6263 (zero_extend:DI
6264 (truncate:SI
2f7e5a0d
EC
6265 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
6266 (zero_extend:DI
fb492564 6267 (match_operand:SI 2 "nonimmediate_operand" "d,RT")))))
5665e398
UW
6268 (const_int 32))
6269 (zero_extend:DI
6270 (truncate:SI
6271 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
9602b6a1 6272 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1e77d83
UW
6273 "@
6274 dlr\t%0,%2
6275 dl\t%0,%2"
6276 [(set_attr "op_type" "RRE,RXY")
6277 (set_attr "type" "idiv")])
4023fb28 6278
9db1d521
HP
6279(define_expand "udivsi3"
6280 [(set (match_operand:SI 0 "register_operand" "=d")
6281 (udiv:SI (match_operand:SI 1 "general_operand" "")
4023fb28
UW
6282 (match_operand:SI 2 "general_operand" "")))
6283 (clobber (match_dup 3))]
9602b6a1 6284 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
9db1d521 6285{
4023fb28
UW
6286 rtx insn, udiv_equal, umod_equal, equal;
6287
6288 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6289 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6290 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6291 gen_rtx_ASHIFT (DImode,
6292 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5665e398
UW
6293 GEN_INT (32)),
6294 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
9db1d521 6295
4023fb28 6296 operands[3] = gen_reg_rtx (DImode);
9db1d521
HP
6297
6298 if (CONSTANT_P (operands[2]))
6299 {
6300 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
6301 {
19f8b229 6302 rtx_code_label *label1 = gen_label_rtx ();
9db1d521 6303
4023fb28
UW
6304 operands[1] = make_safe_from (operands[1], operands[0]);
6305 emit_move_insn (operands[0], const0_rtx);
f90b7a5a
PB
6306 emit_cmp_and_jump_insns (operands[1], operands[2], LT, NULL_RTX,
6307 SImode, 1, label1);
4023fb28 6308 emit_move_insn (operands[0], const1_rtx);
9db1d521
HP
6309 emit_label (label1);
6310 }
6311 else
6312 {
c7453384
EC
6313 operands[2] = force_reg (SImode, operands[2]);
6314 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
6315
6316 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6317 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6318 operands[2]));
bd94cb6e 6319 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
6320
6321 insn = emit_move_insn (operands[0],
4023fb28 6322 gen_lowpart (SImode, operands[3]));
bd94cb6e 6323 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
9db1d521
HP
6324 }
6325 }
6326 else
c7453384 6327 {
19f8b229
TS
6328 rtx_code_label *label1 = gen_label_rtx ();
6329 rtx_code_label *label2 = gen_label_rtx ();
6330 rtx_code_label *label3 = gen_label_rtx ();
9db1d521 6331
c7453384
EC
6332 operands[1] = force_reg (SImode, operands[1]);
6333 operands[1] = make_safe_from (operands[1], operands[0]);
6334 operands[2] = force_reg (SImode, operands[2]);
6335 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
6336
6337 emit_move_insn (operands[0], const0_rtx);
f90b7a5a
PB
6338 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
6339 SImode, 1, label3);
6340 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
6341 SImode, 0, label2);
6342 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
6343 SImode, 0, label1);
4023fb28
UW
6344 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6345 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6346 operands[2]));
bd94cb6e 6347 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
6348
6349 insn = emit_move_insn (operands[0],
4023fb28 6350 gen_lowpart (SImode, operands[3]));
bd94cb6e
SB
6351 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
6352
f314b9b1 6353 emit_jump (label3);
9db1d521 6354 emit_label (label1);
4023fb28 6355 emit_move_insn (operands[0], operands[1]);
f314b9b1 6356 emit_jump (label3);
9db1d521 6357 emit_label (label2);
4023fb28 6358 emit_move_insn (operands[0], const1_rtx);
9db1d521
HP
6359 emit_label (label3);
6360 }
c7453384 6361 emit_move_insn (operands[0], operands[0]);
9db1d521 6362 DONE;
10bbf137 6363})
9db1d521
HP
6364
6365(define_expand "umodsi3"
6366 [(set (match_operand:SI 0 "register_operand" "=d")
6367 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
4023fb28
UW
6368 (match_operand:SI 2 "nonimmediate_operand" "")))
6369 (clobber (match_dup 3))]
9602b6a1 6370 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
9db1d521 6371{
4023fb28
UW
6372 rtx insn, udiv_equal, umod_equal, equal;
6373
6374 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6375 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6376 equal = gen_rtx_IOR (DImode,
4023fb28
UW
6377 gen_rtx_ASHIFT (DImode,
6378 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5665e398
UW
6379 GEN_INT (32)),
6380 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
9db1d521 6381
4023fb28 6382 operands[3] = gen_reg_rtx (DImode);
9db1d521
HP
6383
6384 if (CONSTANT_P (operands[2]))
6385 {
6386 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
6387 {
19f8b229 6388 rtx_code_label *label1 = gen_label_rtx ();
9db1d521 6389
4023fb28
UW
6390 operands[1] = make_safe_from (operands[1], operands[0]);
6391 emit_move_insn (operands[0], operands[1]);
f90b7a5a
PB
6392 emit_cmp_and_jump_insns (operands[0], operands[2], LT, NULL_RTX,
6393 SImode, 1, label1);
4023fb28
UW
6394 emit_insn (gen_abssi2 (operands[0], operands[2]));
6395 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
9db1d521
HP
6396 emit_label (label1);
6397 }
6398 else
6399 {
c7453384
EC
6400 operands[2] = force_reg (SImode, operands[2]);
6401 operands[2] = make_safe_from (operands[2], operands[0]);
4023fb28
UW
6402
6403 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6404 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6405 operands[2]));
bd94cb6e 6406 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
6407
6408 insn = emit_move_insn (operands[0],
4023fb28 6409 gen_highpart (SImode, operands[3]));
bd94cb6e 6410 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
9db1d521
HP
6411 }
6412 }
6413 else
6414 {
19f8b229
TS
6415 rtx_code_label *label1 = gen_label_rtx ();
6416 rtx_code_label *label2 = gen_label_rtx ();
6417 rtx_code_label *label3 = gen_label_rtx ();
9db1d521 6418
c7453384
EC
6419 operands[1] = force_reg (SImode, operands[1]);
6420 operands[1] = make_safe_from (operands[1], operands[0]);
6421 operands[2] = force_reg (SImode, operands[2]);
6422 operands[2] = make_safe_from (operands[2], operands[0]);
9db1d521 6423
c7453384 6424 emit_move_insn(operands[0], operands[1]);
f90b7a5a
PB
6425 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
6426 SImode, 1, label3);
6427 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
6428 SImode, 0, label2);
6429 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
6430 SImode, 0, label1);
4023fb28
UW
6431 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6432 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6433 operands[2]));
bd94cb6e 6434 set_unique_reg_note (insn, REG_EQUAL, equal);
c7453384
EC
6435
6436 insn = emit_move_insn (operands[0],
4023fb28 6437 gen_highpart (SImode, operands[3]));
bd94cb6e
SB
6438 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
6439
f314b9b1 6440 emit_jump (label3);
9db1d521 6441 emit_label (label1);
4023fb28 6442 emit_move_insn (operands[0], const0_rtx);
f314b9b1 6443 emit_jump (label3);
9db1d521 6444 emit_label (label2);
4023fb28 6445 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
9db1d521
HP
6446 emit_label (label3);
6447 }
9db1d521 6448 DONE;
10bbf137 6449})
9db1d521
HP
6450
6451;
f5905b37 6452; div(df|sf)3 instruction pattern(s).
9db1d521
HP
6453;
6454
609e7e80 6455; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
142cd70f 6456(define_insn "div<mode>3"
609e7e80
AK
6457 [(set (match_operand:FP 0 "register_operand" "=f,f")
6458 (div:FP (match_operand:FP 1 "register_operand" "<f0>,0")
6459 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
142cd70f 6460 "TARGET_HARD_FLOAT"
9db1d521 6461 "@
609e7e80 6462 d<xde><bt>r\t%0,<op1>%2
f61a2c7d 6463 d<xde>b\t%0,%2"
609e7e80 6464 [(set_attr "op_type" "<RRer>,RXE")
9381e3f1 6465 (set_attr "type" "fdiv<mode>")])
9db1d521 6466
9db1d521
HP
6467
6468;;
6469;;- And instructions.
6470;;
6471
047d35ed
AS
6472(define_expand "and<mode>3"
6473 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6474 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
6475 (match_operand:INT 2 "general_operand" "")))
6476 (clobber (reg:CC CC_REGNUM))]
6477 ""
6478 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
6479
9db1d521
HP
6480;
6481; anddi3 instruction pattern(s).
6482;
6483
6484(define_insn "*anddi3_cc"
ae156f85 6485 [(set (reg CC_REGNUM)
e3140518
RH
6486 (compare
6487 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0, d")
6488 (match_operand:DI 2 "general_operand" " d,d,RT,NxxDq"))
6489 (const_int 0)))
6490 (set (match_operand:DI 0 "register_operand" "=d,d, d, d")
9db1d521 6491 (and:DI (match_dup 1) (match_dup 2)))]
e3140518 6492 "TARGET_ZARCH && s390_match_ccmode(insn, CCTmode)"
9db1d521 6493 "@
d40c829f 6494 ngr\t%0,%2
65b1d8ea 6495 ngrk\t%0,%1,%2
e3140518
RH
6496 ng\t%0,%2
6497 risbg\t%0,%1,%s2,128+%e2,0"
6498 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
6499 (set_attr "cpu_facility" "*,z196,*,z10")
6500 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521
HP
6501
6502(define_insn "*anddi3_cconly"
ae156f85 6503 [(set (reg CC_REGNUM)
e3140518
RH
6504 (compare
6505 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0, d")
6506 (match_operand:DI 2 "general_operand" " d,d,RT,NxxDq"))
9db1d521 6507 (const_int 0)))
e3140518
RH
6508 (clobber (match_scratch:DI 0 "=d,d, d, d"))]
6509 "TARGET_ZARCH
6510 && s390_match_ccmode(insn, CCTmode)
68f9c5e2
UW
6511 /* Do not steal TM patterns. */
6512 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
9db1d521 6513 "@
d40c829f 6514 ngr\t%0,%2
65b1d8ea 6515 ngrk\t%0,%1,%2
e3140518
RH
6516 ng\t%0,%2
6517 risbg\t%0,%1,%s2,128+%e2,0"
6518 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
6519 (set_attr "cpu_facility" "*,z196,*,z10")
6520 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
9db1d521 6521
3af8e996 6522(define_insn "*anddi3"
65b1d8ea 6523 [(set (match_operand:DI 0 "nonimmediate_operand"
e3140518
RH
6524 "=d,d, d, d, d, d, d, d,d,d, d, d, AQ,Q")
6525 (and:DI
6526 (match_operand:DI 1 "nonimmediate_operand"
6527 "%d,o, 0, 0, 0, 0, 0, 0,0,d, 0, d, 0,0")
6528 (match_operand:DI 2 "general_operand"
6529 "M, M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,d,RT,NxxDq,NxQDF,Q")))
ec24698e 6530 (clobber (reg:CC CC_REGNUM))]
9602b6a1 6531 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
6532 "@
6533 #
6534 #
6535 nihh\t%0,%j2
6536 nihl\t%0,%j2
6537 nilh\t%0,%j2
6538 nill\t%0,%j2
6539 nihf\t%0,%m2
6540 nilf\t%0,%m2
6541 ngr\t%0,%2
65b1d8ea 6542 ngrk\t%0,%1,%2
ec24698e 6543 ng\t%0,%2
e3140518 6544 risbg\t%0,%1,%s2,128+%e2,0
ec24698e
UW
6545 #
6546 #"
e3140518
RH
6547 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,RIE,SI,SS")
6548 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,z196,*,z10,*,*")
9381e3f1
WG
6549 (set_attr "z10prop" "*,
6550 *,
6551 z10_super_E1,
6552 z10_super_E1,
6553 z10_super_E1,
6554 z10_super_E1,
6555 z10_super_E1,
6556 z10_super_E1,
6557 z10_super_E1,
65b1d8ea 6558 *,
9381e3f1 6559 z10_super_E1,
e3140518 6560 z10_super_E1,
9381e3f1
WG
6561 *,
6562 *")])
0dfa6c5e
UW
6563
6564(define_split
6565 [(set (match_operand:DI 0 "s_operand" "")
6566 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 6567 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
6568 "reload_completed"
6569 [(parallel
6570 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 6571 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 6572 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
4023fb28 6573
1a2e356e
RH
6574;; These two are what combine generates for (ashift (zero_extract)).
6575(define_insn "*extzv_<mode>_srl"
6576 [(set (match_operand:GPR 0 "register_operand" "=d")
6577 (and:GPR (lshiftrt:GPR
6578 (match_operand:GPR 1 "register_operand" "d")
6579 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
6580 (match_operand:GPR 3 "contiguous_bitmask_operand" "")))
6581 (clobber (reg:CC CC_REGNUM))]
6582 "TARGET_Z10
6583 /* Note that even for the SImode pattern, the rotate is always DImode. */
6584 && s390_extzv_shift_ok (<bitsize>, -INTVAL (operands[2]),
6585 INTVAL (operands[3]))"
6586 "risbg\t%0,%1,%<bfstart>3,128+%<bfend>3,64-%2"
6587 [(set_attr "op_type" "RIE")
6588 (set_attr "z10prop" "z10_super_E1")])
6589
6590(define_insn "*extzv_<mode>_sll"
6591 [(set (match_operand:GPR 0 "register_operand" "=d")
6592 (and:GPR (ashift:GPR
6593 (match_operand:GPR 1 "register_operand" "d")
6594 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
6595 (match_operand:GPR 3 "contiguous_bitmask_operand" "")))
6596 (clobber (reg:CC CC_REGNUM))]
6597 "TARGET_Z10
6598 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[2]),
6599 INTVAL (operands[3]))"
6600 "risbg\t%0,%1,%<bfstart>3,128+%<bfend>3,%2"
6601 [(set_attr "op_type" "RIE")
6602 (set_attr "z10prop" "z10_super_E1")])
6603
9db1d521
HP
6604
6605;
6606; andsi3 instruction pattern(s).
6607;
6608
6609(define_insn "*andsi3_cc"
ae156f85 6610 [(set (reg CC_REGNUM)
e3140518
RH
6611 (compare
6612 (and:SI
6613 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
6614 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
6615 (const_int 0)))
6616 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d, d")
9db1d521
HP
6617 (and:SI (match_dup 1) (match_dup 2)))]
6618 "s390_match_ccmode(insn, CCTmode)"
6619 "@
ec24698e 6620 nilf\t%0,%o2
d40c829f 6621 nr\t%0,%2
65b1d8ea 6622 nrk\t%0,%1,%2
d40c829f 6623 n\t%0,%2
e3140518
RH
6624 ny\t%0,%2
6625 risbg\t%0,%1,%t2,128+%f2,0"
6626 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
6627 (set_attr "cpu_facility" "*,*,z196,*,*,z10")
6628 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
6629 z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521
HP
6630
6631(define_insn "*andsi3_cconly"
ae156f85 6632 [(set (reg CC_REGNUM)
e3140518
RH
6633 (compare
6634 (and:SI
6635 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
6636 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
6637 (const_int 0)))
6638 (clobber (match_scratch:SI 0 "=d,d,d,d,d, d"))]
68f9c5e2
UW
6639 "s390_match_ccmode(insn, CCTmode)
6640 /* Do not steal TM patterns. */
6641 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
9db1d521 6642 "@
ec24698e 6643 nilf\t%0,%o2
d40c829f 6644 nr\t%0,%2
65b1d8ea 6645 nrk\t%0,%1,%2
d40c829f 6646 n\t%0,%2
e3140518
RH
6647 ny\t%0,%2
6648 risbg\t%0,%1,%t2,128+%f2,0"
6649 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
6650 (set_attr "cpu_facility" "*,*,z196,*,*,z10")
65b1d8ea 6651 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
e3140518 6652 z10_super_E1,z10_super_E1,z10_super_E1")])
9db1d521 6653
f19a9af7 6654(define_insn "*andsi3_zarch"
65b1d8ea 6655 [(set (match_operand:SI 0 "nonimmediate_operand"
e3140518 6656 "=d,d, d, d, d,d,d,d,d, d, AQ,Q")
0dfa6c5e 6657 (and:SI (match_operand:SI 1 "nonimmediate_operand"
e3140518 6658 "%d,o, 0, 0, 0,0,d,0,0, d, 0,0")
0dfa6c5e 6659 (match_operand:SI 2 "general_operand"
e3140518 6660 " M,M,N0HSF,N1HSF,Os,d,d,R,T,NxxSq,NxQSF,Q")))
ae156f85 6661 (clobber (reg:CC CC_REGNUM))]
8cb66696 6662 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 6663 "@
f19a9af7
AK
6664 #
6665 #
6666 nilh\t%0,%j2
2f7e5a0d 6667 nill\t%0,%j2
ec24698e 6668 nilf\t%0,%o2
d40c829f 6669 nr\t%0,%2
65b1d8ea 6670 nrk\t%0,%1,%2
d40c829f 6671 n\t%0,%2
8cb66696 6672 ny\t%0,%2
e3140518 6673 risbg\t%0,%1,%t2,128+%f2,0
0dfa6c5e 6674 #
19b63d8e 6675 #"
e3140518
RH
6676 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RRF,RX,RXY,RIE,SI,SS")
6677 (set_attr "cpu_facility" "*,*,*,*,*,*,z196,*,*,z10,*,*")
9381e3f1
WG
6678 (set_attr "z10prop" "*,
6679 *,
6680 z10_super_E1,
6681 z10_super_E1,
6682 z10_super_E1,
6683 z10_super_E1,
65b1d8ea 6684 *,
9381e3f1
WG
6685 z10_super_E1,
6686 z10_super_E1,
e3140518 6687 z10_super_E1,
9381e3f1
WG
6688 *,
6689 *")])
f19a9af7
AK
6690
6691(define_insn "*andsi3_esa"
65b1d8ea
AK
6692 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d, AQ,Q")
6693 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0, 0,0")
6694 (match_operand:SI 2 "general_operand" " d,R,NxQSF,Q")))
ae156f85 6695 (clobber (reg:CC CC_REGNUM))]
8cb66696 6696 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
f19a9af7
AK
6697 "@
6698 nr\t%0,%2
8cb66696 6699 n\t%0,%2
0dfa6c5e 6700 #
19b63d8e 6701 #"
9381e3f1
WG
6702 [(set_attr "op_type" "RR,RX,SI,SS")
6703 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6704
0dfa6c5e
UW
6705
6706(define_split
6707 [(set (match_operand:SI 0 "s_operand" "")
6708 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 6709 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
6710 "reload_completed"
6711 [(parallel
6712 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 6713 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 6714 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
4023fb28 6715
9db1d521
HP
6716;
6717; andhi3 instruction pattern(s).
6718;
6719
8cb66696 6720(define_insn "*andhi3_zarch"
65b1d8ea
AK
6721 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
6722 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
6723 (match_operand:HI 2 "general_operand" " d,d,n,NxQHF,Q")))
ae156f85 6724 (clobber (reg:CC CC_REGNUM))]
8cb66696 6725 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 6726 "@
d40c829f 6727 nr\t%0,%2
65b1d8ea 6728 nrk\t%0,%1,%2
8cb66696 6729 nill\t%0,%x2
0dfa6c5e 6730 #
19b63d8e 6731 #"
65b1d8ea
AK
6732 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
6733 (set_attr "cpu_facility" "*,z196,*,*,*")
6734 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")
9381e3f1 6735])
8cb66696
UW
6736
6737(define_insn "*andhi3_esa"
0dfa6c5e
UW
6738 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
6739 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
6740 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
ae156f85 6741 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
6742 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6743 "@
6744 nr\t%0,%2
0dfa6c5e 6745 #
19b63d8e 6746 #"
9381e3f1
WG
6747 [(set_attr "op_type" "RR,SI,SS")
6748 (set_attr "z10prop" "z10_super_E1,*,*")
6749])
0dfa6c5e
UW
6750
6751(define_split
6752 [(set (match_operand:HI 0 "s_operand" "")
6753 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 6754 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
6755 "reload_completed"
6756 [(parallel
6757 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
ae156f85 6758 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 6759 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
9db1d521 6760
9db1d521
HP
6761;
6762; andqi3 instruction pattern(s).
6763;
6764
8cb66696 6765(define_insn "*andqi3_zarch"
65b1d8ea
AK
6766 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
6767 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
6768 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
ae156f85 6769 (clobber (reg:CC CC_REGNUM))]
8cb66696 6770 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 6771 "@
d40c829f 6772 nr\t%0,%2
65b1d8ea 6773 nrk\t%0,%1,%2
8cb66696 6774 nill\t%0,%b2
fc0ea003
UW
6775 ni\t%S0,%b2
6776 niy\t%S0,%b2
19b63d8e 6777 #"
65b1d8ea
AK
6778 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
6779 (set_attr "cpu_facility" "*,z196,*,*,*,*")
6780 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super,z10_super,*")])
8cb66696
UW
6781
6782(define_insn "*andqi3_esa"
6783 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
6784 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6785 (match_operand:QI 2 "general_operand" "d,n,Q")))
ae156f85 6786 (clobber (reg:CC CC_REGNUM))]
8cb66696 6787 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 6788 "@
8cb66696 6789 nr\t%0,%2
fc0ea003 6790 ni\t%S0,%b2
19b63d8e 6791 #"
9381e3f1
WG
6792 [(set_attr "op_type" "RR,SI,SS")
6793 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
4023fb28 6794
19b63d8e
UW
6795;
6796; Block and (NC) patterns.
6797;
6798
6799(define_insn "*nc"
6800 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6801 (and:BLK (match_dup 0)
6802 (match_operand:BLK 1 "memory_operand" "Q")))
6803 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 6804 (clobber (reg:CC CC_REGNUM))]
19b63d8e 6805 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 6806 "nc\t%O0(%2,%R0),%S1"
65b1d8ea
AK
6807 [(set_attr "op_type" "SS")
6808 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
6809
6810(define_split
6811 [(set (match_operand 0 "memory_operand" "")
6812 (and (match_dup 0)
6813 (match_operand 1 "memory_operand" "")))
ae156f85 6814 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
6815 "reload_completed
6816 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6817 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6818 [(parallel
6819 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
6820 (use (match_dup 2))
ae156f85 6821 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
6822{
6823 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6824 operands[0] = adjust_address (operands[0], BLKmode, 0);
6825 operands[1] = adjust_address (operands[1], BLKmode, 0);
6826})
6827
6828(define_peephole2
6829 [(parallel
6830 [(set (match_operand:BLK 0 "memory_operand" "")
6831 (and:BLK (match_dup 0)
6832 (match_operand:BLK 1 "memory_operand" "")))
6833 (use (match_operand 2 "const_int_operand" ""))
ae156f85 6834 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
6835 (parallel
6836 [(set (match_operand:BLK 3 "memory_operand" "")
6837 (and:BLK (match_dup 3)
6838 (match_operand:BLK 4 "memory_operand" "")))
6839 (use (match_operand 5 "const_int_operand" ""))
ae156f85 6840 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
6841 "s390_offset_p (operands[0], operands[3], operands[2])
6842 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 6843 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 6844 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
6845 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6846 [(parallel
6847 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
6848 (use (match_dup 8))
ae156f85 6849 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
6850 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6851 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6852 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6853
9db1d521
HP
6854
6855;;
6856;;- Bit set (inclusive or) instructions.
6857;;
6858
047d35ed
AS
6859(define_expand "ior<mode>3"
6860 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6861 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
6862 (match_operand:INT 2 "general_operand" "")))
6863 (clobber (reg:CC CC_REGNUM))]
6864 ""
6865 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
6866
9db1d521
HP
6867;
6868; iordi3 instruction pattern(s).
6869;
6870
4023fb28 6871(define_insn "*iordi3_cc"
ae156f85 6872 [(set (reg CC_REGNUM)
65b1d8ea
AK
6873 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
6874 (match_operand:DI 2 "general_operand" " d,d,RT"))
4023fb28 6875 (const_int 0)))
65b1d8ea 6876 (set (match_operand:DI 0 "register_operand" "=d,d, d")
4023fb28 6877 (ior:DI (match_dup 1) (match_dup 2)))]
9602b6a1 6878 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 6879 "@
d40c829f 6880 ogr\t%0,%2
65b1d8ea 6881 ogrk\t%0,%1,%2
d40c829f 6882 og\t%0,%2"
65b1d8ea
AK
6883 [(set_attr "op_type" "RRE,RRF,RXY")
6884 (set_attr "cpu_facility" "*,z196,*")
6885 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28
UW
6886
6887(define_insn "*iordi3_cconly"
ae156f85 6888 [(set (reg CC_REGNUM)
65b1d8ea
AK
6889 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
6890 (match_operand:DI 2 "general_operand" " d,d,RT"))
4023fb28 6891 (const_int 0)))
65b1d8ea 6892 (clobber (match_scratch:DI 0 "=d,d,d"))]
9602b6a1 6893 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 6894 "@
d40c829f 6895 ogr\t%0,%2
65b1d8ea 6896 ogrk\t%0,%1,%2
d40c829f 6897 og\t%0,%2"
65b1d8ea
AK
6898 [(set_attr "op_type" "RRE,RRF,RXY")
6899 (set_attr "cpu_facility" "*,z196,*")
6900 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28 6901
3af8e996 6902(define_insn "*iordi3"
65b1d8ea
AK
6903 [(set (match_operand:DI 0 "nonimmediate_operand"
6904 "=d, d, d, d, d, d,d,d, d, AQ,Q")
6905 (ior:DI (match_operand:DI 1 "nonimmediate_operand"
6906 " %0, 0, 0, 0, 0, 0,0,d, 0, 0,0")
ec24698e 6907 (match_operand:DI 2 "general_operand"
65b1d8ea 6908 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,d,RT,NxQD0,Q")))
ec24698e 6909 (clobber (reg:CC CC_REGNUM))]
9602b6a1 6910 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
6911 "@
6912 oihh\t%0,%i2
6913 oihl\t%0,%i2
6914 oilh\t%0,%i2
6915 oill\t%0,%i2
6916 oihf\t%0,%k2
6917 oilf\t%0,%k2
6918 ogr\t%0,%2
65b1d8ea 6919 ogrk\t%0,%1,%2
ec24698e
UW
6920 og\t%0,%2
6921 #
6922 #"
65b1d8ea
AK
6923 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,SI,SS")
6924 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,z196,*,*,*")
9381e3f1
WG
6925 (set_attr "z10prop" "z10_super_E1,
6926 z10_super_E1,
6927 z10_super_E1,
6928 z10_super_E1,
6929 z10_super_E1,
6930 z10_super_E1,
6931 z10_super_E1,
65b1d8ea 6932 *,
9381e3f1
WG
6933 z10_super_E1,
6934 *,
6935 *")])
0dfa6c5e
UW
6936
6937(define_split
6938 [(set (match_operand:DI 0 "s_operand" "")
6939 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 6940 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
6941 "reload_completed"
6942 [(parallel
6943 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 6944 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 6945 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
4023fb28 6946
9db1d521
HP
6947;
6948; iorsi3 instruction pattern(s).
6949;
6950
4023fb28 6951(define_insn "*iorsi3_cc"
ae156f85 6952 [(set (reg CC_REGNUM)
65b1d8ea
AK
6953 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
6954 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 6955 (const_int 0)))
65b1d8ea 6956 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
4023fb28
UW
6957 (ior:SI (match_dup 1) (match_dup 2)))]
6958 "s390_match_ccmode(insn, CCTmode)"
6959 "@
ec24698e 6960 oilf\t%0,%o2
d40c829f 6961 or\t%0,%2
65b1d8ea 6962 ork\t%0,%1,%2
d40c829f
UW
6963 o\t%0,%2
6964 oy\t%0,%2"
65b1d8ea
AK
6965 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
6966 (set_attr "cpu_facility" "*,*,z196,*,*")
6967 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
4023fb28
UW
6968
6969(define_insn "*iorsi3_cconly"
ae156f85 6970 [(set (reg CC_REGNUM)
65b1d8ea
AK
6971 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
6972 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 6973 (const_int 0)))
65b1d8ea 6974 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
4023fb28
UW
6975 "s390_match_ccmode(insn, CCTmode)"
6976 "@
ec24698e 6977 oilf\t%0,%o2
d40c829f 6978 or\t%0,%2
65b1d8ea 6979 ork\t%0,%1,%2
d40c829f
UW
6980 o\t%0,%2
6981 oy\t%0,%2"
65b1d8ea
AK
6982 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
6983 (set_attr "cpu_facility" "*,*,z196,*,*")
6984 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
4023fb28 6985
8cb66696 6986(define_insn "*iorsi3_zarch"
65b1d8ea
AK
6987 [(set (match_operand:SI 0 "nonimmediate_operand" "=d, d, d,d,d,d,d, AQ,Q")
6988 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0, 0, 0,0,d,0,0, 0,0")
6989 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,d,R,T,NxQS0,Q")))
ae156f85 6990 (clobber (reg:CC CC_REGNUM))]
8cb66696 6991 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 6992 "@
f19a9af7
AK
6993 oilh\t%0,%i2
6994 oill\t%0,%i2
ec24698e 6995 oilf\t%0,%o2
d40c829f 6996 or\t%0,%2
65b1d8ea 6997 ork\t%0,%1,%2
d40c829f 6998 o\t%0,%2
8cb66696 6999 oy\t%0,%2
0dfa6c5e 7000 #
19b63d8e 7001 #"
65b1d8ea
AK
7002 [(set_attr "op_type" "RI,RI,RIL,RR,RRF,RX,RXY,SI,SS")
7003 (set_attr "cpu_facility" "*,*,*,*,z196,*,*,*,*")
9381e3f1
WG
7004 (set_attr "z10prop" "z10_super_E1,
7005 z10_super_E1,
7006 z10_super_E1,
7007 z10_super_E1,
65b1d8ea 7008 *,
9381e3f1
WG
7009 z10_super_E1,
7010 z10_super_E1,
7011 *,
7012 *")])
8cb66696
UW
7013
7014(define_insn "*iorsi3_esa"
0dfa6c5e 7015 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
bad82153 7016 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
0dfa6c5e 7017 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
ae156f85 7018 (clobber (reg:CC CC_REGNUM))]
8cb66696 7019 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
f19a9af7
AK
7020 "@
7021 or\t%0,%2
8cb66696 7022 o\t%0,%2
0dfa6c5e 7023 #
19b63d8e 7024 #"
9381e3f1
WG
7025 [(set_attr "op_type" "RR,RX,SI,SS")
7026 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
0dfa6c5e
UW
7027
7028(define_split
7029 [(set (match_operand:SI 0 "s_operand" "")
7030 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 7031 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7032 "reload_completed"
7033 [(parallel
7034 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 7035 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7036 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
4023fb28 7037
4023fb28
UW
7038;
7039; iorhi3 instruction pattern(s).
7040;
7041
8cb66696 7042(define_insn "*iorhi3_zarch"
65b1d8ea
AK
7043 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7044 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
7045 (match_operand:HI 2 "general_operand" " d,d,n,NxQH0,Q")))
ae156f85 7046 (clobber (reg:CC CC_REGNUM))]
8cb66696 7047 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7048 "@
d40c829f 7049 or\t%0,%2
65b1d8ea 7050 ork\t%0,%1,%2
8cb66696 7051 oill\t%0,%x2
0dfa6c5e 7052 #
19b63d8e 7053 #"
65b1d8ea
AK
7054 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
7055 (set_attr "cpu_facility" "*,z196,*,*,*")
7056 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")])
8cb66696
UW
7057
7058(define_insn "*iorhi3_esa"
0dfa6c5e
UW
7059 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
7060 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
7061 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
ae156f85 7062 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
7063 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7064 "@
7065 or\t%0,%2
0dfa6c5e 7066 #
19b63d8e 7067 #"
9381e3f1
WG
7068 [(set_attr "op_type" "RR,SI,SS")
7069 (set_attr "z10prop" "z10_super_E1,*,*")])
0dfa6c5e
UW
7070
7071(define_split
7072 [(set (match_operand:HI 0 "s_operand" "")
7073 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 7074 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7075 "reload_completed"
7076 [(parallel
7077 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
ae156f85 7078 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7079 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
9db1d521 7080
9db1d521 7081;
4023fb28 7082; iorqi3 instruction pattern(s).
9db1d521
HP
7083;
7084
8cb66696 7085(define_insn "*iorqi3_zarch"
65b1d8ea
AK
7086 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7087 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7088 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
ae156f85 7089 (clobber (reg:CC CC_REGNUM))]
8cb66696 7090 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
4023fb28 7091 "@
d40c829f 7092 or\t%0,%2
65b1d8ea 7093 ork\t%0,%1,%2
8cb66696 7094 oill\t%0,%b2
fc0ea003
UW
7095 oi\t%S0,%b2
7096 oiy\t%S0,%b2
19b63d8e 7097 #"
65b1d8ea
AK
7098 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
7099 (set_attr "cpu_facility" "*,z196,*,*,*,*")
7100 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,
7101 z10_super,z10_super,*")])
8cb66696
UW
7102
7103(define_insn "*iorqi3_esa"
7104 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
7105 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7106 (match_operand:QI 2 "general_operand" "d,n,Q")))
ae156f85 7107 (clobber (reg:CC CC_REGNUM))]
8cb66696 7108 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
9db1d521 7109 "@
8cb66696 7110 or\t%0,%2
fc0ea003 7111 oi\t%S0,%b2
19b63d8e 7112 #"
9381e3f1
WG
7113 [(set_attr "op_type" "RR,SI,SS")
7114 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
9db1d521 7115
19b63d8e
UW
7116;
7117; Block inclusive or (OC) patterns.
7118;
7119
7120(define_insn "*oc"
7121 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7122 (ior:BLK (match_dup 0)
7123 (match_operand:BLK 1 "memory_operand" "Q")))
7124 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 7125 (clobber (reg:CC CC_REGNUM))]
19b63d8e 7126 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 7127 "oc\t%O0(%2,%R0),%S1"
65b1d8ea
AK
7128 [(set_attr "op_type" "SS")
7129 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
7130
7131(define_split
7132 [(set (match_operand 0 "memory_operand" "")
7133 (ior (match_dup 0)
7134 (match_operand 1 "memory_operand" "")))
ae156f85 7135 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
7136 "reload_completed
7137 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7138 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7139 [(parallel
7140 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
7141 (use (match_dup 2))
ae156f85 7142 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7143{
7144 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7145 operands[0] = adjust_address (operands[0], BLKmode, 0);
7146 operands[1] = adjust_address (operands[1], BLKmode, 0);
7147})
7148
7149(define_peephole2
7150 [(parallel
7151 [(set (match_operand:BLK 0 "memory_operand" "")
7152 (ior:BLK (match_dup 0)
7153 (match_operand:BLK 1 "memory_operand" "")))
7154 (use (match_operand 2 "const_int_operand" ""))
ae156f85 7155 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
7156 (parallel
7157 [(set (match_operand:BLK 3 "memory_operand" "")
7158 (ior:BLK (match_dup 3)
7159 (match_operand:BLK 4 "memory_operand" "")))
7160 (use (match_operand 5 "const_int_operand" ""))
ae156f85 7161 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7162 "s390_offset_p (operands[0], operands[3], operands[2])
7163 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 7164 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 7165 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
7166 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7167 [(parallel
7168 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
7169 (use (match_dup 8))
ae156f85 7170 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7171 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7172 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7173 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7174
9db1d521
HP
7175
7176;;
7177;;- Xor instructions.
7178;;
7179
047d35ed
AS
7180(define_expand "xor<mode>3"
7181 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7182 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
7183 (match_operand:INT 2 "general_operand" "")))
7184 (clobber (reg:CC CC_REGNUM))]
7185 ""
7186 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
7187
3c91f126
AK
7188; Combine replaces (xor (x) (const_int -1)) with (not (x)) when doing
7189; simplifications. So its better to have something matching.
7190(define_split
7191 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7192 (not:INT (match_operand:INT 1 "nonimmediate_operand" "")))]
7193 ""
7194 [(parallel
7195 [(set (match_dup 0) (xor:INT (match_dup 1) (match_dup 2)))
7196 (clobber (reg:CC CC_REGNUM))])]
7197{
7198 operands[2] = constm1_rtx;
7199 if (!s390_logical_operator_ok_p (operands))
7200 FAIL;
7201})
7202
9db1d521
HP
7203;
7204; xordi3 instruction pattern(s).
7205;
7206
4023fb28 7207(define_insn "*xordi3_cc"
ae156f85 7208 [(set (reg CC_REGNUM)
65b1d8ea
AK
7209 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
7210 (match_operand:DI 2 "general_operand" " d,d,RT"))
4023fb28 7211 (const_int 0)))
65b1d8ea 7212 (set (match_operand:DI 0 "register_operand" "=d,d, d")
4023fb28 7213 (xor:DI (match_dup 1) (match_dup 2)))]
9602b6a1 7214 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7215 "@
d40c829f 7216 xgr\t%0,%2
65b1d8ea 7217 xgrk\t%0,%1,%2
d40c829f 7218 xg\t%0,%2"
65b1d8ea 7219 [(set_attr "op_type" "RRE,RRF,RXY")
5490de28 7220 (set_attr "cpu_facility" "*,z196,*")
65b1d8ea 7221 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28
UW
7222
7223(define_insn "*xordi3_cconly"
ae156f85 7224 [(set (reg CC_REGNUM)
65b1d8ea
AK
7225 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
7226 (match_operand:DI 2 "general_operand" " d,d,RT"))
4023fb28 7227 (const_int 0)))
65b1d8ea 7228 (clobber (match_scratch:DI 0 "=d,d, d"))]
9602b6a1 7229 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
4023fb28 7230 "@
d40c829f 7231 xgr\t%0,%2
65b1d8ea 7232 xgrk\t%0,%1,%2
c7fd8cd8 7233 xg\t%0,%2"
65b1d8ea
AK
7234 [(set_attr "op_type" "RRE,RRF,RXY")
7235 (set_attr "cpu_facility" "*,z196,*")
7236 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
4023fb28 7237
3af8e996 7238(define_insn "*xordi3"
65b1d8ea
AK
7239 [(set (match_operand:DI 0 "nonimmediate_operand" "=d, d,d,d, d, AQ,Q")
7240 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0, 0,0,d, 0, 0,0")
7241 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,d,RT,NxQD0,Q")))
ec24698e 7242 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7243 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
ec24698e
UW
7244 "@
7245 xihf\t%0,%k2
7246 xilf\t%0,%k2
7247 xgr\t%0,%2
65b1d8ea 7248 xgrk\t%0,%1,%2
ec24698e
UW
7249 xg\t%0,%2
7250 #
7251 #"
65b1d8ea
AK
7252 [(set_attr "op_type" "RIL,RIL,RRE,RRF,RXY,SI,SS")
7253 (set_attr "cpu_facility" "extimm,extimm,*,z196,*,*,*")
7254 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,
7255 *,z10_super_E1,*,*")])
0dfa6c5e
UW
7256
7257(define_split
7258 [(set (match_operand:DI 0 "s_operand" "")
7259 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
ae156f85 7260 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7261 "reload_completed"
7262 [(parallel
7263 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 7264 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7265 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
4023fb28 7266
9db1d521
HP
7267;
7268; xorsi3 instruction pattern(s).
7269;
7270
4023fb28 7271(define_insn "*xorsi3_cc"
ae156f85 7272 [(set (reg CC_REGNUM)
65b1d8ea
AK
7273 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7274 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7275 (const_int 0)))
65b1d8ea 7276 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
4023fb28
UW
7277 (xor:SI (match_dup 1) (match_dup 2)))]
7278 "s390_match_ccmode(insn, CCTmode)"
7279 "@
ec24698e 7280 xilf\t%0,%o2
d40c829f 7281 xr\t%0,%2
65b1d8ea 7282 xrk\t%0,%1,%2
d40c829f
UW
7283 x\t%0,%2
7284 xy\t%0,%2"
65b1d8ea
AK
7285 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
7286 (set_attr "cpu_facility" "*,*,z196,*,*")
7287 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7288 z10_super_E1,z10_super_E1")])
4023fb28
UW
7289
7290(define_insn "*xorsi3_cconly"
ae156f85 7291 [(set (reg CC_REGNUM)
65b1d8ea
AK
7292 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7293 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
4023fb28 7294 (const_int 0)))
65b1d8ea 7295 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
4023fb28
UW
7296 "s390_match_ccmode(insn, CCTmode)"
7297 "@
ec24698e 7298 xilf\t%0,%o2
d40c829f 7299 xr\t%0,%2
65b1d8ea 7300 xrk\t%0,%1,%2
d40c829f
UW
7301 x\t%0,%2
7302 xy\t%0,%2"
65b1d8ea
AK
7303 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
7304 (set_attr "cpu_facility" "*,*,z196,*,*")
7305 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7306 z10_super_E1,z10_super_E1")])
9db1d521 7307
8cb66696 7308(define_insn "*xorsi3"
65b1d8ea
AK
7309 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d, AQ,Q")
7310 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, 0,0")
7311 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxQS0,Q")))
ae156f85 7312 (clobber (reg:CC CC_REGNUM))]
8cb66696 7313 "s390_logical_operator_ok_p (operands)"
9db1d521 7314 "@
ec24698e 7315 xilf\t%0,%o2
d40c829f 7316 xr\t%0,%2
65b1d8ea 7317 xrk\t%0,%1,%2
d40c829f 7318 x\t%0,%2
8cb66696 7319 xy\t%0,%2
0dfa6c5e 7320 #
19b63d8e 7321 #"
65b1d8ea
AK
7322 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,SI,SS")
7323 (set_attr "cpu_facility" "*,*,z196,*,*,*,*")
7324 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7325 z10_super_E1,z10_super_E1,*,*")])
0dfa6c5e
UW
7326
7327(define_split
7328 [(set (match_operand:SI 0 "s_operand" "")
7329 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
ae156f85 7330 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7331 "reload_completed"
7332 [(parallel
7333 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 7334 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7335 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
8cb66696 7336
9db1d521
HP
7337;
7338; xorhi3 instruction pattern(s).
7339;
7340
8cb66696 7341(define_insn "*xorhi3"
65b1d8ea
AK
7342 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7343 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,d, 0,0")
7344 (match_operand:HI 2 "general_operand" "Os,d,d,NxQH0,Q")))
ae156f85 7345 (clobber (reg:CC CC_REGNUM))]
8cb66696
UW
7346 "s390_logical_operator_ok_p (operands)"
7347 "@
ec24698e 7348 xilf\t%0,%x2
8cb66696 7349 xr\t%0,%2
65b1d8ea 7350 xrk\t%0,%1,%2
0dfa6c5e 7351 #
19b63d8e 7352 #"
65b1d8ea
AK
7353 [(set_attr "op_type" "RIL,RR,RRF,SI,SS")
7354 (set_attr "cpu_facility" "*,*,z196,*,*")
7355 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*,*")])
0dfa6c5e
UW
7356
7357(define_split
7358 [(set (match_operand:HI 0 "s_operand" "")
7359 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
ae156f85 7360 (clobber (reg:CC CC_REGNUM))]
0dfa6c5e
UW
7361 "reload_completed"
7362 [(parallel
7363 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
ae156f85 7364 (clobber (reg:CC CC_REGNUM))])]
0dfa6c5e 7365 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
9db1d521 7366
9db1d521
HP
7367;
7368; xorqi3 instruction pattern(s).
7369;
7370
8cb66696 7371(define_insn "*xorqi3"
65b1d8ea
AK
7372 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7373 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,d,0,0,0")
7374 (match_operand:QI 2 "general_operand" "Os,d,d,n,n,Q")))
ae156f85 7375 (clobber (reg:CC CC_REGNUM))]
8cb66696 7376 "s390_logical_operator_ok_p (operands)"
9db1d521 7377 "@
ec24698e 7378 xilf\t%0,%b2
8cb66696 7379 xr\t%0,%2
65b1d8ea 7380 xrk\t%0,%1,%2
fc0ea003
UW
7381 xi\t%S0,%b2
7382 xiy\t%S0,%b2
19b63d8e 7383 #"
65b1d8ea
AK
7384 [(set_attr "op_type" "RIL,RR,RRF,SI,SIY,SS")
7385 (set_attr "cpu_facility" "*,*,z196,*,*,*")
7386 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super,z10_super,*")])
9381e3f1 7387
4023fb28 7388
19b63d8e
UW
7389;
7390; Block exclusive or (XC) patterns.
7391;
7392
7393(define_insn "*xc"
7394 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7395 (xor:BLK (match_dup 0)
7396 (match_operand:BLK 1 "memory_operand" "Q")))
7397 (use (match_operand 2 "const_int_operand" "n"))
ae156f85 7398 (clobber (reg:CC CC_REGNUM))]
19b63d8e 7399 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
fc0ea003 7400 "xc\t%O0(%2,%R0),%S1"
b628bd8e 7401 [(set_attr "op_type" "SS")])
19b63d8e
UW
7402
7403(define_split
7404 [(set (match_operand 0 "memory_operand" "")
7405 (xor (match_dup 0)
7406 (match_operand 1 "memory_operand" "")))
ae156f85 7407 (clobber (reg:CC CC_REGNUM))]
19b63d8e
UW
7408 "reload_completed
7409 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7410 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7411 [(parallel
7412 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
7413 (use (match_dup 2))
ae156f85 7414 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7415{
7416 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7417 operands[0] = adjust_address (operands[0], BLKmode, 0);
7418 operands[1] = adjust_address (operands[1], BLKmode, 0);
7419})
7420
7421(define_peephole2
7422 [(parallel
7423 [(set (match_operand:BLK 0 "memory_operand" "")
7424 (xor:BLK (match_dup 0)
7425 (match_operand:BLK 1 "memory_operand" "")))
7426 (use (match_operand 2 "const_int_operand" ""))
ae156f85 7427 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
7428 (parallel
7429 [(set (match_operand:BLK 3 "memory_operand" "")
7430 (xor:BLK (match_dup 3)
7431 (match_operand:BLK 4 "memory_operand" "")))
7432 (use (match_operand 5 "const_int_operand" ""))
ae156f85 7433 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7434 "s390_offset_p (operands[0], operands[3], operands[2])
7435 && s390_offset_p (operands[1], operands[4], operands[2])
9381e3f1 7436 && !s390_overlap_p (operands[0], operands[1],
bcf8c1cc 7437 INTVAL (operands[2]) + INTVAL (operands[5]))
19b63d8e
UW
7438 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7439 [(parallel
7440 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
7441 (use (match_dup 8))
ae156f85 7442 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7443 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7444 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7445 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7446
7447;
7448; Block xor (XC) patterns with src == dest.
7449;
7450
7451(define_insn "*xc_zero"
7452 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7453 (const_int 0))
7454 (use (match_operand 1 "const_int_operand" "n"))
ae156f85 7455 (clobber (reg:CC CC_REGNUM))]
19b63d8e 7456 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
fc0ea003 7457 "xc\t%O0(%1,%R0),%S0"
65b1d8ea
AK
7458 [(set_attr "op_type" "SS")
7459 (set_attr "z196prop" "z196_cracked")])
19b63d8e
UW
7460
7461(define_peephole2
7462 [(parallel
7463 [(set (match_operand:BLK 0 "memory_operand" "")
7464 (const_int 0))
7465 (use (match_operand 1 "const_int_operand" ""))
ae156f85 7466 (clobber (reg:CC CC_REGNUM))])
19b63d8e
UW
7467 (parallel
7468 [(set (match_operand:BLK 2 "memory_operand" "")
7469 (const_int 0))
7470 (use (match_operand 3 "const_int_operand" ""))
ae156f85 7471 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7472 "s390_offset_p (operands[0], operands[2], operands[1])
7473 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
7474 [(parallel
7475 [(set (match_dup 4) (const_int 0))
7476 (use (match_dup 5))
ae156f85 7477 (clobber (reg:CC CC_REGNUM))])]
19b63d8e
UW
7478 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7479 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
7480
9db1d521
HP
7481
7482;;
7483;;- Negate instructions.
7484;;
7485
7486;
9a91a21f 7487; neg(di|si)2 instruction pattern(s).
9db1d521
HP
7488;
7489
9a91a21f 7490(define_expand "neg<mode>2"
9db1d521 7491 [(parallel
9a91a21f
AS
7492 [(set (match_operand:DSI 0 "register_operand" "=d")
7493 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
ae156f85 7494 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
7495 ""
7496 "")
7497
26a89301 7498(define_insn "*negdi2_sign_cc"
ae156f85 7499 [(set (reg CC_REGNUM)
26a89301
UW
7500 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
7501 (match_operand:SI 1 "register_operand" "d") 0)
7502 (const_int 32)) (const_int 32)))
7503 (const_int 0)))
7504 (set (match_operand:DI 0 "register_operand" "=d")
7505 (neg:DI (sign_extend:DI (match_dup 1))))]
9602b6a1 7506 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 7507 "lcgfr\t%0,%1"
729e750f
WG
7508 [(set_attr "op_type" "RRE")
7509 (set_attr "z10prop" "z10_c")])
9381e3f1 7510
26a89301
UW
7511(define_insn "*negdi2_sign"
7512 [(set (match_operand:DI 0 "register_operand" "=d")
7513 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
ae156f85 7514 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7515 "TARGET_ZARCH"
26a89301 7516 "lcgfr\t%0,%1"
729e750f
WG
7517 [(set_attr "op_type" "RRE")
7518 (set_attr "z10prop" "z10_c")])
26a89301 7519
43a09b63 7520; lcr, lcgr
9a91a21f 7521(define_insn "*neg<mode>2_cc"
ae156f85 7522 [(set (reg CC_REGNUM)
9a91a21f 7523 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 7524 (const_int 0)))
9a91a21f
AS
7525 (set (match_operand:GPR 0 "register_operand" "=d")
7526 (neg:GPR (match_dup 1)))]
7527 "s390_match_ccmode (insn, CCAmode)"
7528 "lc<g>r\t%0,%1"
9381e3f1
WG
7529 [(set_attr "op_type" "RR<E>")
7530 (set_attr "z10prop" "z10_super_c_E1")])
43a09b63
AK
7531
7532; lcr, lcgr
9a91a21f 7533(define_insn "*neg<mode>2_cconly"
ae156f85 7534 [(set (reg CC_REGNUM)
9a91a21f 7535 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 7536 (const_int 0)))
9a91a21f
AS
7537 (clobber (match_scratch:GPR 0 "=d"))]
7538 "s390_match_ccmode (insn, CCAmode)"
7539 "lc<g>r\t%0,%1"
9381e3f1
WG
7540 [(set_attr "op_type" "RR<E>")
7541 (set_attr "z10prop" "z10_super_c_E1")])
43a09b63
AK
7542
7543; lcr, lcgr
9a91a21f
AS
7544(define_insn "*neg<mode>2"
7545 [(set (match_operand:GPR 0 "register_operand" "=d")
7546 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
ae156f85 7547 (clobber (reg:CC CC_REGNUM))]
9a91a21f
AS
7548 ""
7549 "lc<g>r\t%0,%1"
9381e3f1
WG
7550 [(set_attr "op_type" "RR<E>")
7551 (set_attr "z10prop" "z10_super_c_E1")])
9db1d521 7552
b7d19263 7553(define_insn "*negdi2_31"
9db1d521
HP
7554 [(set (match_operand:DI 0 "register_operand" "=d")
7555 (neg:DI (match_operand:DI 1 "register_operand" "d")))
ae156f85 7556 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7557 "!TARGET_ZARCH"
b7d19263
AK
7558 "#")
7559
7560; Split a DImode NEG on 31bit into 2 SImode NEGs
7561
7562; Doing the twos complement separately on the SImode parts does an
7563; unwanted +1 on the high part which needs to be subtracted afterwards
7564; ... unless the +1 on the low part created an overflow.
7565
7566(define_split
7567 [(set (match_operand:DI 0 "register_operand" "")
7568 (neg:DI (match_operand:DI 1 "register_operand" "")))
7569 (clobber (reg:CC CC_REGNUM))]
7570 "!TARGET_ZARCH
7571 && (REGNO (operands[0]) == REGNO (operands[1])
7572 || s390_split_ok_p (operands[0], operands[1], DImode, 0))
7573 && reload_completed"
26a89301
UW
7574 [(parallel
7575 [(set (match_dup 2) (neg:SI (match_dup 3)))
ae156f85 7576 (clobber (reg:CC CC_REGNUM))])
26a89301 7577 (parallel
ae156f85 7578 [(set (reg:CCAP CC_REGNUM)
26a89301
UW
7579 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
7580 (set (match_dup 4) (neg:SI (match_dup 5)))])
7581 (set (pc)
ae156f85 7582 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
26a89301
UW
7583 (pc)
7584 (label_ref (match_dup 6))))
7585 (parallel
7586 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
ae156f85 7587 (clobber (reg:CC CC_REGNUM))])
26a89301
UW
7588 (match_dup 6)]
7589 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
7590 operands[3] = operand_subword (operands[1], 0, 0, DImode);
7591 operands[4] = operand_subword (operands[0], 1, 0, DImode);
7592 operands[5] = operand_subword (operands[1], 1, 0, DImode);
7593 operands[6] = gen_label_rtx ();")
9db1d521 7594
b7d19263
AK
7595; Like above but first make a copy of the low part of the src operand
7596; since it might overlap with the high part of the destination.
7597
7598(define_split
7599 [(set (match_operand:DI 0 "register_operand" "")
7600 (neg:DI (match_operand:DI 1 "register_operand" "")))
7601 (clobber (reg:CC CC_REGNUM))]
7602 "!TARGET_ZARCH
7603 && s390_split_ok_p (operands[0], operands[1], DImode, 1)
7604 && reload_completed"
7605 [; Make a backup of op5 first
7606 (set (match_dup 4) (match_dup 5))
7607 ; Setting op2 here might clobber op5
7608 (parallel
7609 [(set (match_dup 2) (neg:SI (match_dup 3)))
7610 (clobber (reg:CC CC_REGNUM))])
7611 (parallel
7612 [(set (reg:CCAP CC_REGNUM)
7613 (compare:CCAP (neg:SI (match_dup 4)) (const_int 0)))
7614 (set (match_dup 4) (neg:SI (match_dup 4)))])
7615 (set (pc)
7616 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
7617 (pc)
7618 (label_ref (match_dup 6))))
7619 (parallel
7620 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
7621 (clobber (reg:CC CC_REGNUM))])
7622 (match_dup 6)]
7623 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
7624 operands[3] = operand_subword (operands[1], 0, 0, DImode);
7625 operands[4] = operand_subword (operands[0], 1, 0, DImode);
7626 operands[5] = operand_subword (operands[1], 1, 0, DImode);
7627 operands[6] = gen_label_rtx ();")
7628
9db1d521 7629;
f5905b37 7630; neg(df|sf)2 instruction pattern(s).
9db1d521
HP
7631;
7632
f5905b37 7633(define_expand "neg<mode>2"
9db1d521 7634 [(parallel
7b6baae1
AK
7635 [(set (match_operand:BFP 0 "register_operand" "=f")
7636 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
ae156f85 7637 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
7638 "TARGET_HARD_FLOAT"
7639 "")
7640
43a09b63 7641; lcxbr, lcdbr, lcebr
f5905b37 7642(define_insn "*neg<mode>2_cc"
ae156f85 7643 [(set (reg CC_REGNUM)
7b6baae1
AK
7644 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
7645 (match_operand:BFP 2 "const0_operand" "")))
7646 (set (match_operand:BFP 0 "register_operand" "=f")
7647 (neg:BFP (match_dup 1)))]
142cd70f 7648 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 7649 "lc<xde>br\t%0,%1"
26a89301 7650 [(set_attr "op_type" "RRE")
f5905b37 7651 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
7652
7653; lcxbr, lcdbr, lcebr
f5905b37 7654(define_insn "*neg<mode>2_cconly"
ae156f85 7655 [(set (reg CC_REGNUM)
7b6baae1
AK
7656 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
7657 (match_operand:BFP 2 "const0_operand" "")))
7658 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 7659 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 7660 "lc<xde>br\t%0,%1"
26a89301 7661 [(set_attr "op_type" "RRE")
f5905b37 7662 (set_attr "type" "fsimp<mode>")])
43a09b63 7663
85dae55a
AK
7664; lcdfr
7665(define_insn "*neg<mode>2_nocc"
609e7e80
AK
7666 [(set (match_operand:FP 0 "register_operand" "=f")
7667 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
fb068247 7668 "TARGET_DFP"
85dae55a
AK
7669 "lcdfr\t%0,%1"
7670 [(set_attr "op_type" "RRE")
9381e3f1 7671 (set_attr "type" "fsimp<mode>")])
85dae55a 7672
43a09b63 7673; lcxbr, lcdbr, lcebr
f5905b37 7674(define_insn "*neg<mode>2"
7b6baae1
AK
7675 [(set (match_operand:BFP 0 "register_operand" "=f")
7676 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
ae156f85 7677 (clobber (reg:CC CC_REGNUM))]
142cd70f 7678 "TARGET_HARD_FLOAT"
f61a2c7d 7679 "lc<xde>br\t%0,%1"
077dab3b 7680 [(set_attr "op_type" "RRE")
f5905b37 7681 (set_attr "type" "fsimp<mode>")])
9db1d521 7682
9db1d521
HP
7683
7684;;
7685;;- Absolute value instructions.
7686;;
7687
7688;
9a91a21f 7689; abs(di|si)2 instruction pattern(s).
9db1d521
HP
7690;
7691
26a89301 7692(define_insn "*absdi2_sign_cc"
ae156f85 7693 [(set (reg CC_REGNUM)
26a89301
UW
7694 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
7695 (match_operand:SI 1 "register_operand" "d") 0)
7696 (const_int 32)) (const_int 32)))
7697 (const_int 0)))
7698 (set (match_operand:DI 0 "register_operand" "=d")
7699 (abs:DI (sign_extend:DI (match_dup 1))))]
9602b6a1 7700 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 7701 "lpgfr\t%0,%1"
729e750f
WG
7702 [(set_attr "op_type" "RRE")
7703 (set_attr "z10prop" "z10_c")])
26a89301
UW
7704
7705(define_insn "*absdi2_sign"
7706 [(set (match_operand:DI 0 "register_operand" "=d")
7707 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
ae156f85 7708 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7709 "TARGET_ZARCH"
26a89301 7710 "lpgfr\t%0,%1"
729e750f
WG
7711 [(set_attr "op_type" "RRE")
7712 (set_attr "z10prop" "z10_c")])
26a89301 7713
43a09b63 7714; lpr, lpgr
9a91a21f 7715(define_insn "*abs<mode>2_cc"
ae156f85 7716 [(set (reg CC_REGNUM)
9a91a21f 7717 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
26a89301 7718 (const_int 0)))
9a91a21f
AS
7719 (set (match_operand:GPR 0 "register_operand" "=d")
7720 (abs:GPR (match_dup 1)))]
26a89301 7721 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 7722 "lp<g>r\t%0,%1"
9381e3f1
WG
7723 [(set_attr "op_type" "RR<E>")
7724 (set_attr "z10prop" "z10_c")])
43a09b63 7725
9381e3f1 7726; lpr, lpgr
9a91a21f 7727(define_insn "*abs<mode>2_cconly"
ae156f85 7728 [(set (reg CC_REGNUM)
9a91a21f 7729 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
26a89301 7730 (const_int 0)))
9a91a21f 7731 (clobber (match_scratch:GPR 0 "=d"))]
26a89301 7732 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 7733 "lp<g>r\t%0,%1"
9381e3f1
WG
7734 [(set_attr "op_type" "RR<E>")
7735 (set_attr "z10prop" "z10_c")])
43a09b63
AK
7736
7737; lpr, lpgr
9a91a21f
AS
7738(define_insn "abs<mode>2"
7739 [(set (match_operand:GPR 0 "register_operand" "=d")
7740 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
ae156f85 7741 (clobber (reg:CC CC_REGNUM))]
9db1d521 7742 ""
9a91a21f 7743 "lp<g>r\t%0,%1"
9381e3f1
WG
7744 [(set_attr "op_type" "RR<E>")
7745 (set_attr "z10prop" "z10_c")])
9db1d521 7746
9db1d521 7747;
f5905b37 7748; abs(df|sf)2 instruction pattern(s).
9db1d521
HP
7749;
7750
f5905b37 7751(define_expand "abs<mode>2"
9db1d521 7752 [(parallel
7b6baae1
AK
7753 [(set (match_operand:BFP 0 "register_operand" "=f")
7754 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
ae156f85 7755 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
7756 "TARGET_HARD_FLOAT"
7757 "")
7758
43a09b63 7759; lpxbr, lpdbr, lpebr
f5905b37 7760(define_insn "*abs<mode>2_cc"
ae156f85 7761 [(set (reg CC_REGNUM)
7b6baae1
AK
7762 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
7763 (match_operand:BFP 2 "const0_operand" "")))
7764 (set (match_operand:BFP 0 "register_operand" "=f")
7765 (abs:BFP (match_dup 1)))]
142cd70f 7766 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 7767 "lp<xde>br\t%0,%1"
26a89301 7768 [(set_attr "op_type" "RRE")
f5905b37 7769 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
7770
7771; lpxbr, lpdbr, lpebr
f5905b37 7772(define_insn "*abs<mode>2_cconly"
ae156f85 7773 [(set (reg CC_REGNUM)
7b6baae1
AK
7774 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
7775 (match_operand:BFP 2 "const0_operand" "")))
7776 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 7777 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 7778 "lp<xde>br\t%0,%1"
26a89301 7779 [(set_attr "op_type" "RRE")
f5905b37 7780 (set_attr "type" "fsimp<mode>")])
43a09b63 7781
85dae55a
AK
7782; lpdfr
7783(define_insn "*abs<mode>2_nocc"
609e7e80
AK
7784 [(set (match_operand:FP 0 "register_operand" "=f")
7785 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
fb068247 7786 "TARGET_DFP"
85dae55a
AK
7787 "lpdfr\t%0,%1"
7788 [(set_attr "op_type" "RRE")
9381e3f1 7789 (set_attr "type" "fsimp<mode>")])
85dae55a 7790
43a09b63 7791; lpxbr, lpdbr, lpebr
f5905b37 7792(define_insn "*abs<mode>2"
7b6baae1
AK
7793 [(set (match_operand:BFP 0 "register_operand" "=f")
7794 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
ae156f85 7795 (clobber (reg:CC CC_REGNUM))]
142cd70f 7796 "TARGET_HARD_FLOAT"
f61a2c7d 7797 "lp<xde>br\t%0,%1"
077dab3b 7798 [(set_attr "op_type" "RRE")
f5905b37 7799 (set_attr "type" "fsimp<mode>")])
9db1d521 7800
9db1d521 7801
3ef093a8
AK
7802;;
7803;;- Negated absolute value instructions
7804;;
7805
7806;
7807; Integer
7808;
7809
26a89301 7810(define_insn "*negabsdi2_sign_cc"
ae156f85 7811 [(set (reg CC_REGNUM)
26a89301
UW
7812 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
7813 (match_operand:SI 1 "register_operand" "d") 0)
7814 (const_int 32)) (const_int 32))))
7815 (const_int 0)))
7816 (set (match_operand:DI 0 "register_operand" "=d")
7817 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
9602b6a1 7818 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
26a89301 7819 "lngfr\t%0,%1"
729e750f
WG
7820 [(set_attr "op_type" "RRE")
7821 (set_attr "z10prop" "z10_c")])
9381e3f1 7822
26a89301
UW
7823(define_insn "*negabsdi2_sign"
7824 [(set (match_operand:DI 0 "register_operand" "=d")
7825 (neg:DI (abs:DI (sign_extend:DI
7826 (match_operand:SI 1 "register_operand" "d")))))
ae156f85 7827 (clobber (reg:CC CC_REGNUM))]
9602b6a1 7828 "TARGET_ZARCH"
26a89301 7829 "lngfr\t%0,%1"
729e750f
WG
7830 [(set_attr "op_type" "RRE")
7831 (set_attr "z10prop" "z10_c")])
3ef093a8 7832
43a09b63 7833; lnr, lngr
9a91a21f 7834(define_insn "*negabs<mode>2_cc"
ae156f85 7835 [(set (reg CC_REGNUM)
9a91a21f 7836 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
26a89301 7837 (const_int 0)))
9a91a21f
AS
7838 (set (match_operand:GPR 0 "register_operand" "=d")
7839 (neg:GPR (abs:GPR (match_dup 1))))]
26a89301 7840 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 7841 "ln<g>r\t%0,%1"
9381e3f1
WG
7842 [(set_attr "op_type" "RR<E>")
7843 (set_attr "z10prop" "z10_c")])
43a09b63
AK
7844
7845; lnr, lngr
9a91a21f 7846(define_insn "*negabs<mode>2_cconly"
ae156f85 7847 [(set (reg CC_REGNUM)
9a91a21f 7848 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
26a89301 7849 (const_int 0)))
9a91a21f 7850 (clobber (match_scratch:GPR 0 "=d"))]
26a89301 7851 "s390_match_ccmode (insn, CCAmode)"
9a91a21f 7852 "ln<g>r\t%0,%1"
9381e3f1
WG
7853 [(set_attr "op_type" "RR<E>")
7854 (set_attr "z10prop" "z10_c")])
43a09b63
AK
7855
7856; lnr, lngr
9a91a21f
AS
7857(define_insn "*negabs<mode>2"
7858 [(set (match_operand:GPR 0 "register_operand" "=d")
7859 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
ae156f85 7860 (clobber (reg:CC CC_REGNUM))]
26a89301 7861 ""
9a91a21f 7862 "ln<g>r\t%0,%1"
9381e3f1
WG
7863 [(set_attr "op_type" "RR<E>")
7864 (set_attr "z10prop" "z10_c")])
26a89301 7865
3ef093a8
AK
7866;
7867; Floating point
7868;
7869
43a09b63 7870; lnxbr, lndbr, lnebr
f5905b37 7871(define_insn "*negabs<mode>2_cc"
ae156f85 7872 [(set (reg CC_REGNUM)
7b6baae1
AK
7873 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7874 (match_operand:BFP 2 "const0_operand" "")))
7875 (set (match_operand:BFP 0 "register_operand" "=f")
7876 (neg:BFP (abs:BFP (match_dup 1))))]
142cd70f 7877 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 7878 "ln<xde>br\t%0,%1"
26a89301 7879 [(set_attr "op_type" "RRE")
f5905b37 7880 (set_attr "type" "fsimp<mode>")])
43a09b63
AK
7881
7882; lnxbr, lndbr, lnebr
f5905b37 7883(define_insn "*negabs<mode>2_cconly"
ae156f85 7884 [(set (reg CC_REGNUM)
7b6baae1
AK
7885 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7886 (match_operand:BFP 2 "const0_operand" "")))
7887 (clobber (match_scratch:BFP 0 "=f"))]
142cd70f 7888 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
f61a2c7d 7889 "ln<xde>br\t%0,%1"
26a89301 7890 [(set_attr "op_type" "RRE")
f5905b37 7891 (set_attr "type" "fsimp<mode>")])
43a09b63 7892
85dae55a
AK
7893; lndfr
7894(define_insn "*negabs<mode>2_nocc"
609e7e80
AK
7895 [(set (match_operand:FP 0 "register_operand" "=f")
7896 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
fb068247 7897 "TARGET_DFP"
85dae55a
AK
7898 "lndfr\t%0,%1"
7899 [(set_attr "op_type" "RRE")
9381e3f1 7900 (set_attr "type" "fsimp<mode>")])
85dae55a 7901
43a09b63 7902; lnxbr, lndbr, lnebr
f5905b37 7903(define_insn "*negabs<mode>2"
7b6baae1
AK
7904 [(set (match_operand:BFP 0 "register_operand" "=f")
7905 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f"))))
ae156f85 7906 (clobber (reg:CC CC_REGNUM))]
142cd70f 7907 "TARGET_HARD_FLOAT"
f61a2c7d 7908 "ln<xde>br\t%0,%1"
26a89301 7909 [(set_attr "op_type" "RRE")
f5905b37 7910 (set_attr "type" "fsimp<mode>")])
26a89301 7911
4023fb28
UW
7912;;
7913;;- Square root instructions.
7914;;
7915
7916;
f5905b37 7917; sqrt(df|sf)2 instruction pattern(s).
4023fb28
UW
7918;
7919
9381e3f1 7920; sqxbr, sqdbr, sqebr, sqdb, sqeb
f5905b37 7921(define_insn "sqrt<mode>2"
7b6baae1
AK
7922 [(set (match_operand:BFP 0 "register_operand" "=f,f")
7923 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,<Rf>")))]
142cd70f 7924 "TARGET_HARD_FLOAT"
4023fb28 7925 "@
f61a2c7d
AK
7926 sq<xde>br\t%0,%1
7927 sq<xde>b\t%0,%1"
a036c6f7 7928 [(set_attr "op_type" "RRE,RXE")
f5905b37 7929 (set_attr "type" "fsqrt<mode>")])
4023fb28 7930
9db1d521
HP
7931
7932;;
7933;;- One complement instructions.
7934;;
7935
7936;
342cf42b 7937; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
9db1d521 7938;
c7453384 7939
342cf42b 7940(define_expand "one_cmpl<mode>2"
4023fb28 7941 [(parallel
342cf42b
AS
7942 [(set (match_operand:INT 0 "register_operand" "")
7943 (xor:INT (match_operand:INT 1 "register_operand" "")
7944 (const_int -1)))
ae156f85 7945 (clobber (reg:CC CC_REGNUM))])]
9db1d521 7946 ""
4023fb28 7947 "")
9db1d521
HP
7948
7949
ec24698e
UW
7950;;
7951;; Find leftmost bit instructions.
7952;;
7953
7954(define_expand "clzdi2"
7955 [(set (match_operand:DI 0 "register_operand" "=d")
7956 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
9602b6a1 7957 "TARGET_EXTIMM && TARGET_ZARCH"
ec24698e
UW
7958{
7959 rtx insn, clz_equal;
7960 rtx wide_reg = gen_reg_rtx (TImode);
7961 rtx msb = gen_rtx_CONST_INT (DImode, (unsigned HOST_WIDE_INT) 1 << 63);
7962
7963 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
7964
7965 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
7966
9381e3f1 7967 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
bd94cb6e 7968 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
ec24698e
UW
7969
7970 DONE;
7971})
7972
7973(define_insn "clztidi2"
7974 [(set (match_operand:TI 0 "register_operand" "=d")
7975 (ior:TI
9381e3f1
WG
7976 (ashift:TI
7977 (zero_extend:TI
ec24698e
UW
7978 (xor:DI (match_operand:DI 1 "register_operand" "d")
7979 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
7980 (subreg:SI (clz:DI (match_dup 1)) 4))))
9381e3f1 7981
ec24698e
UW
7982 (const_int 64))
7983 (zero_extend:TI (clz:DI (match_dup 1)))))
7984 (clobber (reg:CC CC_REGNUM))]
9381e3f1 7985 "(unsigned HOST_WIDE_INT) INTVAL (operands[2])
ec24698e 7986 == (unsigned HOST_WIDE_INT) 1 << 63
9602b6a1 7987 && TARGET_EXTIMM && TARGET_ZARCH"
ec24698e
UW
7988 "flogr\t%0,%1"
7989 [(set_attr "op_type" "RRE")])
7990
7991
9db1d521
HP
7992;;
7993;;- Rotate instructions.
7994;;
7995
7996;
9a91a21f 7997; rotl(di|si)3 instruction pattern(s).
9db1d521
HP
7998;
7999
43a09b63 8000; rll, rllg
9a91a21f
AS
8001(define_insn "rotl<mode>3"
8002 [(set (match_operand:GPR 0 "register_operand" "=d")
8003 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
4989e88a 8004 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
9e8327e3 8005 "TARGET_CPU_ZARCH"
9a91a21f 8006 "rll<g>\t%0,%1,%Y2"
077dab3b 8007 [(set_attr "op_type" "RSE")
9381e3f1
WG
8008 (set_attr "atype" "reg")
8009 (set_attr "z10prop" "z10_super_E1")])
9db1d521 8010
43a09b63 8011; rll, rllg
4989e88a
AK
8012(define_insn "*rotl<mode>3_and"
8013 [(set (match_operand:GPR 0 "register_operand" "=d")
8014 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
8015 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
8016 (match_operand:SI 3 "const_int_operand" "n"))))]
8017 "TARGET_CPU_ZARCH && (INTVAL (operands[3]) & 63) == 63"
8018 "rll<g>\t%0,%1,%Y2"
8019 [(set_attr "op_type" "RSE")
9381e3f1
WG
8020 (set_attr "atype" "reg")
8021 (set_attr "z10prop" "z10_super_E1")])
4989e88a 8022
9db1d521
HP
8023
8024;;
f337b930 8025;;- Shift instructions.
9db1d521 8026;;
9db1d521
HP
8027
8028;
1b48c8cc 8029; (ashl|lshr)(di|si)3 instruction pattern(s).
65b1d8ea 8030; Left shifts and logical right shifts
9db1d521 8031
1b48c8cc
AS
8032(define_expand "<shift><mode>3"
8033 [(set (match_operand:DSI 0 "register_operand" "")
8034 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
8035 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))]
9db1d521
HP
8036 ""
8037 "")
8038
43a09b63 8039; sldl, srdl
f337b930 8040(define_insn "*<shift>di3_31"
ac32b25e 8041 [(set (match_operand:DI 0 "register_operand" "=d")
f337b930 8042 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
4989e88a 8043 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
9602b6a1 8044 "!TARGET_ZARCH"
f337b930 8045 "s<lr>dl\t%0,%Y2"
077dab3b 8046 [(set_attr "op_type" "RS")
65b1d8ea
AK
8047 (set_attr "atype" "reg")
8048 (set_attr "z196prop" "z196_cracked")])
9db1d521 8049
65b1d8ea 8050; sll, srl, sllg, srlg, sllk, srlk
1b48c8cc 8051(define_insn "*<shift><mode>3"
65b1d8ea
AK
8052 [(set (match_operand:GPR 0 "register_operand" "=d,d")
8053 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
8054 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")))]
1b48c8cc 8055 ""
65b1d8ea
AK
8056 "@
8057 s<lr>l<g>\t%0,<1>%Y2
8058 s<lr>l<gk>\t%0,%1,%Y2"
8059 [(set_attr "op_type" "RS<E>,RSY")
8060 (set_attr "atype" "reg,reg")
8061 (set_attr "cpu_facility" "*,z196")
8062 (set_attr "z10prop" "z10_super_E1,*")])
9db1d521 8063
43a09b63 8064; sldl, srdl
4989e88a
AK
8065(define_insn "*<shift>di3_31_and"
8066 [(set (match_operand:DI 0 "register_operand" "=d")
8067 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
8068 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
8069 (match_operand:SI 3 "const_int_operand" "n"))))]
9602b6a1 8070 "!TARGET_ZARCH && (INTVAL (operands[3]) & 63) == 63"
4989e88a
AK
8071 "s<lr>dl\t%0,%Y2"
8072 [(set_attr "op_type" "RS")
8073 (set_attr "atype" "reg")])
8074
65b1d8ea 8075; sll, srl, sllg, srlg, sllk, srlk
1b48c8cc 8076(define_insn "*<shift><mode>3_and"
65b1d8ea
AK
8077 [(set (match_operand:GPR 0 "register_operand" "=d,d")
8078 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
8079 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
8080 (match_operand:SI 3 "const_int_operand" "n,n"))))]
1b48c8cc 8081 "(INTVAL (operands[3]) & 63) == 63"
65b1d8ea
AK
8082 "@
8083 s<lr>l<g>\t%0,<1>%Y2
8084 s<lr>l<gk>\t%0,%1,%Y2"
8085 [(set_attr "op_type" "RS<E>,RSY")
8086 (set_attr "atype" "reg,reg")
8087 (set_attr "cpu_facility" "*,z196")
8088 (set_attr "z10prop" "z10_super_E1,*")])
4989e88a 8089
9db1d521 8090;
1b48c8cc 8091; ashr(di|si)3 instruction pattern(s).
65b1d8ea 8092; Arithmetic right shifts
9db1d521 8093
1b48c8cc 8094(define_expand "ashr<mode>3"
9db1d521 8095 [(parallel
1b48c8cc
AS
8096 [(set (match_operand:DSI 0 "register_operand" "")
8097 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
8098 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))
ae156f85 8099 (clobber (reg:CC CC_REGNUM))])]
9db1d521
HP
8100 ""
8101 "")
8102
ecbe845e 8103(define_insn "*ashrdi3_cc_31"
ae156f85 8104 [(set (reg CC_REGNUM)
ac32b25e 8105 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4989e88a 8106 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
ecbe845e 8107 (const_int 0)))
ac32b25e 8108 (set (match_operand:DI 0 "register_operand" "=d")
ecbe845e 8109 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
9602b6a1 8110 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)"
ac32b25e 8111 "srda\t%0,%Y2"
077dab3b
HP
8112 [(set_attr "op_type" "RS")
8113 (set_attr "atype" "reg")])
ecbe845e
UW
8114
8115(define_insn "*ashrdi3_cconly_31"
ae156f85 8116 [(set (reg CC_REGNUM)
ac32b25e 8117 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4989e88a 8118 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
ecbe845e 8119 (const_int 0)))
ac32b25e 8120 (clobber (match_scratch:DI 0 "=d"))]
9602b6a1 8121 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)"
ac32b25e 8122 "srda\t%0,%Y2"
077dab3b
HP
8123 [(set_attr "op_type" "RS")
8124 (set_attr "atype" "reg")])
ecbe845e 8125
9db1d521 8126(define_insn "*ashrdi3_31"
ac32b25e
UW
8127 [(set (match_operand:DI 0 "register_operand" "=d")
8128 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4989e88a 8129 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
ae156f85 8130 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8131 "!TARGET_ZARCH"
ac32b25e 8132 "srda\t%0,%Y2"
077dab3b
HP
8133 [(set_attr "op_type" "RS")
8134 (set_attr "atype" "reg")])
c7453384 8135
65b1d8ea 8136; sra, srag, srak
1b48c8cc 8137(define_insn "*ashr<mode>3_cc"
ae156f85 8138 [(set (reg CC_REGNUM)
65b1d8ea
AK
8139 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
8140 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y"))
ecbe845e 8141 (const_int 0)))
65b1d8ea 8142 (set (match_operand:GPR 0 "register_operand" "=d,d")
1b48c8cc
AS
8143 (ashiftrt:GPR (match_dup 1) (match_dup 2)))]
8144 "s390_match_ccmode(insn, CCSmode)"
65b1d8ea
AK
8145 "@
8146 sra<g>\t%0,<1>%Y2
8147 sra<gk>\t%0,%1,%Y2"
8148 [(set_attr "op_type" "RS<E>,RSY")
8149 (set_attr "atype" "reg,reg")
8150 (set_attr "cpu_facility" "*,z196")
8151 (set_attr "z10prop" "z10_super_E1,*")])
ecbe845e 8152
65b1d8ea 8153; sra, srag, srak
1b48c8cc 8154(define_insn "*ashr<mode>3_cconly"
ae156f85 8155 [(set (reg CC_REGNUM)
65b1d8ea
AK
8156 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
8157 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y"))
ecbe845e 8158 (const_int 0)))
65b1d8ea 8159 (clobber (match_scratch:GPR 0 "=d,d"))]
1b48c8cc 8160 "s390_match_ccmode(insn, CCSmode)"
65b1d8ea
AK
8161 "@
8162 sra<g>\t%0,<1>%Y2
8163 sra<gk>\t%0,%1,%Y2"
8164 [(set_attr "op_type" "RS<E>,RSY")
8165 (set_attr "atype" "reg,reg")
8166 (set_attr "cpu_facility" "*,z196")
8167 (set_attr "z10prop" "z10_super_E1,*")])
ecbe845e 8168
43a09b63 8169; sra, srag
1b48c8cc 8170(define_insn "*ashr<mode>3"
65b1d8ea
AK
8171 [(set (match_operand:GPR 0 "register_operand" "=d,d")
8172 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
8173 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")))
ae156f85 8174 (clobber (reg:CC CC_REGNUM))]
1b48c8cc 8175 ""
65b1d8ea
AK
8176 "@
8177 sra<g>\t%0,<1>%Y2
8178 sra<gk>\t%0,%1,%Y2"
8179 [(set_attr "op_type" "RS<E>,RSY")
8180 (set_attr "atype" "reg,reg")
8181 (set_attr "cpu_facility" "*,z196")
8182 (set_attr "z10prop" "z10_super_E1,*")])
077dab3b 8183
9db1d521 8184
4989e88a
AK
8185; shift pattern with implicit ANDs
8186
8187(define_insn "*ashrdi3_cc_31_and"
8188 [(set (reg CC_REGNUM)
8189 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
8190 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
8191 (match_operand:SI 3 "const_int_operand" "n")))
8192 (const_int 0)))
8193 (set (match_operand:DI 0 "register_operand" "=d")
8194 (ashiftrt:DI (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
9602b6a1 8195 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)
4989e88a
AK
8196 && (INTVAL (operands[3]) & 63) == 63"
8197 "srda\t%0,%Y2"
8198 [(set_attr "op_type" "RS")
8199 (set_attr "atype" "reg")])
8200
8201(define_insn "*ashrdi3_cconly_31_and"
8202 [(set (reg CC_REGNUM)
8203 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
8204 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
8205 (match_operand:SI 3 "const_int_operand" "n")))
8206 (const_int 0)))
8207 (clobber (match_scratch:DI 0 "=d"))]
9602b6a1 8208 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)
4989e88a
AK
8209 && (INTVAL (operands[3]) & 63) == 63"
8210 "srda\t%0,%Y2"
8211 [(set_attr "op_type" "RS")
8212 (set_attr "atype" "reg")])
8213
8214(define_insn "*ashrdi3_31_and"
8215 [(set (match_operand:DI 0 "register_operand" "=d")
8216 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
8217 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
8218 (match_operand:SI 3 "const_int_operand" "n"))))
8219 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8220 "!TARGET_ZARCH && (INTVAL (operands[3]) & 63) == 63"
4989e88a
AK
8221 "srda\t%0,%Y2"
8222 [(set_attr "op_type" "RS")
8223 (set_attr "atype" "reg")])
8224
65b1d8ea 8225; sra, srag, srak
1b48c8cc 8226(define_insn "*ashr<mode>3_cc_and"
4989e88a 8227 [(set (reg CC_REGNUM)
65b1d8ea
AK
8228 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
8229 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
8230 (match_operand:SI 3 "const_int_operand" "n,n")))
4989e88a 8231 (const_int 0)))
65b1d8ea 8232 (set (match_operand:GPR 0 "register_operand" "=d,d")
1b48c8cc 8233 (ashiftrt:GPR (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
4989e88a 8234 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
65b1d8ea
AK
8235 "@
8236 sra<g>\t%0,<1>%Y2
8237 sra<gk>\t%0,%1,%Y2"
8238 [(set_attr "op_type" "RS<E>,RSY")
8239 (set_attr "atype" "reg,reg")
8240 (set_attr "cpu_facility" "*,z196")
8241 (set_attr "z10prop" "z10_super_E1,*")])
4989e88a 8242
65b1d8ea 8243; sra, srag, srak
1b48c8cc 8244(define_insn "*ashr<mode>3_cconly_and"
4989e88a 8245 [(set (reg CC_REGNUM)
65b1d8ea
AK
8246 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
8247 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
8248 (match_operand:SI 3 "const_int_operand" "n,n")))
4989e88a 8249 (const_int 0)))
65b1d8ea 8250 (clobber (match_scratch:GPR 0 "=d,d"))]
4989e88a 8251 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
65b1d8ea
AK
8252 "@
8253 sra<g>\t%0,<1>%Y2
8254 sra<gk>\t%0,%1,%Y2"
8255 [(set_attr "op_type" "RS<E>,RSY")
8256 (set_attr "atype" "reg,reg")
8257 (set_attr "cpu_facility" "*,z196")
8258 (set_attr "z10prop" "z10_super_E1,*")])
4989e88a 8259
65b1d8ea 8260; sra, srag, srak
1b48c8cc 8261(define_insn "*ashr<mode>3_and"
65b1d8ea
AK
8262 [(set (match_operand:GPR 0 "register_operand" "=d,d")
8263 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
8264 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
8265 (match_operand:SI 3 "const_int_operand" "n,n"))))
4989e88a
AK
8266 (clobber (reg:CC CC_REGNUM))]
8267 "(INTVAL (operands[3]) & 63) == 63"
65b1d8ea
AK
8268 "@
8269 sra<g>\t%0,<1>%Y2
8270 sra<gk>\t%0,%1,%Y2"
8271 [(set_attr "op_type" "RS<E>,RSY")
8272 (set_attr "atype" "reg,reg")
01496eca 8273 (set_attr "cpu_facility" "*,z196")
65b1d8ea 8274 (set_attr "z10prop" "z10_super_E1,*")])
4989e88a 8275
9db1d521 8276
9db1d521
HP
8277;;
8278;; Branch instruction patterns.
8279;;
8280
f90b7a5a 8281(define_expand "cbranch<mode>4"
fa77b251 8282 [(set (pc)
f90b7a5a
PB
8283 (if_then_else (match_operator 0 "comparison_operator"
8284 [(match_operand:GPR 1 "register_operand" "")
8285 (match_operand:GPR 2 "general_operand" "")])
8286 (label_ref (match_operand 3 "" ""))
fa77b251 8287 (pc)))]
ba956982 8288 ""
f90b7a5a
PB
8289 "s390_emit_jump (operands[3],
8290 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8291 DONE;")
8292
8293(define_expand "cbranch<mode>4"
8294 [(set (pc)
8295 (if_then_else (match_operator 0 "comparison_operator"
8296 [(match_operand:FP 1 "register_operand" "")
8297 (match_operand:FP 2 "general_operand" "")])
8298 (label_ref (match_operand 3 "" ""))
8299 (pc)))]
8300 "TARGET_HARD_FLOAT"
8301 "s390_emit_jump (operands[3],
8302 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8303 DONE;")
8304
8305(define_expand "cbranchcc4"
8306 [(set (pc)
de6fba39 8307 (if_then_else (match_operator 0 "s390_comparison"
f90b7a5a 8308 [(match_operand 1 "cc_reg_operand" "")
de6fba39 8309 (match_operand 2 "const_int_operand" "")])
f90b7a5a
PB
8310 (label_ref (match_operand 3 "" ""))
8311 (pc)))]
de6fba39
UW
8312 ""
8313 "")
ba956982 8314
9db1d521
HP
8315
8316;;
8317;;- Conditional jump instructions.
8318;;
8319
6590e19a
UW
8320(define_insn "*cjump_64"
8321 [(set (pc)
8322 (if_then_else
5a3fe9b6
AK
8323 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8324 (match_operand 2 "const_int_operand" "")])
6590e19a
UW
8325 (label_ref (match_operand 0 "" ""))
8326 (pc)))]
8327 "TARGET_CPU_ZARCH"
9db1d521 8328{
13e58269 8329 if (get_attr_length (insn) == 4)
d40c829f 8330 return "j%C1\t%l0";
6590e19a 8331 else
d40c829f 8332 return "jg%C1\t%l0";
6590e19a
UW
8333}
8334 [(set_attr "op_type" "RI")
8335 (set_attr "type" "branch")
8336 (set (attr "length")
8337 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8338 (const_int 4) (const_int 6)))])
8339
8340(define_insn "*cjump_31"
8341 [(set (pc)
8342 (if_then_else
5a3fe9b6
AK
8343 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8344 (match_operand 2 "const_int_operand" "")])
6590e19a
UW
8345 (label_ref (match_operand 0 "" ""))
8346 (pc)))]
8347 "!TARGET_CPU_ZARCH"
8348{
8d933e31
AS
8349 gcc_assert (get_attr_length (insn) == 4);
8350 return "j%C1\t%l0";
10bbf137 8351}
9db1d521 8352 [(set_attr "op_type" "RI")
077dab3b 8353 (set_attr "type" "branch")
13e58269 8354 (set (attr "length")
d7f99b2c 8355 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
8356 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8357 (const_int 4) (const_int 6))
8358 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8359 (const_int 4) (const_int 8))))])
9db1d521 8360
f314b9b1 8361(define_insn "*cjump_long"
6590e19a
UW
8362 [(set (pc)
8363 (if_then_else
ae156f85 8364 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
4fe6dea8 8365 (match_operand 0 "address_operand" "ZQZR")
6590e19a 8366 (pc)))]
9db1d521 8367 ""
f314b9b1
UW
8368{
8369 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8370 return "b%C1r\t%0";
f314b9b1 8371 else
d40c829f 8372 return "b%C1\t%a0";
10bbf137 8373}
c7453384 8374 [(set (attr "op_type")
f314b9b1
UW
8375 (if_then_else (match_operand 0 "register_operand" "")
8376 (const_string "RR") (const_string "RX")))
6590e19a 8377 (set_attr "type" "branch")
077dab3b 8378 (set_attr "atype" "agen")])
9db1d521 8379
177bc204
RS
8380;; A conditional return instruction.
8381(define_insn "*c<code>"
8382 [(set (pc)
8383 (if_then_else
8384 (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8385 (ANY_RETURN)
8386 (pc)))]
8387 "s390_can_use_<code>_insn ()"
8388 "b%C0r\t%%r14"
8389 [(set_attr "op_type" "RR")
8390 (set_attr "type" "jsr")
8391 (set_attr "atype" "agen")])
9db1d521
HP
8392
8393;;
8394;;- Negated conditional jump instructions.
8395;;
8396
6590e19a
UW
8397(define_insn "*icjump_64"
8398 [(set (pc)
8399 (if_then_else
ae156f85 8400 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a
UW
8401 (pc)
8402 (label_ref (match_operand 0 "" ""))))]
8403 "TARGET_CPU_ZARCH"
c7453384 8404{
13e58269 8405 if (get_attr_length (insn) == 4)
d40c829f 8406 return "j%D1\t%l0";
6590e19a 8407 else
d40c829f 8408 return "jg%D1\t%l0";
6590e19a
UW
8409}
8410 [(set_attr "op_type" "RI")
8411 (set_attr "type" "branch")
8412 (set (attr "length")
8413 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8414 (const_int 4) (const_int 6)))])
8415
8416(define_insn "*icjump_31"
8417 [(set (pc)
8418 (if_then_else
ae156f85 8419 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a
UW
8420 (pc)
8421 (label_ref (match_operand 0 "" ""))))]
8422 "!TARGET_CPU_ZARCH"
8423{
8d933e31
AS
8424 gcc_assert (get_attr_length (insn) == 4);
8425 return "j%D1\t%l0";
10bbf137 8426}
9db1d521 8427 [(set_attr "op_type" "RI")
077dab3b 8428 (set_attr "type" "branch")
13e58269 8429 (set (attr "length")
d7f99b2c 8430 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
8431 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8432 (const_int 4) (const_int 6))
8433 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8434 (const_int 4) (const_int 8))))])
9db1d521 8435
f314b9b1 8436(define_insn "*icjump_long"
6590e19a
UW
8437 [(set (pc)
8438 (if_then_else
ae156f85 8439 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
6590e19a 8440 (pc)
4fe6dea8 8441 (match_operand 0 "address_operand" "ZQZR")))]
9db1d521 8442 ""
f314b9b1
UW
8443{
8444 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8445 return "b%D1r\t%0";
f314b9b1 8446 else
d40c829f 8447 return "b%D1\t%a0";
10bbf137 8448}
c7453384 8449 [(set (attr "op_type")
f314b9b1
UW
8450 (if_then_else (match_operand 0 "register_operand" "")
8451 (const_string "RR") (const_string "RX")))
077dab3b
HP
8452 (set_attr "type" "branch")
8453 (set_attr "atype" "agen")])
9db1d521 8454
4456530d
HP
8455;;
8456;;- Trap instructions.
8457;;
8458
8459(define_insn "trap"
8460 [(trap_if (const_int 1) (const_int 0))]
8461 ""
d40c829f 8462 "j\t.+2"
6590e19a 8463 [(set_attr "op_type" "RI")
077dab3b 8464 (set_attr "type" "branch")])
4456530d 8465
f90b7a5a
PB
8466(define_expand "ctrap<mode>4"
8467 [(trap_if (match_operator 0 "comparison_operator"
8468 [(match_operand:GPR 1 "register_operand" "")
8469 (match_operand:GPR 2 "general_operand" "")])
8470 (match_operand 3 "const0_operand" ""))]
4456530d 8471 ""
f90b7a5a
PB
8472 {
8473 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8474 operands[1], operands[2]);
8475 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8476 DONE;
8477 })
8478
8479(define_expand "ctrap<mode>4"
8480 [(trap_if (match_operator 0 "comparison_operator"
8481 [(match_operand:FP 1 "register_operand" "")
8482 (match_operand:FP 2 "general_operand" "")])
8483 (match_operand 3 "const0_operand" ""))]
8484 ""
8485 {
8486 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8487 operands[1], operands[2]);
8488 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8489 DONE;
8490 })
4456530d 8491
f90b7a5a
PB
8492(define_insn "condtrap"
8493 [(trap_if (match_operator 0 "s390_comparison"
8494 [(match_operand 1 "cc_reg_operand" "c")
8495 (const_int 0)])
4456530d
HP
8496 (const_int 0))]
8497 ""
d40c829f 8498 "j%C0\t.+2";
077dab3b
HP
8499 [(set_attr "op_type" "RI")
8500 (set_attr "type" "branch")])
9db1d521 8501
963fc8d0
AK
8502; crt, cgrt, cit, cgit
8503(define_insn "*cmp_and_trap_signed_int<mode>"
8504 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
8505 [(match_operand:GPR 1 "register_operand" "d,d")
8506 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
8507 (const_int 0))]
8508 "TARGET_Z10"
8509 "@
8510 c<g>rt%C0\t%1,%2
8511 c<g>it%C0\t%1,%h2"
8512 [(set_attr "op_type" "RRF,RIE")
9381e3f1 8513 (set_attr "type" "branch")
729e750f 8514 (set_attr "z10prop" "z10_super_c,z10_super")])
963fc8d0 8515
22ac2c2f 8516; clrt, clgrt, clfit, clgit, clt, clgt
963fc8d0
AK
8517(define_insn "*cmp_and_trap_unsigned_int<mode>"
8518 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
22ac2c2f
AK
8519 [(match_operand:GPR 1 "register_operand" "d,d, d")
8520 (match_operand:GPR 2 "general_operand" "d,D,RT")])
963fc8d0
AK
8521 (const_int 0))]
8522 "TARGET_Z10"
8523 "@
8524 cl<g>rt%C0\t%1,%2
22ac2c2f
AK
8525 cl<gf>it%C0\t%1,%x2
8526 cl<g>t%C0\t%1,%2"
8527 [(set_attr "op_type" "RRF,RIE,RSY")
8528 (set_attr "type" "branch")
8529 (set_attr "z10prop" "z10_super_c,z10_super,*")
8530 (set_attr "cpu_facility" "z10,z10,zEC12")])
8531
8532; lat, lgat
8533(define_insn "*load_and_trap<mode>"
8534 [(trap_if (eq (match_operand:GPR 0 "memory_operand" "RT")
8535 (const_int 0))
8536 (const_int 0))
8537 (set (match_operand:GPR 1 "register_operand" "=d")
8538 (match_dup 0))]
8539 "TARGET_ZEC12"
8540 "l<g>at\t%1,%0"
8541 [(set_attr "op_type" "RXY")])
8542
963fc8d0 8543
9db1d521 8544;;
0a3bdf9d 8545;;- Loop instructions.
9db1d521 8546;;
0a3bdf9d
UW
8547;; This is all complicated by the fact that since this is a jump insn
8548;; we must handle our own output reloads.
c7453384 8549
f1149235
AK
8550;; branch on index
8551
8552; This splitter will be matched by combine and has to add the 2 moves
8553; necessary to load the compare and the increment values into a
8554; register pair as needed by brxle.
8555
8556(define_insn_and_split "*brx_stage1_<GPR:mode>"
8557 [(set (pc)
8558 (if_then_else
8559 (match_operator 6 "s390_brx_operator"
8560 [(plus:GPR (match_operand:GPR 1 "register_operand" "")
8561 (match_operand:GPR 2 "general_operand" ""))
8562 (match_operand:GPR 3 "register_operand" "")])
8563 (label_ref (match_operand 0 "" ""))
8564 (pc)))
8565 (set (match_operand:GPR 4 "nonimmediate_operand" "")
8566 (plus:GPR (match_dup 1) (match_dup 2)))
8567 (clobber (match_scratch:GPR 5 ""))]
8568 "TARGET_CPU_ZARCH"
8569 "#"
8570 "!reload_completed && !reload_in_progress"
8571 [(set (match_dup 7) (match_dup 2)) ; the increment
8572 (set (match_dup 8) (match_dup 3)) ; the comparison value
8573 (parallel [(set (pc)
8574 (if_then_else
8575 (match_op_dup 6
8576 [(plus:GPR (match_dup 1) (match_dup 7))
8577 (match_dup 8)])
8578 (label_ref (match_dup 0))
8579 (pc)))
8580 (set (match_dup 4)
8581 (plus:GPR (match_dup 1) (match_dup 7)))
8582 (clobber (match_dup 5))
8583 (clobber (reg:CC CC_REGNUM))])]
8584 {
8585 rtx dreg = gen_reg_rtx (word_mode == DImode ? TImode : DImode);
8586 operands[7] = gen_lowpart (<GPR:MODE>mode,
8587 gen_highpart (word_mode, dreg));
8588 operands[8] = gen_lowpart (<GPR:MODE>mode,
8589 gen_lowpart (word_mode, dreg));
8590 })
8591
8592; brxlg, brxhg
8593
8594(define_insn_and_split "*brxg_64bit"
8595 [(set (pc)
8596 (if_then_else
8597 (match_operator 5 "s390_brx_operator"
8598 [(plus:DI (match_operand:DI 1 "register_operand" "d,d,d")
8599 (subreg:DI (match_operand:TI 2 "register_operand" "d,d,d") 0))
8600 (subreg:DI (match_dup 2) 8)])
8601 (label_ref (match_operand 0 "" ""))
8602 (pc)))
8603 (set (match_operand:DI 3 "nonimmediate_operand" "=1,?X,?X")
8604 (plus:DI (match_dup 1)
8605 (subreg:DI (match_dup 2) 0)))
8606 (clobber (match_scratch:DI 4 "=X,&1,&?d"))
8607 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8608 "TARGET_ZARCH"
f1149235
AK
8609{
8610 if (which_alternative != 0)
8611 return "#";
8612 else if (get_attr_length (insn) == 6)
8613 return "brx%E5g\t%1,%2,%l0";
8614 else
8615 return "agr\t%1,%2\;cgr\t%1,%M2\;jg%C5\t%l0";
8616}
8617 "&& reload_completed
8618 && (!REG_P (operands[3])
8619 || !rtx_equal_p (operands[1], operands[3]))"
8620 [(set (match_dup 4) (match_dup 1))
8621 (parallel [(set (match_dup 4) (plus:DI (match_dup 4) (subreg:DI (match_dup 2) 0)))
8622 (clobber (reg:CC CC_REGNUM))])
8623 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:DI (match_dup 2) 8)))
8624 (set (match_dup 3) (match_dup 4))
8625 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8626 (label_ref (match_dup 0))
8627 (pc)))]
8628 ""
8629 [(set_attr "op_type" "RIE")
8630 (set_attr "type" "branch")
8631 (set (attr "length")
8632 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8633 (const_int 6) (const_int 16)))])
8634
8635; brxle, brxh
8636
8637(define_insn_and_split "*brx_64bit"
8638 [(set (pc)
8639 (if_then_else
8640 (match_operator 5 "s390_brx_operator"
8641 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
8642 (subreg:SI (match_operand:TI 2 "register_operand" "d,d,d") 4))
8643 (subreg:SI (match_dup 2) 12)])
8644 (label_ref (match_operand 0 "" ""))
8645 (pc)))
8646 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
8647 (plus:SI (match_dup 1)
8648 (subreg:SI (match_dup 2) 4)))
8649 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
8650 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8651 "TARGET_ZARCH"
f1149235
AK
8652{
8653 if (which_alternative != 0)
8654 return "#";
8655 else if (get_attr_length (insn) == 6)
8656 return "brx%C5\t%1,%2,%l0";
8657 else
8658 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
8659}
8660 "&& reload_completed
8661 && (!REG_P (operands[3])
8662 || !rtx_equal_p (operands[1], operands[3]))"
8663 [(set (match_dup 4) (match_dup 1))
8664 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 4)))
8665 (clobber (reg:CC CC_REGNUM))])
8666 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 12)))
8667 (set (match_dup 3) (match_dup 4))
8668 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8669 (label_ref (match_dup 0))
8670 (pc)))]
8671 ""
8672 [(set_attr "op_type" "RSI")
8673 (set_attr "type" "branch")
8674 (set (attr "length")
8675 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8676 (const_int 6) (const_int 14)))])
8677
8678; brxle, brxh
8679
8680(define_insn_and_split "*brx_31bit"
8681 [(set (pc)
8682 (if_then_else
8683 (match_operator 5 "s390_brx_operator"
8684 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
8685 (subreg:SI (match_operand:DI 2 "register_operand" "d,d,d") 0))
8686 (subreg:SI (match_dup 2) 4)])
8687 (label_ref (match_operand 0 "" ""))
8688 (pc)))
8689 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
8690 (plus:SI (match_dup 1)
8691 (subreg:SI (match_dup 2) 0)))
8692 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
8693 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8694 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
f1149235
AK
8695{
8696 if (which_alternative != 0)
8697 return "#";
8698 else if (get_attr_length (insn) == 6)
8699 return "brx%C5\t%1,%2,%l0";
8700 else
8701 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
8702}
8703 "&& reload_completed
8704 && (!REG_P (operands[3])
8705 || !rtx_equal_p (operands[1], operands[3]))"
8706 [(set (match_dup 4) (match_dup 1))
8707 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 0)))
8708 (clobber (reg:CC CC_REGNUM))])
8709 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 4)))
8710 (set (match_dup 3) (match_dup 4))
8711 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8712 (label_ref (match_dup 0))
8713 (pc)))]
8714 ""
8715 [(set_attr "op_type" "RSI")
8716 (set_attr "type" "branch")
8717 (set (attr "length")
8718 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8719 (const_int 6) (const_int 14)))])
8720
8721
8722;; branch on count
8723
0a3bdf9d
UW
8724(define_expand "doloop_end"
8725 [(use (match_operand 0 "" "")) ; loop pseudo
1d0216c8 8726 (use (match_operand 1 "" ""))] ; label
0a3bdf9d 8727 ""
0a3bdf9d 8728{
6590e19a 8729 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
1d0216c8 8730 emit_jump_insn (gen_doloop_si31 (operands[1], operands[0], operands[0]));
6590e19a 8731 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
1d0216c8 8732 emit_jump_insn (gen_doloop_si64 (operands[1], operands[0], operands[0]));
9602b6a1 8733 else if (GET_MODE (operands[0]) == DImode && TARGET_ZARCH)
1d0216c8 8734 emit_jump_insn (gen_doloop_di (operands[1], operands[0], operands[0]));
0a3bdf9d
UW
8735 else
8736 FAIL;
8737
8738 DONE;
10bbf137 8739})
0a3bdf9d 8740
6590e19a 8741(define_insn_and_split "doloop_si64"
0a3bdf9d
UW
8742 [(set (pc)
8743 (if_then_else
7e665d18 8744 (ne (match_operand:SI 1 "register_operand" "d,d,d")
0a3bdf9d
UW
8745 (const_int 1))
8746 (label_ref (match_operand 0 "" ""))
8747 (pc)))
7e665d18 8748 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
0a3bdf9d 8749 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 8750 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
ae156f85 8751 (clobber (reg:CC CC_REGNUM))]
6590e19a 8752 "TARGET_CPU_ZARCH"
0a3bdf9d
UW
8753{
8754 if (which_alternative != 0)
10bbf137 8755 return "#";
0a3bdf9d 8756 else if (get_attr_length (insn) == 4)
d40c829f 8757 return "brct\t%1,%l0";
6590e19a 8758 else
545d16ff 8759 return "ahi\t%1,-1\;jgne\t%l0";
6590e19a
UW
8760}
8761 "&& reload_completed
8762 && (! REG_P (operands[2])
8763 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
8764 [(set (match_dup 3) (match_dup 1))
8765 (parallel [(set (reg:CCAN CC_REGNUM)
6590e19a
UW
8766 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
8767 (const_int 0)))
8768 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
8769 (set (match_dup 2) (match_dup 3))
ae156f85 8770 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a
UW
8771 (label_ref (match_dup 0))
8772 (pc)))]
8773 ""
8774 [(set_attr "op_type" "RI")
9381e3f1
WG
8775 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8776 ; hurt us in the (rare) case of ahi.
729e750f 8777 (set_attr "z10prop" "z10_super_E1")
6590e19a
UW
8778 (set_attr "type" "branch")
8779 (set (attr "length")
8780 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8781 (const_int 4) (const_int 10)))])
8782
8783(define_insn_and_split "doloop_si31"
8784 [(set (pc)
8785 (if_then_else
7e665d18 8786 (ne (match_operand:SI 1 "register_operand" "d,d,d")
6590e19a
UW
8787 (const_int 1))
8788 (label_ref (match_operand 0 "" ""))
8789 (pc)))
7e665d18 8790 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
6590e19a 8791 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 8792 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
ae156f85 8793 (clobber (reg:CC CC_REGNUM))]
6590e19a
UW
8794 "!TARGET_CPU_ZARCH"
8795{
8796 if (which_alternative != 0)
8797 return "#";
8798 else if (get_attr_length (insn) == 4)
8799 return "brct\t%1,%l0";
0a3bdf9d 8800 else
8d933e31 8801 gcc_unreachable ();
10bbf137 8802}
6590e19a
UW
8803 "&& reload_completed
8804 && (! REG_P (operands[2])
8805 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
8806 [(set (match_dup 3) (match_dup 1))
8807 (parallel [(set (reg:CCAN CC_REGNUM)
6590e19a
UW
8808 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
8809 (const_int 0)))
8810 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
8811 (set (match_dup 2) (match_dup 3))
ae156f85 8812 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a
UW
8813 (label_ref (match_dup 0))
8814 (pc)))]
8815 ""
0a3bdf9d 8816 [(set_attr "op_type" "RI")
9381e3f1
WG
8817 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8818 ; hurt us in the (rare) case of ahi.
729e750f 8819 (set_attr "z10prop" "z10_super_E1")
077dab3b 8820 (set_attr "type" "branch")
0a3bdf9d 8821 (set (attr "length")
d7f99b2c 8822 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
8823 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8824 (const_int 4) (const_int 6))
8825 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8826 (const_int 4) (const_int 8))))])
9db1d521 8827
0a3bdf9d
UW
8828(define_insn "*doloop_si_long"
8829 [(set (pc)
8830 (if_then_else
7e665d18 8831 (ne (match_operand:SI 1 "register_operand" "d")
0a3bdf9d 8832 (const_int 1))
4fe6dea8 8833 (match_operand 0 "address_operand" "ZQZR")
0a3bdf9d 8834 (pc)))
7e665d18 8835 (set (match_operand:SI 2 "register_operand" "=1")
0a3bdf9d 8836 (plus:SI (match_dup 1) (const_int -1)))
7e665d18 8837 (clobber (match_scratch:SI 3 "=X"))
ae156f85 8838 (clobber (reg:CC CC_REGNUM))]
6590e19a 8839 "!TARGET_CPU_ZARCH"
0a3bdf9d
UW
8840{
8841 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8842 return "bctr\t%1,%0";
0a3bdf9d 8843 else
d40c829f 8844 return "bct\t%1,%a0";
10bbf137 8845}
c7453384 8846 [(set (attr "op_type")
0a3bdf9d
UW
8847 (if_then_else (match_operand 0 "register_operand" "")
8848 (const_string "RR") (const_string "RX")))
077dab3b 8849 (set_attr "type" "branch")
729e750f 8850 (set_attr "atype" "agen")
65b1d8ea
AK
8851 (set_attr "z10prop" "z10_c")
8852 (set_attr "z196prop" "z196_cracked")])
0a3bdf9d 8853
6590e19a 8854(define_insn_and_split "doloop_di"
0a3bdf9d
UW
8855 [(set (pc)
8856 (if_then_else
7e665d18 8857 (ne (match_operand:DI 1 "register_operand" "d,d,d")
0a3bdf9d
UW
8858 (const_int 1))
8859 (label_ref (match_operand 0 "" ""))
8860 (pc)))
7e665d18 8861 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
0a3bdf9d 8862 (plus:DI (match_dup 1) (const_int -1)))
7e665d18 8863 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
ae156f85 8864 (clobber (reg:CC CC_REGNUM))]
9602b6a1 8865 "TARGET_ZARCH"
0a3bdf9d
UW
8866{
8867 if (which_alternative != 0)
10bbf137 8868 return "#";
0a3bdf9d 8869 else if (get_attr_length (insn) == 4)
d40c829f 8870 return "brctg\t%1,%l0";
0a3bdf9d 8871 else
545d16ff 8872 return "aghi\t%1,-1\;jgne\t%l0";
10bbf137 8873}
6590e19a 8874 "&& reload_completed
0a3bdf9d
UW
8875 && (! REG_P (operands[2])
8876 || ! rtx_equal_p (operands[1], operands[2]))"
7e665d18
AK
8877 [(set (match_dup 3) (match_dup 1))
8878 (parallel [(set (reg:CCAN CC_REGNUM)
0a3bdf9d
UW
8879 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
8880 (const_int 0)))
8881 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
8882 (set (match_dup 2) (match_dup 3))
ae156f85 8883 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
6590e19a 8884 (label_ref (match_dup 0))
0a3bdf9d 8885 (pc)))]
6590e19a
UW
8886 ""
8887 [(set_attr "op_type" "RI")
9381e3f1
WG
8888 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8889 ; hurt us in the (rare) case of ahi.
729e750f 8890 (set_attr "z10prop" "z10_super_E1")
6590e19a
UW
8891 (set_attr "type" "branch")
8892 (set (attr "length")
8893 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8894 (const_int 4) (const_int 10)))])
9db1d521
HP
8895
8896;;
8897;;- Unconditional jump instructions.
8898;;
8899
8900;
8901; jump instruction pattern(s).
8902;
8903
6590e19a
UW
8904(define_expand "jump"
8905 [(match_operand 0 "" "")]
9db1d521 8906 ""
6590e19a
UW
8907 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
8908
8909(define_insn "*jump64"
8910 [(set (pc) (label_ref (match_operand 0 "" "")))]
8911 "TARGET_CPU_ZARCH"
9db1d521 8912{
13e58269 8913 if (get_attr_length (insn) == 4)
d40c829f 8914 return "j\t%l0";
6590e19a 8915 else
d40c829f 8916 return "jg\t%l0";
6590e19a
UW
8917}
8918 [(set_attr "op_type" "RI")
8919 (set_attr "type" "branch")
8920 (set (attr "length")
8921 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8922 (const_int 4) (const_int 6)))])
8923
8924(define_insn "*jump31"
8925 [(set (pc) (label_ref (match_operand 0 "" "")))]
8926 "!TARGET_CPU_ZARCH"
8927{
8d933e31
AS
8928 gcc_assert (get_attr_length (insn) == 4);
8929 return "j\t%l0";
10bbf137 8930}
9db1d521 8931 [(set_attr "op_type" "RI")
077dab3b 8932 (set_attr "type" "branch")
13e58269 8933 (set (attr "length")
d7f99b2c 8934 (if_then_else (not (match_test "flag_pic"))
6590e19a
UW
8935 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8936 (const_int 4) (const_int 6))
8937 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8938 (const_int 4) (const_int 8))))])
9db1d521
HP
8939
8940;
8941; indirect-jump instruction pattern(s).
8942;
8943
8944(define_insn "indirect_jump"
4fe6dea8 8945 [(set (pc) (match_operand 0 "address_operand" "ZQZR"))]
9db1d521 8946 ""
f314b9b1
UW
8947{
8948 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8949 return "br\t%0";
f314b9b1 8950 else
d40c829f 8951 return "b\t%a0";
10bbf137 8952}
c7453384 8953 [(set (attr "op_type")
f314b9b1
UW
8954 (if_then_else (match_operand 0 "register_operand" "")
8955 (const_string "RR") (const_string "RX")))
077dab3b 8956 (set_attr "type" "branch")
729e750f 8957 (set_attr "atype" "agen")])
9db1d521
HP
8958
8959;
f314b9b1 8960; casesi instruction pattern(s).
9db1d521
HP
8961;
8962
f314b9b1 8963(define_insn "casesi_jump"
4fe6dea8 8964 [(set (pc) (match_operand 0 "address_operand" "ZQZR"))
f314b9b1 8965 (use (label_ref (match_operand 1 "" "")))]
9db1d521 8966 ""
9db1d521 8967{
f314b9b1 8968 if (get_attr_op_type (insn) == OP_TYPE_RR)
d40c829f 8969 return "br\t%0";
f314b9b1 8970 else
d40c829f 8971 return "b\t%a0";
10bbf137 8972}
c7453384 8973 [(set (attr "op_type")
f314b9b1
UW
8974 (if_then_else (match_operand 0 "register_operand" "")
8975 (const_string "RR") (const_string "RX")))
077dab3b
HP
8976 (set_attr "type" "branch")
8977 (set_attr "atype" "agen")])
9db1d521 8978
f314b9b1
UW
8979(define_expand "casesi"
8980 [(match_operand:SI 0 "general_operand" "")
8981 (match_operand:SI 1 "general_operand" "")
8982 (match_operand:SI 2 "general_operand" "")
8983 (label_ref (match_operand 3 "" ""))
8984 (label_ref (match_operand 4 "" ""))]
9db1d521 8985 ""
f314b9b1
UW
8986{
8987 rtx index = gen_reg_rtx (SImode);
8988 rtx base = gen_reg_rtx (Pmode);
8989 rtx target = gen_reg_rtx (Pmode);
8990
8991 emit_move_insn (index, operands[0]);
8992 emit_insn (gen_subsi3 (index, index, operands[1]));
8993 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
e790b36a 8994 operands[4]);
f314b9b1
UW
8995
8996 if (Pmode != SImode)
8997 index = convert_to_mode (Pmode, index, 1);
8998 if (GET_CODE (index) != REG)
8999 index = copy_to_mode_reg (Pmode, index);
9000
9001 if (TARGET_64BIT)
9002 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
9003 else
a556fd39 9004 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
9db1d521 9005
f314b9b1
UW
9006 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
9007
542a8afa 9008 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
f314b9b1
UW
9009 emit_move_insn (target, index);
9010
9011 if (flag_pic)
9012 target = gen_rtx_PLUS (Pmode, base, target);
9013 emit_jump_insn (gen_casesi_jump (target, operands[3]));
9014
9015 DONE;
10bbf137 9016})
9db1d521
HP
9017
9018
9019;;
9020;;- Jump to subroutine.
9021;;
9022;;
9023
9024;
9025; untyped call instruction pattern(s).
9026;
9027
9028;; Call subroutine returning any type.
9029(define_expand "untyped_call"
9030 [(parallel [(call (match_operand 0 "" "")
9031 (const_int 0))
9032 (match_operand 1 "" "")
9033 (match_operand 2 "" "")])]
9034 ""
9db1d521
HP
9035{
9036 int i;
9037
9038 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
9039
9040 for (i = 0; i < XVECLEN (operands[2], 0); i++)
9041 {
9042 rtx set = XVECEXP (operands[2], 0, i);
9043 emit_move_insn (SET_DEST (set), SET_SRC (set));
9044 }
9045
9046 /* The optimizer does not know that the call sets the function value
9047 registers we stored in the result block. We avoid problems by
9048 claiming that all hard registers are used and clobbered at this
9049 point. */
9050 emit_insn (gen_blockage ());
9051
9052 DONE;
10bbf137 9053})
9db1d521
HP
9054
9055;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
9056;; all of memory. This blocks insns from being moved across this point.
9057
9058(define_insn "blockage"
10bbf137 9059 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
9db1d521 9060 ""
4023fb28 9061 ""
d5869ca0
UW
9062 [(set_attr "type" "none")
9063 (set_attr "length" "0")])
4023fb28 9064
9db1d521 9065;
ed9676cf 9066; sibcall patterns
9db1d521
HP
9067;
9068
ed9676cf 9069(define_expand "sibcall"
44b8152b 9070 [(call (match_operand 0 "" "")
ed9676cf 9071 (match_operand 1 "" ""))]
9db1d521 9072 ""
9db1d521 9073{
ed9676cf
AK
9074 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
9075 DONE;
9076})
9db1d521 9077
ed9676cf 9078(define_insn "*sibcall_br"
ae156f85 9079 [(call (mem:QI (reg SIBCALL_REGNUM))
ed9676cf 9080 (match_operand 0 "const_int_operand" "n"))]
2f7e5a0d 9081 "SIBLING_CALL_P (insn)
ed9676cf
AK
9082 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
9083 "br\t%%r1"
9084 [(set_attr "op_type" "RR")
9085 (set_attr "type" "branch")
9086 (set_attr "atype" "agen")])
9db1d521 9087
ed9676cf
AK
9088(define_insn "*sibcall_brc"
9089 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9090 (match_operand 1 "const_int_operand" "n"))]
9091 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
9092 "j\t%0"
9093 [(set_attr "op_type" "RI")
9094 (set_attr "type" "branch")])
9db1d521 9095
ed9676cf
AK
9096(define_insn "*sibcall_brcl"
9097 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9098 (match_operand 1 "const_int_operand" "n"))]
9099 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
9100 "jg\t%0"
9101 [(set_attr "op_type" "RIL")
9102 (set_attr "type" "branch")])
44b8152b 9103
ed9676cf
AK
9104;
9105; sibcall_value patterns
9106;
9e8327e3 9107
ed9676cf
AK
9108(define_expand "sibcall_value"
9109 [(set (match_operand 0 "" "")
9110 (call (match_operand 1 "" "")
9111 (match_operand 2 "" "")))]
9112 ""
9113{
9114 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
44b8152b 9115 DONE;
10bbf137 9116})
9db1d521 9117
ed9676cf
AK
9118(define_insn "*sibcall_value_br"
9119 [(set (match_operand 0 "" "")
ae156f85 9120 (call (mem:QI (reg SIBCALL_REGNUM))
ed9676cf 9121 (match_operand 1 "const_int_operand" "n")))]
2f7e5a0d 9122 "SIBLING_CALL_P (insn)
ed9676cf
AK
9123 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
9124 "br\t%%r1"
9125 [(set_attr "op_type" "RR")
9126 (set_attr "type" "branch")
9127 (set_attr "atype" "agen")])
9128
9129(define_insn "*sibcall_value_brc"
9130 [(set (match_operand 0 "" "")
9131 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9132 (match_operand 2 "const_int_operand" "n")))]
9133 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
9134 "j\t%1"
9135 [(set_attr "op_type" "RI")
9136 (set_attr "type" "branch")])
9137
9138(define_insn "*sibcall_value_brcl"
9139 [(set (match_operand 0 "" "")
9140 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9141 (match_operand 2 "const_int_operand" "n")))]
9142 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
9143 "jg\t%1"
9144 [(set_attr "op_type" "RIL")
9145 (set_attr "type" "branch")])
9146
9147
9148;
9149; call instruction pattern(s).
9150;
9151
9152(define_expand "call"
9153 [(call (match_operand 0 "" "")
9154 (match_operand 1 "" ""))
9155 (use (match_operand 2 "" ""))]
44b8152b 9156 ""
ed9676cf 9157{
2f7e5a0d 9158 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
ed9676cf
AK
9159 gen_rtx_REG (Pmode, RETURN_REGNUM));
9160 DONE;
9161})
44b8152b 9162
9e8327e3
UW
9163(define_insn "*bras"
9164 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9165 (match_operand 1 "const_int_operand" "n"))
9166 (clobber (match_operand 2 "register_operand" "=r"))]
2f7e5a0d
EC
9167 "!SIBLING_CALL_P (insn)
9168 && TARGET_SMALL_EXEC
ed9676cf 9169 && GET_MODE (operands[2]) == Pmode"
d40c829f 9170 "bras\t%2,%0"
9db1d521 9171 [(set_attr "op_type" "RI")
65b1d8ea
AK
9172 (set_attr "type" "jsr")
9173 (set_attr "z196prop" "z196_cracked")])
9db1d521 9174
9e8327e3
UW
9175(define_insn "*brasl"
9176 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9177 (match_operand 1 "const_int_operand" "n"))
9178 (clobber (match_operand 2 "register_operand" "=r"))]
2f7e5a0d
EC
9179 "!SIBLING_CALL_P (insn)
9180 && TARGET_CPU_ZARCH
ed9676cf 9181 && GET_MODE (operands[2]) == Pmode"
9e8327e3
UW
9182 "brasl\t%2,%0"
9183 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9184 (set_attr "type" "jsr")
9185 (set_attr "z196prop" "z196_cracked")])
9db1d521 9186
9e8327e3 9187(define_insn "*basr"
4fe6dea8 9188 [(call (mem:QI (match_operand 0 "address_operand" "ZQZR"))
9e8327e3
UW
9189 (match_operand 1 "const_int_operand" "n"))
9190 (clobber (match_operand 2 "register_operand" "=r"))]
ed9676cf 9191 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
9e8327e3
UW
9192{
9193 if (get_attr_op_type (insn) == OP_TYPE_RR)
9194 return "basr\t%2,%0";
9195 else
9196 return "bas\t%2,%a0";
9197}
9198 [(set (attr "op_type")
9199 (if_then_else (match_operand 0 "register_operand" "")
9200 (const_string "RR") (const_string "RX")))
9201 (set_attr "type" "jsr")
65b1d8ea
AK
9202 (set_attr "atype" "agen")
9203 (set_attr "z196prop" "z196_cracked")])
9db1d521
HP
9204
9205;
9206; call_value instruction pattern(s).
9207;
9208
9209(define_expand "call_value"
44b8152b
UW
9210 [(set (match_operand 0 "" "")
9211 (call (match_operand 1 "" "")
9212 (match_operand 2 "" "")))
9213 (use (match_operand 3 "" ""))]
9db1d521 9214 ""
9db1d521 9215{
2f7e5a0d 9216 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
ed9676cf 9217 gen_rtx_REG (Pmode, RETURN_REGNUM));
44b8152b 9218 DONE;
10bbf137 9219})
9db1d521 9220
9e8327e3 9221(define_insn "*bras_r"
c19ec8f9 9222 [(set (match_operand 0 "" "")
9e8327e3 9223 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9db1d521 9224 (match_operand:SI 2 "const_int_operand" "n")))
9e8327e3 9225 (clobber (match_operand 3 "register_operand" "=r"))]
2f7e5a0d
EC
9226 "!SIBLING_CALL_P (insn)
9227 && TARGET_SMALL_EXEC
ed9676cf 9228 && GET_MODE (operands[3]) == Pmode"
d40c829f 9229 "bras\t%3,%1"
9db1d521 9230 [(set_attr "op_type" "RI")
65b1d8ea
AK
9231 (set_attr "type" "jsr")
9232 (set_attr "z196prop" "z196_cracked")])
9db1d521 9233
9e8327e3 9234(define_insn "*brasl_r"
c19ec8f9 9235 [(set (match_operand 0 "" "")
9e8327e3
UW
9236 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9237 (match_operand 2 "const_int_operand" "n")))
9238 (clobber (match_operand 3 "register_operand" "=r"))]
2f7e5a0d
EC
9239 "!SIBLING_CALL_P (insn)
9240 && TARGET_CPU_ZARCH
ed9676cf 9241 && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9242 "brasl\t%3,%1"
9243 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9244 (set_attr "type" "jsr")
9245 (set_attr "z196prop" "z196_cracked")])
9db1d521 9246
9e8327e3 9247(define_insn "*basr_r"
c19ec8f9 9248 [(set (match_operand 0 "" "")
4fe6dea8 9249 (call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
9e8327e3
UW
9250 (match_operand 2 "const_int_operand" "n")))
9251 (clobber (match_operand 3 "register_operand" "=r"))]
ed9676cf 9252 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9253{
9254 if (get_attr_op_type (insn) == OP_TYPE_RR)
9255 return "basr\t%3,%1";
9256 else
9257 return "bas\t%3,%a1";
9258}
9259 [(set (attr "op_type")
9260 (if_then_else (match_operand 1 "register_operand" "")
9261 (const_string "RR") (const_string "RX")))
9262 (set_attr "type" "jsr")
65b1d8ea
AK
9263 (set_attr "atype" "agen")
9264 (set_attr "z196prop" "z196_cracked")])
9db1d521 9265
fd3cd001
UW
9266;;
9267;;- Thread-local storage support.
9268;;
9269
f959607b
CLT
9270(define_expand "get_thread_pointer<mode>"
9271 [(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))]
9272 ""
c5aa1d12 9273 "")
fd3cd001 9274
f959607b
CLT
9275(define_expand "set_thread_pointer<mode>"
9276 [(set (reg:P TP_REGNUM) (match_operand:P 0 "nonimmediate_operand" ""))
9277 (set (reg:P TP_REGNUM) (unspec_volatile:P [(reg:P TP_REGNUM)] UNSPECV_SET_TP))]
9278 ""
c5aa1d12
UW
9279 "")
9280
9281(define_insn "*set_tp"
ae156f85 9282 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
c5aa1d12
UW
9283 ""
9284 ""
9285 [(set_attr "type" "none")
9286 (set_attr "length" "0")])
c7453384 9287
fd3cd001
UW
9288(define_insn "*tls_load_64"
9289 [(set (match_operand:DI 0 "register_operand" "=d")
fb492564 9290 (unspec:DI [(match_operand:DI 1 "memory_operand" "RT")
fd3cd001
UW
9291 (match_operand:DI 2 "" "")]
9292 UNSPEC_TLS_LOAD))]
9293 "TARGET_64BIT"
d40c829f 9294 "lg\t%0,%1%J2"
9381e3f1
WG
9295 [(set_attr "op_type" "RXE")
9296 (set_attr "z10prop" "z10_fwd_A3")])
fd3cd001
UW
9297
9298(define_insn "*tls_load_31"
d3632d41
UW
9299 [(set (match_operand:SI 0 "register_operand" "=d,d")
9300 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
fd3cd001
UW
9301 (match_operand:SI 2 "" "")]
9302 UNSPEC_TLS_LOAD))]
9303 "!TARGET_64BIT"
d3632d41 9304 "@
d40c829f
UW
9305 l\t%0,%1%J2
9306 ly\t%0,%1%J2"
9381e3f1 9307 [(set_attr "op_type" "RX,RXY")
cdc15d23 9308 (set_attr "type" "load")
9381e3f1 9309 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
fd3cd001 9310
9e8327e3 9311(define_insn "*bras_tls"
c19ec8f9 9312 [(set (match_operand 0 "" "")
9e8327e3
UW
9313 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9314 (match_operand 2 "const_int_operand" "n")))
9315 (clobber (match_operand 3 "register_operand" "=r"))
9316 (use (match_operand 4 "" ""))]
2f7e5a0d
EC
9317 "!SIBLING_CALL_P (insn)
9318 && TARGET_SMALL_EXEC
ed9676cf 9319 && GET_MODE (operands[3]) == Pmode"
d40c829f 9320 "bras\t%3,%1%J4"
fd3cd001 9321 [(set_attr "op_type" "RI")
65b1d8ea
AK
9322 (set_attr "type" "jsr")
9323 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9324
9e8327e3 9325(define_insn "*brasl_tls"
c19ec8f9 9326 [(set (match_operand 0 "" "")
9e8327e3
UW
9327 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9328 (match_operand 2 "const_int_operand" "n")))
9329 (clobber (match_operand 3 "register_operand" "=r"))
9330 (use (match_operand 4 "" ""))]
2f7e5a0d
EC
9331 "!SIBLING_CALL_P (insn)
9332 && TARGET_CPU_ZARCH
ed9676cf 9333 && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9334 "brasl\t%3,%1%J4"
9335 [(set_attr "op_type" "RIL")
65b1d8ea
AK
9336 (set_attr "type" "jsr")
9337 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9338
9e8327e3 9339(define_insn "*basr_tls"
c19ec8f9 9340 [(set (match_operand 0 "" "")
4fe6dea8 9341 (call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
9e8327e3
UW
9342 (match_operand 2 "const_int_operand" "n")))
9343 (clobber (match_operand 3 "register_operand" "=r"))
9344 (use (match_operand 4 "" ""))]
ed9676cf 9345 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9e8327e3
UW
9346{
9347 if (get_attr_op_type (insn) == OP_TYPE_RR)
9348 return "basr\t%3,%1%J4";
9349 else
9350 return "bas\t%3,%a1%J4";
9351}
9352 [(set (attr "op_type")
9353 (if_then_else (match_operand 1 "register_operand" "")
9354 (const_string "RR") (const_string "RX")))
9355 (set_attr "type" "jsr")
65b1d8ea
AK
9356 (set_attr "atype" "agen")
9357 (set_attr "z196prop" "z196_cracked")])
fd3cd001 9358
e0374221
AS
9359;;
9360;;- Atomic operations
9361;;
9362
9363;
78ce265b 9364; memory barrier patterns.
e0374221
AS
9365;
9366
78ce265b
RH
9367(define_expand "mem_signal_fence"
9368 [(match_operand:SI 0 "const_int_operand")] ;; model
e0374221
AS
9369 ""
9370{
78ce265b
RH
9371 /* The s390 memory model is strong enough not to require any
9372 barrier in order to synchronize a thread with itself. */
9373 DONE;
9374})
9375
9376(define_expand "mem_thread_fence"
9377 [(match_operand:SI 0 "const_int_operand")] ;; model
9378 ""
9379{
9380 /* Unless this is a SEQ_CST fence, the s390 memory model is strong
9381 enough not to require barriers of any kind. */
46b35980 9382 if (is_mm_seq_cst (memmodel_from_int (INTVAL (operands[0]))))
78ce265b
RH
9383 {
9384 rtx mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
9385 MEM_VOLATILE_P (mem) = 1;
9386 emit_insn (gen_mem_thread_fence_1 (mem));
9387 }
9388 DONE;
e0374221
AS
9389})
9390
78ce265b
RH
9391; Although bcr is superscalar on Z10, this variant will never
9392; become part of an execution group.
a9cc3f58
AK
9393; With z196 we can make use of the fast-BCR-serialization facility.
9394; This allows for a slightly faster sync which is sufficient for our
9395; purposes.
78ce265b 9396(define_insn "mem_thread_fence_1"
e0374221 9397 [(set (match_operand:BLK 0 "" "")
1a8c13b3 9398 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
e0374221 9399 ""
a9cc3f58
AK
9400{
9401 if (TARGET_Z196)
9402 return "bcr\t14,0";
9403 else
9404 return "bcr\t15,0";
9405}
9406 [(set_attr "op_type" "RR")
9407 (set_attr "mnemonic" "bcr_flush")
9408 (set_attr "z196prop" "z196_alone")])
1a8c13b3 9409
78ce265b
RH
9410;
9411; atomic load/store operations
9412;
9413
9414; Atomic loads need not examine the memory model at all.
9415(define_expand "atomic_load<mode>"
9416 [(match_operand:DINT 0 "register_operand") ;; output
9417 (match_operand:DINT 1 "memory_operand") ;; memory
9418 (match_operand:SI 2 "const_int_operand")] ;; model
9419 ""
9420{
75cc21e2
AK
9421 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
9422 FAIL;
9423
78ce265b
RH
9424 if (<MODE>mode == TImode)
9425 emit_insn (gen_atomic_loadti_1 (operands[0], operands[1]));
9426 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9427 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
9428 else
9429 emit_move_insn (operands[0], operands[1]);
9430 DONE;
9431})
9432
9433; Different from movdi_31 in that we want no splitters.
9434(define_insn "atomic_loaddi_1"
9435 [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f")
9436 (unspec:DI [(match_operand:DI 1 "memory_operand" "Q,S,R,T")]
9437 UNSPEC_MOVA))]
9438 "!TARGET_ZARCH"
9439 "@
9440 lm\t%0,%M0,%S1
9441 lmy\t%0,%M0,%S1
9442 ld\t%0,%1
9443 ldy\t%0,%1"
9444 [(set_attr "op_type" "RS,RSY,RS,RSY")
9445 (set_attr "type" "lm,lm,floaddf,floaddf")])
9446
9447(define_insn "atomic_loadti_1"
9448 [(set (match_operand:TI 0 "register_operand" "=r")
9449 (unspec:TI [(match_operand:TI 1 "memory_operand" "RT")]
9450 UNSPEC_MOVA))]
9451 "TARGET_ZARCH"
9452 "lpq\t%0,%1"
9453 [(set_attr "op_type" "RXY")
9454 (set_attr "type" "other")])
9455
9456; Atomic stores must(?) enforce sequential consistency.
9457(define_expand "atomic_store<mode>"
9458 [(match_operand:DINT 0 "memory_operand") ;; memory
9459 (match_operand:DINT 1 "register_operand") ;; input
9460 (match_operand:SI 2 "const_int_operand")] ;; model
9461 ""
9462{
46b35980 9463 enum memmodel model = memmodel_from_int (INTVAL (operands[2]));
78ce265b 9464
75cc21e2
AK
9465 if (MEM_ALIGN (operands[0]) < GET_MODE_BITSIZE (GET_MODE (operands[0])))
9466 FAIL;
9467
78ce265b
RH
9468 if (<MODE>mode == TImode)
9469 emit_insn (gen_atomic_storeti_1 (operands[0], operands[1]));
9470 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9471 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
9472 else
9473 emit_move_insn (operands[0], operands[1]);
46b35980 9474 if (is_mm_seq_cst (model))
78ce265b
RH
9475 emit_insn (gen_mem_thread_fence (operands[2]));
9476 DONE;
9477})
9478
9479; Different from movdi_31 in that we want no splitters.
9480(define_insn "atomic_storedi_1"
9481 [(set (match_operand:DI 0 "memory_operand" "=Q,S,R,T")
9482 (unspec:DI [(match_operand:DI 1 "register_operand" "d,d,!*f,!*f")]
9483 UNSPEC_MOVA))]
9484 "!TARGET_ZARCH"
9485 "@
9486 stm\t%1,%N1,%S0
9487 stmy\t%1,%N1,%S0
9488 std %1,%0
9489 stdy %1,%0"
9490 [(set_attr "op_type" "RS,RSY,RS,RSY")
9491 (set_attr "type" "stm,stm,fstoredf,fstoredf")])
9492
9493(define_insn "atomic_storeti_1"
9494 [(set (match_operand:TI 0 "memory_operand" "=RT")
9495 (unspec:TI [(match_operand:TI 1 "register_operand" "r")]
9496 UNSPEC_MOVA))]
9497 "TARGET_ZARCH"
9498 "stpq\t%1,%0"
9499 [(set_attr "op_type" "RXY")
9500 (set_attr "type" "other")])
e0374221
AS
9501
9502;
9503; compare and swap patterns.
9504;
9505
78ce265b
RH
9506(define_expand "atomic_compare_and_swap<mode>"
9507 [(match_operand:SI 0 "register_operand") ;; bool success output
215770ad 9508 (match_operand:DGPR 1 "nonimmediate_operand");; oldval output
78ce265b
RH
9509 (match_operand:DGPR 2 "memory_operand") ;; memory
9510 (match_operand:DGPR 3 "register_operand") ;; expected intput
9511 (match_operand:DGPR 4 "register_operand") ;; newval intput
9512 (match_operand:SI 5 "const_int_operand") ;; is_weak
9513 (match_operand:SI 6 "const_int_operand") ;; success model
9514 (match_operand:SI 7 "const_int_operand")] ;; failure model
9515 ""
9516{
215770ad
UW
9517 rtx cc, cmp, output = operands[1];
9518
9519 if (!register_operand (output, <MODE>mode))
9520 output = gen_reg_rtx (<MODE>mode);
9521
75cc21e2
AK
9522 if (MEM_ALIGN (operands[2]) < GET_MODE_BITSIZE (GET_MODE (operands[2])))
9523 FAIL;
9524
78ce265b 9525 emit_insn (gen_atomic_compare_and_swap<mode>_internal
215770ad
UW
9526 (output, operands[2], operands[3], operands[4]));
9527
9528 /* We deliberately accept non-register operands in the predicate
9529 to ensure the write back to the output operand happens *before*
9530 the store-flags code below. This makes it easier for combine
9531 to merge the store-flags code with a potential test-and-branch
9532 pattern following (immediately!) afterwards. */
9533 if (output != operands[1])
9534 emit_move_insn (operands[1], output);
9535
78ce265b
RH
9536 cc = gen_rtx_REG (CCZ1mode, CC_REGNUM);
9537 cmp = gen_rtx_EQ (SImode, cc, const0_rtx);
9538 emit_insn (gen_cstorecc4 (operands[0], cmp, cc, const0_rtx));
9539 DONE;
9540})
e0374221 9541
78ce265b
RH
9542(define_expand "atomic_compare_and_swap<mode>"
9543 [(match_operand:SI 0 "register_operand") ;; bool success output
215770ad 9544 (match_operand:HQI 1 "nonimmediate_operand") ;; oldval output
78ce265b
RH
9545 (match_operand:HQI 2 "memory_operand") ;; memory
9546 (match_operand:HQI 3 "general_operand") ;; expected intput
9547 (match_operand:HQI 4 "general_operand") ;; newval intput
9548 (match_operand:SI 5 "const_int_operand") ;; is_weak
9549 (match_operand:SI 6 "const_int_operand") ;; success model
9550 (match_operand:SI 7 "const_int_operand")] ;; failure model
3093f076 9551 ""
78ce265b
RH
9552{
9553 s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1], operands[2],
9554 operands[3], operands[4], INTVAL (operands[5]));
9555 DONE;
9556})
3093f076 9557
78ce265b
RH
9558(define_expand "atomic_compare_and_swap<mode>_internal"
9559 [(parallel
9560 [(set (match_operand:DGPR 0 "register_operand")
9561 (match_operand:DGPR 1 "memory_operand"))
9562 (set (match_dup 1)
9563 (unspec_volatile:DGPR
9564 [(match_dup 1)
9565 (match_operand:DGPR 2 "register_operand")
9566 (match_operand:DGPR 3 "register_operand")]
9567 UNSPECV_CAS))
9568 (set (reg:CCZ1 CC_REGNUM)
9569 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
9570 "")
9571
9572; cdsg, csg
9573(define_insn "*atomic_compare_and_swap<mode>_1"
9574 [(set (match_operand:TDI 0 "register_operand" "=r")
9575 (match_operand:TDI 1 "memory_operand" "+QS"))
8006eaa6 9576 (set (match_dup 1)
78ce265b 9577 (unspec_volatile:TDI
8006eaa6 9578 [(match_dup 1)
78ce265b
RH
9579 (match_operand:TDI 2 "register_operand" "0")
9580 (match_operand:TDI 3 "register_operand" "r")]
8006eaa6
AS
9581 UNSPECV_CAS))
9582 (set (reg:CCZ1 CC_REGNUM)
9583 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
78ce265b
RH
9584 "TARGET_ZARCH"
9585 "c<td>sg\t%0,%3,%S1"
9586 [(set_attr "op_type" "RSY")
8006eaa6
AS
9587 (set_attr "type" "sem")])
9588
78ce265b
RH
9589; cds, cdsy
9590(define_insn "*atomic_compare_and_swapdi_2"
9591 [(set (match_operand:DI 0 "register_operand" "=r,r")
9592 (match_operand:DI 1 "memory_operand" "+Q,S"))
e0374221 9593 (set (match_dup 1)
78ce265b
RH
9594 (unspec_volatile:DI
9595 [(match_dup 1)
9596 (match_operand:DI 2 "register_operand" "0,0")
9597 (match_operand:DI 3 "register_operand" "r,r")]
9598 UNSPECV_CAS))
9599 (set (reg:CCZ1 CC_REGNUM)
9600 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9601 "!TARGET_ZARCH"
9602 "@
9603 cds\t%0,%3,%S1
9604 cdsy\t%0,%3,%S1"
9605 [(set_attr "op_type" "RS,RSY")
9606 (set_attr "type" "sem")])
9607
9608; cs, csy
9609(define_insn "*atomic_compare_and_swapsi_3"
9610 [(set (match_operand:SI 0 "register_operand" "=r,r")
9611 (match_operand:SI 1 "memory_operand" "+Q,S"))
9612 (set (match_dup 1)
9613 (unspec_volatile:SI
e0374221 9614 [(match_dup 1)
78ce265b
RH
9615 (match_operand:SI 2 "register_operand" "0,0")
9616 (match_operand:SI 3 "register_operand" "r,r")]
e0374221 9617 UNSPECV_CAS))
69950452
AS
9618 (set (reg:CCZ1 CC_REGNUM)
9619 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9381e3f1 9620 ""
78ce265b
RH
9621 "@
9622 cs\t%0,%3,%S1
9623 csy\t%0,%3,%S1"
9624 [(set_attr "op_type" "RS,RSY")
e0374221
AS
9625 (set_attr "type" "sem")])
9626
45d18331
AS
9627;
9628; Other atomic instruction patterns.
9629;
9630
65b1d8ea
AK
9631; z196 load and add, xor, or and and instructions
9632
78ce265b
RH
9633(define_expand "atomic_fetch_<atomic><mode>"
9634 [(match_operand:GPR 0 "register_operand") ;; val out
9635 (ATOMIC_Z196:GPR
9636 (match_operand:GPR 1 "memory_operand") ;; memory
9637 (match_operand:GPR 2 "register_operand")) ;; val in
9638 (match_operand:SI 3 "const_int_operand")] ;; model
65b1d8ea 9639 "TARGET_Z196"
78ce265b 9640{
75cc21e2
AK
9641 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
9642 FAIL;
9643
78ce265b
RH
9644 emit_insn (gen_atomic_fetch_<atomic><mode>_iaf
9645 (operands[0], operands[1], operands[2]));
9646 DONE;
9647})
65b1d8ea
AK
9648
9649; lan, lang, lao, laog, lax, laxg, laa, laag
78ce265b
RH
9650(define_insn "atomic_fetch_<atomic><mode>_iaf"
9651 [(set (match_operand:GPR 0 "register_operand" "=d")
9652 (match_operand:GPR 1 "memory_operand" "+QS"))
9653 (set (match_dup 1)
9654 (unspec_volatile:GPR
9655 [(ATOMIC_Z196:GPR (match_dup 1)
9656 (match_operand:GPR 2 "general_operand" "d"))]
9657 UNSPECV_ATOMIC_OP))
9658 (clobber (reg:CC CC_REGNUM))]
65b1d8ea 9659 "TARGET_Z196"
78ce265b
RH
9660 "la<noxa><g>\t%0,%2,%1"
9661 [(set_attr "op_type" "RSY")
9662 (set_attr "type" "sem")])
65b1d8ea 9663
78ce265b
RH
9664;; For SImode and larger, the optabs.c code will do just fine in
9665;; expanding a compare-and-swap loop. For QI/HImode, we can do
9666;; better by expanding our own loop.
65b1d8ea 9667
78ce265b
RH
9668(define_expand "atomic_<atomic><mode>"
9669 [(ATOMIC:HQI
9670 (match_operand:HQI 0 "memory_operand") ;; memory
9671 (match_operand:HQI 1 "general_operand")) ;; val in
9672 (match_operand:SI 2 "const_int_operand")] ;; model
45d18331 9673 ""
78ce265b
RH
9674{
9675 s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
9676 operands[1], false);
9677 DONE;
9678})
45d18331 9679
78ce265b
RH
9680(define_expand "atomic_fetch_<atomic><mode>"
9681 [(match_operand:HQI 0 "register_operand") ;; val out
9682 (ATOMIC:HQI
9683 (match_operand:HQI 1 "memory_operand") ;; memory
9684 (match_operand:HQI 2 "general_operand")) ;; val in
9685 (match_operand:SI 3 "const_int_operand")] ;; model
45d18331 9686 ""
78ce265b
RH
9687{
9688 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
9689 operands[2], false);
9690 DONE;
9691})
9692
9693(define_expand "atomic_<atomic>_fetch<mode>"
9694 [(match_operand:HQI 0 "register_operand") ;; val out
9695 (ATOMIC:HQI
9696 (match_operand:HQI 1 "memory_operand") ;; memory
9697 (match_operand:HQI 2 "general_operand")) ;; val in
9698 (match_operand:SI 3 "const_int_operand")] ;; model
9699 ""
9700{
9701 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
9702 operands[2], true);
9703 DONE;
9704})
9705
9706(define_expand "atomic_exchange<mode>"
9707 [(match_operand:HQI 0 "register_operand") ;; val out
9708 (match_operand:HQI 1 "memory_operand") ;; memory
9709 (match_operand:HQI 2 "general_operand") ;; val in
9710 (match_operand:SI 3 "const_int_operand")] ;; model
45d18331 9711 ""
78ce265b
RH
9712{
9713 s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
9714 operands[2], false);
9715 DONE;
9716})
45d18331 9717
9db1d521
HP
9718;;
9719;;- Miscellaneous instructions.
9720;;
9721
9722;
9723; allocate stack instruction pattern(s).
9724;
9725
9726(define_expand "allocate_stack"
ef44a6ff
UW
9727 [(match_operand 0 "general_operand" "")
9728 (match_operand 1 "general_operand" "")]
b3d31392 9729 "TARGET_BACKCHAIN"
9db1d521 9730{
ef44a6ff 9731 rtx temp = gen_reg_rtx (Pmode);
9db1d521 9732
ef44a6ff
UW
9733 emit_move_insn (temp, s390_back_chain_rtx ());
9734 anti_adjust_stack (operands[1]);
9735 emit_move_insn (s390_back_chain_rtx (), temp);
9db1d521 9736
ef44a6ff
UW
9737 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9738 DONE;
10bbf137 9739})
9db1d521
HP
9740
9741
9742;
43ab026f 9743; setjmp instruction pattern.
9db1d521
HP
9744;
9745
9db1d521 9746(define_expand "builtin_setjmp_receiver"
fd7643fb 9747 [(match_operand 0 "" "")]
f314b9b1 9748 "flag_pic"
9db1d521 9749{
585539a1 9750 emit_insn (s390_load_got ());
c41c1387 9751 emit_use (pic_offset_table_rtx);
9db1d521 9752 DONE;
fd7643fb 9753})
9db1d521 9754
9db1d521
HP
9755;; These patterns say how to save and restore the stack pointer. We need not
9756;; save the stack pointer at function level since we are careful to
9757;; preserve the backchain. At block level, we have to restore the backchain
9758;; when we restore the stack pointer.
9759;;
9760;; For nonlocal gotos, we must save both the stack pointer and its
9761;; backchain and restore both. Note that in the nonlocal case, the
9762;; save area is a memory location.
9763
9764(define_expand "save_stack_function"
9765 [(match_operand 0 "general_operand" "")
9766 (match_operand 1 "general_operand" "")]
9767 ""
9768 "DONE;")
9769
9770(define_expand "restore_stack_function"
9771 [(match_operand 0 "general_operand" "")
9772 (match_operand 1 "general_operand" "")]
9773 ""
9774 "DONE;")
9775
9776(define_expand "restore_stack_block"
ef44a6ff
UW
9777 [(match_operand 0 "register_operand" "")
9778 (match_operand 1 "register_operand" "")]
b3d31392 9779 "TARGET_BACKCHAIN"
9db1d521 9780{
ef44a6ff
UW
9781 rtx temp = gen_reg_rtx (Pmode);
9782
9783 emit_move_insn (temp, s390_back_chain_rtx ());
9784 emit_move_insn (operands[0], operands[1]);
9785 emit_move_insn (s390_back_chain_rtx (), temp);
9786
9787 DONE;
10bbf137 9788})
9db1d521
HP
9789
9790(define_expand "save_stack_nonlocal"
9791 [(match_operand 0 "memory_operand" "")
9792 (match_operand 1 "register_operand" "")]
9793 ""
9db1d521 9794{
ef44a6ff
UW
9795 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
9796
9797 /* Copy the backchain to the first word, sp to the second and the
9798 literal pool base to the third. */
9799
9602b6a1
AK
9800 rtx save_bc = adjust_address (operands[0], Pmode, 0);
9801 rtx save_sp = adjust_address (operands[0], Pmode, GET_MODE_SIZE (Pmode));
9802 rtx save_bp = adjust_address (operands[0], Pmode, 2 * GET_MODE_SIZE (Pmode));
9803
b3d31392 9804 if (TARGET_BACKCHAIN)
9602b6a1 9805 emit_move_insn (save_bc, force_reg (Pmode, s390_back_chain_rtx ()));
ef44a6ff 9806
9602b6a1
AK
9807 emit_move_insn (save_sp, operands[1]);
9808 emit_move_insn (save_bp, base);
9db1d521 9809
9db1d521 9810 DONE;
10bbf137 9811})
9db1d521
HP
9812
9813(define_expand "restore_stack_nonlocal"
9814 [(match_operand 0 "register_operand" "")
9815 (match_operand 1 "memory_operand" "")]
9816 ""
9db1d521 9817{
490ceeb4 9818 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
ef44a6ff 9819 rtx temp = NULL_RTX;
9db1d521 9820
43ab026f 9821 /* Restore the backchain from the first word, sp from the second and the
ff482c8d 9822 literal pool base from the third. */
43ab026f 9823
9602b6a1
AK
9824 rtx save_bc = adjust_address (operands[1], Pmode, 0);
9825 rtx save_sp = adjust_address (operands[1], Pmode, GET_MODE_SIZE (Pmode));
9826 rtx save_bp = adjust_address (operands[1], Pmode, 2 * GET_MODE_SIZE (Pmode));
9827
b3d31392 9828 if (TARGET_BACKCHAIN)
9602b6a1 9829 temp = force_reg (Pmode, save_bc);
9381e3f1 9830
9602b6a1
AK
9831 emit_move_insn (base, save_bp);
9832 emit_move_insn (operands[0], save_sp);
ef44a6ff
UW
9833
9834 if (temp)
9835 emit_move_insn (s390_back_chain_rtx (), temp);
9836
c41c1387 9837 emit_use (base);
9db1d521 9838 DONE;
10bbf137 9839})
9db1d521 9840
7bcebb25
AK
9841(define_expand "exception_receiver"
9842 [(const_int 0)]
9843 ""
9844{
9845 s390_set_has_landing_pad_p (true);
9846 DONE;
9847})
9db1d521
HP
9848
9849;
9850; nop instruction pattern(s).
9851;
9852
9853(define_insn "nop"
9854 [(const_int 0)]
9855 ""
d40c829f 9856 "lr\t0,0"
729e750f
WG
9857 [(set_attr "op_type" "RR")
9858 (set_attr "z10prop" "z10_fr_E1")])
9db1d521 9859
d277db6b
WG
9860(define_insn "nop1"
9861 [(const_int 1)]
9862 ""
9863 "lr\t1,1"
9864 [(set_attr "op_type" "RR")])
9865
f8af0e30
DV
9866;;- Undeletable nops (used for hotpatching)
9867
9868(define_insn "nop_2_byte"
9869 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_2_BYTE)]
9870 ""
9871 "nopr\t%%r7"
9872 [(set_attr "op_type" "RR")])
9873
9874(define_insn "nop_4_byte"
9875 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_4_BYTE)]
9876 ""
9877 "nop\t0"
9878 [(set_attr "op_type" "RX")])
9879
9880(define_insn "nop_6_byte"
9881 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_6_BYTE)]
9882 "TARGET_CPU_ZARCH"
9883 "brcl\t0, 0"
9884 [(set_attr "op_type" "RIL")])
9885
9db1d521
HP
9886
9887;
9888; Special literal pool access instruction pattern(s).
9889;
9890
416cf582
UW
9891(define_insn "*pool_entry"
9892 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
9893 UNSPECV_POOL_ENTRY)]
9db1d521 9894 ""
9db1d521 9895{
ef4bddc2 9896 machine_mode mode = GET_MODE (PATTERN (insn));
416cf582 9897 unsigned int align = GET_MODE_BITSIZE (mode);
faeb9bb6 9898 s390_output_pool_entry (operands[0], mode, align);
fd7643fb
UW
9899 return "";
9900}
b628bd8e 9901 [(set (attr "length")
416cf582 9902 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
b2ccb744 9903
9bb86f41
UW
9904(define_insn "pool_align"
9905 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
9906 UNSPECV_POOL_ALIGN)]
9907 ""
9908 ".align\t%0"
b628bd8e 9909 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
b2ccb744 9910
9bb86f41
UW
9911(define_insn "pool_section_start"
9912 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
9913 ""
9914 ".section\t.rodata"
b628bd8e 9915 [(set_attr "length" "0")])
b2ccb744 9916
9bb86f41
UW
9917(define_insn "pool_section_end"
9918 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
9919 ""
b2ccb744 9920 ".previous"
b628bd8e 9921 [(set_attr "length" "0")])
b2ccb744 9922
5af2f3d3 9923(define_insn "main_base_31_small"
9e8327e3
UW
9924 [(set (match_operand 0 "register_operand" "=a")
9925 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
9926 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
9927 "basr\t%0,0"
9928 [(set_attr "op_type" "RR")
65b1d8ea
AK
9929 (set_attr "type" "la")
9930 (set_attr "z196prop" "z196_cracked")])
5af2f3d3
UW
9931
9932(define_insn "main_base_31_large"
9e8327e3
UW
9933 [(set (match_operand 0 "register_operand" "=a")
9934 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
5af2f3d3 9935 (set (pc) (label_ref (match_operand 2 "" "")))]
9e8327e3 9936 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3 9937 "bras\t%0,%2"
65b1d8ea
AK
9938 [(set_attr "op_type" "RI")
9939 (set_attr "z196prop" "z196_cracked")])
5af2f3d3
UW
9940
9941(define_insn "main_base_64"
9e8327e3
UW
9942 [(set (match_operand 0 "register_operand" "=a")
9943 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
9944 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
5af2f3d3
UW
9945 "larl\t%0,%1"
9946 [(set_attr "op_type" "RIL")
9381e3f1 9947 (set_attr "type" "larl")
729e750f 9948 (set_attr "z10prop" "z10_fwd_A1")])
5af2f3d3
UW
9949
9950(define_insn "main_pool"
585539a1
UW
9951 [(set (match_operand 0 "register_operand" "=a")
9952 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
9953 "GET_MODE (operands[0]) == Pmode"
8d933e31
AS
9954{
9955 gcc_unreachable ();
9956}
9381e3f1 9957 [(set (attr "type")
d7f99b2c 9958 (if_then_else (match_test "TARGET_CPU_ZARCH")
ea77e738 9959 (const_string "larl") (const_string "la")))])
5af2f3d3 9960
aee4e0db 9961(define_insn "reload_base_31"
9e8327e3
UW
9962 [(set (match_operand 0 "register_operand" "=a")
9963 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
9964 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
d40c829f 9965 "basr\t%0,0\;la\t%0,%1-.(%0)"
b628bd8e 9966 [(set_attr "length" "6")
65b1d8ea
AK
9967 (set_attr "type" "la")
9968 (set_attr "z196prop" "z196_cracked")])
b2ccb744 9969
aee4e0db 9970(define_insn "reload_base_64"
9e8327e3
UW
9971 [(set (match_operand 0 "register_operand" "=a")
9972 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
9973 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
d40c829f 9974 "larl\t%0,%1"
aee4e0db 9975 [(set_attr "op_type" "RIL")
9381e3f1 9976 (set_attr "type" "larl")
729e750f 9977 (set_attr "z10prop" "z10_fwd_A1")])
aee4e0db 9978
aee4e0db 9979(define_insn "pool"
fd7643fb 9980 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
aee4e0db 9981 ""
8d933e31
AS
9982{
9983 gcc_unreachable ();
9984}
b628bd8e 9985 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
9db1d521 9986
4023fb28
UW
9987;;
9988;; Insns related to generating the function prologue and epilogue.
9989;;
9990
9991
9992(define_expand "prologue"
9993 [(use (const_int 0))]
9994 ""
10bbf137 9995 "s390_emit_prologue (); DONE;")
4023fb28
UW
9996
9997(define_expand "epilogue"
9998 [(use (const_int 1))]
9999 ""
ed9676cf
AK
10000 "s390_emit_epilogue (false); DONE;")
10001
10002(define_expand "sibcall_epilogue"
10003 [(use (const_int 0))]
10004 ""
10005 "s390_emit_epilogue (true); DONE;")
4023fb28 10006
177bc204
RS
10007;; A direct return instruction, without using an epilogue.
10008(define_insn "<code>"
10009 [(ANY_RETURN)]
10010 "s390_can_use_<code>_insn ()"
10011 "br\t%%r14"
10012 [(set_attr "op_type" "RR")
10013 (set_attr "type" "jsr")
10014 (set_attr "atype" "agen")])
10015
9e8327e3 10016(define_insn "*return"
4023fb28 10017 [(return)
9e8327e3
UW
10018 (use (match_operand 0 "register_operand" "a"))]
10019 "GET_MODE (operands[0]) == Pmode"
d40c829f 10020 "br\t%0"
4023fb28 10021 [(set_attr "op_type" "RR")
c7453384 10022 (set_attr "type" "jsr")
077dab3b 10023 (set_attr "atype" "agen")])
4023fb28 10024
4023fb28 10025
c7453384 10026;; Instruction definition to extend a 31-bit pointer into a 64-bit
839a4992 10027;; pointer. This is used for compatibility.
c7453384
EC
10028
10029(define_expand "ptr_extend"
10030 [(set (match_operand:DI 0 "register_operand" "=r")
10031 (match_operand:SI 1 "register_operand" "r"))]
9e8327e3 10032 "TARGET_64BIT"
c7453384 10033{
c7453384
EC
10034 emit_insn (gen_anddi3 (operands[0],
10035 gen_lowpart (DImode, operands[1]),
10036 GEN_INT (0x7fffffff)));
c7453384 10037 DONE;
10bbf137 10038})
4798630c
D
10039
10040;; Instruction definition to expand eh_return macro to support
10041;; swapping in special linkage return addresses.
10042
10043(define_expand "eh_return"
10044 [(use (match_operand 0 "register_operand" ""))]
10045 "TARGET_TPF"
10046{
10047 s390_emit_tpf_eh_return (operands[0]);
10048 DONE;
10049})
10050
7b8acc34
AK
10051;
10052; Stack Protector Patterns
10053;
10054
10055(define_expand "stack_protect_set"
10056 [(set (match_operand 0 "memory_operand" "")
10057 (match_operand 1 "memory_operand" ""))]
10058 ""
10059{
10060#ifdef TARGET_THREAD_SSP_OFFSET
10061 operands[1]
10062 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
10063 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
10064#endif
10065 if (TARGET_64BIT)
10066 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
10067 else
10068 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
10069
10070 DONE;
10071})
10072
10073(define_insn "stack_protect_set<mode>"
10074 [(set (match_operand:DSI 0 "memory_operand" "=Q")
10075 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
10076 ""
10077 "mvc\t%O0(%G0,%R0),%S1"
10078 [(set_attr "op_type" "SS")])
10079
10080(define_expand "stack_protect_test"
10081 [(set (reg:CC CC_REGNUM)
10082 (compare (match_operand 0 "memory_operand" "")
10083 (match_operand 1 "memory_operand" "")))
10084 (match_operand 2 "" "")]
10085 ""
10086{
f90b7a5a 10087 rtx cc_reg, test;
7b8acc34
AK
10088#ifdef TARGET_THREAD_SSP_OFFSET
10089 operands[1]
10090 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
10091 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
10092#endif
7b8acc34
AK
10093 if (TARGET_64BIT)
10094 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
10095 else
10096 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
10097
f90b7a5a
PB
10098 cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM);
10099 test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx);
10100 emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2]));
7b8acc34
AK
10101 DONE;
10102})
10103
10104(define_insn "stack_protect_test<mode>"
10105 [(set (reg:CCZ CC_REGNUM)
10106 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
10107 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
10108 ""
10109 "clc\t%O0(%G0,%R0),%S1"
10110 [(set_attr "op_type" "SS")])
12959abe
AK
10111
10112; This is used in s390_emit_prologue in order to prevent insns
10113; adjusting the stack pointer to be moved over insns writing stack
10114; slots using a copy of the stack pointer in a different register.
10115(define_insn "stack_tie"
10116 [(set (match_operand:BLK 0 "memory_operand" "+m")
10117 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
10118 ""
10119 ""
10120 [(set_attr "length" "0")])
963fc8d0
AK
10121
10122
10123;
10124; Data prefetch patterns
10125;
10126
10127(define_insn "prefetch"
22d72dbc
AK
10128 [(prefetch (match_operand 0 "address_operand" "ZQZRZSZT,X")
10129 (match_operand:SI 1 "const_int_operand" " n,n")
10130 (match_operand:SI 2 "const_int_operand" " n,n"))]
10131 "TARGET_Z10"
963fc8d0 10132{
4fe6dea8
AK
10133 switch (which_alternative)
10134 {
10135 case 0:
4fe6dea8 10136 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
22d72dbc 10137 case 1:
4fe6dea8
AK
10138 if (larl_operand (operands[0], Pmode))
10139 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
10140 default:
10141
10142 /* This might be reached for symbolic operands with an odd
10143 addend. We simply omit the prefetch for such rare cases. */
10144
10145 return "";
10146 }
9381e3f1 10147}
22d72dbc
AK
10148 [(set_attr "type" "load,larl")
10149 (set_attr "op_type" "RXY,RIL")
65b1d8ea
AK
10150 (set_attr "z10prop" "z10_super")
10151 (set_attr "z196prop" "z196_alone")])
07da44ab
AK
10152
10153
10154;
10155; Byte swap instructions
10156;
10157
10158(define_insn "bswap<mode>2"
10159 [(set (match_operand:GPR 0 "register_operand" "=d, d")
10160 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,RT")))]
677fbff4 10161 "TARGET_CPU_ZARCH"
07da44ab
AK
10162 "@
10163 lrv<g>r\t%0,%1
10164 lrv<g>\t%0,%1"
10165 [(set_attr "type" "*,load")
10166 (set_attr "op_type" "RRE,RXY")
10167 (set_attr "z10prop" "z10_super")])
65b1d8ea
AK
10168
10169
10170;
10171; Population count instruction
10172;
10173
10174; The S/390 popcount instruction counts the bits of op1 in 8 byte
10175; portions and stores the result in the corresponding bytes in op0.
10176(define_insn "*popcount<mode>"
10177 [(set (match_operand:INT 0 "register_operand" "=d")
10178 (unspec:INT [(match_operand:INT 1 "register_operand" "d")] UNSPEC_POPCNT))
10179 (clobber (reg:CC CC_REGNUM))]
10180 "TARGET_Z196"
10181 "popcnt\t%0,%1"
10182 [(set_attr "op_type" "RRE")])
10183
10184(define_expand "popcountdi2"
10185 [; popcnt op0, op1
10186 (parallel [(set (match_operand:DI 0 "register_operand" "")
10187 (unspec:DI [(match_operand:DI 1 "register_operand")]
10188 UNSPEC_POPCNT))
10189 (clobber (reg:CC CC_REGNUM))])
10190 ; sllg op2, op0, 32
10191 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 32)))
10192 ; agr op0, op2
10193 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10194 (clobber (reg:CC CC_REGNUM))])
10195 ; sllg op2, op0, 16
17465c6e 10196 (set (match_dup 2)
65b1d8ea
AK
10197 (ashift:DI (match_dup 0) (const_int 16)))
10198 ; agr op0, op2
10199 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10200 (clobber (reg:CC CC_REGNUM))])
10201 ; sllg op2, op0, 8
10202 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 8)))
10203 ; agr op0, op2
10204 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10205 (clobber (reg:CC CC_REGNUM))])
10206 ; srlg op0, op0, 56
10207 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (const_int 56)))]
10208 "TARGET_Z196 && TARGET_64BIT"
10209 "operands[2] = gen_reg_rtx (DImode);")
10210
10211(define_expand "popcountsi2"
10212 [; popcnt op0, op1
10213 (parallel [(set (match_operand:SI 0 "register_operand" "")
10214 (unspec:SI [(match_operand:SI 1 "register_operand")]
10215 UNSPEC_POPCNT))
10216 (clobber (reg:CC CC_REGNUM))])
10217 ; sllk op2, op0, 16
17465c6e 10218 (set (match_dup 2)
65b1d8ea
AK
10219 (ashift:SI (match_dup 0) (const_int 16)))
10220 ; ar op0, op2
10221 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10222 (clobber (reg:CC CC_REGNUM))])
10223 ; sllk op2, op0, 8
10224 (set (match_dup 2) (ashift:SI (match_dup 0) (const_int 8)))
10225 ; ar op0, op2
10226 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10227 (clobber (reg:CC CC_REGNUM))])
10228 ; srl op0, op0, 24
10229 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 24)))]
10230 "TARGET_Z196"
10231 "operands[2] = gen_reg_rtx (SImode);")
10232
10233(define_expand "popcounthi2"
10234 [; popcnt op0, op1
10235 (parallel [(set (match_operand:HI 0 "register_operand" "")
10236 (unspec:HI [(match_operand:HI 1 "register_operand")]
10237 UNSPEC_POPCNT))
10238 (clobber (reg:CC CC_REGNUM))])
10239 ; sllk op2, op0, 8
17465c6e 10240 (set (match_dup 2)
65b1d8ea
AK
10241 (ashift:SI (match_dup 0) (const_int 8)))
10242 ; ar op0, op2
10243 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10244 (clobber (reg:CC CC_REGNUM))])
10245 ; srl op0, op0, 8
10246 (set (match_dup 0) (lshiftrt:HI (match_dup 0) (const_int 8)))]
10247 "TARGET_Z196"
10248 "operands[2] = gen_reg_rtx (SImode);")
10249
10250(define_expand "popcountqi2"
10251 [; popcnt op0, op1
10252 (parallel [(set (match_operand:QI 0 "register_operand" "")
10253 (unspec:QI [(match_operand:QI 1 "register_operand")]
10254 UNSPEC_POPCNT))
10255 (clobber (reg:CC CC_REGNUM))])]
10256 "TARGET_Z196"
10257 "")
10258
10259;;
10260;;- Copy sign instructions
10261;;
10262
10263(define_insn "copysign<mode>3"
10264 [(set (match_operand:FP 0 "register_operand" "=f")
10265 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
10266 (match_operand:FP 2 "register_operand" "f")]
10267 UNSPEC_COPYSIGN))]
10268 "TARGET_Z196"
10269 "cpsdr\t%0,%2,%1"
10270 [(set_attr "op_type" "RRF")
10271 (set_attr "type" "fsimp<mode>")])
5a3fe9b6
AK
10272
10273
10274;;
10275;;- Transactional execution instructions
10276;;
10277
10278; This splitter helps combine to make use of CC directly when
10279; comparing the integer result of a tbegin builtin with a constant.
10280; The unspec is already removed by canonicalize_comparison. So this
10281; splitters only job is to turn the PARALLEL into separate insns
10282; again. Unfortunately this only works with the very first cc/int
10283; compare since combine is not able to deal with data flow across
10284; basic block boundaries.
10285
10286; It needs to be an insn pattern as well since combine does not apply
10287; the splitter directly. Combine would only use it if it actually
10288; would reduce the number of instructions.
10289(define_insn_and_split "*ccraw_to_int"
10290 [(set (pc)
10291 (if_then_else
10292 (match_operator 0 "s390_eqne_operator"
10293 [(reg:CCRAW CC_REGNUM)
10294 (match_operand 1 "const_int_operand" "")])
10295 (label_ref (match_operand 2 "" ""))
10296 (pc)))
10297 (set (match_operand:SI 3 "register_operand" "=d")
10298 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
10299 ""
10300 "#"
10301 ""
10302 [(set (match_dup 3)
10303 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))
10304 (set (pc)
10305 (if_then_else (match_op_dup 0 [(reg:CCRAW CC_REGNUM) (match_dup 1)])
10306 (label_ref (match_dup 2))
10307 (pc)))]
10308 "")
10309
10310; Non-constrained transaction begin
10311
10312(define_expand "tbegin"
ee163e72
AK
10313 [(match_operand:SI 0 "register_operand" "")
10314 (match_operand:BLK 1 "memory_operand" "")]
5a3fe9b6
AK
10315 "TARGET_HTM"
10316{
10317 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, true);
10318 DONE;
10319})
10320
10321(define_expand "tbegin_nofloat"
ee163e72
AK
10322 [(match_operand:SI 0 "register_operand" "")
10323 (match_operand:BLK 1 "memory_operand" "")]
5a3fe9b6
AK
10324 "TARGET_HTM"
10325{
10326 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, false);
10327 DONE;
10328})
10329
10330(define_expand "tbegin_retry"
ee163e72
AK
10331 [(match_operand:SI 0 "register_operand" "")
10332 (match_operand:BLK 1 "memory_operand" "")
10333 (match_operand:SI 2 "general_operand" "")]
5a3fe9b6
AK
10334 "TARGET_HTM"
10335{
10336 s390_expand_tbegin (operands[0], operands[1], operands[2], true);
10337 DONE;
10338})
10339
10340(define_expand "tbegin_retry_nofloat"
ee163e72
AK
10341 [(match_operand:SI 0 "register_operand" "")
10342 (match_operand:BLK 1 "memory_operand" "")
10343 (match_operand:SI 2 "general_operand" "")]
5a3fe9b6
AK
10344 "TARGET_HTM"
10345{
10346 s390_expand_tbegin (operands[0], operands[1], operands[2], false);
10347 DONE;
10348})
10349
10350(define_insn "tbegin_1"
10351 [(set (reg:CCRAW CC_REGNUM)
2561451d 10352 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
5a3fe9b6 10353 UNSPECV_TBEGIN))
2561451d
AK
10354 (set (match_operand:BLK 1 "memory_operand" "=Q")
10355 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
5a3fe9b6
AK
10356 (clobber (reg:DF 16))
10357 (clobber (reg:DF 17))
10358 (clobber (reg:DF 18))
10359 (clobber (reg:DF 19))
10360 (clobber (reg:DF 20))
10361 (clobber (reg:DF 21))
10362 (clobber (reg:DF 22))
10363 (clobber (reg:DF 23))
10364 (clobber (reg:DF 24))
10365 (clobber (reg:DF 25))
10366 (clobber (reg:DF 26))
10367 (clobber (reg:DF 27))
10368 (clobber (reg:DF 28))
10369 (clobber (reg:DF 29))
10370 (clobber (reg:DF 30))
10371 (clobber (reg:DF 31))]
10372; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
10373; not supposed to be used for immediates (see genpreds.c).
2561451d
AK
10374 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10375 "tbegin\t%1,%x0"
5a3fe9b6
AK
10376 [(set_attr "op_type" "SIL")])
10377
10378; Same as above but without the FPR clobbers
10379(define_insn "tbegin_nofloat_1"
10380 [(set (reg:CCRAW CC_REGNUM)
2561451d
AK
10381 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10382 UNSPECV_TBEGIN))
10383 (set (match_operand:BLK 1 "memory_operand" "=Q")
10384 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))]
10385 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10386 "tbegin\t%1,%x0"
5a3fe9b6
AK
10387 [(set_attr "op_type" "SIL")])
10388
10389
10390; Constrained transaction begin
10391
10392(define_expand "tbeginc"
10393 [(set (reg:CCRAW CC_REGNUM)
10394 (unspec_volatile:CCRAW [(const_int TBEGINC_MASK)]
10395 UNSPECV_TBEGINC))]
10396 "TARGET_HTM"
10397 "")
10398
10399(define_insn "*tbeginc_1"
10400 [(set (reg:CCRAW CC_REGNUM)
10401 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" " D")]
10402 UNSPECV_TBEGINC))]
10403 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10404 "tbeginc\t0,%x0"
10405 [(set_attr "op_type" "SIL")])
10406
10407; Transaction end
10408
10409(define_expand "tend"
10410 [(set (reg:CCRAW CC_REGNUM)
10411 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))
ee163e72 10412 (set (match_operand:SI 0 "register_operand" "")
5a3fe9b6
AK
10413 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
10414 "TARGET_HTM"
10415 "")
10416
10417(define_insn "*tend_1"
10418 [(set (reg:CCRAW CC_REGNUM)
10419 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))]
10420 "TARGET_HTM"
10421 "tend"
10422 [(set_attr "op_type" "S")])
10423
10424; Transaction abort
10425
10426(define_expand "tabort"
ee163e72 10427 [(unspec_volatile [(match_operand:SI 0 "shift_count_or_setmem_operand" "")]
5a3fe9b6
AK
10428 UNSPECV_TABORT)]
10429 "TARGET_HTM && operands != NULL"
10430{
10431 if (CONST_INT_P (operands[0])
10432 && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 255)
10433 {
10434 error ("Invalid transaction abort code: " HOST_WIDE_INT_PRINT_DEC
10435 ". Values in range 0 through 255 are reserved.",
10436 INTVAL (operands[0]));
10437 FAIL;
10438 }
10439})
10440
10441(define_insn "*tabort_1"
ee163e72 10442 [(unspec_volatile [(match_operand:SI 0 "shift_count_or_setmem_operand" "Y")]
5a3fe9b6
AK
10443 UNSPECV_TABORT)]
10444 "TARGET_HTM && operands != NULL"
10445 "tabort\t%Y0"
10446 [(set_attr "op_type" "S")])
10447
10448; Transaction extract nesting depth
10449
10450(define_insn "etnd"
10451 [(set (match_operand:SI 0 "register_operand" "=d")
10452 (unspec_volatile:SI [(const_int 0)] UNSPECV_ETND))]
10453 "TARGET_HTM"
10454 "etnd\t%0"
10455 [(set_attr "op_type" "RRE")])
10456
10457; Non-transactional store
10458
10459(define_insn "ntstg"
10460 [(set (match_operand:DI 0 "memory_operand" "=RT")
10461 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "d")]
10462 UNSPECV_NTSTG))]
10463 "TARGET_HTM"
10464 "ntstg\t%1,%0"
10465 [(set_attr "op_type" "RXY")])
10466
10467; Transaction perform processor assist
10468
10469(define_expand "tx_assist"
2561451d
AK
10470 [(unspec_volatile [(match_operand:SI 0 "register_operand" "")
10471 (reg:SI GPR0_REGNUM)
5a3fe9b6
AK
10472 (const_int 1)]
10473 UNSPECV_PPA)]
10474 "TARGET_HTM"
2561451d 10475 "")
5a3fe9b6
AK
10476
10477(define_insn "*ppa"
10478 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")
10479 (match_operand:SI 1 "register_operand" "d")
10480 (match_operand 2 "const_int_operand" "I")]
10481 UNSPECV_PPA)]
10482 "TARGET_HTM && INTVAL (operands[2]) < 16"
2561451d 10483 "ppa\t%0,%1,%2"
5a3fe9b6 10484 [(set_attr "op_type" "RRF")])
004f64e1
AK
10485
10486
10487; Set and get floating point control register
10488
10489(define_insn "s390_sfpc"
10490 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")]
10491 UNSPECV_SFPC)]
10492 "TARGET_HARD_FLOAT"
10493 "sfpc\t%0")
10494
10495(define_insn "s390_efpc"
10496 [(set (match_operand:SI 0 "register_operand" "=d")
10497 (unspec_volatile:SI [(const_int 0)] UNSPECV_EFPC))]
10498 "TARGET_HARD_FLOAT"
10499 "efpc\t%0")