Debian Codegraph @

gcc/config/s390/s390.md

raw
1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;; Copyright (C) 1999-2025 Free Software Foundation, Inc.
3 ;; Contributed by Hartmut Penner ([email protected]) and
4 ;; Ulrich Weigand ([email protected]) and
5 ;; Andreas Krebbel ([email protected])
6
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
11 ;; Software Foundation; either version 3, or (at your option) any later
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.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
22
23 ;;
24 ;; See constraints.md for a description of constraints specific to s390.
25 ;;
26
27 ;; Special formats used for outputting 390 instructions.
28 ;;
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
32 ;; %G: print the size of the operand in bytes.
33 ;; %O: print only the displacement of a memory reference.
34 ;; %R: print only the base register of a memory reference.
35 ;; %S: print S-type memory reference (base+displacement).
36 ;; %N: print the second word of a DImode operand.
37 ;; %M: print the second word of a TImode operand.
38 ;; %Y: print shift count operand.
39 ;;
40 ;; %b: print integer X as if it's an unsigned byte.
41 ;; %c: print integer X as if it's an signed byte.
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.
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 ;;
54
55 ;;
56 ;; UNSPEC usage
57 ;;
58
59 (define_c_enum "unspec" [
60 ; Miscellaneous
61 UNSPEC_ROUND
62 UNSPEC_ICM
63 UNSPEC_TIE
64 UNSPEC_MVCRL
65
66 ; Convert CC into a str comparison result and copy it into an
67 ; integer register
68 ; cc0->0, cc1->1, cc2->-1, (cc3->-1)
69 UNSPEC_STRCMPCC_TO_INT
70
71 ; Copy CC as is into the lower 2 bits of an integer register
72 UNSPEC_CC_TO_INT
73
74 ; The right hand side of an setmem
75 UNSPEC_REPLICATE_BYTE
76
77 ; GOT/PLT and lt-relative accesses
78 UNSPEC_LTREL_OFFSET
79 UNSPEC_POOL_OFFSET
80 UNSPEC_GOTENT
81 UNSPEC_GOT
82 UNSPEC_GOTOFF
83 UNSPEC_PLT31
84 UNSPEC_PLTOFF
85
86 ; Literal pool
87 UNSPEC_RELOAD_BASE
88 UNSPEC_MAIN_BASE
89 UNSPEC_LTREF
90 UNSPEC_INSN
91 UNSPEC_EXECUTE
92 UNSPEC_EXECUTE_JUMP
93
94 ; Atomic Support
95 UNSPEC_MB
96 UNSPEC_MOVA
97
98 ; TLS relocation specifiers
99 UNSPEC_TLSGD
100 UNSPEC_TLSLDM
101 UNSPEC_NTPOFF
102 UNSPEC_DTPOFF
103 UNSPEC_GOTNTPOFF
104 UNSPEC_INDNTPOFF
105
106 ; TLS support
107 UNSPEC_TLSLDM_NTPOFF
108 UNSPEC_TLS_LOAD
109 UNSPEC_GET_TP
110
111 ; String Functions
112 UNSPEC_SRST
113 UNSPEC_MVST
114
115 ; Stack Smashing Protector
116 UNSPEC_SP_SET
117 UNSPEC_SP_TEST
118
119 ; Split stack support
120 UNSPEC_STACK_CHECK
121
122 ; Test Data Class (TDC)
123 UNSPEC_TDC_INSN
124
125 ; Byte-wise Population Count
126 UNSPEC_POPCNT
127
128 UNSPEC_BDEPG
129 UNSPEC_BEXTG
130
131 ; Load FP Integer
132 UNSPEC_FPINT_FLOOR
133 UNSPEC_FPINT_BTRUNC
134 UNSPEC_FPINT_ROUND
135 UNSPEC_FPINT_CEIL
136 UNSPEC_FPINT_NEARBYINT
137 UNSPEC_FPINT_RINT
138
139 UNSPEC_LCBB
140
141 ; Vector
142 UNSPEC_VEC_SMULT_HI
143 UNSPEC_VEC_UMULT_HI
144 UNSPEC_VEC_SMULT_LO
145 UNSPEC_VEC_SMULT_EVEN
146 UNSPEC_VEC_UMULT_EVEN
147 UNSPEC_VEC_SMULT_ODD
148 UNSPEC_VEC_UMULT_ODD
149
150 UNSPEC_VEC_VMAL
151 UNSPEC_VEC_VMAH
152 UNSPEC_VEC_VMALH
153 UNSPEC_VEC_VMAE
154 UNSPEC_VEC_VMALE
155 UNSPEC_VEC_VMAO
156 UNSPEC_VEC_VMALO
157
158 UNSPEC_VEC_GATHER
159 UNSPEC_VEC_INSERT_AND_ZERO
160 UNSPEC_VEC_LOAD_BNDRY
161 UNSPEC_VEC_LOAD_LEN
162 UNSPEC_VEC_LOAD_LEN_R
163 UNSPEC_VEC_PACK
164 UNSPEC_VEC_PACK_SATURATE
165 UNSPEC_VEC_PACK_SATURATE_CC
166 UNSPEC_VEC_PACK_SATURATE_GENCC
167 UNSPEC_VEC_PACK_UNSIGNED_SATURATE
168 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_CC
169 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_GENCC
170 UNSPEC_VEC_PERM
171 UNSPEC_VEC_EXTEND
172 UNSPEC_VEC_STORE_LEN
173 UNSPEC_VEC_STORE_LEN_R
174 UNSPEC_VEC_VBPERM
175 UNSPEC_VEC_UNPACKH
176 UNSPEC_VEC_UNPACKH_L
177 UNSPEC_VEC_UNPACKL
178 UNSPEC_VEC_UNPACKL_L
179 UNSPEC_VEC_ADDC
180 UNSPEC_VEC_ADDE_U128
181 UNSPEC_VEC_ADDEC_U128
182 UNSPEC_VEC_AVG
183 UNSPEC_VEC_AVGU
184 UNSPEC_VEC_CHECKSUM
185 UNSPEC_VEC_GFMSUM
186 UNSPEC_VEC_GFMSUM_128
187 UNSPEC_VEC_GFMSUM_ACCUM
188 UNSPEC_VEC_GFMSUM_ACCUM_128
189 UNSPEC_VEC_SET
190
191 UNSPEC_VEC_VSUMG
192 UNSPEC_VEC_VSUMQ
193 UNSPEC_VEC_VSUM
194 UNSPEC_VEC_RL_MASK
195 UNSPEC_VEC_SLL
196 UNSPEC_VEC_SLB
197 UNSPEC_VEC_SLDBYTE
198 UNSPEC_VEC_SLDBIT
199 UNSPEC_VEC_SRDBIT
200 UNSPEC_VEC_SRAL
201 UNSPEC_VEC_SRAB
202 UNSPEC_VEC_SRL
203 UNSPEC_VEC_SRLB
204
205 UNSPEC_VEC_SUBC
206 UNSPEC_VEC_SUBE_U128
207 UNSPEC_VEC_SUBEC_U128
208
209 UNSPEC_VEC_TEST_MASK
210
211 UNSPEC_VEC_VFAE
212 UNSPEC_VEC_VFAECC
213
214 UNSPEC_VEC_VFEE
215 UNSPEC_VEC_VFEECC
216 UNSPEC_VEC_VFENE
217 UNSPEC_VEC_VFENECC
218
219 UNSPEC_VEC_VISTR
220 UNSPEC_VEC_VISTRCC
221
222 UNSPEC_VEC_VSTRC
223 UNSPEC_VEC_VSTRCCC
224
225 UNSPEC_VEC_VSTRS
226 UNSPEC_VEC_VSTRSCC
227
228 UNSPEC_VEC_VCDGB
229 UNSPEC_VEC_VCDLGB
230
231 UNSPEC_VEC_VCGDB
232 UNSPEC_VEC_VCLGDB
233
234 UNSPEC_VEC_VFI
235
236 UNSPEC_VEC_VFLL ; vector fp load lengthened
237 UNSPEC_VEC_VFLR ; vector fp load rounded
238
239 UNSPEC_VEC_VFTCI
240 UNSPEC_VEC_VFTCICC
241
242 UNSPEC_VEC_MSUM
243
244 UNSPEC_VEC_VFMIN
245 UNSPEC_VEC_VFMAX
246
247 UNSPEC_VEC_VBLEND
248 UNSPEC_VEC_VEVAL
249 UNSPEC_VEC_VGEM
250
251 UNSPEC_TF_TO_FPRX2
252
253 UNSPEC_NNPA_VCLFNHS_V8HI
254 UNSPEC_NNPA_VCLFNLS_V8HI
255 UNSPEC_NNPA_VCRNFS_V8HI
256
257 UNSPEC_NNPA_VCFN_V8HI
258 UNSPEC_NNPA_VCNF_V8HI
259 ])
260
261 ;;
262 ;; UNSPEC_VOLATILE usage
263 ;;
264
265 (define_c_enum "unspecv" [
266 ; Blockage
267 UNSPECV_BLOCKAGE
268
269 ; TPF Support
270 UNSPECV_TPF_PROLOGUE
271 UNSPECV_TPF_EPILOGUE
272
273 ; Literal pool
274 UNSPECV_POOL
275 UNSPECV_POOL_SECTION
276 UNSPECV_POOL_ALIGN
277 UNSPECV_POOL_ENTRY
278 UNSPECV_MAIN_POOL
279
280 ; TLS support
281 UNSPECV_SET_TP
282
283 ; Atomic Support
284 UNSPECV_CAS
285 UNSPECV_ATOMIC_OP
286
287 ; Non-branch nops used for compare-and-branch adjustments on z10
288 UNSPECV_NOP_LR_0
289 UNSPECV_NOP_LR_1
290
291 ; Hotpatching (unremovable NOPs)
292 UNSPECV_NOP_2_BYTE
293 UNSPECV_NOP_4_BYTE
294 UNSPECV_NOP_6_BYTE
295
296 ; Transactional Execution support
297 UNSPECV_TBEGIN
298 UNSPECV_TBEGIN_TDB
299 UNSPECV_TBEGINC
300 UNSPECV_TEND
301 UNSPECV_TABORT
302 UNSPECV_ETND
303 UNSPECV_NTSTG
304 UNSPECV_PPA
305
306 ; Set and get floating point control register
307 UNSPECV_SFPC
308 UNSPECV_EFPC
309
310 ; Split stack support
311 UNSPECV_SPLIT_STACK_CALL
312
313 UNSPECV_OSC_BREAK
314 ])
315
316 ;;
317 ;; Registers
318 ;;
319
320 ; Registers with special meaning
321
322 (define_constants
323 [
324 ; Sibling call register.
325 (SIBCALL_REGNUM 1)
326 ; A call-clobbered reg which can be used in indirect branch thunks
327 (INDIRECT_BRANCH_THUNK_REGNUM 1)
328 ; Literal pool base register.
329 (BASE_REGNUM 13)
330 ; Return address register.
331 (RETURN_REGNUM 14)
332 ; Stack pointer register.
333 (STACK_REGNUM 15)
334 ; Condition code register.
335 (CC_REGNUM 33)
336 ; Thread local storage pointer register.
337 (TP_REGNUM 36)
338 ])
339
340 ; Hardware register names
341
342 (define_constants
343 [
344 ; General purpose registers
345 (GPR0_REGNUM 0)
346 (GPR1_REGNUM 1)
347 (GPR2_REGNUM 2)
348 (GPR6_REGNUM 6)
349 ; Floating point registers.
350 (FPR0_REGNUM 16)
351 (FPR1_REGNUM 20)
352 (FPR2_REGNUM 17)
353 (FPR3_REGNUM 21)
354 (FPR4_REGNUM 18)
355 (FPR5_REGNUM 22)
356 (FPR6_REGNUM 19)
357 (FPR7_REGNUM 23)
358 (FPR8_REGNUM 24)
359 (FPR9_REGNUM 28)
360 (FPR10_REGNUM 25)
361 (FPR11_REGNUM 29)
362 (FPR12_REGNUM 26)
363 (FPR13_REGNUM 30)
364 (FPR14_REGNUM 27)
365 (FPR15_REGNUM 31)
366 (VR0_REGNUM 16)
367 (VR16_REGNUM 38)
368 (VR23_REGNUM 45)
369 (VR24_REGNUM 46)
370 (VR31_REGNUM 53)
371 ])
372
373 ; Rounding modes for binary floating point numbers
374 (define_constants
375 [(BFP_RND_CURRENT 0)
376 (BFP_RND_NEAREST_TIE_AWAY_FROM_0 1)
377 (BFP_RND_PREP_FOR_SHORT_PREC 3)
378 (BFP_RND_NEAREST_TIE_TO_EVEN 4)
379 (BFP_RND_TOWARD_0 5)
380 (BFP_RND_TOWARD_INF 6)
381 (BFP_RND_TOWARD_MINF 7)])
382
383 ; Rounding modes for decimal floating point numbers
384 ; 1-7 were introduced with the floating point extension facility
385 ; available with z196
386 ; With these rounding modes (1-7) a quantum exception might occur
387 ; which is suppressed for the other modes.
388 (define_constants
389 [(DFP_RND_CURRENT 0)
390 (DFP_RND_NEAREST_TIE_AWAY_FROM_0_QUANTEXC 1)
391 (DFP_RND_CURRENT_QUANTEXC 2)
392 (DFP_RND_PREP_FOR_SHORT_PREC_QUANTEXC 3)
393 (DFP_RND_NEAREST_TIE_TO_EVEN_QUANTEXC 4)
394 (DFP_RND_TOWARD_0_QUANTEXC 5)
395 (DFP_RND_TOWARD_INF_QUANTEXC 6)
396 (DFP_RND_TOWARD_MINF_QUANTEXC 7)
397 (DFP_RND_NEAREST_TIE_TO_EVEN 8)
398 (DFP_RND_TOWARD_0 9)
399 (DFP_RND_TOWARD_INF 10)
400 (DFP_RND_TOWARD_MINF 11)
401 (DFP_RND_NEAREST_TIE_AWAY_FROM_0 12)
402 (DFP_RND_NEAREST_TIE_TO_0 13)
403 (DFP_RND_AWAY_FROM_0 14)
404 (DFP_RND_PREP_FOR_SHORT_PREC 15)])
405
406 ;;
407 ;; PFPO GPR0 argument format
408 ;;
409
410 (define_constants
411 [
412 ; PFPO operation type
413 (PFPO_CONVERT 0x1000000)
414 ; PFPO operand types
415 (PFPO_OP_TYPE_SF 0x5)
416 (PFPO_OP_TYPE_DF 0x6)
417 (PFPO_OP_TYPE_TF 0x7)
418 (PFPO_OP_TYPE_FPRX2 0x7)
419 (PFPO_OP_TYPE_SD 0x8)
420 (PFPO_OP_TYPE_DD 0x9)
421 (PFPO_OP_TYPE_TD 0xa)
422 ; Bitposition of operand types
423 (PFPO_OP0_TYPE_SHIFT 16)
424 (PFPO_OP1_TYPE_SHIFT 8)
425 ; Decide whether current DFP or BFD rounding mode should be used
426 ; for the conversion.
427 (PFPO_RND_MODE_DFP 0)
428 (PFPO_RND_MODE_BFP 1)
429 ])
430
431 ;; PPA constants
432
433 ; Immediate values which can be used as the third operand to the
434 ; perform processor assist instruction
435
436 (define_constants
437 [(PPA_TX_ABORT 1)
438 (PPA_OOO_BARRIER 15)])
439
440 ; Immediate operands for tbegin and tbeginc
441 (define_constants [(TBEGIN_MASK 65292)]) ; 0xff0c
442 (define_constants [(TBEGINC_MASK 65288)]) ; 0xff08
443
444 ;; TEST DATA CLASS
445
446 ; Data class bitmap:
447 ;
448 ; positive zero 11
449 ; negative zero 10
450 ; positive normalized bfp number 9
451 ; negative normalized bfp number 8
452 ; positive denormalized bfp number 7
453 ; negative denormalized bfp number 6
454 ; positive infinity 5
455 ; negative infinity 4
456 ; positive quiet nan 3
457 ; negative quiet nan 2
458 ; positive signaling nan 1
459 ; negative signaling nan 0
460 ;
461 ; The following values are different for DFP:
462 ;
463 ; positive denormalized dfp number 9
464 ; negative denormalized dfp number 8
465 ; positive normalized dfp number 7
466 ; negative normalized dfp number 6
467
468 ; For signbit, the BFP-DFP-difference makes no difference.
469 ; S390_TDC_SIGNBIT_SET = negative_zero
470 ; | negative_normalized_bfp_number
471 ; | negative_denormalized_bfp_number
472 ; | negative_infinity
473 ; | negative_quiet_nan
474 ; | negative_signaling_nan
475 ; = 1365
476 ;
477 ; For finite, the BFP-DFP-difference makes no difference.
478 ; S390_TDC_FINITE = positive_zero
479 ; | negative_zero
480 ; | positive_normalized_bfp_number
481 ; | negative_normalized_bfp_number
482 ; | positive_denormalized_bfp_number
483 ; | negative_denormalized_bfp_number
484 ; = 4032
485 ;
486 ; S390_TDC_INFINITY = positive_infinity
487 ; | negative_infinity
488 ; = 48
489 ;
490 ; S390_TDC_NORMAL_BFP = positive_normalized_bfp_number
491 ; | negative_normalized_bfp_number
492 ; = 768
493 ;
494 ; S390_TDC_NORMAL_DFP = positive_normalized_dfp_number
495 ; | negative_normalized_dfp_number
496 ; = 192
497
498 (define_constants [(S390_TDC_SIGNBIT_SET 1365)
499 (S390_TDC_FINITE 4032)
500 (S390_TDC_INFINITY 48)
501 (S390_TDC_NORMAL_BFP 768)
502 (S390_TDC_NORMAL_DFP 192)])
503
504 (define_int_iterator TDC_CLASS [S390_TDC_SIGNBIT_SET
505 S390_TDC_FINITE
506 S390_TDC_INFINITY])
507
508 (define_int_iterator TDC_CLASS_BFP [S390_TDC_SIGNBIT_SET
509 S390_TDC_FINITE
510 S390_TDC_INFINITY
511 S390_TDC_NORMAL_BFP])
512
513 (define_int_attr tdc_insn [(S390_TDC_SIGNBIT_SET "signbit")
514 (S390_TDC_FINITE "isfinite")
515 (S390_TDC_INFINITY "isinf")
516 (S390_TDC_NORMAL_BFP "isnormal")
517 (S390_TDC_NORMAL_DFP "isnormal")])
518
519 ;; Instruction operand type as used in the Principles of Operation.
520 ;; Used to determine defaults for length and other attribute values.
521
522 (define_attr "op_type"
523 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,SIL,RRS,RIS,VRI,VRR,VRS,VRV,VRX,VSI"
524 (const_string "NN"))
525
526 ;; Instruction type attribute used for scheduling.
527
528 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
529 cs,vs,store,sem,idiv,
530 imulhi,imulsi,imuldi,
531 branch,jsr,fsimptf,fsimpdf,fsimpsf,fhex,
532 floadtf,floaddf,floadsf,fstoredf,fstoresf,
533 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
534 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
535 fmadddf,fmaddsf,
536 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
537 itoftf, itofdf, itofsf, itofdd, itoftd,
538 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
539 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
540 ftoidfp, other"
541 (cond [(eq_attr "op_type" "NN") (const_string "other")
542 (eq_attr "op_type" "SS") (const_string "cs")]
543 (const_string "integer")))
544
545 ;; Another attribute used for scheduling purposes:
546 ;; agen: Instruction uses the address generation unit
547 ;; reg: Instruction does not use the agen unit
548
549 (define_attr "atype" "agen,reg"
550 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF")
551 (const_string "reg")
552 (const_string "agen")))
553
554 ;; Properties concerning Z10 execution grouping and value forwarding.
555 ;; z10_super: instruction is superscalar.
556 ;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
557 ;; z10_fwd: The instruction reads the value of an operand and stores it into a
558 ;; target register. It can forward this value to a second instruction that reads
559 ;; the same register if that second instruction is issued in the same group.
560 ;; z10_rec: The instruction is in the T pipeline and reads a register. If the
561 ;; instruction in the S pipe writes to the register, then the T instruction
562 ;; can immediately read the new value.
563 ;; z10_fr: union of Z10_fwd and z10_rec.
564 ;; z10_c: second operand of instruction is a register and read with complemented bits.
565 ;;
566 ;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
567
568
569 (define_attr "z10prop" "none,
570 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
571 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
572 z10_rec,
573 z10_fr, z10_fr_A3, z10_fr_E1,
574 z10_c"
575 (const_string "none"))
576
577 ;; Properties concerning Z196 decoding
578 ;; z196_alone: must group alone
579 ;; z196_end: ends a group
580 ;; z196_cracked: instruction is cracked or expanded
581 (define_attr "z196prop" "none,
582 z196_alone, z196_ends,
583 z196_cracked"
584 (const_string "none"))
585
586 ; mnemonics which only get defined through if_then_else currently
587 ; don't get added to the list values automatically and hence need to
588 ; be listed here.
589 (define_attr "mnemonic" "b,bas,basr,bc,bcr_flush,unknown" (const_string "unknown"))
590
591 ;; Length in bytes.
592
593 (define_attr "length" ""
594 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
595 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF") (const_int 4)]
596 (const_int 6)))
597
598
599 ;; Processor type. This attribute must exactly match the processor_type
600 ;; enumeration in s390.h.
601
602 (define_attr "cpu" "z900,z990,z9_109,z9_ec,z10,z196,zEC12,z13,z14,z15,z16,z17"
603 (const (symbol_ref "s390_tune_attr")))
604
605 (define_attr "cpu_facility"
606 "standard,ieee,zarch,cpu_zarch,longdisp,extimm,dfp,z10,z196,zEC12,vx,z13,z14,vxe,z15,vxe2,z16,nnpa,vxe3,z17"
607 (const_string "standard"))
608
609 (define_attr "enabled" ""
610 (cond [(eq_attr "cpu_facility" "standard")
611 (const_int 1)
612
613 (and (eq_attr "cpu_facility" "ieee")
614 (match_test "TARGET_CPU_IEEE_FLOAT"))
615 (const_int 1)
616
617 (and (eq_attr "cpu_facility" "zarch")
618 (match_test "TARGET_ZARCH"))
619 (const_int 1)
620
621 (and (eq_attr "cpu_facility" "longdisp")
622 (match_test "TARGET_LONG_DISPLACEMENT"))
623 (const_int 1)
624
625 (and (eq_attr "cpu_facility" "extimm")
626 (match_test "TARGET_EXTIMM"))
627 (const_int 1)
628
629 (and (eq_attr "cpu_facility" "dfp")
630 (match_test "TARGET_DFP"))
631 (const_int 1)
632
633 (eq_attr "cpu_facility" "cpu_zarch")
634 (const_int 1)
635
636 (and (eq_attr "cpu_facility" "z10")
637 (match_test "TARGET_Z10"))
638 (const_int 1)
639
640 (and (eq_attr "cpu_facility" "z196")
641 (match_test "TARGET_Z196"))
642 (const_int 1)
643
644 (and (eq_attr "cpu_facility" "zEC12")
645 (match_test "TARGET_ZEC12"))
646 (const_int 1)
647
648 (and (eq_attr "cpu_facility" "vx")
649 (match_test "TARGET_VX"))
650 (const_int 1)
651
652 (and (eq_attr "cpu_facility" "z13")
653 (match_test "TARGET_Z13"))
654 (const_int 1)
655
656 (and (eq_attr "cpu_facility" "z14")
657 (match_test "TARGET_Z14"))
658 (const_int 1)
659
660 (and (eq_attr "cpu_facility" "vxe")
661 (match_test "TARGET_VXE"))
662 (const_int 1)
663
664 (and (eq_attr "cpu_facility" "z15")
665 (match_test "TARGET_Z15"))
666 (const_int 1)
667
668 (and (eq_attr "cpu_facility" "vxe2")
669 (match_test "TARGET_VXE2"))
670 (const_int 1)
671
672 (and (eq_attr "cpu_facility" "z16")
673 (match_test "TARGET_Z16"))
674 (const_int 1)
675
676 (and (eq_attr "cpu_facility" "nnpa")
677 (match_test "TARGET_NNPA"))
678 (const_int 1)
679
680 (and (eq_attr "cpu_facility" "vxe3")
681 (match_test "TARGET_VXE3"))
682 (const_int 1)
683
684 (and (eq_attr "cpu_facility" "z17")
685 (match_test "TARGET_Z17"))
686 (const_int 1)
687 ]
688 (const_int 0)))
689
690 ;; Whether an instruction supports relative long addressing.
691 ;; Currently this corresponds to RIL-b and RIL-c instruction formats,
692 ;; but having a separate attribute, as opposed to reusing op_type,
693 ;; provides additional flexibility.
694
695 (define_attr "relative_long" "no,yes" (const_string "no"))
696
697 (define_code_attr extend_insn [(sign_extend "extend") (zero_extend "zero_extend")])
698 (define_code_attr zero_extend [(sign_extend "") (zero_extend "l")])
699 (define_code_iterator any_extend [sign_extend zero_extend])
700
701 ;; Pipeline description for z900.
702 (include "2064.md")
703
704 ;; Pipeline description for z990, z9-109 and z9-ec.
705 (include "2084.md")
706
707 ;; Pipeline description for z10
708 (include "2097.md")
709
710 ;; Pipeline description for z196
711 (include "2817.md")
712
713 ;; Pipeline description for zEC12
714 (include "2827.md")
715
716 ;; Pipeline description for z13
717 (include "2964.md")
718
719 ;; Pipeline description for z14
720 (include "3906.md")
721
722 ;; Pipeline description for z15
723 (include "8561.md")
724
725 ;; Pipeline description for z16
726 (include "3931.md")
727
728 ;; Pipeline description for z17
729 (include "9175.md")
730
731 ;; Predicates
732 (include "predicates.md")
733
734 ;; Constraint definitions
735 (include "constraints.md")
736
737 ;; Other includes
738 (include "tpf.md")
739
740 ;; Iterators
741
742 (define_mode_iterator ALL [TI DI SI HI QI TF FPRX2 DF SF TD DD SD V1QI V2QI
743 V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI
744 V1DI V2DI V1SF V2SF V4SF V1TI V1DF V2DF V1TF])
745
746 ;; These mode iterators allow floating point patterns to be generated from the
747 ;; same template.
748 (define_mode_iterator FP_ALL [(TF "!TARGET_VXE") (FPRX2 "TARGET_VXE") DF SF
749 (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
750 (SD "TARGET_HARD_DFP")])
751 (define_mode_iterator FP [(TF "!TARGET_VXE") (FPRX2 "TARGET_VXE") DF SF
752 (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
753 ;; Like FP, but without a condition on TF. Useful for expanders that must be
754 ;; the same for FP and VR variants of TF.
755 (define_mode_iterator FP_ANYTF [TF (FPRX2 "TARGET_VXE") DF SF
756 (TD "TARGET_HARD_DFP")
757 (DD "TARGET_HARD_DFP")])
758 (define_mode_iterator BFP [(TF "!TARGET_VXE") (FPRX2 "TARGET_VXE") DF SF])
759 (define_mode_iterator DFP [TD DD])
760 (define_mode_iterator DFP_ALL [TD DD SD])
761 (define_mode_iterator DSF [DF SF])
762 (define_mode_iterator SD_SF [SF SD])
763 (define_mode_iterator DD_DF [DF DD])
764 (define_mode_iterator TD_TF [(TF "!TARGET_VXE") (FPRX2 "TARGET_VXE") TD])
765
766 ; 32 bit int<->fp conversion instructions are available since VXE2 (z15).
767 (define_mode_iterator VX_CONV_BFP [DF (SF "TARGET_VXE2")])
768
769 ;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
770 ;; from the same template.
771 (define_mode_iterator GPR [(DI "TARGET_ZARCH") SI])
772 (define_mode_iterator DGPR [(TI "TARGET_ZARCH") DI SI])
773 (define_mode_iterator DSI [DI SI])
774 (define_mode_iterator TDI [TI DI])
775
776 ;; These mode iterators allow :P to be used for patterns that operate on
777 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
778 (define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
779
780 ;; These macros refer to the actual word_mode of the configuration.
781 ;; This is equal to Pmode except on 31-bit machines in zarch mode.
782 (define_mode_iterator DW [(TI "TARGET_ZARCH") (DI "!TARGET_ZARCH")])
783 (define_mode_iterator W [(DI "TARGET_ZARCH") (SI "!TARGET_ZARCH")])
784
785 ;; Used by the umul pattern to express modes having half the size.
786 (define_mode_attr DWH [(TI "DI") (DI "SI")])
787 (define_mode_attr dwh [(TI "di") (DI "si")])
788
789 ;; This mode iterator allows the QI and HI patterns to be defined from
790 ;; the same template.
791 (define_mode_iterator HQI [HI QI])
792
793 ;; This mode iterator allows the integer patterns to be defined from the
794 ;; same template.
795 (define_mode_iterator INT [(DI "TARGET_ZARCH") SI HI QI])
796 (define_mode_iterator DINT [(TI "TARGET_ZARCH") DI SI HI QI])
797 (define_mode_iterator SINT [SI HI QI])
798
799 ;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
800 ;; the same template.
801 (define_code_iterator SHIFT [ashift lshiftrt])
802
803 ;; This iterator allows r[ox]sbg to be defined with the same template
804 (define_code_iterator IXOR [ior xor])
805
806 ;; This is used for merging the nand/nor and and/or with complement patterns
807 (define_code_iterator ANDOR [and ior])
808 (define_code_attr bitops_name [(and "and") (ior "or")])
809 (define_code_attr inv_bitops_name [(and "or") (ior "and")])
810 (define_code_attr inv_no [(and "o") (ior "n")])
811
812 ;; This iterator is used to expand the patterns for the nearest
813 ;; integer functions.
814 (define_int_iterator FPINT [UNSPEC_FPINT_FLOOR UNSPEC_FPINT_BTRUNC
815 UNSPEC_FPINT_ROUND UNSPEC_FPINT_CEIL
816 UNSPEC_FPINT_NEARBYINT])
817 (define_int_attr fpint_name [(UNSPEC_FPINT_FLOOR "floor")
818 (UNSPEC_FPINT_BTRUNC "btrunc")
819 (UNSPEC_FPINT_ROUND "round")
820 (UNSPEC_FPINT_CEIL "ceil")
821 (UNSPEC_FPINT_NEARBYINT "nearbyint")])
822 (define_int_attr fpint_roundingmode [(UNSPEC_FPINT_FLOOR "7")
823 (UNSPEC_FPINT_BTRUNC "5")
824 (UNSPEC_FPINT_ROUND "1")
825 (UNSPEC_FPINT_CEIL "6")
826 (UNSPEC_FPINT_NEARBYINT "0")])
827
828 ;; This iterator and attribute allow to combine most atomic operations.
829 (define_code_iterator ATOMIC [and ior xor plus minus mult])
830 (define_code_iterator ATOMIC_Z196 [and ior xor plus])
831 (define_code_attr atomic [(and "and") (ior "or") (xor "xor")
832 (plus "add") (minus "sub") (mult "nand")])
833 (define_code_attr noxa [(and "n") (ior "o") (xor "x") (plus "a")])
834
835 ;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
836 ;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
837 (define_mode_attr xde [(TF "x") (FPRX2 "x") (DF "d") (SF "e") (TD "x")
838 (DD "d") (SD "e") (V4SF "e") (V2DF "d")])
839
840 ;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
841 ;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
842 ;; SDmode.
843 (define_mode_attr xdee [(TF "x") (FPRX2 "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
844
845 ;; The decimal floating point variants of add, sub, div and mul support 3
846 ;; fp register operands. The following attributes allow to merge the bfp and
847 ;; dfp variants in a single insn definition.
848
849 ;; These mode attributes are supposed to be used in the `enabled' insn
850 ;; attribute to disable certain alternatives for certain modes.
851 (define_mode_attr nBFP [(TF "0") (FPRX2 "0") (DF "0") (SF "0") (TD "*")
852 (DD "*") (DD "*")])
853 (define_mode_attr nDFP [(TF "*") (FPRX2 "*") (DF "*") (SF "*") (TD "0")
854 (DD "0") (DD "0")])
855 (define_mode_attr DSF [(TF "0") (FPRX2 "0") (DF "*") (SF "*") (TD "0")
856 (DD "0") (SD "0")])
857 (define_mode_attr DFDI [(TF "0") (FPRX2 "0") (DF "*") (SF "0")
858 (TD "0") (DD "0") (DD "0")
859 (TI "0") (DI "*") (SI "0")])
860 (define_mode_attr SFSI [(TF "0") (FPRX2 "0") (DF "0") (SF "*")
861 (TD "0") (DD "0") (DD "0")
862 (TI "0") (DI "0") (SI "*")])
863 (define_mode_attr DF [(TF "0") (FPRX2 "0") (DF "*") (SF "0")
864 (TD "0") (DD "0") (DD "0")
865 (TI "0") (DI "0") (SI "0")])
866 (define_mode_attr SF [(TF "0") (FPRX2 "0") (DF "0") (SF "*")
867 (TD "0") (DD "0") (DD "0")
868 (TI "0") (DI "0") (SI "0")])
869
870 ;; This attribute is used in the operand constraint list
871 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
872 ;; TFmode values are represented by a fp register pair. Since the
873 ;; sign bit instructions only handle single source and target fp registers
874 ;; these instructions can only be used for TFmode values if the source and
875 ;; target operand uses the same fp register.
876 (define_mode_attr fT0 [(TF "0") (FPRX2 "0") (DF "f") (SF "f")])
877
878 ;; This attribute adds b for bfp instructions and t for dfp instructions and is used
879 ;; within instruction mnemonics.
880 (define_mode_attr bt [(TF "b") (FPRX2 "b") (DF "b") (SF "b") (TD "t") (DD "t")
881 (SD "t")])
882
883 ;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
884 ;; modes and to an empty string for bfp modes.
885 (define_mode_attr _d [(TF "") (FPRX2 "") (DF "") (SF "") (TD "d") (DD "d")
886 (SD "d")])
887
888 ;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
889 ;; and "0" in SImode. This allows to combine instructions of which the 31bit
890 ;; version only operates on one register.
891 (define_mode_attr d0 [(DI "d") (SI "0")])
892
893 ;; In combination with d0 this allows to combine instructions of which the 31bit
894 ;; version only operates on one register. The DImode version needs an additional
895 ;; register for the assembler output.
896 (define_mode_attr 1 [(DI "%1,") (SI "")])
897
898 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
899 ;; 'ashift' and "srdl" in 'lshiftrt'.
900 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
901
902 ;; In SHIFT templates, this attribute holds the correct standard name for the
903 ;; pattern itself and the corresponding function calls.
904 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
905
906 ;; This attribute handles differences in the instruction 'type' and will result
907 ;; in "RRE" for DImode and "RR" for SImode.
908 (define_mode_attr E [(DI "E") (SI "")])
909
910 ;; This attribute handles differences in the instruction 'type' and makes RX<Y>
911 ;; to result in "RXY" for DImode and "RX" for SImode.
912 (define_mode_attr Y [(DI "Y") (SI "")])
913
914 ;; This attribute handles differences in the instruction 'type' and will result
915 ;; in "RSE" for TImode and "RS" for DImode.
916 (define_mode_attr TE [(TI "E") (DI "")])
917
918 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
919 ;; and "lcr" in SImode.
920 (define_mode_attr g [(DI "g") (SI "")])
921
922 ;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
923 ;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
924 ;; were enhanced with long displacements whereas 31bit instructions got a ..y
925 ;; variant for long displacements.
926 (define_mode_attr y [(DI "g") (SI "y")])
927
928 ;; In DW templates, a string like "cds<g>" will expand to "cdsg" in TImode
929 ;; and "cds" in DImode.
930 (define_mode_attr tg [(TI "g") (DI "")])
931
932 ;; In TDI templates, a string like "c<d>sg".
933 (define_mode_attr td [(TI "d") (DI "")])
934
935 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
936 ;; and "cfdbr" in SImode.
937 (define_mode_attr gf [(DI "g") (SI "f") (DF "g") (SF "f")])
938
939 ;; In GPR templates, a string like sll<gk> will expand to sllg for DI
940 ;; and sllk for SI. This way it is possible to merge the new z196 SI
941 ;; 3 operands shift instructions into the existing patterns.
942 (define_mode_attr gk [(DI "g") (SI "k")])
943
944 ;; ICM mask required to load MODE value into the lowest subreg
945 ;; of a SImode register.
946 (define_mode_attr icm_lo [(HI "3") (QI "1")])
947
948 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
949 ;; HImode and "llgc" in QImode.
950 (define_mode_attr hc [(HI "h") (QI "c")])
951
952 ;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
953 ;; in SImode.
954 (define_mode_attr DBL [(DI "TI") (SI "DI")])
955
956 ;; This attribute expands to DF for TFmode and to DD for TDmode . It is
957 ;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
958 (define_mode_attr HALF_TMODE [(TF "DF") (FPRX2 "DF") (TD "DD")])
959
960 ;; Maximum unsigned integer that fits in MODE.
961 (define_mode_attr max_uint [(HI "65535") (QI "255")])
962
963 ;; Start and end field computations for RISBG et al.
964 (define_mode_attr bfstart [(DI "s") (SI "t")])
965 (define_mode_attr bfend [(DI "e") (SI "f")])
966
967 ;; In place of GET_MODE_BITSIZE (<MODE>mode)
968 (define_mode_attr bitsize [(DI "64") (SI "32") (HI "16") (QI "8")])
969 ;; 64 - bitsize
970 (define_mode_attr bitoff [(DI "0") (SI "32") (HI "48") (QI "56")])
971 (define_mode_attr bitoff_plus [(DI "") (SI "32+") (HI "48+") (QI "56+")])
972
973 ;; In place of GET_MODE_SIZE (<MODE>mode)
974 (define_mode_attr modesize [(DI "8") (SI "4")])
975
976 ;; Allow return and simple_return to be defined from a single template.
977 (define_code_iterator ANY_RETURN [return simple_return])
978
979 ;; Facilitate dispatching TFmode expanders on z14+.
980 (define_mode_attr tf_fpr [(TF "_fpr") (FPRX2 "") (DF "") (SF "") (TD "")
981 (DD "") (SD "")])
982
983 ;; Mode names as seen in type mode_attr values.
984 (define_mode_attr type [(TF "tf") (FPRX2 "tf") (DF "df") (SF "sf") (TD "td")
985 (DD "dd") (SD "sd")])
986
987
988 ; Condition code modes generated by vector fp comparisons. These will
989 ; be used also in single element mode.
990 (define_mode_iterator VFCMP [CCVEQ CCVFH CCVFHE])
991 ; Used with VFCMP to expand part of the mnemonic
992 ; For fp we have a mismatch: eq in the insn name - e in asm
993 (define_mode_attr asm_fcmp [(CCVEQ "e") (CCVFH "h") (CCVFHE "he")])
994 (define_mode_attr insn_cmp [(CCVEQ "eq") (CCVIH "h") (CCVIHU "hl") (CCVFH "h") (CCVFHE "he")])
995
996 ; Analogue to TOINTVEC / tointvec
997 (define_mode_attr TOINT [(TF "TI") (DF "DI") (SF "SI")])
998 (define_mode_attr toint [(TF "ti") (DF "di") (SF "si")])
999
1000 ;; Subst pattern definitions
1001 (include "subst.md")
1002
1003 (include "vector.md")
1004
1005 ;;
1006 ;;- Compare instructions.
1007 ;;
1008
1009 ; Test-under-Mask instructions
1010
1011 (define_insn "*tmqi_mem"
1012 [(set (reg CC_REGNUM)
1013 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
1014 (match_operand:QI 1 "immediate_operand" "n,n"))
1015 (match_operand:QI 2 "immediate_operand" "n,n")))]
1016 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
1017 "@
1018 tm\t%S0,%b1
1019 tmy\t%S0,%b1"
1020 [(set_attr "op_type" "SI,SIY")
1021 (set_attr "cpu_facility" "*,longdisp")
1022 (set_attr "z10prop" "z10_super,z10_super")])
1023
1024 (define_insn "*tmdi_reg"
1025 [(set (reg CC_REGNUM)
1026 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
1027 (match_operand:DI 1 "immediate_operand"
1028 "N0HD0,N1HD0,N2HD0,N3HD0"))
1029 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
1030 "TARGET_ZARCH
1031 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
1032 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
1033 "@
1034 tmhh\t%0,%i1
1035 tmhl\t%0,%i1
1036 tmlh\t%0,%i1
1037 tmll\t%0,%i1"
1038 [(set_attr "op_type" "RI")
1039 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
1040
1041 (define_insn "*tmsi_reg"
1042 [(set (reg CC_REGNUM)
1043 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
1044 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
1045 (match_operand:SI 2 "immediate_operand" "n,n")))]
1046 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
1047 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
1048 "@
1049 tmh\t%0,%i1
1050 tml\t%0,%i1"
1051 [(set_attr "op_type" "RI")
1052 (set_attr "z10prop" "z10_super,z10_super")])
1053
1054 (define_insn "*tm<mode>_full"
1055 [(set (reg CC_REGNUM)
1056 (compare (match_operand:HQI 0 "register_operand" "d")
1057 (match_operand:HQI 1 "immediate_operand" "n")))]
1058 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
1059 "tml\t%0,<max_uint>"
1060 [(set_attr "op_type" "RI")
1061 (set_attr "z10prop" "z10_super")])
1062
1063
1064 ;
1065 ; Load-and-Test instructions
1066 ;
1067
1068 ; tst(di|si) instruction pattern(s).
1069
1070 (define_insn "*tstdi_sign"
1071 [(set (reg CC_REGNUM)
1072 (compare
1073 (ashiftrt:DI
1074 (ashift:DI
1075 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,T") 0)
1076 (const_int 32)) (const_int 32))
1077 (match_operand:DI 1 "const0_operand" "")))
1078 (set (match_operand:DI 2 "register_operand" "=d,d")
1079 (sign_extend:DI (match_dup 0)))]
1080 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH"
1081 "ltgfr\t%2,%0
1082 ltgf\t%2,%0"
1083 [(set_attr "op_type" "RRE,RXY")
1084 (set_attr "cpu_facility" "*,z10")
1085 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
1086
1087 ; ltr, lt, ltgr, ltg
1088 (define_insn "*tst<mode>_extimm"
1089 [(set (reg CC_REGNUM)
1090 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,T")
1091 (match_operand:GPR 1 "const0_operand" "")))
1092 (set (match_operand:GPR 2 "register_operand" "=d,d")
1093 (match_dup 0))]
1094 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
1095 "@
1096 lt<g>r\t%2,%0
1097 lt<g>\t%2,%0"
1098 [(set_attr "op_type" "RR<E>,RXY")
1099 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
1100
1101 ; Peephole to combine a load-and-test from volatile memory which combine does
1102 ; not do.
1103 (define_peephole2
1104 [(set (match_operand:GPR 0 "register_operand")
1105 (match_operand:GPR 2 "memory_operand"))
1106 (set (reg CC_REGNUM)
1107 (compare (match_dup 0) (match_operand:GPR 1 "const0_operand")))]
1108 "s390_match_ccmode (peep2_next_insn (1), CCSmode) && TARGET_EXTIMM
1109 && GENERAL_REG_P (operands[0])
1110 && satisfies_constraint_T (operands[2])
1111 && !contains_constant_pool_address_p (operands[2])"
1112 [(parallel
1113 [(set (reg:CCS CC_REGNUM)
1114 (compare:CCS (match_dup 2) (match_dup 1)))
1115 (set (match_dup 0) (match_dup 2))])])
1116
1117 ; ltr, lt, ltgr, ltg
1118 (define_insn "*tst<mode>_cconly_extimm"
1119 [(set (reg CC_REGNUM)
1120 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,T")
1121 (match_operand:GPR 1 "const0_operand" "")))
1122 (clobber (match_scratch:GPR 2 "=X,d"))]
1123 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
1124 "@
1125 lt<g>r\t%0,%0
1126 lt<g>\t%2,%0"
1127 [(set_attr "op_type" "RR<E>,RXY")
1128 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
1129
1130 (define_insn "*tstdi"
1131 [(set (reg CC_REGNUM)
1132 (compare (match_operand:DI 0 "register_operand" "d")
1133 (match_operand:DI 1 "const0_operand" "")))
1134 (set (match_operand:DI 2 "register_operand" "=d")
1135 (match_dup 0))]
1136 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH && !TARGET_EXTIMM"
1137 "ltgr\t%2,%0"
1138 [(set_attr "op_type" "RRE")
1139 (set_attr "z10prop" "z10_fr_E1")])
1140
1141 (define_insn "*tstsi"
1142 [(set (reg CC_REGNUM)
1143 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
1144 (match_operand:SI 1 "const0_operand" "")))
1145 (set (match_operand:SI 2 "register_operand" "=d,d,d")
1146 (match_dup 0))]
1147 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
1148 "@
1149 ltr\t%2,%0
1150 icm\t%2,15,%S0
1151 icmy\t%2,15,%S0"
1152 [(set_attr "op_type" "RR,RS,RSY")
1153 (set_attr "cpu_facility" "*,*,longdisp")
1154 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
1155
1156 (define_insn "*tstsi_cconly"
1157 [(set (reg CC_REGNUM)
1158 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
1159 (match_operand:SI 1 "const0_operand" "")))
1160 (clobber (match_scratch:SI 2 "=X,d,d"))]
1161 "s390_match_ccmode(insn, CCSmode)"
1162 "@
1163 ltr\t%0,%0
1164 icm\t%2,15,%S0
1165 icmy\t%2,15,%S0"
1166 [(set_attr "op_type" "RR,RS,RSY")
1167 (set_attr "cpu_facility" "*,*,longdisp")
1168 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
1169
1170 (define_insn "*tstdi_cconly_31"
1171 [(set (reg CC_REGNUM)
1172 (compare (match_operand:DI 0 "register_operand" "d")
1173 (match_operand:DI 1 "const0_operand" "")))]
1174 "s390_match_ccmode(insn, CCSmode) && !TARGET_ZARCH"
1175 "srda\t%0,0"
1176 [(set_attr "op_type" "RS")
1177 (set_attr "atype" "reg")])
1178
1179 ; ltr, ltgr
1180 (define_insn "*tst<mode>_cconly2"
1181 [(set (reg CC_REGNUM)
1182 (compare (match_operand:GPR 0 "register_operand" "d")
1183 (match_operand:GPR 1 "const0_operand" "")))]
1184 "s390_match_ccmode(insn, CCSmode)"
1185 "lt<g>r\t%0,%0"
1186 [(set_attr "op_type" "RR<E>")
1187 (set_attr "z10prop" "z10_fr_E1")])
1188
1189 ; tst(hi|qi) instruction pattern(s).
1190
1191 (define_insn "*tst<mode>CCT"
1192 [(set (reg CC_REGNUM)
1193 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
1194 (match_operand:HQI 1 "const0_operand" "")))
1195 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
1196 (match_dup 0))]
1197 "s390_match_ccmode(insn, CCTmode)"
1198 "@
1199 icm\t%2,<icm_lo>,%S0
1200 icmy\t%2,<icm_lo>,%S0
1201 tml\t%0,<max_uint>"
1202 [(set_attr "op_type" "RS,RSY,RI")
1203 (set_attr "cpu_facility" "*,longdisp,*")
1204 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
1205
1206 (define_insn "*tsthiCCT_cconly"
1207 [(set (reg CC_REGNUM)
1208 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
1209 (match_operand:HI 1 "const0_operand" "")))
1210 (clobber (match_scratch:HI 2 "=d,d,X"))]
1211 "s390_match_ccmode(insn, CCTmode)"
1212 "@
1213 icm\t%2,3,%S0
1214 icmy\t%2,3,%S0
1215 tml\t%0,65535"
1216 [(set_attr "op_type" "RS,RSY,RI")
1217 (set_attr "cpu_facility" "*,longdisp,*")
1218 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
1219
1220 (define_insn "*tstqiCCT_cconly"
1221 [(set (reg CC_REGNUM)
1222 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
1223 (match_operand:QI 1 "const0_operand" "")))]
1224 "s390_match_ccmode(insn, CCTmode)"
1225 "@
1226 cli\t%S0,0
1227 cliy\t%S0,0
1228 tml\t%0,255"
1229 [(set_attr "op_type" "SI,SIY,RI")
1230 (set_attr "cpu_facility" "*,longdisp,*")
1231 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
1232
1233 (define_insn "*tst<mode>"
1234 [(set (reg CC_REGNUM)
1235 (compare (match_operand:HQI 0 "s_operand" "Q,S")
1236 (match_operand:HQI 1 "const0_operand" "")))
1237 (set (match_operand:HQI 2 "register_operand" "=d,d")
1238 (match_dup 0))]
1239 "s390_match_ccmode(insn, CCSmode)"
1240 "@
1241 icm\t%2,<icm_lo>,%S0
1242 icmy\t%2,<icm_lo>,%S0"
1243 [(set_attr "op_type" "RS,RSY")
1244 (set_attr "cpu_facility" "*,longdisp")
1245 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1246
1247 (define_insn "*tst<mode>_cconly"
1248 [(set (reg CC_REGNUM)
1249 (compare (match_operand:HQI 0 "s_operand" "Q,S")
1250 (match_operand:HQI 1 "const0_operand" "")))
1251 (clobber (match_scratch:HQI 2 "=d,d"))]
1252 "s390_match_ccmode(insn, CCSmode)"
1253 "@
1254 icm\t%2,<icm_lo>,%S0
1255 icmy\t%2,<icm_lo>,%S0"
1256 [(set_attr "op_type" "RS,RSY")
1257 (set_attr "cpu_facility" "*,longdisp")
1258 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1259
1260
1261 ; Compare (equality) instructions
1262
1263 (define_insn "*cmpdi_cct"
1264 [(set (reg CC_REGNUM)
1265 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
1266 (match_operand:DI 1 "general_operand" "d,K,Os,T,BQ")))]
1267 "s390_match_ccmode (insn, CCTmode) && TARGET_ZARCH"
1268 "@
1269 cgr\t%0,%1
1270 cghi\t%0,%h1
1271 cgfi\t%0,%1
1272 cg\t%0,%1
1273 #"
1274 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
1275 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
1276
1277 (define_insn "*cmpsi_cct"
1278 [(set (reg CC_REGNUM)
1279 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
1280 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
1281 "s390_match_ccmode (insn, CCTmode)"
1282 "@
1283 cr\t%0,%1
1284 chi\t%0,%h1
1285 cfi\t%0,%1
1286 c\t%0,%1
1287 cy\t%0,%1
1288 #"
1289 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
1290 (set_attr "cpu_facility" "*,*,*,*,longdisp,*")
1291 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*")])
1292
1293 ; Compare (signed) instructions
1294
1295 (define_insn "*cmpdi_ccs_sign"
1296 [(set (reg CC_REGNUM)
1297 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
1298 "d,T,b"))
1299 (match_operand:DI 0 "register_operand" "d, d,d")))]
1300 "s390_match_ccmode(insn, CCSRmode) && TARGET_ZARCH"
1301 "@
1302 cgfr\t%0,%1
1303 cgf\t%0,%1
1304 cgfrl\t%0,%1"
1305 [(set_attr "op_type" "RRE,RXY,RIL")
1306 (set_attr "z10prop" "z10_c,*,*")
1307 (set_attr "type" "*,*,larl")
1308 (set_attr "relative_long" "*,*,yes")])
1309
1310
1311
1312 (define_insn "*cmpsi_ccs_sign"
1313 [(set (reg CC_REGNUM)
1314 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
1315 (match_operand:SI 0 "register_operand" "d,d,d")))]
1316 "s390_match_ccmode(insn, CCSRmode)"
1317 "@
1318 ch\t%0,%1
1319 chy\t%0,%1
1320 chrl\t%0,%1"
1321 [(set_attr "op_type" "RX,RXY,RIL")
1322 (set_attr "cpu_facility" "*,longdisp,z10")
1323 (set_attr "type" "*,*,larl")
1324 (set_attr "z196prop" "z196_cracked,z196_cracked,z196_cracked")
1325 (set_attr "relative_long" "*,*,yes")])
1326
1327 (define_insn "*cmphi_ccs_z10"
1328 [(set (reg CC_REGNUM)
1329 (compare (match_operand:HI 0 "s_operand" "Q")
1330 (match_operand:HI 1 "immediate_operand" "K")))]
1331 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
1332 "chhsi\t%0,%1"
1333 [(set_attr "op_type" "SIL")
1334 (set_attr "z196prop" "z196_cracked")])
1335
1336 (define_insn "*cmpdi_ccs_signhi_rl"
1337 [(set (reg CC_REGNUM)
1338 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "T,b"))
1339 (match_operand:GPR 0 "register_operand" "d,d")))]
1340 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
1341 "@
1342 cgh\t%0,%1
1343 cghrl\t%0,%1"
1344 [(set_attr "op_type" "RXY,RIL")
1345 (set_attr "type" "*,larl")
1346 (set_attr "relative_long" "*,yes")])
1347
1348 ; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
1349 (define_insn "*cmp<mode>_ccs"
1350 [(set (reg CC_REGNUM)
1351 (compare (match_operand:GPR 0 "nonimmediate_operand"
1352 "d,d,Q, d,d,d,d")
1353 (match_operand:GPR 1 "general_operand"
1354 "d,K,K,Os,R,T,b")))]
1355 "s390_match_ccmode(insn, CCSmode)"
1356 "@
1357 c<g>r\t%0,%1
1358 c<g>hi\t%0,%h1
1359 c<g>hsi\t%0,%h1
1360 c<g>fi\t%0,%1
1361 c<g>\t%0,%1
1362 c<y>\t%0,%1
1363 c<g>rl\t%0,%1"
1364 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
1365 (set_attr "cpu_facility" "*,*,z10,extimm,*,longdisp,z10")
1366 (set_attr "type" "*,*,*,*,*,*,larl")
1367 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")
1368 (set_attr "relative_long" "*,*,*,*,*,*,yes")])
1369
1370
1371 ; Compare (unsigned) instructions
1372
1373 (define_insn "*cmpsi_ccu_zerohi_rlsi"
1374 [(set (reg CC_REGNUM)
1375 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
1376 "larl_operand" "X")))
1377 (match_operand:SI 0 "register_operand" "d")))]
1378 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
1379 "clhrl\t%0,%1"
1380 [(set_attr "op_type" "RIL")
1381 (set_attr "type" "larl")
1382 (set_attr "z10prop" "z10_super")
1383 (set_attr "relative_long" "yes")])
1384
1385 ; clhrl, clghrl
1386 (define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
1387 [(set (reg CC_REGNUM)
1388 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
1389 "larl_operand" "X")))
1390 (match_operand:GPR 0 "register_operand" "d")))]
1391 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
1392 "cl<g>hrl\t%0,%1"
1393 [(set_attr "op_type" "RIL")
1394 (set_attr "type" "larl")
1395 (set_attr "z10prop" "z10_super")
1396 (set_attr "relative_long" "yes")])
1397
1398 (define_insn "*cmpdi_ccu_zero"
1399 [(set (reg CC_REGNUM)
1400 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
1401 "d,T,b"))
1402 (match_operand:DI 0 "register_operand" "d,d,d")))]
1403 "s390_match_ccmode (insn, CCURmode) && TARGET_ZARCH"
1404 "@
1405 clgfr\t%0,%1
1406 clgf\t%0,%1
1407 clgfrl\t%0,%1"
1408 [(set_attr "op_type" "RRE,RXY,RIL")
1409 (set_attr "cpu_facility" "*,*,z10")
1410 (set_attr "type" "*,*,larl")
1411 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")
1412 (set_attr "relative_long" "*,*,yes")])
1413
1414 (define_insn "*cmpdi_ccu"
1415 [(set (reg CC_REGNUM)
1416 (compare (match_operand:DI 0 "nonimmediate_operand"
1417 "d, d,d,Q,d, Q,BQ")
1418 (match_operand:DI 1 "general_operand"
1419 "d,Op,b,D,T,BQ,Q")))]
1420 "s390_match_ccmode (insn, CCUmode) && TARGET_ZARCH"
1421 "@
1422 clgr\t%0,%1
1423 clgfi\t%0,%1
1424 clgrl\t%0,%1
1425 clghsi\t%0,%x1
1426 clg\t%0,%1
1427 #
1428 #"
1429 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
1430 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
1431 (set_attr "type" "*,*,larl,*,*,*,*")
1432 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")
1433 (set_attr "relative_long" "*,*,yes,*,*,*,*")])
1434
1435 (define_insn "*cmpsi_ccu"
1436 [(set (reg CC_REGNUM)
1437 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
1438 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
1439 "s390_match_ccmode (insn, CCUmode)"
1440 "@
1441 clr\t%0,%1
1442 clfi\t%0,%o1
1443 clrl\t%0,%1
1444 clfhsi\t%0,%x1
1445 cl\t%0,%1
1446 cly\t%0,%1
1447 #
1448 #"
1449 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
1450 (set_attr "cpu_facility" "*,extimm,z10,z10,*,longdisp,*,*")
1451 (set_attr "type" "*,*,larl,*,*,*,*,*")
1452 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")
1453 (set_attr "relative_long" "*,*,yes,*,*,*,*,*")])
1454
1455 (define_insn "*cmphi_ccu"
1456 [(set (reg CC_REGNUM)
1457 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
1458 (match_operand:HI 1 "general_operand" "Q,S,n,BQ,Q")))]
1459 "s390_match_ccmode (insn, CCUmode)
1460 && !register_operand (operands[1], HImode)"
1461 "@
1462 clm\t%0,3,%S1
1463 clmy\t%0,3,%S1
1464 clhhsi\t%0,%x1
1465 #
1466 #"
1467 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
1468 (set_attr "cpu_facility" "*,longdisp,z10,*,*")
1469 (set_attr "z10prop" "*,*,z10_super,*,*")])
1470
1471 (define_insn "*cmpqi_ccu"
1472 [(set (reg CC_REGNUM)
1473 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
1474 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
1475 "s390_match_ccmode (insn, CCUmode)
1476 && !register_operand (operands[1], QImode)"
1477 "@
1478 clm\t%0,1,%S1
1479 clmy\t%0,1,%S1
1480 cli\t%S0,%b1
1481 cliy\t%S0,%b1
1482 #
1483 #"
1484 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
1485 (set_attr "cpu_facility" "*,longdisp,*,longdisp,*,*")
1486 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
1487
1488
1489 ; Block compare (CLC) instruction patterns.
1490
1491 (define_insn "*clc"
1492 [(set (reg CC_REGNUM)
1493 (compare (match_operand:BLK 0 "memory_operand" "Q")
1494 (match_operand:BLK 1 "memory_operand" "Q")))
1495 (use (match_operand 2 "const_int_operand" "n"))]
1496 "s390_match_ccmode (insn, CCUmode)
1497 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1498 "clc\t%O0(%2,%R0),%S1"
1499 [(set_attr "op_type" "SS")])
1500
1501 (define_split
1502 [(set (reg CC_REGNUM)
1503 (compare (match_operand 0 "memory_operand" "")
1504 (match_operand 1 "memory_operand" "")))]
1505 "reload_completed
1506 && s390_match_ccmode (insn, CCUmode)
1507 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1508 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1509 [(parallel
1510 [(set (match_dup 0) (match_dup 1))
1511 (use (match_dup 2))])]
1512 {
1513 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1514 operands[0] = adjust_address (operands[0], BLKmode, 0);
1515 operands[1] = adjust_address (operands[1], BLKmode, 0);
1516
1517 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
1518 operands[0], operands[1]);
1519 operands[0] = SET_DEST (PATTERN (curr_insn));
1520 })
1521
1522
1523 ; (TF|DF|SF|TD|DD|SD) instructions
1524
1525
1526 ; load and test instructions turn a signaling NaN into a quiet NaN. Thus they
1527 ; may only be used if the target register is dead afterwards or if fast math
1528 ; is enabled. The former is done via a peephole optimization. Note, load and
1529 ; test instructions may only be used for (in)equality comparisons because
1530 ; relational comparisons must treat a quiet NaN like a signaling NaN which is
1531 ; not the case for load and test instructions. For fast math insn
1532 ; "cmp<mode>_ccs_0_fastmath" applies.
1533 ; See testcases load-and-test-fp-{1,2}.c
1534
1535 (define_peephole2
1536 [(set (match_operand:FP 0 "register_operand")
1537 (match_operand:FP 1 "const0_operand"))
1538 (set (reg:CCZ CC_REGNUM)
1539 (compare:CCZ (match_operand:FP 2 "register_operand")
1540 (match_operand:FP 3 "register_operand")))]
1541 "TARGET_HARD_FLOAT
1542 && FP_REG_P (operands[2])
1543 && REGNO (operands[0]) == REGNO (operands[3])
1544 && peep2_reg_dead_p (2, operands[0])
1545 && peep2_reg_dead_p (2, operands[2])"
1546 [(parallel
1547 [(set (reg:CCZ CC_REGNUM)
1548 (compare:CCZ (match_dup 2) (match_dup 1)))
1549 (clobber (match_dup 2))])]
1550 "")
1551
1552 ; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
1553 (define_insn "*cmp<mode>_ccz_0"
1554 [(set (reg:CCZ CC_REGNUM)
1555 (compare:CCZ (match_operand:FP 0 "register_operand" "f")
1556 (match_operand:FP 1 "const0_operand")))
1557 (clobber (match_operand:FP 2 "register_operand" "=0"))]
1558 "TARGET_HARD_FLOAT"
1559 "lt<xde><bt>r\t%0,%0"
1560 [(set_attr "op_type" "RRE")
1561 (set_attr "type" "fsimp<type>")])
1562
1563 (define_insn "*cmp<mode>_ccs_0_fastmath"
1564 [(set (reg CC_REGNUM)
1565 (compare (match_operand:FP 0 "register_operand" "f")
1566 (match_operand:FP 1 "const0_operand")))]
1567 "s390_match_ccmode (insn, CCSmode)
1568 && TARGET_HARD_FLOAT
1569 && !flag_trapping_math
1570 && !flag_signaling_nans"
1571 "lt<xde><bt>r\t%0,%0"
1572 [(set_attr "op_type" "RRE")
1573 (set_attr "type" "fsimp<type>")])
1574
1575 ; VX: TFmode in FPR pairs: use cxbr instead of wfcxb
1576 ; cxtr, cdtr, cxbr, cdbr, cebr, cdb, ceb, wfcsb, wfcdb
1577 (define_insn "*cmp<mode>_ccs"
1578 [(set (reg CC_REGNUM)
1579 (compare (match_operand:FP 0 "register_operand" "f,f,v,v")
1580 (match_operand:FP 1 "general_operand" "f,R,v,v")))]
1581 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1582 "@
1583 c<xde><bt>r\t%0,%1
1584 c<xde>b\t%0,%1
1585 wfcdb\t%0,%1
1586 wfcsb\t%0,%1"
1587 [(set_attr "op_type" "RRE,RXE,VRR,VRR")
1588 (set_attr "cpu_facility" "*,*,vx,vxe")
1589 (set_attr "enabled" "*,<DSF>,<DF>,<SF>")])
1590
1591 ; VX: TFmode in VR: use wfcxb
1592 (define_insn "*cmptf_ccs"
1593 [(set (reg CC_REGNUM)
1594 (compare (match_operand:TF 0 "register_operand" "v")
1595 (match_operand:TF 1 "register_operand" "v")))]
1596 "s390_match_ccmode(insn, CCSmode) && TARGET_VXE"
1597 "wfcxb\t%0,%1"
1598 [(set_attr "op_type" "VRR")
1599 (set_attr "cpu_facility" "vxe")])
1600
1601 ; VX: TFmode in FPR pairs: use kxbr instead of wfkxb
1602 ; kxtr, kdtr, kxbr, kdbr, kebr, kdb, keb, wfksb, wfkdb
1603 (define_insn "*cmp<mode>_ccsfps"
1604 [(set (reg CC_REGNUM)
1605 (compare (match_operand:FP 0 "register_operand" "f,f,v,v")
1606 (match_operand:FP 1 "general_operand" "f,R,v,v")))]
1607 "s390_match_ccmode (insn, CCSFPSmode) && TARGET_HARD_FLOAT"
1608 "@
1609 k<xde><bt>r\t%0,%1
1610 k<xde>b\t%0,%1
1611 wfkdb\t%0,%1
1612 wfksb\t%0,%1"
1613 [(set_attr "op_type" "RRE,RXE,VRR,VRR")
1614 (set_attr "cpu_facility" "*,*,vx,vxe")
1615 (set_attr "enabled" "*,<DSF>,<DF>,<SF>")])
1616
1617 ; VX: TFmode in VR: use wfkxb
1618 (define_insn "*cmptf_ccsfps"
1619 [(set (reg CC_REGNUM)
1620 (compare (match_operand:TF 0 "register_operand" "v")
1621 (match_operand:TF 1 "register_operand" "v")))]
1622 "s390_match_ccmode (insn, CCSFPSmode) && TARGET_VXE"
1623 "wfkxb\t%0,%1"
1624 [(set_attr "op_type" "VRR")
1625 (set_attr "cpu_facility" "vxe")])
1626
1627 ; Compare and Branch instructions
1628
1629 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1630 ; The following instructions do a complementary access of their second
1631 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1632 (define_insn "*cmp_and_br_signed_<mode>"
1633 [(set (pc)
1634 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1635 [(match_operand:GPR 1 "register_operand" "d,d")
1636 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1637 (label_ref (match_operand 3 "" ""))
1638 (pc)))
1639 (clobber (reg:CC CC_REGNUM))]
1640 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1641 {
1642 if (get_attr_length (insn) == 6)
1643 return which_alternative ?
1644 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1645 else
1646 return which_alternative ?
1647 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1648 }
1649 [(set_attr "op_type" "RIE")
1650 (set_attr "type" "branch")
1651 (set_attr "z10prop" "z10_super_c,z10_super")
1652 (set (attr "length")
1653 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1654 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1655 ; 10 byte for cgr/jg
1656
1657 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1658 ; The following instructions do a complementary access of their second
1659 ; operand (z10 only): clrj, clgrj, clr, clgr
1660 (define_insn "*cmp_and_br_unsigned_<mode>"
1661 [(set (pc)
1662 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1663 [(match_operand:GPR 1 "register_operand" "d,d")
1664 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1665 (label_ref (match_operand 3 "" ""))
1666 (pc)))
1667 (clobber (reg:CC CC_REGNUM))]
1668 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1669 {
1670 if (get_attr_length (insn) == 6)
1671 return which_alternative ?
1672 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1673 else
1674 return which_alternative ?
1675 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1676 }
1677 [(set_attr "op_type" "RIE")
1678 (set_attr "type" "branch")
1679 (set_attr "z10prop" "z10_super_c,z10_super")
1680 (set (attr "length")
1681 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1682 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1683 ; 10 byte for clgr/jg
1684
1685 ; And now the same two patterns as above but with a negated CC mask.
1686
1687 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1688 ; The following instructions do a complementary access of their second
1689 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1690 (define_insn "*icmp_and_br_signed_<mode>"
1691 [(set (pc)
1692 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1693 [(match_operand:GPR 1 "register_operand" "d,d")
1694 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1695 (pc)
1696 (label_ref (match_operand 3 "" ""))))
1697 (clobber (reg:CC CC_REGNUM))]
1698 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1699 {
1700 if (get_attr_length (insn) == 6)
1701 return which_alternative ?
1702 "c<g>ij%D0\t%1,%c2,%l3" : "c<g>rj%D0\t%1,%2,%l3";
1703 else
1704 return which_alternative ?
1705 "c<g>fi\t%1,%c2\;jg%D0\t%l3" : "c<g>r\t%1,%2\;jg%D0\t%l3";
1706 }
1707 [(set_attr "op_type" "RIE")
1708 (set_attr "type" "branch")
1709 (set_attr "z10prop" "z10_super_c,z10_super")
1710 (set (attr "length")
1711 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1712 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1713 ; 10 byte for cgr/jg
1714
1715 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1716 ; The following instructions do a complementary access of their second
1717 ; operand (z10 only): clrj, clgrj, clr, clgr
1718 (define_insn "*icmp_and_br_unsigned_<mode>"
1719 [(set (pc)
1720 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1721 [(match_operand:GPR 1 "register_operand" "d,d")
1722 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1723 (pc)
1724 (label_ref (match_operand 3 "" ""))))
1725 (clobber (reg:CC CC_REGNUM))]
1726 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1727 {
1728 if (get_attr_length (insn) == 6)
1729 return which_alternative ?
1730 "cl<g>ij%D0\t%1,%b2,%l3" : "cl<g>rj%D0\t%1,%2,%l3";
1731 else
1732 return which_alternative ?
1733 "cl<g>fi\t%1,%b2\;jg%D0\t%l3" : "cl<g>r\t%1,%2\;jg%D0\t%l3";
1734 }
1735 [(set_attr "op_type" "RIE")
1736 (set_attr "type" "branch")
1737 (set_attr "z10prop" "z10_super_c,z10_super")
1738 (set (attr "length")
1739 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1740 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1741 ; 10 byte for clgr/jg
1742
1743 ;;
1744 ;;- Move instructions.
1745 ;;
1746
1747 ;
1748 ; movti instruction pattern(s).
1749 ;
1750
1751
1752 ; Separate out the register pair alternative since constraints (P) are
1753 ; not able to deal with const_wide_int's. But predicates do.
1754 (define_insn "*movti_bigconst"
1755 [(set (match_operand:TI 0 "register_operand" "=d")
1756 (match_operand:TI 1 "reload_const_wide_int_operand" ""))]
1757 "TARGET_ZARCH"
1758 "#")
1759
1760 ; FIXME: More constants are possible by enabling jxx, jyy constraints
1761 ; for TImode (use double-int for the calculations)
1762 (define_insn "movti"
1763 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,S,v, v, v, v, v, v,v,d,v,R,d, d, d, d, d,o")
1764 (match_operand:TI 1 "general_operand" " S,d,v,j00,jm1,jyy,jxx,jzz,d,v,R,v,K,NxHD0,Os,NxSD0,dT,d"))]
1765 "TARGET_ZARCH"
1766 "@
1767 lmg\t%0,%N0,%S1
1768 stmg\t%1,%N1,%S0
1769 vlr\t%v0,%v1
1770 vzero\t%v0
1771 vone\t%v0
1772 vgbm\t%v0,%r1
1773 vgm\t%v0,%q1
1774 vrepi\t%v0,%p1
1775 vlvgp\t%v0,%1,%N1
1776 #
1777 vl\t%v0,%1%A1
1778 vst\t%v1,%0%A0
1779 #
1780 #
1781 #
1782 #
1783 #
1784 #"
1785 [(set_attr "op_type" "RSY,RSY,VRR,VRI,VRI,VRI,VRI,VRI,VRR,*,VRX,VRX,*,*,*,*,*,*")
1786 (set_attr "type" "lm,stm,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
1787 (set_attr "cpu_facility" "*,*,vx,vx,vx,vx,vx,vx,vx,vx,vx,vx,*,*,*,extimm,*,*")])
1788
1789 (define_split
1790 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1791 (match_operand:TI 1 "general_operand" ""))]
1792 "TARGET_ZARCH && reload_completed
1793 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
1794 [(set (match_dup 2) (match_dup 4))
1795 (set (match_dup 3) (match_dup 5))]
1796 {
1797 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1798 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1799 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1800 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1801 })
1802
1803 (define_split
1804 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1805 (match_operand:TI 1 "general_operand" ""))]
1806 "TARGET_ZARCH && reload_completed
1807 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1808 [(set (match_dup 2) (match_dup 4))
1809 (set (match_dup 3) (match_dup 5))]
1810 {
1811 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1812 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1813 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1814 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1815 })
1816
1817 ; Use part of the TImode target reg to perform the address
1818 ; calculation. If the TImode value is supposed to be copied into a VR
1819 ; this splitter is not necessary.
1820 (define_split
1821 [(set (match_operand:TI 0 "register_operand" "")
1822 (match_operand:TI 1 "memory_operand" ""))]
1823 "TARGET_ZARCH && reload_completed
1824 && !VECTOR_REG_P (operands[0])
1825 && !s_operand (operands[1], VOIDmode)"
1826 [(set (match_dup 0) (match_dup 1))]
1827 {
1828 rtx addr = operand_subword (operands[0], 1, 0, TImode);
1829 addr = gen_lowpart (Pmode, addr);
1830 s390_load_address (addr, XEXP (operands[1], 0));
1831 operands[1] = replace_equiv_address (operands[1], addr);
1832 })
1833
1834
1835 ; Split a VR -> GPR TImode move into 2 vector load GR from VR element.
1836 ; For the higher order bits we do simply a DImode move while the
1837 ; second part is done via vec extract. Both will end up as vlgvg.
1838 (define_split
1839 [(set (match_operand:TI 0 "register_operand" "")
1840 (match_operand:TI 1 "register_operand" ""))]
1841 "TARGET_VX && reload_completed
1842 && GENERAL_REG_P (operands[0])
1843 && VECTOR_REG_P (operands[1])"
1844 [(set (match_dup 2) (match_dup 4))
1845 (set (match_dup 3) (vec_select:DI (match_dup 5)
1846 (parallel [(const_int 1)])))]
1847 {
1848 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1849 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1850 operands[4] = gen_rtx_REG (DImode, REGNO (operands[1]));
1851 operands[5] = gen_rtx_REG (V2DImode, REGNO (operands[1]));
1852 })
1853
1854 ;
1855 ; Patterns used for secondary reloads
1856 ;
1857
1858 ; z10 provides move instructions accepting larl memory operands.
1859 ; Unfortunately there is no such variant for QI, TI and FP mode moves.
1860 ; These patterns are also used for unaligned SI and DI accesses.
1861
1862 (define_expand "reload<ALL:mode><P:mode>_tomem_z10"
1863 [(parallel [(match_operand:ALL 0 "memory_operand" "")
1864 (match_operand:ALL 1 "register_operand" "=d")
1865 (match_operand:P 2 "register_operand" "=&a")])]
1866 "TARGET_Z10"
1867 {
1868 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1869 DONE;
1870 })
1871
1872 (define_expand "reload<ALL:mode><P:mode>_toreg_z10"
1873 [(parallel [(match_operand:ALL 0 "register_operand" "=d")
1874 (match_operand:ALL 1 "memory_operand" "")
1875 (match_operand:P 2 "register_operand" "=a")])]
1876 "TARGET_Z10"
1877 {
1878 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1879 DONE;
1880 })
1881
1882 (define_expand "reload<P:mode>_larl_odd_addend_z10"
1883 [(parallel [(match_operand:P 0 "register_operand" "=d")
1884 (match_operand:P 1 "larl_operand" "")
1885 (match_operand:P 2 "register_operand" "=a")])]
1886 "TARGET_Z10"
1887 {
1888 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1889 DONE;
1890 })
1891
1892 ; Handles loading a PLUS (load address) expression
1893
1894 (define_expand "reload<mode>_plus"
1895 [(parallel [(match_operand:P 0 "register_operand" "=a")
1896 (match_operand:P 1 "s390_plus_operand" "")
1897 (match_operand:P 2 "register_operand" "=&a")])]
1898 ""
1899 {
1900 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1901 DONE;
1902 })
1903
1904 ; Not all the indirect memory access instructions support the full
1905 ; format (long disp + index + base). So whenever a move from/to such
1906 ; an address is required and the instruction cannot deal with it we do
1907 ; a load address into a scratch register first and use this as the new
1908 ; base register.
1909 ; This in particular is used for:
1910 ; - non-offsetable memory accesses for multiword moves
1911 ; - full vector reg moves with long displacements
1912
1913 (define_expand "reload<mode>_la_in"
1914 [(parallel [(match_operand 0 "register_operand" "")
1915 (match_operand 1 "" "")
1916 (match_operand:P 2 "register_operand" "=&a")])]
1917 ""
1918 {
1919 gcc_assert (MEM_P (operands[1]));
1920 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1921 operands[1] = replace_equiv_address (operands[1], operands[2]);
1922 emit_move_insn (operands[0], operands[1]);
1923 DONE;
1924 })
1925
1926 (define_expand "reload<mode>_la_out"
1927 [(parallel [(match_operand 0 "" "")
1928 (match_operand 1 "register_operand" "")
1929 (match_operand:P 2 "register_operand" "=&a")])]
1930 ""
1931 {
1932 gcc_assert (MEM_P (operands[0]));
1933 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1934 operands[0] = replace_equiv_address (operands[0], operands[2]);
1935 emit_move_insn (operands[0], operands[1]);
1936 DONE;
1937 })
1938
1939 (define_expand "reload<mode>_PIC_addr"
1940 [(parallel [(match_operand 0 "register_operand" "=d")
1941 (match_operand 1 "larl_operand" "")
1942 (match_operand:P 2 "register_operand" "=a")])]
1943 ""
1944 {
1945 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1946 emit_move_insn (operands[0], new_rtx);
1947 })
1948
1949 ;
1950 ; movdi instruction pattern(s).
1951 ;
1952
1953 (define_expand "movdi"
1954 [(set (match_operand:DI 0 "general_operand" "")
1955 (match_operand:DI 1 "general_operand" ""))]
1956 ""
1957 {
1958 /* Handle symbolic constants. */
1959 if (TARGET_64BIT
1960 && (SYMBOLIC_CONST (operands[1])
1961 || (GET_CODE (operands[1]) == PLUS
1962 && XEXP (operands[1], 0) == pic_offset_table_rtx
1963 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
1964 emit_symbolic_move (operands);
1965 })
1966
1967 (define_insn "*movdi_64"
1968 [(set (match_operand:DI 0 "nonimmediate_operand"
1969 "=d, d, d, d, d, d, d, d,f,d,!*f,d,d,d,d,T,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t,v,v,v,d,v,R,d")
1970 (match_operand:DI 1 "general_operand"
1971 " K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,j00,L,b,d,T,d, *f, R, T,*f,*f,d,K,t,d,t,Q,K,v,d,v,R,v,ZL"))]
1972 "TARGET_ZARCH"
1973 "@
1974 lghi\t%0,%h1
1975 llihh\t%0,%i1
1976 llihl\t%0,%i1
1977 llilh\t%0,%i1
1978 llill\t%0,%i1
1979 lgfi\t%0,%1
1980 llihf\t%0,%k1
1981 llilf\t%0,%k1
1982 ldgr\t%0,%1
1983 lgdr\t%0,%1
1984 lzdr\t%0
1985 lay\t%0,%a1
1986 lgrl\t%0,%1
1987 lgr\t%0,%1
1988 lg\t%0,%1
1989 stg\t%1,%0
1990 ldr\t%0,%1
1991 ld\t%0,%1
1992 ldy\t%0,%1
1993 std\t%1,%0
1994 stdy\t%1,%0
1995 stgrl\t%1,%0
1996 mvghi\t%0,%1
1997 #
1998 #
1999 stam\t%1,%N1,%S0
2000 lam\t%0,%N0,%S1
2001 vleig\t%v0,%h1,0
2002 vlr\t%v0,%v1
2003 vlvgg\t%v0,%1,0
2004 vlgvg\t%0,%v1,0
2005 vleg\t%v0,%1,0
2006 vsteg\t%v1,%0,0
2007 larl\t%0,%1"
2008 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RRE,RXY,RIL,RRE,RXY,
2009 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS,
2010 VRX,VRX,RIL")
2011 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,fsimpdf,la,larl,lr,load,store,
2012 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,*,
2013 *,*,*,*,*,*,*,larl")
2014 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,*,longdisp,
2015 z10,*,*,*,*,*,longdisp,*,longdisp,
2016 z10,z10,*,*,*,*,vx,vx,vx,vx,vx,vx,*")
2017 (set_attr "z10prop" "z10_fwd_A1,
2018 z10_fwd_E1,
2019 z10_fwd_E1,
2020 z10_fwd_E1,
2021 z10_fwd_E1,
2022 z10_fwd_A1,
2023 z10_fwd_E1,
2024 z10_fwd_E1,
2025 *,
2026 *,
2027 *,
2028 z10_fwd_A1,
2029 z10_fwd_A3,
2030 z10_fr_E1,
2031 z10_fwd_A3,
2032 z10_rec,
2033 *,
2034 *,
2035 *,
2036 *,
2037 *,
2038 z10_rec,
2039 z10_super,
2040 *,
2041 *,
2042 *,
2043 *,*,*,*,*,*,*,
2044 z10_super_A1")
2045 (set_attr "relative_long" "*,*,*,*,*,*,*,*,*,*,*,
2046 *,yes,*,*,*,*,*,*,*,*,
2047 yes,*,*,*,*,*,*,*,*,*,
2048 *,*,yes")
2049 ])
2050
2051 ; LOAD INDEXED ADDRESS
2052 ; lxab, lxah, lxaf, lxag, lxaq
2053
2054 (define_int_iterator LXAMODEITER [1 2 3 4])
2055 (define_int_attr lxamode [(1 "h") (2 "f") (3 "g") (4 "q")])
2056
2057 ; see testsuite/gcc.target/s390/lxa-1.c
2058 (define_insn "*lxa<lxamode>_index"
2059 [(set (match_operand:DI 0 "register_operand" "=d")
2060 (ashift:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "a"))
2061 (const_int LXAMODEITER)))]
2062 "TARGET_Z17 && TARGET_64BIT"
2063 "lxa<lxamode>\t%0,0(%1,0)"
2064 [(set_attr "op_type" "RXY")])
2065
2066 ; see testsuite/gcc.target/s390/lxa-2.c
2067 (define_insn "*lxa<lxamode>_displacement_index"
2068 [(set (match_operand:DI 0 "register_operand" "=d")
2069 (ashift:DI (sign_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "a")
2070 (match_operand:SI 2 "const_int_operand")))
2071 (const_int LXAMODEITER)))]
2072 "TARGET_Z17 && TARGET_64BIT && INTVAL (operands[2]) >= -0x80000 && INTVAL (operands[2]) <= 0x7FFFF"
2073 "lxa<lxamode>\t%0,%2(%1,0)"
2074 [(set_attr "op_type" "RXY")])
2075
2076 ; see testsuite/gcc.target/s390/lxa-3.c
2077 (define_insn "*lxa<lxamode>_index_base"
2078 [(set (match_operand:DI 0 "register_operand" "=d")
2079 (plus:DI (ashift:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "a"))
2080 (const_int LXAMODEITER))
2081 (match_operand:DI 2 "register_operand" "a")))]
2082 "TARGET_Z17 && TARGET_64BIT"
2083 "lxa<lxamode>\t%0,0(%1,%2)"
2084 [(set_attr "op_type" "RXY")])
2085
2086 ; see testsuite/gcc.target/s390/lxa-4.c
2087 (define_insn "*lxa<lxamode>_displacement_index_base"
2088 [(set (match_operand:DI 0 "register_operand" "=d")
2089 (plus:DI (ashift:DI (sign_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "a")
2090 (match_operand:SI 2 "const_int_operand")))
2091 (const_int LXAMODEITER))
2092 (match_operand:DI 3 "register_operand" "a")))]
2093 "TARGET_Z17 && TARGET_64BIT && INTVAL (operands[2]) >= -0x80000 && INTVAL (operands[2]) <= 0x7FFFF"
2094 "lxa<lxamode>\t%0,%2(%1,%3)"
2095 [(set_attr "op_type" "RXY")])
2096
2097 (define_insn "*lxab_displacement_index_base"
2098 [(set (match_operand:DI 0 "register_operand" "=d")
2099 (plus:DI (sign_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "a")
2100 (match_operand:SI 2 "const_int_operand")))
2101 (match_operand:DI 3 "register_operand" "a")))]
2102 "TARGET_Z17 && TARGET_64BIT && INTVAL (operands[2]) >= -0x80000 && INTVAL (operands[2]) <= 0x7FFFF"
2103 "lxab\t%0,%2(%1,%3)"
2104 [(set_attr "op_type" "RXY")])
2105
2106 ; LOAD LOGICAL INDEXED ADDRESS
2107 ; llxab, llxah, llxaf, llxag, llxaq
2108
2109 (define_int_attr LLXAMASK [(1 "8589934590") (2 "17179869180") (3 "34359738360") (4 "68719476720")])
2110
2111 ; see testsuite/gcc.target/s390/llxa-1.c
2112 (define_insn "*llxa<lxamode>_displacement_index"
2113 [(set (match_operand:DI 0 "register_operand" "=d")
2114 (and:DI (ashift:DI (subreg:DI (plus:SI (match_operand:SI 1 "register_operand" "a")
2115 (match_operand:SI 2 "const_int_operand"))
2116 0)
2117 (const_int LXAMODEITER))
2118 (const_int <LLXAMASK>)))]
2119 "TARGET_Z17 && TARGET_64BIT && INTVAL (operands[2]) >= -0x80000 && INTVAL (operands[2]) <= 0x7FFFF"
2120 "llxa<lxamode>\t%0,%2(%1,0)"
2121 [(set_attr "op_type" "RXY")])
2122
2123 ; see testsuite/gcc.target/s390/llxa-2.c
2124 (define_insn "*llxa<lxamode>_index_base"
2125 [(set (match_operand:DI 0 "register_operand" "=d")
2126 (plus:DI (and:DI (ashift:DI (match_operand:DI 1 "register_operand" "a")
2127 (const_int LXAMODEITER))
2128 (const_int <LLXAMASK>))
2129 (match_operand:DI 2 "register_operand" "a")))]
2130 "TARGET_Z17 && TARGET_64BIT"
2131 "llxa<lxamode>\t%0,0(%1,%2)"
2132 [(set_attr "op_type" "RXY")])
2133
2134 ; see testsuite/gcc.target/s390/llxa-3.c
2135 (define_insn "*llxa<lxamode>_displacement_index_base"
2136 [(set (match_operand:DI 0 "register_operand" "=d")
2137 (plus:DI (and:DI (ashift:DI (subreg:DI (plus:SI (match_operand:SI 1 "register_operand" "a")
2138 (match_operand:SI 2 "const_int_operand"))
2139 0)
2140 (const_int LXAMODEITER))
2141 (const_int <LLXAMASK>))
2142 (match_operand:DI 3 "register_operand" "a")))]
2143 "TARGET_Z17 && TARGET_64BIT && INTVAL (operands[2]) >= -0x80000 && INTVAL (operands[2]) <= 0x7FFFF"
2144 "llxa<lxamode>\t%0,%2(%1,%3)"
2145 [(set_attr "op_type" "RXY")])
2146
2147 (define_insn "*llxab_displacement_index_base"
2148 [(set (match_operand:DI 0 "register_operand" "=d")
2149 (plus:DI (zero_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "a")
2150 (match_operand:SI 2 "const_int_operand")))
2151 (match_operand:DI 3 "register_operand" "a")))]
2152 "TARGET_Z17 && TARGET_64BIT && INTVAL (operands[2]) >= -0x80000 && INTVAL (operands[2]) <= 0x7FFFF"
2153 "llxab\t%0,%2(%1,%3)"
2154 [(set_attr "op_type" "RXY")])
2155
2156 ; Splitters for loading TLS pointer from UNSPEC_GET_TP.
2157 ; UNSPEC_GET_TP is used instead of %a0:P, since the latter is a hard register,
2158 ; and those are not handled by Partial Redundancy Elimination (gcse.cc), which
2159 ; results in generation of redundant thread pointer loads.
2160
2161 (define_insn_and_split "*get_tp_31"
2162 [(set (match_operand:SI 0 "register_operand" "=r")
2163 (unspec:SI [(match_operand:SI 1 "register_operand" "t")]
2164 UNSPEC_GET_TP))]
2165 ""
2166 "#"
2167 "&& reload_completed"
2168 [(set (match_dup 0) (match_dup 1))])
2169
2170 (define_insn_and_split "*get_tp_64"
2171 [(set (match_operand:DI 0 "register_operand" "=r")
2172 (unspec:DI [(match_operand:DI 1 "register_operand" "t")]
2173 UNSPEC_GET_TP))]
2174 "TARGET_ZARCH"
2175 "#"
2176 "&& reload_completed"
2177 [(set (match_dup 2) (match_dup 3))
2178 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
2179 (set (strict_low_part (match_dup 2)) (match_dup 4))]
2180 "operands[2] = gen_lowpart (SImode, operands[0]);
2181 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
2182
2183 ; Splitters for storing TLS pointer to %a0:DI.
2184
2185 (define_split
2186 [(set (match_operand:DI 0 "register_operand" "")
2187 (match_operand:DI 1 "register_operand" ""))]
2188 "TARGET_ZARCH && ACCESS_REG_P (operands[0]) && reload_completed
2189 && dead_or_set_p (insn, operands[1])"
2190 [(set (match_dup 3) (match_dup 2))
2191 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
2192 (set (match_dup 4) (match_dup 2))]
2193 "operands[2] = gen_lowpart (SImode, operands[1]);
2194 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
2195
2196 (define_split
2197 [(set (match_operand:DI 0 "register_operand" "")
2198 (match_operand:DI 1 "register_operand" ""))]
2199 "TARGET_ZARCH && ACCESS_REG_P (operands[0]) && reload_completed
2200 && !dead_or_set_p (insn, operands[1])"
2201 [(set (match_dup 3) (match_dup 2))
2202 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
2203 (set (match_dup 4) (match_dup 2))
2204 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
2205 "operands[2] = gen_lowpart (SImode, operands[1]);
2206 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
2207
2208 (define_insn "*movdi_31"
2209 [(set (match_operand:DI 0 "nonimmediate_operand"
2210 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!*f,!R,!T,d")
2211 (match_operand:DI 1 "general_operand"
2212 " Q,S,d,d,dPT,d, *f, R, T,j00,*f,*f,b"))]
2213 "!TARGET_ZARCH"
2214 "@
2215 lm\t%0,%N0,%S1
2216 lmy\t%0,%N0,%S1
2217 stm\t%1,%N1,%S0
2218 stmy\t%1,%N1,%S0
2219 #
2220 #
2221 ldr\t%0,%1
2222 ld\t%0,%1
2223 ldy\t%0,%1
2224 lzdr\t%0
2225 std\t%1,%0
2226 stdy\t%1,%0
2227 #"
2228 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RRE,RX,RXY,*")
2229 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fsimpdf,fstoredf,fstoredf,*")
2230 (set_attr "cpu_facility" "*,longdisp,*,longdisp,*,*,*,*,longdisp,*,*,longdisp,z10")])
2231
2232 ; For a load from a symbol ref we can use one of the target registers
2233 ; together with larl to load the address.
2234 (define_split
2235 [(set (match_operand:DI 0 "register_operand" "")
2236 (match_operand:DI 1 "memory_operand" ""))]
2237 "!TARGET_ZARCH && reload_completed && TARGET_Z10
2238 && larl_operand (XEXP (operands[1], 0), SImode)"
2239 [(set (match_dup 2) (match_dup 3))
2240 (set (match_dup 0) (match_dup 1))]
2241 {
2242 operands[2] = operand_subword (operands[0], 1, 0, DImode);
2243 operands[3] = XEXP (operands[1], 0);
2244 operands[1] = replace_equiv_address (operands[1], operands[2]);
2245 })
2246
2247 (define_split
2248 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2249 (match_operand:DI 1 "general_operand" ""))]
2250 "!TARGET_ZARCH && reload_completed
2251 && !s_operand (operands[0], DImode)
2252 && !s_operand (operands[1], DImode)
2253 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
2254 [(set (match_dup 2) (match_dup 4))
2255 (set (match_dup 3) (match_dup 5))]
2256 {
2257 operands[2] = operand_subword (operands[0], 0, 0, DImode);
2258 operands[3] = operand_subword (operands[0], 1, 0, DImode);
2259 operands[4] = operand_subword (operands[1], 0, 0, DImode);
2260 operands[5] = operand_subword (operands[1], 1, 0, DImode);
2261 })
2262
2263 (define_split
2264 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2265 (match_operand:DI 1 "general_operand" ""))]
2266 "!TARGET_ZARCH && reload_completed
2267 && !s_operand (operands[0], DImode)
2268 && !s_operand (operands[1], DImode)
2269 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
2270 [(set (match_dup 2) (match_dup 4))
2271 (set (match_dup 3) (match_dup 5))]
2272 {
2273 operands[2] = operand_subword (operands[0], 1, 0, DImode);
2274 operands[3] = operand_subword (operands[0], 0, 0, DImode);
2275 operands[4] = operand_subword (operands[1], 1, 0, DImode);
2276 operands[5] = operand_subword (operands[1], 0, 0, DImode);
2277 })
2278
2279 (define_split
2280 [(set (match_operand:DI 0 "register_operand" "")
2281 (match_operand:DI 1 "memory_operand" ""))]
2282 "!TARGET_ZARCH && reload_completed
2283 && !FP_REG_P (operands[0])
2284 && !s_operand (operands[1], VOIDmode)"
2285 [(set (match_dup 0) (match_dup 1))]
2286 {
2287 rtx addr = operand_subword (operands[0], 1, 0, DImode);
2288 s390_load_address (addr, XEXP (operands[1], 0));
2289 operands[1] = replace_equiv_address (operands[1], addr);
2290 })
2291
2292 (define_peephole2
2293 [(set (match_operand:DI 0 "register_operand" "")
2294 (mem:DI (match_operand 1 "address_operand" "")))]
2295 "TARGET_ZARCH
2296 && !FP_REG_P (operands[0])
2297 && GET_CODE (operands[1]) == SYMBOL_REF
2298 && CONSTANT_POOL_ADDRESS_P (operands[1])
2299 && get_pool_mode (operands[1]) == DImode
2300 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
2301 [(set (match_dup 0) (match_dup 2))]
2302 "operands[2] = get_pool_constant (operands[1]);")
2303
2304 (define_insn "*la_64"
2305 [(set (match_operand:DI 0 "register_operand" "=d,d")
2306 (match_operand:QI 1 "address_operand" "ZR,ZT"))]
2307 "TARGET_64BIT"
2308 "@
2309 la\t%0,%a1
2310 lay\t%0,%a1"
2311 [(set_attr "op_type" "RX,RXY")
2312 (set_attr "type" "la")
2313 (set_attr "cpu_facility" "*,longdisp")
2314 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
2315
2316 (define_peephole2
2317 [(parallel
2318 [(set (match_operand:DI 0 "register_operand" "")
2319 (match_operand:QI 1 "address_operand" ""))
2320 (clobber (reg:CC CC_REGNUM))])]
2321 "TARGET_64BIT
2322 && preferred_la_operand_p (operands[1], const0_rtx)"
2323 [(set (match_dup 0) (match_dup 1))]
2324 "")
2325
2326 (define_peephole2
2327 [(set (match_operand:DI 0 "register_operand" "")
2328 (match_operand:DI 1 "register_operand" ""))
2329 (parallel
2330 [(set (match_dup 0)
2331 (plus:DI (match_dup 0)
2332 (match_operand:DI 2 "nonmemory_operand" "")))
2333 (clobber (reg:CC CC_REGNUM))])]
2334 "TARGET_64BIT
2335 && !reg_overlap_mentioned_p (operands[0], operands[2])
2336 && preferred_la_operand_p (operands[1], operands[2])"
2337 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
2338 "")
2339
2340 ; Split loading of 64-bit constants into GPRs into llihf + oilf -
2341 ; counterintuitively, using oilf is faster than iilf. oilf clobbers
2342 ; cc, so cc must be dead.
2343 (define_peephole2
2344 [(set (match_operand:DI 0 "register_operand" "")
2345 (match_operand:DI 1 "memory_operand" ""))]
2346 "TARGET_64BIT
2347 && TARGET_EXTIMM
2348 && GENERAL_REG_P (operands[0])
2349 && s390_const_int_pool_entry_p (operands[1], nullptr)
2350 && peep2_reg_dead_p (1, gen_rtx_REG (CCmode, CC_REGNUM))"
2351 [(set (match_dup 0) (match_dup 2))
2352 (parallel
2353 [(set (match_dup 0) (ior:DI (match_dup 0) (match_dup 3)))
2354 (clobber (reg:CC CC_REGNUM))])]
2355 {
2356 HOST_WIDE_INT val;
2357 bool ok = s390_const_int_pool_entry_p (operands[1], &val);
2358 gcc_assert (ok);
2359 operands[2] = GEN_INT (val & 0xFFFFFFFF00000000ULL);
2360 operands[3] = GEN_INT (val & 0x00000000FFFFFFFFULL);
2361 if (operands[2] == const0_rtx)
2362 {
2363 emit_move_insn (operands[0], operands[3]);
2364 DONE;
2365 }
2366 else if (operands[3] == const0_rtx)
2367 {
2368 emit_move_insn (operands[0], operands[2]);
2369 DONE;
2370 }
2371 })
2372
2373 ;
2374 ; movsi instruction pattern(s).
2375 ;
2376
2377 (define_expand "movsi"
2378 [(set (match_operand:SI 0 "general_operand" "")
2379 (match_operand:SI 1 "general_operand" ""))]
2380 ""
2381 {
2382 /* Handle symbolic constants. */
2383 if (!TARGET_64BIT
2384 && (SYMBOLIC_CONST (operands[1])
2385 || (GET_CODE (operands[1]) == PLUS
2386 && XEXP (operands[1], 0) == pic_offset_table_rtx
2387 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
2388 emit_symbolic_move (operands);
2389 })
2390
2391 (define_insn "*movsi_larl"
2392 [(set (match_operand:SI 0 "register_operand" "=d")
2393 (match_operand:SI 1 "larl_operand" "X"))]
2394 "!TARGET_64BIT
2395 && !FP_REG_P (operands[0])"
2396 "larl\t%0,%1"
2397 [(set_attr "op_type" "RIL")
2398 (set_attr "type" "larl")
2399 (set_attr "z10prop" "z10_fwd_A1")
2400 (set_attr "relative_long" "yes")])
2401
2402 (define_insn "*movsi_zarch"
2403 [(set (match_operand:SI 0 "nonimmediate_operand"
2404 "=d, d, d, d,d,d,d,d,d,R,T,!*f,!*f,!*f,!*f,!*f,!R,!T,d,t,Q,b,Q,t,v,v,v,d,v,R")
2405 (match_operand:SI 1 "general_operand"
2406 " K,N0HS0,N1HS0,Os,L,b,d,R,T,d,d, *f, *f, R, R, T,*f,*f,t,d,t,d,K,Q,K,v,d,v,R,v"))]
2407 "TARGET_ZARCH"
2408 "@
2409 lhi\t%0,%h1
2410 llilh\t%0,%i1
2411 llill\t%0,%i1
2412 iilf\t%0,%o1
2413 lay\t%0,%a1
2414 lrl\t%0,%1
2415 lr\t%0,%1
2416 l\t%0,%1
2417 ly\t%0,%1
2418 st\t%1,%0
2419 sty\t%1,%0
2420 ldr\t%0,%1
2421 ler\t%0,%1
2422 lde\t%0,%1
2423 le\t%0,%1
2424 ley\t%0,%1
2425 ste\t%1,%0
2426 stey\t%1,%0
2427 ear\t%0,%1
2428 sar\t%0,%1
2429 stam\t%1,%1,%S0
2430 strl\t%1,%0
2431 mvhi\t%0,%1
2432 lam\t%0,%0,%S1
2433 vleif\t%v0,%h1,0
2434 vlr\t%v0,%v1
2435 vlvgf\t%v0,%1,0
2436 vlgvf\t%0,%v1,0
2437 vlef\t%v0,%1,0
2438 vstef\t%v1,%0,0"
2439 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
2440 RR,RR,RXE,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS,VRI,VRR,VRS,VRS,VRX,VRX")
2441 (set_attr "type" "*,
2442 *,
2443 *,
2444 *,
2445 la,
2446 larl,
2447 lr,
2448 load,
2449 load,
2450 store,
2451 store,
2452 floadsf,
2453 floadsf,
2454 floadsf,
2455 floadsf,
2456 floadsf,
2457 fstoresf,
2458 fstoresf,
2459 *,
2460 *,
2461 *,
2462 larl,
2463 *,
2464 *,*,*,*,*,*,*")
2465 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
2466 vx,*,vx,*,longdisp,*,longdisp,*,*,*,z10,z10,*,vx,vx,vx,vx,vx,vx")
2467 (set_attr "z10prop" "z10_fwd_A1,
2468 z10_fwd_E1,
2469 z10_fwd_E1,
2470 z10_fwd_A1,
2471 z10_fwd_A1,
2472 z10_fwd_A3,
2473 z10_fr_E1,
2474 z10_fwd_A3,
2475 z10_fwd_A3,
2476 z10_rec,
2477 z10_rec,
2478 *,
2479 *,
2480 *,
2481 *,
2482 *,
2483 *,
2484 *,
2485 z10_super_E1,
2486 z10_super,
2487 *,
2488 z10_rec,
2489 z10_super,
2490 *,*,*,*,*,*,*")
2491 (set_attr "relative_long" "*,*,*,*,*,yes,*,*,*,*,
2492 *,*,*,*,*,*,*,*,*,*,
2493 *,yes,*,*,*,*,*,*,*,*")])
2494
2495 (define_insn "*movsi_esa"
2496 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!*f,!*f,!R,d,t,Q,t")
2497 (match_operand:SI 1 "general_operand" "K,d,R,d, *f, *f, R, R,*f,t,d,t,Q"))]
2498 "!TARGET_ZARCH"
2499 "@
2500 lhi\t%0,%h1
2501 lr\t%0,%1
2502 l\t%0,%1
2503 st\t%1,%0
2504 ldr\t%0,%1
2505 ler\t%0,%1
2506 lde\t%0,%1
2507 le\t%0,%1
2508 ste\t%1,%0
2509 ear\t%0,%1
2510 sar\t%0,%1
2511 stam\t%1,%1,%S0
2512 lam\t%0,%0,%S1"
2513 [(set_attr "op_type" "RI,RR,RX,RX,RR,RR,RXE,RX,RX,RRE,RRE,RS,RS")
2514 (set_attr "type" "*,lr,load,store,floadsf,floadsf,floadsf,floadsf,fstoresf,*,*,*,*")
2515 (set_attr "z10prop" "z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec,*,*,*,*,*,z10_super_E1,
2516 z10_super,*,*")
2517 (set_attr "cpu_facility" "*,*,*,*,vx,*,vx,*,*,*,*,*,*")
2518 ])
2519
2520 (define_peephole2
2521 [(set (match_operand:SI 0 "register_operand" "")
2522 (mem:SI (match_operand 1 "address_operand" "")))]
2523 "!FP_REG_P (operands[0])
2524 && GET_CODE (operands[1]) == SYMBOL_REF
2525 && CONSTANT_POOL_ADDRESS_P (operands[1])
2526 && get_pool_mode (operands[1]) == SImode
2527 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
2528 [(set (match_dup 0) (match_dup 2))]
2529 "operands[2] = get_pool_constant (operands[1]);")
2530
2531 (define_insn "*la_31"
2532 [(set (match_operand:SI 0 "register_operand" "=d,d")
2533 (match_operand:QI 1 "address_operand" "ZR,ZT"))]
2534 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
2535 "@
2536 la\t%0,%a1
2537 lay\t%0,%a1"
2538 [(set_attr "op_type" "RX,RXY")
2539 (set_attr "type" "la")
2540 (set_attr "cpu_facility" "*,longdisp")
2541 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
2542
2543 (define_peephole2
2544 [(parallel
2545 [(set (match_operand:SI 0 "register_operand" "")
2546 (match_operand:QI 1 "address_operand" ""))
2547 (clobber (reg:CC CC_REGNUM))])]
2548 "!TARGET_64BIT
2549 && preferred_la_operand_p (operands[1], const0_rtx)"
2550 [(set (match_dup 0) (match_dup 1))]
2551 "")
2552
2553 (define_peephole2
2554 [(set (match_operand:SI 0 "register_operand" "")
2555 (match_operand:SI 1 "register_operand" ""))
2556 (parallel
2557 [(set (match_dup 0)
2558 (plus:SI (match_dup 0)
2559 (match_operand:SI 2 "nonmemory_operand" "")))
2560 (clobber (reg:CC CC_REGNUM))])]
2561 "!TARGET_64BIT
2562 && !reg_overlap_mentioned_p (operands[0], operands[2])
2563 && preferred_la_operand_p (operands[1], operands[2])"
2564 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2565 "")
2566
2567 (define_insn "*la_31_and"
2568 [(set (match_operand:SI 0 "register_operand" "=d,d")
2569 (and:SI (match_operand:QI 1 "address_operand" "ZR,ZT")
2570 (const_int 2147483647)))]
2571 "!TARGET_64BIT"
2572 "@
2573 la\t%0,%a1
2574 lay\t%0,%a1"
2575 [(set_attr "op_type" "RX,RXY")
2576 (set_attr "type" "la")
2577 (set_attr "cpu_facility" "*,longdisp")
2578 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
2579
2580 (define_insn_and_split "*la_31_and_cc"
2581 [(set (match_operand:SI 0 "register_operand" "=d")
2582 (and:SI (match_operand:QI 1 "address_operand" "p")
2583 (const_int 2147483647)))
2584 (clobber (reg:CC CC_REGNUM))]
2585 "!TARGET_64BIT"
2586 "#"
2587 "&& reload_completed"
2588 [(set (match_dup 0)
2589 (and:SI (match_dup 1) (const_int 2147483647)))]
2590 ""
2591 [(set_attr "op_type" "RX")
2592 (set_attr "type" "la")])
2593
2594 (define_insn "force_la_31"
2595 [(set (match_operand:SI 0 "register_operand" "=d,d")
2596 (match_operand:QI 1 "address_operand" "ZR,ZT"))
2597 (use (const_int 0))]
2598 "!TARGET_64BIT"
2599 "@
2600 la\t%0,%a1
2601 lay\t%0,%a1"
2602 [(set_attr "op_type" "RX")
2603 (set_attr "type" "la")
2604 (set_attr "cpu_facility" "*,longdisp")
2605 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
2606
2607 ;
2608 ; movhi instruction pattern(s).
2609 ;
2610
2611 (define_expand "movhi"
2612 [(set (match_operand:HI 0 "nonimmediate_operand" "")
2613 (match_operand:HI 1 "general_operand" ""))]
2614 ""
2615 {
2616 /* Make it explicit that loading a register from memory
2617 always sign-extends (at least) to SImode. */
2618 if (optimize && can_create_pseudo_p ()
2619 && register_operand (operands[0], VOIDmode)
2620 && GET_CODE (operands[1]) == MEM)
2621 {
2622 rtx tmp = gen_reg_rtx (SImode);
2623 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
2624 emit_insn (gen_rtx_SET (tmp, ext));
2625 operands[1] = gen_lowpart (HImode, tmp);
2626 }
2627 })
2628
2629 (define_insn "*movhi"
2630 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q,v,v,v,d,v,R")
2631 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K,K,v,d,v,R,v"))]
2632 ""
2633 "@
2634 lr\t%0,%1
2635 lhi\t%0,%h1
2636 lh\t%0,%1
2637 lhy\t%0,%1
2638 lhrl\t%0,%1
2639 sth\t%1,%0
2640 sthy\t%1,%0
2641 sthrl\t%1,%0
2642 mvhhi\t%0,%1
2643 vleih\t%v0,%h1,0
2644 vlr\t%v0,%v1
2645 vlvgh\t%v0,%1,0
2646 vlgvh\t%0,%v1,0
2647 vleh\t%v0,%1,0
2648 vsteh\t%v1,%0,0"
2649 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL,VRI,VRR,VRS,VRS,VRX,VRX")
2650 (set_attr "type" "lr,*,*,*,larl,store,store,store,*,*,*,*,*,*,*")
2651 (set_attr "cpu_facility" "*,*,*,longdisp,z10,*,longdisp,z10,z10,vx,vx,vx,vx,vx,vx")
2652 (set_attr "z10prop" "z10_fr_E1,
2653 z10_fwd_A1,
2654 z10_super_E1,
2655 z10_super_E1,
2656 z10_super_E1,
2657 z10_rec,
2658 z10_rec,
2659 z10_rec,
2660 z10_super,*,*,*,*,*,*")
2661 (set_attr "relative_long" "*,*,*,*,yes,*,*,yes,*,*,*,*,*,*,*")])
2662
2663 (define_peephole2
2664 [(set (match_operand:HI 0 "register_operand" "")
2665 (mem:HI (match_operand 1 "address_operand" "")))]
2666 "GET_CODE (operands[1]) == SYMBOL_REF
2667 && CONSTANT_POOL_ADDRESS_P (operands[1])
2668 && get_pool_mode (operands[1]) == HImode
2669 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2670 [(set (match_dup 0) (match_dup 2))]
2671 "operands[2] = get_pool_constant (operands[1]);")
2672
2673 ;
2674 ; movqi instruction pattern(s).
2675 ;
2676
2677 (define_expand "movqi"
2678 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2679 (match_operand:QI 1 "general_operand" ""))]
2680 ""
2681 {
2682 /* On z/Architecture, zero-extending from memory to register
2683 is just as fast as a QImode load. */
2684 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
2685 && register_operand (operands[0], VOIDmode)
2686 && GET_CODE (operands[1]) == MEM)
2687 {
2688 rtx tmp = gen_reg_rtx (DImode);
2689 rtx ext = gen_rtx_ZERO_EXTEND (DImode, operands[1]);
2690 emit_insn (gen_rtx_SET (tmp, ext));
2691 operands[1] = gen_lowpart (QImode, tmp);
2692 }
2693 })
2694
2695 (define_insn "*movqi"
2696 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q,v,v,v,d,v,R")
2697 (match_operand:QI 1 "general_operand" " d,n,R,T,d,d,n,n,?Q,K,v,d,v,R,v"))]
2698 ""
2699 "@
2700 lr\t%0,%1
2701 lhi\t%0,%b1
2702 ic\t%0,%1
2703 icy\t%0,%1
2704 stc\t%1,%0
2705 stcy\t%1,%0
2706 mvi\t%S0,%b1
2707 mviy\t%S0,%b1
2708 #
2709 vleib\t%v0,%b1,0
2710 vlr\t%v0,%v1
2711 vlvgb\t%v0,%1,0
2712 vlgvb\t%0,%v1,0
2713 vleb\t%v0,%1,0
2714 vsteb\t%v1,%0,0"
2715 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS,VRI,VRR,VRS,VRS,VRX,VRX")
2716 (set_attr "type" "lr,*,*,*,store,store,store,store,*,*,*,*,*,*,*")
2717 (set_attr "cpu_facility" "*,*,*,longdisp,*,longdisp,*,longdisp,*,vx,vx,vx,vx,vx,vx")
2718 (set_attr "z10prop" "z10_fr_E1,
2719 z10_fwd_A1,
2720 z10_super_E1,
2721 z10_super_E1,
2722 z10_rec,
2723 z10_rec,
2724 z10_super,
2725 z10_super,
2726 *,*,*,*,*,*,*")])
2727
2728 (define_peephole2
2729 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2730 (mem:QI (match_operand 1 "address_operand" "")))]
2731 "GET_CODE (operands[1]) == SYMBOL_REF
2732 && CONSTANT_POOL_ADDRESS_P (operands[1])
2733 && get_pool_mode (operands[1]) == QImode
2734 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2735 [(set (match_dup 0) (match_dup 2))]
2736 "operands[2] = get_pool_constant (operands[1]);")
2737
2738
2739 ;
2740 ; movstrict instruction pattern(s).
2741 ;
2742
2743 (define_insn "movstrictqi"
2744 [(set (strict_low_part (match_operand:QI 0 "subreg_register_operand" "+d,d"))
2745 (match_operand:QI 1 "memory_operand" "R,T"))]
2746 ""
2747 "@
2748 ic\t%0,%1
2749 icy\t%0,%1"
2750 [(set_attr "op_type" "RX,RXY")
2751 (set_attr "cpu_facility" "*,longdisp")
2752 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
2753
2754 (define_insn "movstricthi"
2755 [(set (strict_low_part (match_operand:HI 0 "subreg_register_operand" "+d,d"))
2756 (match_operand:HI 1 "memory_operand" "Q,S"))
2757 (clobber (reg:CC CC_REGNUM))]
2758 ""
2759 "@
2760 icm\t%0,3,%S1
2761 icmy\t%0,3,%S1"
2762 [(set_attr "op_type" "RS,RSY")
2763 (set_attr "cpu_facility" "*,longdisp")
2764 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
2765
2766 (define_insn "movstrictsi"
2767 [(set (strict_low_part (match_operand:SI 0 "subreg_register_operand" "+d,d,d,d"))
2768 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
2769 "TARGET_ZARCH"
2770 "@
2771 lr\t%0,%1
2772 l\t%0,%1
2773 ly\t%0,%1
2774 ear\t%0,%1"
2775 [(set_attr "op_type" "RR,RX,RXY,RRE")
2776 (set_attr "type" "lr,load,load,*")
2777 (set_attr "cpu_facility" "*,*,longdisp,*")
2778 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
2779
2780 ;
2781 ; mov(tf|td) instruction pattern(s).
2782 ;
2783
2784 (define_expand "mov<mode><tf_fpr>"
2785 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2786 (match_operand:TD_TF 1 "general_operand" ""))]
2787 ""
2788 "")
2789
2790 (define_insn "*mov<mode>_64"
2791 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o,d,S, d,o")
2792 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,S,d,dT,d"))]
2793 "TARGET_ZARCH"
2794 "@
2795 lzxr\t%0
2796 lxr\t%0,%1
2797 #
2798 #
2799 lmg\t%0,%N0,%S1
2800 stmg\t%1,%N1,%S0
2801 #
2802 #"
2803 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
2804 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")
2805 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*")])
2806
2807 (define_insn "*mov<mode>_31"
2808 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
2809 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
2810 "!TARGET_ZARCH"
2811 "@
2812 lzxr\t%0
2813 lxr\t%0,%1
2814 #
2815 #"
2816 [(set_attr "op_type" "RRE,RRE,*,*")
2817 (set_attr "type" "fsimptf,fsimptf,*,*")
2818 (set_attr "cpu_facility" "z196,*,*,*")])
2819
2820 ; TFmode in GPRs splitters
2821
2822 (define_split
2823 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2824 (match_operand:TD_TF 1 "general_operand" ""))]
2825 "TARGET_ZARCH && reload_completed
2826 && !s_operand (operands[0], <MODE>mode)
2827 && !s_operand (operands[1], <MODE>mode)
2828 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2829 [(set (match_dup 2) (match_dup 4))
2830 (set (match_dup 3) (match_dup 5))]
2831 {
2832 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2833 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2834 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2835 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2836 })
2837
2838 (define_split
2839 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2840 (match_operand:TD_TF 1 "general_operand" ""))]
2841 "TARGET_ZARCH && reload_completed
2842 && !s_operand (operands[0], <MODE>mode)
2843 && !s_operand (operands[1], <MODE>mode)
2844 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2845 [(set (match_dup 2) (match_dup 4))
2846 (set (match_dup 3) (match_dup 5))]
2847 {
2848 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2849 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2850 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2851 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2852 })
2853
2854 (define_split
2855 [(set (match_operand:TD_TF 0 "register_operand" "")
2856 (match_operand:TD_TF 1 "memory_operand" ""))]
2857 "TARGET_ZARCH && reload_completed
2858 && GENERAL_REG_P (operands[0])
2859 && !s_operand (operands[1], VOIDmode)"
2860 [(set (match_dup 0) (match_dup 1))]
2861 {
2862 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2863 addr = gen_lowpart (Pmode, addr);
2864 s390_load_address (addr, XEXP (operands[1], 0));
2865 operands[1] = replace_equiv_address (operands[1], addr);
2866 })
2867
2868 ; TFmode in BFPs splitters
2869
2870 (define_split
2871 [(set (match_operand:TD_TF 0 "register_operand" "")
2872 (match_operand:TD_TF 1 "memory_operand" ""))]
2873 "reload_completed && offsettable_memref_p (operands[1])
2874 && FP_REG_P (operands[0])"
2875 [(set (match_dup 2) (match_dup 4))
2876 (set (match_dup 3) (match_dup 5))]
2877 {
2878 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2879 <MODE>mode, 0);
2880 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2881 <MODE>mode, 8);
2882 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
2883 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
2884 })
2885
2886 (define_split
2887 [(set (match_operand:TD_TF 0 "memory_operand" "")
2888 (match_operand:TD_TF 1 "register_operand" ""))]
2889 "reload_completed && offsettable_memref_p (operands[0])
2890 && FP_REG_P (operands[1])"
2891 [(set (match_dup 2) (match_dup 4))
2892 (set (match_dup 3) (match_dup 5))]
2893 {
2894 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
2895 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
2896 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2897 <MODE>mode, 0);
2898 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2899 <MODE>mode, 8);
2900 })
2901
2902 ;
2903 ; mov(df|dd) instruction pattern(s).
2904 ;
2905
2906 (define_expand "mov<mode>"
2907 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2908 (match_operand:DD_DF 1 "general_operand" ""))]
2909 ""
2910 "")
2911
2912 (define_insn "*mov<mode>_64dfp"
2913 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2914 "=f,f,f,d,f,f,R,T,d,d,d,d,b,T,v,v,v,d,v,R")
2915 (match_operand:DD_DF 1 "general_operand"
2916 " G,f,d,f,R,T,f,f,G,d,b,T,d,d,v,G,d,v,R,v"))]
2917 "TARGET_DFP"
2918 "@
2919 lzdr\t%0
2920 ldr\t%0,%1
2921 ldgr\t%0,%1
2922 lgdr\t%0,%1
2923 ld\t%0,%1
2924 ldy\t%0,%1
2925 std\t%1,%0
2926 stdy\t%1,%0
2927 lghi\t%0,0
2928 lgr\t%0,%1
2929 lgrl\t%0,%1
2930 lg\t%0,%1
2931 stgrl\t%1,%0
2932 stg\t%1,%0
2933 vlr\t%v0,%v1
2934 vleig\t%v0,0,0
2935 vlvgg\t%v0,%1,0
2936 vlgvg\t%0,%v1,0
2937 vleg\t%0,%1,0
2938 vsteg\t%1,%0,0"
2939 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY,VRR,VRI,VRS,VRS,VRX,VRX")
2940 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
2941 fstoredf,fstoredf,*,lr,load,load,store,store,*,*,*,*,load,store")
2942 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,*,*,*,*,*,*")
2943 (set_attr "cpu_facility" "z196,*,*,*,*,longdisp,*,longdisp,*,*,z10,*,z10,*,vx,vx,vx,vx,vx,vx")
2944 (set_attr "relative_long" "*,*,*,*,*,*,*,*,*,*,yes,*,yes,*,*,*,*,*,*,*")])
2945
2946 (define_insn "*mov<mode>_64"
2947 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,d,d,b,T")
2948 (match_operand:DD_DF 1 "general_operand" " G,f,R,T,f,f,G,d,b,T,d,d"))]
2949 "TARGET_ZARCH"
2950 "@
2951 lzdr\t%0
2952 ldr\t%0,%1
2953 ld\t%0,%1
2954 ldy\t%0,%1
2955 std\t%1,%0
2956 stdy\t%1,%0
2957 lghi\t%0,0
2958 lgr\t%0,%1
2959 lgrl\t%0,%1
2960 lg\t%0,%1
2961 stgrl\t%1,%0
2962 stg\t%1,%0"
2963 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY")
2964 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2965 fstore<mode>,fstore<mode>,*,lr,load,load,store,store")
2966 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
2967 (set_attr "cpu_facility" "z196,*,*,longdisp,*,longdisp,*,*,z10,*,z10,*")
2968 (set_attr "relative_long" "*,*,*,*,*,*,*,*,yes,*,*,*")])
2969
2970 (define_insn "*mov<mode>_31"
2971 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2972 "=f,f,f,f,R,T,d,d,Q,S, d,o")
2973 (match_operand:DD_DF 1 "general_operand"
2974 " G,f,R,T,f,f,Q,S,d,d,dPT,d"))]
2975 "!TARGET_ZARCH"
2976 "@
2977 lzdr\t%0
2978 ldr\t%0,%1
2979 ld\t%0,%1
2980 ldy\t%0,%1
2981 std\t%1,%0
2982 stdy\t%1,%0
2983 lm\t%0,%N0,%S1
2984 lmy\t%0,%N0,%S1
2985 stm\t%1,%N1,%S0
2986 stmy\t%1,%N1,%S0
2987 #
2988 #"
2989 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2990 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2991 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")
2992 (set_attr "cpu_facility" "z196,*,*,longdisp,*,longdisp,*,longdisp,*,longdisp,*,*")])
2993
2994 (define_split
2995 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2996 (match_operand:DD_DF 1 "general_operand" ""))]
2997 "!TARGET_ZARCH && reload_completed
2998 && !s_operand (operands[0], <MODE>mode)
2999 && !s_operand (operands[1], <MODE>mode)
3000 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
3001 [(set (match_dup 2) (match_dup 4))
3002 (set (match_dup 3) (match_dup 5))]
3003 {
3004 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
3005 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
3006 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
3007 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
3008 })
3009
3010 (define_split
3011 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
3012 (match_operand:DD_DF 1 "general_operand" ""))]
3013 "!TARGET_ZARCH && reload_completed
3014 && !s_operand (operands[0], <MODE>mode)
3015 && !s_operand (operands[1], <MODE>mode)
3016 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
3017 [(set (match_dup 2) (match_dup 4))
3018 (set (match_dup 3) (match_dup 5))]
3019 {
3020 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
3021 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
3022 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
3023 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
3024 })
3025
3026 (define_split
3027 [(set (match_operand:DD_DF 0 "register_operand" "")
3028 (match_operand:DD_DF 1 "memory_operand" ""))]
3029 "!TARGET_ZARCH && reload_completed
3030 && !FP_REG_P (operands[0])
3031 && !s_operand (operands[1], VOIDmode)"
3032 [(set (match_dup 0) (match_dup 1))]
3033 {
3034 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
3035 s390_load_address (addr, XEXP (operands[1], 0));
3036 operands[1] = replace_equiv_address (operands[1], addr);
3037 })
3038
3039 ;
3040 ; mov(sf|sd) instruction pattern(s).
3041 ;
3042
3043 (define_insn "mov<mode>"
3044 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
3045 "=f,f,f,f,f,f,R,T,d,d,d,d,d,b,R,T,v,v,v,d,v,R")
3046 (match_operand:SD_SF 1 "general_operand"
3047 " G,f,f,R,R,T,f,f,G,d,b,R,T,d,d,d,v,G,d,v,R,v"))]
3048 ""
3049 "@
3050 lzer\t%0
3051 ldr\t%0,%1
3052 ler\t%0,%1
3053 lde\t%0,%1
3054 le\t%0,%1
3055 ley\t%0,%1
3056 ste\t%1,%0
3057 stey\t%1,%0
3058 lhi\t%0,0
3059 lr\t%0,%1
3060 lrl\t%0,%1
3061 l\t%0,%1
3062 ly\t%0,%1
3063 strl\t%1,%0
3064 st\t%1,%0
3065 sty\t%1,%0
3066 vlr\t%v0,%v1
3067 vleif\t%v0,0,0
3068 vlvgf\t%v0,%1,0
3069 vlgvf\t%0,%v1,0
3070 vlef\t%0,%1,0
3071 vstef\t%1,%0,0"
3072 [(set_attr "op_type" "RRE,RR,RR,RXE,RX,RXY,RX,RXY,RI,RR,RIL,RX,RXY,RIL,RX,RXY,VRR,VRI,VRS,VRS,VRX,VRX")
3073 (set_attr "type" "fsimpsf,fsimpsf,fload<mode>,fload<mode>,fload<mode>,fload<mode>,
3074 fstore<mode>,fstore<mode>,*,lr,load,load,load,store,store,store,*,*,*,*,load,store")
3075 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,z10_rec,*,*,*,*,*,*")
3076 (set_attr "cpu_facility" "z196,vx,*,vx,*,longdisp,*,longdisp,*,*,z10,*,longdisp,z10,*,longdisp,vx,vx,vx,vx,vx,vx")
3077 (set_attr "relative_long" "*,*,*,*,*,*,*,*,*,*,yes,*,*,yes,*,*,*,*,*,*,*,*")])
3078
3079 ;
3080 ; movcc instruction pattern
3081 ;
3082
3083 (define_insn "movcc"
3084 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
3085 (match_operand:CC 1 "nonimmediate_operand" " d,d,c,R,T,d,d"))]
3086 ""
3087 "@
3088 lr\t%0,%1
3089 tmh\t%1,12288
3090 ipm\t%0
3091 l\t%0,%1
3092 ly\t%0,%1
3093 st\t%1,%0
3094 sty\t%1,%0"
3095 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
3096 (set_attr "type" "lr,*,*,load,load,store,store")
3097 (set_attr "cpu_facility" "*,*,*,*,longdisp,*,longdisp")
3098 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
3099 (set_attr "z196prop" "*,*,z196_ends,*,*,*,*")])
3100
3101 ;
3102 ; Block move (MVC) patterns.
3103 ;
3104
3105 (define_insn "*mvc"
3106 [(set (match_operand:BLK 0 "memory_operand" "=Q")
3107 (match_operand:BLK 1 "memory_operand" "Q"))
3108 (use (match_operand 2 "const_int_operand" "n"))]
3109 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
3110 "mvc\t%O0(%2,%R0),%S1"
3111 [(set_attr "op_type" "SS")])
3112
3113 ; This splitter converts a QI to QI mode copy into a BLK mode copy in
3114 ; order to have it implemented with mvc.
3115
3116 (define_split
3117 [(set (match_operand:QI 0 "memory_operand" "")
3118 (match_operand:QI 1 "memory_operand" ""))]
3119 "reload_completed"
3120 [(parallel
3121 [(set (match_dup 0) (match_dup 1))
3122 (use (const_int 1))])]
3123 {
3124 operands[0] = adjust_address (operands[0], BLKmode, 0);
3125 operands[1] = adjust_address (operands[1], BLKmode, 0);
3126 })
3127
3128
3129 (define_peephole2
3130 [(parallel
3131 [(set (match_operand:BLK 0 "memory_operand" "")
3132 (match_operand:BLK 1 "memory_operand" ""))
3133 (use (match_operand 2 "const_int_operand" ""))])
3134 (parallel
3135 [(set (match_operand:BLK 3 "memory_operand" "")
3136 (match_operand:BLK 4 "memory_operand" ""))
3137 (use (match_operand 5 "const_int_operand" ""))])]
3138 "((INTVAL (operands[2]) > 16 && INTVAL (operands[5]) > 16)
3139 || (INTVAL (operands[2]) + INTVAL (operands[5]) <= 16))
3140 && s390_offset_p (operands[0], operands[3], operands[2])
3141 && s390_offset_p (operands[1], operands[4], operands[2])
3142 && !s390_overlap_p (operands[0], operands[1],
3143 INTVAL (operands[2]) + INTVAL (operands[5]))
3144 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
3145 [(parallel
3146 [(set (match_dup 6) (match_dup 7))
3147 (use (match_dup 8))])]
3148 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
3149 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
3150 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
3151
3152 (define_peephole2
3153 [(parallel
3154 [(set (match_operand:BLK 0 "plus16_Q_operand" "")
3155 (match_operand:BLK 1 "plus16_Q_operand" ""))
3156 (use (match_operand 2 "const_int_operand" ""))])]
3157 "INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32"
3158 [(parallel
3159 [(set (match_dup 0) (match_dup 1))
3160 (use (const_int 16))])
3161 (parallel
3162 [(set (match_dup 3) (match_dup 4))
3163 (use (match_dup 5))])]
3164 "operands[3] = change_address (operands[0], VOIDmode,
3165 plus_constant (Pmode, XEXP (operands[0], 0), 16));
3166 operands[4] = change_address (operands[1], VOIDmode,
3167 plus_constant (Pmode, XEXP (operands[1], 0), 16));
3168 operands[5] = GEN_INT (INTVAL (operands[2]) - 16);")
3169
3170
3171 ;
3172 ; load_multiple pattern(s).
3173 ;
3174 ; ??? Due to reload problems with replacing registers inside match_parallel
3175 ; we currently support load_multiple/store_multiple only after reload.
3176 ;
3177
3178 (define_expand "load_multiple"
3179 [(match_par_dup 3 [(set (match_operand 0 "" "")
3180 (match_operand 1 "" ""))
3181 (use (match_operand 2 "" ""))])]
3182 "reload_completed"
3183 {
3184 machine_mode mode;
3185 int regno;
3186 int count;
3187 rtx from;
3188 int i, off;
3189
3190 /* Support only loading a constant number of fixed-point registers from
3191 memory and only bother with this if more than two */
3192 if (GET_CODE (operands[2]) != CONST_INT
3193 || INTVAL (operands[2]) < 2
3194 || INTVAL (operands[2]) > 16
3195 || GET_CODE (operands[1]) != MEM
3196 || GET_CODE (operands[0]) != REG
3197 || REGNO (operands[0]) >= 16)
3198 FAIL;
3199
3200 count = INTVAL (operands[2]);
3201 regno = REGNO (operands[0]);
3202 mode = GET_MODE (operands[0]);
3203 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
3204 FAIL;
3205
3206 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
3207 if (!can_create_pseudo_p ())
3208 {
3209 if (GET_CODE (XEXP (operands[1], 0)) == REG)
3210 {
3211 from = XEXP (operands[1], 0);
3212 off = 0;
3213 }
3214 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
3215 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
3216 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
3217 {
3218 from = XEXP (XEXP (operands[1], 0), 0);
3219 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
3220 }
3221 else
3222 FAIL;
3223 }
3224 else
3225 {
3226 from = force_reg (Pmode, XEXP (operands[1], 0));
3227 off = 0;
3228 }
3229
3230 for (i = 0; i < count; i++)
3231 XVECEXP (operands[3], 0, i)
3232 = gen_rtx_SET (gen_rtx_REG (mode, regno + i),
3233 change_address (operands[1], mode,
3234 plus_constant (Pmode, from,
3235 off + i * GET_MODE_SIZE (mode))));
3236 })
3237
3238 (define_insn "*load_multiple_di"
3239 [(match_parallel 0 "load_multiple_operation"
3240 [(set (match_operand:DI 1 "register_operand" "=r")
3241 (match_operand:DI 2 "s_operand" "S"))])]
3242 "reload_completed && TARGET_ZARCH"
3243 {
3244 int words = XVECLEN (operands[0], 0);
3245 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
3246 return "lmg\t%1,%0,%S2";
3247 }
3248 [(set_attr "op_type" "RSY")
3249 (set_attr "type" "lm")])
3250
3251 (define_insn "*load_multiple_si"
3252 [(match_parallel 0 "load_multiple_operation"
3253 [(set (match_operand:SI 1 "register_operand" "=r,r")
3254 (match_operand:SI 2 "s_operand" "Q,S"))])]
3255 "reload_completed"
3256 {
3257 int words = XVECLEN (operands[0], 0);
3258 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
3259 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
3260 }
3261 [(set_attr "op_type" "RS,RSY")
3262 (set_attr "cpu_facility" "*,longdisp")
3263 (set_attr "type" "lm")])
3264
3265 ;
3266 ; store multiple pattern(s).
3267 ;
3268
3269 (define_expand "store_multiple"
3270 [(match_par_dup 3 [(set (match_operand 0 "" "")
3271 (match_operand 1 "" ""))
3272 (use (match_operand 2 "" ""))])]
3273 "reload_completed"
3274 {
3275 machine_mode mode;
3276 int regno;
3277 int count;
3278 rtx to;
3279 int i, off;
3280
3281 /* Support only storing a constant number of fixed-point registers to
3282 memory and only bother with this if more than two. */
3283 if (GET_CODE (operands[2]) != CONST_INT
3284 || INTVAL (operands[2]) < 2
3285 || INTVAL (operands[2]) > 16
3286 || GET_CODE (operands[0]) != MEM
3287 || GET_CODE (operands[1]) != REG
3288 || REGNO (operands[1]) >= 16)
3289 FAIL;
3290
3291 count = INTVAL (operands[2]);
3292 regno = REGNO (operands[1]);
3293 mode = GET_MODE (operands[1]);
3294 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
3295 FAIL;
3296
3297 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
3298
3299 if (!can_create_pseudo_p ())
3300 {
3301 if (GET_CODE (XEXP (operands[0], 0)) == REG)
3302 {
3303 to = XEXP (operands[0], 0);
3304 off = 0;
3305 }
3306 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
3307 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
3308 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
3309 {
3310 to = XEXP (XEXP (operands[0], 0), 0);
3311 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
3312 }
3313 else
3314 FAIL;
3315 }
3316 else
3317 {
3318 to = force_reg (Pmode, XEXP (operands[0], 0));
3319 off = 0;
3320 }
3321
3322 for (i = 0; i < count; i++)
3323 XVECEXP (operands[3], 0, i)
3324 = gen_rtx_SET (change_address (operands[0], mode,
3325 plus_constant (Pmode, to,
3326 off + i * GET_MODE_SIZE (mode))),
3327 gen_rtx_REG (mode, regno + i));
3328 })
3329
3330 (define_insn "*store_multiple_di"
3331 [(match_parallel 0 "store_multiple_operation"
3332 [(set (match_operand:DI 1 "s_operand" "=S")
3333 (match_operand:DI 2 "register_operand" "r"))])]
3334 "reload_completed && TARGET_ZARCH"
3335 {
3336 int words = XVECLEN (operands[0], 0);
3337 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
3338 return "stmg\t%2,%0,%S1";
3339 }
3340 [(set_attr "op_type" "RSY")
3341 (set_attr "type" "stm")])
3342
3343
3344 (define_insn "*store_multiple_si"
3345 [(match_parallel 0 "store_multiple_operation"
3346 [(set (match_operand:SI 1 "s_operand" "=Q,S")
3347 (match_operand:SI 2 "register_operand" "r,r"))])]
3348 "reload_completed"
3349 {
3350 int words = XVECLEN (operands[0], 0);
3351 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
3352 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
3353 }
3354 [(set_attr "op_type" "RS,RSY")
3355 (set_attr "cpu_facility" "*,longdisp")
3356 (set_attr "type" "stm")])
3357
3358 ;;
3359 ;; String instructions.
3360 ;;
3361
3362 (define_insn "*execute_rl"
3363 [(match_parallel 0 "execute_operation"
3364 [(unspec [(match_operand 1 "register_operand" "a")
3365 (match_operand 2 "" "")
3366 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
3367 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
3368 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
3369 "exrl\t%1,%3"
3370 [(set_attr "op_type" "RIL")
3371 (set_attr "type" "cs")
3372 (set_attr "relative_long" "yes")])
3373
3374 (define_insn "*execute"
3375 [(match_parallel 0 "execute_operation"
3376 [(unspec [(match_operand 1 "register_operand" "a")
3377 (match_operand:BLK 2 "memory_operand" "R")
3378 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
3379 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
3380 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
3381 "ex\t%1,%2"
3382 [(set_attr "op_type" "RX")
3383 (set_attr "type" "cs")])
3384
3385
3386 ;
3387 ; strlenM instruction pattern(s).
3388 ;
3389
3390 (define_expand "strlen<mode>"
3391 [(match_operand:P 0 "register_operand" "") ; result
3392 (match_operand:BLK 1 "memory_operand" "") ; input string
3393 (match_operand:SI 2 "immediate_operand" "") ; search character
3394 (match_operand:SI 3 "immediate_operand" "")] ; known alignment
3395 ""
3396 {
3397 if (!TARGET_VX || operands[2] != const0_rtx)
3398 emit_insn (gen_strlen_srst<mode> (operands[0], operands[1],
3399 operands[2], operands[3]));
3400 else
3401 s390_expand_vec_strlen (operands[0], operands[1], operands[3]);
3402
3403 DONE;
3404 })
3405
3406 (define_expand "strlen_srst<mode>"
3407 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
3408 (parallel
3409 [(set (match_dup 4)
3410 (unspec:P [(const_int 0)
3411 (match_operand:BLK 1 "memory_operand" "")
3412 (reg:SI 0)
3413 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
3414 (clobber (scratch:P))
3415 (clobber (reg:CC CC_REGNUM))])
3416 (parallel
3417 [(set (match_operand:P 0 "register_operand" "")
3418 (minus:P (match_dup 4) (match_dup 5)))
3419 (clobber (reg:CC CC_REGNUM))])]
3420 ""
3421 {
3422 operands[4] = gen_reg_rtx (Pmode);
3423 operands[5] = gen_reg_rtx (Pmode);
3424 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
3425 operands[1] = replace_equiv_address (operands[1], operands[5]);
3426 })
3427
3428 (define_insn "*strlen<mode>"
3429 [(set (match_operand:P 0 "register_operand" "=a")
3430 (unspec:P [(match_operand:P 2 "general_operand" "0")
3431 (mem:BLK (match_operand:P 3 "register_operand" "1"))
3432 (reg:SI 0)
3433 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
3434 (clobber (match_scratch:P 1 "=a"))
3435 (clobber (reg:CC CC_REGNUM))]
3436 ""
3437 "srst\t%0,%1\;jo\t.-4"
3438 [(set_attr "length" "8")
3439 (set_attr "type" "vs")])
3440
3441 ;
3442 ; cmpstrM instruction pattern(s).
3443 ;
3444
3445 (define_expand "cmpstrsi"
3446 [(set (reg:SI 0) (const_int 0))
3447 (parallel
3448 [(clobber (match_operand 3 "" ""))
3449 (clobber (match_dup 4))
3450 (set (reg:CCU CC_REGNUM)
3451 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
3452 (match_operand:BLK 2 "memory_operand" "")))
3453 (use (reg:SI 0))])
3454 (parallel
3455 [(set (match_operand:SI 0 "register_operand" "=d")
3456 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_STRCMPCC_TO_INT))
3457 (clobber (reg:CC CC_REGNUM))])]
3458 ""
3459 {
3460 /* As the result of CMPINT is inverted compared to what we need,
3461 we have to swap the operands. */
3462 rtx op1 = operands[2];
3463 rtx op2 = operands[1];
3464 rtx addr1 = gen_reg_rtx (Pmode);
3465 rtx addr2 = gen_reg_rtx (Pmode);
3466
3467 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
3468 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
3469 operands[1] = replace_equiv_address_nv (op1, addr1);
3470 operands[2] = replace_equiv_address_nv (op2, addr2);
3471 operands[3] = addr1;
3472 operands[4] = addr2;
3473 })
3474
3475 (define_insn "*cmpstr<mode>"
3476 [(clobber (match_operand:P 0 "register_operand" "=d"))
3477 (clobber (match_operand:P 1 "register_operand" "=d"))
3478 (set (reg:CCU CC_REGNUM)
3479 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
3480 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
3481 (use (reg:SI 0))]
3482 ""
3483 "clst\t%0,%1\;jo\t.-4"
3484 [(set_attr "length" "8")
3485 (set_attr "type" "vs")])
3486
3487 ;
3488 ; movstr instruction pattern.
3489 ;
3490
3491 (define_expand "movstr"
3492 [(match_operand 0 "register_operand" "")
3493 (match_operand 1 "memory_operand" "")
3494 (match_operand 2 "memory_operand" "")]
3495 ""
3496 {
3497 if (TARGET_64BIT)
3498 emit_insn (gen_movstrdi (operands[0], operands[1], operands[2]));
3499 else
3500 emit_insn (gen_movstrsi (operands[0], operands[1], operands[2]));
3501 DONE;
3502 })
3503
3504 (define_expand "movstr<P:mode>"
3505 [(set (reg:SI 0) (const_int 0))
3506 (parallel
3507 [(clobber (match_dup 3))
3508 (set (match_operand:BLK 1 "memory_operand" "")
3509 (match_operand:BLK 2 "memory_operand" ""))
3510 (set (match_operand:P 0 "register_operand" "")
3511 (unspec:P [(match_dup 1)
3512 (match_dup 2)
3513 (reg:SI 0)] UNSPEC_MVST))
3514 (clobber (reg:CC CC_REGNUM))])]
3515 ""
3516 {
3517 rtx addr1, addr2;
3518
3519 if (TARGET_VX && optimize_function_for_speed_p (cfun))
3520 {
3521 s390_expand_vec_movstr (operands[0], operands[1], operands[2]);
3522 DONE;
3523 }
3524
3525 addr1 = gen_reg_rtx (Pmode);
3526 addr2 = gen_reg_rtx (Pmode);
3527
3528 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3529 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
3530 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3531 operands[2] = replace_equiv_address_nv (operands[2], addr2);
3532 operands[3] = addr2;
3533 })
3534
3535 (define_insn "*movstr"
3536 [(clobber (match_operand:P 2 "register_operand" "=d"))
3537 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
3538 (mem:BLK (match_operand:P 3 "register_operand" "2")))
3539 (set (match_operand:P 0 "register_operand" "=d")
3540 (unspec:P [(mem:BLK (match_dup 1))
3541 (mem:BLK (match_dup 3))
3542 (reg:SI 0)] UNSPEC_MVST))
3543 (clobber (reg:CC CC_REGNUM))]
3544 ""
3545 "mvst\t%1,%2\;jo\t.-4"
3546 [(set_attr "length" "8")
3547 (set_attr "type" "vs")])
3548
3549
3550 ;
3551 ; cpymemM instruction pattern(s).
3552 ;
3553
3554 (define_expand "cpymem<mode>"
3555 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
3556 (match_operand:BLK 1 "memory_operand" "")) ; source
3557 (use (match_operand:GPR 2 "general_operand" "")) ; size
3558 (match_operand 3 "") ; align
3559 (match_operand 4 "") ; expected align
3560 (match_operand 5 "") ; expected size
3561 (match_operand 6 "") ; minimal size
3562 (match_operand 7 "")] ; maximal size
3563 ""
3564 {
3565 if (s390_expand_cpymem (operands[0], operands[1], operands[2], operands[6], operands[7]))
3566 DONE;
3567 else
3568 FAIL;
3569 })
3570
3571 ; Move a block that is up to 256 bytes in length.
3572 ; The block length is taken as (operands[2] % 256) + 1.
3573
3574 (define_expand "cpymem_short"
3575 [(parallel
3576 [(set (match_operand:BLK 0 "memory_operand" "")
3577 (match_operand:BLK 1 "memory_operand" ""))
3578 (use (match_operand 2 "nonmemory_operand" ""))
3579 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3580 (clobber (match_dup 3))])]
3581 ""
3582 "operands[3] = gen_rtx_SCRATCH (Pmode);")
3583
3584 (define_insn "*cpymem_short"
3585 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
3586 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
3587 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3588 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
3589 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3590 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
3591 "#"
3592 [(set_attr "type" "cs")
3593 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
3594
3595 (define_split
3596 [(set (match_operand:BLK 0 "memory_operand" "")
3597 (match_operand:BLK 1 "memory_operand" ""))
3598 (use (match_operand 2 "const_int_operand" ""))
3599 (use (match_operand 3 "immediate_operand" ""))
3600 (clobber (match_scratch 4))]
3601 "reload_completed"
3602 [(parallel
3603 [(set (match_dup 0) (match_dup 1))
3604 (use (match_dup 2))])]
3605 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
3606
3607 (define_split
3608 [(set (match_operand:BLK 0 "memory_operand" "")
3609 (match_operand:BLK 1 "memory_operand" ""))
3610 (use (match_operand 2 "register_operand" ""))
3611 (use (match_operand 3 "memory_operand" ""))
3612 (clobber (match_scratch 4))]
3613 "reload_completed"
3614 [(parallel
3615 [(unspec [(match_dup 2) (match_dup 3)
3616 (const_int 0)] UNSPEC_EXECUTE)
3617 (set (match_dup 0) (match_dup 1))
3618 (use (const_int 1))])]
3619 "")
3620
3621 (define_split
3622 [(set (match_operand:BLK 0 "memory_operand" "")
3623 (match_operand:BLK 1 "memory_operand" ""))
3624 (use (match_operand 2 "register_operand" ""))
3625 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3626 (clobber (match_scratch 3))]
3627 "TARGET_Z10 && reload_completed"
3628 [(parallel
3629 [(unspec [(match_dup 2) (const_int 0)
3630 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3631 (set (match_dup 0) (match_dup 1))
3632 (use (const_int 1))])]
3633 "operands[4] = gen_label_rtx ();")
3634
3635 (define_split
3636 [(set (match_operand:BLK 0 "memory_operand" "")
3637 (match_operand:BLK 1 "memory_operand" ""))
3638 (use (match_operand 2 "register_operand" ""))
3639 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3640 (clobber (match_operand 3 "register_operand" ""))]
3641 "reload_completed"
3642 [(set (match_dup 3) (label_ref (match_dup 4)))
3643 (parallel
3644 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
3645 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3646 (set (match_dup 0) (match_dup 1))
3647 (use (const_int 1))])]
3648 "operands[4] = gen_label_rtx ();")
3649
3650 ; Move a block of arbitrary length.
3651
3652 (define_expand "cpymem_long"
3653 [(parallel
3654 [(clobber (match_dup 2))
3655 (clobber (match_dup 3))
3656 (set (match_operand:BLK 0 "memory_operand" "")
3657 (match_operand:BLK 1 "memory_operand" ""))
3658 (use (match_operand 2 "general_operand" ""))
3659 (use (match_dup 3))
3660 (clobber (reg:CC CC_REGNUM))])]
3661 ""
3662 {
3663 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3664 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
3665 rtx reg0 = gen_reg_rtx (dreg_mode);
3666 rtx reg1 = gen_reg_rtx (dreg_mode);
3667 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3668 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
3669 rtx len0 = gen_lowpart (Pmode, reg0);
3670 rtx len1 = gen_lowpart (Pmode, reg1);
3671
3672 emit_clobber (reg0);
3673 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3674 emit_move_insn (len0, operands[2]);
3675
3676 emit_clobber (reg1);
3677 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3678 emit_move_insn (len1, operands[2]);
3679
3680 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3681 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3682 operands[2] = reg0;
3683 operands[3] = reg1;
3684 })
3685
3686 (define_insn "*cpymem_long"
3687 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3688 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3689 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3690 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
3691 (use (match_dup 2))
3692 (use (match_dup 3))
3693 (clobber (reg:CC CC_REGNUM))]
3694 "TARGET_64BIT || !TARGET_ZARCH"
3695 "mvcle\t%0,%1,0\;jo\t.-4"
3696 [(set_attr "length" "8")
3697 (set_attr "type" "vs")])
3698
3699 (define_insn "*cpymem_long_31z"
3700 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3701 (clobber (match_operand:TI 1 "register_operand" "=d"))
3702 (set (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3703 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4)))
3704 (use (match_dup 2))
3705 (use (match_dup 3))
3706 (clobber (reg:CC CC_REGNUM))]
3707 "!TARGET_64BIT && TARGET_ZARCH"
3708 "mvcle\t%0,%1,0\;jo\t.-4"
3709 [(set_attr "length" "8")
3710 (set_attr "type" "vs")])
3711
3712 (define_expand "movmem<mode>"
3713 [(set (match_operand:BLK 0 "memory_operand") ; destination
3714 (match_operand:BLK 1 "memory_operand")) ; source
3715 (use (match_operand:GPR 2 "general_operand")) ; size
3716 (match_operand 3 "") ; align
3717 (match_operand 4 "") ; expected align
3718 (match_operand 5 "") ; expected size
3719 (match_operand 6 "") ; minimal size
3720 (match_operand 7 "")] ; maximal size
3721 ""
3722 {
3723 if (s390_expand_movmem (operands[0], operands[1], operands[2], operands[6], operands[7]))
3724 DONE;
3725 else
3726 FAIL;
3727 })
3728
3729 (define_insn "*mvcrl"
3730 [(set (match_operand:BLK 0 "memory_operand" "=Q")
3731 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "Q")
3732 (reg:SI GPR0_REGNUM)]
3733 UNSPEC_MVCRL))]
3734 "TARGET_Z15"
3735 "mvcrl\t%0,%1"
3736 [(set_attr "op_type" "SSE")])
3737
3738 (define_expand "mvcrl"
3739 [(set (reg:SI GPR0_REGNUM) (match_operand:SI 2 "general_operand"))
3740 (set (match_operand:BLK 0 "memory_operand" "=Q")
3741 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "Q")
3742 (reg:SI GPR0_REGNUM)]
3743 UNSPEC_MVCRL))]
3744 "TARGET_Z15"
3745 "")
3746
3747 ;
3748 ; Test data class.
3749 ;
3750
3751 (define_expand "<TDC_CLASS:tdc_insn><mode>2<tf_fpr>"
3752 [(set (reg:CCZ CC_REGNUM)
3753 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3754 (const_int TDC_CLASS)]
3755 UNSPEC_TDC_INSN))
3756 (set (match_operand:SI 0 "register_operand" "=d")
3757 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
3758 "TARGET_HARD_FLOAT")
3759
3760 (define_expand "isnormal<mode>2<tf_fpr>"
3761 [(set (reg:CCZ CC_REGNUM)
3762 (unspec:CCZ [(match_operand:BFP 1 "register_operand" "f")
3763 (const_int S390_TDC_NORMAL_BFP)]
3764 UNSPEC_TDC_INSN))
3765 (set (match_operand:SI 0 "register_operand" "=d")
3766 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
3767 "TARGET_HARD_FLOAT")
3768
3769 (define_expand "isnormal<mode>2"
3770 [(set (reg:CCZ CC_REGNUM)
3771 (unspec:CCZ [(match_operand:DFP_ALL 1 "register_operand" "f")
3772 (const_int S390_TDC_NORMAL_DFP)]
3773 UNSPEC_TDC_INSN))
3774 (set (match_operand:SI 0 "register_operand" "=d")
3775 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
3776 "TARGET_HARD_DFP")
3777
3778 ; This extracts CC into a GPR properly shifted. The actual IPM
3779 ; instruction will be issued by reload. The constraint of operand 1
3780 ; forces reload to use a GPR. So reload will issue a movcc insn for
3781 ; copying CC into a GPR first.
3782 (define_insn_and_split "*cc_to_int"
3783 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3784 (unspec:SI [(match_operand 1 "register_operand" "0")]
3785 UNSPEC_CC_TO_INT))]
3786 ""
3787 "#"
3788 "reload_completed"
3789 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
3790
3791 ; This insn is used to generate all variants of the Test Data Class
3792 ; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
3793 ; is the register to be tested and the second one is the bit mask
3794 ; specifying the required test(s).
3795 ;
3796 ; tcxb, tcdb, tceb, tdcxt, tdcdt, tdcet
3797 (define_insn "*TDC_insn_<mode>"
3798 [(set (reg:CCZ CC_REGNUM)
3799 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
3800 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
3801 "TARGET_HARD_FLOAT"
3802 "t<_d>c<xde><bt>\t%0,%1"
3803 [(set_attr "op_type" "RXE")
3804 (set_attr "type" "fsimp<type>")])
3805
3806
3807
3808 ;
3809 ; setmemM instruction pattern(s).
3810 ;
3811
3812 (define_expand "setmem<mode>"
3813 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
3814 (match_operand:QI 2 "general_operand" "")) ; value
3815 (use (match_operand:GPR 1 "general_operand" "")) ; size
3816 (match_operand 3 "") ; align
3817 (match_operand 4 "") ; expected align
3818 (match_operand 5 "") ; expected size
3819 (match_operand 6 "") ; minimal size
3820 (match_operand 7 "")] ; maximal size
3821 ""
3822 "s390_expand_setmem (operands[0], operands[1], operands[2], operands[6], operands[7]); DONE;")
3823
3824 ; Clear a block that is up to 256 bytes in length.
3825 ; The block length is taken as (operands[1] % 256) + 1.
3826
3827 (define_expand "clrmem_short"
3828 [(parallel
3829 [(set (match_operand:BLK 0 "memory_operand" "")
3830 (const_int 0))
3831 (use (match_operand 1 "nonmemory_operand" ""))
3832 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3833 (clobber (match_dup 2))
3834 (clobber (reg:CC CC_REGNUM))])]
3835 ""
3836 "operands[2] = gen_rtx_SCRATCH (Pmode);")
3837
3838 (define_insn "*clrmem_short"
3839 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
3840 (const_int 0))
3841 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
3842 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
3843 (clobber (match_scratch:P 3 "=X,X,X,&a"))
3844 (clobber (reg:CC CC_REGNUM))]
3845 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)"
3846 "#"
3847 [(set_attr "type" "cs")
3848 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
3849
3850 (define_split
3851 [(set (match_operand:BLK 0 "memory_operand" "")
3852 (const_int 0))
3853 (use (match_operand 1 "const_int_operand" ""))
3854 (use (match_operand 2 "immediate_operand" ""))
3855 (clobber (match_scratch 3))
3856 (clobber (reg:CC CC_REGNUM))]
3857 "reload_completed"
3858 [(parallel
3859 [(set (match_dup 0) (const_int 0))
3860 (use (match_dup 1))
3861 (clobber (reg:CC CC_REGNUM))])]
3862 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
3863
3864 (define_split
3865 [(set (match_operand:BLK 0 "memory_operand" "")
3866 (const_int 0))
3867 (use (match_operand 1 "register_operand" ""))
3868 (use (match_operand 2 "memory_operand" ""))
3869 (clobber (match_scratch 3))
3870 (clobber (reg:CC CC_REGNUM))]
3871 "reload_completed"
3872 [(parallel
3873 [(unspec [(match_dup 1) (match_dup 2)
3874 (const_int 0)] UNSPEC_EXECUTE)
3875 (set (match_dup 0) (const_int 0))
3876 (use (const_int 1))
3877 (clobber (reg:CC CC_REGNUM))])]
3878 "")
3879
3880 (define_split
3881 [(set (match_operand:BLK 0 "memory_operand" "")
3882 (const_int 0))
3883 (use (match_operand 1 "register_operand" ""))
3884 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3885 (clobber (match_scratch 2))
3886 (clobber (reg:CC CC_REGNUM))]
3887 "TARGET_Z10 && reload_completed"
3888 [(parallel
3889 [(unspec [(match_dup 1) (const_int 0)
3890 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3891 (set (match_dup 0) (const_int 0))
3892 (use (const_int 1))
3893 (clobber (reg:CC CC_REGNUM))])]
3894 "operands[3] = gen_label_rtx ();")
3895
3896 (define_split
3897 [(set (match_operand:BLK 0 "memory_operand" "")
3898 (const_int 0))
3899 (use (match_operand 1 "register_operand" ""))
3900 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3901 (clobber (match_operand 2 "register_operand" ""))
3902 (clobber (reg:CC CC_REGNUM))]
3903 "reload_completed"
3904 [(set (match_dup 2) (label_ref (match_dup 3)))
3905 (parallel
3906 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
3907 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3908 (set (match_dup 0) (const_int 0))
3909 (use (const_int 1))
3910 (clobber (reg:CC CC_REGNUM))])]
3911 "operands[3] = gen_label_rtx ();")
3912
3913 ; Initialize a block of arbitrary length with (operands[2] % 256).
3914
3915 (define_expand "setmem_long_<P:mode>"
3916 [(parallel
3917 [(clobber (match_dup 1))
3918 (set (match_operand:BLK 0 "memory_operand" "")
3919 (unspec:BLK [(match_operand:P 2 "setmem_operand" "")
3920 (match_dup 4)] UNSPEC_REPLICATE_BYTE))
3921 (use (match_dup 3))
3922 (clobber (reg:CC CC_REGNUM))])]
3923 ""
3924 {
3925 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3926 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
3927 rtx reg0 = gen_reg_rtx (dreg_mode);
3928 rtx reg1 = gen_reg_rtx (dreg_mode);
3929 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3930 rtx len0 = gen_lowpart (Pmode, reg0);
3931
3932 emit_clobber (reg0);
3933 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3934 emit_move_insn (len0, operands[1]);
3935
3936 emit_move_insn (reg1, const0_rtx);
3937
3938 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3939 operands[1] = reg0;
3940 operands[3] = reg1;
3941 operands[4] = gen_lowpart (Pmode, operands[1]);
3942 })
3943
3944 ; Patterns for 31 bit + Esa and 64 bit + Zarch.
3945
3946 (define_insn "*setmem_long"
3947 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3948 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3949 (unspec:BLK [(match_operand:P 2 "setmem_operand" "Y")
3950 (subreg:P (match_dup 3) <modesize>)]
3951 UNSPEC_REPLICATE_BYTE))
3952 (use (match_operand:<DBL> 1 "register_operand" "d"))
3953 (clobber (reg:CC CC_REGNUM))]
3954 "TARGET_64BIT || !TARGET_ZARCH"
3955 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3956 [(set_attr "length" "8")
3957 (set_attr "type" "vs")])
3958
3959 (define_insn "*setmem_long_and"
3960 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3961 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3962 (unspec:BLK [(zero_extend:P (match_operand:QI 2 "setmem_operand" "Y"))
3963 (subreg:P (match_dup 3) <modesize>)]
3964 UNSPEC_REPLICATE_BYTE))
3965 (use (match_operand:<DBL> 1 "register_operand" "d"))
3966 (clobber (reg:CC CC_REGNUM))]
3967 "(TARGET_64BIT || !TARGET_ZARCH)"
3968 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3969 [(set_attr "length" "8")
3970 (set_attr "type" "vs")])
3971
3972 ; Variants for 31 bit + Zarch, necessary because of the odd in-register offsets
3973 ; of the SImode subregs.
3974
3975 (define_insn "*setmem_long_31z"
3976 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3977 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
3978 (unspec:BLK [(match_operand:SI 2 "setmem_operand" "Y")
3979 (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
3980 (use (match_operand:TI 1 "register_operand" "d"))
3981 (clobber (reg:CC CC_REGNUM))]
3982 "!TARGET_64BIT && TARGET_ZARCH"
3983 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3984 [(set_attr "length" "8")
3985 (set_attr "type" "vs")])
3986
3987 (define_insn "*setmem_long_and_31z"
3988 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3989 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
3990 (unspec:BLK [(zero_extend:SI (match_operand:QI 2 "setmem_operand" "Y"))
3991 (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
3992 (use (match_operand:TI 1 "register_operand" "d"))
3993 (clobber (reg:CC CC_REGNUM))]
3994 "(!TARGET_64BIT && TARGET_ZARCH)"
3995 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3996 [(set_attr "length" "8")
3997 (set_attr "type" "vs")])
3998
3999 ;
4000 ; cmpmemM instruction pattern(s).
4001 ;
4002
4003 (define_expand "cmpmemsi"
4004 [(set (match_operand:SI 0 "register_operand" "")
4005 (compare:SI (match_operand:BLK 1 "memory_operand" "")
4006 (match_operand:BLK 2 "memory_operand" "") ) )
4007 (use (match_operand:SI 3 "general_operand" ""))
4008 (use (match_operand:SI 4 "" ""))]
4009 ""
4010 {
4011 if (s390_expand_cmpmem (operands[0], operands[1],
4012 operands[2], operands[3]))
4013 DONE;
4014 else
4015 FAIL;
4016 })
4017
4018 ; Compare a block that is up to 256 bytes in length.
4019 ; The block length is taken as (operands[2] % 256) + 1.
4020
4021 (define_expand "cmpmem_short"
4022 [(parallel
4023 [(set (reg:CCU CC_REGNUM)
4024 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
4025 (match_operand:BLK 1 "memory_operand" "")))
4026 (use (match_operand 2 "nonmemory_operand" ""))
4027 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
4028 (clobber (match_dup 3))])]
4029 ""
4030 "operands[3] = gen_rtx_SCRATCH (Pmode);")
4031
4032 (define_insn "*cmpmem_short"
4033 [(set (reg:CCU CC_REGNUM)
4034 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
4035 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
4036 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
4037 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
4038 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
4039 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
4040 "#"
4041 [(set_attr "type" "cs")
4042 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
4043
4044 (define_split
4045 [(set (reg:CCU CC_REGNUM)
4046 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
4047 (match_operand:BLK 1 "memory_operand" "")))
4048 (use (match_operand 2 "const_int_operand" ""))
4049 (use (match_operand 3 "immediate_operand" ""))
4050 (clobber (match_scratch 4))]
4051 "reload_completed"
4052 [(parallel
4053 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
4054 (use (match_dup 2))])]
4055 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
4056
4057 (define_split
4058 [(set (reg:CCU CC_REGNUM)
4059 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
4060 (match_operand:BLK 1 "memory_operand" "")))
4061 (use (match_operand 2 "register_operand" ""))
4062 (use (match_operand 3 "memory_operand" ""))
4063 (clobber (match_scratch 4))]
4064 "reload_completed"
4065 [(parallel
4066 [(unspec [(match_dup 2) (match_dup 3)
4067 (const_int 0)] UNSPEC_EXECUTE)
4068 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
4069 (use (const_int 1))])]
4070 "")
4071
4072 (define_split
4073 [(set (reg:CCU CC_REGNUM)
4074 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
4075 (match_operand:BLK 1 "memory_operand" "")))
4076 (use (match_operand 2 "register_operand" ""))
4077 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
4078 (clobber (match_scratch 3))]
4079 "TARGET_Z10 && reload_completed"
4080 [(parallel
4081 [(unspec [(match_dup 2) (const_int 0)
4082 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
4083 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
4084 (use (const_int 1))])]
4085 "operands[4] = gen_label_rtx ();")
4086
4087 (define_split
4088 [(set (reg:CCU CC_REGNUM)
4089 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
4090 (match_operand:BLK 1 "memory_operand" "")))
4091 (use (match_operand 2 "register_operand" ""))
4092 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
4093 (clobber (match_operand 3 "register_operand" ""))]
4094 "reload_completed"
4095 [(set (match_dup 3) (label_ref (match_dup 4)))
4096 (parallel
4097 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
4098 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
4099 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
4100 (use (const_int 1))])]
4101 "operands[4] = gen_label_rtx ();")
4102
4103 ; Compare a block of arbitrary length.
4104
4105 (define_expand "cmpmem_long"
4106 [(parallel
4107 [(clobber (match_dup 2))
4108 (clobber (match_dup 3))
4109 (set (reg:CCU CC_REGNUM)
4110 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
4111 (match_operand:BLK 1 "memory_operand" "")))
4112 (use (match_operand 2 "general_operand" ""))
4113 (use (match_dup 3))])]
4114 ""
4115 {
4116 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
4117 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
4118 rtx reg0 = gen_reg_rtx (dreg_mode);
4119 rtx reg1 = gen_reg_rtx (dreg_mode);
4120 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
4121 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
4122 rtx len0 = gen_lowpart (Pmode, reg0);
4123 rtx len1 = gen_lowpart (Pmode, reg1);
4124
4125 emit_clobber (reg0);
4126 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
4127 emit_move_insn (len0, operands[2]);
4128
4129 emit_clobber (reg1);
4130 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
4131 emit_move_insn (len1, operands[2]);
4132
4133 operands[0] = replace_equiv_address_nv (operands[0], addr0);
4134 operands[1] = replace_equiv_address_nv (operands[1], addr1);
4135 operands[2] = reg0;
4136 operands[3] = reg1;
4137 })
4138
4139 (define_insn "*cmpmem_long"
4140 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
4141 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
4142 (set (reg:CCU CC_REGNUM)
4143 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
4144 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
4145 (use (match_dup 2))
4146 (use (match_dup 3))]
4147 "TARGET_64BIT || !TARGET_ZARCH"
4148 "clcle\t%0,%1,0\;jo\t.-4"
4149 [(set_attr "length" "8")
4150 (set_attr "type" "vs")])
4151
4152 (define_insn "*cmpmem_long_31z"
4153 [(clobber (match_operand:TI 0 "register_operand" "=d"))
4154 (clobber (match_operand:TI 1 "register_operand" "=d"))
4155 (set (reg:CCU CC_REGNUM)
4156 (compare:CCU (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
4157 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4))))
4158 (use (match_dup 2))
4159 (use (match_dup 3))]
4160 "!TARGET_64BIT && TARGET_ZARCH"
4161 "clcle\t%0,%1,0\;jo\t.-4"
4162 [(set_attr "op_type" "NN")
4163 (set_attr "type" "vs")
4164 (set_attr "length" "8")])
4165
4166 ; Convert CCUmode condition code to integer.
4167 ; Result is zero if EQ, positive if LTU, negative if GTU.
4168
4169 (define_insn_and_split "cmpint"
4170 [(set (match_operand:SI 0 "register_operand" "=d")
4171 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
4172 UNSPEC_STRCMPCC_TO_INT))
4173 (clobber (reg:CC CC_REGNUM))]
4174 ""
4175 "#"
4176 "reload_completed"
4177 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
4178 (parallel
4179 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
4180 (clobber (reg:CC CC_REGNUM))])])
4181
4182 (define_insn_and_split "*cmpint_cc"
4183 [(set (reg CC_REGNUM)
4184 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
4185 UNSPEC_STRCMPCC_TO_INT)
4186 (const_int 0)))
4187 (set (match_operand:SI 0 "register_operand" "=d")
4188 (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT))]
4189 "s390_match_ccmode (insn, CCSmode)"
4190 "#"
4191 "&& reload_completed"
4192 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
4193 (parallel
4194 [(set (match_dup 2) (match_dup 3))
4195 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
4196 {
4197 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
4198 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
4199 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
4200 })
4201
4202 (define_insn_and_split "*cmpint_sign"
4203 [(set (match_operand:DI 0 "register_operand" "=d")
4204 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
4205 UNSPEC_STRCMPCC_TO_INT)))
4206 (clobber (reg:CC CC_REGNUM))]
4207 "TARGET_ZARCH"
4208 "#"
4209 "&& reload_completed"
4210 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
4211 (parallel
4212 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
4213 (clobber (reg:CC CC_REGNUM))])])
4214
4215 (define_insn_and_split "*cmpint_sign_cc"
4216 [(set (reg CC_REGNUM)
4217 (compare (ashiftrt:DI (ashift:DI (subreg:DI
4218 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
4219 UNSPEC_STRCMPCC_TO_INT) 0)
4220 (const_int 32)) (const_int 32))
4221 (const_int 0)))
4222 (set (match_operand:DI 0 "register_operand" "=d")
4223 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT)))]
4224 "s390_match_ccmode (insn, CCSmode) && TARGET_ZARCH"
4225 "#"
4226 "&& reload_completed"
4227 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
4228 (parallel
4229 [(set (match_dup 2) (match_dup 3))
4230 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
4231 {
4232 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
4233 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
4234 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
4235 })
4236
4237
4238 ;;
4239 ;;- Conversion instructions.
4240 ;;
4241
4242 (define_insn "*sethighpartsi"
4243 [(set (match_operand:SI 0 "register_operand" "=d,d")
4244 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
4245 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
4246 (clobber (reg:CC CC_REGNUM))]
4247 ""
4248 "@
4249 icm\t%0,%2,%S1
4250 icmy\t%0,%2,%S1"
4251 [(set_attr "op_type" "RS,RSY")
4252 (set_attr "cpu_facility" "*,longdisp")
4253 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4254
4255 (define_insn "*sethighpartdi_64"
4256 [(set (match_operand:DI 0 "register_operand" "=d")
4257 (unspec:DI [(match_operand:BLK 1 "s_operand" "S")
4258 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
4259 (clobber (reg:CC CC_REGNUM))]
4260 "TARGET_ZARCH"
4261 "icmh\t%0,%2,%S1"
4262 [(set_attr "op_type" "RSY")
4263 (set_attr "z10prop" "z10_super")])
4264
4265 (define_insn "*sethighpartdi_31"
4266 [(set (match_operand:DI 0 "register_operand" "=d,d")
4267 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
4268 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
4269 (clobber (reg:CC CC_REGNUM))]
4270 "!TARGET_ZARCH"
4271 "@
4272 icm\t%0,%2,%S1
4273 icmy\t%0,%2,%S1"
4274 [(set_attr "op_type" "RS,RSY")
4275 (set_attr "cpu_facility" "*,longdisp")
4276 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4277
4278 ;
4279 ; extv instruction patterns
4280 ;
4281
4282 ; FIXME: This expander needs to be converted from DI to GPR as well
4283 ; after resolving some issues with it.
4284
4285 (define_expand "extzv"
4286 [(parallel
4287 [(set (match_operand:DI 0 "register_operand" "=d")
4288 (zero_extract:DI
4289 (match_operand:DI 1 "register_operand" "d")
4290 (match_operand 2 "const_int_operand" "") ; size
4291 (match_operand 3 "const_int_operand" ""))) ; start
4292 (clobber (reg:CC CC_REGNUM))])]
4293 "TARGET_Z10"
4294 {
4295 if (! EXTRACT_ARGS_IN_RANGE (INTVAL (operands[2]), INTVAL (operands[3]), 64))
4296 FAIL;
4297 /* Starting with zEC12 there is risbgn not clobbering CC. */
4298 if (TARGET_ZEC12)
4299 {
4300 emit_move_insn (operands[0],
4301 gen_rtx_ZERO_EXTRACT (DImode,
4302 operands[1],
4303 operands[2],
4304 operands[3]));
4305 DONE;
4306 }
4307 })
4308
4309 (define_insn "*extzv<mode><clobbercc_or_nocc>"
4310 [(set (match_operand:GPR 0 "register_operand" "=d")
4311 (zero_extract:GPR
4312 (match_operand:GPR 1 "register_operand" "d")
4313 (match_operand 2 "const_int_operand" "") ; size
4314 (match_operand 3 "const_int_operand" ""))) ; start
4315 ]
4316 "<z10_or_zEC12_cond>
4317 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[2]), INTVAL (operands[3]),
4318 GET_MODE_BITSIZE (<MODE>mode))"
4319 "<risbg_n>\t%0,%1,64-%2,128+63,<bitoff_plus>%3+%2" ; dst, src, start, end, shift
4320 [(set_attr "op_type" "RIE")
4321 (set_attr "z10prop" "z10_super_E1")])
4322
4323 ; 64 bit: (a & -16) | ((b >> 8) & 15)
4324 (define_insn "*extzvdi<clobbercc_or_nocc>_lshiftrt"
4325 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4326 (match_operand 1 "const_int_operand" "") ; size
4327 (match_operand 2 "const_int_operand" "")) ; start
4328 (lshiftrt:DI (match_operand:DI 3 "register_operand" "d")
4329 (match_operand:DI 4 "nonzero_shift_count_operand" "")))]
4330 "<z10_or_zEC12_cond>
4331 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
4332 && 64 - UINTVAL (operands[4]) >= UINTVAL (operands[1])"
4333 "<risbg_n>\t%0,%3,%2,%2+%1-1,128-%2-%1-%4"
4334 [(set_attr "op_type" "RIE")
4335 (set_attr "z10prop" "z10_super_E1")])
4336
4337 ; (a & -16) | ((b >> 8) & 15)
4338 (define_insn "*<risbg_n>_ior_and_sr_ze<mode>"
4339 [(set (match_operand:DSI 0 "register_operand" "=d")
4340 (ior:DSI (and:DSI
4341 (match_operand:DSI 1 "register_operand" "0")
4342 (match_operand:DSI 2 "const_int_operand" ""))
4343 (zero_extract:DSI
4344 (match_operand:DSI 3 "register_operand" "d")
4345 (match_operand 4 "const_int_operand" "") ; size
4346 (match_operand 5 "const_int_operand" "")) ; start
4347 ))]
4348 "<z10_or_zEC12_cond>
4349 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[4]), INTVAL (operands[5]), <DSI:bitsize>)
4350 && UINTVAL (operands[2]) == (HOST_WIDE_INT_M1U << UINTVAL (operands[4]))"
4351 "<risbg_n>\t%0,%3,64-%4,63,(64-<DSI:bitsize>)+%4+%5"
4352 [(set_attr "op_type" "RIE")
4353 (set_attr "z10prop" "z10_super_E1")])
4354
4355 ; ((int)foo >> 10) & 1;
4356 (define_insn "*extract1bitdi<clobbercc_or_nocc>"
4357 [(set (match_operand:DI 0 "register_operand" "=d")
4358 (ne:DI (zero_extract:DI
4359 (match_operand:DI 1 "register_operand" "d")
4360 (const_int 1) ; size
4361 (match_operand 2 "const_int_operand" "")) ; start
4362 (const_int 0)))]
4363 "<z10_or_zEC12_cond>
4364 && EXTRACT_ARGS_IN_RANGE (1, INTVAL (operands[2]), 64)"
4365 "<risbg_n>\t%0,%1,64-1,128+63,%2+1" ; dst, src, start, end, shift
4366 [(set_attr "op_type" "RIE")
4367 (set_attr "z10prop" "z10_super_E1")])
4368
4369 (define_insn "*<risbg_n>_and_subregdi_rotr"
4370 [(set (match_operand:DI 0 "register_operand" "=d")
4371 (and:DI (subreg:DI
4372 (rotate:SINT (match_operand:SINT 1 "register_operand" "d")
4373 (match_operand:SINT 2 "const_int_operand" "")) 0)
4374 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
4375 "<z10_or_zEC12_cond>
4376 && (UINTVAL (operands[3])
4377 < (HOST_WIDE_INT_1U << (UINTVAL (operands[2]) & 0x3f)))"
4378 "<risbg_n>\t%0,%1,%s3,128+%e3,<bitoff_plus>%2" ; dst, src, start, end, shift
4379 [(set_attr "op_type" "RIE")
4380 (set_attr "z10prop" "z10_super_E1")])
4381
4382 (define_insn "*<risbg_n>_and_subregdi_rotl"
4383 [(set (match_operand:DI 0 "register_operand" "=d")
4384 (and:DI (subreg:DI
4385 (rotate:SINT (match_operand:SINT 1 "register_operand" "d")
4386 (match_operand:SINT 2 "const_int_operand" "")) 0)
4387 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
4388 "<z10_or_zEC12_cond>
4389 && !(UINTVAL (operands[3])
4390 & ((HOST_WIDE_INT_1U << (UINTVAL (operands[2]) & 0x3f)) - 1))"
4391 "<risbg_n>\t%0,%1,%s3,128+%e3,%2" ; dst, src, start, end, shift
4392 [(set_attr "op_type" "RIE")
4393 (set_attr "z10prop" "z10_super_E1")])
4394
4395 (define_insn "*<risbg_n>_di_and_rot"
4396 [(set (match_operand:DI 0 "register_operand" "=d")
4397 (and:DI (rotate:DI (match_operand:DI 1 "register_operand" "d")
4398 (match_operand:DI 2 "const_int_operand" ""))
4399 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
4400 "<z10_or_zEC12_cond>"
4401 "<risbg_n>\t%0,%1,%s3,128+%e3,%2" ; dst, src, start, end, shift
4402 [(set_attr "op_type" "RIE")
4403 (set_attr "z10prop" "z10_super_E1")])
4404
4405 (define_insn_and_split "*pre_z10_extzv<mode>"
4406 [(set (match_operand:GPR 0 "register_operand" "=d")
4407 (zero_extract:GPR (match_operand:QI 1 "s_operand" "S")
4408 (match_operand 2 "nonzero_shift_count_operand" "")
4409 (const_int 0)))
4410 (clobber (reg:CC CC_REGNUM))]
4411 "!TARGET_Z10"
4412 "#"
4413 "&& reload_completed"
4414 [(parallel
4415 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
4416 (clobber (reg:CC CC_REGNUM))])
4417 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
4418 {
4419 int bitsize = INTVAL (operands[2]);
4420 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
4421 unsigned HOST_WIDE_INT mask
4422 = ((HOST_WIDE_INT_1U << size) - 1) << (GET_MODE_SIZE (SImode) - size);
4423
4424 operands[1] = adjust_address (operands[1], BLKmode, 0);
4425 set_mem_size (operands[1], size);
4426 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
4427 operands[3] = GEN_INT (mask);
4428 })
4429
4430 (define_insn_and_split "*pre_z10_extv<mode>"
4431 [(set (match_operand:GPR 0 "register_operand" "=d")
4432 (sign_extract:GPR (match_operand:QI 1 "s_operand" "S")
4433 (match_operand 2 "nonzero_shift_count_operand" "")
4434 (const_int 0)))
4435 (clobber (reg:CC CC_REGNUM))]
4436 ""
4437 "#"
4438 "&& reload_completed"
4439 [(parallel
4440 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
4441 (clobber (reg:CC CC_REGNUM))])
4442 (parallel
4443 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
4444 (clobber (reg:CC CC_REGNUM))])]
4445 {
4446 int bitsize = INTVAL (operands[2]);
4447 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
4448 unsigned HOST_WIDE_INT mask
4449 = ((HOST_WIDE_INT_1U << size) - 1) << (GET_MODE_SIZE (SImode) - size);
4450
4451 operands[1] = adjust_address (operands[1], BLKmode, 0);
4452 set_mem_size (operands[1], size);
4453 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
4454 operands[3] = GEN_INT (mask);
4455 })
4456
4457 ;
4458 ; insv instruction patterns
4459 ;
4460
4461 (define_expand "insv"
4462 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
4463 (match_operand 1 "const_int_operand" "")
4464 (match_operand 2 "const_int_operand" ""))
4465 (match_operand 3 "general_operand" ""))]
4466 ""
4467 {
4468 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
4469 DONE;
4470 FAIL;
4471 })
4472
4473
4474 ; The normal RTL expansion will never generate a zero_extract where
4475 ; the location operand isn't word mode. However, we do this in the
4476 ; back-end when generating atomic operations. See s390_two_part_insv.
4477 (define_insn "*insv<mode><clobbercc_or_nocc>"
4478 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
4479 (match_operand 1 "const_int_operand" "I") ; size
4480 (match_operand 2 "const_int_operand" "I")) ; pos
4481 (match_operand:GPR 3 "nonimmediate_operand" "d"))]
4482 "<z10_or_zEC12_cond>
4483 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]),
4484 GET_MODE_BITSIZE (<MODE>mode))
4485 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
4486 "<risbg_n>\t%0,%3,<bitoff_plus>%2,<bitoff_plus>%2+%1-1,<bitsize>-%2-%1"
4487 [(set_attr "op_type" "RIE")
4488 (set_attr "z10prop" "z10_super_E1")])
4489
4490 ; and op1 with a mask being 1 for the selected bits and 0 for the rest
4491 ; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
4492 (define_insn "*insv<mode><clobbercc_or_nocc>_noshift"
4493 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d")
4494 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d,0")
4495 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
4496 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0,d")
4497 (match_operand:GPR 4 "const_int_operand" ""))))]
4498 "<z10_or_zEC12_cond> && INTVAL (operands[2]) == ~INTVAL (operands[4])"
4499 "@
4500 <risbg_n>\t%0,%1,%<bfstart>2,%<bfend>2,0
4501 <risbg_n>\t%0,%3,%<bfstart>4,%<bfend>4,0"
4502 [(set_attr "op_type" "RIE")
4503 (set_attr "z10prop" "z10_super_E1")])
4504
4505 (define_insn "*insv_z10_noshift_cc"
4506 [(set (reg CC_REGNUM)
4507 (compare
4508 (ior:DI
4509 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,0")
4510 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
4511 (and:DI (match_operand:DI 3 "nonimmediate_operand" "0,d")
4512 (match_operand:DI 4 "const_int_operand" "")))
4513 (const_int 0)))
4514 (set (match_operand:DI 0 "nonimmediate_operand" "=d,d")
4515 (ior:DI (and:DI (match_dup 1) (match_dup 2))
4516 (and:DI (match_dup 3) (match_dup 4))))]
4517 "TARGET_Z10 && s390_match_ccmode (insn, CCSmode)
4518 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
4519 "@
4520 risbg\t%0,%1,%s2,%e2,0
4521 risbg\t%0,%3,%s4,%e4,0"
4522 [(set_attr "op_type" "RIE")
4523 (set_attr "z10prop" "z10_super_E1")])
4524
4525 (define_insn "*insv_z10_noshift_cconly"
4526 [(set
4527 (reg CC_REGNUM)
4528 (compare
4529 (ior:DI
4530 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,0")
4531 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
4532 (and:DI (match_operand:DI 3 "nonimmediate_operand" "0,d")
4533 (match_operand:DI 4 "const_int_operand" "")))
4534 (const_int 0)))
4535 (clobber (match_scratch:DI 0 "=d,d"))]
4536 "TARGET_Z10 && s390_match_ccmode (insn, CCSmode)
4537 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
4538 "@
4539 risbg\t%0,%1,%s2,%e2,0
4540 risbg\t%0,%3,%s4,%e4,0"
4541 [(set_attr "op_type" "RIE")
4542 (set_attr "z10prop" "z10_super_E1")])
4543
4544 ; Implement appending Y on the left of S bits of X
4545 ; x = (y << s) | (x & ((1 << s) - 1))
4546 (define_insn "*insv<mode><clobbercc_or_nocc>_appendbitsleft"
4547 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4548 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "0")
4549 (match_operand:GPR 2 "immediate_operand" ""))
4550 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "d")
4551 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4552 "<z10_or_zEC12_cond>
4553 && UINTVAL (operands[2]) == (HOST_WIDE_INT_1U << UINTVAL (operands[4])) - 1"
4554 "<risbg_n>\t%0,%3,<bitoff>,64-%4-1,%4"
4555 [(set_attr "op_type" "RIE")
4556 (set_attr "z10prop" "z10_super_E1")])
4557
4558 ; a = ((i32)a & -16777216) | (((ui32)b) >> 8)
4559 (define_insn "*<risbg_n>_<mode>_ior_and_lshiftrt"
4560 [(set (match_operand:GPR 0 "register_operand" "=d")
4561 (ior:GPR (and:GPR
4562 (match_operand:GPR 1 "register_operand" "0")
4563 (match_operand:GPR 2 "const_int_operand" ""))
4564 (lshiftrt:GPR
4565 (match_operand:GPR 3 "register_operand" "d")
4566 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4567 "<z10_or_zEC12_cond> && UINTVAL (operands[2])
4568 == (HOST_WIDE_INT_M1U
4569 << (GET_MODE_BITSIZE (<MODE>mode) - UINTVAL (operands[4])))"
4570 "<risbg_n>\t%0,%3,<bitoff_plus>%4,63,64-%4"
4571 [(set_attr "op_type" "RIE")
4572 (set_attr "z10prop" "z10_super_E1")])
4573
4574 ; (ui32)(((ui64)x) >> 48) | ((i32)y & -65536);
4575 (define_insn "*<risbg_n>_sidi_ior_and_lshiftrt"
4576 [(set (match_operand:SI 0 "register_operand" "=d")
4577 (ior:SI (and:SI
4578 (match_operand:SI 1 "register_operand" "0")
4579 (match_operand:SI 2 "const_int_operand" ""))
4580 (subreg:SI
4581 (lshiftrt:DI
4582 (match_operand:DI 3 "register_operand" "d")
4583 (match_operand:DI 4 "nonzero_shift_count_operand" "")) 4)))]
4584 "<z10_or_zEC12_cond>
4585 && UINTVAL (operands[2]) == ~(HOST_WIDE_INT_M1U >> UINTVAL (operands[4]))"
4586 "<risbg_n>\t%0,%3,%4,63,64-%4"
4587 [(set_attr "op_type" "RIE")
4588 (set_attr "z10prop" "z10_super_E1")])
4589
4590 ; (ui32)(((ui64)x) >> 12) & -4
4591 (define_insn "*trunc_sidi_and_subreg_lshrt<clobbercc_or_nocc>"
4592 [(set (match_operand:SI 0 "register_operand" "=d")
4593 (and:SI
4594 (subreg:SI (lshiftrt:DI
4595 (match_operand:DI 1 "register_operand" "d")
4596 (match_operand:DI 2 "nonzero_shift_count_operand" "")) 4)
4597 (match_operand:SI 3 "contiguous_bitmask_nowrap_operand" "")))]
4598 "<z10_or_zEC12_cond>"
4599 "<risbg_n>\t%0,%1,%t3,128+%f3,64-%2"
4600 [(set_attr "op_type" "RIE")
4601 (set_attr "z10prop" "z10_super_E1")])
4602
4603 ; (ui32)(((ui64)x) >> 12) & -4
4604 (define_insn "*trunc_sidi_and_subreg_ze<clobbercc_or_nocc>"
4605 [(set (match_operand:SI 0 "register_operand" "=d")
4606 (and:SI
4607 (subreg:SI (zero_extract:DI
4608 (match_operand:DI 1 "register_operand" "d")
4609 (const_int 32)
4610 (match_operand:SI 2 "nonzero_shift_count_operand" "")) 4)
4611 (match_operand:SI 3 "contiguous_bitmask_nowrap_operand" "")))]
4612 "<z10_or_zEC12_cond>"
4613 "<risbg_n>\t%0,%1,%t3,128+%f3,32+%2"
4614 [(set_attr "op_type" "RIE")
4615 (set_attr "z10prop" "z10_super_E1")])
4616
4617 ; z = (x << c) | (y >> d) with (x << c) and (y >> d) not overlapping after shifting
4618 ; -> z = y >> d; z = (x << c) | (z & ((1 << c) - 1))
4619 ; -> z = y >> d; z = risbg;
4620
4621 (define_split
4622 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
4623 (ior:GPR (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
4624 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4625 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "")
4626 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4627 "TARGET_ZEC12 && UINTVAL (operands[2]) + UINTVAL (operands[4]) >= <bitsize>"
4628 [(set (match_dup 6)
4629 (lshiftrt:GPR (match_dup 1) (match_dup 2)))
4630 (set (match_dup 0)
4631 (ior:GPR (and:GPR (match_dup 6) (match_dup 5))
4632 (ashift:GPR (match_dup 3) (match_dup 4))))]
4633 {
4634 operands[5] = GEN_INT ((HOST_WIDE_INT_1U << UINTVAL (operands[4])) - 1);
4635 if (reg_overlap_mentioned_p (operands[0], operands[3]))
4636 {
4637 if (!can_create_pseudo_p ())
4638 FAIL;
4639 operands[6] = gen_reg_rtx (<MODE>mode);
4640 }
4641 else
4642 operands[6] = operands[0];
4643 })
4644
4645 (define_split
4646 [(parallel
4647 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
4648 (ior:GPR (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
4649 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4650 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "")
4651 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))
4652 (clobber (reg:CC CC_REGNUM))])]
4653 "TARGET_Z10 && !TARGET_ZEC12 && UINTVAL (operands[2]) + UINTVAL (operands[4]) >= <bitsize>"
4654 [(set (match_dup 6)
4655 (lshiftrt:GPR (match_dup 1) (match_dup 2)))
4656 (parallel
4657 [(set (match_dup 0)
4658 (ior:GPR (and:GPR (match_dup 6) (match_dup 5))
4659 (ashift:GPR (match_dup 3) (match_dup 4))))
4660 (clobber (reg:CC CC_REGNUM))])]
4661 {
4662 operands[5] = GEN_INT ((HOST_WIDE_INT_1U << UINTVAL (operands[4])) - 1);
4663 if (reg_overlap_mentioned_p (operands[0], operands[3]))
4664 {
4665 if (!can_create_pseudo_p ())
4666 FAIL;
4667 operands[6] = gen_reg_rtx (<MODE>mode);
4668 }
4669 else
4670 operands[6] = operands[0];
4671 })
4672
4673 ; rosbg, rxsbg
4674 (define_insn "*r<noxa>sbg_<mode>_noshift"
4675 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4676 (IXOR:GPR
4677 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
4678 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
4679 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4680 (clobber (reg:CC CC_REGNUM))]
4681 "TARGET_Z10"
4682 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
4683 [(set_attr "op_type" "RIE")])
4684
4685 ; rosbg, rxsbg
4686 (define_insn "*r<noxa>sbg_di_rotl"
4687 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4688 (IXOR:DI
4689 (and:DI
4690 (rotate:DI
4691 (match_operand:DI 1 "nonimmediate_operand" "d")
4692 (match_operand:DI 3 "const_int_operand" ""))
4693 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
4694 (match_operand:DI 4 "nonimmediate_operand" "0")))
4695 (clobber (reg:CC CC_REGNUM))]
4696 "TARGET_Z10"
4697 "r<noxa>sbg\t%0,%1,%s2,%e2,%b3"
4698 [(set_attr "op_type" "RIE")])
4699
4700 ; rosbg, rxsbg
4701 (define_insn "*r<noxa>sbg_<mode>_srl_bitmask"
4702 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4703 (IXOR:GPR
4704 (and:GPR
4705 (lshiftrt:GPR
4706 (match_operand:GPR 1 "nonimmediate_operand" "d")
4707 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
4708 (match_operand:GPR 2 "contiguous_bitmask_nowrap_operand" ""))
4709 (match_operand:GPR 4 "nonimmediate_operand" "0")))
4710 (clobber (reg:CC CC_REGNUM))]
4711 "TARGET_Z10
4712 && s390_extzv_shift_ok (<bitsize>, 64 - INTVAL (operands[3]),
4713 INTVAL (operands[2]))"
4714 {
4715 operands[3] = GEN_INT (64 - INTVAL (operands[3]));
4716 return "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%3";
4717 }
4718 [(set_attr "op_type" "RIE")])
4719
4720 ; rosbg, rxsbg
4721 (define_insn "*r<noxa>sbg_<mode>_sll_bitmask"
4722 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4723 (IXOR:GPR
4724 (and:GPR
4725 (ashift:GPR
4726 (match_operand:GPR 1 "nonimmediate_operand" "d")
4727 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
4728 (match_operand:GPR 2 "contiguous_bitmask_nowrap_operand" ""))
4729 (match_operand:GPR 4 "nonimmediate_operand" "0")))
4730 (clobber (reg:CC CC_REGNUM))]
4731 "TARGET_Z10
4732 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[3]),
4733 INTVAL (operands[2]))"
4734 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%3"
4735 [(set_attr "op_type" "RIE")])
4736
4737 ;; unsigned {int,long} a, b
4738 ;; a = a | (b << const_int)
4739 ;; a = a ^ (b << const_int)
4740 ; rosbg, rxsbg
4741 (define_insn "*r<noxa>sbg_<mode>_sll"
4742 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4743 (IXOR:GPR
4744 (ashift:GPR
4745 (match_operand:GPR 1 "nonimmediate_operand" "d")
4746 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4747 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4748 (clobber (reg:CC CC_REGNUM))]
4749 "TARGET_Z10"
4750 {
4751 operands[3] = GEN_INT (63 - INTVAL (operands[2]));
4752 return "r<noxa>sbg\t%0,%1,<bitoff>,%3,%2";
4753 }
4754 [(set_attr "op_type" "RIE")])
4755
4756 ;; unsigned {int,long} a, b
4757 ;; a = a | (b >> const_int)
4758 ;; a = a ^ (b >> const_int)
4759 ; rosbg, rxsbg
4760 (define_insn "*r<noxa>sbg_<mode>_srl"
4761 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4762 (IXOR:GPR
4763 (lshiftrt:GPR
4764 (match_operand:GPR 1 "nonimmediate_operand" "d")
4765 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4766 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4767 (clobber (reg:CC CC_REGNUM))]
4768 "TARGET_Z10"
4769 {
4770 operands[3] = GEN_INT (64 - INTVAL (operands[2]));
4771 operands[2] = GEN_INT (<bitoff_plus> INTVAL (operands[2]));
4772 return "r<noxa>sbg\t%0,%1,%2,63,%3";
4773 }
4774 [(set_attr "op_type" "RIE")])
4775
4776 ; rosbg, rxsbg
4777 (define_insn "*r<noxa>sbg_sidi_srl"
4778 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4779 (IXOR:SI
4780 (subreg:SI
4781 (zero_extract:DI
4782 (match_operand:DI 1 "nonimmediate_operand" "d")
4783 (const_int 32)
4784 (match_operand:DI 2 "immediate_operand" ""))
4785 4)
4786 (match_operand:SI 3 "nonimmediate_operand" "0")))
4787 (clobber (reg:CC CC_REGNUM))]
4788 "TARGET_Z10"
4789 {
4790 operands[2] = GEN_INT (32 + INTVAL (operands[2]));
4791 return "r<noxa>sbg\t%0,%1,32,63,%2";
4792 }
4793 [(set_attr "op_type" "RIE")])
4794
4795 ;; These two are generated by combine for s.bf &= val.
4796 ;; ??? For bitfields smaller than 32-bits, we wind up with SImode
4797 ;; shifts and ands, which results in some truly awful patterns
4798 ;; including subregs of operations. Rather unnecessisarily, IMO.
4799 ;; Instead of
4800 ;;
4801 ;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
4802 ;; (const_int 24 [0x18])
4803 ;; (const_int 0 [0]))
4804 ;; (subreg:DI (and:SI (subreg:SI (lshiftrt:DI (reg/v:DI 50 [ s ])
4805 ;; (const_int 40 [0x28])) 4)
4806 ;; (reg:SI 4 %r4 [ y+4 ])) 0))
4807 ;;
4808 ;; we should instead generate
4809 ;;
4810 ;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
4811 ;; (const_int 24 [0x18])
4812 ;; (const_int 0 [0]))
4813 ;; (and:DI (lshiftrt:DI (reg/v:DI 50 [ s ])
4814 ;; (const_int 40 [0x28]))
4815 ;; (subreg:DI (reg:SI 4 %r4 [ y+4 ]) 0)))
4816 ;;
4817 ;; by noticing that we can push down the outer paradoxical subreg
4818 ;; into the operation.
4819
4820 (define_insn "*insv_rnsbg_noshift"
4821 [(set (zero_extract:DI
4822 (match_operand:DI 0 "nonimmediate_operand" "+d")
4823 (match_operand 1 "const_int_operand" "")
4824 (match_operand 2 "const_int_operand" ""))
4825 (and:DI
4826 (match_dup 0)
4827 (match_operand:DI 3 "nonimmediate_operand" "d")))
4828 (clobber (reg:CC CC_REGNUM))]
4829 "TARGET_Z10
4830 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
4831 && INTVAL (operands[1]) + INTVAL (operands[2]) == 64"
4832 "rnsbg\t%0,%3,%2,63,0"
4833 [(set_attr "op_type" "RIE")])
4834
4835 (define_insn "*insv_rnsbg_srl"
4836 [(set (zero_extract:DI
4837 (match_operand:DI 0 "nonimmediate_operand" "+d")
4838 (match_operand 1 "const_int_operand" "")
4839 (match_operand 2 "const_int_operand" ""))
4840 (and:DI
4841 (lshiftrt:DI
4842 (match_dup 0)
4843 (match_operand 3 "const_int_operand" ""))
4844 (match_operand:DI 4 "nonimmediate_operand" "d")))
4845 (clobber (reg:CC CC_REGNUM))]
4846 "TARGET_Z10
4847 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
4848 && INTVAL (operands[3]) == 64 - INTVAL (operands[1]) - INTVAL (operands[2])"
4849 "rnsbg\t%0,%4,%2,%2+%1-1,%3"
4850 [(set_attr "op_type" "RIE")])
4851
4852 (define_insn "*insv<mode>_mem_reg"
4853 [(set (zero_extract:W (match_operand:QI 0 "memory_operand" "+Q,S")
4854 (match_operand 1 "const_int_operand" "n,n")
4855 (const_int 0))
4856 (match_operand:W 2 "register_operand" "d,d"))]
4857 "EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), 0, 64)
4858 && INTVAL (operands[1]) > 0
4859 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
4860 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
4861 {
4862 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
4863
4864 operands[1] = GEN_INT ((HOST_WIDE_INT_1U << size) - 1);
4865 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
4866 : "stcmy\t%2,%1,%S0";
4867 }
4868 [(set_attr "op_type" "RS,RSY")
4869 (set_attr "cpu_facility" "*,longdisp")
4870 (set_attr "z10prop" "z10_super,z10_super")])
4871
4872 (define_insn "*insvdi_mem_reghigh"
4873 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+S")
4874 (match_operand 1 "const_int_operand" "n")
4875 (const_int 0))
4876 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
4877 (const_int 32)))]
4878 "TARGET_ZARCH
4879 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), 0, 64)
4880 && INTVAL (operands[1]) > 0
4881 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
4882 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
4883 {
4884 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
4885
4886 operands[1] = GEN_INT ((HOST_WIDE_INT_1U << size) - 1);
4887 return "stcmh\t%2,%1,%S0";
4888 }
4889 [(set_attr "op_type" "RSY")
4890 (set_attr "z10prop" "z10_super")])
4891
4892 (define_insn "*insvdi_reg_imm"
4893 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4894 (const_int 16)
4895 (match_operand 1 "const_int_operand" "n"))
4896 (match_operand:DI 2 "const_int_operand" "n"))]
4897 "TARGET_ZARCH
4898 && EXTRACT_ARGS_IN_RANGE (16, INTVAL (operands[1]), 64)
4899 && INTVAL (operands[1]) >= 0
4900 && INTVAL (operands[1]) < BITS_PER_WORD
4901 && INTVAL (operands[1]) % 16 == 0"
4902 {
4903 switch (BITS_PER_WORD - INTVAL (operands[1]))
4904 {
4905 case 64: return "iihh\t%0,%x2"; break;
4906 case 48: return "iihl\t%0,%x2"; break;
4907 case 32: return "iilh\t%0,%x2"; break;
4908 case 16: return "iill\t%0,%x2"; break;
4909 default: gcc_unreachable();
4910 }
4911 }
4912 [(set_attr "op_type" "RI")
4913 (set_attr "z10prop" "z10_super_E1")])
4914
4915 ; Update the left-most 32 bit of a DI.
4916 (define_insn "*insv_h_di_reg_extimm"
4917 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4918 (const_int 32)
4919 (const_int 0))
4920 (match_operand:DI 1 "const_int_operand" "n"))]
4921 "TARGET_EXTIMM"
4922 "iihf\t%0,%o1"
4923 [(set_attr "op_type" "RIL")
4924 (set_attr "z10prop" "z10_fwd_E1")])
4925
4926 ; Update the right-most 32 bit of a DI.
4927 (define_insn "*insv_l_di_reg_extimm"
4928 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4929 (const_int 32)
4930 (const_int 32))
4931 (match_operand:DI 1 "const_int_operand" "n"))]
4932 "TARGET_EXTIMM"
4933 "iilf\t%0,%o1"
4934 [(set_attr "op_type" "RIL")
4935 (set_attr "z10prop" "z10_fwd_A1")])
4936
4937 ;
4938 ; BIT DEPOSIT
4939 ;
4940
4941 (define_insn "bdepg"
4942 [(set (match_operand:DI 0 "register_operand" "=d")
4943 (unspec:DI [(match_operand:DI 1 "register_operand" "d")
4944 (match_operand:DI 2 "register_operand" "d")]
4945 UNSPEC_BDEPG))]
4946 "TARGET_Z17 && TARGET_64BIT"
4947 "bdepg\t%0,%1,%2"
4948 [(set_attr "op_type" "RRF")])
4949
4950 ;
4951 ; BIT EXTRACT
4952 ;
4953
4954 (define_insn "bextg"
4955 [(set (match_operand:DI 0 "register_operand" "=d")
4956 (unspec:DI [(match_operand:DI 1 "register_operand" "d")
4957 (match_operand:DI 2 "register_operand" "d")]
4958 UNSPEC_BEXTG))]
4959 "TARGET_Z17 && TARGET_64BIT"
4960 "bextg\t%0,%1,%2"
4961 [(set_attr "op_type" "RRF")])
4962
4963
4964 ;
4965 ; extendsidi2 instruction pattern(s).
4966 ;
4967
4968 (define_expand "extendsidi2"
4969 [(set (match_operand:DI 0 "register_operand" "")
4970 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
4971 ""
4972 {
4973 if (!TARGET_ZARCH)
4974 {
4975 emit_clobber (operands[0]);
4976 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
4977 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
4978 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
4979 DONE;
4980 }
4981 })
4982
4983 (define_insn "*extendsidi2"
4984 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4985 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,T,b")))]
4986 "TARGET_ZARCH"
4987 "@
4988 lgfr\t%0,%1
4989 lgf\t%0,%1
4990 lgfrl\t%0,%1"
4991 [(set_attr "op_type" "RRE,RXY,RIL")
4992 (set_attr "type" "*,*,larl")
4993 (set_attr "cpu_facility" "*,*,z10")
4994 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")
4995 (set_attr "relative_long" "*,*,yes")])
4996
4997 ;
4998 ; extend(hi|qi)(si|di)2 instruction pattern(s).
4999 ;
5000
5001 (define_expand "extend<HQI:mode><DSI:mode>2"
5002 [(set (match_operand:DSI 0 "register_operand" "")
5003 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
5004 ""
5005 {
5006 if (<DSI:MODE>mode == DImode && !TARGET_ZARCH)
5007 {
5008 rtx tmp = gen_reg_rtx (SImode);
5009 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
5010 emit_insn (gen_extendsidi2 (operands[0], tmp));
5011 DONE;
5012 }
5013 else if (!TARGET_EXTIMM)
5014 {
5015 rtx bitcount = GEN_INT (<DSI:bitsize> - <HQI:bitsize>);
5016
5017 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
5018 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
5019 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
5020 DONE;
5021 }
5022 })
5023
5024 ;
5025 ; extendhidi2 instruction pattern(s).
5026 ;
5027
5028 (define_insn "*extendhidi2_extimm"
5029 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
5030 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,T,b")))]
5031 "TARGET_ZARCH && TARGET_EXTIMM"
5032 "@
5033 lghr\t%0,%1
5034 lgh\t%0,%1
5035 lghrl\t%0,%1"
5036 [(set_attr "op_type" "RRE,RXY,RIL")
5037 (set_attr "type" "*,*,larl")
5038 (set_attr "cpu_facility" "extimm,extimm,z10")
5039 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")
5040 (set_attr "relative_long" "*,*,yes")])
5041
5042 (define_insn "*extendhidi2"
5043 [(set (match_operand:DI 0 "register_operand" "=d")
5044 (sign_extend:DI (match_operand:HI 1 "memory_operand" "T")))]
5045 "TARGET_ZARCH"
5046 "lgh\t%0,%1"
5047 [(set_attr "op_type" "RXY")
5048 (set_attr "z10prop" "z10_super_E1")])
5049
5050 ;
5051 ; extendhisi2 instruction pattern(s).
5052 ;
5053
5054 (define_insn "*extendhisi2_extimm"
5055 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
5056 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
5057 "TARGET_EXTIMM"
5058 "@
5059 lhr\t%0,%1
5060 lh\t%0,%1
5061 lhy\t%0,%1
5062 lhrl\t%0,%1"
5063 [(set_attr "op_type" "RRE,RX,RXY,RIL")
5064 (set_attr "type" "*,*,*,larl")
5065 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
5066 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")
5067 (set_attr "relative_long" "*,*,*,yes")])
5068
5069 (define_insn "*extendhisi2"
5070 [(set (match_operand:SI 0 "register_operand" "=d,d")
5071 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
5072 "!TARGET_EXTIMM"
5073 "@
5074 lh\t%0,%1
5075 lhy\t%0,%1"
5076 [(set_attr "op_type" "RX,RXY")
5077 (set_attr "cpu_facility" "*,longdisp")
5078 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5079
5080 ;
5081 ; extendqi(si|di)2 instruction pattern(s).
5082 ;
5083
5084 ; lbr, lgbr, lb, lgb
5085 (define_insn "*extendqi<mode>2_extimm"
5086 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5087 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,T")))]
5088 "TARGET_EXTIMM"
5089 "@
5090 l<g>br\t%0,%1
5091 l<g>b\t%0,%1"
5092 [(set_attr "op_type" "RRE,RXY")
5093 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5094
5095 ; lb, lgb
5096 (define_insn "*extendqi<mode>2"
5097 [(set (match_operand:GPR 0 "register_operand" "=d")
5098 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "T")))]
5099 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
5100 "l<g>b\t%0,%1"
5101 [(set_attr "op_type" "RXY")
5102 (set_attr "z10prop" "z10_super_E1")])
5103
5104 (define_insn_and_split "*extendqi<mode>2_short_displ"
5105 [(set (match_operand:GPR 0 "register_operand" "=d")
5106 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
5107 (clobber (reg:CC CC_REGNUM))]
5108 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
5109 "#"
5110 "&& reload_completed"
5111 [(parallel
5112 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
5113 (clobber (reg:CC CC_REGNUM))])
5114 (parallel
5115 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
5116 (clobber (reg:CC CC_REGNUM))])]
5117 {
5118 operands[1] = adjust_address (operands[1], BLKmode, 0);
5119 set_mem_size (operands[1], GET_MODE_SIZE (QImode));
5120 operands[2] = GEN_INT (<GPR:bitsize> - BITS_PER_UNIT);
5121 })
5122
5123 ;
5124 ; zero_extendsidi2 instruction pattern(s).
5125 ;
5126
5127 (define_expand "zero_extendsidi2"
5128 [(set (match_operand:DI 0 "register_operand" "")
5129 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
5130 ""
5131 {
5132 if (!TARGET_ZARCH)
5133 {
5134 emit_clobber (operands[0]);
5135 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
5136 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
5137 DONE;
5138 }
5139 })
5140
5141 (define_insn "*zero_extendsidi2"
5142 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
5143 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,T,b")))]
5144 "TARGET_ZARCH"
5145 "@
5146 llgfr\t%0,%1
5147 llgf\t%0,%1
5148 llgfrl\t%0,%1"
5149 [(set_attr "op_type" "RRE,RXY,RIL")
5150 (set_attr "type" "*,*,larl")
5151 (set_attr "cpu_facility" "*,*,z10")
5152 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")
5153 (set_attr "relative_long" "*,*,yes")])
5154
5155 ;
5156 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
5157 ;
5158
5159 (define_insn "*llgt_sidi"
5160 [(set (match_operand:DI 0 "register_operand" "=d")
5161 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "T") 0)
5162 (const_int 2147483647)))]
5163 "TARGET_ZARCH"
5164 "llgt\t%0,%1"
5165 [(set_attr "op_type" "RXE")
5166 (set_attr "z10prop" "z10_super_E1")])
5167
5168 (define_insn_and_split "*llgt_sidi_split"
5169 [(set (match_operand:DI 0 "register_operand" "=d")
5170 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "T") 0)
5171 (const_int 2147483647)))
5172 (clobber (reg:CC CC_REGNUM))]
5173 "TARGET_ZARCH"
5174 "#"
5175 "&& reload_completed"
5176 [(set (match_dup 0)
5177 (and:DI (subreg:DI (match_dup 1) 0)
5178 (const_int 2147483647)))]
5179 "")
5180
5181 (define_insn "*llgt_sisi"
5182 [(set (match_operand:SI 0 "register_operand" "=d,d")
5183 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,T")
5184 (const_int 2147483647)))]
5185 "TARGET_ZARCH"
5186 "@
5187 llgtr\t%0,%1
5188 llgt\t%0,%1"
5189 [(set_attr "op_type" "RRE,RXE")
5190 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5191
5192 (define_insn "*llgt_didi"
5193 [(set (match_operand:DI 0 "register_operand" "=d,d")
5194 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
5195 (const_int 2147483647)))]
5196 "TARGET_ZARCH"
5197 "@
5198 llgtr\t%0,%1
5199 llgt\t%0,%N1"
5200 [(set_attr "op_type" "RRE,RXE")
5201 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5202
5203 (define_split
5204 [(set (match_operand:DSI 0 "register_operand" "")
5205 (and:DSI (match_operand:DSI 1 "nonimmediate_operand" "")
5206 (const_int 2147483647)))
5207 (clobber (reg:CC CC_REGNUM))]
5208 "TARGET_ZARCH && reload_completed"
5209 [(set (match_dup 0)
5210 (and:DSI (match_dup 1)
5211 (const_int 2147483647)))]
5212 "")
5213
5214 ;
5215 ; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
5216 ;
5217
5218 (define_expand "zero_extend<mode>di2"
5219 [(set (match_operand:DI 0 "register_operand" "")
5220 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
5221 ""
5222 {
5223 if (!TARGET_ZARCH)
5224 {
5225 rtx tmp = gen_reg_rtx (SImode);
5226 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
5227 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
5228 DONE;
5229 }
5230 else if (!TARGET_EXTIMM)
5231 {
5232 rtx bitcount = GEN_INT (64 - <HQI:bitsize>);
5233 operands[1] = gen_lowpart (DImode, operands[1]);
5234 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
5235 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
5236 DONE;
5237 }
5238 })
5239
5240 (define_expand "zero_extend<mode>si2"
5241 [(set (match_operand:SI 0 "register_operand" "")
5242 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
5243 ""
5244 {
5245 if (!TARGET_EXTIMM)
5246 {
5247 operands[1] = gen_lowpart (SImode, operands[1]);
5248 emit_insn (gen_andsi3 (operands[0], operands[1],
5249 GEN_INT ((1 << <HQI:bitsize>) - 1)));
5250 DONE;
5251 }
5252 })
5253
5254 ; llhrl, llghrl
5255 (define_insn "*zero_extendhi<mode>2_z10"
5256 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
5257 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,T,b")))]
5258 "TARGET_Z10"
5259 "@
5260 ll<g>hr\t%0,%1
5261 ll<g>h\t%0,%1
5262 ll<g>hrl\t%0,%1"
5263 [(set_attr "op_type" "RXY,RRE,RIL")
5264 (set_attr "type" "*,*,larl")
5265 (set_attr "cpu_facility" "*,*,z10")
5266 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")
5267 (set_attr "relative_long" "*,*,yes")])
5268
5269 ; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
5270 (define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
5271 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5272 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,T")))]
5273 "TARGET_EXTIMM"
5274 "@
5275 ll<g><hc>r\t%0,%1
5276 ll<g><hc>\t%0,%1"
5277 [(set_attr "op_type" "RRE,RXY")
5278 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
5279
5280 ; llgh, llgc
5281 (define_insn "*zero_extend<HQI:mode><GPR:mode>2"
5282 [(set (match_operand:GPR 0 "register_operand" "=d")
5283 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "T")))]
5284 "TARGET_ZARCH && !TARGET_EXTIMM"
5285 "llg<hc>\t%0,%1"
5286 [(set_attr "op_type" "RXY")
5287 (set_attr "z10prop" "z10_fwd_A3")])
5288
5289 (define_insn_and_split "*zero_extendhisi2_31"
5290 [(set (match_operand:SI 0 "register_operand" "=&d")
5291 (zero_extend:SI (match_operand:HI 1 "s_operand" "S")))
5292 (clobber (reg:CC CC_REGNUM))]
5293 "!TARGET_ZARCH"
5294 "#"
5295 "&& reload_completed"
5296 [(set (match_dup 0) (const_int 0))
5297 (parallel
5298 [(set (strict_low_part (match_dup 2)) (match_dup 1))
5299 (clobber (reg:CC CC_REGNUM))])]
5300 "operands[2] = gen_lowpart (HImode, operands[0]);")
5301
5302 (define_insn_and_split "*zero_extendqisi2_31"
5303 [(set (match_operand:SI 0 "register_operand" "=&d")
5304 (zero_extend:SI (match_operand:QI 1 "memory_operand" "T")))]
5305 "!TARGET_ZARCH"
5306 "#"
5307 "&& reload_completed"
5308 [(set (match_dup 0) (const_int 0))
5309 (set (strict_low_part (match_dup 2)) (match_dup 1))]
5310 "operands[2] = gen_lowpart (QImode, operands[0]);")
5311
5312 ;
5313 ; zero_extendqihi2 instruction pattern(s).
5314 ;
5315
5316 (define_expand "zero_extendqihi2"
5317 [(set (match_operand:HI 0 "register_operand" "")
5318 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
5319 "TARGET_ZARCH && !TARGET_EXTIMM"
5320 {
5321 operands[1] = gen_lowpart (HImode, operands[1]);
5322 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
5323 DONE;
5324 })
5325
5326 (define_insn "*zero_extendqihi2_64"
5327 [(set (match_operand:HI 0 "register_operand" "=d")
5328 (zero_extend:HI (match_operand:QI 1 "memory_operand" "T")))]
5329 "TARGET_ZARCH && !TARGET_EXTIMM"
5330 "llgc\t%0,%1"
5331 [(set_attr "op_type" "RXY")
5332 (set_attr "z10prop" "z10_fwd_A3")])
5333
5334 (define_insn_and_split "*zero_extendqihi2_31"
5335 [(set (match_operand:HI 0 "register_operand" "=&d")
5336 (zero_extend:HI (match_operand:QI 1 "memory_operand" "T")))]
5337 "!TARGET_ZARCH"
5338 "#"
5339 "&& reload_completed"
5340 [(set (match_dup 0) (const_int 0))
5341 (set (strict_low_part (match_dup 2)) (match_dup 1))]
5342 "operands[2] = gen_lowpart (QImode, operands[0]);")
5343
5344 ;
5345 ; fixuns_trunc(dd|td|sf|df|tf)(si|di)2 expander
5346 ;
5347
5348 ; This is the only entry point for fixuns_trunc. It multiplexes the
5349 ; expansion to either the *_emu expanders below for pre z196 machines
5350 ; or emits the default pattern otherwise.
5351 (define_expand "fixuns_trunc<FP:mode><GPR:mode>2<FP:tf_fpr>"
5352 [(parallel
5353 [(set (match_operand:GPR 0 "register_operand" "")
5354 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "")))
5355 (unspec:GPR [(match_dup 2)] UNSPEC_ROUND)
5356 (clobber (reg:CC CC_REGNUM))])]
5357 "TARGET_HARD_FLOAT"
5358 {
5359 if (!TARGET_Z196)
5360 {
5361 /* We don't provide emulation for TD|DD->SI. */
5362 if (GET_MODE_CLASS (<FP:MODE>mode) == MODE_DECIMAL_FLOAT
5363 && <GPR:MODE>mode == SImode)
5364 FAIL;
5365 emit_insn (gen_fixuns_trunc<FP:mode><GPR:mode>2_emu (operands[0],
5366 operands[1]));
5367 DONE;
5368 }
5369
5370 if (GET_MODE_CLASS (<FP:MODE>mode) == MODE_DECIMAL_FLOAT)
5371 operands[2] = GEN_INT (DFP_RND_TOWARD_0);
5372 else
5373 operands[2] = GEN_INT (BFP_RND_TOWARD_0);
5374 })
5375
5376 ; (sf|df|tf)->unsigned (si|di)
5377
5378 ; Emulate the unsigned conversion with the signed version for pre z196
5379 ; machines.
5380 (define_expand "fixuns_trunc<BFP:mode><GPR:mode>2_emu"
5381 [(parallel
5382 [(set (match_operand:GPR 0 "register_operand" "")
5383 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))
5384 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
5385 (clobber (reg:CC CC_REGNUM))])]
5386 "!TARGET_Z196 && TARGET_HARD_FLOAT"
5387 {
5388 rtx_code_label *label1 = gen_label_rtx ();
5389 rtx_code_label *label2 = gen_label_rtx ();
5390 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
5391 REAL_VALUE_TYPE cmp, sub;
5392
5393 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
5394 real_2expN (&cmp, <GPR:bitsize> - 1, <BFP:MODE>mode);
5395 real_2expN (&sub, <GPR:bitsize>, <BFP:MODE>mode);
5396
5397 emit_cmp_and_jump_insns (operands[1],
5398 const_double_from_real_value (cmp, <BFP:MODE>mode),
5399 LT, NULL_RTX, VOIDmode, 0, label1);
5400 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
5401 const_double_from_real_value (sub, <BFP:MODE>mode)));
5402 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
5403 GEN_INT (BFP_RND_TOWARD_MINF)));
5404 emit_jump (label2);
5405
5406 emit_label (label1);
5407 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
5408 operands[1],
5409 GEN_INT (BFP_RND_TOWARD_0)));
5410 emit_label (label2);
5411 DONE;
5412 })
5413
5414 ; dd->unsigned di
5415
5416 ; Emulate the unsigned conversion with the signed version for pre z196
5417 ; machines.
5418 (define_expand "fixuns_truncdddi2_emu"
5419 [(parallel
5420 [(set (match_operand:DI 0 "register_operand" "")
5421 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
5422 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
5423 (clobber (reg:CC CC_REGNUM))])]
5424
5425 "!TARGET_Z196 && TARGET_HARD_DFP"
5426 {
5427 rtx_code_label *label1 = gen_label_rtx ();
5428 rtx_code_label *label2 = gen_label_rtx ();
5429 rtx temp = gen_reg_rtx (TDmode);
5430 REAL_VALUE_TYPE cmp, sub;
5431
5432 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
5433 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
5434
5435 /* 2^63 can't be represented as 64bit DFP number with full precision. The
5436 solution is doing the check and the subtraction in TD mode and using a
5437 TD -> DI convert afterwards. */
5438 emit_insn (gen_extendddtd2 (temp, operands[1]));
5439 temp = force_reg (TDmode, temp);
5440 emit_cmp_and_jump_insns (temp,
5441 const_double_from_real_value (cmp, TDmode),
5442 LT, NULL_RTX, VOIDmode, 0, label1);
5443 emit_insn (gen_subtd3 (temp, temp,
5444 const_double_from_real_value (sub, TDmode)));
5445 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp,
5446 GEN_INT (DFP_RND_TOWARD_MINF)));
5447 emit_jump (label2);
5448
5449 emit_label (label1);
5450 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1],
5451 GEN_INT (DFP_RND_TOWARD_0)));
5452 emit_label (label2);
5453 DONE;
5454 })
5455
5456 ; td->unsigned di
5457
5458 ; Emulate the unsigned conversion with the signed version for pre z196
5459 ; machines.
5460 (define_expand "fixuns_trunctddi2_emu"
5461 [(parallel
5462 [(set (match_operand:DI 0 "register_operand" "")
5463 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))
5464 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
5465 (clobber (reg:CC CC_REGNUM))])]
5466
5467 "!TARGET_Z196 && TARGET_HARD_DFP"
5468 {
5469 rtx_code_label *label1 = gen_label_rtx ();
5470 rtx_code_label *label2 = gen_label_rtx ();
5471 rtx temp = gen_reg_rtx (TDmode);
5472 REAL_VALUE_TYPE cmp, sub;
5473
5474 operands[1] = force_reg (TDmode, operands[1]);
5475 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
5476 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
5477
5478 emit_cmp_and_jump_insns (operands[1],
5479 const_double_from_real_value (cmp, TDmode),
5480 LT, NULL_RTX, VOIDmode, 0, label1);
5481 emit_insn (gen_subtd3 (temp, operands[1],
5482 const_double_from_real_value (sub, TDmode)));
5483 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp,
5484 GEN_INT (DFP_RND_TOWARD_MINF)));
5485 emit_jump (label2);
5486
5487 emit_label (label1);
5488 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1],
5489 GEN_INT (DFP_RND_TOWARD_0)));
5490 emit_label (label2);
5491 DONE;
5492 })
5493
5494 ; Just a dummy to make the code in the first expander a bit easier.
5495 (define_expand "fixuns_trunc<mode>si2_emu"
5496 [(parallel
5497 [(set (match_operand:SI 0 "register_operand" "")
5498 (unsigned_fix:SI (match_operand:DFP 1 "register_operand" "")))
5499 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
5500 (clobber (reg:CC CC_REGNUM))])]
5501
5502 "!TARGET_Z196 && TARGET_HARD_DFP"
5503 {
5504 FAIL;
5505 })
5506
5507
5508 ; fixuns_trunc(tf|df|sf|td|dd)(di|si)2 instruction patterns.
5509
5510 ; df -> unsigned di, vxe2: sf -> unsigned si
5511 ; clgdbr, clfebr, wclgdb, wclfeb
5512 (define_insn "*fixuns_trunc<mode><toint>2_z13"
5513 [(set (match_operand:<TOINT> 0 "register_operand" "=d,v")
5514 (unsigned_fix:<TOINT> (match_operand:VX_CONV_BFP 1 "register_operand" "f,v")))
5515 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K,K")] UNSPEC_ROUND)
5516 (clobber (reg:CC CC_REGNUM))]
5517 "TARGET_VX && TARGET_HARD_FLOAT"
5518 "@
5519 cl<gf><xde>br\t%0,%h2,%1,0
5520 wcl<gf><xde>b\t%v0,%v1,0,%h2"
5521 [(set_attr "op_type" "RRF,VRR")
5522 (set_attr "type" "ftoi")])
5523
5524 ; (dd|td|sf|df|tf)->unsigned (di|si)
5525 ; clfebr, clfdbr, clfxbr, clgebr, clgdbr, clgxbr
5526 ; clfdtr, clfxtr, clgdtr, clgxtr
5527 (define_insn "*fixuns_trunc<FP:mode><GPR:mode>2_z196"
5528 [(set (match_operand:GPR 0 "register_operand" "=d")
5529 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "f")))
5530 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
5531 (clobber (reg:CC CC_REGNUM))]
5532 "TARGET_Z196 && TARGET_HARD_FLOAT
5533 && (!TARGET_VX || <GPR:MODE>mode != DImode || <FP:MODE>mode != DFmode)"
5534 "cl<GPR:gf><FP:xde><FP:bt>r\t%0,%h2,%1,0"
5535 [(set_attr "op_type" "RRF")
5536 (set_attr "type" "ftoi")])
5537
5538 (define_expand "fix_trunc<DSF:mode><GPR:mode>2"
5539 [(set (match_operand:GPR 0 "register_operand" "")
5540 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
5541 "TARGET_HARD_FLOAT"
5542 {
5543 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
5544 GEN_INT (BFP_RND_TOWARD_0)));
5545 DONE;
5546 })
5547
5548 ; df -> signed di, vxe2: sf -> signed si
5549 ; cgdbr, cfebr, wcgdb, wcfeb
5550 (define_insn "*fix_trunc<mode><toint>2_bfp_z13"
5551 [(set (match_operand:<TOINT> 0 "register_operand" "=d,v")
5552 (fix:<TOINT> (match_operand:VX_CONV_BFP 1 "register_operand" "f,v")))
5553 (unspec:<TOINT> [(match_operand:<TOINT> 2 "immediate_operand" "K,K")] UNSPEC_ROUND)
5554 (clobber (reg:CC CC_REGNUM))]
5555 "TARGET_VX && TARGET_HARD_FLOAT"
5556 "@
5557 c<gf><xde>br\t%0,%h2,%1
5558 wc<gf><xde>b\t%v0,%v1,0,%h2"
5559 [(set_attr "op_type" "RRE,VRR")
5560 (set_attr "type" "ftoi")])
5561
5562 ; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
5563 (define_insn "*fix_trunc<BFP:mode><GPR:mode>2_bfp"
5564 [(set (match_operand:GPR 0 "register_operand" "=d")
5565 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
5566 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
5567 (clobber (reg:CC CC_REGNUM))]
5568 "TARGET_HARD_FLOAT
5569 && (!TARGET_VX || <GPR:MODE>mode != DImode || <BFP:MODE>mode != DFmode)"
5570 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
5571 [(set_attr "op_type" "RRE")
5572 (set_attr "type" "ftoi")])
5573
5574 (define_expand "fix_trunc<BFP:mode><GPR:mode>2_bfp"
5575 [(parallel
5576 [(set (match_operand:GPR 0 "register_operand" "=d")
5577 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
5578 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
5579 (clobber (reg:CC CC_REGNUM))])]
5580 "TARGET_HARD_FLOAT")
5581 ;
5582 ; fix_trunc(td|dd)di2 instruction pattern(s).
5583 ;
5584
5585 (define_expand "fix_trunc<mode>di2"
5586 [(set (match_operand:DI 0 "register_operand" "")
5587 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
5588 "TARGET_ZARCH && TARGET_HARD_DFP"
5589 {
5590 operands[1] = force_reg (<MODE>mode, operands[1]);
5591 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
5592 GEN_INT (DFP_RND_TOWARD_0)));
5593 DONE;
5594 })
5595
5596 ; cgxtr, cgdtr
5597 (define_insn "fix_trunc<DFP:mode>di2_dfp"
5598 [(set (match_operand:DI 0 "register_operand" "=d")
5599 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
5600 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
5601 (clobber (reg:CC CC_REGNUM))]
5602 "TARGET_ZARCH && TARGET_HARD_DFP"
5603 "cg<DFP:xde>tr\t%0,%h2,%1"
5604 [(set_attr "op_type" "RRF")
5605 (set_attr "type" "ftoidfp")])
5606
5607
5608 ;
5609 ; fix_trunctf(si|di)2 instruction pattern(s).
5610 ;
5611
5612 (define_expand "fix_trunctf<mode>2_fpr"
5613 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
5614 (fix:GPR (match_operand:TF 1 "register_operand" "")))
5615 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
5616 (clobber (reg:CC CC_REGNUM))])]
5617 "TARGET_HARD_FLOAT && !TARGET_VXE"
5618 "")
5619
5620
5621 ;
5622 ; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
5623 ;
5624
5625 ; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
5626 (define_insn "floatdi<mode>2<tf_fpr>"
5627 [(set (match_operand:FP 0 "register_operand" "=f,v")
5628 (float:FP (match_operand:DI 1 "register_operand" "d,v")))]
5629 "TARGET_ZARCH && TARGET_HARD_FLOAT"
5630 "@
5631 c<xde>g<bt>r\t%0,%1
5632 wcdgb\t%v0,%v1,0,0"
5633 [(set_attr "op_type" "RRE,VRR")
5634 (set_attr "type" "itof<type>" )
5635 (set_attr "cpu_facility" "*,vx")
5636 (set_attr "enabled" "*,<DFDI>")])
5637
5638 ; cxfbr, cdfbr, cefbr, wcefb
5639 (define_insn "floatsi<mode>2<tf_fpr>"
5640 [(set (match_operand:BFP 0 "register_operand" "=f,v")
5641 (float:BFP (match_operand:SI 1 "register_operand" "d,v")))]
5642 "TARGET_HARD_FLOAT"
5643 "@
5644 c<xde>fbr\t%0,%1
5645 wcefb\t%v0,%v1,0,0"
5646 [(set_attr "op_type" "RRE,VRR")
5647 (set_attr "type" "itof<type>" )
5648 (set_attr "cpu_facility" "*,vxe2")
5649 (set_attr "enabled" "*,<SFSI>")])
5650
5651 ; cxftr, cdftr
5652 (define_insn "floatsi<mode>2"
5653 [(set (match_operand:DFP 0 "register_operand" "=f")
5654 (float:DFP (match_operand:SI 1 "register_operand" "d")))]
5655 "TARGET_Z196 && TARGET_HARD_FLOAT"
5656 "c<xde>ftr\t%0,0,%1,0"
5657 [(set_attr "op_type" "RRE")
5658 (set_attr "type" "itof<type>")])
5659
5660 ;
5661 ; floatuns(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
5662 ;
5663
5664 (define_insn "*floatuns<toint><mode>2_z13"
5665 [(set (match_operand:VX_CONV_BFP 0 "register_operand" "=f,v")
5666 (unsigned_float:VX_CONV_BFP (match_operand:<TOINT> 1 "register_operand" "d,v")))]
5667 "TARGET_VX && TARGET_HARD_FLOAT"
5668 "@
5669 c<xde>l<gf>br\t%0,0,%1,0
5670 wc<xde>l<gf>b\t%v0,%v1,0,0"
5671 [(set_attr "op_type" "RRE,VRR")
5672 (set_attr "type" "itofdf")])
5673
5674 ; cxlgbr, cdlgbr, celgbr, cxlgtr, cdlgtr
5675 ; cxlfbr, cdlfbr, celfbr, cxlftr, cdlftr
5676 (define_insn "*floatuns<GPR:mode><FP:mode>2"
5677 [(set (match_operand:FP 0 "register_operand" "=f")
5678 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "d")))]
5679 "TARGET_Z196 && TARGET_HARD_FLOAT
5680 && (!TARGET_VX || <FP:MODE>mode != DFmode || <GPR:MODE>mode != DImode)"
5681 "c<FP:xde>l<GPR:gf><FP:bt>r\t%0,0,%1,0"
5682 [(set_attr "op_type" "RRE")
5683 (set_attr "type" "itof<FP:type>")])
5684
5685 (define_expand "floatuns<GPR:mode><FP:mode>2<tf_fpr>"
5686 [(set (match_operand:FP 0 "register_operand" "")
5687 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "")))]
5688 "TARGET_Z196 && TARGET_HARD_FLOAT")
5689
5690 ;
5691 ; truncdfsf2 instruction pattern(s).
5692 ;
5693
5694 (define_insn "truncdfsf2"
5695 [(set (match_operand:SF 0 "register_operand" "=f,v")
5696 (float_truncate:SF (match_operand:DF 1 "register_operand" "f,v")))]
5697 "TARGET_HARD_FLOAT"
5698 "@
5699 ledbr\t%0,%1
5700 wledb\t%v0,%v1,0,0" ; IEEE inexact exception not suppressed
5701 ; According to BFP rounding mode
5702 [(set_attr "op_type" "RRE,VRR")
5703 (set_attr "type" "ftruncdf")
5704 (set_attr "cpu_facility" "*,vx")])
5705
5706 ;
5707 ; trunctf(df|sf)2 instruction pattern(s).
5708 ;
5709
5710 ; ldxbr, lexbr
5711 (define_insn "trunctf<mode>2_fpr"
5712 [(set (match_operand:DSF 0 "register_operand" "=f")
5713 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
5714 (clobber (match_scratch:TF 2 "=f"))]
5715 "TARGET_HARD_FLOAT"
5716 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
5717 [(set_attr "length" "6")
5718 (set_attr "type" "ftrunctf")])
5719
5720 ;
5721 ; trunctddd2 and truncddsd2 instruction pattern(s).
5722 ;
5723
5724
5725 (define_expand "trunctddd2"
5726 [(parallel
5727 [(set (match_operand:DD 0 "register_operand" "")
5728 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
5729 (unspec:DI [(const_int DFP_RND_CURRENT)] UNSPEC_ROUND)
5730 (clobber (scratch:TD))])]
5731 "TARGET_HARD_DFP")
5732
5733 (define_insn "*trunctddd2"
5734 [(set (match_operand:DD 0 "register_operand" "=f")
5735 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
5736 (unspec:DI [(match_operand:DI 2 "const_mask_operand" "I")] UNSPEC_ROUND)
5737 (clobber (match_scratch:TD 3 "=f"))]
5738 "TARGET_HARD_DFP"
5739 "ldxtr\t%3,%2,%1,0\;ldr\t%0,%3"
5740 [(set_attr "length" "6")
5741 (set_attr "type" "ftruncdd")])
5742
5743 (define_insn "truncddsd2"
5744 [(set (match_operand:SD 0 "register_operand" "=f")
5745 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
5746 "TARGET_HARD_DFP"
5747 "ledtr\t%0,0,%1,0"
5748 [(set_attr "op_type" "RRF")
5749 (set_attr "type" "ftruncsd")])
5750
5751 (define_expand "trunctdsd2"
5752 [(parallel
5753 [(set (match_dup 2)
5754 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
5755 (unspec:DI [(const_int DFP_RND_PREP_FOR_SHORT_PREC)] UNSPEC_ROUND)
5756 (clobber (match_scratch:TD 3 ""))])
5757 (set (match_operand:SD 0 "register_operand" "")
5758 (float_truncate:SD (match_dup 2)))]
5759 "TARGET_HARD_DFP"
5760 {
5761 operands[2] = gen_reg_rtx (DDmode);
5762 })
5763
5764 ;
5765 ; extend(sf|df)(df|tf)2 instruction pattern(s).
5766 ;
5767
5768 ; wflls
5769 (define_insn "*extendsfdf2_z13"
5770 [(set (match_operand:DF 0 "register_operand" "=f,f,v")
5771 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R,v")))]
5772 "TARGET_VX && TARGET_HARD_FLOAT"
5773 "@
5774 ldebr\t%0,%1
5775 ldeb\t%0,%1
5776 wldeb\t%v0,%v1"
5777 [(set_attr "op_type" "RRE,RXE,VRR")
5778 (set_attr "type" "fsimpdf, floaddf,fsimpdf")])
5779
5780 ; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
5781 (define_insn "*extend<DSF:mode><BFP:mode>2"
5782 [(set (match_operand:BFP 0 "register_operand" "=f,f")
5783 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
5784 "TARGET_HARD_FLOAT
5785 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)
5786 && (!TARGET_VX || <BFP:MODE>mode != DFmode || <DSF:MODE>mode != SFmode)"
5787 "@
5788 l<BFP:xde><DSF:xde>br\t%0,%1
5789 l<BFP:xde><DSF:xde>b\t%0,%1"
5790 [(set_attr "op_type" "RRE,RXE")
5791 (set_attr "type" "fsimp<BFP:type>, fload<BFP:type>")])
5792
5793 (define_expand "extend<DSF:mode><BFP:mode>2<BFP:tf_fpr>"
5794 [(set (match_operand:BFP 0 "register_operand" "")
5795 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "")))]
5796 "TARGET_HARD_FLOAT
5797 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)")
5798
5799 ;
5800 ; extendddtd2 and extendsddd2 instruction pattern(s).
5801 ;
5802
5803 (define_insn "extendddtd2"
5804 [(set (match_operand:TD 0 "register_operand" "=f")
5805 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
5806 "TARGET_HARD_DFP"
5807 "lxdtr\t%0,%1,0"
5808 [(set_attr "op_type" "RRF")
5809 (set_attr "type" "fsimptf")])
5810
5811 (define_insn "extendsddd2"
5812 [(set (match_operand:DD 0 "register_operand" "=f")
5813 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
5814 "TARGET_HARD_DFP"
5815 "ldetr\t%0,%1,0"
5816 [(set_attr "op_type" "RRF")
5817 (set_attr "type" "fsimptf")])
5818
5819 (define_expand "extendsdtd2"
5820 [(set (match_dup 2)
5821 (float_extend:DD (match_operand:SD 1 "register_operand" "")))
5822 (set (match_operand:TD 0 "register_operand" "")
5823 (float_extend:TD (match_dup 2)))]
5824 "TARGET_HARD_DFP"
5825 {
5826 operands[2] = gen_reg_rtx (DDmode);
5827 })
5828
5829 ; Binary Floating Point - load fp integer
5830
5831 ; Expanders for: floor, btrunc, round, ceil, and nearbyint
5832 ; For all of them the inexact exceptions are suppressed.
5833
5834 ; fiebra, fidbra, fixbra
5835 (define_insn "<FPINT:fpint_name><BFP:mode>2<BFP:tf_fpr>"
5836 [(set (match_operand:BFP 0 "register_operand" "=f")
5837 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
5838 FPINT))]
5839 "TARGET_Z196"
5840 "fi<BFP:xde>bra\t%0,<FPINT:fpint_roundingmode>,%1,4"
5841 [(set_attr "op_type" "RRF")
5842 (set_attr "type" "fsimp<BFP:type>")])
5843
5844 ; rint is supposed to raise an inexact exception so we can use the
5845 ; older instructions.
5846
5847 ; fiebr, fidbr, fixbr
5848 (define_insn "rint<BFP:mode>2<BFP:tf_fpr>"
5849 [(set (match_operand:BFP 0 "register_operand" "=f")
5850 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
5851 UNSPEC_FPINT_RINT))]
5852 ""
5853 "fi<BFP:xde>br\t%0,0,%1"
5854 [(set_attr "op_type" "RRF")
5855 (set_attr "type" "fsimp<BFP:type>")])
5856
5857
5858 ; Decimal Floating Point - load fp integer
5859
5860 ; fidtr, fixtr
5861 (define_insn "<FPINT:fpint_name><DFP:mode>2"
5862 [(set (match_operand:DFP 0 "register_operand" "=f")
5863 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
5864 FPINT))]
5865 "TARGET_HARD_DFP"
5866 "fi<DFP:xde>tr\t%0,<FPINT:fpint_roundingmode>,%1,4"
5867 [(set_attr "op_type" "RRF")
5868 (set_attr "type" "fsimp<DFP:type>")])
5869
5870 ; fidtr, fixtr
5871 (define_insn "rint<DFP:mode>2"
5872 [(set (match_operand:DFP 0 "register_operand" "=f")
5873 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
5874 UNSPEC_FPINT_RINT))]
5875 "TARGET_HARD_DFP"
5876 "fi<DFP:xde>tr\t%0,0,%1,0"
5877 [(set_attr "op_type" "RRF")
5878 (set_attr "type" "fsimp<DFP:type>")])
5879
5880 ;
5881 ; Binary <-> Decimal floating point trunc patterns
5882 ;
5883
5884 (define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
5885 [(set (reg:DFP_ALL FPR0_REGNUM)
5886 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
5887 (use (reg:SI GPR0_REGNUM))
5888 (clobber (reg:CC CC_REGNUM))
5889 (clobber (reg:SI GPR1_REGNUM))]
5890 "TARGET_HARD_DFP"
5891 "pfpo")
5892
5893 (define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
5894 [(set (reg:BFP FPR0_REGNUM)
5895 (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
5896 (use (reg:SI GPR0_REGNUM))
5897 (clobber (reg:CC CC_REGNUM))
5898 (clobber (reg:SI GPR1_REGNUM))]
5899 "TARGET_HARD_DFP"
5900 "pfpo")
5901
5902 (define_expand "trunc<BFP:mode><DFP_ALL:mode>2<BFP:tf_fpr>"
5903 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
5904 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5905 (parallel
5906 [(set (reg:DFP_ALL FPR0_REGNUM)
5907 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
5908 (use (reg:SI GPR0_REGNUM))
5909 (clobber (reg:CC CC_REGNUM))
5910 (clobber (reg:SI GPR1_REGNUM))])
5911 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
5912 (reg:DFP_ALL FPR0_REGNUM))]
5913 "TARGET_HARD_DFP
5914 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
5915 {
5916 HOST_WIDE_INT flags;
5917
5918 /* According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
5919 rounding mode of the target format needs to be used. */
5920
5921 flags = (PFPO_CONVERT |
5922 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
5923 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT |
5924 PFPO_RND_MODE_DFP);
5925
5926 operands[2] = GEN_INT (flags);
5927 })
5928
5929 (define_expand "trunc<DFP_ALL:mode><BFP:mode>2<BFP:tf_fpr>"
5930 [(set (reg:DFP_ALL FPR4_REGNUM)
5931 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
5932 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5933 (parallel
5934 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
5935 (use (reg:SI GPR0_REGNUM))
5936 (clobber (reg:CC CC_REGNUM))
5937 (clobber (reg:SI GPR1_REGNUM))])
5938 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
5939 "TARGET_HARD_DFP
5940 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
5941 {
5942 HOST_WIDE_INT flags;
5943
5944 /* According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
5945 rounding mode of the target format needs to be used. */
5946
5947 flags = (PFPO_CONVERT |
5948 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
5949 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT |
5950 PFPO_RND_MODE_BFP);
5951
5952 operands[2] = GEN_INT (flags);
5953 })
5954
5955 ;
5956 ; Binary <-> Decimal floating point extend patterns
5957 ;
5958
5959 (define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
5960 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
5961 (use (reg:SI GPR0_REGNUM))
5962 (clobber (reg:CC CC_REGNUM))
5963 (clobber (reg:SI GPR1_REGNUM))]
5964 "TARGET_HARD_DFP"
5965 "pfpo")
5966
5967 (define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
5968 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
5969 (use (reg:SI GPR0_REGNUM))
5970 (clobber (reg:CC CC_REGNUM))
5971 (clobber (reg:SI GPR1_REGNUM))]
5972 "TARGET_HARD_DFP"
5973 "pfpo")
5974
5975 (define_expand "extend<BFP:mode><DFP_ALL:mode>2<BFP:tf_fpr>"
5976 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
5977 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5978 (parallel
5979 [(set (reg:DFP_ALL FPR0_REGNUM)
5980 (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
5981 (use (reg:SI GPR0_REGNUM))
5982 (clobber (reg:CC CC_REGNUM))
5983 (clobber (reg:SI GPR1_REGNUM))])
5984 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
5985 (reg:DFP_ALL FPR0_REGNUM))]
5986 "TARGET_HARD_DFP
5987 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
5988 {
5989 HOST_WIDE_INT flags;
5990
5991 /* According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
5992 rounding mode of the target format needs to be used. */
5993
5994 flags = (PFPO_CONVERT |
5995 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
5996 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT |
5997 PFPO_RND_MODE_DFP);
5998
5999 operands[2] = GEN_INT (flags);
6000 })
6001
6002 (define_expand "extend<DFP_ALL:mode><BFP:mode>2<BFP:tf_fpr>"
6003 [(set (reg:DFP_ALL FPR4_REGNUM)
6004 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
6005 (set (reg:SI GPR0_REGNUM) (match_dup 2))
6006 (parallel
6007 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
6008 (use (reg:SI GPR0_REGNUM))
6009 (clobber (reg:CC CC_REGNUM))
6010 (clobber (reg:SI GPR1_REGNUM))])
6011 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
6012 "TARGET_HARD_DFP
6013 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
6014 {
6015 HOST_WIDE_INT flags;
6016
6017 /* According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
6018 rounding mode of the target format needs to be used. */
6019
6020 flags = (PFPO_CONVERT |
6021 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
6022 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT |
6023 PFPO_RND_MODE_BFP);
6024
6025 operands[2] = GEN_INT (flags);
6026 })
6027
6028
6029 ;;
6030 ;; ARITHMETIC OPERATIONS
6031 ;;
6032 ; arithmetic operations set the ConditionCode,
6033 ; because of unpredictable Bits in Register for Halfword and Byte
6034 ; the ConditionCode can be set wrong in operations for Halfword and Byte
6035
6036 ;;
6037 ;;- Add instructions.
6038 ;;
6039
6040 ;
6041 ; addti3 instruction pattern(s).
6042 ;
6043
6044 (define_expand "addti3"
6045 [(parallel
6046 [(set (match_operand:TI 0 "register_operand" "")
6047 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "")
6048 (match_operand:TI 2 "general_operand" "") ) )
6049 (clobber (reg:CC CC_REGNUM))])]
6050 "TARGET_ZARCH"
6051 {
6052 /* For z13 we have vaq which doesn't set CC. */
6053 if (TARGET_VX)
6054 {
6055 emit_insn (gen_rtx_SET (operands[0],
6056 gen_rtx_PLUS (TImode,
6057 copy_to_mode_reg (TImode, operands[1]),
6058 copy_to_mode_reg (TImode, operands[2]))));
6059 DONE;
6060 }
6061 })
6062
6063 (define_insn_and_split "*addti3"
6064 [(set (match_operand:TI 0 "register_operand" "=&d")
6065 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
6066 (match_operand:TI 2 "general_operand" "do") ) )
6067 (clobber (reg:CC CC_REGNUM))]
6068 "TARGET_ZARCH"
6069 "#"
6070 "&& reload_completed"
6071 [(parallel
6072 [(set (reg:CCL1 CC_REGNUM)
6073 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
6074 (match_dup 7)))
6075 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
6076 (parallel
6077 [(set (match_dup 3) (plus:DI
6078 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
6079 (match_dup 4)) (match_dup 5)))
6080 (clobber (reg:CC CC_REGNUM))])]
6081 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
6082 operands[4] = operand_subword (operands[1], 0, 0, TImode);
6083 operands[5] = operand_subword (operands[2], 0, 0, TImode);
6084 operands[6] = operand_subword (operands[0], 1, 0, TImode);
6085 operands[7] = operand_subword (operands[1], 1, 0, TImode);
6086 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
6087 [(set_attr "op_type" "*")
6088 (set_attr "cpu_facility" "*")])
6089
6090 ;
6091 ; adddi3 instruction pattern(s).
6092 ;
6093
6094 (define_expand "adddi3"
6095 [(parallel
6096 [(set (match_operand:DI 0 "nonimmediate_operand" "")
6097 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
6098 (match_operand:DI 2 "general_operand" "")))
6099 (clobber (reg:CC CC_REGNUM))])]
6100 ""
6101 "")
6102
6103 (define_insn "*adddi3_sign"
6104 [(set (match_operand:DI 0 "register_operand" "=d,d")
6105 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
6106 (match_operand:DI 1 "register_operand" "0,0")))
6107 (clobber (reg:CC CC_REGNUM))]
6108 "TARGET_ZARCH"
6109 "@
6110 agfr\t%0,%2
6111 agf\t%0,%2"
6112 [(set_attr "op_type" "RRE,RXY")
6113 (set_attr "z196prop" "z196_cracked,z196_cracked")])
6114
6115 (define_insn "*adddi3_zero_cc"
6116 [(set (reg CC_REGNUM)
6117 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
6118 (match_operand:DI 1 "register_operand" "0,0"))
6119 (const_int 0)))
6120 (set (match_operand:DI 0 "register_operand" "=d,d")
6121 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
6122 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
6123 "@
6124 algfr\t%0,%2
6125 algf\t%0,%2"
6126 [(set_attr "op_type" "RRE,RXY")
6127 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6128
6129 (define_insn "*adddi3_zero_cconly"
6130 [(set (reg CC_REGNUM)
6131 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
6132 (match_operand:DI 1 "register_operand" "0,0"))
6133 (const_int 0)))
6134 (clobber (match_scratch:DI 0 "=d,d"))]
6135 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
6136 "@
6137 algfr\t%0,%2
6138 algf\t%0,%2"
6139 [(set_attr "op_type" "RRE,RXY")
6140 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6141
6142 (define_insn "*adddi3_zero"
6143 [(set (match_operand:DI 0 "register_operand" "=d,d")
6144 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
6145 (match_operand:DI 1 "register_operand" "0,0")))
6146 (clobber (reg:CC CC_REGNUM))]
6147 "TARGET_ZARCH"
6148 "@
6149 algfr\t%0,%2
6150 algf\t%0,%2"
6151 [(set_attr "op_type" "RRE,RXY")
6152 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6153
6154 (define_insn_and_split "*adddi3_31z"
6155 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
6156 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
6157 (match_operand:DI 2 "general_operand" "do") ) )
6158 (clobber (reg:CC CC_REGNUM))]
6159 "!TARGET_ZARCH"
6160 "#"
6161 "&& reload_completed"
6162 [(parallel
6163 [(set (reg:CCL1 CC_REGNUM)
6164 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
6165 (match_dup 7)))
6166 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
6167 (parallel
6168 [(set (match_dup 3) (plus:SI
6169 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
6170 (match_dup 4)) (match_dup 5)))
6171 (clobber (reg:CC CC_REGNUM))])]
6172 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
6173 operands[4] = operand_subword (operands[1], 0, 0, DImode);
6174 operands[5] = operand_subword (operands[2], 0, 0, DImode);
6175 operands[6] = operand_subword (operands[0], 1, 0, DImode);
6176 operands[7] = operand_subword (operands[1], 1, 0, DImode);
6177 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
6178
6179 ;
6180 ; addsi3 instruction pattern(s).
6181 ;
6182
6183 (define_expand "addsi3"
6184 [(parallel
6185 [(set (match_operand:SI 0 "nonimmediate_operand" "")
6186 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
6187 (match_operand:SI 2 "general_operand" "")))
6188 (clobber (reg:CC CC_REGNUM))])]
6189 ""
6190 "")
6191
6192 (define_insn "*addsi3_sign"
6193 [(set (match_operand:SI 0 "register_operand" "=d,d")
6194 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
6195 (match_operand:SI 1 "register_operand" "0,0")))
6196 (clobber (reg:CC CC_REGNUM))]
6197 ""
6198 "@
6199 ah\t%0,%2
6200 ahy\t%0,%2"
6201 [(set_attr "op_type" "RX,RXY")
6202 (set_attr "cpu_facility" "*,longdisp")
6203 (set_attr "z196prop" "z196_cracked,z196_cracked")])
6204
6205 ;
6206 ; add(di|si)3 instruction pattern(s).
6207 ;
6208
6209 ; ark, agrk, ar, ahi, ahik, aghik, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
6210 (define_insn "*add<mode>3"
6211 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d, d, d,d,d,S")
6212 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,d, 0, 0,0,0,0")
6213 (match_operand:GPR 2 "general_operand" " d,d,K,K,Op,On,R,T,C") ) )
6214 (clobber (reg:CC CC_REGNUM))]
6215 ""
6216 "@
6217 a<g>r\t%0,%2
6218 a<g>rk\t%0,%1,%2
6219 a<g>hi\t%0,%h2
6220 a<g>hik\t%0,%1,%h2
6221 al<g>fi\t%0,%2
6222 sl<g>fi\t%0,%n2
6223 a<g>\t%0,%2
6224 a<y>\t%0,%2
6225 a<g>si\t%0,%c2"
6226 [(set_attr "op_type" "RR<E>,RRF,RI,RIE,RIL,RIL,RX<Y>,RXY,SIY")
6227 (set_attr "cpu_facility" "*,z196,*,z196,extimm,extimm,*,longdisp,z10")
6228 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,z10_super_E1,z10_super_E1,
6229 z10_super_E1,z10_super_E1,z10_super_E1")])
6230
6231 ; alr, alfi, slfi, al, aly, alrk, alhsik, algr, algfi, slgfi, alg, alsi, algsi, algrk, alghsik
6232 (define_insn "add<mode>3_carry1_cc"
6233 [(set (reg:CCL1 CC_REGNUM)
6234 (compare:CCL1 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
6235 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
6236 (match_dup 1)))
6237 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,d")
6238 (plus:GPR (match_dup 1) (match_dup 2)))]
6239 ""
6240 "@
6241 al<g>r\t%0,%2
6242 al<g>rk\t%0,%1,%2
6243 al<g>fi\t%0,%2
6244 sl<g>fi\t%0,%n2
6245 al<g>hsik\t%0,%1,%h2
6246 al<g>\t%0,%2
6247 al<y>\t%0,%2
6248 al<g>si\t%0,%c2"
6249 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
6250 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
6251 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
6252 z10_super_E1,z10_super_E1,z10_super_E1")])
6253
6254 ; alr, al, aly, algr, alg, alrk, algrk
6255 (define_insn "*add<mode>3_carry1_cconly"
6256 [(set (reg CC_REGNUM)
6257 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
6258 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6259 (match_dup 1)))
6260 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6261 "s390_match_ccmode (insn, CCL1mode)"
6262 "@
6263 al<g>r\t%0,%2
6264 al<g>rk\t%0,%1,%2
6265 al<g>\t%0,%2
6266 al<y>\t%0,%2"
6267 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6268 (set_attr "cpu_facility" "*,z196,*,longdisp")
6269 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6270
6271 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
6272 (define_insn "*add<mode>3_carry2_cc"
6273 [(set (reg CC_REGNUM)
6274 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
6275 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
6276 (match_dup 2)))
6277 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,S")
6278 (plus:GPR (match_dup 1) (match_dup 2)))]
6279 "s390_match_ccmode (insn, CCL1mode)"
6280 "@
6281 al<g>r\t%0,%2
6282 al<g>rk\t%0,%1,%2
6283 al<g>fi\t%0,%2
6284 sl<g>fi\t%0,%n2
6285 al<g>hsik\t%0,%1,%h2
6286 al<g>\t%0,%2
6287 al<y>\t%0,%2
6288 al<g>si\t%0,%c2"
6289 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
6290 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
6291 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
6292 z10_super_E1,z10_super_E1,z10_super_E1")])
6293
6294 ; alr, al, aly, algr, alg, alrk, algrk
6295 (define_insn "*add<mode>3_carry2_cconly"
6296 [(set (reg CC_REGNUM)
6297 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
6298 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6299 (match_dup 2)))
6300 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6301 "s390_match_ccmode (insn, CCL1mode)"
6302 "@
6303 al<g>r\t%0,%2
6304 al<g>rk\t%0,%1,%2
6305 al<g>\t%0,%2
6306 al<y>\t%0,%2"
6307 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6308 (set_attr "cpu_facility" "*,z196,*,longdisp")
6309 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6310
6311 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
6312 (define_insn "*add<mode>3_cc"
6313 [(set (reg CC_REGNUM)
6314 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
6315 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
6316 (const_int 0)))
6317 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,S")
6318 (plus:GPR (match_dup 1) (match_dup 2)))]
6319 "s390_match_ccmode (insn, CCLmode)"
6320 "@
6321 al<g>r\t%0,%2
6322 al<g>rk\t%0,%1,%2
6323 al<g>fi\t%0,%2
6324 sl<g>fi\t%0,%n2
6325 al<g>hsik\t%0,%1,%h2
6326 al<g>\t%0,%2
6327 al<y>\t%0,%2
6328 al<g>si\t%0,%c2"
6329 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
6330 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
6331 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,
6332 *,z10_super_E1,z10_super_E1,z10_super_E1")])
6333
6334 ; alr, al, aly, algr, alg, alrk, algrk
6335 (define_insn "*add<mode>3_cconly"
6336 [(set (reg CC_REGNUM)
6337 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
6338 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6339 (const_int 0)))
6340 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6341 "s390_match_ccmode (insn, CCLmode)"
6342 "@
6343 al<g>r\t%0,%2
6344 al<g>rk\t%0,%1,%2
6345 al<g>\t%0,%2
6346 al<y>\t%0,%2"
6347 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6348 (set_attr "cpu_facility" "*,z196,*,longdisp")
6349 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6350
6351 ; alr, al, aly, algr, alg, alrk, algrk
6352 (define_insn "*add<mode>3_cconly2"
6353 [(set (reg CC_REGNUM)
6354 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
6355 (neg:GPR (match_operand:GPR 2 "general_operand" "d,d,R,T"))))
6356 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6357 "s390_match_ccmode(insn, CCLmode)"
6358 "@
6359 al<g>r\t%0,%2
6360 al<g>rk\t%0,%1,%2
6361 al<g>\t%0,%2
6362 al<y>\t%0,%2"
6363 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6364 (set_attr "cpu_facility" "*,z196,*,longdisp")
6365 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6366
6367 ; ahi, afi, aghi, agfi, asi, agsi
6368 (define_insn "*add<mode>3_imm_cc"
6369 [(set (reg CC_REGNUM)
6370 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" " 0, d,0, 0")
6371 (match_operand:GPR 2 "const_int_operand" " K, K,Os,C"))
6372 (const_int 0)))
6373 (set (match_operand:GPR 0 "nonimmediate_operand" "=d, d,d, S")
6374 (plus:GPR (match_dup 1) (match_dup 2)))]
6375 "s390_match_ccmode (insn, CCAmode)
6376 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
6377 || (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
6378 /* Avoid INT32_MIN on 32 bit. */
6379 && (!TARGET_ZARCH || INTVAL (operands[2]) != -0x7fffffff - 1)))"
6380 "@
6381 a<g>hi\t%0,%h2
6382 a<g>hik\t%0,%1,%h2
6383 a<g>fi\t%0,%2
6384 a<g>si\t%0,%c2"
6385 [(set_attr "op_type" "RI,RIE,RIL,SIY")
6386 (set_attr "cpu_facility" "*,z196,extimm,z10")
6387 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6388
6389 (define_insn "*adddi3_sign"
6390 [(set (match_operand:DI 0 "register_operand" "=d")
6391 (plus:DI (sign_extend:DI (match_operand:HI 2 "memory_operand" "T"))
6392 (match_operand:DI 1 "register_operand" "0")))
6393 (clobber (reg:CC CC_REGNUM))]
6394 "TARGET_Z14"
6395 "agh\t%0,%2"
6396 [(set_attr "op_type" "RXY")])
6397
6398
6399 ; Jump to label OP3 if OP1 + OP2 results in a signed overflow
6400
6401 ; addv_const_operand accepts all constants which can be handled
6402 ; without reloads. These will be handled primarily by
6403 ; "*addv<mode>3_ccoverflow_const" which doesn't provide a register
6404 ; alternative. Hence we have to match the operand exactly.
6405 ; For immediates we have to avoid the SIGN_EXTEND around OP2.
6406 (define_expand "addv<mode>4"
6407 [(parallel
6408 [(set (reg:CCO CC_REGNUM)
6409 (compare:CCO (plus:<DBL>
6410 (sign_extend:<DBL> (match_operand:GPR 1 "nonimmediate_operand"))
6411 (match_dup 4))
6412 (sign_extend:<DBL> (plus:GPR (match_dup 1)
6413 (match_operand:GPR 2 "general_operand")))))
6414 (set (match_operand:GPR 0 "nonimmediate_operand")
6415 (plus:GPR (match_dup 1) (match_dup 2)))])
6416 (set (pc)
6417 (if_then_else (ne (reg:CCO CC_REGNUM) (const_int 0))
6418 (label_ref (match_operand 3))
6419 (pc)))]
6420 ""
6421 {
6422 if (CONSTANT_P (operands[2])
6423 && !addv_const_operand (operands[2], GET_MODE (operands[2])))
6424 operands[2] = force_reg (<GPR:MODE>mode, operands[2]);
6425
6426 if (GET_MODE (operands[2]) != VOIDmode)
6427 operands[4] = gen_rtx_SIGN_EXTEND (<DBL>mode, operands[2]);
6428 else
6429 /* This is what CSE does when propagating a constant into the pattern. */
6430 operands[4] = simplify_unary_operation (SIGN_EXTEND, <GPR:DBL>mode, operands[2], <GPR:MODE>mode);
6431 })
6432
6433 ; ark, agrk, ar, ahi, ahik, aghik, a, ay, agr, aghi, ag, asi, agsi
6434 (define_insn "*addv<mode>3_ccoverflow"
6435 [(set (reg CC_REGNUM)
6436 (compare (plus:<DBL>
6437 (sign_extend:<DBL> (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,d,0,0,0"))
6438 (sign_extend:<DBL> (match_operand:GPR 2 "general_operand" " d,d,K,K,R,T,C")))
6439 (sign_extend:<DBL> (plus:GPR (match_dup 1) (match_dup 2)))))
6440 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,S")
6441 (plus:GPR (match_dup 1) (match_dup 2)))]
6442 "s390_match_ccmode (insn, CCOmode)"
6443 "@
6444 a<g>r\t%0,%2
6445 a<g>rk\t%0,%1,%2
6446 a<g>hi\t%0,%h2
6447 a<g>hik\t%0,%1,%h2
6448 a<g>\t%0,%2
6449 a<y>\t%0,%2
6450 a<g>si\t%0,%c2"
6451 [(set_attr "op_type" "RR<E>,RRF,RI,RIE,RX<Y>,RXY,SIY")
6452 (set_attr "cpu_facility" "*,z196,*,z196,*,longdisp,z10")
6453 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,
6454 z10_super_E1,z10_super_E1,z10_super_E1")])
6455
6456 ; ahi, aghi, ahik, aghik, asi, agsi
6457 (define_insn "*addv<mode>3_ccoverflow_const"
6458 [(set (reg CC_REGNUM)
6459 (compare (plus:<DBL>
6460 (sign_extend:<DBL> (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0"))
6461 (match_operand:<DBL> 2 "addv_const_operand" "K,K,C"))
6462 (sign_extend:<DBL> (plus:GPR (match_dup 1) (match_dup 2)))))
6463 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,S")
6464 (plus:GPR (match_dup 1) (match_dup 2)))]
6465 "s390_match_ccmode (insn, CCOmode)"
6466 "@
6467 a<g>hi\t%0,%h2
6468 a<g>hik\t%0,%1,%h2
6469 a<g>si\t%0,%c2"
6470 [(set_attr "op_type" "RI,RIE,SIY")
6471 (set_attr "cpu_facility" "*,z196,z10")
6472 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6473
6474
6475 ;
6476 ; add(tf|df|sf|td|dd)3 instruction pattern(s).
6477 ;
6478
6479 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
6480 ; FIXME: wfadb does not clobber cc
6481 (define_insn "add<mode>3<tf_fpr>"
6482 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v,v")
6483 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0,v,v")
6484 (match_operand:FP 2 "general_operand" "f,f,R,v,v")))
6485 (clobber (reg:CC CC_REGNUM))]
6486 "TARGET_HARD_FLOAT"
6487 "@
6488 a<xde>tr\t%0,%1,%2
6489 a<xde>br\t%0,%2
6490 a<xde>b\t%0,%2
6491 wfadb\t%v0,%v1,%v2
6492 wfasb\t%v0,%v1,%v2"
6493 [(set_attr "op_type" "RRF,RRE,RXE,VRR,VRR")
6494 (set_attr "type" "fsimp<type>")
6495 (set_attr "cpu_facility" "*,*,*,vx,vxe")
6496 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DF>,<SF>")])
6497
6498 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
6499 (define_insn "*add<mode>3_cc"
6500 [(set (reg CC_REGNUM)
6501 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0")
6502 (match_operand:FP 2 "general_operand" "f,f,R"))
6503 (match_operand:FP 3 "const0_operand" "")))
6504 (set (match_operand:FP 0 "register_operand" "=f,f,f")
6505 (plus:FP (match_dup 1) (match_dup 2)))]
6506 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6507 "@
6508 a<xde>tr\t%0,%1,%2
6509 a<xde>br\t%0,%2
6510 a<xde>b\t%0,%2"
6511 [(set_attr "op_type" "RRF,RRE,RXE")
6512 (set_attr "type" "fsimp<type>")
6513 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
6514
6515 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
6516 (define_insn "*add<mode>3_cconly"
6517 [(set (reg CC_REGNUM)
6518 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0")
6519 (match_operand:FP 2 "general_operand" "f,f,R"))
6520 (match_operand:FP 3 "const0_operand" "")))
6521 (clobber (match_scratch:FP 0 "=f,f,f"))]
6522 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6523 "@
6524 a<xde>tr\t%0,%1,%2
6525 a<xde>br\t%0,%2
6526 a<xde>b\t%0,%2"
6527 [(set_attr "op_type" "RRF,RRE,RXE")
6528 (set_attr "type" "fsimp<type>")
6529 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
6530
6531 ;
6532 ; Pointer add instruction patterns
6533 ;
6534
6535 ; This will match "*la_64"
6536 (define_expand "addptrdi3"
6537 [(set (match_operand:DI 0 "register_operand" "")
6538 (plus:DI (match_operand:DI 1 "register_operand" "")
6539 (match_operand:DI 2 "nonmemory_operand" "")))]
6540 "TARGET_64BIT"
6541 {
6542 if (GET_CODE (operands[2]) == CONST_INT)
6543 {
6544 HOST_WIDE_INT c = INTVAL (operands[2]);
6545
6546 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
6547 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
6548 {
6549 operands[2] = force_const_mem (DImode, operands[2]);
6550 operands[2] = force_reg (DImode, operands[2]);
6551 }
6552 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
6553 operands[2] = force_reg (DImode, operands[2]);
6554 }
6555 })
6556
6557 ; For 31 bit we have to prevent the generated pattern from matching
6558 ; normal ADDs since la only does a 31 bit add. This is supposed to
6559 ; match "force_la_31".
6560 (define_expand "addptrsi3"
6561 [(parallel
6562 [(set (match_operand:SI 0 "register_operand" "")
6563 (plus:SI (match_operand:SI 1 "register_operand" "")
6564 (match_operand:SI 2 "nonmemory_operand" "")))
6565 (use (const_int 0))])]
6566 "!TARGET_64BIT"
6567 {
6568 if (GET_CODE (operands[2]) == CONST_INT)
6569 {
6570 HOST_WIDE_INT c = INTVAL (operands[2]);
6571
6572 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
6573 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
6574 {
6575 operands[2] = force_const_mem (SImode, operands[2]);
6576 operands[2] = force_reg (SImode, operands[2]);
6577 }
6578 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
6579 operands[2] = force_reg (SImode, operands[2]);
6580 }
6581 })
6582
6583 ;;
6584 ;;- Subtract instructions.
6585 ;;
6586
6587 ;
6588 ; subti3 instruction pattern(s).
6589 ;
6590
6591 (define_expand "subti3"
6592 [(parallel
6593 [(set (match_operand:TI 0 "register_operand" "")
6594 (minus:TI (match_operand:TI 1 "register_operand" "")
6595 (match_operand:TI 2 "general_operand" "") ) )
6596 (clobber (reg:CC CC_REGNUM))])]
6597 "TARGET_ZARCH"
6598 {
6599 /* For z13 we have vsq which doesn't set CC. */
6600 if (TARGET_VX)
6601 {
6602 emit_insn (gen_rtx_SET (operands[0],
6603 gen_rtx_MINUS (TImode,
6604 operands[1],
6605 copy_to_mode_reg (TImode, operands[2]))));
6606 DONE;
6607 }
6608 })
6609
6610 (define_insn_and_split "*subti3"
6611 [(set (match_operand:TI 0 "register_operand" "=&d")
6612 (minus:TI (match_operand:TI 1 "register_operand" "0")
6613 (match_operand:TI 2 "general_operand" "do") ) )
6614 (clobber (reg:CC CC_REGNUM))]
6615 "TARGET_ZARCH"
6616 "#"
6617 "&& reload_completed"
6618 [(parallel
6619 [(set (reg:CCL2 CC_REGNUM)
6620 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
6621 (match_dup 7)))
6622 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
6623 (parallel
6624 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
6625 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
6626 (clobber (reg:CC CC_REGNUM))])]
6627 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
6628 operands[4] = operand_subword (operands[1], 0, 0, TImode);
6629 operands[5] = operand_subword (operands[2], 0, 0, TImode);
6630 operands[6] = operand_subword (operands[0], 1, 0, TImode);
6631 operands[7] = operand_subword (operands[1], 1, 0, TImode);
6632 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
6633 [(set_attr "op_type" "*")
6634 (set_attr "cpu_facility" "*")])
6635
6636 ;
6637 ; subdi3 instruction pattern(s).
6638 ;
6639
6640 (define_expand "subdi3"
6641 [(parallel
6642 [(set (match_operand:DI 0 "register_operand" "")
6643 (minus:DI (match_operand:DI 1 "register_operand" "")
6644 (match_operand:DI 2 "general_operand" "")))
6645 (clobber (reg:CC CC_REGNUM))])]
6646 ""
6647 "")
6648
6649 (define_insn "*subdi3_sign"
6650 [(set (match_operand:DI 0 "register_operand" "=d,d")
6651 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
6652 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))))
6653 (clobber (reg:CC CC_REGNUM))]
6654 "TARGET_ZARCH"
6655 "@
6656 sgfr\t%0,%2
6657 sgf\t%0,%2"
6658 [(set_attr "op_type" "RRE,RXY")
6659 (set_attr "z10prop" "z10_c,*")
6660 (set_attr "z196prop" "z196_cracked")])
6661
6662 (define_insn "*subdi3_zero_cc"
6663 [(set (reg CC_REGNUM)
6664 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
6665 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T")))
6666 (const_int 0)))
6667 (set (match_operand:DI 0 "register_operand" "=d,d")
6668 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
6669 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
6670 "@
6671 slgfr\t%0,%2
6672 slgf\t%0,%2"
6673 [(set_attr "op_type" "RRE,RXY")
6674 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
6675
6676 (define_insn "*subdi3_zero_cconly"
6677 [(set (reg CC_REGNUM)
6678 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
6679 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T")))
6680 (const_int 0)))
6681 (clobber (match_scratch:DI 0 "=d,d"))]
6682 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
6683 "@
6684 slgfr\t%0,%2
6685 slgf\t%0,%2"
6686 [(set_attr "op_type" "RRE,RXY")
6687 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
6688
6689 (define_insn "*subdi3_zero"
6690 [(set (match_operand:DI 0 "register_operand" "=d,d")
6691 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
6692 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))))
6693 (clobber (reg:CC CC_REGNUM))]
6694 "TARGET_ZARCH"
6695 "@
6696 slgfr\t%0,%2
6697 slgf\t%0,%2"
6698 [(set_attr "op_type" "RRE,RXY")
6699 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
6700
6701 (define_insn_and_split "*subdi3_31z"
6702 [(set (match_operand:DI 0 "register_operand" "=&d")
6703 (minus:DI (match_operand:DI 1 "register_operand" "0")
6704 (match_operand:DI 2 "general_operand" "do") ) )
6705 (clobber (reg:CC CC_REGNUM))]
6706 "!TARGET_ZARCH"
6707 "#"
6708 "&& reload_completed"
6709 [(parallel
6710 [(set (reg:CCL2 CC_REGNUM)
6711 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
6712 (match_dup 7)))
6713 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
6714 (parallel
6715 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
6716 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
6717 (clobber (reg:CC CC_REGNUM))])]
6718 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
6719 operands[4] = operand_subword (operands[1], 0, 0, DImode);
6720 operands[5] = operand_subword (operands[2], 0, 0, DImode);
6721 operands[6] = operand_subword (operands[0], 1, 0, DImode);
6722 operands[7] = operand_subword (operands[1], 1, 0, DImode);
6723 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
6724
6725 ;
6726 ; subsi3 instruction pattern(s).
6727 ;
6728
6729 (define_expand "subsi3"
6730 [(parallel
6731 [(set (match_operand:SI 0 "register_operand" "")
6732 (minus:SI (match_operand:SI 1 "register_operand" "")
6733 (match_operand:SI 2 "general_operand" "")))
6734 (clobber (reg:CC CC_REGNUM))])]
6735 ""
6736 "")
6737
6738 (define_insn "*subsi3_sign"
6739 [(set (match_operand:SI 0 "register_operand" "=d,d")
6740 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
6741 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
6742 (clobber (reg:CC CC_REGNUM))]
6743 ""
6744 "@
6745 sh\t%0,%2
6746 shy\t%0,%2"
6747 [(set_attr "op_type" "RX,RXY")
6748 (set_attr "cpu_facility" "*,longdisp")
6749 (set_attr "z196prop" "z196_cracked,z196_cracked")])
6750
6751 ;
6752 ; sub(di|si)3 instruction pattern(s).
6753 ;
6754
6755 ; sr, s, sy, sgr, sg, srk, sgrk
6756 (define_insn "*sub<mode>3"
6757 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6758 (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6759 (match_operand:GPR 2 "general_operand" "d,d,R,T") ) )
6760 (clobber (reg:CC CC_REGNUM))]
6761 ""
6762 "@
6763 s<g>r\t%0,%2
6764 s<g>rk\t%0,%1,%2
6765 s<g>\t%0,%2
6766 s<y>\t%0,%2"
6767 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6768 (set_attr "cpu_facility" "*,z196,*,longdisp")
6769 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6770
6771 ; slr, sl, sly, slgr, slg, slrk, slgrk
6772 (define_insn "sub<mode>3_borrow_cc"
6773 [(set (reg:CCL2 CC_REGNUM)
6774 (compare:CCL2 (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6775 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6776 (match_dup 1)))
6777 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6778 (minus:GPR (match_dup 1) (match_dup 2)))]
6779 ""
6780 "@
6781 sl<g>r\t%0,%2
6782 sl<g>rk\t%0,%1,%2
6783 sl<g>\t%0,%2
6784 sl<y>\t%0,%2"
6785 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6786 (set_attr "cpu_facility" "*,z196,*,longdisp")
6787 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6788
6789 ; slr, sl, sly, slgr, slg, slrk, slgrk
6790 (define_insn "*sub<mode>3_borrow_cconly"
6791 [(set (reg CC_REGNUM)
6792 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6793 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6794 (match_dup 1)))
6795 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6796 "s390_match_ccmode (insn, CCL2mode)"
6797 "@
6798 sl<g>r\t%0,%2
6799 sl<g>rk\t%0,%1,%2
6800 sl<g>\t%0,%2
6801 sl<y>\t%0,%2"
6802 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6803 (set_attr "cpu_facility" "*,z196,*,longdisp")
6804 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6805
6806 ; slr, sl, sly, slgr, slg, slrk, slgrk
6807 (define_insn "*sub<mode>3_cc"
6808 [(set (reg CC_REGNUM)
6809 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6810 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6811 (const_int 0)))
6812 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6813 (minus:GPR (match_dup 1) (match_dup 2)))]
6814 "s390_match_ccmode (insn, CCLmode)"
6815 "@
6816 sl<g>r\t%0,%2
6817 sl<g>rk\t%0,%1,%2
6818 sl<g>\t%0,%2
6819 sl<y>\t%0,%2"
6820 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6821 (set_attr "cpu_facility" "*,z196,*,longdisp")
6822 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6823
6824 ; slr, sl, sly, slgr, slg, slrk, slgrk
6825 (define_insn "*sub<mode>3_cc2"
6826 [(set (reg CC_REGNUM)
6827 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
6828 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
6829 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6830 (minus:GPR (match_dup 1) (match_dup 2)))]
6831 "s390_match_ccmode (insn, CCL3mode)"
6832 "@
6833 sl<g>r\t%0,%2
6834 sl<g>rk\t%0,%1,%2
6835 sl<g>\t%0,%2
6836 sl<y>\t%0,%2"
6837 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6838 (set_attr "cpu_facility" "*,z196,*,longdisp")
6839 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6840
6841 ; slr, sl, sly, slgr, slg, slrk, slgrk
6842 (define_insn "*sub<mode>3_cconly"
6843 [(set (reg CC_REGNUM)
6844 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6845 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6846 (const_int 0)))
6847 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6848 "s390_match_ccmode (insn, CCLmode)"
6849 "@
6850 sl<g>r\t%0,%2
6851 sl<g>rk\t%0,%1,%2
6852 sl<g>\t%0,%2
6853 sl<y>\t%0,%2"
6854 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6855 (set_attr "cpu_facility" "*,z196,*,longdisp")
6856 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6857
6858
6859 ; slr, sl, sly, slgr, slg, slrk, slgrk
6860 (define_insn "*sub<mode>3_cconly2"
6861 [(set (reg CC_REGNUM)
6862 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
6863 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
6864 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6865 "s390_match_ccmode (insn, CCL3mode)"
6866 "@
6867 sl<g>r\t%0,%2
6868 sl<g>rk\t%0,%1,%2
6869 sl<g>\t%0,%2
6870 sl<y>\t%0,%2"
6871 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6872 (set_attr "cpu_facility" "*,z196,*,longdisp")
6873 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6874
6875 (define_insn "*subdi3_sign"
6876 [(set (match_operand:DI 0 "register_operand" "=d")
6877 (minus:DI (match_operand:DI 1 "register_operand" "0")
6878 (sign_extend:DI (match_operand:HI 2 "memory_operand" "T"))))
6879 (clobber (reg:CC CC_REGNUM))]
6880 "TARGET_Z14"
6881 "sgh\t%0,%2"
6882 [(set_attr "op_type" "RXY")])
6883
6884 ; Jump to label OP3 if OP1 - OP2 results in a signed overflow
6885 (define_expand "subv<mode>4"
6886 [(parallel
6887 [(set (reg:CCO CC_REGNUM)
6888 (compare:CCO (minus:<DBL>
6889 (sign_extend:<DBL> (match_operand:GPR 1 "nonimmediate_operand"))
6890 (sign_extend:<DBL> (match_operand:GPR 2 "nonimmediate_operand")))
6891 (sign_extend:<DBL> (minus:GPR (match_dup 1) (match_dup 2)))))
6892 (set (match_operand:GPR 0 "nonimmediate_operand")
6893 (minus:GPR (match_dup 1) (match_dup 2)))])
6894 (set (pc)
6895 (if_then_else (ne (reg:CCO CC_REGNUM) (const_int 0))
6896 (label_ref (match_operand 3))
6897 (pc)))]
6898 "")
6899
6900 ; sr, s, sy, sgr, sg, srk, sgrk
6901 (define_insn "*subv<mode>3_ccoverflow"
6902 [(set (reg CC_REGNUM)
6903 (compare (minus:<DBL>
6904 (sign_extend:<DBL> (match_operand:GPR 1 "nonimmediate_operand" "0,d,0,0"))
6905 (sign_extend:<DBL> (match_operand:GPR 2 "nonimmediate_operand" "d,d,R,T")))
6906 (sign_extend:<DBL> (minus:GPR (match_dup 1) (match_dup 2)))))
6907 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6908 (minus:GPR (match_dup 1) (match_dup 2)))]
6909 "s390_match_ccmode (insn, CCOmode)"
6910 "@
6911 s<g>r\t%0,%2
6912 s<g>rk\t%0,%1,%2
6913 s<g>\t%0,%2
6914 s<y>\t%0,%2"
6915 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6916 (set_attr "cpu_facility" "*,z196,*,longdisp")
6917 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6918
6919
6920 ;
6921 ; sub(tf|df|sf|td|dd)3 instruction pattern(s).
6922 ;
6923
6924 ; FIXME: (clobber (match_scratch:CC 3 "=c,c,c,X,X")) does not work - why?
6925 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
6926 (define_insn "sub<mode>3<tf_fpr>"
6927 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v,v")
6928 (minus:FP (match_operand:FP 1 "register_operand" "f,0,0,v,v")
6929 (match_operand:FP 2 "general_operand" "f,f,R,v,v")))
6930 (clobber (reg:CC CC_REGNUM))]
6931 "TARGET_HARD_FLOAT"
6932 "@
6933 s<xde>tr\t%0,%1,%2
6934 s<xde>br\t%0,%2
6935 s<xde>b\t%0,%2
6936 wfsdb\t%v0,%v1,%v2
6937 wfssb\t%v0,%v1,%v2"
6938 [(set_attr "op_type" "RRF,RRE,RXE,VRR,VRR")
6939 (set_attr "type" "fsimp<type>")
6940 (set_attr "cpu_facility" "*,*,*,vx,vxe")
6941 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DF>,<SF>")])
6942
6943 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
6944 (define_insn "*sub<mode>3_cc"
6945 [(set (reg CC_REGNUM)
6946 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "f,0,0")
6947 (match_operand:FP 2 "general_operand" "f,f,R"))
6948 (match_operand:FP 3 "const0_operand" "")))
6949 (set (match_operand:FP 0 "register_operand" "=f,f,f")
6950 (minus:FP (match_dup 1) (match_dup 2)))]
6951 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6952 "@
6953 s<xde>tr\t%0,%1,%2
6954 s<xde>br\t%0,%2
6955 s<xde>b\t%0,%2"
6956 [(set_attr "op_type" "RRF,RRE,RXE")
6957 (set_attr "type" "fsimp<type>")
6958 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
6959
6960 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
6961 (define_insn "*sub<mode>3_cconly"
6962 [(set (reg CC_REGNUM)
6963 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "f,0,0")
6964 (match_operand:FP 2 "general_operand" "f,f,R"))
6965 (match_operand:FP 3 "const0_operand" "")))
6966 (clobber (match_scratch:FP 0 "=f,f,f"))]
6967 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6968 "@
6969 s<xde>tr\t%0,%1,%2
6970 s<xde>br\t%0,%2
6971 s<xde>b\t%0,%2"
6972 [(set_attr "op_type" "RRF,RRE,RXE")
6973 (set_attr "type" "fsimp<type>")
6974 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
6975
6976
6977 ;;
6978 ;;- Conditional add/subtract instructions.
6979 ;;
6980
6981 ;
6982 ; add(di|si)cc instruction pattern(s).
6983 ;
6984
6985 (define_expand "uaddc<mode>5"
6986 [(match_operand:GPR 0 "register_operand")
6987 (match_operand:GPR 1 "nonimmediate_operand")
6988 (match_operand:GPR 2 "nonimmediate_operand")
6989 (match_operand:GPR 3 "nonimmediate_operand")
6990 (match_operand:GPR 4 "general_operand")]
6991 "TARGET_Z196"
6992 {
6993 if (operands[4] == const0_rtx)
6994 emit_insn (gen_add<mode>3_carry1_cc (operands[0], operands[2], operands[3]));
6995 else
6996 {
6997 operands[4] = force_reg (<MODE>mode, operands[4]);
6998 rtx alc_cond = s390_emit_compare (<MODE>mode, GTU, operands[4], const0_rtx);
6999 emit_insn (gen_add<mode>3_alc_carry1_cc (operands[0], operands[2], operands[3], alc_cond));
7000 }
7001 rtx mov_cond = gen_rtx_LTU (<MODE>mode, gen_rtx_REG (CCL1mode, CC_REGNUM), const0_rtx);
7002 emit_insn (gen_mov<mode>cc (operands[1], mov_cond, const1_rtx, const0_rtx));
7003 DONE;
7004 })
7005
7006 ; the following 4 patterns are used when the result of an add with
7007 ; carry is checked for an overflow condition
7008
7009 ; op1 + op2 + c < op1
7010
7011 ; alcr, alc, alcgr, alcg
7012 (define_insn "add<mode>3_alc_carry1_cc"
7013 [(set (reg:CCL1 CC_REGNUM)
7014 (compare:CCL1
7015 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
7016 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
7017 (match_operand:GPR 2 "general_operand" "d,T"))
7018 (match_dup 1)))
7019 (set (match_operand:GPR 0 "register_operand" "=d,d")
7020 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
7021 ""
7022 "@
7023 alc<g>r\t%0,%2
7024 alc<g>\t%0,%2"
7025 [(set_attr "op_type" "RRE,RXY")
7026 (set_attr "z196prop" "z196_alone,z196_alone")])
7027
7028 ; alcr, alc, alcgr, alcg
7029 (define_insn "*add<mode>3_alc_carry1_cconly"
7030 [(set (reg CC_REGNUM)
7031 (compare
7032 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
7033 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
7034 (match_operand:GPR 2 "general_operand" "d,T"))
7035 (match_dup 1)))
7036 (clobber (match_scratch:GPR 0 "=d,d"))]
7037 "s390_match_ccmode (insn, CCL1mode)"
7038 "@
7039 alc<g>r\t%0,%2
7040 alc<g>\t%0,%2"
7041 [(set_attr "op_type" "RRE,RXY")
7042 (set_attr "z196prop" "z196_alone,z196_alone")])
7043
7044 ; op1 + op2 + c < op2
7045
7046 ; alcr, alc, alcgr, alcg
7047 (define_insn "*add<mode>3_alc_carry2_cc"
7048 [(set (reg CC_REGNUM)
7049 (compare
7050 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
7051 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
7052 (match_operand:GPR 2 "general_operand" "d,T"))
7053 (match_dup 2)))
7054 (set (match_operand:GPR 0 "register_operand" "=d,d")
7055 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
7056 "s390_match_ccmode (insn, CCL1mode)"
7057 "@
7058 alc<g>r\t%0,%2
7059 alc<g>\t%0,%2"
7060 [(set_attr "op_type" "RRE,RXY")])
7061
7062 ; alcr, alc, alcgr, alcg
7063 (define_insn "*add<mode>3_alc_carry2_cconly"
7064 [(set (reg CC_REGNUM)
7065 (compare
7066 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
7067 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
7068 (match_operand:GPR 2 "general_operand" "d,T"))
7069 (match_dup 2)))
7070 (clobber (match_scratch:GPR 0 "=d,d"))]
7071 "s390_match_ccmode (insn, CCL1mode)"
7072 "@
7073 alc<g>r\t%0,%2
7074 alc<g>\t%0,%2"
7075 [(set_attr "op_type" "RRE,RXY")])
7076
7077 ; alcr, alc, alcgr, alcg
7078 (define_insn "*add<mode>3_alc_cc"
7079 [(set (reg CC_REGNUM)
7080 (compare
7081 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
7082 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
7083 (match_operand:GPR 2 "general_operand" "d,T"))
7084 (const_int 0)))
7085 (set (match_operand:GPR 0 "register_operand" "=d,d")
7086 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
7087 "s390_match_ccmode (insn, CCLmode)"
7088 "@
7089 alc<g>r\t%0,%2
7090 alc<g>\t%0,%2"
7091 [(set_attr "op_type" "RRE,RXY")])
7092
7093 ; alcr, alc, alcgr, alcg
7094 (define_insn "*add<mode>3_alc"
7095 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7096 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
7097 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
7098 (match_operand:GPR 2 "general_operand" "d,T")))
7099 (clobber (reg:CC CC_REGNUM))]
7100 ""
7101 "@
7102 alc<g>r\t%0,%2
7103 alc<g>\t%0,%2"
7104 [(set_attr "op_type" "RRE,RXY")])
7105
7106 (define_expand "usubc<mode>5"
7107 [(match_operand:GPR 0 "register_operand")
7108 (match_operand:GPR 1 "nonimmediate_operand")
7109 (match_operand:GPR 2 "nonimmediate_operand")
7110 (match_operand:GPR 3 "nonimmediate_operand")
7111 (match_operand:GPR 4 "general_operand")]
7112 "TARGET_Z196"
7113 {
7114 if (operands[4] == const0_rtx)
7115 {
7116 operands[2] = force_reg (<MODE>mode, operands[2]);
7117 emit_insn (gen_sub<mode>3_borrow_cc (operands[0], operands[2], operands[3]));
7118 }
7119 else
7120 {
7121 rtx tmp = gen_reg_rtx (<MODE>mode);
7122 emit_insn (gen_xor<mode>3 (tmp, operands[4], const1_rtx));
7123 rtx slb_cond = s390_emit_compare (<MODE>mode, LEU, tmp, const0_rtx);
7124 emit_insn (gen_sub<mode>3_slb_borrow1_cc (operands[0], operands[2], operands[3], slb_cond));
7125 }
7126 rtx mov_cond = gen_rtx_GTU (<MODE>mode, gen_rtx_REG (CCL2mode, CC_REGNUM), const0_rtx);
7127 emit_insn (gen_mov<mode>cc (operands[1], mov_cond, const1_rtx, const0_rtx));
7128 DONE;
7129 })
7130
7131 ; slbr, slb, slbgr, slbg
7132 (define_insn "*sub<mode>3_slb_cc"
7133 [(set (reg CC_REGNUM)
7134 (compare
7135 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
7136 (match_operand:GPR 2 "general_operand" "d,T"))
7137 (match_operand:GPR 3 "s390_slb_comparison" ""))
7138 (const_int 0)))
7139 (set (match_operand:GPR 0 "register_operand" "=d,d")
7140 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
7141 "s390_match_ccmode (insn, CCLmode)"
7142 "@
7143 slb<g>r\t%0,%2
7144 slb<g>\t%0,%2"
7145 [(set_attr "op_type" "RRE,RXY")
7146 (set_attr "z10prop" "z10_c,*")])
7147
7148 ; slbr, slb, slbgr, slbg
7149 (define_insn "*sub<mode>3_slb"
7150 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7151 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
7152 (match_operand:GPR 2 "general_operand" "d,T"))
7153 (match_operand:GPR 3 "s390_slb_comparison" "")))
7154 (clobber (reg:CC CC_REGNUM))]
7155 ""
7156 "@
7157 slb<g>r\t%0,%2
7158 slb<g>\t%0,%2"
7159 [(set_attr "op_type" "RRE,RXY")
7160 (set_attr "z10prop" "z10_c,*")])
7161
7162 ; slbr, slb, slbgr, slbg
7163 (define_insn "sub<mode>3_slb_borrow1_cc"
7164 [(set (reg:CCL2 CC_REGNUM)
7165 (compare:CCL2
7166 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
7167 (match_operand:GPR 2 "general_operand" "d,T"))
7168 (match_operand:GPR 3 "s390_slb_comparison" ""))
7169 (match_dup 1)))
7170 (set (match_operand:GPR 0 "register_operand" "=d,d")
7171 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
7172 ""
7173 "@
7174 slb<g>r\t%0,%2
7175 slb<g>\t%0,%2"
7176 [(set_attr "op_type" "RRE,RXY")
7177 (set_attr "z10prop" "z10_c,*")])
7178
7179 (define_expand "add<mode>cc"
7180 [(match_operand:GPR 0 "register_operand" "")
7181 (match_operand 1 "comparison_operator" "")
7182 (match_operand:GPR 2 "register_operand" "")
7183 (match_operand:GPR 3 "const_int_operand" "")]
7184 ""
7185 "if (!s390_expand_addcc (GET_CODE (operands[1]),
7186 XEXP (operands[1], 0), XEXP (operands[1], 1),
7187 operands[0], operands[2],
7188 operands[3])) FAIL; DONE;")
7189
7190 ;
7191 ; scond instruction pattern(s).
7192 ;
7193
7194 (define_insn_and_split "*scond<mode>"
7195 [(set (match_operand:GPR 0 "register_operand" "=&d")
7196 (match_operand:GPR 1 "s390_alc_comparison" ""))
7197 (clobber (reg:CC CC_REGNUM))]
7198 ""
7199 "#"
7200 "&& reload_completed"
7201 [(set (match_dup 0) (const_int 0))
7202 (parallel
7203 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
7204 (match_dup 0)))
7205 (clobber (reg:CC CC_REGNUM))])]
7206 "")
7207
7208 (define_insn_and_split "*scond<mode>_neg"
7209 [(set (match_operand:GPR 0 "register_operand" "=&d")
7210 (match_operand:GPR 1 "s390_slb_comparison" ""))
7211 (clobber (reg:CC CC_REGNUM))]
7212 ""
7213 "#"
7214 "&& reload_completed"
7215 [(set (match_dup 0) (const_int 0))
7216 (parallel
7217 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
7218 (match_dup 1)))
7219 (clobber (reg:CC CC_REGNUM))])
7220 (parallel
7221 [(set (match_dup 0) (neg:GPR (match_dup 0)))
7222 (clobber (reg:CC CC_REGNUM))])]
7223 "")
7224
7225
7226 (define_expand "cstore<mode>4"
7227 [(set (match_operand:SI 0 "register_operand" "")
7228 (match_operator:SI 1 "s390_scond_operator"
7229 [(match_operand:GPR 2 "register_operand" "")
7230 (match_operand:GPR 3 "general_operand" "")]))]
7231 ""
7232 "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3],
7233 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
7234
7235 (define_expand "cstorecc4"
7236 [(parallel
7237 [(set (match_operand:SI 0 "register_operand" "")
7238 (match_operator:SI 1 "s390_eqne_operator"
7239 [(match_operand 2 "cc_reg_operand")
7240 (match_operand 3 "const_mask_operand")]))
7241 (clobber (reg:CC CC_REGNUM))])]
7242 ""
7243 "machine_mode mode = GET_MODE (operands[2]);
7244 if (TARGET_Z196)
7245 {
7246 rtx cond, ite;
7247
7248 if (GET_CODE (operands[1]) == NE)
7249 cond = gen_rtx_NE (VOIDmode, operands[2], operands[3]);
7250 else
7251 cond = gen_rtx_EQ (VOIDmode, operands[2], operands[3]);
7252 ite = gen_rtx_IF_THEN_ELSE (SImode, cond, const1_rtx, const0_rtx);
7253 emit_insn (gen_rtx_SET (operands[0], ite));
7254 }
7255 else
7256 {
7257 if (mode != CCZ1mode || operands[3] != const0_rtx)
7258 FAIL;
7259 emit_insn (gen_sne (operands[0], operands[2]));
7260 if (GET_CODE (operands[1]) == EQ)
7261 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
7262 }
7263 DONE;")
7264
7265 (define_insn_and_split "sne"
7266 [(set (match_operand:SI 0 "register_operand" "=d")
7267 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
7268 (const_int 0)))
7269 (clobber (reg:CC CC_REGNUM))]
7270 ""
7271 "#"
7272 "reload_completed"
7273 [(parallel
7274 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
7275 (clobber (reg:CC CC_REGNUM))])])
7276
7277 ; Such patterns get directly emitted by noce_emit_store_flag.
7278 (define_insn_and_split "*cstorecc<mode>_z13"
7279 [(set (match_operand:GPR 0 "register_operand" "=&d")
7280 (match_operator:GPR 1 "s390_comparison"
7281 [(match_operand 2 "cc_reg_operand" "c")
7282 (match_operand 3 "const_int_operand" "")]))]
7283 "TARGET_Z13"
7284 "#"
7285 "reload_completed"
7286 [(set (match_dup 0) (const_int 0))
7287 (set (match_dup 0)
7288 (if_then_else:GPR
7289 (match_op_dup 1 [(match_dup 2) (match_dup 3)])
7290 (const_int 1)
7291 (match_dup 0)))])
7292
7293 ;;
7294 ;; - Conditional move instructions (introduced with z196)
7295 ;;
7296
7297 (define_expand "mov<mode>cc"
7298 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
7299 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
7300 (match_operand:GPR 2 "loc_operand" "")
7301 (match_operand:GPR 3 "loc_operand" "")))]
7302 "TARGET_Z196"
7303 {
7304 if (!TARGET_Z13 && CONSTANT_P (operands[2]))
7305 operands[2] = force_reg (<MODE>mode, operands[2]);
7306
7307 if (!TARGET_Z13 && CONSTANT_P (operands[3]))
7308 operands[3] = force_reg (<MODE>mode, operands[3]);
7309
7310 /* Emit the comparison insn in case we do not already have a comparison result. */
7311 if (!s390_comparison (operands[1], VOIDmode))
7312 operands[1] = s390_emit_compare (VOIDmode,
7313 GET_CODE (operands[1]),
7314 XEXP (operands[1], 0),
7315 XEXP (operands[1], 1));
7316 })
7317
7318 ;;
7319 ;; - We do not have instructions for QImode or HImode but still
7320 ;; enable load on condition/if conversion for them.
7321 (define_expand "mov<mode>cc"
7322 [(set (match_operand:HQI 0 "nonimmediate_operand" "")
7323 (if_then_else:HQI (match_operand 1 "comparison_operator" "")
7324 (match_operand:HQI 2 "loc_operand" "")
7325 (match_operand:HQI 3 "loc_operand" "")))]
7326 "TARGET_Z196"
7327 {
7328 /* Emit the comparison insn in case we do not already have a comparison
7329 result. */
7330 if (!s390_comparison (operands[1], VOIDmode))
7331 operands[1] = s390_emit_compare (VOIDmode,
7332 GET_CODE (operands[1]),
7333 XEXP (operands[1], 0),
7334 XEXP (operands[1], 1));
7335
7336 rtx then = operands[2];
7337 rtx els = operands[3];
7338
7339 if ((!TARGET_Z13 && CONSTANT_P (then)) || MEM_P (then))
7340 then = force_reg (<MODE>mode, then);
7341 if ((!TARGET_Z13 && CONSTANT_P (els)) || MEM_P (els))
7342 els = force_reg (<MODE>mode, els);
7343
7344 if (!CONSTANT_P (then))
7345 then = simplify_gen_subreg (E_SImode, then, <MODE>mode, 0);
7346 if (!CONSTANT_P (els))
7347 els = simplify_gen_subreg (E_SImode, els, <MODE>mode, 0);
7348
7349 rtx tmp_target = simplify_gen_subreg (E_SImode, operands[0], <MODE>mode, 0);
7350
7351 emit_insn (gen_movsicc (tmp_target, operands[1], then, els));
7352 DONE;
7353 })
7354
7355
7356
7357 ; locr, loc, stoc, locgr, locg, stocg, lochi, locghi, selr, selgr
7358 (define_insn "*mov<mode>cc"
7359 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,S,S")
7360 (if_then_else:GPR
7361 (match_operator 1 "s390_comparison"
7362 [(match_operand 2 "cc_reg_operand" " c,c,c,c,c,c,c,c,c")
7363 (match_operand 5 "const_int_operand" "")])
7364 (match_operand:GPR 3 "loc_operand" " d,0,d,S,0,K,0,d,0")
7365 (match_operand:GPR 4 "loc_operand" " 0,d,d,0,S,0,K,0,d")))]
7366 "TARGET_Z196"
7367 "@
7368 loc<g>r%C1\t%0,%3
7369 loc<g>r%D1\t%0,%4
7370 sel<g>r%C1\t%0,%3,%4
7371 loc<g>%C1\t%0,%3
7372 loc<g>%D1\t%0,%4
7373 loc<g>hi%C1\t%0,%h3
7374 loc<g>hi%D1\t%0,%h4
7375 stoc<g>%C1\t%3,%0
7376 stoc<g>%D1\t%4,%0"
7377 [(set_attr "op_type" "RRF,RRF,RRF,RSY,RSY,RIE,RIE,RSY,RSY")
7378 (set_attr "cpu_facility" "*,*,z15,*,*,z13,z13,*,*")])
7379
7380 ;;
7381 ;;- Multiply instructions.
7382 ;;
7383
7384 ;
7385 ; muldi3 instruction pattern(s).
7386 ;
7387
7388 (define_expand "muldi3"
7389 [(parallel
7390 [(set (match_operand:DI 0 "register_operand")
7391 (mult:DI (match_operand:DI 1 "nonimmediate_operand")
7392 (match_operand:DI 2 "general_operand")))
7393 (clobber (reg:CC CC_REGNUM))])]
7394 "TARGET_ZARCH")
7395
7396 (define_insn "*muldi3_sign"
7397 [(set (match_operand:DI 0 "register_operand" "=d,d")
7398 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
7399 (match_operand:DI 1 "register_operand" "0,0")))]
7400 "TARGET_ZARCH"
7401 "@
7402 msgfr\t%0,%2
7403 msgf\t%0,%2"
7404 [(set_attr "op_type" "RRE,RXY")
7405 (set_attr "type" "imuldi")])
7406
7407 (define_insn "*muldi3"
7408 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d,d")
7409 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0,0,0")
7410 (match_operand:DI 2 "general_operand" "d,d,K,T,Os")))
7411 (clobber (match_scratch:CC 3 "=X,c,X,X,X"))]
7412 "TARGET_ZARCH"
7413 "@
7414 msgr\t%0,%2
7415 msgrkc\t%0,%1,%2
7416 mghi\t%0,%h2
7417 msg\t%0,%2
7418 msgfi\t%0,%2"
7419 [(set_attr "op_type" "RRE,RRF,RI,RXY,RIL")
7420 (set_attr "type" "imuldi")
7421 (set_attr "cpu_facility" "*,z14,*,*,z10")])
7422
7423 (define_insn "mulditi3"
7424 [(set (match_operand:TI 0 "register_operand" "=d,d")
7425 (mult:TI (sign_extend:TI
7426 (match_operand:DI 1 "register_operand" "%d,0"))
7427 (sign_extend:TI
7428 (match_operand:DI 2 "nonimmediate_operand" " d,T"))))]
7429 "TARGET_Z14"
7430 "@
7431 mgrk\t%0,%1,%2
7432 mg\t%0,%2"
7433 [(set_attr "op_type" "RRF,RXY")])
7434
7435 ; Combine likes op1 and op2 to be swapped sometimes.
7436 (define_insn "mulditi3_2"
7437 [(set (match_operand:TI 0 "register_operand" "=d,d")
7438 (mult:TI (sign_extend:TI
7439 (match_operand:DI 1 "nonimmediate_operand" "%d,T"))
7440 (sign_extend:TI
7441 (match_operand:DI 2 "register_operand" " d,0"))))]
7442 "TARGET_Z14"
7443 "@
7444 mgrk\t%0,%1,%2
7445 mg\t%0,%1"
7446 [(set_attr "op_type" "RRF,RXY")])
7447
7448 (define_insn "*muldi3_sign"
7449 [(set (match_operand:DI 0 "register_operand" "=d")
7450 (mult:DI (sign_extend:DI (match_operand:HI 2 "memory_operand" "T"))
7451 (match_operand:DI 1 "register_operand" "0")))]
7452 "TARGET_Z14"
7453 "mgh\t%0,%2"
7454 [(set_attr "op_type" "RXY")])
7455
7456
7457 ;
7458 ; mulsi3 instruction pattern(s).
7459 ;
7460
7461 (define_expand "mulsi3"
7462 [(parallel
7463 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d,d")
7464 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7465 (match_operand:SI 2 "general_operand" "d,d,K,R,T,Os")))
7466 (clobber (reg:CC CC_REGNUM))])]
7467 "")
7468
7469 (define_insn "*mulsi3_sign"
7470 [(set (match_operand:SI 0 "register_operand" "=d,d")
7471 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
7472 (match_operand:SI 1 "register_operand" "0,0")))]
7473 ""
7474 "@
7475 mh\t%0,%2
7476 mhy\t%0,%2"
7477 [(set_attr "op_type" "RX,RXY")
7478 (set_attr "type" "imulhi")
7479 (set_attr "cpu_facility" "*,z10")])
7480
7481 (define_insn "*mulsi3"
7482 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d,d")
7483 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7484 (match_operand:SI 2 "general_operand" "d,d,K,R,T,Os")))
7485 (clobber (match_scratch:CC 3 "=X,c,X,X,X,X"))]
7486 ""
7487 "@
7488 msr\t%0,%2
7489 msrkc\t%0,%1,%2
7490 mhi\t%0,%h2
7491 ms\t%0,%2
7492 msy\t%0,%2
7493 msfi\t%0,%2"
7494 [(set_attr "op_type" "RRE,RRF,RI,RX,RXY,RIL")
7495 (set_attr "type" "imulsi,*,imulhi,imulsi,imulsi,imulsi")
7496 (set_attr "cpu_facility" "*,z14,*,*,longdisp,z10")])
7497
7498 ;
7499 ; mulsidi3 instruction pattern(s).
7500 ;
7501
7502 (define_insn "mulsidi3"
7503 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
7504 (mult:DI (sign_extend:DI
7505 (match_operand:SI 1 "register_operand" "%0,0,0"))
7506 (sign_extend:DI
7507 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
7508 "!TARGET_ZARCH"
7509 "@
7510 mr\t%0,%2
7511 m\t%0,%2
7512 mfy\t%0,%2"
7513 [(set_attr "op_type" "RR,RX,RXY")
7514 (set_attr "type" "imulsi")
7515 (set_attr "cpu_facility" "*,*,z10")])
7516
7517 ; Jump to label OP3 if OP1 * OP2 results in a signed overflow
7518 (define_expand "mulv<mode>4"
7519 [(parallel
7520 [(set (reg:CCO CC_REGNUM)
7521 (compare:CCO (mult:<DBL>
7522 (sign_extend:<DBL> (match_operand:GPR 1 "register_operand"))
7523 (sign_extend:<DBL> (match_operand:GPR 2 "nonimmediate_operand")))
7524 (sign_extend:<DBL> (mult:GPR (match_dup 1) (match_dup 2)))))
7525 (set (match_operand:GPR 0 "register_operand")
7526 (mult:GPR (match_dup 1) (match_dup 2)))])
7527 (set (pc)
7528 (if_then_else (ne (reg:CCO CC_REGNUM) (const_int 0))
7529 (label_ref (match_operand 3))
7530 (pc)))]
7531 "TARGET_Z14")
7532
7533 ; msrkc, msc, msgrkc, msgc
7534 (define_insn "*mulv<mode>3_ccoverflow"
7535 [(set (reg CC_REGNUM)
7536 (compare (mult:<DBL>
7537 (sign_extend:<DBL> (match_operand:GPR 1 "register_operand" "%d,0"))
7538 (sign_extend:<DBL> (match_operand:GPR 2 "nonimmediate_operand" " d,T")))
7539 (sign_extend:<DBL> (mult:GPR (match_dup 1) (match_dup 2)))))
7540 (set (match_operand:GPR 0 "register_operand" "=d,d")
7541 (mult:GPR (match_dup 1) (match_dup 2)))]
7542 "s390_match_ccmode (insn, CCOmode) && TARGET_Z14"
7543 "@
7544 ms<g>rkc\t%0,%1,%2
7545 ms<g>c\t%0,%2"
7546 [(set_attr "op_type" "RRF,RXY")])
7547
7548
7549 ;
7550 ; umul instruction pattern(s).
7551 ;
7552
7553 ; mlr, ml, mlgr, mlg
7554 (define_insn "umul<dwh><mode>3"
7555 [(set (match_operand:DW 0 "register_operand" "=d,d")
7556 (mult:DW (zero_extend:DW
7557 (match_operand:<DWH> 1 "register_operand" "%0,0"))
7558 (zero_extend:DW
7559 (match_operand:<DWH> 2 "nonimmediate_operand" " d,T"))))]
7560 ""
7561 "@
7562 ml<tg>r\t%0,%2
7563 ml<tg>\t%0,%2"
7564 [(set_attr "op_type" "RRE,RXY")
7565 (set_attr "type" "imul<dwh>")])
7566
7567 ;
7568 ; mul(tf|df|sf|td|dd)3 instruction pattern(s).
7569 ;
7570
7571 ; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
7572 (define_insn "mul<mode>3<tf_fpr>"
7573 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v,v")
7574 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0,v,v")
7575 (match_operand:FP 2 "general_operand" "f,f,R,v,v")))]
7576 "TARGET_HARD_FLOAT"
7577 "@
7578 m<xdee>tr\t%0,%1,%2
7579 m<xdee>br\t%0,%2
7580 m<xdee>b\t%0,%2
7581 wfmdb\t%v0,%v1,%v2
7582 wfmsb\t%v0,%v1,%v2"
7583 [(set_attr "op_type" "RRF,RRE,RXE,VRR,VRR")
7584 (set_attr "type" "fmul<type>")
7585 (set_attr "cpu_facility" "*,*,*,vx,vxe")
7586 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DF>,<SF>")])
7587
7588 ; madbr, maebr, maxb, madb, maeb
7589 (define_insn "fma<mode>4"
7590 [(set (match_operand:DSF 0 "register_operand" "=f,f,v,v")
7591 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f,v,v")
7592 (match_operand:DSF 2 "nonimmediate_operand" "f,R,v,v")
7593 (match_operand:DSF 3 "register_operand" "0,0,v,v")))]
7594 "TARGET_HARD_FLOAT && s390_fma_allowed_p (<MODE>mode)"
7595 "@
7596 ma<xde>br\t%0,%1,%2
7597 ma<xde>b\t%0,%1,%2
7598 wfmadb\t%v0,%v1,%v2,%v3
7599 wfmasb\t%v0,%v1,%v2,%v3"
7600 [(set_attr "op_type" "RRE,RXE,VRR,VRR")
7601 (set_attr "type" "fmadd<mode>")
7602 (set_attr "cpu_facility" "*,*,vx,vxe")
7603 (set_attr "enabled" "*,*,<DF>,<SF>")])
7604
7605 ; msxbr, msdbr, msebr, msxb, msdb, mseb
7606 (define_insn "fms<mode>4"
7607 [(set (match_operand:DSF 0 "register_operand" "=f,f,v,v")
7608 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f,v,v")
7609 (match_operand:DSF 2 "nonimmediate_operand" "f,R,v,v")
7610 (neg:DSF (match_operand:DSF 3 "register_operand" "0,0,v,v"))))]
7611 "TARGET_HARD_FLOAT && s390_fma_allowed_p (<MODE>mode)"
7612 "@
7613 ms<xde>br\t%0,%1,%2
7614 ms<xde>b\t%0,%1,%2
7615 wfmsdb\t%v0,%v1,%v2,%v3
7616 wfmssb\t%v0,%v1,%v2,%v3"
7617 [(set_attr "op_type" "RRE,RXE,VRR,VRR")
7618 (set_attr "type" "fmadd<mode>")
7619 (set_attr "cpu_facility" "*,*,vx,vxe")
7620 (set_attr "enabled" "*,*,<DF>,<SF>")])
7621
7622 ;;
7623 ;;- Divide and modulo instructions.
7624 ;;
7625
7626 ;
7627 ; divmoddi4 instruction pattern(s).
7628 ;
7629
7630 (define_expand "divmoddi4"
7631 [(parallel [(set (match_operand:DI 0 "general_operand" "")
7632 (div:DI (match_operand:DI 1 "register_operand" "")
7633 (match_operand:DI 2 "general_operand" "")))
7634 (set (match_operand:DI 3 "general_operand" "")
7635 (mod:DI (match_dup 1) (match_dup 2)))])
7636 (clobber (match_dup 4))]
7637 "TARGET_ZARCH"
7638 {
7639 rtx div_equal, mod_equal;
7640 rtx_insn *insn;
7641
7642 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
7643 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
7644
7645 operands[4] = gen_reg_rtx(TImode);
7646 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
7647
7648 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
7649 set_unique_reg_note (insn, REG_EQUAL, div_equal);
7650
7651 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
7652 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
7653
7654 DONE;
7655 })
7656
7657 (define_insn "divmodtidi3"
7658 [(set (match_operand:TI 0 "register_operand" "=d,d")
7659 (ior:TI
7660 (ashift:TI
7661 (zero_extend:TI
7662 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
7663 (match_operand:DI 2 "general_operand" "d,T")))
7664 (const_int 64))
7665 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
7666 "TARGET_ZARCH"
7667 "@
7668 dsgr\t%0,%2
7669 dsg\t%0,%2"
7670 [(set_attr "op_type" "RRE,RXY")
7671 (set_attr "type" "idiv")])
7672
7673 (define_insn "divmodtisi3"
7674 [(set (match_operand:TI 0 "register_operand" "=d,d")
7675 (ior:TI
7676 (ashift:TI
7677 (zero_extend:TI
7678 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
7679 (sign_extend:DI
7680 (match_operand:SI 2 "nonimmediate_operand" "d,T"))))
7681 (const_int 64))
7682 (zero_extend:TI
7683 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
7684 "TARGET_ZARCH"
7685 "@
7686 dsgfr\t%0,%2
7687 dsgf\t%0,%2"
7688 [(set_attr "op_type" "RRE,RXY")
7689 (set_attr "type" "idiv")])
7690
7691 ;
7692 ; udivmoddi4 instruction pattern(s).
7693 ;
7694
7695 (define_expand "udivmoddi4"
7696 [(parallel [(set (match_operand:DI 0 "general_operand" "")
7697 (udiv:DI (match_operand:DI 1 "general_operand" "")
7698 (match_operand:DI 2 "nonimmediate_operand" "")))
7699 (set (match_operand:DI 3 "general_operand" "")
7700 (umod:DI (match_dup 1) (match_dup 2)))])
7701 (clobber (match_dup 4))]
7702 "TARGET_ZARCH"
7703 {
7704 rtx div_equal, mod_equal, equal;
7705 rtx_insn *insn;
7706
7707 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
7708 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
7709 equal = gen_rtx_IOR (TImode,
7710 gen_rtx_ASHIFT (TImode,
7711 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
7712 GEN_INT (64)),
7713 gen_rtx_ZERO_EXTEND (TImode, div_equal));
7714
7715 operands[4] = gen_reg_rtx(TImode);
7716 emit_clobber (operands[4]);
7717 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
7718 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
7719
7720 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
7721 set_unique_reg_note (insn, REG_EQUAL, equal);
7722
7723 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
7724 set_unique_reg_note (insn, REG_EQUAL, div_equal);
7725
7726 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
7727 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
7728
7729 DONE;
7730 })
7731
7732 (define_insn "udivmodtidi3"
7733 [(set (match_operand:TI 0 "register_operand" "=d,d")
7734 (ior:TI
7735 (ashift:TI
7736 (zero_extend:TI
7737 (truncate:DI
7738 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
7739 (zero_extend:TI
7740 (match_operand:DI 2 "nonimmediate_operand" "d,T")))))
7741 (const_int 64))
7742 (zero_extend:TI
7743 (truncate:DI
7744 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
7745 "TARGET_ZARCH"
7746 "@
7747 dlgr\t%0,%2
7748 dlg\t%0,%2"
7749 [(set_attr "op_type" "RRE,RXY")
7750 (set_attr "type" "idiv")])
7751
7752 ;
7753 ; divmodsi4 instruction pattern(s).
7754 ;
7755
7756 (define_expand "divmodsi4"
7757 [(parallel [(set (match_operand:SI 0 "general_operand" "")
7758 (div:SI (match_operand:SI 1 "general_operand" "")
7759 (match_operand:SI 2 "nonimmediate_operand" "")))
7760 (set (match_operand:SI 3 "general_operand" "")
7761 (mod:SI (match_dup 1) (match_dup 2)))])
7762 (clobber (match_dup 4))]
7763 "!TARGET_ZARCH"
7764 {
7765 rtx div_equal, mod_equal, equal;
7766 rtx_insn *insn;
7767
7768 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
7769 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
7770 equal = gen_rtx_IOR (DImode,
7771 gen_rtx_ASHIFT (DImode,
7772 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
7773 GEN_INT (32)),
7774 gen_rtx_ZERO_EXTEND (DImode, div_equal));
7775
7776 operands[4] = gen_reg_rtx(DImode);
7777 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
7778
7779 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
7780 set_unique_reg_note (insn, REG_EQUAL, equal);
7781
7782 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
7783 set_unique_reg_note (insn, REG_EQUAL, div_equal);
7784
7785 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
7786 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
7787
7788 DONE;
7789 })
7790
7791 (define_insn "divmoddisi3"
7792 [(set (match_operand:DI 0 "register_operand" "=d,d")
7793 (ior:DI
7794 (ashift:DI
7795 (zero_extend:DI
7796 (truncate:SI
7797 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
7798 (sign_extend:DI
7799 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
7800 (const_int 32))
7801 (zero_extend:DI
7802 (truncate:SI
7803 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
7804 "!TARGET_ZARCH"
7805 "@
7806 dr\t%0,%2
7807 d\t%0,%2"
7808 [(set_attr "op_type" "RR,RX")
7809 (set_attr "type" "idiv")])
7810
7811 ;
7812 ; udivsi3 and umodsi3 instruction pattern(s).
7813 ;
7814
7815 (define_expand "udivmodsi4"
7816 [(parallel [(set (match_operand:SI 0 "general_operand" "")
7817 (udiv:SI (match_operand:SI 1 "general_operand" "")
7818 (match_operand:SI 2 "nonimmediate_operand" "")))
7819 (set (match_operand:SI 3 "general_operand" "")
7820 (umod:SI (match_dup 1) (match_dup 2)))])
7821 (clobber (match_dup 4))]
7822 "!TARGET_ZARCH"
7823 {
7824 rtx div_equal, mod_equal, equal;
7825 rtx_insn *insn;
7826
7827 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
7828 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
7829 equal = gen_rtx_IOR (DImode,
7830 gen_rtx_ASHIFT (DImode,
7831 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
7832 GEN_INT (32)),
7833 gen_rtx_ZERO_EXTEND (DImode, div_equal));
7834
7835 operands[4] = gen_reg_rtx(DImode);
7836 emit_clobber (operands[4]);
7837 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
7838 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
7839
7840 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
7841 set_unique_reg_note (insn, REG_EQUAL, equal);
7842
7843 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
7844 set_unique_reg_note (insn, REG_EQUAL, div_equal);
7845
7846 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
7847 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
7848
7849 DONE;
7850 })
7851
7852 (define_insn "udivmoddisi3"
7853 [(set (match_operand:DI 0 "register_operand" "=d,d")
7854 (ior:DI
7855 (ashift:DI
7856 (zero_extend:DI
7857 (truncate:SI
7858 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
7859 (zero_extend:DI
7860 (match_operand:SI 2 "nonimmediate_operand" "d,T")))))
7861 (const_int 32))
7862 (zero_extend:DI
7863 (truncate:SI
7864 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
7865 "!TARGET_ZARCH"
7866 "@
7867 dlr\t%0,%2
7868 dl\t%0,%2"
7869 [(set_attr "op_type" "RRE,RXY")
7870 (set_attr "type" "idiv")])
7871
7872 ;
7873 ; div(df|sf)3 instruction pattern(s).
7874 ;
7875
7876 ; dxbr, ddbr, debr, ddb, deb, ddtr, dxtr
7877 (define_insn "div<mode>3<tf_fpr>"
7878 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v,v")
7879 (div:FP (match_operand:FP 1 "register_operand" "f,0,0,v,v")
7880 (match_operand:FP 2 "general_operand" "f,f,R,v,v")))]
7881 "TARGET_HARD_FLOAT"
7882 "@
7883 d<xde>tr\t%0,%1,%2
7884 d<xde>br\t%0,%2
7885 d<xde>b\t%0,%2
7886 wfddb\t%v0,%v1,%v2
7887 wfdsb\t%v0,%v1,%v2"
7888 [(set_attr "op_type" "RRF,RRE,RXE,VRR,VRR")
7889 (set_attr "type" "fdiv<type>")
7890 (set_attr "cpu_facility" "*,*,*,vx,vxe")
7891 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DF>,<SF>")])
7892
7893
7894 ;;
7895 ;;- And instructions.
7896 ;;
7897
7898 (define_expand "and<mode>3"
7899 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7900 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
7901 (match_operand:INT 2 "general_operand" "")))
7902 (clobber (reg:CC CC_REGNUM))]
7903 ""
7904 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
7905
7906 ;
7907 ; anddi3 instruction pattern(s).
7908 ;
7909
7910 (define_insn "*anddi3_cc"
7911 [(set (reg CC_REGNUM)
7912 (compare
7913 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0, d")
7914 (match_operand:DI 2 "general_operand" " d,d,T,NxxDw"))
7915 (const_int 0)))
7916 (set (match_operand:DI 0 "register_operand" "=d,d,d, d")
7917 (and:DI (match_dup 1) (match_dup 2)))]
7918 "TARGET_ZARCH && s390_match_ccmode(insn, CCTmode)"
7919 "@
7920 ngr\t%0,%2
7921 ngrk\t%0,%1,%2
7922 ng\t%0,%2
7923 risbg\t%0,%1,%s2,128+%e2,0"
7924 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
7925 (set_attr "cpu_facility" "*,z196,*,z10")
7926 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
7927
7928 (define_insn "*anddi3_cconly"
7929 [(set (reg CC_REGNUM)
7930 (compare
7931 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0, d")
7932 (match_operand:DI 2 "general_operand" " d,d,T,NxxDw"))
7933 (const_int 0)))
7934 (clobber (match_scratch:DI 0 "=d,d,d, d"))]
7935 "TARGET_ZARCH
7936 && s390_match_ccmode(insn, CCTmode)
7937 /* Do not steal TM patterns. */
7938 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
7939 "@
7940 ngr\t%0,%2
7941 ngrk\t%0,%1,%2
7942 ng\t%0,%2
7943 risbg\t%0,%1,%s2,128+%e2,0"
7944 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
7945 (set_attr "cpu_facility" "*,z196,*,z10")
7946 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
7947
7948 (define_insn "*anddi3"
7949 [(set (match_operand:DI 0 "nonimmediate_operand"
7950 "=d,d, d, d, d, d, d, d,d,d,d, d, AQ,Q")
7951 (and:DI
7952 (match_operand:DI 1 "nonimmediate_operand"
7953 "%d,o, 0, 0, 0, 0, 0, 0,0,d,0, d, 0,0")
7954 (match_operand:DI 2 "general_operand"
7955 "M, M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,d,T,NxxDw,NxQDF,Q")))
7956 (clobber (reg:CC CC_REGNUM))]
7957 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7958 "@
7959 #
7960 #
7961 nihh\t%0,%j2
7962 nihl\t%0,%j2
7963 nilh\t%0,%j2
7964 nill\t%0,%j2
7965 nihf\t%0,%m2
7966 nilf\t%0,%m2
7967 ngr\t%0,%2
7968 ngrk\t%0,%1,%2
7969 ng\t%0,%2
7970 risbg\t%0,%1,%s2,128+%e2,0
7971 #
7972 #"
7973 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,RIE,SI,SS")
7974 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,z196,*,z10,*,*")
7975 (set_attr "z10prop" "*,
7976 *,
7977 z10_super_E1,
7978 z10_super_E1,
7979 z10_super_E1,
7980 z10_super_E1,
7981 z10_super_E1,
7982 z10_super_E1,
7983 z10_super_E1,
7984 *,
7985 z10_super_E1,
7986 z10_super_E1,
7987 *,
7988 *")])
7989
7990 (define_split
7991 [(set (match_operand:DI 0 "s_operand" "")
7992 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
7993 (clobber (reg:CC CC_REGNUM))]
7994 "reload_completed"
7995 [(parallel
7996 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
7997 (clobber (reg:CC CC_REGNUM))])]
7998 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
7999
8000 ;; These two are what combine generates for (ashift (zero_extract)).
8001 (define_insn "*extzv_<mode>_srl<clobbercc_or_nocc>"
8002 [(set (match_operand:GPR 0 "register_operand" "=d")
8003 (and:GPR (lshiftrt:GPR
8004 (match_operand:GPR 1 "register_operand" "d")
8005 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
8006 (match_operand:GPR 3 "contiguous_bitmask_nowrap_operand" "")))]
8007 "<z10_or_zEC12_cond>
8008 /* Note that even for the SImode pattern, the rotate is always DImode. */
8009 && s390_extzv_shift_ok (<bitsize>, -INTVAL (operands[2]),
8010 INTVAL (operands[3]))"
8011 "<risbg_n>\t%0,%1,%<bfstart>3,128+%<bfend>3,64-%2"
8012 [(set_attr "op_type" "RIE")
8013 (set_attr "z10prop" "z10_super_E1")])
8014
8015 (define_insn "*extzv_<mode>_sll<clobbercc_or_nocc>"
8016 [(set (match_operand:GPR 0 "register_operand" "=d")
8017 (and:GPR (ashift:GPR
8018 (match_operand:GPR 1 "register_operand" "d")
8019 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
8020 (match_operand:GPR 3 "contiguous_bitmask_nowrap_operand" "")))]
8021 "<z10_or_zEC12_cond>
8022 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[2]),
8023 INTVAL (operands[3]))"
8024 "<risbg_n>\t%0,%1,%<bfstart>3,128+%<bfend>3,%2"
8025 [(set_attr "op_type" "RIE")
8026 (set_attr "z10prop" "z10_super_E1")])
8027
8028
8029 ;
8030 ; andsi3 instruction pattern(s).
8031 ;
8032
8033 (define_insn "*andsi3_cc"
8034 [(set (reg CC_REGNUM)
8035 (compare
8036 (and:SI
8037 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
8038 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
8039 (const_int 0)))
8040 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d, d")
8041 (and:SI (match_dup 1) (match_dup 2)))]
8042 "s390_match_ccmode(insn, CCTmode)"
8043 "@
8044 nilf\t%0,%o2
8045 nr\t%0,%2
8046 nrk\t%0,%1,%2
8047 n\t%0,%2
8048 ny\t%0,%2
8049 risbg\t%0,%1,%t2,128+%f2,0"
8050 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
8051 (set_attr "cpu_facility" "*,*,z196,*,longdisp,z10")
8052 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
8053 z10_super_E1,z10_super_E1,z10_super_E1")])
8054
8055 (define_insn "*andsi3_cconly"
8056 [(set (reg CC_REGNUM)
8057 (compare
8058 (and:SI
8059 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
8060 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
8061 (const_int 0)))
8062 (clobber (match_scratch:SI 0 "=d,d,d,d,d, d"))]
8063 "s390_match_ccmode(insn, CCTmode)
8064 /* Do not steal TM patterns. */
8065 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
8066 "@
8067 nilf\t%0,%o2
8068 nr\t%0,%2
8069 nrk\t%0,%1,%2
8070 n\t%0,%2
8071 ny\t%0,%2
8072 risbg\t%0,%1,%t2,128+%f2,0"
8073 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
8074 (set_attr "cpu_facility" "*,*,z196,*,longdisp,z10")
8075 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
8076 z10_super_E1,z10_super_E1,z10_super_E1")])
8077
8078 (define_insn "*andsi3_zarch"
8079 [(set (match_operand:SI 0 "nonimmediate_operand"
8080 "=d,d, d, d, d,d,d,d,d, d, AQ,Q")
8081 (and:SI (match_operand:SI 1 "nonimmediate_operand"
8082 "%d,o, 0, 0, 0,0,d,0,0, d, 0,0")
8083 (match_operand:SI 2 "general_operand"
8084 " M,M,N0HSF,N1HSF,Os,d,d,R,T,NxxSw,NxQSF,Q")))
8085 (clobber (reg:CC CC_REGNUM))]
8086 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8087 "@
8088 #
8089 #
8090 nilh\t%0,%j2
8091 nill\t%0,%j2
8092 nilf\t%0,%o2
8093 nr\t%0,%2
8094 nrk\t%0,%1,%2
8095 n\t%0,%2
8096 ny\t%0,%2
8097 risbg\t%0,%1,%t2,128+%f2,0
8098 #
8099 #"
8100 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RRF,RX,RXY,RIE,SI,SS")
8101 (set_attr "cpu_facility" "*,*,*,*,*,*,z196,*,longdisp,z10,*,*")
8102 (set_attr "z10prop" "*,
8103 *,
8104 z10_super_E1,
8105 z10_super_E1,
8106 z10_super_E1,
8107 z10_super_E1,
8108 *,
8109 z10_super_E1,
8110 z10_super_E1,
8111 z10_super_E1,
8112 *,
8113 *")])
8114
8115 (define_insn "*andsi3_esa"
8116 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d, AQ,Q")
8117 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0, 0,0")
8118 (match_operand:SI 2 "general_operand" " d,R,NxQSF,Q")))
8119 (clobber (reg:CC CC_REGNUM))]
8120 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8121 "@
8122 nr\t%0,%2
8123 n\t%0,%2
8124 #
8125 #"
8126 [(set_attr "op_type" "RR,RX,SI,SS")
8127 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
8128
8129
8130 (define_split
8131 [(set (match_operand:SI 0 "s_operand" "")
8132 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
8133 (clobber (reg:CC CC_REGNUM))]
8134 "reload_completed"
8135 [(parallel
8136 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
8137 (clobber (reg:CC CC_REGNUM))])]
8138 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
8139
8140 ;
8141 ; andhi3 instruction pattern(s).
8142 ;
8143
8144 (define_insn "*andhi3_zarch"
8145 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
8146 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
8147 (match_operand:HI 2 "general_operand" " d,d,n,NxQHF,Q")))
8148 (clobber (reg:CC CC_REGNUM))]
8149 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8150 "@
8151 nr\t%0,%2
8152 nrk\t%0,%1,%2
8153 nill\t%0,%x2
8154 #
8155 #"
8156 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
8157 (set_attr "cpu_facility" "*,z196,*,*,*")
8158 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")
8159 ])
8160
8161 (define_insn "*andhi3_esa"
8162 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
8163 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
8164 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
8165 (clobber (reg:CC CC_REGNUM))]
8166 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8167 "@
8168 nr\t%0,%2
8169 #
8170 #"
8171 [(set_attr "op_type" "RR,SI,SS")
8172 (set_attr "z10prop" "z10_super_E1,*,*")
8173 ])
8174
8175 (define_split
8176 [(set (match_operand:HI 0 "s_operand" "")
8177 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
8178 (clobber (reg:CC CC_REGNUM))]
8179 "reload_completed"
8180 [(parallel
8181 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
8182 (clobber (reg:CC CC_REGNUM))])]
8183 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
8184
8185 ;
8186 ; andqi3 instruction pattern(s).
8187 ;
8188
8189 (define_insn "*andqi3_zarch"
8190 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
8191 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
8192 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
8193 (clobber (reg:CC CC_REGNUM))]
8194 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8195 "@
8196 nr\t%0,%2
8197 nrk\t%0,%1,%2
8198 nill\t%0,%b2
8199 ni\t%S0,%b2
8200 niy\t%S0,%b2
8201 #"
8202 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
8203 (set_attr "cpu_facility" "*,z196,*,*,longdisp,*")
8204 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super,z10_super,*")])
8205
8206 (define_insn "*andqi3_esa"
8207 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
8208 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8209 (match_operand:QI 2 "general_operand" "d,n,Q")))
8210 (clobber (reg:CC CC_REGNUM))]
8211 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8212 "@
8213 nr\t%0,%2
8214 ni\t%S0,%b2
8215 #"
8216 [(set_attr "op_type" "RR,SI,SS")
8217 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
8218
8219 ;
8220 ; And with complement
8221 ;
8222 ; c = ~b & a = (b & a) ^ a
8223
8224 (define_insn_and_split "*andc_split_<mode>"
8225 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
8226 (and:GPR (not:GPR (match_operand:GPR 1 "nonimmediate_operand" ""))
8227 (match_operand:GPR 2 "general_operand" "")))
8228 (clobber (reg:CC CC_REGNUM))]
8229 "!TARGET_Z15
8230 && ! reload_completed
8231 && (GET_CODE (operands[0]) != MEM
8232 /* Ensure that s390_logical_operator_ok_p will succeed even
8233 on the split xor if (b & a) is stored into a pseudo. */
8234 || rtx_equal_p (operands[0], operands[2]))"
8235 "#"
8236 "&& 1"
8237 [
8238 (parallel
8239 [(set (match_dup 3) (and:GPR (match_dup 1) (match_dup 2)))
8240 (clobber (reg:CC CC_REGNUM))])
8241 (parallel
8242 [(set (match_dup 0) (xor:GPR (match_dup 3) (match_dup 2)))
8243 (clobber (reg:CC CC_REGNUM))])]
8244 {
8245 if (reg_overlap_mentioned_p (operands[0], operands[2]))
8246 operands[3] = gen_reg_rtx (<MODE>mode);
8247 else
8248 operands[3] = operands[0];
8249 })
8250
8251 ;
8252 ; Block and (NC) patterns.
8253 ;
8254
8255 (define_insn "*nc"
8256 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8257 (and:BLK (match_dup 0)
8258 (match_operand:BLK 1 "memory_operand" "Q")))
8259 (use (match_operand 2 "const_int_operand" "n"))
8260 (clobber (reg:CC CC_REGNUM))]
8261 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
8262 "nc\t%O0(%2,%R0),%S1"
8263 [(set_attr "op_type" "SS")
8264 (set_attr "z196prop" "z196_cracked")])
8265
8266 (define_split
8267 [(set (match_operand 0 "memory_operand" "")
8268 (and (match_dup 0)
8269 (match_operand 1 "memory_operand" "")))
8270 (clobber (reg:CC CC_REGNUM))]
8271 "reload_completed
8272 && GET_MODE (operands[0]) == GET_MODE (operands[1])
8273 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
8274 [(parallel
8275 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
8276 (use (match_dup 2))
8277 (clobber (reg:CC CC_REGNUM))])]
8278 {
8279 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
8280 operands[0] = adjust_address (operands[0], BLKmode, 0);
8281 operands[1] = adjust_address (operands[1], BLKmode, 0);
8282 })
8283
8284 (define_peephole2
8285 [(parallel
8286 [(set (match_operand:BLK 0 "memory_operand" "")
8287 (and:BLK (match_dup 0)
8288 (match_operand:BLK 1 "memory_operand" "")))
8289 (use (match_operand 2 "const_int_operand" ""))
8290 (clobber (reg:CC CC_REGNUM))])
8291 (parallel
8292 [(set (match_operand:BLK 3 "memory_operand" "")
8293 (and:BLK (match_dup 3)
8294 (match_operand:BLK 4 "memory_operand" "")))
8295 (use (match_operand 5 "const_int_operand" ""))
8296 (clobber (reg:CC CC_REGNUM))])]
8297 "s390_offset_p (operands[0], operands[3], operands[2])
8298 && s390_offset_p (operands[1], operands[4], operands[2])
8299 && !s390_overlap_p (operands[0], operands[1],
8300 INTVAL (operands[2]) + INTVAL (operands[5]))
8301 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
8302 [(parallel
8303 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
8304 (use (match_dup 8))
8305 (clobber (reg:CC CC_REGNUM))])]
8306 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8307 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
8308 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
8309
8310
8311 ;;
8312 ;;- Bit set (inclusive or) instructions.
8313 ;;
8314
8315 (define_expand "ior<mode>3"
8316 [(set (match_operand:INT 0 "nonimmediate_operand" "")
8317 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
8318 (match_operand:INT 2 "general_operand" "")))
8319 (clobber (reg:CC CC_REGNUM))]
8320 ""
8321 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
8322
8323 ;
8324 ; iordi3 instruction pattern(s).
8325 ;
8326
8327 (define_insn "*iordi3_cc"
8328 [(set (reg CC_REGNUM)
8329 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
8330 (match_operand:DI 2 "general_operand" " d,d,T"))
8331 (const_int 0)))
8332 (set (match_operand:DI 0 "register_operand" "=d,d,d")
8333 (ior:DI (match_dup 1) (match_dup 2)))]
8334 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
8335 "@
8336 ogr\t%0,%2
8337 ogrk\t%0,%1,%2
8338 og\t%0,%2"
8339 [(set_attr "op_type" "RRE,RRF,RXY")
8340 (set_attr "cpu_facility" "*,z196,*")
8341 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
8342
8343 (define_insn "*iordi3_cconly"
8344 [(set (reg CC_REGNUM)
8345 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
8346 (match_operand:DI 2 "general_operand" " d,d,T"))
8347 (const_int 0)))
8348 (clobber (match_scratch:DI 0 "=d,d,d"))]
8349 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
8350 "@
8351 ogr\t%0,%2
8352 ogrk\t%0,%1,%2
8353 og\t%0,%2"
8354 [(set_attr "op_type" "RRE,RRF,RXY")
8355 (set_attr "cpu_facility" "*,z196,*")
8356 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
8357
8358 (define_insn "*iordi3"
8359 [(set (match_operand:DI 0 "nonimmediate_operand"
8360 "=d, d, d, d, d, d,d,d,d, AQ,Q")
8361 (ior:DI (match_operand:DI 1 "nonimmediate_operand"
8362 " %0, 0, 0, 0, 0, 0,0,d,0, 0,0")
8363 (match_operand:DI 2 "general_operand"
8364 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,d,T,NxQD0,Q")))
8365 (clobber (reg:CC CC_REGNUM))]
8366 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8367 "@
8368 oihh\t%0,%i2
8369 oihl\t%0,%i2
8370 oilh\t%0,%i2
8371 oill\t%0,%i2
8372 oihf\t%0,%k2
8373 oilf\t%0,%k2
8374 ogr\t%0,%2
8375 ogrk\t%0,%1,%2
8376 og\t%0,%2
8377 #
8378 #"
8379 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,SI,SS")
8380 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,z196,*,*,*")
8381 (set_attr "z10prop" "z10_super_E1,
8382 z10_super_E1,
8383 z10_super_E1,
8384 z10_super_E1,
8385 z10_super_E1,
8386 z10_super_E1,
8387 z10_super_E1,
8388 *,
8389 z10_super_E1,
8390 *,
8391 *")])
8392
8393 (define_split
8394 [(set (match_operand:DI 0 "s_operand" "")
8395 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
8396 (clobber (reg:CC CC_REGNUM))]
8397 "reload_completed"
8398 [(parallel
8399 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
8400 (clobber (reg:CC CC_REGNUM))])]
8401 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
8402
8403 ;
8404 ; iorsi3 instruction pattern(s).
8405 ;
8406
8407 (define_insn "*iorsi3_cc"
8408 [(set (reg CC_REGNUM)
8409 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
8410 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
8411 (const_int 0)))
8412 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
8413 (ior:SI (match_dup 1) (match_dup 2)))]
8414 "s390_match_ccmode(insn, CCTmode)"
8415 "@
8416 oilf\t%0,%o2
8417 or\t%0,%2
8418 ork\t%0,%1,%2
8419 o\t%0,%2
8420 oy\t%0,%2"
8421 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
8422 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
8423 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
8424
8425 (define_insn "*iorsi3_cconly"
8426 [(set (reg CC_REGNUM)
8427 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
8428 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
8429 (const_int 0)))
8430 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
8431 "s390_match_ccmode(insn, CCTmode)"
8432 "@
8433 oilf\t%0,%o2
8434 or\t%0,%2
8435 ork\t%0,%1,%2
8436 o\t%0,%2
8437 oy\t%0,%2"
8438 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
8439 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
8440 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
8441
8442 (define_insn "*iorsi3_zarch"
8443 [(set (match_operand:SI 0 "nonimmediate_operand" "=d, d, d,d,d,d,d, AQ,Q")
8444 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0, 0, 0,0,d,0,0, 0,0")
8445 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,d,R,T,NxQS0,Q")))
8446 (clobber (reg:CC CC_REGNUM))]
8447 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8448 "@
8449 oilh\t%0,%i2
8450 oill\t%0,%i2
8451 oilf\t%0,%o2
8452 or\t%0,%2
8453 ork\t%0,%1,%2
8454 o\t%0,%2
8455 oy\t%0,%2
8456 #
8457 #"
8458 [(set_attr "op_type" "RI,RI,RIL,RR,RRF,RX,RXY,SI,SS")
8459 (set_attr "cpu_facility" "*,*,*,*,z196,*,longdisp,*,*")
8460 (set_attr "z10prop" "z10_super_E1,
8461 z10_super_E1,
8462 z10_super_E1,
8463 z10_super_E1,
8464 *,
8465 z10_super_E1,
8466 z10_super_E1,
8467 *,
8468 *")])
8469
8470 (define_insn "*iorsi3_esa"
8471 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
8472 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
8473 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
8474 (clobber (reg:CC CC_REGNUM))]
8475 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8476 "@
8477 or\t%0,%2
8478 o\t%0,%2
8479 #
8480 #"
8481 [(set_attr "op_type" "RR,RX,SI,SS")
8482 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
8483
8484 (define_split
8485 [(set (match_operand:SI 0 "s_operand" "")
8486 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
8487 (clobber (reg:CC CC_REGNUM))]
8488 "reload_completed"
8489 [(parallel
8490 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
8491 (clobber (reg:CC CC_REGNUM))])]
8492 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
8493
8494 ;
8495 ; iorhi3 instruction pattern(s).
8496 ;
8497
8498 (define_insn "*iorhi3_zarch"
8499 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
8500 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
8501 (match_operand:HI 2 "general_operand" " d,d,n,NxQH0,Q")))
8502 (clobber (reg:CC CC_REGNUM))]
8503 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8504 "@
8505 or\t%0,%2
8506 ork\t%0,%1,%2
8507 oill\t%0,%x2
8508 #
8509 #"
8510 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
8511 (set_attr "cpu_facility" "*,z196,*,*,*")
8512 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")])
8513
8514 (define_insn "*iorhi3_esa"
8515 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
8516 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
8517 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
8518 (clobber (reg:CC CC_REGNUM))]
8519 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8520 "@
8521 or\t%0,%2
8522 #
8523 #"
8524 [(set_attr "op_type" "RR,SI,SS")
8525 (set_attr "z10prop" "z10_super_E1,*,*")])
8526
8527 (define_split
8528 [(set (match_operand:HI 0 "s_operand" "")
8529 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
8530 (clobber (reg:CC CC_REGNUM))]
8531 "reload_completed"
8532 [(parallel
8533 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
8534 (clobber (reg:CC CC_REGNUM))])]
8535 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
8536
8537 ;
8538 ; iorqi3 instruction pattern(s).
8539 ;
8540
8541 (define_insn "*iorqi3_zarch"
8542 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
8543 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
8544 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
8545 (clobber (reg:CC CC_REGNUM))]
8546 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8547 "@
8548 or\t%0,%2
8549 ork\t%0,%1,%2
8550 oill\t%0,%b2
8551 oi\t%S0,%b2
8552 oiy\t%S0,%b2
8553 #"
8554 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
8555 (set_attr "cpu_facility" "*,z196,*,*,longdisp,*")
8556 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,
8557 z10_super,z10_super,*")])
8558
8559 (define_insn "*iorqi3_esa"
8560 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
8561 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
8562 (match_operand:QI 2 "general_operand" "d,n,Q")))
8563 (clobber (reg:CC CC_REGNUM))]
8564 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8565 "@
8566 or\t%0,%2
8567 oi\t%S0,%b2
8568 #"
8569 [(set_attr "op_type" "RR,SI,SS")
8570 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
8571
8572 ;
8573 ; And/Or with complement
8574 ;
8575
8576 ; ncrk, ncgrk, ocrk, ocgrk
8577 (define_insn "*<ANDOR:bitops_name>c<GPR:mode>_cc"
8578 [(set (reg CC_REGNUM)
8579 (compare
8580 (ANDOR:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
8581 (match_operand:GPR 2 "register_operand" "d"))
8582 (const_int 0)))
8583 (set (match_operand:GPR 0 "register_operand" "=d")
8584 (ANDOR:GPR (not:GPR (match_dup 1))
8585 (match_dup 2)))]
8586 "TARGET_Z15 && s390_match_ccmode(insn, CCTmode)"
8587 "<ANDOR:noxa>c<GPR:g>rk\t%0,%2,%1"
8588 [(set_attr "op_type" "RRF")])
8589
8590 ; ncrk, ncgrk, ocrk, ocgrk
8591 (define_insn "*<ANDOR:bitops_name>c<GPR:mode>_cconly"
8592 [(set (reg CC_REGNUM)
8593 (compare
8594 (ANDOR:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
8595 (match_operand:GPR 2 "register_operand" "d"))
8596 (const_int 0)))
8597 (clobber (match_scratch:GPR 0 "=d"))]
8598 "TARGET_Z15 && s390_match_ccmode(insn, CCTmode)"
8599 "<ANDOR:noxa>c<GPR:g>rk\t%0,%2,%1"
8600 [(set_attr "op_type" "RRF")])
8601
8602 ; ncrk, ncgrk, ocrk, ocgrk
8603 (define_insn "*<ANDOR:bitops_name>c<GPR:mode>"
8604 [(set (match_operand:GPR 0 "register_operand" "=d")
8605 (ANDOR:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
8606 (match_operand:GPR 2 "register_operand" "d")))
8607 (clobber (reg:CC CC_REGNUM))]
8608 "TARGET_Z15"
8609 "<ANDOR:noxa>c<GPR:g>rk\t%0,%2,%1"
8610 [(set_attr "op_type" "RRF")])
8611
8612 ;
8613 ;- Nand/Nor instructions.
8614 ;
8615
8616 ; nnrk, nngrk, nork, nogrk
8617 (define_insn "*n<ANDOR:inv_bitops_name><GPR:mode>_cc"
8618 [(set (reg CC_REGNUM)
8619 (compare
8620 (ANDOR:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
8621 (not:GPR (match_operand:GPR 2 "register_operand" "d")))
8622 (const_int 0)))
8623 (set (match_operand:GPR 0 "register_operand" "=d")
8624 (ANDOR:GPR (not:GPR (match_dup 1))
8625 (not:GPR (match_dup 2))))]
8626 "TARGET_Z15 && s390_match_ccmode(insn, CCTmode)"
8627 "n<ANDOR:inv_no><GPR:g>rk\t%0,%1,%2"
8628 [(set_attr "op_type" "RRF")])
8629
8630 ; nnrk, nngrk, nork, nogrk
8631 (define_insn "*n<ANDOR:inv_bitops_name><mode>_cconly"
8632 [(set (reg CC_REGNUM)
8633 (compare
8634 (ANDOR:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
8635 (not:GPR (match_operand:GPR 2 "register_operand" "d")))
8636 (const_int 0)))
8637 (clobber (match_scratch:GPR 0 "=d"))]
8638 "TARGET_Z15 && s390_match_ccmode(insn, CCTmode)"
8639 "n<ANDOR:inv_no><GPR:g>rk\t%0,%1,%2"
8640 [(set_attr "op_type" "RRF")])
8641
8642 ; nnrk, nngrk, nork, nogrk
8643 (define_insn "*n<ANDOR:inv_bitops_name><mode>"
8644 [(set (match_operand:GPR 0 "register_operand" "=d")
8645 (ANDOR:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))
8646 (not:GPR (match_operand:GPR 2 "register_operand" "d"))))
8647 (clobber (reg:CC CC_REGNUM))]
8648 "TARGET_Z15"
8649 "n<ANDOR:inv_no><GPR:g>rk\t%0,%1,%2"
8650 [(set_attr "op_type" "RRF")])
8651
8652 ; Use NAND for bit inversion
8653 (define_insn "*not<mode>"
8654 [(set (match_operand:GPR 0 "register_operand" "=d")
8655 (not:GPR (match_operand:GPR 1 "register_operand" "d")))
8656 (clobber (reg:CC CC_REGNUM))]
8657 "TARGET_Z15"
8658 "nn<GPR:g>rk\t%0,%1,%1"
8659 [(set_attr "op_type" "RRF")])
8660
8661 ;
8662 ; Block inclusive or (OC) patterns.
8663 ;
8664
8665 (define_insn "*oc"
8666 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8667 (ior:BLK (match_dup 0)
8668 (match_operand:BLK 1 "memory_operand" "Q")))
8669 (use (match_operand 2 "const_int_operand" "n"))
8670 (clobber (reg:CC CC_REGNUM))]
8671 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
8672 "oc\t%O0(%2,%R0),%S1"
8673 [(set_attr "op_type" "SS")
8674 (set_attr "z196prop" "z196_cracked")])
8675
8676 (define_split
8677 [(set (match_operand 0 "memory_operand" "")
8678 (ior (match_dup 0)
8679 (match_operand 1 "memory_operand" "")))
8680 (clobber (reg:CC CC_REGNUM))]
8681 "reload_completed
8682 && GET_MODE (operands[0]) == GET_MODE (operands[1])
8683 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
8684 [(parallel
8685 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
8686 (use (match_dup 2))
8687 (clobber (reg:CC CC_REGNUM))])]
8688 {
8689 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
8690 operands[0] = adjust_address (operands[0], BLKmode, 0);
8691 operands[1] = adjust_address (operands[1], BLKmode, 0);
8692 })
8693
8694 (define_peephole2
8695 [(parallel
8696 [(set (match_operand:BLK 0 "memory_operand" "")
8697 (ior:BLK (match_dup 0)
8698 (match_operand:BLK 1 "memory_operand" "")))
8699 (use (match_operand 2 "const_int_operand" ""))
8700 (clobber (reg:CC CC_REGNUM))])
8701 (parallel
8702 [(set (match_operand:BLK 3 "memory_operand" "")
8703 (ior:BLK (match_dup 3)
8704 (match_operand:BLK 4 "memory_operand" "")))
8705 (use (match_operand 5 "const_int_operand" ""))
8706 (clobber (reg:CC CC_REGNUM))])]
8707 "s390_offset_p (operands[0], operands[3], operands[2])
8708 && s390_offset_p (operands[1], operands[4], operands[2])
8709 && !s390_overlap_p (operands[0], operands[1],
8710 INTVAL (operands[2]) + INTVAL (operands[5]))
8711 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
8712 [(parallel
8713 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
8714 (use (match_dup 8))
8715 (clobber (reg:CC CC_REGNUM))])]
8716 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8717 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
8718 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
8719
8720
8721 ;;
8722 ;;- Xor instructions.
8723 ;;
8724
8725 (define_expand "xor<mode>3"
8726 [(set (match_operand:INT 0 "nonimmediate_operand" "")
8727 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
8728 (match_operand:INT 2 "general_operand" "")))
8729 (clobber (reg:CC CC_REGNUM))]
8730 ""
8731 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
8732
8733 ; Combine replaces (xor (x) (const_int -1)) with (not (x)) when doing
8734 ; simplifications. So its better to have something matching.
8735 (define_split
8736 [(set (match_operand:INT 0 "nonimmediate_operand" "")
8737 (not:INT (match_operand:INT 1 "nonimmediate_operand" "")))]
8738 ""
8739 [(parallel
8740 [(set (match_dup 0) (xor:INT (match_dup 1) (match_dup 2)))
8741 (clobber (reg:CC CC_REGNUM))])]
8742 {
8743 operands[2] = constm1_rtx;
8744 if (!s390_logical_operator_ok_p (operands))
8745 FAIL;
8746 })
8747
8748 ;
8749 ; xordi3 instruction pattern(s).
8750 ;
8751
8752 (define_insn "*xordi3_cc"
8753 [(set (reg CC_REGNUM)
8754 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
8755 (match_operand:DI 2 "general_operand" " d,d,T"))
8756 (const_int 0)))
8757 (set (match_operand:DI 0 "register_operand" "=d,d,d")
8758 (xor:DI (match_dup 1) (match_dup 2)))]
8759 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
8760 "@
8761 xgr\t%0,%2
8762 xgrk\t%0,%1,%2
8763 xg\t%0,%2"
8764 [(set_attr "op_type" "RRE,RRF,RXY")
8765 (set_attr "cpu_facility" "*,z196,*")
8766 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
8767
8768 (define_insn "*xordi3_cconly"
8769 [(set (reg CC_REGNUM)
8770 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
8771 (match_operand:DI 2 "general_operand" " d,d,T"))
8772 (const_int 0)))
8773 (clobber (match_scratch:DI 0 "=d,d,d"))]
8774 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
8775 "@
8776 xgr\t%0,%2
8777 xgrk\t%0,%1,%2
8778 xg\t%0,%2"
8779 [(set_attr "op_type" "RRE,RRF,RXY")
8780 (set_attr "cpu_facility" "*,z196,*")
8781 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
8782
8783 (define_insn "*xordi3"
8784 [(set (match_operand:DI 0 "nonimmediate_operand" "=d, d,d,d,d, AQ,Q")
8785 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0, 0,0,d,0, 0,0")
8786 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,d,T,NxQD0,Q")))
8787 (clobber (reg:CC CC_REGNUM))]
8788 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
8789 "@
8790 xihf\t%0,%k2
8791 xilf\t%0,%k2
8792 xgr\t%0,%2
8793 xgrk\t%0,%1,%2
8794 xg\t%0,%2
8795 #
8796 #"
8797 [(set_attr "op_type" "RIL,RIL,RRE,RRF,RXY,SI,SS")
8798 (set_attr "cpu_facility" "extimm,extimm,*,z196,*,*,*")
8799 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,
8800 *,z10_super_E1,*,*")])
8801
8802 (define_split
8803 [(set (match_operand:DI 0 "s_operand" "")
8804 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
8805 (clobber (reg:CC CC_REGNUM))]
8806 "reload_completed"
8807 [(parallel
8808 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
8809 (clobber (reg:CC CC_REGNUM))])]
8810 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
8811
8812 ;
8813 ; xorsi3 instruction pattern(s).
8814 ;
8815
8816 (define_insn "*xorsi3_cc"
8817 [(set (reg CC_REGNUM)
8818 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
8819 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
8820 (const_int 0)))
8821 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
8822 (xor:SI (match_dup 1) (match_dup 2)))]
8823 "s390_match_ccmode(insn, CCTmode)"
8824 "@
8825 xilf\t%0,%o2
8826 xr\t%0,%2
8827 xrk\t%0,%1,%2
8828 x\t%0,%2
8829 xy\t%0,%2"
8830 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
8831 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
8832 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
8833 z10_super_E1,z10_super_E1")])
8834
8835 (define_insn "*xorsi3_cconly"
8836 [(set (reg CC_REGNUM)
8837 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
8838 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
8839 (const_int 0)))
8840 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
8841 "s390_match_ccmode(insn, CCTmode)"
8842 "@
8843 xilf\t%0,%o2
8844 xr\t%0,%2
8845 xrk\t%0,%1,%2
8846 x\t%0,%2
8847 xy\t%0,%2"
8848 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
8849 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
8850 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
8851 z10_super_E1,z10_super_E1")])
8852
8853 (define_insn "*xorsi3"
8854 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d, AQ,Q")
8855 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, 0,0")
8856 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxQS0,Q")))
8857 (clobber (reg:CC CC_REGNUM))]
8858 "s390_logical_operator_ok_p (operands)"
8859 "@
8860 xilf\t%0,%o2
8861 xr\t%0,%2
8862 xrk\t%0,%1,%2
8863 x\t%0,%2
8864 xy\t%0,%2
8865 #
8866 #"
8867 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,SI,SS")
8868 (set_attr "cpu_facility" "*,*,z196,*,longdisp,*,*")
8869 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
8870 z10_super_E1,z10_super_E1,*,*")])
8871
8872 (define_split
8873 [(set (match_operand:SI 0 "s_operand" "")
8874 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
8875 (clobber (reg:CC CC_REGNUM))]
8876 "reload_completed"
8877 [(parallel
8878 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
8879 (clobber (reg:CC CC_REGNUM))])]
8880 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
8881
8882 ;
8883 ; xorhi3 instruction pattern(s).
8884 ;
8885
8886 (define_insn "*xorhi3"
8887 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
8888 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,d, 0,0")
8889 (match_operand:HI 2 "general_operand" "Os,d,d,NxQH0,Q")))
8890 (clobber (reg:CC CC_REGNUM))]
8891 "s390_logical_operator_ok_p (operands)"
8892 "@
8893 xilf\t%0,%x2
8894 xr\t%0,%2
8895 xrk\t%0,%1,%2
8896 #
8897 #"
8898 [(set_attr "op_type" "RIL,RR,RRF,SI,SS")
8899 (set_attr "cpu_facility" "*,*,z196,*,*")
8900 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*,*")])
8901
8902 (define_split
8903 [(set (match_operand:HI 0 "s_operand" "")
8904 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
8905 (clobber (reg:CC CC_REGNUM))]
8906 "reload_completed"
8907 [(parallel
8908 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
8909 (clobber (reg:CC CC_REGNUM))])]
8910 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
8911
8912 ;
8913 ; xorqi3 instruction pattern(s).
8914 ;
8915
8916 (define_insn "*xorqi3"
8917 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
8918 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,d,0,0,0")
8919 (match_operand:QI 2 "general_operand" "Os,d,d,n,n,Q")))
8920 (clobber (reg:CC CC_REGNUM))]
8921 "s390_logical_operator_ok_p (operands)"
8922 "@
8923 xilf\t%0,%b2
8924 xr\t%0,%2
8925 xrk\t%0,%1,%2
8926 xi\t%S0,%b2
8927 xiy\t%S0,%b2
8928 #"
8929 [(set_attr "op_type" "RIL,RR,RRF,SI,SIY,SS")
8930 (set_attr "cpu_facility" "*,*,z196,*,longdisp,*")
8931 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super,z10_super,*")])
8932
8933
8934 ;
8935 ; Block exclusive or (XC) patterns.
8936 ;
8937
8938 (define_insn "*xc"
8939 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8940 (xor:BLK (match_dup 0)
8941 (match_operand:BLK 1 "memory_operand" "Q")))
8942 (use (match_operand 2 "const_int_operand" "n"))
8943 (clobber (reg:CC CC_REGNUM))]
8944 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
8945 "xc\t%O0(%2,%R0),%S1"
8946 [(set_attr "op_type" "SS")])
8947
8948 (define_split
8949 [(set (match_operand 0 "memory_operand" "")
8950 (xor (match_dup 0)
8951 (match_operand 1 "memory_operand" "")))
8952 (clobber (reg:CC CC_REGNUM))]
8953 "reload_completed
8954 && GET_MODE (operands[0]) == GET_MODE (operands[1])
8955 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
8956 [(parallel
8957 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
8958 (use (match_dup 2))
8959 (clobber (reg:CC CC_REGNUM))])]
8960 {
8961 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
8962 operands[0] = adjust_address (operands[0], BLKmode, 0);
8963 operands[1] = adjust_address (operands[1], BLKmode, 0);
8964 })
8965
8966 (define_peephole2
8967 [(parallel
8968 [(set (match_operand:BLK 0 "memory_operand" "")
8969 (xor:BLK (match_dup 0)
8970 (match_operand:BLK 1 "memory_operand" "")))
8971 (use (match_operand 2 "const_int_operand" ""))
8972 (clobber (reg:CC CC_REGNUM))])
8973 (parallel
8974 [(set (match_operand:BLK 3 "memory_operand" "")
8975 (xor:BLK (match_dup 3)
8976 (match_operand:BLK 4 "memory_operand" "")))
8977 (use (match_operand 5 "const_int_operand" ""))
8978 (clobber (reg:CC CC_REGNUM))])]
8979 "s390_offset_p (operands[0], operands[3], operands[2])
8980 && s390_offset_p (operands[1], operands[4], operands[2])
8981 && !s390_overlap_p (operands[0], operands[1],
8982 INTVAL (operands[2]) + INTVAL (operands[5]))
8983 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
8984 [(parallel
8985 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
8986 (use (match_dup 8))
8987 (clobber (reg:CC CC_REGNUM))])]
8988 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8989 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
8990 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
8991
8992 ;
8993 ; Block xor (XC) patterns with src == dest.
8994 ;
8995
8996 (define_insn "*xc_zero"
8997 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8998 (const_int 0))
8999 (use (match_operand 1 "const_int_operand" "n"))
9000 (clobber (reg:CC CC_REGNUM))]
9001 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
9002 "xc\t%O0(%1,%R0),%S0"
9003 [(set_attr "op_type" "SS")
9004 (set_attr "z196prop" "z196_cracked")])
9005
9006 (define_peephole2
9007 [(parallel
9008 [(set (match_operand:BLK 0 "memory_operand" "")
9009 (const_int 0))
9010 (use (match_operand 1 "const_int_operand" ""))
9011 (clobber (reg:CC CC_REGNUM))])
9012 (parallel
9013 [(set (match_operand:BLK 2 "memory_operand" "")
9014 (const_int 0))
9015 (use (match_operand 3 "const_int_operand" ""))
9016 (clobber (reg:CC CC_REGNUM))])]
9017 "s390_offset_p (operands[0], operands[2], operands[1])
9018 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
9019 [(parallel
9020 [(set (match_dup 4) (const_int 0))
9021 (use (match_dup 5))
9022 (clobber (reg:CC CC_REGNUM))])]
9023 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
9024 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
9025
9026 ;
9027 ;- Nxor instructions.
9028 ;
9029
9030 ; nxrk, nxgrk
9031 (define_insn "*nxor<GPR:mode>_cc"
9032 [(set (reg CC_REGNUM)
9033 (compare
9034 (not:GPR (xor:GPR (match_operand:GPR 1 "register_operand" "d")
9035 (match_operand:GPR 2 "register_operand" "d")))
9036 (const_int 0)))
9037 (set (match_operand:GPR 0 "register_operand" "=d")
9038 (xor:GPR (not:GPR (match_dup 1))
9039 (match_dup 2)))]
9040 "TARGET_Z15 && s390_match_ccmode(insn, CCTmode)"
9041 "nx<GPR:g>rk\t%0,%1,%2"
9042 [(set_attr "op_type" "RRF")])
9043
9044 ; nxrk, nxgrk
9045 (define_insn "*nxor<mode>_cconly"
9046 [(set (reg CC_REGNUM)
9047 (compare
9048 (not:GPR (xor:GPR (match_operand:GPR 1 "register_operand" "d")
9049 (match_operand:GPR 2 "register_operand" "d")))
9050 (const_int 0)))
9051 (clobber (match_scratch:GPR 0 "=d"))]
9052 "TARGET_Z15 && s390_match_ccmode(insn, CCTmode)"
9053 "nx<GPR:g>rk\t%0,%1,%2"
9054 [(set_attr "op_type" "RRF")])
9055
9056 ; nxrk, nxgrk
9057 (define_insn "*nxor<mode>"
9058 [(set (match_operand:GPR 0 "register_operand" "=d")
9059 (not:GPR (xor:GPR (match_operand:GPR 1 "register_operand" "d")
9060 (match_operand:GPR 2 "register_operand" "d"))))
9061 (clobber (reg:CC CC_REGNUM))]
9062 "TARGET_Z15"
9063 "nx<GPR:g>rk\t%0,%1,%2"
9064 [(set_attr "op_type" "RRF")])
9065
9066 ;;
9067 ;;- Negate instructions.
9068 ;;
9069
9070 ;
9071 ; neg(di|si)2 instruction pattern(s).
9072 ;
9073
9074 (define_expand "neg<mode>2"
9075 [(parallel
9076 [(set (match_operand:DSI 0 "register_operand" "=d")
9077 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
9078 (clobber (reg:CC CC_REGNUM))])]
9079 ""
9080 "")
9081
9082 (define_insn "*negdi2_sign_cc"
9083 [(set (reg CC_REGNUM)
9084 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
9085 (match_operand:SI 1 "register_operand" "d") 0)
9086 (const_int 32)) (const_int 32)))
9087 (const_int 0)))
9088 (set (match_operand:DI 0 "register_operand" "=d")
9089 (neg:DI (sign_extend:DI (match_dup 1))))]
9090 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
9091 "lcgfr\t%0,%1"
9092 [(set_attr "op_type" "RRE")
9093 (set_attr "z10prop" "z10_c")])
9094
9095 (define_insn "*negdi2_sign"
9096 [(set (match_operand:DI 0 "register_operand" "=d")
9097 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
9098 (clobber (reg:CC CC_REGNUM))]
9099 "TARGET_ZARCH"
9100 "lcgfr\t%0,%1"
9101 [(set_attr "op_type" "RRE")
9102 (set_attr "z10prop" "z10_c")])
9103
9104 ; lcr, lcgr
9105 (define_insn "*neg<mode>2_cc"
9106 [(set (reg CC_REGNUM)
9107 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
9108 (const_int 0)))
9109 (set (match_operand:GPR 0 "register_operand" "=d")
9110 (neg:GPR (match_dup 1)))]
9111 "s390_match_ccmode (insn, CCAmode)"
9112 "lc<g>r\t%0,%1"
9113 [(set_attr "op_type" "RR<E>")
9114 (set_attr "z10prop" "z10_super_c_E1")])
9115
9116 ; lcr, lcgr
9117 (define_insn "*neg<mode>2_cconly"
9118 [(set (reg CC_REGNUM)
9119 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
9120 (const_int 0)))
9121 (clobber (match_scratch:GPR 0 "=d"))]
9122 "s390_match_ccmode (insn, CCAmode)"
9123 "lc<g>r\t%0,%1"
9124 [(set_attr "op_type" "RR<E>")
9125 (set_attr "z10prop" "z10_super_c_E1")])
9126
9127 ; lcr, lcgr
9128 (define_insn "*neg<mode>2"
9129 [(set (match_operand:GPR 0 "register_operand" "=d")
9130 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
9131 (clobber (reg:CC CC_REGNUM))]
9132 ""
9133 "lc<g>r\t%0,%1"
9134 [(set_attr "op_type" "RR<E>")
9135 (set_attr "z10prop" "z10_super_c_E1")])
9136
9137 (define_insn "*negdi2_31"
9138 [(set (match_operand:DI 0 "register_operand" "=d")
9139 (neg:DI (match_operand:DI 1 "register_operand" "d")))
9140 (clobber (reg:CC CC_REGNUM))]
9141 "!TARGET_ZARCH"
9142 "#")
9143
9144 ; Split a DImode NEG on 31bit into 2 SImode NEGs
9145
9146 ; Doing the twos complement separately on the SImode parts does an
9147 ; unwanted +1 on the high part which needs to be subtracted afterwards
9148 ; ... unless the +1 on the low part created an overflow.
9149
9150 (define_split
9151 [(set (match_operand:DI 0 "register_operand" "")
9152 (neg:DI (match_operand:DI 1 "register_operand" "")))
9153 (clobber (reg:CC CC_REGNUM))]
9154 "!TARGET_ZARCH
9155 && reload_completed
9156 && ((REG_P (operands[0]) && REG_P (operands[1])
9157 && REGNO (operands[0]) == REGNO (operands[1]))
9158 || s390_split_ok_p (operands[0], operands[1], DImode, 0))"
9159 [(parallel
9160 [(set (match_dup 2) (neg:SI (match_dup 3)))
9161 (clobber (reg:CC CC_REGNUM))])
9162 (parallel
9163 [(set (reg:CCAP CC_REGNUM)
9164 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
9165 (set (match_dup 4) (neg:SI (match_dup 5)))])
9166 (set (pc)
9167 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
9168 (pc)
9169 (label_ref (match_dup 6))))
9170 (parallel
9171 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
9172 (clobber (reg:CC CC_REGNUM))])
9173 (match_dup 6)]
9174 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
9175 operands[3] = operand_subword (operands[1], 0, 0, DImode);
9176 operands[4] = operand_subword (operands[0], 1, 0, DImode);
9177 operands[5] = operand_subword (operands[1], 1, 0, DImode);
9178 operands[6] = gen_label_rtx ();")
9179
9180 ; Like above but first make a copy of the low part of the src operand
9181 ; since it might overlap with the high part of the destination.
9182
9183 (define_split
9184 [(set (match_operand:DI 0 "register_operand" "")
9185 (neg:DI (match_operand:DI 1 "register_operand" "")))
9186 (clobber (reg:CC CC_REGNUM))]
9187 "!TARGET_ZARCH
9188 && s390_split_ok_p (operands[0], operands[1], DImode, 1)
9189 && reload_completed"
9190 [; Make a backup of op5 first
9191 (set (match_dup 4) (match_dup 5))
9192 ; Setting op2 here might clobber op5
9193 (parallel
9194 [(set (match_dup 2) (neg:SI (match_dup 3)))
9195 (clobber (reg:CC CC_REGNUM))])
9196 (parallel
9197 [(set (reg:CCAP CC_REGNUM)
9198 (compare:CCAP (neg:SI (match_dup 4)) (const_int 0)))
9199 (set (match_dup 4) (neg:SI (match_dup 4)))])
9200 (set (pc)
9201 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
9202 (pc)
9203 (label_ref (match_dup 6))))
9204 (parallel
9205 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
9206 (clobber (reg:CC CC_REGNUM))])
9207 (match_dup 6)]
9208 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
9209 operands[3] = operand_subword (operands[1], 0, 0, DImode);
9210 operands[4] = operand_subword (operands[0], 1, 0, DImode);
9211 operands[5] = operand_subword (operands[1], 1, 0, DImode);
9212 operands[6] = gen_label_rtx ();")
9213
9214 ;
9215 ; neg(tf|df|sf)2 instruction pattern(s).
9216 ;
9217
9218 (define_expand "neg<mode>2<tf_fpr>"
9219 [(parallel
9220 [(set (match_operand:BFP 0 "register_operand")
9221 (neg:BFP (match_operand:BFP 1 "register_operand")))
9222 (clobber (reg:CC CC_REGNUM))])]
9223 "TARGET_HARD_FLOAT")
9224
9225 ; lcxbr, lcdbr, lcebr
9226 (define_insn "*neg<mode>2_cc"
9227 [(set (reg CC_REGNUM)
9228 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
9229 (match_operand:BFP 2 "const0_operand" "")))
9230 (set (match_operand:BFP 0 "register_operand" "=f")
9231 (neg:BFP (match_dup 1)))]
9232 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
9233 "lc<xde>br\t%0,%1"
9234 [(set_attr "op_type" "RRE")
9235 (set_attr "type" "fsimp<type>")])
9236
9237 ; lcxbr, lcdbr, lcebr
9238 (define_insn "*neg<mode>2_cconly"
9239 [(set (reg CC_REGNUM)
9240 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
9241 (match_operand:BFP 2 "const0_operand" "")))
9242 (clobber (match_scratch:BFP 0 "=f"))]
9243 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
9244 "lc<xde>br\t%0,%1"
9245 [(set_attr "op_type" "RRE")
9246 (set_attr "type" "fsimp<type>")])
9247
9248 ; lcdfr
9249 (define_insn "*neg<mode>2_nocc"
9250 [(set (match_operand:FP 0 "register_operand" "=f")
9251 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
9252 "TARGET_DFP"
9253 "lcdfr\t%0,%1"
9254 [(set_attr "op_type" "RRE")
9255 (set_attr "type" "fsimp<type>")])
9256
9257 ; lcxbr, lcdbr, lcebr
9258 ; FIXME: wflcdb does not clobber cc
9259 ; FIXME: Does wflcdb ever match here?
9260 (define_insn "*neg<mode>2"
9261 [(set (match_operand:BFP 0 "register_operand" "=f,v,v")
9262 (neg:BFP (match_operand:BFP 1 "register_operand" "f,v,v")))
9263 (clobber (reg:CC CC_REGNUM))]
9264 "TARGET_HARD_FLOAT"
9265 "@
9266 lc<xde>br\t%0,%1
9267 wflcdb\t%0,%1
9268 wflcsb\t%0,%1"
9269 [(set_attr "op_type" "RRE,VRR,VRR")
9270 (set_attr "cpu_facility" "*,vx,vxe")
9271 (set_attr "type" "fsimp<type>,*,*")
9272 (set_attr "enabled" "*,<DF>,<SF>")])
9273
9274
9275 ;;
9276 ;;- Absolute value instructions.
9277 ;;
9278
9279 ;
9280 ; abs(di|si)2 instruction pattern(s).
9281 ;
9282
9283 (define_insn "*absdi2_sign_cc"
9284 [(set (reg CC_REGNUM)
9285 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
9286 (match_operand:SI 1 "register_operand" "d") 0)
9287 (const_int 32)) (const_int 32)))
9288 (const_int 0)))
9289 (set (match_operand:DI 0 "register_operand" "=d")
9290 (abs:DI (sign_extend:DI (match_dup 1))))]
9291 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
9292 "lpgfr\t%0,%1"
9293 [(set_attr "op_type" "RRE")
9294 (set_attr "z10prop" "z10_c")])
9295
9296 (define_insn "*absdi2_sign"
9297 [(set (match_operand:DI 0 "register_operand" "=d")
9298 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
9299 (clobber (reg:CC CC_REGNUM))]
9300 "TARGET_ZARCH"
9301 "lpgfr\t%0,%1"
9302 [(set_attr "op_type" "RRE")
9303 (set_attr "z10prop" "z10_c")])
9304
9305 ; lpr, lpgr
9306 (define_insn "*abs<mode>2_cc"
9307 [(set (reg CC_REGNUM)
9308 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
9309 (const_int 0)))
9310 (set (match_operand:GPR 0 "register_operand" "=d")
9311 (abs:GPR (match_dup 1)))]
9312 "s390_match_ccmode (insn, CCAmode)"
9313 "lp<g>r\t%0,%1"
9314 [(set_attr "op_type" "RR<E>")
9315 (set_attr "z10prop" "z10_c")])
9316
9317 ; lpr, lpgr
9318 (define_insn "*abs<mode>2_cconly"
9319 [(set (reg CC_REGNUM)
9320 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
9321 (const_int 0)))
9322 (clobber (match_scratch:GPR 0 "=d"))]
9323 "s390_match_ccmode (insn, CCAmode)"
9324 "lp<g>r\t%0,%1"
9325 [(set_attr "op_type" "RR<E>")
9326 (set_attr "z10prop" "z10_c")])
9327
9328 ; lpr, lpgr
9329 (define_insn "abs<mode>2"
9330 [(set (match_operand:GPR 0 "register_operand" "=d")
9331 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
9332 (clobber (reg:CC CC_REGNUM))]
9333 ""
9334 "lp<g>r\t%0,%1"
9335 [(set_attr "op_type" "RR<E>")
9336 (set_attr "z10prop" "z10_c")])
9337
9338 ;
9339 ; abs(tf|df|sf)2 instruction pattern(s).
9340 ;
9341
9342 (define_expand "abs<mode>2<tf_fpr>"
9343 [(parallel
9344 [(set (match_operand:BFP 0 "register_operand" "=f")
9345 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
9346 (clobber (reg:CC CC_REGNUM))])]
9347 "TARGET_HARD_FLOAT"
9348 "")
9349
9350 ; lpxbr, lpdbr, lpebr
9351 (define_insn "*abs<mode>2_cc"
9352 [(set (reg CC_REGNUM)
9353 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
9354 (match_operand:BFP 2 "const0_operand" "")))
9355 (set (match_operand:BFP 0 "register_operand" "=f")
9356 (abs:BFP (match_dup 1)))]
9357 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
9358 "lp<xde>br\t%0,%1"
9359 [(set_attr "op_type" "RRE")
9360 (set_attr "type" "fsimp<type>")])
9361
9362 ; lpxbr, lpdbr, lpebr
9363 (define_insn "*abs<mode>2_cconly"
9364 [(set (reg CC_REGNUM)
9365 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
9366 (match_operand:BFP 2 "const0_operand" "")))
9367 (clobber (match_scratch:BFP 0 "=f"))]
9368 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
9369 "lp<xde>br\t%0,%1"
9370 [(set_attr "op_type" "RRE")
9371 (set_attr "type" "fsimp<type>")])
9372
9373 ; lpdfr
9374 (define_insn "*abs<mode>2_nocc"
9375 [(set (match_operand:FP 0 "register_operand" "=f")
9376 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
9377 "TARGET_DFP"
9378 "lpdfr\t%0,%1"
9379 [(set_attr "op_type" "RRE")
9380 (set_attr "type" "fsimp<type>")])
9381
9382 ; lpxbr, lpdbr, lpebr
9383 ; FIXME: wflpdb does not clobber cc
9384 (define_insn "*abs<mode>2"
9385 [(set (match_operand:BFP 0 "register_operand" "=f,v")
9386 (abs:BFP (match_operand:BFP 1 "register_operand" "f,v")))
9387 (clobber (reg:CC CC_REGNUM))]
9388 "TARGET_HARD_FLOAT"
9389 "@
9390 lp<xde>br\t%0,%1
9391 wflpdb\t%0,%1"
9392 [(set_attr "op_type" "RRE,VRR")
9393 (set_attr "cpu_facility" "*,vx")
9394 (set_attr "type" "fsimp<type>,*")
9395 (set_attr "enabled" "*,<DFDI>")])
9396
9397
9398 ;;
9399 ;; Emulate smin, smax, umin, umax
9400 ;;
9401
9402 ; We have to manually emulate min/max for SI/DI modes since if they are not
9403 ; available expand tries to find an implementation for a wider mode and ends
9404 ; up with a vector implementation for TI mode.
9405
9406 (define_code_iterator MINMAXOP [lt gt ltu gtu])
9407 (define_code_attr minmaxcc [(lt "CCS") (gt "CCS") (ltu "CCU") (gtu "CCU")])
9408 (define_code_attr minmaxname [(lt "smin") (gt "smax") (ltu "umin") (gtu "umax")])
9409
9410 (define_expand "<minmaxname><mode>3"
9411 [(set (reg:<minmaxcc> CC_REGNUM)
9412 (compare:<minmaxcc> (match_operand:GPR 1 "loc_operand")
9413 (match_operand:GPR 2 "loc_operand")))
9414 (set (match_operand:GPR 0 "nonimmediate_operand")
9415 (if_then_else:GPR (MINMAXOP (reg:<minmaxcc> CC_REGNUM) (const_int 0))
9416 (match_dup 1)
9417 (match_dup 2)))]
9418 "TARGET_Z196")
9419
9420
9421 ;;
9422 ;;- Negated absolute value instructions
9423 ;;
9424
9425 ;
9426 ; Integer
9427 ;
9428
9429 (define_insn "*negabsdi2_sign_cc"
9430 [(set (reg CC_REGNUM)
9431 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
9432 (match_operand:SI 1 "register_operand" "d") 0)
9433 (const_int 32)) (const_int 32))))
9434 (const_int 0)))
9435 (set (match_operand:DI 0 "register_operand" "=d")
9436 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
9437 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
9438 "lngfr\t%0,%1"
9439 [(set_attr "op_type" "RRE")
9440 (set_attr "z10prop" "z10_c")])
9441
9442 (define_insn "*negabsdi2_sign"
9443 [(set (match_operand:DI 0 "register_operand" "=d")
9444 (neg:DI (abs:DI (sign_extend:DI
9445 (match_operand:SI 1 "register_operand" "d")))))
9446 (clobber (reg:CC CC_REGNUM))]
9447 "TARGET_ZARCH"
9448 "lngfr\t%0,%1"
9449 [(set_attr "op_type" "RRE")
9450 (set_attr "z10prop" "z10_c")])
9451
9452 ; lnr, lngr
9453 (define_insn "*negabs<mode>2_cc"
9454 [(set (reg CC_REGNUM)
9455 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
9456 (const_int 0)))
9457 (set (match_operand:GPR 0 "register_operand" "=d")
9458 (neg:GPR (abs:GPR (match_dup 1))))]
9459 "s390_match_ccmode (insn, CCAmode)"
9460 "ln<g>r\t%0,%1"
9461 [(set_attr "op_type" "RR<E>")
9462 (set_attr "z10prop" "z10_c")])
9463
9464 ; lnr, lngr
9465 (define_insn "*negabs<mode>2_cconly"
9466 [(set (reg CC_REGNUM)
9467 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
9468 (const_int 0)))
9469 (clobber (match_scratch:GPR 0 "=d"))]
9470 "s390_match_ccmode (insn, CCAmode)"
9471 "ln<g>r\t%0,%1"
9472 [(set_attr "op_type" "RR<E>")
9473 (set_attr "z10prop" "z10_c")])
9474
9475 ; lnr, lngr
9476 (define_insn "*negabs<mode>2"
9477 [(set (match_operand:GPR 0 "register_operand" "=d")
9478 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
9479 (clobber (reg:CC CC_REGNUM))]
9480 ""
9481 "ln<g>r\t%0,%1"
9482 [(set_attr "op_type" "RR<E>")
9483 (set_attr "z10prop" "z10_c")])
9484
9485 ;
9486 ; Floating point
9487 ;
9488
9489 ; lnxbr, lndbr, lnebr
9490 (define_insn "*negabs<mode>2_cc"
9491 [(set (reg CC_REGNUM)
9492 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
9493 (match_operand:BFP 2 "const0_operand" "")))
9494 (set (match_operand:BFP 0 "register_operand" "=f")
9495 (neg:BFP (abs:BFP (match_dup 1))))]
9496 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
9497 "ln<xde>br\t%0,%1"
9498 [(set_attr "op_type" "RRE")
9499 (set_attr "type" "fsimp<type>")])
9500
9501 ; lnxbr, lndbr, lnebr
9502 (define_insn "*negabs<mode>2_cconly"
9503 [(set (reg CC_REGNUM)
9504 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
9505 (match_operand:BFP 2 "const0_operand" "")))
9506 (clobber (match_scratch:BFP 0 "=f"))]
9507 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
9508 "ln<xde>br\t%0,%1"
9509 [(set_attr "op_type" "RRE")
9510 (set_attr "type" "fsimp<type>")])
9511
9512 ; lndfr
9513 (define_insn "*negabs<mode>2_nocc"
9514 [(set (match_operand:FP 0 "register_operand" "=f")
9515 (neg:FP (abs:FP (match_operand:FP 1 "register_operand" "<fT0>"))))]
9516 "TARGET_DFP"
9517 "lndfr\t%0,%1"
9518 [(set_attr "op_type" "RRE")
9519 (set_attr "type" "fsimp<type>")])
9520
9521 ; lnxbr, lndbr, lnebr
9522 ; FIXME: wflndb does not clobber cc
9523 (define_insn "*negabs<mode>2"
9524 [(set (match_operand:BFP 0 "register_operand" "=f,v")
9525 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f,v"))))
9526 (clobber (reg:CC CC_REGNUM))]
9527 "TARGET_HARD_FLOAT"
9528 "@
9529 ln<xde>br\t%0,%1
9530 wflndb\t%0,%1"
9531 [(set_attr "op_type" "RRE,VRR")
9532 (set_attr "cpu_facility" "*,vx")
9533 (set_attr "type" "fsimp<type>,*")
9534 (set_attr "enabled" "*,<DFDI>")])
9535
9536 ;;
9537 ;;- Square root instructions.
9538 ;;
9539
9540 ;
9541 ; sqrt(df|sf)2 instruction pattern(s).
9542 ;
9543
9544 ; sqxbr, sqdbr, sqebr, sqdb, sqeb
9545 (define_insn "sqrt<mode>2<tf_fpr>"
9546 [(set (match_operand:BFP 0 "register_operand" "=f,f,v")
9547 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,R,v")))]
9548 "TARGET_HARD_FLOAT"
9549 "@
9550 sq<xde>br\t%0,%1
9551 sq<xde>b\t%0,%1
9552 wfsqdb\t%v0,%v1"
9553 [(set_attr "op_type" "RRE,RXE,VRR")
9554 (set_attr "type" "fsqrt<type>")
9555 (set_attr "cpu_facility" "*,*,vx")
9556 (set_attr "enabled" "*,<DSF>,<DFDI>")])
9557
9558
9559 ;;
9560 ;;- One complement instructions.
9561 ;;
9562
9563 ;
9564 ; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
9565 ;
9566
9567 (define_expand "one_cmpl<mode>2"
9568 [(parallel
9569 [(set (match_operand:INT 0 "register_operand" "")
9570 (xor:INT (match_operand:INT 1 "register_operand" "")
9571 (const_int -1)))
9572 (clobber (reg:CC CC_REGNUM))])]
9573 ""
9574 "")
9575
9576
9577 ;;
9578 ;; Find leftmost bit instructions.
9579 ;;
9580
9581 (define_expand "clzdi2"
9582 [(set (match_operand:DI 0 "register_operand" "=d")
9583 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
9584 "TARGET_EXTIMM && TARGET_ZARCH"
9585 {
9586 if (!(TARGET_Z17 && TARGET_64BIT))
9587 {
9588 rtx_insn *insn;
9589 rtx clz_equal;
9590 rtx wide_reg = gen_reg_rtx (TImode);
9591 rtx msb = gen_rtx_CONST_INT (DImode, HOST_WIDE_INT_1U << 63);
9592
9593 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
9594
9595 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
9596
9597 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
9598 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
9599
9600 DONE;
9601 }
9602 })
9603
9604 (define_insn "*clzg"
9605 [(set (match_operand:DI 0 "register_operand" "=d")
9606 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
9607 "TARGET_Z17 && TARGET_64BIT"
9608 "clzg\t%0,%1"
9609 [(set_attr "op_type" "RRE")])
9610
9611 ; CLZ result is in hard reg op0 - this is the high part of the target operand
9612 ; The source with the left-most one bit cleared is in hard reg op0 + 1 - the low part
9613 (define_insn "clztidi2"
9614 [(set (match_operand:TI 0 "register_operand" "=d")
9615 (ior:TI
9616 (ashift:TI (zero_extend:TI (clz:DI (match_operand:DI 1 "register_operand" "d")))
9617 (const_int 64))
9618 (zero_extend:TI
9619 (xor:DI (match_dup 1)
9620 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
9621 (subreg:SI (clz:DI (match_dup 1)) 4))))))
9622 (clobber (reg:CC CC_REGNUM))]
9623 "UINTVAL (operands[2]) == HOST_WIDE_INT_1U << 63
9624 && TARGET_EXTIMM && TARGET_ZARCH"
9625 "flogr\t%0,%1"
9626 [(set_attr "op_type" "RRE")])
9627
9628
9629 ;;
9630 ;; Count Trailing Zeros.
9631 ;;
9632
9633 (define_insn "ctzdi2"
9634 [(set (match_operand:DI 0 "register_operand" "=d")
9635 (ctz:DI (match_operand:DI 1 "register_operand" "d")))]
9636 "TARGET_Z17 && TARGET_64BIT"
9637 "ctzg\t%0,%1"
9638 [(set_attr "op_type" "RRE")])
9639
9640
9641 ;;
9642 ;;- Rotate instructions.
9643 ;;
9644
9645 ;
9646 ; rotl(di|si)3 instruction pattern(s).
9647 ;
9648
9649 (define_expand "rotl<mode>3"
9650 [(set (match_operand:GPR 0 "register_operand" "")
9651 (rotate:GPR (match_operand:GPR 1 "register_operand" "")
9652 (match_operand:QI 2 "shift_count_operand" "")))]
9653 ""
9654 "")
9655
9656 ; rll, rllg
9657 (define_insn "*rotl<mode>3"
9658 [(set (match_operand:GPR 0 "register_operand" "=d")
9659 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
9660 (match_operand:QI 2 "shift_count_operand" "jsc")))]
9661 ""
9662 "rll<g>\t%0,%1,%Y2"
9663 [(set_attr "op_type" "RSE")
9664 (set_attr "atype" "reg")
9665 (set_attr "z10prop" "z10_super_E1")])
9666
9667
9668 ;;
9669 ;;- Shift instructions.
9670 ;;
9671
9672 ;
9673 ; (ashl|lshr)(di|si)3 instruction pattern(s).
9674 ; Left shifts and logical right shifts
9675
9676 (define_expand "<shift><mode>3"
9677 [(set (match_operand:DSI 0 "register_operand" "")
9678 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
9679 (match_operand:QI 2 "shift_count_operand" "")))]
9680 ""
9681 "")
9682
9683 ; ESA 64 bit register pair shift with reg or imm shift count
9684 ; sldl, srdl
9685 (define_insn "*<shift>di3_31"
9686 [(set (match_operand:DI 0 "register_operand" "=d")
9687 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
9688 (match_operand:QI 2 "shift_count_operand" "jsc")))]
9689 "!TARGET_ZARCH"
9690 "s<lr>dl\t%0,%Y2"
9691 [(set_attr "op_type" "RS")
9692 (set_attr "atype" "reg")
9693 (set_attr "z196prop" "z196_cracked")])
9694
9695
9696 ; 64 bit register shift with reg or imm shift count
9697 ; sll, srl, sllg, srlg, sllk, srlk
9698 (define_insn "*<shift><mode>3"
9699 [(set (match_operand:GPR 0 "register_operand" "=d, d")
9700 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>, d")
9701 (match_operand:QI 2 "shift_count_operand" "jsc,jsc")))]
9702 ""
9703 "@
9704 s<lr>l<g>\t%0,<1>%Y2
9705 s<lr>l<gk>\t%0,%1,%Y2"
9706 [(set_attr "op_type" "RS<E>,RSY")
9707 (set_attr "atype" "reg,reg")
9708 (set_attr "cpu_facility" "*,z196")
9709 (set_attr "z10prop" "z10_super_E1,*")])
9710
9711
9712 ;
9713 ; ashr(di|si)3 instruction pattern(s).
9714 ; Arithmetic right shifts
9715
9716 (define_expand "ashr<mode>3"
9717 [(parallel
9718 [(set (match_operand:DSI 0 "register_operand" "")
9719 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
9720 (match_operand:QI 2 "shift_count_operand" "")))
9721 (clobber (reg:CC CC_REGNUM))])]
9722 ""
9723 "")
9724
9725 (define_insn "*ashrdi3_31<setcc><cconly>"
9726 [(set (match_operand:DI 0 "register_operand" "=d")
9727 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
9728 (match_operand:QI 2 "shift_count_operand" "jsc")))
9729 (clobber (reg:CC CC_REGNUM))]
9730 "!TARGET_ZARCH"
9731 "srda\t%0,%Y2"
9732 [(set_attr "op_type" "RS")
9733 (set_attr "atype" "reg")])
9734
9735
9736 ; sra, srag
9737 (define_insn "*ashr<mode>3<setcc><cconly>"
9738 [(set (match_operand:GPR 0 "register_operand" "=d, d")
9739 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>, d")
9740 (match_operand:QI 2 "shift_count_operand" "jsc,jsc")))
9741 (clobber (reg:CC CC_REGNUM))]
9742 ""
9743 "@
9744 sra<g>\t%0,<1>%Y2
9745 sra<gk>\t%0,%1,%Y2"
9746 [(set_attr "op_type" "RS<E>,RSY")
9747 (set_attr "atype" "reg")
9748 (set_attr "cpu_facility" "*,z196")
9749 (set_attr "z10prop" "z10_super_E1,*")])
9750
9751
9752 ;;
9753 ;; Branch instruction patterns.
9754 ;;
9755
9756 (define_expand "cbranch<mode>4"
9757 [(set (pc)
9758 (if_then_else (match_operator 0 "comparison_operator"
9759 [(match_operand:GPR 1 "register_operand" "")
9760 (match_operand:GPR 2 "general_operand" "")])
9761 (label_ref (match_operand 3 "" ""))
9762 (pc)))]
9763 ""
9764 "s390_emit_jump (operands[3],
9765 s390_emit_compare (VOIDmode, GET_CODE (operands[0]), operands[1], operands[2]));
9766 DONE;")
9767
9768 (define_expand "cbranch<mode>4"
9769 [(set (pc)
9770 (if_then_else (match_operator 0 "comparison_operator"
9771 [(match_operand:FP_ANYTF 1 "register_operand" "")
9772 (match_operand:FP_ANYTF 2 "general_operand" "")])
9773 (label_ref (match_operand 3 "" ""))
9774 (pc)))]
9775 "TARGET_HARD_FLOAT"
9776 "s390_emit_jump (operands[3],
9777 s390_emit_compare (VOIDmode, GET_CODE (operands[0]), operands[1], operands[2]));
9778 DONE;")
9779
9780 (define_expand "cbranchcc4"
9781 [(set (pc)
9782 (if_then_else (match_operator 0 "s390_comparison"
9783 [(match_operand 1 "cc_reg_operand" "")
9784 (match_operand 2 "const_int_operand" "")])
9785 (label_ref (match_operand 3 "" ""))
9786 (pc)))]
9787 ""
9788 "")
9789
9790
9791 ;;
9792 ;;- Conditional jump instructions.
9793 ;;
9794
9795 (define_insn "*cjump_64"
9796 [(set (pc)
9797 (if_then_else
9798 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
9799 (match_operand 2 "const_int_operand" "")])
9800 (label_ref (match_operand 0 "" ""))
9801 (pc)))]
9802 ""
9803 {
9804 if (get_attr_length (insn) == 4)
9805 return "j%C1\t%l0";
9806 else
9807 return "jg%C1\t%l0";
9808 }
9809 [(set_attr "op_type" "RI")
9810 (set_attr "type" "branch")
9811 (set (attr "length")
9812 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9813 (const_int 4) (const_int 6)))])
9814
9815 (define_insn "*cjump_long"
9816 [(set (pc)
9817 (if_then_else
9818 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
9819 (match_operand 0 "address_operand" "ZQZR")
9820 (pc)))]
9821 "!TARGET_INDIRECT_BRANCH_NOBP_JUMP"
9822 {
9823 if (get_attr_op_type (insn) == OP_TYPE_RR)
9824 return "b%C1r\t%0";
9825 else
9826 return "b%C1\t%a0";
9827 }
9828 [(set (attr "op_type")
9829 (if_then_else (match_operand 0 "register_operand" "")
9830 (const_string "RR") (const_string "RX")))
9831 (set (attr "mnemonic")
9832 (if_then_else (match_operand 0 "register_operand" "")
9833 (const_string "bcr") (const_string "bc")))
9834 (set_attr "type" "branch")
9835 (set_attr "atype" "agen")])
9836
9837 ;; A conditional return instruction.
9838 (define_insn "*c<code>"
9839 [(set (pc)
9840 (if_then_else
9841 (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
9842 (ANY_RETURN)
9843 (pc)))]
9844 "s390_can_use_<code>_insn ()"
9845 {
9846 if (TARGET_INDIRECT_BRANCH_NOBP_RET)
9847 {
9848 s390_indirect_branch_via_thunk (RETURN_REGNUM,
9849 INVALID_REGNUM,
9850 operands[0],
9851 s390_indirect_branch_type_return);
9852 return "";
9853 }
9854 else
9855 return "b%C0r\t%%r14";
9856 }
9857 [(set (attr "op_type")
9858 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
9859 (const_string "RIL")
9860 (const_string "RR")))
9861 (set (attr "mnemonic")
9862 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
9863 (const_string "brcl")
9864 (const_string "bcr")))
9865 (set_attr "type" "jsr")
9866 (set_attr "atype" "agen")])
9867
9868 ;;
9869 ;;- Negated conditional jump instructions.
9870 ;;
9871
9872 (define_insn "*icjump_64"
9873 [(set (pc)
9874 (if_then_else
9875 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
9876 (match_operand 2 "const_int_operand" "")])
9877 (pc)
9878 (label_ref (match_operand 0 "" ""))))]
9879 ""
9880 {
9881 if (get_attr_length (insn) == 4)
9882 return "j%D1\t%l0";
9883 else
9884 return "jg%D1\t%l0";
9885 }
9886 [(set_attr "op_type" "RI")
9887 (set_attr "type" "branch")
9888 (set (attr "length")
9889 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9890 (const_int 4) (const_int 6)))])
9891
9892 (define_insn "*icjump_long"
9893 [(set (pc)
9894 (if_then_else
9895 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
9896 (pc)
9897 (match_operand 0 "address_operand" "ZQZR")))]
9898 "!TARGET_INDIRECT_BRANCH_NOBP_JUMP"
9899 {
9900 if (get_attr_op_type (insn) == OP_TYPE_RR)
9901 return "b%D1r\t%0";
9902 else
9903 return "b%D1\t%a0";
9904 }
9905 [(set (attr "op_type")
9906 (if_then_else (match_operand 0 "register_operand" "")
9907 (const_string "RR") (const_string "RX")))
9908 (set (attr "mnemonic")
9909 (if_then_else (match_operand 0 "register_operand" "")
9910 (const_string "bcr") (const_string "bc")))
9911 (set_attr "type" "branch")
9912 (set_attr "atype" "agen")])
9913
9914 ;;
9915 ;;- Trap instructions.
9916 ;;
9917
9918 (define_insn "trap"
9919 [(trap_if (const_int 1) (const_int 0))]
9920 ""
9921 "j\t.+2"
9922 [(set_attr "op_type" "RI")
9923 (set_attr "type" "branch")])
9924
9925 (define_expand "ctrap<mode>4"
9926 [(trap_if (match_operator 0 "comparison_operator"
9927 [(match_operand:GPR 1 "register_operand" "")
9928 (match_operand:GPR 2 "general_operand" "")])
9929 (match_operand 3 "const0_operand" ""))]
9930 ""
9931 {
9932 rtx cond = s390_emit_compare (VOIDmode, GET_CODE (operands[0]),
9933 operands[1], operands[2]);
9934 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
9935 DONE;
9936 })
9937
9938 (define_expand "ctrap<mode>4"
9939 [(trap_if (match_operator 0 "comparison_operator"
9940 [(match_operand:FP 1 "register_operand" "")
9941 (match_operand:FP 2 "general_operand" "")])
9942 (match_operand 3 "const0_operand" ""))]
9943 ""
9944 {
9945 rtx cond = s390_emit_compare (VOIDmode, GET_CODE (operands[0]),
9946 operands[1], operands[2]);
9947 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
9948 DONE;
9949 })
9950
9951 (define_insn "condtrap"
9952 [(trap_if (match_operator 0 "s390_comparison"
9953 [(match_operand 1 "cc_reg_operand" "c")
9954 (const_int 0)])
9955 (const_int 0))]
9956 ""
9957 "j%C0\t.+2";
9958 [(set_attr "op_type" "RI")
9959 (set_attr "type" "branch")])
9960
9961 ; crt, cgrt, cit, cgit
9962 (define_insn "*cmp_and_trap_signed_int<mode>"
9963 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
9964 [(match_operand:GPR 1 "register_operand" "d,d")
9965 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
9966 (const_int 0))]
9967 "TARGET_Z10"
9968 "@
9969 c<g>rt%C0\t%1,%2
9970 c<g>it%C0\t%1,%h2"
9971 [(set_attr "op_type" "RRF,RIE")
9972 (set_attr "type" "branch")
9973 (set_attr "z10prop" "z10_super_c,z10_super")])
9974
9975 ; clrt, clgrt, clfit, clgit, clt, clgt
9976 (define_insn "*cmp_and_trap_unsigned_int<mode>"
9977 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
9978 [(match_operand:GPR 1 "register_operand" "d,d,d")
9979 (match_operand:GPR 2 "general_operand" "d,D,S")])
9980 (const_int 0))]
9981 "TARGET_Z10"
9982 "@
9983 cl<g>rt%C0\t%1,%2
9984 cl<gf>it%C0\t%1,%x2
9985 cl<g>t%C0\t%1,%2"
9986 [(set_attr "op_type" "RRF,RIE,RSY")
9987 (set_attr "type" "branch")
9988 (set_attr "z10prop" "z10_super_c,z10_super,*")
9989 (set_attr "cpu_facility" "z10,z10,zEC12")])
9990
9991 ; lat, lgat
9992 (define_insn "*load_and_trap<mode>"
9993 [(trap_if (eq (match_operand:GPR 0 "memory_operand" "T")
9994 (const_int 0))
9995 (const_int 0))
9996 (set (match_operand:GPR 1 "register_operand" "=d")
9997 (match_dup 0))]
9998 "TARGET_ZEC12"
9999 "l<g>at\t%1,%0"
10000 [(set_attr "op_type" "RXY")])
10001
10002
10003 ;;
10004 ;;- Loop instructions.
10005 ;;
10006 ;; This is all complicated by the fact that since this is a jump insn
10007 ;; we must handle our own output reloads.
10008
10009 ;; branch on index
10010
10011 ; This splitter will be matched by combine and has to add the 2 moves
10012 ; necessary to load the compare and the increment values into a
10013 ; register pair as needed by brxle.
10014
10015 (define_insn_and_split "*brx_stage1_<GPR:mode>"
10016 [(set (pc)
10017 (if_then_else
10018 (match_operator 6 "s390_brx_operator"
10019 [(plus:GPR (match_operand:GPR 1 "register_operand" "")
10020 (match_operand:GPR 2 "general_operand" ""))
10021 (match_operand:GPR 3 "register_operand" "")])
10022 (label_ref (match_operand 0 "" ""))
10023 (pc)))
10024 (set (match_operand:GPR 4 "nonimmediate_operand" "")
10025 (plus:GPR (match_dup 1) (match_dup 2)))
10026 (clobber (match_scratch:GPR 5 ""))]
10027 ""
10028 "#"
10029 "!reload_completed && !reload_in_progress"
10030 [(set (match_dup 7) (match_dup 2)) ; the increment
10031 (set (match_dup 8) (match_dup 3)) ; the comparison value
10032 (parallel [(set (pc)
10033 (if_then_else
10034 (match_op_dup 6
10035 [(plus:GPR (match_dup 1) (match_dup 7))
10036 (match_dup 8)])
10037 (label_ref (match_dup 0))
10038 (pc)))
10039 (set (match_dup 4)
10040 (plus:GPR (match_dup 1) (match_dup 7)))
10041 (clobber (match_dup 5))
10042 (clobber (reg:CC CC_REGNUM))])]
10043 {
10044 rtx dreg = gen_reg_rtx (word_mode == DImode ? TImode : DImode);
10045 operands[7] = gen_lowpart (<GPR:MODE>mode,
10046 gen_highpart (word_mode, dreg));
10047 operands[8] = gen_lowpart (<GPR:MODE>mode,
10048 gen_lowpart (word_mode, dreg));
10049 })
10050
10051 ; brxlg, brxhg
10052
10053 (define_insn_and_split "*brxg_64bit"
10054 [(set (pc)
10055 (if_then_else
10056 (match_operator 5 "s390_brx_operator"
10057 [(plus:DI (match_operand:DI 1 "register_operand" "d,d,d")
10058 (subreg:DI (match_operand:TI 2 "register_operand" "d,d,d") 0))
10059 (subreg:DI (match_dup 2) 8)])
10060 (label_ref (match_operand 0 "" ""))
10061 (pc)))
10062 (set (match_operand:DI 3 "nonimmediate_operand" "=1,?X,?X")
10063 (plus:DI (match_dup 1)
10064 (subreg:DI (match_dup 2) 0)))
10065 (clobber (match_scratch:DI 4 "=X,&1,&?d"))
10066 (clobber (reg:CC CC_REGNUM))]
10067 "TARGET_ZARCH"
10068 {
10069 if (which_alternative != 0)
10070 return "#";
10071 else if (get_attr_length (insn) == 6)
10072 return "brx%E5g\t%1,%2,%l0";
10073 else
10074 return "agr\t%1,%2\;cgr\t%1,%M2\;jg%C5\t%l0";
10075 }
10076 "&& reload_completed
10077 && (!REG_P (operands[3])
10078 || !rtx_equal_p (operands[1], operands[3]))"
10079 [(set (match_dup 4) (match_dup 1))
10080 (parallel [(set (match_dup 4) (plus:DI (match_dup 4) (subreg:DI (match_dup 2) 0)))
10081 (clobber (reg:CC CC_REGNUM))])
10082 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:DI (match_dup 2) 8)))
10083 (set (match_dup 3) (match_dup 4))
10084 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
10085 (label_ref (match_dup 0))
10086 (pc)))]
10087 ""
10088 [(set_attr "op_type" "RIE")
10089 (set_attr "type" "branch")
10090 (set (attr "length")
10091 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
10092 (const_int 6) (const_int 16)))])
10093
10094 ; brxle, brxh
10095
10096 (define_insn_and_split "*brx_64bit"
10097 [(set (pc)
10098 (if_then_else
10099 (match_operator 5 "s390_brx_operator"
10100 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
10101 (subreg:SI (match_operand:TI 2 "register_operand" "d,d,d") 4))
10102 (subreg:SI (match_dup 2) 12)])
10103 (label_ref (match_operand 0 "" ""))
10104 (pc)))
10105 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
10106 (plus:SI (match_dup 1)
10107 (subreg:SI (match_dup 2) 4)))
10108 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
10109 (clobber (reg:CC CC_REGNUM))]
10110 "TARGET_ZARCH"
10111 {
10112 if (which_alternative != 0)
10113 return "#";
10114 else if (get_attr_length (insn) == 6)
10115 return "brx%C5\t%1,%2,%l0";
10116 else
10117 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
10118 }
10119 "&& reload_completed
10120 && (!REG_P (operands[3])
10121 || !rtx_equal_p (operands[1], operands[3]))"
10122 [(set (match_dup 4) (match_dup 1))
10123 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 4)))
10124 (clobber (reg:CC CC_REGNUM))])
10125 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 12)))
10126 (set (match_dup 3) (match_dup 4))
10127 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
10128 (label_ref (match_dup 0))
10129 (pc)))]
10130 ""
10131 [(set_attr "op_type" "RSI")
10132 (set_attr "type" "branch")
10133 (set (attr "length")
10134 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
10135 (const_int 6) (const_int 14)))])
10136
10137 ; brxle, brxh
10138
10139 (define_insn_and_split "*brx_31bit"
10140 [(set (pc)
10141 (if_then_else
10142 (match_operator 5 "s390_brx_operator"
10143 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
10144 (subreg:SI (match_operand:DI 2 "register_operand" "d,d,d") 0))
10145 (subreg:SI (match_dup 2) 4)])
10146 (label_ref (match_operand 0 "" ""))
10147 (pc)))
10148 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
10149 (plus:SI (match_dup 1)
10150 (subreg:SI (match_dup 2) 0)))
10151 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
10152 (clobber (reg:CC CC_REGNUM))]
10153 "!TARGET_ZARCH"
10154 {
10155 if (which_alternative != 0)
10156 return "#";
10157 else if (get_attr_length (insn) == 6)
10158 return "brx%C5\t%1,%2,%l0";
10159 else
10160 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
10161 }
10162 "&& reload_completed
10163 && (!REG_P (operands[3])
10164 || !rtx_equal_p (operands[1], operands[3]))"
10165 [(set (match_dup 4) (match_dup 1))
10166 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 0)))
10167 (clobber (reg:CC CC_REGNUM))])
10168 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 4)))
10169 (set (match_dup 3) (match_dup 4))
10170 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
10171 (label_ref (match_dup 0))
10172 (pc)))]
10173 ""
10174 [(set_attr "op_type" "RSI")
10175 (set_attr "type" "branch")
10176 (set (attr "length")
10177 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
10178 (const_int 6) (const_int 14)))])
10179
10180
10181 ;; branch on count
10182
10183 (define_expand "doloop_end"
10184 [(use (match_operand 0 "" "")) ; loop pseudo
10185 (use (match_operand 1 "" ""))] ; label
10186 ""
10187 {
10188 if (GET_MODE (operands[0]) == SImode)
10189 emit_jump_insn (gen_doloop_si64 (operands[1], operands[0], operands[0]));
10190 else if (GET_MODE (operands[0]) == DImode && TARGET_ZARCH)
10191 emit_jump_insn (gen_doloop_di (operands[1], operands[0], operands[0]));
10192 else
10193 FAIL;
10194
10195 DONE;
10196 })
10197
10198 (define_insn_and_split "doloop_si64"
10199 [(set (pc)
10200 (if_then_else
10201 (ne (match_operand:SI 1 "register_operand" "d,d,d")
10202 (const_int 1))
10203 (label_ref (match_operand 0 "" ""))
10204 (pc)))
10205 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
10206 (plus:SI (match_dup 1) (const_int -1)))
10207 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
10208 (clobber (reg:CC CC_REGNUM))]
10209 ""
10210 {
10211 if (which_alternative != 0)
10212 return "#";
10213 else if (get_attr_length (insn) == 4)
10214 return "brct\t%1,%l0";
10215 else
10216 return "ahi\t%1,-1\;jgne\t%l0";
10217 }
10218 "&& reload_completed
10219 && (! REG_P (operands[2])
10220 || ! rtx_equal_p (operands[1], operands[2]))"
10221 [(set (match_dup 3) (match_dup 1))
10222 (parallel [(set (reg:CCAN CC_REGNUM)
10223 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
10224 (const_int 0)))
10225 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
10226 (set (match_dup 2) (match_dup 3))
10227 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
10228 (label_ref (match_dup 0))
10229 (pc)))]
10230 ""
10231 [(set_attr "op_type" "RI")
10232 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
10233 ; hurt us in the (rare) case of ahi.
10234 (set_attr "z10prop" "z10_super_E1")
10235 (set_attr "type" "branch")
10236 (set (attr "length")
10237 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
10238 (const_int 4) (const_int 10)))])
10239
10240 (define_insn_and_split "doloop_di"
10241 [(set (pc)
10242 (if_then_else
10243 (ne (match_operand:DI 1 "register_operand" "d,d,d")
10244 (const_int 1))
10245 (label_ref (match_operand 0 "" ""))
10246 (pc)))
10247 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
10248 (plus:DI (match_dup 1) (const_int -1)))
10249 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
10250 (clobber (reg:CC CC_REGNUM))]
10251 "TARGET_ZARCH"
10252 {
10253 if (which_alternative != 0)
10254 return "#";
10255 else if (get_attr_length (insn) == 4)
10256 return "brctg\t%1,%l0";
10257 else
10258 return "aghi\t%1,-1\;jgne\t%l0";
10259 }
10260 "&& reload_completed
10261 && (! REG_P (operands[2])
10262 || ! rtx_equal_p (operands[1], operands[2]))"
10263 [(set (match_dup 3) (match_dup 1))
10264 (parallel [(set (reg:CCAN CC_REGNUM)
10265 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
10266 (const_int 0)))
10267 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
10268 (set (match_dup 2) (match_dup 3))
10269 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
10270 (label_ref (match_dup 0))
10271 (pc)))]
10272 ""
10273 [(set_attr "op_type" "RI")
10274 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
10275 ; hurt us in the (rare) case of ahi.
10276 (set_attr "z10prop" "z10_super_E1")
10277 (set_attr "type" "branch")
10278 (set (attr "length")
10279 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
10280 (const_int 4) (const_int 10)))])
10281
10282 ;;
10283 ;;- Unconditional jump instructions.
10284 ;;
10285
10286 ;
10287 ; jump instruction pattern(s).
10288 ;
10289
10290 (define_expand "jump"
10291 [(match_operand 0 "" "")]
10292 ""
10293 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
10294
10295 (define_insn "*jump64"
10296 [(set (pc) (label_ref (match_operand 0 "" "")))]
10297 ""
10298 {
10299 if (get_attr_length (insn) == 4)
10300 return "j\t%l0";
10301 else
10302 return "jg\t%l0";
10303 }
10304 [(set_attr "op_type" "RI")
10305 (set_attr "type" "branch")
10306 (set (attr "length")
10307 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
10308 (const_int 4) (const_int 6)))])
10309
10310 ;
10311 ; indirect-jump instruction pattern(s).
10312 ;
10313
10314 (define_expand "indirect_jump"
10315 [(set (pc) (match_operand 0 "nonimmediate_operand" ""))]
10316 ""
10317 {
10318 if (address_operand (operands[0], GET_MODE (operands[0])))
10319 ;
10320 else if (TARGET_Z14
10321 && GET_MODE (operands[0]) == Pmode
10322 && memory_operand (operands[0], Pmode))
10323 ;
10324 else
10325 operands[0] = force_reg (Pmode, operands[0]);
10326
10327 if (TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK)
10328 {
10329 operands[0] = force_reg (Pmode, operands[0]);
10330 if (TARGET_CPU_Z10)
10331 {
10332 if (TARGET_64BIT)
10333 emit_jump_insn (gen_indirect_jump_via_thunkdi_z10 (operands[0]));
10334 else
10335 emit_jump_insn (gen_indirect_jump_via_thunksi_z10 (operands[0]));
10336 }
10337 else
10338 {
10339 if (TARGET_64BIT)
10340 emit_jump_insn (gen_indirect_jump_via_thunkdi (operands[0]));
10341 else
10342 emit_jump_insn (gen_indirect_jump_via_thunksi (operands[0]));
10343 }
10344 DONE;
10345 }
10346
10347 if (TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK)
10348 {
10349 operands[0] = force_reg (Pmode, operands[0]);
10350 rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ());
10351 if (TARGET_CPU_Z10)
10352 {
10353 if (TARGET_64BIT)
10354 emit_jump_insn (gen_indirect_jump_via_inlinethunkdi_z10 (operands[0],
10355 label_ref));
10356 else
10357 emit_jump_insn (gen_indirect_jump_via_inlinethunksi_z10 (operands[0],
10358 label_ref));
10359 }
10360 else
10361 {
10362 if (TARGET_64BIT)
10363 emit_jump_insn (gen_indirect_jump_via_inlinethunkdi (operands[0],
10364 label_ref,
10365 force_reg (Pmode, label_ref)));
10366 else
10367 emit_jump_insn (gen_indirect_jump_via_inlinethunksi (operands[0],
10368 label_ref,
10369 force_reg (Pmode, label_ref)));
10370 }
10371 DONE;
10372 }
10373 })
10374
10375 (define_insn "*indirect_jump"
10376 [(set (pc)
10377 (match_operand 0 "address_operand" "ZR"))]
10378 "!TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK"
10379 {
10380 if (get_attr_op_type (insn) == OP_TYPE_RR)
10381 return "br\t%0";
10382 else
10383 return "b\t%a0";
10384 }
10385 [(set (attr "op_type")
10386 (if_then_else (match_operand 0 "register_operand" "")
10387 (const_string "RR") (const_string "RX")))
10388 (set (attr "mnemonic")
10389 (if_then_else (match_operand 0 "register_operand" "")
10390 (const_string "br") (const_string "b")))
10391 (set_attr "type" "branch")
10392 (set_attr "atype" "agen")])
10393
10394 (define_insn "indirect_jump_via_thunk<mode>_z10"
10395 [(set (pc)
10396 (match_operand:P 0 "register_operand" "a"))]
10397 "TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK
10398 && TARGET_CPU_Z10"
10399 {
10400 s390_indirect_branch_via_thunk (REGNO (operands[0]),
10401 INVALID_REGNUM,
10402 NULL_RTX,
10403 s390_indirect_branch_type_jump);
10404 return "";
10405 }
10406 [(set_attr "op_type" "RIL")
10407 (set_attr "mnemonic" "jg")
10408 (set_attr "type" "branch")
10409 (set_attr "atype" "agen")])
10410
10411 (define_insn "indirect_jump_via_thunk<mode>"
10412 [(set (pc)
10413 (match_operand:P 0 "register_operand" " a"))
10414 (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
10415 "TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK
10416 && !TARGET_CPU_Z10"
10417 {
10418 s390_indirect_branch_via_thunk (REGNO (operands[0]),
10419 INVALID_REGNUM,
10420 NULL_RTX,
10421 s390_indirect_branch_type_jump);
10422 return "";
10423 }
10424 [(set_attr "op_type" "RIL")
10425 (set_attr "mnemonic" "jg")
10426 (set_attr "type" "branch")
10427 (set_attr "atype" "agen")])
10428
10429
10430 ; The label_ref is wrapped into an if_then_else in order to hide it
10431 ; from mark_jump_label. Without this the label_ref would become the
10432 ; ONLY jump target of that jump breaking the control flow graph.
10433 (define_insn "indirect_jump_via_inlinethunk<mode>_z10"
10434 [(unspec [(if_then_else (match_operand:P 1 "larl_operand" "X")
10435 (const_int 0)
10436 (const_int 0))
10437 (const_int 0)] UNSPEC_EXECUTE_JUMP)
10438 (set (pc) (match_operand:P 0 "register_operand" "a"))]
10439 "TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK
10440 && TARGET_CPU_Z10"
10441 {
10442 s390_indirect_branch_via_inline_thunk (operands[1]);
10443 return "";
10444 }
10445 [(set_attr "op_type" "RIL")
10446 (set_attr "type" "branch")
10447 (set_attr "length" "10")])
10448
10449 (define_insn "indirect_jump_via_inlinethunk<mode>"
10450 [(unspec [(if_then_else (match_operand:P 1 "larl_operand" "X")
10451 (const_int 0)
10452 (const_int 0))
10453 (match_operand:P 2 "register_operand" "a")] UNSPEC_EXECUTE_JUMP)
10454 (set (pc) (match_operand:P 0 "register_operand" "a"))]
10455 "TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK
10456 && !TARGET_CPU_Z10"
10457 {
10458 s390_indirect_branch_via_inline_thunk (operands[2]);
10459 return "";
10460 }
10461 [(set_attr "op_type" "RX")
10462 (set_attr "type" "branch")
10463 (set_attr "length" "8")])
10464
10465 ; FIXME: LRA does not appear to be able to deal with MEMs being
10466 ; checked against address constraints like ZR above. So make this a
10467 ; separate pattern for now.
10468 (define_insn "*indirect2_jump"
10469 [(set (pc)
10470 (match_operand 0 "nonimmediate_operand" "a,T"))]
10471 "!TARGET_INDIRECT_BRANCH_NOBP_JUMP"
10472 "@
10473 br\t%0
10474 bi\t%0"
10475 [(set_attr "op_type" "RR,RXY")
10476 (set_attr "type" "branch")
10477 (set_attr "atype" "agen")
10478 (set_attr "cpu_facility" "*,z14")])
10479
10480 ;
10481 ; casesi instruction pattern(s).
10482 ;
10483
10484 (define_expand "casesi_jump"
10485 [(parallel
10486 [(set (pc) (match_operand 0 "address_operand"))
10487 (use (label_ref (match_operand 1 "")))])]
10488 ""
10489 {
10490 if (TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK)
10491 {
10492 operands[0] = force_reg (GET_MODE (operands[0]), operands[0]);
10493
10494 if (TARGET_CPU_Z10)
10495 {
10496 if (TARGET_64BIT)
10497 emit_jump_insn (gen_casesi_jump_via_thunkdi_z10 (operands[0],
10498 operands[1]));
10499 else
10500 emit_jump_insn (gen_casesi_jump_via_thunksi_z10 (operands[0],
10501 operands[1]));
10502 }
10503 else
10504 {
10505 if (TARGET_64BIT)
10506 emit_jump_insn (gen_casesi_jump_via_thunkdi (operands[0],
10507 operands[1]));
10508 else
10509 emit_jump_insn (gen_casesi_jump_via_thunksi (operands[0],
10510 operands[1]));
10511 }
10512 DONE;
10513 }
10514
10515 if (TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK)
10516 {
10517 operands[0] = force_reg (Pmode, operands[0]);
10518 rtx label_ref = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ());
10519 if (TARGET_CPU_Z10)
10520 {
10521 if (TARGET_64BIT)
10522 emit_jump_insn (gen_casesi_jump_via_inlinethunkdi_z10 (operands[0],
10523 operands[1],
10524 label_ref));
10525 else
10526 emit_jump_insn (gen_casesi_jump_via_inlinethunksi_z10 (operands[0],
10527 operands[1],
10528 label_ref));
10529 }
10530 else
10531 {
10532 if (TARGET_64BIT)
10533 emit_jump_insn (gen_casesi_jump_via_inlinethunkdi (operands[0],
10534 operands[1],
10535 label_ref,
10536 force_reg (Pmode, label_ref)));
10537 else
10538 emit_jump_insn (gen_casesi_jump_via_inlinethunksi (operands[0],
10539 operands[1],
10540 label_ref,
10541 force_reg (Pmode, label_ref)));
10542 }
10543 DONE;
10544 }
10545 })
10546
10547 (define_insn "*casesi_jump"
10548 [(set (pc) (match_operand 0 "address_operand" "ZR"))
10549 (use (label_ref (match_operand 1 "" "")))]
10550 "!TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK"
10551 {
10552 if (get_attr_op_type (insn) == OP_TYPE_RR)
10553 return "br\t%0";
10554 else
10555 return "b\t%a0";
10556 }
10557 [(set (attr "op_type")
10558 (if_then_else (match_operand 0 "register_operand" "")
10559 (const_string "RR") (const_string "RX")))
10560 (set (attr "mnemonic")
10561 (if_then_else (match_operand 0 "register_operand" "")
10562 (const_string "br") (const_string "b")))
10563 (set_attr "type" "branch")
10564 (set_attr "atype" "agen")])
10565
10566 (define_insn "casesi_jump_via_thunk<mode>_z10"
10567 [(set (pc) (match_operand:P 0 "register_operand" "a"))
10568 (use (label_ref (match_operand 1 "" "")))]
10569 "TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK
10570 && TARGET_CPU_Z10"
10571 {
10572 s390_indirect_branch_via_thunk (REGNO (operands[0]),
10573 INVALID_REGNUM,
10574 NULL_RTX,
10575 s390_indirect_branch_type_jump);
10576 return "";
10577 }
10578 [(set_attr "op_type" "RIL")
10579 (set_attr "mnemonic" "jg")
10580 (set_attr "type" "branch")
10581 (set_attr "atype" "agen")])
10582
10583 (define_insn "casesi_jump_via_thunk<mode>"
10584 [(set (pc) (match_operand:P 0 "register_operand" "a"))
10585 (use (label_ref (match_operand 1 "" "")))
10586 (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
10587 "TARGET_INDIRECT_BRANCH_NOBP_JUMP_THUNK
10588 && !TARGET_CPU_Z10"
10589 {
10590 s390_indirect_branch_via_thunk (REGNO (operands[0]),
10591 INVALID_REGNUM,
10592 NULL_RTX,
10593 s390_indirect_branch_type_jump);
10594 return "";
10595 }
10596 [(set_attr "op_type" "RIL")
10597 (set_attr "mnemonic" "jg")
10598 (set_attr "type" "branch")
10599 (set_attr "atype" "agen")])
10600
10601
10602 ; The label_ref is wrapped into an if_then_else in order to hide it
10603 ; from mark_jump_label. Without this the label_ref would become the
10604 ; ONLY jump target of that jump breaking the control flow graph.
10605 (define_insn "casesi_jump_via_inlinethunk<mode>_z10"
10606 [(unspec [(if_then_else (match_operand:P 2 "larl_operand" "X")
10607 (const_int 0)
10608 (const_int 0))
10609 (const_int 0)] UNSPEC_EXECUTE_JUMP)
10610 (set (pc) (match_operand:P 0 "register_operand" "a"))
10611 (use (label_ref (match_operand 1 "" "")))]
10612 "TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK
10613 && TARGET_CPU_Z10"
10614 {
10615 s390_indirect_branch_via_inline_thunk (operands[2]);
10616 return "";
10617 }
10618 [(set_attr "op_type" "RIL")
10619 (set_attr "type" "cs")
10620 (set_attr "length" "10")])
10621
10622 (define_insn "casesi_jump_via_inlinethunk<mode>"
10623 [(unspec [(if_then_else (match_operand:P 2 "larl_operand" "X")
10624 (const_int 0)
10625 (const_int 0))
10626 (match_operand:P 3 "register_operand" "a")] UNSPEC_EXECUTE_JUMP)
10627 (set (pc) (match_operand:P 0 "register_operand" "a"))
10628 (use (label_ref (match_operand 1 "" "")))]
10629 "TARGET_INDIRECT_BRANCH_NOBP_JUMP_INLINE_THUNK
10630 && !TARGET_CPU_Z10"
10631 {
10632 s390_indirect_branch_via_inline_thunk (operands[3]);
10633 return "";
10634 }
10635 [(set_attr "op_type" "RX")
10636 (set_attr "type" "cs")
10637 (set_attr "length" "8")])
10638
10639 (define_expand "casesi"
10640 [(match_operand:SI 0 "general_operand" "")
10641 (match_operand:SI 1 "general_operand" "")
10642 (match_operand:SI 2 "general_operand" "")
10643 (label_ref (match_operand 3 "" ""))
10644 (label_ref (match_operand 4 "" ""))]
10645 ""
10646 {
10647 rtx index = gen_reg_rtx (SImode);
10648 rtx base = gen_reg_rtx (Pmode);
10649 rtx target = gen_reg_rtx (Pmode);
10650
10651 emit_move_insn (index, operands[0]);
10652 emit_insn (gen_subsi3 (index, index, operands[1]));
10653 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
10654 operands[4]);
10655
10656 if (Pmode != SImode)
10657 index = convert_to_mode (Pmode, index, 1);
10658 if (GET_CODE (index) != REG)
10659 index = copy_to_mode_reg (Pmode, index);
10660
10661 if (TARGET_64BIT)
10662 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
10663 else
10664 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
10665
10666 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
10667
10668 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
10669 emit_move_insn (target, index);
10670
10671 if (flag_pic)
10672 target = gen_rtx_PLUS (Pmode, base, target);
10673 emit_jump_insn (gen_casesi_jump (target, operands[3]));
10674
10675 DONE;
10676 })
10677
10678
10679 ;;
10680 ;;- Jump to subroutine.
10681 ;;
10682 ;;
10683
10684 ;
10685 ; untyped call instruction pattern(s).
10686 ;
10687
10688 ;; Call subroutine returning any type.
10689 (define_expand "untyped_call"
10690 [(parallel [(call (match_operand 0 "" "")
10691 (const_int 0))
10692 (match_operand 1 "" "")
10693 (match_operand 2 "" "")])]
10694 ""
10695 {
10696 int i;
10697
10698 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
10699
10700 for (i = 0; i < XVECLEN (operands[2], 0); i++)
10701 {
10702 rtx set = XVECEXP (operands[2], 0, i);
10703 emit_move_insn (SET_DEST (set), SET_SRC (set));
10704 }
10705
10706 /* The optimizer does not know that the call sets the function value
10707 registers we stored in the result block. We avoid problems by
10708 claiming that all hard registers are used and clobbered at this
10709 point. */
10710 emit_insn (gen_blockage ());
10711
10712 DONE;
10713 })
10714
10715 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10716 ;; all of memory. This blocks insns from being moved across this point.
10717
10718 (define_insn "blockage"
10719 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
10720 ""
10721 ""
10722 [(set_attr "type" "none")
10723 (set_attr "length" "0")])
10724
10725 ;
10726 ; sibcall patterns
10727 ;
10728
10729 (define_expand "sibcall"
10730 [(call (match_operand 0 "" "")
10731 (match_operand 1 "" ""))]
10732 ""
10733 {
10734 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
10735 DONE;
10736 })
10737
10738 (define_insn "*sibcall_br"
10739 [(call (mem:QI (reg SIBCALL_REGNUM))
10740 (match_operand 0 "const_int_operand" "n"))]
10741 "SIBLING_CALL_P (insn)
10742 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
10743 {
10744 if (TARGET_INDIRECT_BRANCH_NOBP_CALL)
10745 {
10746 gcc_assert (TARGET_CPU_Z10);
10747 s390_indirect_branch_via_thunk (SIBCALL_REGNUM,
10748 INVALID_REGNUM,
10749 NULL_RTX,
10750 s390_indirect_branch_type_call);
10751 return "";
10752 }
10753 else
10754 return "br\t%%r1";
10755 }
10756 [(set (attr "op_type")
10757 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_CALL")
10758 (const_string "RIL")
10759 (const_string "RR")))
10760 (set (attr "mnemonic")
10761 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_CALL")
10762 (const_string "jg")
10763 (const_string "br")))
10764 (set_attr "type" "branch")
10765 (set_attr "atype" "agen")])
10766
10767 (define_insn "*sibcall_brc"
10768 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
10769 (match_operand 1 "const_int_operand" "n"))]
10770 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
10771 "j\t%0%K0"
10772 [(set_attr "op_type" "RI")
10773 (set_attr "type" "branch")])
10774
10775 (define_insn "*sibcall_brcl"
10776 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
10777 (match_operand 1 "const_int_operand" "n"))]
10778 "SIBLING_CALL_P (insn)"
10779 "jg\t%0%K0"
10780 [(set_attr "op_type" "RIL")
10781 (set_attr "type" "branch")])
10782
10783 ;
10784 ; sibcall_value patterns
10785 ;
10786
10787 (define_expand "sibcall_value"
10788 [(set (match_operand 0 "" "")
10789 (call (match_operand 1 "" "")
10790 (match_operand 2 "" "")))]
10791 ""
10792 {
10793 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
10794 DONE;
10795 })
10796
10797 (define_insn "*sibcall_value_br"
10798 [(set (match_operand 0 "" "")
10799 (call (mem:QI (reg SIBCALL_REGNUM))
10800 (match_operand 1 "const_int_operand" "n")))]
10801 "SIBLING_CALL_P (insn)
10802 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
10803 {
10804 if (TARGET_INDIRECT_BRANCH_NOBP_CALL)
10805 {
10806 gcc_assert (TARGET_CPU_Z10);
10807 s390_indirect_branch_via_thunk (SIBCALL_REGNUM,
10808 INVALID_REGNUM,
10809 NULL_RTX,
10810 s390_indirect_branch_type_call);
10811 return "";
10812 }
10813 else
10814 return "br\t%%r1";
10815 }
10816 [(set (attr "op_type")
10817 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_CALL")
10818 (const_string "RIL")
10819 (const_string "RR")))
10820 (set (attr "mnemonic")
10821 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_CALL")
10822 (const_string "jg")
10823 (const_string "br")))
10824 (set_attr "type" "branch")
10825 (set_attr "atype" "agen")])
10826
10827 (define_insn "*sibcall_value_brc"
10828 [(set (match_operand 0 "" "")
10829 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
10830 (match_operand 2 "const_int_operand" "n")))]
10831 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
10832 "j\t%1%K1"
10833 [(set_attr "op_type" "RI")
10834 (set_attr "type" "branch")])
10835
10836 (define_insn "*sibcall_value_brcl"
10837 [(set (match_operand 0 "" "")
10838 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
10839 (match_operand 2 "const_int_operand" "n")))]
10840 "SIBLING_CALL_P (insn)"
10841 "jg\t%1%K1"
10842 [(set_attr "op_type" "RIL")
10843 (set_attr "type" "branch")])
10844
10845
10846 ;
10847 ; call instruction pattern(s).
10848 ;
10849
10850 (define_expand "call"
10851 [(call (match_operand 0 "" "")
10852 (match_operand 1 "" ""))
10853 (use (match_operand 2 "" ""))]
10854 ""
10855 {
10856 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
10857 gen_rtx_REG (Pmode, RETURN_REGNUM));
10858 DONE;
10859 })
10860
10861 (define_insn "*bras"
10862 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
10863 (match_operand 1 "const_int_operand" "n"))
10864 (clobber (match_operand 2 "register_operand" "=r"))]
10865 "!SIBLING_CALL_P (insn)
10866 && TARGET_SMALL_EXEC
10867 && GET_MODE (operands[2]) == Pmode"
10868 "bras\t%2,%0%K0"
10869 [(set_attr "op_type" "RI")
10870 (set_attr "type" "jsr")
10871 (set_attr "z196prop" "z196_cracked")])
10872
10873 (define_insn "*brasl"
10874 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
10875 (match_operand 1 "const_int_operand" "n"))
10876 (clobber (match_operand 2 "register_operand" "=r"))]
10877 "!SIBLING_CALL_P (insn)
10878
10879 && GET_MODE (operands[2]) == Pmode"
10880 "brasl\t%2,%0%K0"
10881 [(set_attr "op_type" "RIL")
10882 (set_attr "type" "jsr")
10883 (set_attr "z196prop" "z196_cracked")
10884 (set_attr "relative_long" "yes")])
10885
10886 (define_insn "*basr"
10887 [(call (mem:QI (match_operand 0 "address_operand" "ZR"))
10888 (match_operand 1 "const_int_operand" "n"))
10889 (clobber (match_operand 2 "register_operand" "=r"))]
10890 "!TARGET_INDIRECT_BRANCH_NOBP_CALL
10891 && !SIBLING_CALL_P (insn)
10892 && GET_MODE (operands[2]) == Pmode"
10893 {
10894 if (get_attr_op_type (insn) == OP_TYPE_RR)
10895 return "basr\t%2,%0";
10896 else
10897 return "bas\t%2,%a0";
10898 }
10899 [(set (attr "op_type")
10900 (if_then_else (match_operand 0 "register_operand" "")
10901 (const_string "RR") (const_string "RX")))
10902 (set (attr "mnemonic")
10903 (if_then_else (match_operand 0 "register_operand" "")
10904 (const_string "basr") (const_string "bas")))
10905 (set_attr "type" "jsr")
10906 (set_attr "atype" "agen")
10907 (set_attr "z196prop" "z196_cracked")])
10908
10909 (define_insn "*basr_via_thunk<mode>_z10"
10910 [(call (mem:QI (match_operand:P 0 "register_operand" "a"))
10911 (match_operand 1 "const_int_operand" "n"))
10912 (clobber (match_operand:P 2 "register_operand" "=&r"))]
10913 "TARGET_INDIRECT_BRANCH_NOBP_CALL
10914 && TARGET_CPU_Z10
10915 && !SIBLING_CALL_P (insn)"
10916 {
10917 s390_indirect_branch_via_thunk (REGNO (operands[0]),
10918 REGNO (operands[2]),
10919 NULL_RTX,
10920 s390_indirect_branch_type_call);
10921 return "";
10922 }
10923 [(set_attr "op_type" "RIL")
10924 (set_attr "mnemonic" "brasl")
10925 (set_attr "type" "jsr")
10926 (set_attr "atype" "agen")
10927 (set_attr "z196prop" "z196_cracked")])
10928
10929 (define_insn "*basr_via_thunk<mode>"
10930 [(call (mem:QI (match_operand:P 0 "register_operand" "a"))
10931 (match_operand 1 "const_int_operand" "n"))
10932 (clobber (match_operand:P 2 "register_operand" "=&r"))
10933 (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
10934 "TARGET_INDIRECT_BRANCH_NOBP_CALL
10935 && !TARGET_CPU_Z10
10936 && !SIBLING_CALL_P (insn)"
10937 {
10938 s390_indirect_branch_via_thunk (REGNO (operands[0]),
10939 REGNO (operands[2]),
10940 NULL_RTX,
10941 s390_indirect_branch_type_call);
10942 return "";
10943 }
10944 [(set_attr "op_type" "RIL")
10945 (set_attr "mnemonic" "brasl")
10946 (set_attr "type" "jsr")
10947 (set_attr "atype" "agen")
10948 (set_attr "z196prop" "z196_cracked")])
10949
10950 ;
10951 ; call_value instruction pattern(s).
10952 ;
10953
10954 (define_expand "call_value"
10955 [(set (match_operand 0 "" "")
10956 (call (match_operand 1 "" "")
10957 (match_operand 2 "" "")))
10958 (use (match_operand 3 "" ""))]
10959 ""
10960 {
10961 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
10962 gen_rtx_REG (Pmode, RETURN_REGNUM));
10963 DONE;
10964 })
10965
10966 (define_insn "*bras_r"
10967 [(set (match_operand 0 "" "")
10968 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
10969 (match_operand:SI 2 "const_int_operand" "n")))
10970 (clobber (match_operand 3 "register_operand" "=r"))]
10971 "!SIBLING_CALL_P (insn)
10972 && TARGET_SMALL_EXEC
10973 && GET_MODE (operands[3]) == Pmode"
10974 "bras\t%3,%1%K1"
10975 [(set_attr "op_type" "RI")
10976 (set_attr "type" "jsr")
10977 (set_attr "z196prop" "z196_cracked")])
10978
10979 (define_insn "*brasl_r"
10980 [(set (match_operand 0 "" "")
10981 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
10982 (match_operand 2 "const_int_operand" "n")))
10983 (clobber (match_operand 3 "register_operand" "=r"))]
10984 "!SIBLING_CALL_P (insn)
10985
10986 && GET_MODE (operands[3]) == Pmode"
10987 "brasl\t%3,%1%K1"
10988 [(set_attr "op_type" "RIL")
10989 (set_attr "type" "jsr")
10990 (set_attr "z196prop" "z196_cracked")
10991 (set_attr "relative_long" "yes")])
10992
10993 (define_insn "*basr_r"
10994 [(set (match_operand 0 "" "")
10995 (call (mem:QI (match_operand 1 "address_operand" "ZR"))
10996 (match_operand 2 "const_int_operand" "n")))
10997 (clobber (match_operand 3 "register_operand" "=r"))]
10998 "!TARGET_INDIRECT_BRANCH_NOBP_CALL
10999 && !SIBLING_CALL_P (insn)
11000 && GET_MODE (operands[3]) == Pmode"
11001 {
11002 if (get_attr_op_type (insn) == OP_TYPE_RR)
11003 return "basr\t%3,%1";
11004 else
11005 return "bas\t%3,%a1";
11006 }
11007 [(set (attr "op_type")
11008 (if_then_else (match_operand 1 "register_operand" "")
11009 (const_string "RR") (const_string "RX")))
11010 (set (attr "mnemonic")
11011 (if_then_else (match_operand 1 "register_operand" "")
11012 (const_string "basr") (const_string "bas")))
11013 (set_attr "type" "jsr")
11014 (set_attr "atype" "agen")
11015 (set_attr "z196prop" "z196_cracked")])
11016
11017 (define_insn "*basr_r_via_thunk_z10"
11018 [(set (match_operand 0 "" "")
11019 (call (mem:QI (match_operand 1 "register_operand" "a"))
11020 (match_operand 2 "const_int_operand" "n")))
11021 (clobber (match_operand 3 "register_operand" "=&r"))]
11022 "TARGET_INDIRECT_BRANCH_NOBP_CALL
11023 && TARGET_CPU_Z10
11024 && !SIBLING_CALL_P (insn)
11025 && GET_MODE (operands[3]) == Pmode"
11026 {
11027 s390_indirect_branch_via_thunk (REGNO (operands[1]),
11028 REGNO (operands[3]),
11029 NULL_RTX,
11030 s390_indirect_branch_type_call);
11031 return "";
11032 }
11033 [(set_attr "op_type" "RIL")
11034 (set_attr "mnemonic" "brasl")
11035 (set_attr "type" "jsr")
11036 (set_attr "atype" "agen")
11037 (set_attr "z196prop" "z196_cracked")])
11038
11039 (define_insn "*basr_r_via_thunk"
11040 [(set (match_operand 0 "" "")
11041 (call (mem:QI (match_operand 1 "register_operand" "a"))
11042 (match_operand 2 "const_int_operand" "n")))
11043 (clobber (match_operand 3 "register_operand" "=&r"))
11044 (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
11045 "TARGET_INDIRECT_BRANCH_NOBP_CALL
11046 && !TARGET_CPU_Z10
11047 && !SIBLING_CALL_P (insn)
11048 && GET_MODE (operands[3]) == Pmode"
11049 {
11050 s390_indirect_branch_via_thunk (REGNO (operands[1]),
11051 REGNO (operands[3]),
11052 NULL_RTX,
11053 s390_indirect_branch_type_call);
11054 return "";
11055 }
11056 [(set_attr "op_type" "RIL")
11057 (set_attr "mnemonic" "brasl")
11058 (set_attr "type" "jsr")
11059 (set_attr "atype" "agen")
11060 (set_attr "z196prop" "z196_cracked")])
11061
11062 ;;
11063 ;;- Thread-local storage support.
11064 ;;
11065
11066 (define_expand "@get_thread_pointer<mode>"
11067 [(set (match_operand:P 0 "nonimmediate_operand" "")
11068 (unspec:P [(reg:P TP_REGNUM)] UNSPEC_GET_TP))]
11069 ""
11070 "")
11071
11072 (define_expand "set_thread_pointer<mode>"
11073 [(set (reg:P TP_REGNUM) (match_operand:P 0 "nonimmediate_operand" ""))
11074 (set (reg:P TP_REGNUM) (unspec_volatile:P [(reg:P TP_REGNUM)] UNSPECV_SET_TP))]
11075 ""
11076 "")
11077
11078 (define_insn "*set_tp"
11079 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
11080 ""
11081 ""
11082 [(set_attr "type" "none")
11083 (set_attr "length" "0")])
11084
11085 (define_insn "*tls_load_64"
11086 [(set (match_operand:DI 0 "register_operand" "=d")
11087 (unspec:DI [(match_operand:DI 1 "memory_operand" "T")
11088 (match_operand:DI 2 "" "")]
11089 UNSPEC_TLS_LOAD))]
11090 "TARGET_64BIT"
11091 "lg\t%0,%1%J2"
11092 [(set_attr "op_type" "RXE")
11093 (set_attr "z10prop" "z10_fwd_A3")])
11094
11095 (define_insn "*tls_load_31"
11096 [(set (match_operand:SI 0 "register_operand" "=d,d")
11097 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
11098 (match_operand:SI 2 "" "")]
11099 UNSPEC_TLS_LOAD))]
11100 "!TARGET_64BIT"
11101 "@
11102 l\t%0,%1%J2
11103 ly\t%0,%1%J2"
11104 [(set_attr "op_type" "RX,RXY")
11105 (set_attr "type" "load")
11106 (set_attr "cpu_facility" "*,longdisp")
11107 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
11108
11109 (define_insn "*bras_tls"
11110 [(set (match_operand 0 "" "")
11111 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
11112 (match_operand 2 "const_int_operand" "n")))
11113 (clobber (match_operand 3 "register_operand" "=r"))
11114 (use (match_operand 4 "" ""))]
11115 "!SIBLING_CALL_P (insn)
11116 && TARGET_SMALL_EXEC
11117 && GET_MODE (operands[3]) == Pmode"
11118 "bras\t%3,%1%K1%J4"
11119 [(set_attr "op_type" "RI")
11120 (set_attr "type" "jsr")
11121 (set_attr "z196prop" "z196_cracked")])
11122
11123 (define_insn "*brasl_tls"
11124 [(set (match_operand 0 "" "")
11125 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
11126 (match_operand 2 "const_int_operand" "n")))
11127 (clobber (match_operand 3 "register_operand" "=r"))
11128 (use (match_operand 4 "" ""))]
11129 "!SIBLING_CALL_P (insn)
11130
11131 && GET_MODE (operands[3]) == Pmode"
11132 "brasl\t%3,%1%K1%J4"
11133 [(set_attr "op_type" "RIL")
11134 (set_attr "type" "jsr")
11135 (set_attr "z196prop" "z196_cracked")
11136 (set_attr "relative_long" "yes")])
11137
11138 (define_insn "*basr_tls"
11139 [(set (match_operand 0 "" "")
11140 (call (mem:QI (match_operand 1 "address_operand" "ZR"))
11141 (match_operand 2 "const_int_operand" "n")))
11142 (clobber (match_operand 3 "register_operand" "=r"))
11143 (use (match_operand 4 "" ""))]
11144 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
11145 {
11146 if (get_attr_op_type (insn) == OP_TYPE_RR)
11147 return "basr\t%3,%1%J4";
11148 else
11149 return "bas\t%3,%a1%J4";
11150 }
11151 [(set (attr "op_type")
11152 (if_then_else (match_operand 1 "register_operand" "")
11153 (const_string "RR") (const_string "RX")))
11154 (set_attr "type" "jsr")
11155 (set_attr "atype" "agen")
11156 (set_attr "z196prop" "z196_cracked")])
11157
11158 ;;
11159 ;;- Atomic operations
11160 ;;
11161
11162 ;
11163 ; memory barrier patterns.
11164 ;
11165
11166 (define_expand "mem_thread_fence"
11167 [(match_operand:SI 0 "const_int_operand")] ;; model
11168 ""
11169 {
11170 /* Unless this is a SEQ_CST fence, the s390 memory model is strong
11171 enough not to require barriers of any kind. */
11172 if (is_mm_seq_cst (memmodel_from_int (INTVAL (operands[0]))))
11173 {
11174 rtx mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
11175 MEM_VOLATILE_P (mem) = 1;
11176 emit_insn (gen_mem_thread_fence_1 (mem));
11177 }
11178 DONE;
11179 })
11180
11181 ; Although bcr is superscalar on Z10, this variant will never
11182 ; become part of an execution group.
11183 ; With z196 we can make use of the fast-BCR-serialization facility.
11184 ; This allows for a slightly faster sync which is sufficient for our
11185 ; purposes.
11186 (define_insn "mem_thread_fence_1"
11187 [(set (match_operand:BLK 0 "" "")
11188 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
11189 ""
11190 {
11191 if (TARGET_Z196)
11192 return "bcr\t14,0";
11193 else
11194 return "bcr\t15,0";
11195 }
11196 [(set_attr "op_type" "RR")
11197 (set_attr "mnemonic" "bcr_flush")
11198 (set_attr "z196prop" "z196_alone")])
11199
11200 ;
11201 ; atomic load/store operations
11202 ;
11203
11204 ; Atomic loads need not examine the memory model at all.
11205 (define_expand "atomic_load<mode>"
11206 [(match_operand:DINT 0 "register_operand") ;; output
11207 (match_operand:DINT 1 "memory_operand") ;; memory
11208 (match_operand:SI 2 "const_int_operand")] ;; model
11209 ""
11210 {
11211 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
11212 FAIL;
11213
11214 if (<MODE>mode == TImode)
11215 emit_insn (gen_atomic_loadti_1 (operands[0], operands[1]));
11216 else if (<MODE>mode == DImode && !TARGET_ZARCH)
11217 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
11218 else
11219 emit_move_insn (operands[0], operands[1]);
11220 DONE;
11221 })
11222
11223 ; Different from movdi_31 in that we want no splitters.
11224 (define_insn "atomic_loaddi_1"
11225 [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f")
11226 (unspec:DI [(match_operand:DI 1 "memory_operand" "Q,S,R,T")]
11227 UNSPEC_MOVA))]
11228 "!TARGET_ZARCH"
11229 "@
11230 lm\t%0,%M0,%S1
11231 lmy\t%0,%M0,%S1
11232 ld\t%0,%1
11233 ldy\t%0,%1"
11234 [(set_attr "op_type" "RS,RSY,RS,RSY")
11235 (set_attr "cpu_facility" "*,longdisp,*,longdisp")
11236 (set_attr "type" "lm,lm,floaddf,floaddf")])
11237
11238 (define_insn "atomic_loadti_1"
11239 [(set (match_operand:TI 0 "register_operand" "=r")
11240 (unspec:TI [(match_operand:TI 1 "memory_operand" "T")]
11241 UNSPEC_MOVA))]
11242 "TARGET_ZARCH"
11243 "lpq\t%0,%1"
11244 [(set_attr "op_type" "RXY")
11245 (set_attr "type" "other")])
11246
11247 ; Atomic stores must(?) enforce sequential consistency.
11248 (define_expand "atomic_store<mode>"
11249 [(match_operand:DINT 0 "memory_operand") ;; memory
11250 (match_operand:DINT 1 "register_operand") ;; input
11251 (match_operand:SI 2 "const_int_operand")] ;; model
11252 ""
11253 {
11254 enum memmodel model = memmodel_from_int (INTVAL (operands[2]));
11255
11256 if (MEM_ALIGN (operands[0]) < GET_MODE_BITSIZE (GET_MODE (operands[0])))
11257 FAIL;
11258
11259 if (<MODE>mode == TImode)
11260 emit_insn (gen_atomic_storeti_1 (operands[0], operands[1]));
11261 else if (<MODE>mode == DImode && !TARGET_ZARCH)
11262 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
11263 else
11264 emit_move_insn (operands[0], operands[1]);
11265 if (is_mm_seq_cst (model))
11266 emit_insn (gen_mem_thread_fence (operands[2]));
11267 DONE;
11268 })
11269
11270 ; Different from movdi_31 in that we want no splitters.
11271 (define_insn "atomic_storedi_1"
11272 [(set (match_operand:DI 0 "memory_operand" "=Q,S,R,T")
11273 (unspec:DI [(match_operand:DI 1 "register_operand" "d,d,!*f,!*f")]
11274 UNSPEC_MOVA))]
11275 "!TARGET_ZARCH"
11276 "@
11277 stm\t%1,%N1,%S0
11278 stmy\t%1,%N1,%S0
11279 std %1,%0
11280 stdy %1,%0"
11281 [(set_attr "op_type" "RS,RSY,RS,RSY")
11282 (set_attr "cpu_facility" "*,longdisp,*,longdisp")
11283 (set_attr "type" "stm,stm,fstoredf,fstoredf")])
11284
11285 (define_insn "atomic_storeti_1"
11286 [(set (match_operand:TI 0 "memory_operand" "=T")
11287 (unspec:TI [(match_operand:TI 1 "register_operand" "r")]
11288 UNSPEC_MOVA))]
11289 "TARGET_ZARCH"
11290 "stpq\t%1,%0"
11291 [(set_attr "op_type" "RXY")
11292 (set_attr "type" "other")])
11293
11294 ;
11295 ; compare and swap patterns.
11296 ;
11297
11298 (define_expand "atomic_compare_and_swap<mode>"
11299 [(match_operand:SI 0 "register_operand") ;; bool success output
11300 (match_operand:DINT 1 "nonimmediate_operand");; oldval output
11301 (match_operand:DINT 2 "s_operand") ;; memory
11302 (match_operand:DINT 3 "general_operand") ;; expected intput
11303 (match_operand:DINT 4 "general_operand") ;; newval intput
11304 (match_operand:SI 5 "const_int_operand") ;; is_weak
11305 (match_operand:SI 6 "const_int_operand") ;; success model
11306 (match_operand:SI 7 "const_int_operand")] ;; failure model
11307 ""
11308 {
11309 if (GET_MODE_BITSIZE (<MODE>mode) >= 16
11310 && GET_MODE_BITSIZE (<MODE>mode) > MEM_ALIGN (operands[2]))
11311 FAIL;
11312
11313 s390_expand_cs (<MODE>mode, operands[0], operands[1], operands[2],
11314 operands[3], operands[4], INTVAL (operands[5]));
11315 DONE;})
11316
11317 (define_expand "atomic_compare_and_swap<mode>_internal"
11318 [(parallel
11319 [(set (match_operand:DGPR 0 "register_operand")
11320 (match_operand:DGPR 1 "s_operand"))
11321 (set (match_dup 1)
11322 (unspec_volatile:DGPR
11323 [(match_dup 1)
11324 (match_operand:DGPR 2 "register_operand")
11325 (match_operand:DGPR 3 "register_operand")]
11326 UNSPECV_CAS))
11327 (set (match_operand 4 "cc_reg_operand")
11328 (match_dup 5))])]
11329 "GET_MODE (operands[4]) == CCZmode
11330 || GET_MODE (operands[4]) == CCZ1mode"
11331 {
11332 operands[5]
11333 = gen_rtx_COMPARE (GET_MODE (operands[4]), operands[1], operands[2]);
11334 })
11335
11336 ; cdsg, csg
11337 (define_insn "*atomic_compare_and_swap<mode>_1"
11338 [(set (match_operand:TDI 0 "register_operand" "=r")
11339 (match_operand:TDI 1 "nonsym_memory_operand" "+S"))
11340 (set (match_dup 1)
11341 (unspec_volatile:TDI
11342 [(match_dup 1)
11343 (match_operand:TDI 2 "register_operand" "0")
11344 (match_operand:TDI 3 "register_operand" "r")]
11345 UNSPECV_CAS))
11346 (set (reg CC_REGNUM)
11347 (compare (match_dup 1) (match_dup 2)))]
11348 "TARGET_ZARCH
11349 && s390_match_ccmode (insn, CCZ1mode)"
11350 "c<td>sg\t%0,%3,%S1"
11351 [(set_attr "op_type" "RSY")
11352 (set_attr "type" "sem")])
11353
11354 ; cds, cdsy
11355 (define_insn "*atomic_compare_and_swapdi_2"
11356 [(set (match_operand:DI 0 "register_operand" "=r,r")
11357 (match_operand:DI 1 "nonsym_memory_operand" "+Q,S"))
11358 (set (match_dup 1)
11359 (unspec_volatile:DI
11360 [(match_dup 1)
11361 (match_operand:DI 2 "register_operand" "0,0")
11362 (match_operand:DI 3 "register_operand" "r,r")]
11363 UNSPECV_CAS))
11364 (set (reg CC_REGNUM)
11365 (compare (match_dup 1) (match_dup 2)))]
11366 "!TARGET_ZARCH
11367 && s390_match_ccmode (insn, CCZ1mode)"
11368 "@
11369 cds\t%0,%3,%S1
11370 cdsy\t%0,%3,%S1"
11371 [(set_attr "op_type" "RS,RSY")
11372 (set_attr "cpu_facility" "*,longdisp")
11373 (set_attr "type" "sem")])
11374
11375 ; cs, csy
11376 (define_insn "*atomic_compare_and_swapsi_3"
11377 [(set (match_operand:SI 0 "register_operand" "=r,r")
11378 (match_operand:SI 1 "nonsym_memory_operand" "+Q,S"))
11379 (set (match_dup 1)
11380 (unspec_volatile:SI
11381 [(match_dup 1)
11382 (match_operand:SI 2 "register_operand" "0,0")
11383 (match_operand:SI 3 "register_operand" "r,r")]
11384 UNSPECV_CAS))
11385 (set (reg CC_REGNUM)
11386 (compare (match_dup 1) (match_dup 2)))]
11387 "s390_match_ccmode (insn, CCZ1mode)"
11388 "@
11389 cs\t%0,%3,%S1
11390 csy\t%0,%3,%S1"
11391 [(set_attr "op_type" "RS,RSY")
11392 (set_attr "cpu_facility" "*,longdisp")
11393 (set_attr "type" "sem")])
11394
11395 ;
11396 ; Other atomic instruction patterns.
11397 ;
11398
11399 ; z196 load and add, xor, or and and instructions
11400
11401 (define_expand "atomic_fetch_<atomic><mode>"
11402 [(match_operand:GPR 0 "register_operand") ;; val out
11403 (ATOMIC_Z196:GPR
11404 (match_operand:GPR 1 "memory_operand") ;; memory
11405 (match_operand:GPR 2 "register_operand")) ;; val in
11406 (match_operand:SI 3 "const_int_operand")] ;; model
11407 "TARGET_Z196"
11408 {
11409 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
11410 FAIL;
11411
11412 emit_insn (gen_atomic_fetch_<atomic><mode>_iaf
11413 (operands[0], operands[1], operands[2]));
11414 DONE;
11415 })
11416
11417 ; lan, lang, lao, laog, lax, laxg, laa, laag
11418 (define_insn "atomic_fetch_<atomic><mode>_iaf"
11419 [(set (match_operand:GPR 0 "register_operand" "=d")
11420 (match_operand:GPR 1 "memory_operand" "+S"))
11421 (set (match_dup 1)
11422 (unspec_volatile:GPR
11423 [(ATOMIC_Z196:GPR (match_dup 1)
11424 (match_operand:GPR 2 "general_operand" "d"))]
11425 UNSPECV_ATOMIC_OP))
11426 (clobber (reg:CC CC_REGNUM))]
11427 "TARGET_Z196"
11428 "la<noxa><g>\t%0,%2,%1"
11429 [(set_attr "op_type" "RSY")
11430 (set_attr "type" "sem")])
11431
11432 ;; For SImode and larger, the optabs.cc code will do just fine in
11433 ;; expanding a compare-and-swap loop. For QI/HImode, we can do
11434 ;; better by expanding our own loop.
11435
11436 (define_expand "atomic_<atomic><mode>"
11437 [(ATOMIC:HQI
11438 (match_operand:HQI 0 "memory_operand") ;; memory
11439 (match_operand:HQI 1 "general_operand")) ;; val in
11440 (match_operand:SI 2 "const_int_operand")] ;; model
11441 ""
11442 {
11443 s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
11444 operands[1], false);
11445 DONE;
11446 })
11447
11448 (define_expand "atomic_fetch_<atomic><mode>"
11449 [(match_operand:HQI 0 "register_operand") ;; val out
11450 (ATOMIC:HQI
11451 (match_operand:HQI 1 "memory_operand") ;; memory
11452 (match_operand:HQI 2 "general_operand")) ;; val in
11453 (match_operand:SI 3 "const_int_operand")] ;; model
11454 ""
11455 {
11456 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
11457 operands[2], false);
11458 DONE;
11459 })
11460
11461 (define_expand "atomic_<atomic>_fetch<mode>"
11462 [(match_operand:HQI 0 "register_operand") ;; val out
11463 (ATOMIC:HQI
11464 (match_operand:HQI 1 "memory_operand") ;; memory
11465 (match_operand:HQI 2 "general_operand")) ;; val in
11466 (match_operand:SI 3 "const_int_operand")] ;; model
11467 ""
11468 {
11469 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
11470 operands[2], true);
11471 DONE;
11472 })
11473
11474 ;; Pattern to implement atomic_exchange with a compare-and-swap loop. The code
11475 ;; generated by the middleend is not good.
11476 (define_expand "atomic_exchange<mode>"
11477 [(match_operand:DINT 0 "register_operand") ;; val out
11478 (match_operand:DINT 1 "s_operand") ;; memory
11479 (match_operand:DINT 2 "general_operand") ;; val in
11480 (match_operand:SI 3 "const_int_operand")] ;; model
11481 ""
11482 {
11483 if (<MODE>mode != QImode
11484 && MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (<MODE>mode))
11485 FAIL;
11486 if (<MODE>mode == HImode || <MODE>mode == QImode)
11487 s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1], operands[2],
11488 false);
11489 else if (<MODE>mode == SImode || TARGET_ZARCH)
11490 s390_expand_atomic_exchange_tdsi (operands[0], operands[1], operands[2]);
11491 else
11492 FAIL;
11493 DONE;
11494 })
11495
11496 ;;
11497 ;;- Miscellaneous instructions.
11498 ;;
11499
11500 ;
11501 ; allocate stack instruction pattern(s).
11502 ;
11503
11504 (define_expand "allocate_stack"
11505 [(match_operand 0 "general_operand" "")
11506 (match_operand 1 "general_operand" "")]
11507 "TARGET_BACKCHAIN"
11508 {
11509 rtx temp = gen_reg_rtx (Pmode);
11510
11511 emit_move_insn (temp, s390_back_chain_rtx ());
11512
11513 if (flag_stack_clash_protection)
11514 anti_adjust_stack_and_probe_stack_clash (operands[1]);
11515 else
11516 anti_adjust_stack (operands[1]);
11517
11518 emit_move_insn (s390_back_chain_rtx (), temp);
11519
11520 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
11521 DONE;
11522 })
11523
11524 (define_expand "@probe_stack2<mode>"
11525 [(set (reg:CCZ CC_REGNUM)
11526 (compare:CCZ (reg:W 0)
11527 (match_operand:W 0 "memory_operand")))
11528 (unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
11529 "")
11530
11531 (define_expand "probe_stack"
11532 [(match_operand 0 "memory_operand")]
11533 ""
11534 {
11535 emit_insn (gen_probe_stack2 (word_mode, operands[0]));
11536 DONE;
11537 })
11538
11539 ;
11540 ; setjmp instruction pattern.
11541 ;
11542
11543 (define_expand "builtin_setjmp_receiver"
11544 [(match_operand 0 "" "")]
11545 "flag_pic"
11546 {
11547 emit_insn (s390_load_got ());
11548 emit_use (pic_offset_table_rtx);
11549 DONE;
11550 })
11551
11552 ;; These patterns say how to save and restore the stack pointer. We need not
11553 ;; save the stack pointer at function level since we are careful to
11554 ;; preserve the backchain. At block level, we have to restore the backchain
11555 ;; when we restore the stack pointer.
11556 ;;
11557 ;; For nonlocal gotos, we must save both the stack pointer and its
11558 ;; backchain and restore both. Note that in the nonlocal case, the
11559 ;; save area is a memory location.
11560
11561 (define_expand "save_stack_function"
11562 [(match_operand 0 "general_operand" "")
11563 (match_operand 1 "general_operand" "")]
11564 ""
11565 "DONE;")
11566
11567 (define_expand "restore_stack_function"
11568 [(match_operand 0 "general_operand" "")
11569 (match_operand 1 "general_operand" "")]
11570 ""
11571 "DONE;")
11572
11573 (define_expand "restore_stack_block"
11574 [(match_operand 0 "register_operand" "")
11575 (match_operand 1 "register_operand" "")]
11576 "TARGET_BACKCHAIN"
11577 {
11578 rtx temp = gen_reg_rtx (Pmode);
11579
11580 emit_move_insn (temp, s390_back_chain_rtx ());
11581 emit_move_insn (operands[0], operands[1]);
11582 emit_move_insn (s390_back_chain_rtx (), temp);
11583
11584 DONE;
11585 })
11586
11587 (define_expand "save_stack_nonlocal"
11588 [(match_operand 0 "memory_operand" "")
11589 (match_operand 1 "register_operand" "")]
11590 ""
11591 {
11592 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
11593
11594 /* Copy the backchain to the first word, sp to the second and the
11595 literal pool base to the third. */
11596
11597 rtx save_bc = adjust_address (operands[0], Pmode, 0);
11598 rtx save_sp = adjust_address (operands[0], Pmode, GET_MODE_SIZE (Pmode));
11599 rtx save_bp = adjust_address (operands[0], Pmode, 2 * GET_MODE_SIZE (Pmode));
11600
11601 if (TARGET_BACKCHAIN)
11602 emit_move_insn (save_bc, force_reg (Pmode, s390_back_chain_rtx ()));
11603
11604 emit_move_insn (save_sp, operands[1]);
11605 emit_move_insn (save_bp, base);
11606
11607 DONE;
11608 })
11609
11610 (define_expand "restore_stack_nonlocal"
11611 [(match_operand 0 "register_operand" "")
11612 (match_operand 1 "memory_operand" "")]
11613 ""
11614 {
11615 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
11616 rtx temp = NULL_RTX;
11617
11618 /* Restore the backchain from the first word, sp from the second and the
11619 literal pool base from the third. */
11620
11621 rtx save_bc = adjust_address (operands[1], Pmode, 0);
11622 rtx save_sp = adjust_address (operands[1], Pmode, GET_MODE_SIZE (Pmode));
11623 rtx save_bp = adjust_address (operands[1], Pmode, 2 * GET_MODE_SIZE (Pmode));
11624
11625 if (TARGET_BACKCHAIN)
11626 temp = force_reg (Pmode, save_bc);
11627
11628 emit_move_insn (base, save_bp);
11629 emit_move_insn (operands[0], save_sp);
11630
11631 if (temp)
11632 emit_move_insn (s390_back_chain_rtx (), temp);
11633
11634 emit_use (base);
11635 DONE;
11636 })
11637
11638 (define_expand "exception_receiver"
11639 [(const_int 0)]
11640 ""
11641 {
11642 s390_set_has_landing_pad_p (true);
11643 DONE;
11644 })
11645
11646 ;
11647 ; nop instruction pattern(s).
11648 ;
11649
11650 (define_insn "nop"
11651 [(const_int 0)]
11652 ""
11653 "nopr\t%%r0"
11654 [(set_attr "op_type" "RR")])
11655
11656 ; non-branch NOPs required for optimizing compare-and-branch patterns
11657 ; on z10
11658
11659 (define_insn "nop_lr0"
11660 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_LR_0)]
11661 ""
11662 "lr\t0,0"
11663 [(set_attr "op_type" "RR")
11664 (set_attr "z10prop" "z10_fr_E1")])
11665
11666 (define_insn "nop_lr1"
11667 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_LR_1)]
11668 ""
11669 "lr\t1,1"
11670 [(set_attr "op_type" "RR")])
11671
11672 ;;- Undeletable nops (used for hotpatching)
11673
11674 (define_insn "nop_2_byte"
11675 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_2_BYTE)]
11676 ""
11677 "nopr\t%%r0"
11678 [(set_attr "op_type" "RR")])
11679
11680 (define_insn "nop_4_byte"
11681 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_4_BYTE)]
11682 ""
11683 "nop\t0"
11684 [(set_attr "op_type" "RX")])
11685
11686 (define_insn "nop_6_byte"
11687 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_6_BYTE)]
11688 ""
11689 "brcl\t0, 0"
11690 [(set_attr "op_type" "RIL")
11691 (set_attr "relative_long" "yes")])
11692
11693
11694 ;
11695 ; Special literal pool access instruction pattern(s).
11696 ;
11697
11698 (define_insn "*pool_entry"
11699 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
11700 UNSPECV_POOL_ENTRY)]
11701 ""
11702 {
11703 machine_mode mode = GET_MODE (PATTERN (insn));
11704 unsigned int align = GET_MODE_BITSIZE (mode);
11705 s390_output_pool_entry (operands[0], mode, align);
11706 return "";
11707 }
11708 [(set (attr "length")
11709 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
11710
11711 (define_insn "pool_align"
11712 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
11713 UNSPECV_POOL_ALIGN)]
11714 ""
11715 ".align\t%0"
11716 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
11717
11718 (define_insn "pool_section_start"
11719 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
11720 ""
11721 {
11722 switch_to_section (targetm.asm_out.function_rodata_section
11723 (current_function_decl, false));
11724 return "";
11725 }
11726 [(set_attr "length" "0")])
11727
11728 (define_insn "pool_section_end"
11729 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
11730 ""
11731 {
11732 switch_to_section (current_function_section ());
11733 return "";
11734 }
11735 [(set_attr "length" "0")])
11736
11737 (define_insn "main_base_64"
11738 [(set (match_operand 0 "register_operand" "=a")
11739 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
11740 "GET_MODE (operands[0]) == Pmode"
11741 "larl\t%0,%1"
11742 [(set_attr "op_type" "RIL")
11743 (set_attr "type" "larl")
11744 (set_attr "z10prop" "z10_fwd_A1")
11745 (set_attr "relative_long" "yes")])
11746
11747 (define_insn "main_pool"
11748 [(set (match_operand 0 "register_operand" "=a")
11749 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
11750 "GET_MODE (operands[0]) == Pmode"
11751 {
11752 gcc_unreachable ();
11753 }
11754 [(set (attr "type")
11755 (const_string "larl"))])
11756
11757 (define_insn "reload_base_64"
11758 [(set (match_operand 0 "register_operand" "=a")
11759 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
11760 "GET_MODE (operands[0]) == Pmode"
11761 "larl\t%0,%1"
11762 [(set_attr "op_type" "RIL")
11763 (set_attr "type" "larl")
11764 (set_attr "z10prop" "z10_fwd_A1")])
11765
11766 (define_insn "pool"
11767 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
11768 ""
11769 {
11770 gcc_unreachable ();
11771 }
11772 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
11773
11774 ;;
11775 ;; Insns related to generating the function prologue and epilogue.
11776 ;;
11777
11778
11779 (define_expand "prologue"
11780 [(use (const_int 0))]
11781 ""
11782 "s390_emit_prologue (); DONE;")
11783
11784 (define_expand "epilogue"
11785 [(use (const_int 1))]
11786 ""
11787 "s390_emit_epilogue (false); DONE;")
11788
11789 (define_expand "sibcall_epilogue"
11790 [(use (const_int 0))]
11791 ""
11792 "s390_emit_epilogue (true); DONE;")
11793
11794 ;; A direct return instruction, without using an epilogue.
11795 (define_insn "<code>"
11796 [(ANY_RETURN)]
11797 "s390_can_use_<code>_insn ()"
11798 {
11799 if (TARGET_INDIRECT_BRANCH_NOBP_RET)
11800 {
11801 /* The target is always r14 so there is no clobber
11802 of r1 needed for pre z10 targets. */
11803 s390_indirect_branch_via_thunk (RETURN_REGNUM,
11804 INVALID_REGNUM,
11805 NULL_RTX,
11806 s390_indirect_branch_type_return);
11807 return "";
11808 }
11809 else
11810 return "br\t%%r14";
11811 }
11812 [(set (attr "op_type")
11813 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
11814 (const_string "RIL")
11815 (const_string "RR")))
11816 (set (attr "mnemonic")
11817 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
11818 (const_string "jg")
11819 (const_string "br")))
11820 (set_attr "type" "jsr")
11821 (set_attr "atype" "agen")])
11822
11823
11824 (define_expand "return_use"
11825 [(parallel
11826 [(return)
11827 (use (match_operand 0 "register_operand" "a"))])]
11828 ""
11829 {
11830 if (!TARGET_CPU_Z10
11831 && TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION)
11832 {
11833 if (TARGET_64BIT)
11834 emit_jump_insn (gen_returndi_prez10 (operands[0]));
11835 else
11836 emit_jump_insn (gen_returnsi_prez10 (operands[0]));
11837 DONE;
11838 }
11839 })
11840
11841 (define_insn "*return<mode>"
11842 [(return)
11843 (use (match_operand:P 0 "register_operand" "a"))]
11844 "TARGET_CPU_Z10 || !TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION"
11845 {
11846 if (TARGET_INDIRECT_BRANCH_NOBP_RET)
11847 {
11848 s390_indirect_branch_via_thunk (REGNO (operands[0]),
11849 INVALID_REGNUM,
11850 NULL_RTX,
11851 s390_indirect_branch_type_return);
11852 return "";
11853 }
11854 else
11855 return "br\t%0";
11856 }
11857 [(set (attr "op_type")
11858 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
11859 (const_string "RIL")
11860 (const_string "RR")))
11861 (set (attr "mnemonic")
11862 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
11863 (const_string "jg")
11864 (const_string "br")))
11865 (set_attr "type" "jsr")
11866 (set_attr "atype" "agen")])
11867
11868 (define_insn "return<mode>_prez10"
11869 [(return)
11870 (use (match_operand:P 0 "register_operand" "a"))
11871 (clobber (reg:P INDIRECT_BRANCH_THUNK_REGNUM))]
11872 "!TARGET_CPU_Z10 && TARGET_INDIRECT_BRANCH_NOBP_RET_OPTION"
11873 {
11874 if (TARGET_INDIRECT_BRANCH_NOBP_RET)
11875 {
11876 s390_indirect_branch_via_thunk (REGNO (operands[0]),
11877 INVALID_REGNUM,
11878 NULL_RTX,
11879 s390_indirect_branch_type_return);
11880 return "";
11881 }
11882 else
11883 return "br\t%0";
11884 }
11885 [(set (attr "op_type")
11886 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
11887 (const_string "RIL")
11888 (const_string "RR")))
11889 (set (attr "mnemonic")
11890 (if_then_else (match_test "TARGET_INDIRECT_BRANCH_NOBP_RET")
11891 (const_string "jg")
11892 (const_string "br")))
11893 (set_attr "type" "jsr")
11894 (set_attr "atype" "agen")])
11895
11896
11897 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
11898 ;; pointer. This is used for compatibility.
11899
11900 (define_expand "ptr_extend"
11901 [(set (match_operand:DI 0 "register_operand" "=r")
11902 (match_operand:SI 1 "register_operand" "r"))]
11903 "TARGET_64BIT"
11904 {
11905 emit_insn (gen_anddi3 (operands[0],
11906 gen_lowpart (DImode, operands[1]),
11907 GEN_INT (0x7fffffff)));
11908 DONE;
11909 })
11910
11911 ;; Instruction definition to expand eh_return macro to support
11912 ;; swapping in special linkage return addresses.
11913
11914 (define_expand "eh_return"
11915 [(use (match_operand 0 "register_operand" ""))]
11916 "TARGET_TPF"
11917 {
11918 s390_emit_tpf_eh_return (operands[0]);
11919 DONE;
11920 })
11921
11922 ;
11923 ; Stack Protector Patterns
11924 ;
11925
11926 (define_expand "stack_protect_set"
11927 [(set (match_operand 0 "memory_operand" "")
11928 (match_operand 1 "memory_operand" ""))]
11929 ""
11930 {
11931 #ifdef TARGET_THREAD_SSP_OFFSET
11932 operands[1]
11933 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
11934 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
11935 #endif
11936 if (TARGET_64BIT)
11937 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
11938 else
11939 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
11940
11941 DONE;
11942 })
11943
11944 (define_insn "stack_protect_set<mode>"
11945 [(set (match_operand:DSI 0 "memory_operand" "=Q")
11946 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
11947 ""
11948 "mvc\t%O0(%G0,%R0),%S1"
11949 [(set_attr "op_type" "SS")])
11950
11951 (define_expand "stack_protect_test"
11952 [(set (reg:CC CC_REGNUM)
11953 (compare (match_operand 0 "memory_operand" "")
11954 (match_operand 1 "memory_operand" "")))
11955 (match_operand 2 "" "")]
11956 ""
11957 {
11958 rtx cc_reg, test;
11959 #ifdef TARGET_THREAD_SSP_OFFSET
11960 operands[1]
11961 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
11962 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
11963 #endif
11964 if (TARGET_64BIT)
11965 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
11966 else
11967 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
11968
11969 cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM);
11970 test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx);
11971 emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2]));
11972 DONE;
11973 })
11974
11975 (define_insn "stack_protect_test<mode>"
11976 [(set (reg:CCZ CC_REGNUM)
11977 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
11978 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
11979 ""
11980 "clc\t%O0(%G0,%R0),%S1"
11981 [(set_attr "op_type" "SS")])
11982
11983 ; This is used in s390_emit_prologue in order to prevent insns
11984 ; adjusting the stack pointer to be moved over insns writing stack
11985 ; slots using a copy of the stack pointer in a different register.
11986 (define_insn "@stack_tie<mode>"
11987 [(set (match_operand:BLK 0 "memory_operand" "+m")
11988 (unspec:BLK [(match_dup 0)
11989 (match_operand:P 1 "register_operand" "r")] UNSPEC_TIE))]
11990 ""
11991 ""
11992 [(set_attr "length" "0")])
11993
11994
11995 (define_insn "stack_restore_from_fpr"
11996 [(set (reg:DI STACK_REGNUM)
11997 (match_operand:DI 0 "register_operand" "f"))
11998 (clobber (mem:BLK (scratch)))]
11999 "TARGET_Z10"
12000 "lgdr\t%%r15,%0"
12001 [(set_attr "op_type" "RRE")])
12002
12003 ;
12004 ; Data prefetch patterns
12005 ;
12006
12007 (define_insn "prefetch"
12008 [(prefetch (match_operand 0 "address_operand" "ZT,X")
12009 (match_operand:SI 1 "const_int_operand" " n,n")
12010 (match_operand:SI 2 "const_int_operand" " n,n"))]
12011 "TARGET_Z10"
12012 {
12013 switch (which_alternative)
12014 {
12015 case 0:
12016 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
12017 case 1:
12018 if (larl_operand (operands[0], Pmode))
12019 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
12020 /* fallthrough */
12021 default:
12022
12023 /* This might be reached for symbolic operands with an odd
12024 addend. We simply omit the prefetch for such rare cases. */
12025
12026 return "";
12027 }
12028 }
12029 [(set_attr "type" "load,larl")
12030 (set_attr "op_type" "RXY,RIL")
12031 (set_attr "z10prop" "z10_super")
12032 (set_attr "z196prop" "z196_alone")
12033 (set_attr "relative_long" "yes")])
12034
12035
12036 ;
12037 ; Byte swap instructions
12038 ;
12039
12040 ; FIXME: There is also mvcin but we cannot use it since src and target
12041 ; may overlap.
12042 ; lrvr, lrv, strv, lrvgr, lrvg, strvg
12043 (define_insn "bswap<mode>2"
12044 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,T")
12045 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,T,d")))]
12046 ""
12047 "@
12048 lrv<g>r\t%0,%1
12049 lrv<g>\t%0,%1
12050 strv<g>\t%1,%0"
12051 [(set_attr "type" "*,load,store")
12052 (set_attr "op_type" "RRE,RXY,RXY")
12053 (set_attr "z10prop" "z10_super")])
12054
12055 (define_insn "bswaphi2"
12056 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,T")
12057 (bswap:HI (match_operand:HI 1 "nonimmediate_operand" " d,T,d")))]
12058 ""
12059 "@
12060 #
12061 lrvh\t%0,%1
12062 strvh\t%1,%0"
12063 [(set_attr "type" "*,load,store")
12064 (set_attr "op_type" "RRE,RXY,RXY")
12065 (set_attr "z10prop" "z10_super")])
12066
12067 (define_split
12068 [(set (match_operand:HI 0 "register_operand" "")
12069 (bswap:HI (match_operand:HI 1 "register_operand" "")))]
12070 ""
12071 [(set (match_dup 2) (bswap:SI (match_dup 3)))
12072 (set (match_dup 2) (lshiftrt:SI (match_dup 2) (const_int 16)))]
12073 {
12074 operands[2] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
12075 operands[3] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
12076 })
12077
12078
12079 ;
12080 ; Population count instruction
12081 ;
12082
12083 (define_insn "*popcountdi_z15_cc"
12084 [(set (reg CC_REGNUM)
12085 (compare (popcount:DI (match_operand:DI 1 "register_operand" "d"))
12086 (const_int 0)))
12087 (set (match_operand:DI 0 "register_operand" "=d")
12088 (match_dup 1))]
12089 "TARGET_Z15 && s390_match_ccmode (insn, CCTmode)"
12090 "popcnt\t%0,%1,8"
12091 [(set_attr "op_type" "RRF")])
12092
12093 (define_insn "*popcountdi_z15_cconly"
12094 [(set (reg CC_REGNUM)
12095 (compare (popcount:DI (match_operand:DI 1 "register_operand" "d"))
12096 (const_int 0)))
12097 (clobber (match_scratch:DI 0 "=d"))]
12098 "TARGET_Z15 && s390_match_ccmode(insn, CCTmode)"
12099 "popcnt\t%0,%1,8"
12100 [(set_attr "op_type" "RRF")])
12101
12102 (define_insn "*popcountdi_z15"
12103 [(set (match_operand:DI 0 "register_operand" "=d")
12104 (popcount:DI (match_operand:DI 1 "register_operand" "d")))
12105 (clobber (reg:CC CC_REGNUM))]
12106 "TARGET_Z15"
12107 "popcnt\t%0,%1,8"
12108 [(set_attr "op_type" "RRF")])
12109
12110 ; The pre-z15 popcount instruction counts the bits of op1 in 8 byte
12111 ; portions and stores the result in the corresponding bytes in op0.
12112 (define_insn "*popcount<mode>_z196"
12113 [(set (match_operand:INT 0 "register_operand" "=d")
12114 (unspec:INT [(match_operand:INT 1 "register_operand" "d")] UNSPEC_POPCNT))
12115 (clobber (reg:CC CC_REGNUM))]
12116 "TARGET_Z196"
12117 "popcnt\t%0,%1"
12118 [(set_attr "op_type" "RRE")])
12119
12120 (define_expand "popcountdi2_z196"
12121 [; popcnt op0, op1
12122 (parallel [(set (match_operand:DI 0 "register_operand" "")
12123 (unspec:DI [(match_operand:DI 1 "register_operand")]
12124 UNSPEC_POPCNT))
12125 (clobber (reg:CC CC_REGNUM))])
12126 ; sllg op2, op0, 32
12127 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 32)))
12128 ; agr op0, op2
12129 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
12130 (clobber (reg:CC CC_REGNUM))])
12131 ; sllg op2, op0, 16
12132 (set (match_dup 2)
12133 (ashift:DI (match_dup 0) (const_int 16)))
12134 ; agr op0, op2
12135 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
12136 (clobber (reg:CC CC_REGNUM))])
12137 ; sllg op2, op0, 8
12138 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 8)))
12139 ; agr op0, op2
12140 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
12141 (clobber (reg:CC CC_REGNUM))])
12142 ; srlg op0, op0, 56
12143 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (const_int 56)))]
12144 "TARGET_Z196"
12145 "operands[2] = gen_reg_rtx (DImode);")
12146
12147 (define_expand "popcountdi2"
12148 [(parallel
12149 [(set (match_operand:DI 0 "register_operand" "")
12150 (popcount:DI (match_operand:DI 1 "register_operand")))
12151 (clobber (reg:CC CC_REGNUM))])]
12152 "TARGET_Z196"
12153 {
12154 if (!TARGET_Z15)
12155 {
12156 emit_insn (gen_popcountdi2_z196 (operands[0], operands[1]));
12157 DONE;
12158 }
12159 })
12160
12161 (define_expand "popcountsi2_z196"
12162 [; popcnt op0, op1
12163 (parallel [(set (match_operand:SI 0 "register_operand" "")
12164 (unspec:SI [(match_operand:SI 1 "register_operand")]
12165 UNSPEC_POPCNT))
12166 (clobber (reg:CC CC_REGNUM))])
12167 ; sllk op2, op0, 16
12168 (set (match_dup 2)
12169 (ashift:SI (match_dup 0) (const_int 16)))
12170 ; ar op0, op2
12171 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
12172 (clobber (reg:CC CC_REGNUM))])
12173 ; sllk op2, op0, 8
12174 (set (match_dup 2) (ashift:SI (match_dup 0) (const_int 8)))
12175 ; ar op0, op2
12176 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
12177 (clobber (reg:CC CC_REGNUM))])
12178 ; srl op0, op0, 24
12179 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 24)))]
12180 "TARGET_Z196"
12181 "operands[2] = gen_reg_rtx (SImode);")
12182
12183 ; popcount always counts on the full 64 bit. With the z196 version
12184 ; counting bits per byte we just ignore the upper 4 bytes. With the
12185 ; z15 version we have to zero out the upper 32 bits first.
12186 (define_expand "popcountsi2"
12187 [(set (match_dup 2)
12188 (zero_extend:DI (match_operand:SI 1 "register_operand")))
12189 (parallel [(set (match_dup 3) (popcount:DI (match_dup 2)))
12190 (clobber (reg:CC CC_REGNUM))])
12191 (set (match_operand:SI 0 "register_operand")
12192 (subreg:SI (match_dup 3) 4))]
12193 "TARGET_Z196"
12194 {
12195 if (!TARGET_Z15)
12196 {
12197 emit_insn (gen_popcountsi2_z196 (operands[0], operands[1]));
12198 DONE;
12199 }
12200 else
12201 {
12202 operands[2] = gen_reg_rtx (DImode);
12203 operands[3] = gen_reg_rtx (DImode);
12204 }
12205 })
12206
12207 (define_expand "popcounthi2_z196"
12208 [; popcnt op2, op1
12209 (parallel [(set (match_dup 2)
12210 (unspec:HI [(match_operand:HI 1 "register_operand")]
12211 UNSPEC_POPCNT))
12212 (clobber (reg:CC CC_REGNUM))])
12213 ; lr op3, op2
12214 (set (match_dup 3) (subreg:SI (match_dup 2) 0))
12215 ; srl op4, op3, 8
12216 (set (match_dup 4) (lshiftrt:SI (match_dup 3) (const_int 8)))
12217 ; ar op3, op4
12218 (parallel [(set (match_dup 3) (plus:SI (match_dup 3) (match_dup 4)))
12219 (clobber (reg:CC CC_REGNUM))])
12220 ; llgc op0, op3
12221 (parallel [(set (match_operand:HI 0 "register_operand" "")
12222 (and:HI (subreg:HI (match_dup 3) 2) (const_int 255)))
12223 (clobber (reg:CC CC_REGNUM))])]
12224 "TARGET_Z196"
12225 {
12226 operands[2] = gen_reg_rtx (HImode);
12227 operands[3] = gen_reg_rtx (SImode);
12228 operands[4] = gen_reg_rtx (SImode);
12229 })
12230
12231 (define_expand "popcounthi2"
12232 [(set (match_dup 2)
12233 (zero_extend:DI (match_operand:HI 1 "register_operand")))
12234 (parallel [(set (match_dup 3) (popcount:DI (match_dup 2)))
12235 (clobber (reg:CC CC_REGNUM))])
12236 (set (match_operand:HI 0 "register_operand")
12237 (subreg:HI (match_dup 3) 6))]
12238 "TARGET_Z196"
12239 {
12240 if (!TARGET_Z15)
12241 {
12242 emit_insn (gen_popcounthi2_z196 (operands[0], operands[1]));
12243 DONE;
12244 }
12245 else
12246 {
12247 operands[2] = gen_reg_rtx (DImode);
12248 operands[3] = gen_reg_rtx (DImode);
12249 }
12250 })
12251
12252 ; For popcount on a single byte the old z196 style popcount
12253 ; instruction is ideal. Since it anyway does a byte-wise popcount we
12254 ; just use it instead of zero extending the QImode input to DImode and
12255 ; using the z15 popcount variant.
12256 (define_expand "popcountqi2"
12257 [; popcnt op0, op1
12258 (parallel [(set (match_operand:QI 0 "register_operand" "")
12259 (unspec:QI [(match_operand:QI 1 "register_operand")]
12260 UNSPEC_POPCNT))
12261 (clobber (reg:CC CC_REGNUM))])]
12262 "TARGET_Z196"
12263 "")
12264
12265 ;;
12266 ;;- Copy sign instructions
12267 ;;
12268
12269 (define_insn "copysign<mode>3<tf_fpr>"
12270 [(set (match_operand:FP 0 "register_operand" "=f")
12271 (copysign:FP (match_operand:FP 1 "register_operand" "<fT0>")
12272 (match_operand:FP 2 "register_operand" "f")))]
12273 "TARGET_Z196"
12274 "cpsdr\t%0,%2,%1"
12275 [(set_attr "op_type" "RRF")
12276 (set_attr "type" "fsimp<type>")])
12277
12278
12279 ;;
12280 ;;- Transactional execution instructions
12281 ;;
12282
12283 ; This splitter helps combine to make use of CC directly when
12284 ; comparing the integer result of a tbegin builtin with a constant.
12285 ; The unspec is already removed by canonicalize_comparison. So this
12286 ; splitters only job is to turn the PARALLEL into separate insns
12287 ; again. Unfortunately this only works with the very first cc/int
12288 ; compare since combine is not able to deal with data flow across
12289 ; basic block boundaries.
12290
12291 ; It needs to be an insn pattern as well since combine does not apply
12292 ; the splitter directly. Combine would only use it if it actually
12293 ; would reduce the number of instructions.
12294 (define_insn_and_split "*ccraw_to_int"
12295 [(set (pc)
12296 (if_then_else
12297 (match_operator 0 "s390_eqne_operator"
12298 [(reg:CCRAW CC_REGNUM)
12299 (match_operand 1 "const_int_operand" "")])
12300 (label_ref (match_operand 2 "" ""))
12301 (pc)))
12302 (set (match_operand:SI 3 "register_operand" "=d")
12303 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
12304 ""
12305 "#"
12306 ""
12307 [(set (match_dup 3)
12308 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))
12309 (set (pc)
12310 (if_then_else (match_op_dup 0 [(reg:CCRAW CC_REGNUM) (match_dup 1)])
12311 (label_ref (match_dup 2))
12312 (pc)))]
12313 "")
12314
12315 ; Non-constrained transaction begin
12316
12317 (define_expand "tbegin"
12318 [(match_operand:SI 0 "register_operand" "")
12319 (match_operand:BLK 1 "memory_operand" "")]
12320 "TARGET_HTM"
12321 {
12322 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, true);
12323 DONE;
12324 })
12325
12326 (define_expand "tbegin_nofloat"
12327 [(match_operand:SI 0 "register_operand" "")
12328 (match_operand:BLK 1 "memory_operand" "")]
12329 "TARGET_HTM"
12330 {
12331 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, false);
12332 DONE;
12333 })
12334
12335 (define_expand "tbegin_retry"
12336 [(match_operand:SI 0 "register_operand" "")
12337 (match_operand:BLK 1 "memory_operand" "")
12338 (match_operand:SI 2 "general_operand" "")]
12339 "TARGET_HTM"
12340 {
12341 s390_expand_tbegin (operands[0], operands[1], operands[2], true);
12342 DONE;
12343 })
12344
12345 (define_expand "tbegin_retry_nofloat"
12346 [(match_operand:SI 0 "register_operand" "")
12347 (match_operand:BLK 1 "memory_operand" "")
12348 (match_operand:SI 2 "general_operand" "")]
12349 "TARGET_HTM"
12350 {
12351 s390_expand_tbegin (operands[0], operands[1], operands[2], false);
12352 DONE;
12353 })
12354
12355 ; Clobber VRs since they don't get restored
12356 (define_insn "tbegin_1_z13"
12357 [(set (reg:CCRAW CC_REGNUM)
12358 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
12359 UNSPECV_TBEGIN))
12360 (set (match_operand:BLK 1 "memory_operand" "=Q")
12361 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
12362 (clobber (reg:TI 16)) (clobber (reg:TI 38))
12363 (clobber (reg:TI 17)) (clobber (reg:TI 39))
12364 (clobber (reg:TI 18)) (clobber (reg:TI 40))
12365 (clobber (reg:TI 19)) (clobber (reg:TI 41))
12366 (clobber (reg:TI 20)) (clobber (reg:TI 42))
12367 (clobber (reg:TI 21)) (clobber (reg:TI 43))
12368 (clobber (reg:TI 22)) (clobber (reg:TI 44))
12369 (clobber (reg:TI 23)) (clobber (reg:TI 45))
12370 (clobber (reg:TI 24)) (clobber (reg:TI 46))
12371 (clobber (reg:TI 25)) (clobber (reg:TI 47))
12372 (clobber (reg:TI 26)) (clobber (reg:TI 48))
12373 (clobber (reg:TI 27)) (clobber (reg:TI 49))
12374 (clobber (reg:TI 28)) (clobber (reg:TI 50))
12375 (clobber (reg:TI 29)) (clobber (reg:TI 51))
12376 (clobber (reg:TI 30)) (clobber (reg:TI 52))
12377 (clobber (reg:TI 31)) (clobber (reg:TI 53))]
12378 ; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
12379 ; not supposed to be used for immediates (see genpreds.cc).
12380 "TARGET_VX && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
12381 "tbegin\t%1,%x0"
12382 [(set_attr "op_type" "SIL")])
12383
12384 (define_insn "tbegin_1"
12385 [(set (reg:CCRAW CC_REGNUM)
12386 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
12387 UNSPECV_TBEGIN))
12388 (set (match_operand:BLK 1 "memory_operand" "=Q")
12389 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
12390 (clobber (reg:DF 16))
12391 (clobber (reg:DF 17))
12392 (clobber (reg:DF 18))
12393 (clobber (reg:DF 19))
12394 (clobber (reg:DF 20))
12395 (clobber (reg:DF 21))
12396 (clobber (reg:DF 22))
12397 (clobber (reg:DF 23))
12398 (clobber (reg:DF 24))
12399 (clobber (reg:DF 25))
12400 (clobber (reg:DF 26))
12401 (clobber (reg:DF 27))
12402 (clobber (reg:DF 28))
12403 (clobber (reg:DF 29))
12404 (clobber (reg:DF 30))
12405 (clobber (reg:DF 31))]
12406 ; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
12407 ; not supposed to be used for immediates (see genpreds.cc).
12408 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
12409 "tbegin\t%1,%x0"
12410 [(set_attr "op_type" "SIL")])
12411
12412 ; Same as above but without the FPR clobbers
12413 (define_insn "tbegin_nofloat_1"
12414 [(set (reg:CCRAW CC_REGNUM)
12415 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
12416 UNSPECV_TBEGIN))
12417 (set (match_operand:BLK 1 "memory_operand" "=Q")
12418 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))]
12419 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
12420 "tbegin\t%1,%x0"
12421 [(set_attr "op_type" "SIL")])
12422
12423
12424 ; Constrained transaction begin
12425
12426 (define_expand "tbeginc"
12427 [(set (reg:CCRAW CC_REGNUM)
12428 (unspec_volatile:CCRAW [(const_int TBEGINC_MASK)]
12429 UNSPECV_TBEGINC))]
12430 "TARGET_HTM"
12431 "")
12432
12433 (define_insn "*tbeginc_1"
12434 [(set (reg:CCRAW CC_REGNUM)
12435 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" " D")]
12436 UNSPECV_TBEGINC))]
12437 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
12438 "tbeginc\t0,%x0"
12439 [(set_attr "op_type" "SIL")])
12440
12441 ; Transaction end
12442
12443 (define_expand "tend"
12444 [(set (reg:CCRAW CC_REGNUM)
12445 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))
12446 (set (match_operand:SI 0 "register_operand" "")
12447 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
12448 "TARGET_HTM"
12449 "")
12450
12451 (define_insn "*tend_1"
12452 [(set (reg:CCRAW CC_REGNUM)
12453 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))]
12454 "TARGET_HTM"
12455 "tend"
12456 [(set_attr "op_type" "S")])
12457
12458 ; Transaction abort
12459
12460 (define_expand "tabort"
12461 [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "")]
12462 UNSPECV_TABORT)]
12463 "TARGET_HTM"
12464 {
12465 if (CONST_INT_P (operands[0])
12466 && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 255)
12467 {
12468 error ("invalid transaction abort code: %wd (values in range 0 "
12469 "through 255 are reserved)", INTVAL (operands[0]));
12470 FAIL;
12471 }
12472 })
12473
12474 (define_insn "*tabort_1"
12475 [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "aJ")]
12476 UNSPECV_TABORT)]
12477 "TARGET_HTM"
12478 "tabort\t%Y0"
12479 [(set_attr "op_type" "S")])
12480
12481 (define_insn "*tabort_1_plus"
12482 [(unspec_volatile [(plus:SI (match_operand:SI 0 "register_operand" "a")
12483 (match_operand:SI 1 "const_int_operand" "J"))]
12484 UNSPECV_TABORT)]
12485 "TARGET_HTM && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'J', \"J\")"
12486 "tabort\t%1(%0)"
12487 [(set_attr "op_type" "S")])
12488
12489 ; Transaction extract nesting depth
12490
12491 (define_insn "etnd"
12492 [(set (match_operand:SI 0 "register_operand" "=d")
12493 (unspec_volatile:SI [(const_int 0)] UNSPECV_ETND))]
12494 "TARGET_HTM"
12495 "etnd\t%0"
12496 [(set_attr "op_type" "RRE")])
12497
12498 ; Non-transactional store
12499
12500 (define_insn "ntstg"
12501 [(set (match_operand:DI 0 "memory_operand" "=T")
12502 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "d")]
12503 UNSPECV_NTSTG))]
12504 "TARGET_HTM"
12505 "ntstg\t%1,%0"
12506 [(set_attr "op_type" "RXY")])
12507
12508 ; Transaction perform processor assist
12509
12510 (define_expand "tx_assist"
12511 [(unspec_volatile [(match_operand:SI 0 "register_operand" "")
12512 (reg:SI GPR0_REGNUM)
12513 (const_int PPA_TX_ABORT)]
12514 UNSPECV_PPA)]
12515 "TARGET_HTM"
12516 "")
12517
12518 (define_insn "*ppa"
12519 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")
12520 (match_operand:SI 1 "register_operand" "d")
12521 (match_operand 2 "const_int_operand" "I")]
12522 UNSPECV_PPA)]
12523 "(TARGET_ZEC12 || TARGET_HTM) && INTVAL (operands[2]) < 16"
12524 "ppa\t%0,%1,%2"
12525 [(set_attr "op_type" "RRF")])
12526
12527
12528 ; Set and get floating point control register
12529
12530 (define_insn "sfpc"
12531 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")]
12532 UNSPECV_SFPC)]
12533 "TARGET_HARD_FLOAT"
12534 "sfpc\t%0")
12535
12536 (define_insn "efpc"
12537 [(set (match_operand:SI 0 "register_operand" "=d")
12538 (unspec_volatile:SI [(const_int 0)] UNSPECV_EFPC))]
12539 "TARGET_HARD_FLOAT"
12540 "efpc\t%0")
12541
12542
12543 ; Load count to block boundary
12544
12545 (define_insn "lcbb"
12546 [(set (match_operand:SI 0 "register_operand" "=d")
12547 (unspec:SI [(match_operand 1 "address_operand" "ZR")
12548 (match_operand:SI 2 "immediate_operand" "C")] UNSPEC_LCBB))
12549 (clobber (reg:CC CC_REGNUM))]
12550 "TARGET_Z13"
12551 "lcbb\t%0,%a1,%b2"
12552 [(set_attr "op_type" "VRX")])
12553
12554 ; Handle -fsplit-stack.
12555
12556 (define_expand "split_stack_prologue"
12557 [(const_int 0)]
12558 ""
12559 {
12560 s390_expand_split_stack_prologue ();
12561 DONE;
12562 })
12563
12564 ;; If there are operand 0 bytes available on the stack, jump to
12565 ;; operand 1.
12566
12567 (define_expand "split_stack_space_check"
12568 [(set (pc) (if_then_else
12569 (ltu (minus (reg 15)
12570 (match_operand 0 "register_operand"))
12571 (unspec [(const_int 0)] UNSPEC_STACK_CHECK))
12572 (label_ref (match_operand 1))
12573 (pc)))]
12574 ""
12575 {
12576 /* Offset from thread pointer to __private_ss. */
12577 int psso = TARGET_64BIT ? 0x38 : 0x20;
12578 rtx tp = s390_get_thread_pointer ();
12579 rtx guard = gen_rtx_MEM (Pmode, plus_constant (Pmode, tp, psso));
12580 rtx reg = gen_reg_rtx (Pmode);
12581 rtx cc;
12582 if (TARGET_64BIT)
12583 emit_insn (gen_subdi3 (reg, stack_pointer_rtx, operands[0]));
12584 else
12585 emit_insn (gen_subsi3 (reg, stack_pointer_rtx, operands[0]));
12586 cc = s390_emit_compare (VOIDmode, GT, reg, guard);
12587 s390_emit_jump (operands[1], cc);
12588
12589 DONE;
12590 })
12591
12592 ;; Call to __morestack used by the split stack support
12593
12594 ; The insn has 3 parts:
12595 ; 1. A jump to the call done label. The jump will be done as part of
12596 ; __morestack and will not be explicitly emitted to the insn stream.
12597 ; 2. The call of __morestack including a use for r1 which is supposed to
12598 ; point to the parameter block for __morestack.
12599 ; 3. 3 USES whose values together with the call done label will be
12600 ; used to emit the parameter block to the .rodata section. This
12601 ; needs to be tied into the same insn as 1. since the call done
12602 ; label is emitted also as part of the parm block. In order to
12603 ; allow the edge to the BB with the call done label to be
12604 ; redirected both need to make use of the same label_ref.
12605
12606 (define_insn "@split_stack_call<mode>"
12607 [(set (pc) (label_ref (match_operand 2 "" ""))) ; call done label
12608 (set (reg:P 1) (unspec_volatile:P [(match_operand 0 "bras_sym_operand" "X")
12609 (reg:P 1)]
12610 UNSPECV_SPLIT_STACK_CALL))
12611 (use (label_ref (match_operand 1 "" "X"))) ; parm block label
12612 (use (match_operand 3 "const_int_operand" "X")) ; frame size
12613 (use (match_operand 4 "const_int_operand" "X"))] ; arg size
12614 ""
12615 {
12616 s390_output_split_stack_data (operands[1], operands[2], operands[3], operands[4]);
12617 return "jg\t%0%K0";
12618 }
12619 [(set_attr "op_type" "RIL")
12620 (set_attr "type" "branch")])
12621
12622 ; As above but with a conditional jump
12623
12624 (define_insn "@split_stack_cond_call<mode>"
12625 [(set (pc)
12626 (if_then_else
12627 (match_operand 5 "" "") ; condition
12628 (label_ref (match_operand 2 "" "")) ; call done label
12629 (pc)))
12630 (set (reg:P 1) (unspec_volatile:P [(match_operand 0 "bras_sym_operand" "X")
12631 (reg:P 1)]
12632 UNSPECV_SPLIT_STACK_CALL))
12633 (use (label_ref (match_operand 1 "" "X"))) ; parm block label
12634 (use (match_operand 3 "const_int_operand" "X")) ; frame size
12635 (use (match_operand 4 "const_int_operand" "X"))] ; arg size
12636 ""
12637 {
12638 s390_output_split_stack_data (operands[1], operands[2], operands[3], operands[4]);
12639 return "jg%C5\t%0";
12640 }
12641 [(set_attr "op_type" "RIL")
12642 (set_attr "type" "branch")])
12643
12644
12645 (define_insn "osc_break"
12646 [(unspec_volatile [(const_int 0)] UNSPECV_OSC_BREAK)]
12647 ""
12648 "bcr\t7,%%r0"
12649 [(set_attr "op_type" "RR")])
12650
12651 (define_expand "speculation_barrier"
12652 [(unspec_volatile [(reg:SI GPR0_REGNUM)
12653 (reg:SI GPR0_REGNUM)
12654 (const_int PPA_OOO_BARRIER)]
12655 UNSPECV_PPA)]
12656 "TARGET_ZEC12"
12657 "")
12658
12659 (define_expand "rawmemchr<SINT:mode>"
12660 [(match_operand 0 "register_operand")
12661 (match_operand 1 "memory_operand")
12662 (match_operand:SINT 2 "const_int_operand")]
12663 "TARGET_VX"
12664 "s390_rawmemchr(<SINT:MODE>mode, operands[0], operands[1], operands[2]); DONE;")