gcc/
[gcc.git] / gcc / config / s390 / s390.md
1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;; Copyright (C) 1999-2014 Free Software Foundation, Inc.
3 ;; Contributed by Hartmut Penner (hpenner@de.ibm.com) and
4 ;; Ulrich Weigand (uweigand@de.ibm.com) and
5 ;; Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
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
65 ; Convert CC into a str comparison result and copy it into an
66 ; integer register
67 ; cc0->0, cc1->1, cc2->-1, (cc3->-1)
68 UNSPEC_STRCMPCC_TO_INT
69
70 ; Copy CC as is into the lower 2 bits of an integer register
71 UNSPEC_CC_TO_INT
72
73 ; GOT/PLT and lt-relative accesses
74 UNSPEC_LTREL_OFFSET
75 UNSPEC_LTREL_BASE
76 UNSPEC_POOL_OFFSET
77 UNSPEC_GOTENT
78 UNSPEC_GOT
79 UNSPEC_GOTOFF
80 UNSPEC_PLT
81 UNSPEC_PLTOFF
82
83 ; Literal pool
84 UNSPEC_RELOAD_BASE
85 UNSPEC_MAIN_BASE
86 UNSPEC_LTREF
87 UNSPEC_INSN
88 UNSPEC_EXECUTE
89
90 ; Atomic Support
91 UNSPEC_MB
92 UNSPEC_MOVA
93
94 ; TLS relocation specifiers
95 UNSPEC_TLSGD
96 UNSPEC_TLSLDM
97 UNSPEC_NTPOFF
98 UNSPEC_DTPOFF
99 UNSPEC_GOTNTPOFF
100 UNSPEC_INDNTPOFF
101
102 ; TLS support
103 UNSPEC_TLSLDM_NTPOFF
104 UNSPEC_TLS_LOAD
105
106 ; String Functions
107 UNSPEC_SRST
108 UNSPEC_MVST
109
110 ; Stack Smashing Protector
111 UNSPEC_SP_SET
112 UNSPEC_SP_TEST
113
114 ; Test Data Class (TDC)
115 UNSPEC_TDC_INSN
116
117 ; Population Count
118 UNSPEC_POPCNT
119 UNSPEC_COPYSIGN
120
121 ; Load FP Integer
122 UNSPEC_FPINT_FLOOR
123 UNSPEC_FPINT_BTRUNC
124 UNSPEC_FPINT_ROUND
125 UNSPEC_FPINT_CEIL
126 UNSPEC_FPINT_NEARBYINT
127 UNSPEC_FPINT_RINT
128 ])
129
130 ;;
131 ;; UNSPEC_VOLATILE usage
132 ;;
133
134 (define_c_enum "unspecv" [
135 ; Blockage
136 UNSPECV_BLOCKAGE
137
138 ; TPF Support
139 UNSPECV_TPF_PROLOGUE
140 UNSPECV_TPF_EPILOGUE
141
142 ; Literal pool
143 UNSPECV_POOL
144 UNSPECV_POOL_SECTION
145 UNSPECV_POOL_ALIGN
146 UNSPECV_POOL_ENTRY
147 UNSPECV_MAIN_POOL
148
149 ; TLS support
150 UNSPECV_SET_TP
151
152 ; Atomic Support
153 UNSPECV_CAS
154 UNSPECV_ATOMIC_OP
155
156 ; Transactional Execution support
157 UNSPECV_TBEGIN
158 UNSPECV_TBEGIN_TDB
159 UNSPECV_TBEGINC
160 UNSPECV_TEND
161 UNSPECV_TABORT
162 UNSPECV_ETND
163 UNSPECV_NTSTG
164 UNSPECV_PPA
165 ])
166
167 ;;
168 ;; Registers
169 ;;
170
171 ; Registers with special meaning
172
173 (define_constants
174 [
175 ; Sibling call register.
176 (SIBCALL_REGNUM 1)
177 ; Literal pool base register.
178 (BASE_REGNUM 13)
179 ; Return address register.
180 (RETURN_REGNUM 14)
181 ; Condition code register.
182 (CC_REGNUM 33)
183 ; Thread local storage pointer register.
184 (TP_REGNUM 36)
185 ])
186
187 ; Hardware register names
188
189 (define_constants
190 [
191 ; General purpose registers
192 (GPR0_REGNUM 0)
193 ; Floating point registers.
194 (FPR0_REGNUM 16)
195 (FPR1_REGNUM 20)
196 (FPR2_REGNUM 17)
197 (FPR3_REGNUM 21)
198 (FPR4_REGNUM 18)
199 (FPR5_REGNUM 22)
200 (FPR6_REGNUM 19)
201 (FPR7_REGNUM 23)
202 (FPR8_REGNUM 24)
203 (FPR9_REGNUM 28)
204 (FPR10_REGNUM 25)
205 (FPR11_REGNUM 29)
206 (FPR12_REGNUM 26)
207 (FPR13_REGNUM 30)
208 (FPR14_REGNUM 27)
209 (FPR15_REGNUM 31)
210 ])
211
212 ;;
213 ;; PFPO GPR0 argument format
214 ;;
215
216 (define_constants
217 [
218 ; PFPO operation type
219 (PFPO_CONVERT 0x1000000)
220 ; PFPO operand types
221 (PFPO_OP_TYPE_SF 0x5)
222 (PFPO_OP_TYPE_DF 0x6)
223 (PFPO_OP_TYPE_TF 0x7)
224 (PFPO_OP_TYPE_SD 0x8)
225 (PFPO_OP_TYPE_DD 0x9)
226 (PFPO_OP_TYPE_TD 0xa)
227 ; Bitposition of operand types
228 (PFPO_OP0_TYPE_SHIFT 16)
229 (PFPO_OP1_TYPE_SHIFT 8)
230 ])
231
232 ; Immediate operands for tbegin and tbeginc
233 (define_constants [(TBEGIN_MASK 65292)]) ; 0xff0c
234 (define_constants [(TBEGINC_MASK 65288)]) ; 0xff08
235
236 ;; Instruction operand type as used in the Principles of Operation.
237 ;; Used to determine defaults for length and other attribute values.
238
239 (define_attr "op_type"
240 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR,SIL,RRS,RIS"
241 (const_string "NN"))
242
243 ;; Instruction type attribute used for scheduling.
244
245 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
246 cs,vs,store,sem,idiv,
247 imulhi,imulsi,imuldi,
248 branch,jsr,fsimptf,fsimpdf,fsimpsf,fhex,
249 floadtf,floaddf,floadsf,fstoredf,fstoresf,
250 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
251 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
252 fmadddf,fmaddsf,
253 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
254 itoftf, itofdf, itofsf, itofdd, itoftd,
255 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
256 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
257 ftoidfp, other"
258 (cond [(eq_attr "op_type" "NN") (const_string "other")
259 (eq_attr "op_type" "SS") (const_string "cs")]
260 (const_string "integer")))
261
262 ;; Another attribute used for scheduling purposes:
263 ;; agen: Instruction uses the address generation unit
264 ;; reg: Instruction does not use the agen unit
265
266 (define_attr "atype" "agen,reg"
267 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF,RRR")
268 (const_string "reg")
269 (const_string "agen")))
270
271 ;; Properties concerning Z10 execution grouping and value forwarding.
272 ;; z10_super: instruction is superscalar.
273 ;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
274 ;; z10_fwd: The instruction reads the value of an operand and stores it into a
275 ;; target register. It can forward this value to a second instruction that reads
276 ;; the same register if that second instruction is issued in the same group.
277 ;; z10_rec: The instruction is in the T pipeline and reads a register. If the
278 ;; instruction in the S pipe writes to the register, then the T instruction
279 ;; can immediately read the new value.
280 ;; z10_fr: union of Z10_fwd and z10_rec.
281 ;; z10_c: second operand of instruction is a register and read with complemented bits.
282 ;;
283 ;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
284
285
286 (define_attr "z10prop" "none,
287 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
288 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
289 z10_rec,
290 z10_fr, z10_fr_A3, z10_fr_E1,
291 z10_c"
292 (const_string "none"))
293
294 ;; Properties concerning Z196 decoding
295 ;; z196_alone: must group alone
296 ;; z196_end: ends a group
297 ;; z196_cracked: instruction is cracked or expanded
298 (define_attr "z196prop" "none,
299 z196_alone, z196_ends,
300 z196_cracked"
301 (const_string "none"))
302
303 (define_attr "mnemonic" "bcr_flush,unknown" (const_string "unknown"))
304
305 ;; Length in bytes.
306
307 (define_attr "length" ""
308 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
309 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF,RRR") (const_int 4)]
310 (const_int 6)))
311
312
313 ;; Processor type. This attribute must exactly match the processor_type
314 ;; enumeration in s390.h. The current machine description does not
315 ;; distinguish between g5 and g6, but there are differences between the two
316 ;; CPUs could in theory be modeled.
317
318 (define_attr "cpu" "g5,g6,z900,z990,z9_109,z9_ec,z10,z196,zEC12"
319 (const (symbol_ref "s390_tune_attr")))
320
321 (define_attr "cpu_facility"
322 "standard,ieee,zarch,cpu_zarch,longdisp,extimm,dfp,z10,z196,zEC12"
323 (const_string "standard"))
324
325 (define_attr "enabled" ""
326 (cond [(eq_attr "cpu_facility" "standard")
327 (const_int 1)
328
329 (and (eq_attr "cpu_facility" "ieee")
330 (match_test "TARGET_CPU_IEEE_FLOAT"))
331 (const_int 1)
332
333 (and (eq_attr "cpu_facility" "zarch")
334 (match_test "TARGET_ZARCH"))
335 (const_int 1)
336
337 (and (eq_attr "cpu_facility" "longdisp")
338 (match_test "TARGET_LONG_DISPLACEMENT"))
339 (const_int 1)
340
341 (and (eq_attr "cpu_facility" "extimm")
342 (match_test "TARGET_EXTIMM"))
343 (const_int 1)
344
345 (and (eq_attr "cpu_facility" "dfp")
346 (match_test "TARGET_DFP"))
347 (const_int 1)
348
349 (and (eq_attr "cpu_facility" "cpu_zarch")
350 (match_test "TARGET_CPU_ZARCH"))
351 (const_int 1)
352
353 (and (eq_attr "cpu_facility" "z10")
354 (match_test "TARGET_Z10"))
355 (const_int 1)
356
357 (and (eq_attr "cpu_facility" "z196")
358 (match_test "TARGET_Z196"))
359 (const_int 1)
360
361 (and (eq_attr "cpu_facility" "zEC12")
362 (match_test "TARGET_ZEC12"))
363 (const_int 1)]
364 (const_int 0)))
365
366 ;; Pipeline description for z900. For lack of anything better,
367 ;; this description is also used for the g5 and g6.
368 (include "2064.md")
369
370 ;; Pipeline description for z990, z9-109 and z9-ec.
371 (include "2084.md")
372
373 ;; Pipeline description for z10
374 (include "2097.md")
375
376 ;; Pipeline description for z196
377 (include "2817.md")
378
379 ;; Pipeline description for zEC12
380 (include "2827.md")
381
382 ;; Predicates
383 (include "predicates.md")
384
385 ;; Constraint definitions
386 (include "constraints.md")
387
388 ;; Other includes
389 (include "tpf.md")
390
391 ;; Iterators
392
393 ;; These mode iterators allow floating point patterns to be generated from the
394 ;; same template.
395 (define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
396 (SD "TARGET_HARD_DFP")])
397 (define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
398 (define_mode_iterator FPALL [TF DF SF TD DD SD])
399 (define_mode_iterator BFP [TF DF SF])
400 (define_mode_iterator DFP [TD DD])
401 (define_mode_iterator DFP_ALL [TD DD SD])
402 (define_mode_iterator DSF [DF SF])
403 (define_mode_iterator SD_SF [SF SD])
404 (define_mode_iterator DD_DF [DF DD])
405 (define_mode_iterator TD_TF [TF TD])
406
407 ;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
408 ;; from the same template.
409 (define_mode_iterator GPR [(DI "TARGET_ZARCH") SI])
410 (define_mode_iterator DGPR [(TI "TARGET_ZARCH") DI SI])
411 (define_mode_iterator DSI [DI SI])
412 (define_mode_iterator TDI [TI DI])
413
414 ;; These mode iterators allow :P to be used for patterns that operate on
415 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
416 (define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
417
418 ;; These macros refer to the actual word_mode of the configuration.
419 ;; This is equal to Pmode except on 31-bit machines in zarch mode.
420 (define_mode_iterator DW [(TI "TARGET_ZARCH") (DI "!TARGET_ZARCH")])
421 (define_mode_iterator W [(DI "TARGET_ZARCH") (SI "!TARGET_ZARCH")])
422
423 ;; Used by the umul pattern to express modes having half the size.
424 (define_mode_attr DWH [(TI "DI") (DI "SI")])
425 (define_mode_attr dwh [(TI "di") (DI "si")])
426
427 ;; This mode iterator allows the QI and HI patterns to be defined from
428 ;; the same template.
429 (define_mode_iterator HQI [HI QI])
430
431 ;; This mode iterator allows the integer patterns to be defined from the
432 ;; same template.
433 (define_mode_iterator INT [(DI "TARGET_ZARCH") SI HI QI])
434 (define_mode_iterator INTALL [TI DI SI HI QI])
435 (define_mode_iterator DINT [(TI "TARGET_ZARCH") DI SI HI QI])
436
437 ;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
438 ;; the same template.
439 (define_code_iterator SHIFT [ashift lshiftrt])
440
441 ;; This iterator allows r[ox]sbg to be defined with the same template
442 (define_code_iterator IXOR [ior xor])
443
444 ;; This iterator is used to expand the patterns for the nearest
445 ;; integer functions.
446 (define_int_iterator FPINT [UNSPEC_FPINT_FLOOR UNSPEC_FPINT_BTRUNC
447 UNSPEC_FPINT_ROUND UNSPEC_FPINT_CEIL
448 UNSPEC_FPINT_NEARBYINT])
449 (define_int_attr fpint_name [(UNSPEC_FPINT_FLOOR "floor")
450 (UNSPEC_FPINT_BTRUNC "btrunc")
451 (UNSPEC_FPINT_ROUND "round")
452 (UNSPEC_FPINT_CEIL "ceil")
453 (UNSPEC_FPINT_NEARBYINT "nearbyint")])
454 (define_int_attr fpint_roundingmode [(UNSPEC_FPINT_FLOOR "7")
455 (UNSPEC_FPINT_BTRUNC "5")
456 (UNSPEC_FPINT_ROUND "1")
457 (UNSPEC_FPINT_CEIL "6")
458 (UNSPEC_FPINT_NEARBYINT "0")])
459
460 ;; This iterator and attribute allow to combine most atomic operations.
461 (define_code_iterator ATOMIC [and ior xor plus minus mult])
462 (define_code_iterator ATOMIC_Z196 [and ior xor plus])
463 (define_code_attr atomic [(and "and") (ior "ior") (xor "xor")
464 (plus "add") (minus "sub") (mult "nand")])
465 (define_code_attr noxa [(and "n") (ior "o") (xor "x") (plus "a")])
466
467 ;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
468 ;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
469 (define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
470
471 ;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
472 ;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
473 ;; SDmode.
474 (define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
475
476 ;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
477 ;; Likewise for "<RXe>".
478 (define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
479 (define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
480
481 ;; The decimal floating point variants of add, sub, div and mul support 3
482 ;; fp register operands. The following attributes allow to merge the bfp and
483 ;; dfp variants in a single insn definition.
484
485 ;; This attribute is used to set op_type accordingly.
486 (define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
487 (DD "RRR") (SD "RRR")])
488
489 ;; This attribute is used in the operand constraint list in order to have the
490 ;; first and the second operand match for bfp modes.
491 (define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
492
493 ;; This attribute is used in the operand list of the instruction to have an
494 ;; additional operand for the dfp instructions.
495 (define_mode_attr op1 [(TF "") (DF "") (SF "")
496 (TD "%1,") (DD "%1,") (SD "%1,")])
497
498
499 ;; This attribute is used in the operand constraint list
500 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
501 ;; TFmode values are represented by a fp register pair. Since the
502 ;; sign bit instructions only handle single source and target fp registers
503 ;; these instructions can only be used for TFmode values if the source and
504 ;; target operand uses the same fp register.
505 (define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
506
507 ;; In FP templates, "<Rf>" will expand to "f" in TFmode and "R" otherwise.
508 ;; This is used to disable the memory alternative in TFmode patterns.
509 (define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
510
511 ;; This attribute adds b for bfp instructions and t for dfp instructions and is used
512 ;; within instruction mnemonics.
513 (define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
514
515 ;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
516 ;; modes and to an empty string for bfp modes.
517 (define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
518
519 ;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
520 ;; and "0" in SImode. This allows to combine instructions of which the 31bit
521 ;; version only operates on one register.
522 (define_mode_attr d0 [(DI "d") (SI "0")])
523
524 ;; In combination with d0 this allows to combine instructions of which the 31bit
525 ;; version only operates on one register. The DImode version needs an additional
526 ;; register for the assembler output.
527 (define_mode_attr 1 [(DI "%1,") (SI "")])
528
529 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
530 ;; 'ashift' and "srdl" in 'lshiftrt'.
531 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
532
533 ;; In SHIFT templates, this attribute holds the correct standard name for the
534 ;; pattern itself and the corresponding function calls.
535 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
536
537 ;; This attribute handles differences in the instruction 'type' and will result
538 ;; in "RRE" for DImode and "RR" for SImode.
539 (define_mode_attr E [(DI "E") (SI "")])
540
541 ;; This attribute handles differences in the instruction 'type' and makes RX<Y>
542 ;; to result in "RXY" for DImode and "RX" for SImode.
543 (define_mode_attr Y [(DI "Y") (SI "")])
544
545 ;; This attribute handles differences in the instruction 'type' and will result
546 ;; in "RSE" for TImode and "RS" for DImode.
547 (define_mode_attr TE [(TI "E") (DI "")])
548
549 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
550 ;; and "lcr" in SImode.
551 (define_mode_attr g [(DI "g") (SI "")])
552
553 ;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
554 ;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
555 ;; were enhanced with long displacements whereas 31bit instructions got a ..y
556 ;; variant for long displacements.
557 (define_mode_attr y [(DI "g") (SI "y")])
558
559 ;; In DW templates, a string like "cds<g>" will expand to "cdsg" in TImode
560 ;; and "cds" in DImode.
561 (define_mode_attr tg [(TI "g") (DI "")])
562
563 ;; In TDI templates, a string like "c<d>sg".
564 (define_mode_attr td [(TI "d") (DI "")])
565
566 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
567 ;; and "cfdbr" in SImode.
568 (define_mode_attr gf [(DI "g") (SI "f")])
569
570 ;; In GPR templates, a string like sll<gk> will expand to sllg for DI
571 ;; and sllk for SI. This way it is possible to merge the new z196 SI
572 ;; 3 operands shift instructions into the existing patterns.
573 (define_mode_attr gk [(DI "g") (SI "k")])
574
575 ;; ICM mask required to load MODE value into the lowest subreg
576 ;; of a SImode register.
577 (define_mode_attr icm_lo [(HI "3") (QI "1")])
578
579 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
580 ;; HImode and "llgc" in QImode.
581 (define_mode_attr hc [(HI "h") (QI "c")])
582
583 ;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
584 ;; in SImode.
585 (define_mode_attr DBL [(DI "TI") (SI "DI")])
586
587 ;; This attribute expands to DF for TFmode and to DD for TDmode . It is
588 ;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
589 (define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
590
591 ;; Maximum unsigned integer that fits in MODE.
592 (define_mode_attr max_uint [(HI "65535") (QI "255")])
593
594 ;; Start and end field computations for RISBG et al.
595 (define_mode_attr bfstart [(DI "s") (SI "t")])
596 (define_mode_attr bfend [(DI "e") (SI "f")])
597
598 ;; In place of GET_MODE_BITSIZE (<MODE>mode)
599 (define_mode_attr bitsize [(DI "64") (SI "32") (HI "16") (QI "8")])
600
601 ;; Allow return and simple_return to be defined from a single template.
602 (define_code_iterator ANY_RETURN [return simple_return])
603
604 ;;
605 ;;- Compare instructions.
606 ;;
607
608 ; Test-under-Mask instructions
609
610 (define_insn "*tmqi_mem"
611 [(set (reg CC_REGNUM)
612 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
613 (match_operand:QI 1 "immediate_operand" "n,n"))
614 (match_operand:QI 2 "immediate_operand" "n,n")))]
615 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
616 "@
617 tm\t%S0,%b1
618 tmy\t%S0,%b1"
619 [(set_attr "op_type" "SI,SIY")
620 (set_attr "z10prop" "z10_super,z10_super")])
621
622 (define_insn "*tmdi_reg"
623 [(set (reg CC_REGNUM)
624 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
625 (match_operand:DI 1 "immediate_operand"
626 "N0HD0,N1HD0,N2HD0,N3HD0"))
627 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
628 "TARGET_ZARCH
629 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
630 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
631 "@
632 tmhh\t%0,%i1
633 tmhl\t%0,%i1
634 tmlh\t%0,%i1
635 tmll\t%0,%i1"
636 [(set_attr "op_type" "RI")
637 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
638
639 (define_insn "*tmsi_reg"
640 [(set (reg CC_REGNUM)
641 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
642 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
643 (match_operand:SI 2 "immediate_operand" "n,n")))]
644 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
645 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
646 "@
647 tmh\t%0,%i1
648 tml\t%0,%i1"
649 [(set_attr "op_type" "RI")
650 (set_attr "z10prop" "z10_super,z10_super")])
651
652 (define_insn "*tm<mode>_full"
653 [(set (reg CC_REGNUM)
654 (compare (match_operand:HQI 0 "register_operand" "d")
655 (match_operand:HQI 1 "immediate_operand" "n")))]
656 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
657 "tml\t%0,<max_uint>"
658 [(set_attr "op_type" "RI")
659 (set_attr "z10prop" "z10_super")])
660
661
662 ;
663 ; Load-and-Test instructions
664 ;
665
666 ; tst(di|si) instruction pattern(s).
667
668 (define_insn "*tstdi_sign"
669 [(set (reg CC_REGNUM)
670 (compare
671 (ashiftrt:DI
672 (ashift:DI
673 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,RT") 0)
674 (const_int 32)) (const_int 32))
675 (match_operand:DI 1 "const0_operand" "")))
676 (set (match_operand:DI 2 "register_operand" "=d,d")
677 (sign_extend:DI (match_dup 0)))]
678 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH"
679 "ltgfr\t%2,%0
680 ltgf\t%2,%0"
681 [(set_attr "op_type" "RRE,RXY")
682 (set_attr "cpu_facility" "*,z10")
683 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
684
685 ; ltr, lt, ltgr, ltg
686 (define_insn "*tst<mode>_extimm"
687 [(set (reg CC_REGNUM)
688 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
689 (match_operand:GPR 1 "const0_operand" "")))
690 (set (match_operand:GPR 2 "register_operand" "=d,d")
691 (match_dup 0))]
692 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
693 "@
694 lt<g>r\t%2,%0
695 lt<g>\t%2,%0"
696 [(set_attr "op_type" "RR<E>,RXY")
697 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
698
699 ; ltr, lt, ltgr, ltg
700 (define_insn "*tst<mode>_cconly_extimm"
701 [(set (reg CC_REGNUM)
702 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
703 (match_operand:GPR 1 "const0_operand" "")))
704 (clobber (match_scratch:GPR 2 "=X,d"))]
705 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
706 "@
707 lt<g>r\t%0,%0
708 lt<g>\t%2,%0"
709 [(set_attr "op_type" "RR<E>,RXY")
710 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
711
712 (define_insn "*tstdi"
713 [(set (reg CC_REGNUM)
714 (compare (match_operand:DI 0 "register_operand" "d")
715 (match_operand:DI 1 "const0_operand" "")))
716 (set (match_operand:DI 2 "register_operand" "=d")
717 (match_dup 0))]
718 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH && !TARGET_EXTIMM"
719 "ltgr\t%2,%0"
720 [(set_attr "op_type" "RRE")
721 (set_attr "z10prop" "z10_fr_E1")])
722
723 (define_insn "*tstsi"
724 [(set (reg CC_REGNUM)
725 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
726 (match_operand:SI 1 "const0_operand" "")))
727 (set (match_operand:SI 2 "register_operand" "=d,d,d")
728 (match_dup 0))]
729 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
730 "@
731 ltr\t%2,%0
732 icm\t%2,15,%S0
733 icmy\t%2,15,%S0"
734 [(set_attr "op_type" "RR,RS,RSY")
735 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
736
737 (define_insn "*tstsi_cconly"
738 [(set (reg CC_REGNUM)
739 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
740 (match_operand:SI 1 "const0_operand" "")))
741 (clobber (match_scratch:SI 2 "=X,d,d"))]
742 "s390_match_ccmode(insn, CCSmode)"
743 "@
744 ltr\t%0,%0
745 icm\t%2,15,%S0
746 icmy\t%2,15,%S0"
747 [(set_attr "op_type" "RR,RS,RSY")
748 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
749
750 (define_insn "*tstdi_cconly_31"
751 [(set (reg CC_REGNUM)
752 (compare (match_operand:DI 0 "register_operand" "d")
753 (match_operand:DI 1 "const0_operand" "")))]
754 "s390_match_ccmode(insn, CCSmode) && !TARGET_ZARCH"
755 "srda\t%0,0"
756 [(set_attr "op_type" "RS")
757 (set_attr "atype" "reg")])
758
759 ; ltr, ltgr
760 (define_insn "*tst<mode>_cconly2"
761 [(set (reg CC_REGNUM)
762 (compare (match_operand:GPR 0 "register_operand" "d")
763 (match_operand:GPR 1 "const0_operand" "")))]
764 "s390_match_ccmode(insn, CCSmode)"
765 "lt<g>r\t%0,%0"
766 [(set_attr "op_type" "RR<E>")
767 (set_attr "z10prop" "z10_fr_E1")])
768
769 ; tst(hi|qi) instruction pattern(s).
770
771 (define_insn "*tst<mode>CCT"
772 [(set (reg CC_REGNUM)
773 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
774 (match_operand:HQI 1 "const0_operand" "")))
775 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
776 (match_dup 0))]
777 "s390_match_ccmode(insn, CCTmode)"
778 "@
779 icm\t%2,<icm_lo>,%S0
780 icmy\t%2,<icm_lo>,%S0
781 tml\t%0,<max_uint>"
782 [(set_attr "op_type" "RS,RSY,RI")
783 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
784
785 (define_insn "*tsthiCCT_cconly"
786 [(set (reg CC_REGNUM)
787 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
788 (match_operand:HI 1 "const0_operand" "")))
789 (clobber (match_scratch:HI 2 "=d,d,X"))]
790 "s390_match_ccmode(insn, CCTmode)"
791 "@
792 icm\t%2,3,%S0
793 icmy\t%2,3,%S0
794 tml\t%0,65535"
795 [(set_attr "op_type" "RS,RSY,RI")
796 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
797
798 (define_insn "*tstqiCCT_cconly"
799 [(set (reg CC_REGNUM)
800 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
801 (match_operand:QI 1 "const0_operand" "")))]
802 "s390_match_ccmode(insn, CCTmode)"
803 "@
804 cli\t%S0,0
805 cliy\t%S0,0
806 tml\t%0,255"
807 [(set_attr "op_type" "SI,SIY,RI")
808 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
809
810 (define_insn "*tst<mode>"
811 [(set (reg CC_REGNUM)
812 (compare (match_operand:HQI 0 "s_operand" "Q,S")
813 (match_operand:HQI 1 "const0_operand" "")))
814 (set (match_operand:HQI 2 "register_operand" "=d,d")
815 (match_dup 0))]
816 "s390_match_ccmode(insn, CCSmode)"
817 "@
818 icm\t%2,<icm_lo>,%S0
819 icmy\t%2,<icm_lo>,%S0"
820 [(set_attr "op_type" "RS,RSY")
821 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
822
823 (define_insn "*tst<mode>_cconly"
824 [(set (reg CC_REGNUM)
825 (compare (match_operand:HQI 0 "s_operand" "Q,S")
826 (match_operand:HQI 1 "const0_operand" "")))
827 (clobber (match_scratch:HQI 2 "=d,d"))]
828 "s390_match_ccmode(insn, CCSmode)"
829 "@
830 icm\t%2,<icm_lo>,%S0
831 icmy\t%2,<icm_lo>,%S0"
832 [(set_attr "op_type" "RS,RSY")
833 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
834
835
836 ; Compare (equality) instructions
837
838 (define_insn "*cmpdi_cct"
839 [(set (reg CC_REGNUM)
840 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
841 (match_operand:DI 1 "general_operand" "d,K,Os,RT,BQ")))]
842 "s390_match_ccmode (insn, CCTmode) && TARGET_ZARCH"
843 "@
844 cgr\t%0,%1
845 cghi\t%0,%h1
846 cgfi\t%0,%1
847 cg\t%0,%1
848 #"
849 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
850 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
851
852 (define_insn "*cmpsi_cct"
853 [(set (reg CC_REGNUM)
854 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
855 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
856 "s390_match_ccmode (insn, CCTmode)"
857 "@
858 cr\t%0,%1
859 chi\t%0,%h1
860 cfi\t%0,%1
861 c\t%0,%1
862 cy\t%0,%1
863 #"
864 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
865 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*")])
866
867 ; Compare (signed) instructions
868
869 (define_insn "*cmpdi_ccs_sign"
870 [(set (reg CC_REGNUM)
871 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
872 "d,RT,b"))
873 (match_operand:DI 0 "register_operand" "d, d,d")))]
874 "s390_match_ccmode(insn, CCSRmode) && TARGET_ZARCH"
875 "@
876 cgfr\t%0,%1
877 cgf\t%0,%1
878 cgfrl\t%0,%1"
879 [(set_attr "op_type" "RRE,RXY,RIL")
880 (set_attr "z10prop" "z10_c,*,*")
881 (set_attr "type" "*,*,larl")])
882
883
884
885 (define_insn "*cmpsi_ccs_sign"
886 [(set (reg CC_REGNUM)
887 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
888 (match_operand:SI 0 "register_operand" "d,d,d")))]
889 "s390_match_ccmode(insn, CCSRmode)"
890 "@
891 ch\t%0,%1
892 chy\t%0,%1
893 chrl\t%0,%1"
894 [(set_attr "op_type" "RX,RXY,RIL")
895 (set_attr "cpu_facility" "*,*,z10")
896 (set_attr "type" "*,*,larl")
897 (set_attr "z196prop" "z196_cracked,z196_cracked,z196_cracked")])
898
899 (define_insn "*cmphi_ccs_z10"
900 [(set (reg CC_REGNUM)
901 (compare (match_operand:HI 0 "s_operand" "Q")
902 (match_operand:HI 1 "immediate_operand" "K")))]
903 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
904 "chhsi\t%0,%1"
905 [(set_attr "op_type" "SIL")
906 (set_attr "z196prop" "z196_cracked")])
907
908 (define_insn "*cmpdi_ccs_signhi_rl"
909 [(set (reg CC_REGNUM)
910 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT,b"))
911 (match_operand:GPR 0 "register_operand" "d,d")))]
912 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
913 "@
914 cgh\t%0,%1
915 cghrl\t%0,%1"
916 [(set_attr "op_type" "RXY,RIL")
917 (set_attr "type" "*,larl")])
918
919 ; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
920 (define_insn "*cmp<mode>_ccs"
921 [(set (reg CC_REGNUM)
922 (compare (match_operand:GPR 0 "nonimmediate_operand"
923 "d,d,Q, d,d,d,d")
924 (match_operand:GPR 1 "general_operand"
925 "d,K,K,Os,R,T,b")))]
926 "s390_match_ccmode(insn, CCSmode)"
927 "@
928 c<g>r\t%0,%1
929 c<g>hi\t%0,%h1
930 c<g>hsi\t%0,%h1
931 c<g>fi\t%0,%1
932 c<g>\t%0,%1
933 c<y>\t%0,%1
934 c<g>rl\t%0,%1"
935 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
936 (set_attr "cpu_facility" "*,*,z10,extimm,*,*,z10")
937 (set_attr "type" "*,*,*,*,*,*,larl")
938 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
939
940
941 ; Compare (unsigned) instructions
942
943 (define_insn "*cmpsi_ccu_zerohi_rlsi"
944 [(set (reg CC_REGNUM)
945 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
946 "larl_operand" "X")))
947 (match_operand:SI 0 "register_operand" "d")))]
948 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
949 "clhrl\t%0,%1"
950 [(set_attr "op_type" "RIL")
951 (set_attr "type" "larl")
952 (set_attr "z10prop" "z10_super")])
953
954 ; clhrl, clghrl
955 (define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
956 [(set (reg CC_REGNUM)
957 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
958 "larl_operand" "X")))
959 (match_operand:GPR 0 "register_operand" "d")))]
960 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
961 "cl<g>hrl\t%0,%1"
962 [(set_attr "op_type" "RIL")
963 (set_attr "type" "larl")
964 (set_attr "z10prop" "z10_super")])
965
966 (define_insn "*cmpdi_ccu_zero"
967 [(set (reg CC_REGNUM)
968 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
969 "d,RT,b"))
970 (match_operand:DI 0 "register_operand" "d, d,d")))]
971 "s390_match_ccmode (insn, CCURmode) && TARGET_ZARCH"
972 "@
973 clgfr\t%0,%1
974 clgf\t%0,%1
975 clgfrl\t%0,%1"
976 [(set_attr "op_type" "RRE,RXY,RIL")
977 (set_attr "cpu_facility" "*,*,z10")
978 (set_attr "type" "*,*,larl")
979 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
980
981 (define_insn "*cmpdi_ccu"
982 [(set (reg CC_REGNUM)
983 (compare (match_operand:DI 0 "nonimmediate_operand"
984 "d, d,d,Q, d, Q,BQ")
985 (match_operand:DI 1 "general_operand"
986 "d,Op,b,D,RT,BQ,Q")))]
987 "s390_match_ccmode (insn, CCUmode) && TARGET_ZARCH"
988 "@
989 clgr\t%0,%1
990 clgfi\t%0,%1
991 clgrl\t%0,%1
992 clghsi\t%0,%x1
993 clg\t%0,%1
994 #
995 #"
996 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
997 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
998 (set_attr "type" "*,*,larl,*,*,*,*")
999 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
1000
1001 (define_insn "*cmpsi_ccu"
1002 [(set (reg CC_REGNUM)
1003 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
1004 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
1005 "s390_match_ccmode (insn, CCUmode)"
1006 "@
1007 clr\t%0,%1
1008 clfi\t%0,%o1
1009 clrl\t%0,%1
1010 clfhsi\t%0,%x1
1011 cl\t%0,%1
1012 cly\t%0,%1
1013 #
1014 #"
1015 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
1016 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*,*")
1017 (set_attr "type" "*,*,larl,*,*,*,*,*")
1018 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
1019
1020 (define_insn "*cmphi_ccu"
1021 [(set (reg CC_REGNUM)
1022 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
1023 (match_operand:HI 1 "general_operand" "Q,S,D,BQ,Q")))]
1024 "s390_match_ccmode (insn, CCUmode)
1025 && !register_operand (operands[1], HImode)"
1026 "@
1027 clm\t%0,3,%S1
1028 clmy\t%0,3,%S1
1029 clhhsi\t%0,%1
1030 #
1031 #"
1032 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
1033 (set_attr "cpu_facility" "*,*,z10,*,*")
1034 (set_attr "z10prop" "*,*,z10_super,*,*")])
1035
1036 (define_insn "*cmpqi_ccu"
1037 [(set (reg CC_REGNUM)
1038 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
1039 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
1040 "s390_match_ccmode (insn, CCUmode)
1041 && !register_operand (operands[1], QImode)"
1042 "@
1043 clm\t%0,1,%S1
1044 clmy\t%0,1,%S1
1045 cli\t%S0,%b1
1046 cliy\t%S0,%b1
1047 #
1048 #"
1049 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
1050 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
1051
1052
1053 ; Block compare (CLC) instruction patterns.
1054
1055 (define_insn "*clc"
1056 [(set (reg CC_REGNUM)
1057 (compare (match_operand:BLK 0 "memory_operand" "Q")
1058 (match_operand:BLK 1 "memory_operand" "Q")))
1059 (use (match_operand 2 "const_int_operand" "n"))]
1060 "s390_match_ccmode (insn, CCUmode)
1061 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1062 "clc\t%O0(%2,%R0),%S1"
1063 [(set_attr "op_type" "SS")])
1064
1065 (define_split
1066 [(set (reg CC_REGNUM)
1067 (compare (match_operand 0 "memory_operand" "")
1068 (match_operand 1 "memory_operand" "")))]
1069 "reload_completed
1070 && s390_match_ccmode (insn, CCUmode)
1071 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1072 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1073 [(parallel
1074 [(set (match_dup 0) (match_dup 1))
1075 (use (match_dup 2))])]
1076 {
1077 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1078 operands[0] = adjust_address (operands[0], BLKmode, 0);
1079 operands[1] = adjust_address (operands[1], BLKmode, 0);
1080
1081 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
1082 operands[0], operands[1]);
1083 operands[0] = SET_DEST (PATTERN (curr_insn));
1084 })
1085
1086
1087 ; (TF|DF|SF|TD|DD|SD) instructions
1088
1089 ; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
1090 (define_insn "*cmp<mode>_ccs_0"
1091 [(set (reg CC_REGNUM)
1092 (compare (match_operand:FP 0 "register_operand" "f")
1093 (match_operand:FP 1 "const0_operand" "")))]
1094 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1095 "lt<xde><bt>r\t%0,%0"
1096 [(set_attr "op_type" "RRE")
1097 (set_attr "type" "fsimp<mode>")])
1098
1099 ; cxtr, cxbr, cdtr, cdbr, cebr, cdb, ceb
1100 (define_insn "*cmp<mode>_ccs"
1101 [(set (reg CC_REGNUM)
1102 (compare (match_operand:FP 0 "register_operand" "f,f")
1103 (match_operand:FP 1 "general_operand" "f,<Rf>")))]
1104 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1105 "@
1106 c<xde><bt>r\t%0,%1
1107 c<xde>b\t%0,%1"
1108 [(set_attr "op_type" "RRE,RXE")
1109 (set_attr "type" "fsimp<mode>")])
1110
1111
1112 ; Compare and Branch instructions
1113
1114 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1115 ; The following instructions do a complementary access of their second
1116 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1117 (define_insn "*cmp_and_br_signed_<mode>"
1118 [(set (pc)
1119 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1120 [(match_operand:GPR 1 "register_operand" "d,d")
1121 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1122 (label_ref (match_operand 3 "" ""))
1123 (pc)))
1124 (clobber (reg:CC CC_REGNUM))]
1125 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1126 {
1127 if (get_attr_length (insn) == 6)
1128 return which_alternative ?
1129 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1130 else
1131 return which_alternative ?
1132 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1133 }
1134 [(set_attr "op_type" "RIE")
1135 (set_attr "type" "branch")
1136 (set_attr "z10prop" "z10_super_c,z10_super")
1137 (set (attr "length")
1138 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1139 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1140 ; 10 byte for cgr/jg
1141
1142 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1143 ; The following instructions do a complementary access of their second
1144 ; operand (z10 only): clrj, clgrj, clr, clgr
1145 (define_insn "*cmp_and_br_unsigned_<mode>"
1146 [(set (pc)
1147 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1148 [(match_operand:GPR 1 "register_operand" "d,d")
1149 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1150 (label_ref (match_operand 3 "" ""))
1151 (pc)))
1152 (clobber (reg:CC CC_REGNUM))]
1153 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1154 {
1155 if (get_attr_length (insn) == 6)
1156 return which_alternative ?
1157 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1158 else
1159 return which_alternative ?
1160 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1161 }
1162 [(set_attr "op_type" "RIE")
1163 (set_attr "type" "branch")
1164 (set_attr "z10prop" "z10_super_c,z10_super")
1165 (set (attr "length")
1166 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1167 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1168 ; 10 byte for clgr/jg
1169
1170 ; And now the same two patterns as above but with a negated CC mask.
1171
1172 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1173 ; The following instructions do a complementary access of their second
1174 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1175 (define_insn "*icmp_and_br_signed_<mode>"
1176 [(set (pc)
1177 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1178 [(match_operand:GPR 1 "register_operand" "d,d")
1179 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1180 (pc)
1181 (label_ref (match_operand 3 "" ""))))
1182 (clobber (reg:CC CC_REGNUM))]
1183 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1184 {
1185 if (get_attr_length (insn) == 6)
1186 return which_alternative ?
1187 "c<g>ij%D0\t%1,%c2,%l3" : "c<g>rj%D0\t%1,%2,%l3";
1188 else
1189 return which_alternative ?
1190 "c<g>fi\t%1,%c2\;jg%D0\t%l3" : "c<g>r\t%1,%2\;jg%D0\t%l3";
1191 }
1192 [(set_attr "op_type" "RIE")
1193 (set_attr "type" "branch")
1194 (set_attr "z10prop" "z10_super_c,z10_super")
1195 (set (attr "length")
1196 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1197 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1198 ; 10 byte for cgr/jg
1199
1200 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1201 ; The following instructions do a complementary access of their second
1202 ; operand (z10 only): clrj, clgrj, clr, clgr
1203 (define_insn "*icmp_and_br_unsigned_<mode>"
1204 [(set (pc)
1205 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1206 [(match_operand:GPR 1 "register_operand" "d,d")
1207 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1208 (pc)
1209 (label_ref (match_operand 3 "" ""))))
1210 (clobber (reg:CC CC_REGNUM))]
1211 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1212 {
1213 if (get_attr_length (insn) == 6)
1214 return which_alternative ?
1215 "cl<g>ij%D0\t%1,%b2,%l3" : "cl<g>rj%D0\t%1,%2,%l3";
1216 else
1217 return which_alternative ?
1218 "cl<g>fi\t%1,%b2\;jg%D0\t%l3" : "cl<g>r\t%1,%2\;jg%D0\t%l3";
1219 }
1220 [(set_attr "op_type" "RIE")
1221 (set_attr "type" "branch")
1222 (set_attr "z10prop" "z10_super_c,z10_super")
1223 (set (attr "length")
1224 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1225 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1226 ; 10 byte for clgr/jg
1227
1228 ;;
1229 ;;- Move instructions.
1230 ;;
1231
1232 ;
1233 ; movti instruction pattern(s).
1234 ;
1235
1236 (define_insn "movti"
1237 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o")
1238 (match_operand:TI 1 "general_operand" "QS,d,dPRT,d"))]
1239 "TARGET_ZARCH"
1240 "@
1241 lmg\t%0,%N0,%S1
1242 stmg\t%1,%N1,%S0
1243 #
1244 #"
1245 [(set_attr "op_type" "RSY,RSY,*,*")
1246 (set_attr "type" "lm,stm,*,*")])
1247
1248 (define_split
1249 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1250 (match_operand:TI 1 "general_operand" ""))]
1251 "TARGET_ZARCH && reload_completed
1252 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
1253 [(set (match_dup 2) (match_dup 4))
1254 (set (match_dup 3) (match_dup 5))]
1255 {
1256 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1257 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1258 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1259 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1260 })
1261
1262 (define_split
1263 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1264 (match_operand:TI 1 "general_operand" ""))]
1265 "TARGET_ZARCH && reload_completed
1266 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1267 [(set (match_dup 2) (match_dup 4))
1268 (set (match_dup 3) (match_dup 5))]
1269 {
1270 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1271 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1272 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1273 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1274 })
1275
1276 (define_split
1277 [(set (match_operand:TI 0 "register_operand" "")
1278 (match_operand:TI 1 "memory_operand" ""))]
1279 "TARGET_ZARCH && reload_completed
1280 && !s_operand (operands[1], VOIDmode)"
1281 [(set (match_dup 0) (match_dup 1))]
1282 {
1283 rtx addr = operand_subword (operands[0], 1, 0, TImode);
1284 addr = gen_lowpart (Pmode, addr);
1285 s390_load_address (addr, XEXP (operands[1], 0));
1286 operands[1] = replace_equiv_address (operands[1], addr);
1287 })
1288
1289
1290 ;
1291 ; Patterns used for secondary reloads
1292 ;
1293
1294 ; z10 provides move instructions accepting larl memory operands.
1295 ; Unfortunately there is no such variant for QI, TI and FP mode moves.
1296 ; These patterns are also used for unaligned SI and DI accesses.
1297
1298 (define_expand "reload<INTALL:mode><P:mode>_tomem_z10"
1299 [(parallel [(match_operand:INTALL 0 "memory_operand" "")
1300 (match_operand:INTALL 1 "register_operand" "=d")
1301 (match_operand:P 2 "register_operand" "=&a")])]
1302 "TARGET_Z10"
1303 {
1304 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1305 DONE;
1306 })
1307
1308 (define_expand "reload<INTALL:mode><P:mode>_toreg_z10"
1309 [(parallel [(match_operand:INTALL 0 "register_operand" "=d")
1310 (match_operand:INTALL 1 "memory_operand" "")
1311 (match_operand:P 2 "register_operand" "=a")])]
1312 "TARGET_Z10"
1313 {
1314 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1315 DONE;
1316 })
1317
1318 (define_expand "reload<FPALL:mode><P:mode>_tomem_z10"
1319 [(parallel [(match_operand:FPALL 0 "memory_operand" "")
1320 (match_operand:FPALL 1 "register_operand" "=d")
1321 (match_operand:P 2 "register_operand" "=&a")])]
1322 "TARGET_Z10"
1323 {
1324 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1325 DONE;
1326 })
1327
1328 (define_expand "reload<FPALL:mode><P:mode>_toreg_z10"
1329 [(parallel [(match_operand:FPALL 0 "register_operand" "=d")
1330 (match_operand:FPALL 1 "memory_operand" "")
1331 (match_operand:P 2 "register_operand" "=a")])]
1332 "TARGET_Z10"
1333 {
1334 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1335 DONE;
1336 })
1337
1338 (define_expand "reload<P:mode>_larl_odd_addend_z10"
1339 [(parallel [(match_operand:P 0 "register_operand" "=d")
1340 (match_operand:P 1 "larl_operand" "")
1341 (match_operand:P 2 "register_operand" "=a")])]
1342 "TARGET_Z10"
1343 {
1344 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1345 DONE;
1346 })
1347
1348 ; Handles loading a PLUS (load address) expression
1349
1350 (define_expand "reload<mode>_plus"
1351 [(parallel [(match_operand:P 0 "register_operand" "=a")
1352 (match_operand:P 1 "s390_plus_operand" "")
1353 (match_operand:P 2 "register_operand" "=&a")])]
1354 ""
1355 {
1356 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1357 DONE;
1358 })
1359
1360 ; Handles assessing a non-offsetable memory address
1361
1362 (define_expand "reload<mode>_nonoffmem_in"
1363 [(parallel [(match_operand 0 "register_operand" "")
1364 (match_operand 1 "" "")
1365 (match_operand:P 2 "register_operand" "=&a")])]
1366 ""
1367 {
1368 gcc_assert (MEM_P (operands[1]));
1369 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1370 operands[1] = replace_equiv_address (operands[1], operands[2]);
1371 emit_move_insn (operands[0], operands[1]);
1372 DONE;
1373 })
1374
1375 (define_expand "reload<mode>_nonoffmem_out"
1376 [(parallel [(match_operand 0 "" "")
1377 (match_operand 1 "register_operand" "")
1378 (match_operand:P 2 "register_operand" "=&a")])]
1379 ""
1380 {
1381 gcc_assert (MEM_P (operands[0]));
1382 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1383 operands[0] = replace_equiv_address (operands[0], operands[2]);
1384 emit_move_insn (operands[0], operands[1]);
1385 DONE;
1386 })
1387
1388 (define_expand "reload<mode>_PIC_addr"
1389 [(parallel [(match_operand 0 "register_operand" "=d")
1390 (match_operand 1 "larl_operand" "")
1391 (match_operand:P 2 "register_operand" "=a")])]
1392 ""
1393 {
1394 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1395 emit_move_insn (operands[0], new_rtx);
1396 })
1397
1398 ;
1399 ; movdi instruction pattern(s).
1400 ;
1401
1402 (define_expand "movdi"
1403 [(set (match_operand:DI 0 "general_operand" "")
1404 (match_operand:DI 1 "general_operand" ""))]
1405 ""
1406 {
1407 /* Handle symbolic constants. */
1408 if (TARGET_64BIT
1409 && (SYMBOLIC_CONST (operands[1])
1410 || (GET_CODE (operands[1]) == PLUS
1411 && XEXP (operands[1], 0) == pic_offset_table_rtx
1412 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
1413 emit_symbolic_move (operands);
1414 })
1415
1416 (define_insn "*movdi_larl"
1417 [(set (match_operand:DI 0 "register_operand" "=d")
1418 (match_operand:DI 1 "larl_operand" "X"))]
1419 "TARGET_64BIT
1420 && !FP_REG_P (operands[0])"
1421 "larl\t%0,%1"
1422 [(set_attr "op_type" "RIL")
1423 (set_attr "type" "larl")
1424 (set_attr "z10prop" "z10_super_A1")])
1425
1426 (define_insn "*movdi_64"
1427 [(set (match_operand:DI 0 "nonimmediate_operand"
1428 "=d,d,d,d,d,d,d,d,f,d,d,d,d,d,
1429 RT,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t")
1430 (match_operand:DI 1 "general_operand"
1431 "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,RT,
1432 d,*f,R,T,*f,*f,d,K,t,d,t,Q"))]
1433 "TARGET_ZARCH"
1434 "@
1435 lghi\t%0,%h1
1436 llihh\t%0,%i1
1437 llihl\t%0,%i1
1438 llilh\t%0,%i1
1439 llill\t%0,%i1
1440 lgfi\t%0,%1
1441 llihf\t%0,%k1
1442 llilf\t%0,%k1
1443 ldgr\t%0,%1
1444 lgdr\t%0,%1
1445 lay\t%0,%a1
1446 lgrl\t%0,%1
1447 lgr\t%0,%1
1448 lg\t%0,%1
1449 stg\t%1,%0
1450 ldr\t%0,%1
1451 ld\t%0,%1
1452 ldy\t%0,%1
1453 std\t%1,%0
1454 stdy\t%1,%0
1455 stgrl\t%1,%0
1456 mvghi\t%0,%1
1457 #
1458 #
1459 stam\t%1,%N1,%S0
1460 lam\t%0,%N0,%S1"
1461 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
1462 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS")
1463 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
1464 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,
1465 *,*")
1466 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
1467 z10,*,*,*,*,*,longdisp,*,longdisp,
1468 z10,z10,*,*,*,*")
1469 (set_attr "z10prop" "z10_fwd_A1,
1470 z10_fwd_E1,
1471 z10_fwd_E1,
1472 z10_fwd_E1,
1473 z10_fwd_E1,
1474 z10_fwd_A1,
1475 z10_fwd_E1,
1476 z10_fwd_E1,
1477 *,
1478 *,
1479 z10_fwd_A1,
1480 z10_fwd_A3,
1481 z10_fr_E1,
1482 z10_fwd_A3,
1483 z10_rec,
1484 *,
1485 *,
1486 *,
1487 *,
1488 *,
1489 z10_rec,
1490 z10_super,
1491 *,
1492 *,
1493 *,
1494 *")
1495 ])
1496
1497 (define_split
1498 [(set (match_operand:DI 0 "register_operand" "")
1499 (match_operand:DI 1 "register_operand" ""))]
1500 "TARGET_ZARCH && ACCESS_REG_P (operands[1])"
1501 [(set (match_dup 2) (match_dup 3))
1502 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1503 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1504 "operands[2] = gen_lowpart (SImode, operands[0]);
1505 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1506
1507 (define_split
1508 [(set (match_operand:DI 0 "register_operand" "")
1509 (match_operand:DI 1 "register_operand" ""))]
1510 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
1511 && dead_or_set_p (insn, operands[1])"
1512 [(set (match_dup 3) (match_dup 2))
1513 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1514 (set (match_dup 4) (match_dup 2))]
1515 "operands[2] = gen_lowpart (SImode, operands[1]);
1516 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1517
1518 (define_split
1519 [(set (match_operand:DI 0 "register_operand" "")
1520 (match_operand:DI 1 "register_operand" ""))]
1521 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
1522 && !dead_or_set_p (insn, operands[1])"
1523 [(set (match_dup 3) (match_dup 2))
1524 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1525 (set (match_dup 4) (match_dup 2))
1526 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1527 "operands[2] = gen_lowpart (SImode, operands[1]);
1528 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1529
1530 (define_insn "*movdi_31"
1531 [(set (match_operand:DI 0 "nonimmediate_operand"
1532 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!R,!T,d")
1533 (match_operand:DI 1 "general_operand"
1534 " Q,S,d,d,dPRT,d, *f, R, T,*f,*f,b"))]
1535 "!TARGET_ZARCH"
1536 "@
1537 lm\t%0,%N0,%S1
1538 lmy\t%0,%N0,%S1
1539 stm\t%1,%N1,%S0
1540 stmy\t%1,%N1,%S0
1541 #
1542 #
1543 ldr\t%0,%1
1544 ld\t%0,%1
1545 ldy\t%0,%1
1546 std\t%1,%0
1547 stdy\t%1,%0
1548 #"
1549 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1550 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
1551 (set_attr "cpu_facility" "*,*,*,*,*,*,*,*,*,*,*,z10")])
1552
1553 ; For a load from a symbol ref we can use one of the target registers
1554 ; together with larl to load the address.
1555 (define_split
1556 [(set (match_operand:DI 0 "register_operand" "")
1557 (match_operand:DI 1 "memory_operand" ""))]
1558 "!TARGET_ZARCH && reload_completed && TARGET_Z10
1559 && larl_operand (XEXP (operands[1], 0), SImode)"
1560 [(set (match_dup 2) (match_dup 3))
1561 (set (match_dup 0) (match_dup 1))]
1562 {
1563 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1564 operands[3] = XEXP (operands[1], 0);
1565 operands[1] = replace_equiv_address (operands[1], operands[2]);
1566 })
1567
1568 (define_split
1569 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1570 (match_operand:DI 1 "general_operand" ""))]
1571 "!TARGET_ZARCH && reload_completed
1572 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
1573 [(set (match_dup 2) (match_dup 4))
1574 (set (match_dup 3) (match_dup 5))]
1575 {
1576 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1577 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1578 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1579 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1580 })
1581
1582 (define_split
1583 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1584 (match_operand:DI 1 "general_operand" ""))]
1585 "!TARGET_ZARCH && reload_completed
1586 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1587 [(set (match_dup 2) (match_dup 4))
1588 (set (match_dup 3) (match_dup 5))]
1589 {
1590 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1591 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1592 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1593 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1594 })
1595
1596 (define_split
1597 [(set (match_operand:DI 0 "register_operand" "")
1598 (match_operand:DI 1 "memory_operand" ""))]
1599 "!TARGET_ZARCH && reload_completed
1600 && !FP_REG_P (operands[0])
1601 && !s_operand (operands[1], VOIDmode)"
1602 [(set (match_dup 0) (match_dup 1))]
1603 {
1604 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1605 s390_load_address (addr, XEXP (operands[1], 0));
1606 operands[1] = replace_equiv_address (operands[1], addr);
1607 })
1608
1609 (define_peephole2
1610 [(set (match_operand:DI 0 "register_operand" "")
1611 (mem:DI (match_operand 1 "address_operand" "")))]
1612 "TARGET_ZARCH
1613 && !FP_REG_P (operands[0])
1614 && GET_CODE (operands[1]) == SYMBOL_REF
1615 && CONSTANT_POOL_ADDRESS_P (operands[1])
1616 && get_pool_mode (operands[1]) == DImode
1617 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1618 [(set (match_dup 0) (match_dup 2))]
1619 "operands[2] = get_pool_constant (operands[1]);")
1620
1621 (define_insn "*la_64"
1622 [(set (match_operand:DI 0 "register_operand" "=d,d")
1623 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))]
1624 "TARGET_64BIT"
1625 "@
1626 la\t%0,%a1
1627 lay\t%0,%a1"
1628 [(set_attr "op_type" "RX,RXY")
1629 (set_attr "type" "la")
1630 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1631
1632 (define_peephole2
1633 [(parallel
1634 [(set (match_operand:DI 0 "register_operand" "")
1635 (match_operand:QI 1 "address_operand" ""))
1636 (clobber (reg:CC CC_REGNUM))])]
1637 "TARGET_64BIT
1638 && preferred_la_operand_p (operands[1], const0_rtx)"
1639 [(set (match_dup 0) (match_dup 1))]
1640 "")
1641
1642 (define_peephole2
1643 [(set (match_operand:DI 0 "register_operand" "")
1644 (match_operand:DI 1 "register_operand" ""))
1645 (parallel
1646 [(set (match_dup 0)
1647 (plus:DI (match_dup 0)
1648 (match_operand:DI 2 "nonmemory_operand" "")))
1649 (clobber (reg:CC CC_REGNUM))])]
1650 "TARGET_64BIT
1651 && !reg_overlap_mentioned_p (operands[0], operands[2])
1652 && preferred_la_operand_p (operands[1], operands[2])"
1653 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1654 "")
1655
1656 ;
1657 ; movsi instruction pattern(s).
1658 ;
1659
1660 (define_expand "movsi"
1661 [(set (match_operand:SI 0 "general_operand" "")
1662 (match_operand:SI 1 "general_operand" ""))]
1663 ""
1664 {
1665 /* Handle symbolic constants. */
1666 if (!TARGET_64BIT
1667 && (SYMBOLIC_CONST (operands[1])
1668 || (GET_CODE (operands[1]) == PLUS
1669 && XEXP (operands[1], 0) == pic_offset_table_rtx
1670 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
1671 emit_symbolic_move (operands);
1672 })
1673
1674 (define_insn "*movsi_larl"
1675 [(set (match_operand:SI 0 "register_operand" "=d")
1676 (match_operand:SI 1 "larl_operand" "X"))]
1677 "!TARGET_64BIT && TARGET_CPU_ZARCH
1678 && !FP_REG_P (operands[0])"
1679 "larl\t%0,%1"
1680 [(set_attr "op_type" "RIL")
1681 (set_attr "type" "larl")
1682 (set_attr "z10prop" "z10_fwd_A1")])
1683
1684 (define_insn "*movsi_zarch"
1685 [(set (match_operand:SI 0 "nonimmediate_operand"
1686 "=d,d,d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,b,Q,t")
1687 (match_operand:SI 1 "general_operand"
1688 "K,N0HS0,N1HS0,Os,L,b,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,d,K,Q"))]
1689 "TARGET_ZARCH"
1690 "@
1691 lhi\t%0,%h1
1692 llilh\t%0,%i1
1693 llill\t%0,%i1
1694 iilf\t%0,%o1
1695 lay\t%0,%a1
1696 lrl\t%0,%1
1697 lr\t%0,%1
1698 l\t%0,%1
1699 ly\t%0,%1
1700 st\t%1,%0
1701 sty\t%1,%0
1702 ler\t%0,%1
1703 le\t%0,%1
1704 ley\t%0,%1
1705 ste\t%1,%0
1706 stey\t%1,%0
1707 ear\t%0,%1
1708 sar\t%0,%1
1709 stam\t%1,%1,%S0
1710 strl\t%1,%0
1711 mvhi\t%0,%1
1712 lam\t%0,%0,%S1"
1713 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
1714 RR,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS")
1715 (set_attr "type" "*,
1716 *,
1717 *,
1718 *,
1719 la,
1720 larl,
1721 lr,
1722 load,
1723 load,
1724 store,
1725 store,
1726 floadsf,
1727 floadsf,
1728 floadsf,
1729 fstoresf,
1730 fstoresf,
1731 *,
1732 *,
1733 *,
1734 larl,
1735 *,
1736 *")
1737 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
1738 *,*,longdisp,*,longdisp,*,*,*,z10,z10,*")
1739 (set_attr "z10prop" "z10_fwd_A1,
1740 z10_fwd_E1,
1741 z10_fwd_E1,
1742 z10_fwd_A1,
1743 z10_fwd_A1,
1744 z10_fwd_A3,
1745 z10_fr_E1,
1746 z10_fwd_A3,
1747 z10_fwd_A3,
1748 z10_rec,
1749 z10_rec,
1750 *,
1751 *,
1752 *,
1753 *,
1754 *,
1755 z10_super_E1,
1756 z10_super,
1757 *,
1758 z10_rec,
1759 z10_super,
1760 *")])
1761
1762 (define_insn "*movsi_esa"
1763 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t")
1764 (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q"))]
1765 "!TARGET_ZARCH"
1766 "@
1767 lhi\t%0,%h1
1768 lr\t%0,%1
1769 l\t%0,%1
1770 st\t%1,%0
1771 ler\t%0,%1
1772 le\t%0,%1
1773 ste\t%1,%0
1774 ear\t%0,%1
1775 sar\t%0,%1
1776 stam\t%1,%1,%S0
1777 lam\t%0,%0,%S1"
1778 [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS")
1779 (set_attr "type" "*,lr,load,store,floadsf,floadsf,fstoresf,*,*,*,*")
1780 (set_attr "z10prop" "z10_fwd_A1,
1781 z10_fr_E1,
1782 z10_fwd_A3,
1783 z10_rec,
1784 *,
1785 *,
1786 *,
1787 z10_super_E1,
1788 z10_super,
1789 *,
1790 *")
1791 ])
1792
1793 (define_peephole2
1794 [(set (match_operand:SI 0 "register_operand" "")
1795 (mem:SI (match_operand 1 "address_operand" "")))]
1796 "!FP_REG_P (operands[0])
1797 && GET_CODE (operands[1]) == SYMBOL_REF
1798 && CONSTANT_POOL_ADDRESS_P (operands[1])
1799 && get_pool_mode (operands[1]) == SImode
1800 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1801 [(set (match_dup 0) (match_dup 2))]
1802 "operands[2] = get_pool_constant (operands[1]);")
1803
1804 (define_insn "*la_31"
1805 [(set (match_operand:SI 0 "register_operand" "=d,d")
1806 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))]
1807 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1808 "@
1809 la\t%0,%a1
1810 lay\t%0,%a1"
1811 [(set_attr "op_type" "RX,RXY")
1812 (set_attr "type" "la")
1813 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1814
1815 (define_peephole2
1816 [(parallel
1817 [(set (match_operand:SI 0 "register_operand" "")
1818 (match_operand:QI 1 "address_operand" ""))
1819 (clobber (reg:CC CC_REGNUM))])]
1820 "!TARGET_64BIT
1821 && preferred_la_operand_p (operands[1], const0_rtx)"
1822 [(set (match_dup 0) (match_dup 1))]
1823 "")
1824
1825 (define_peephole2
1826 [(set (match_operand:SI 0 "register_operand" "")
1827 (match_operand:SI 1 "register_operand" ""))
1828 (parallel
1829 [(set (match_dup 0)
1830 (plus:SI (match_dup 0)
1831 (match_operand:SI 2 "nonmemory_operand" "")))
1832 (clobber (reg:CC CC_REGNUM))])]
1833 "!TARGET_64BIT
1834 && !reg_overlap_mentioned_p (operands[0], operands[2])
1835 && preferred_la_operand_p (operands[1], operands[2])"
1836 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1837 "")
1838
1839 (define_insn "*la_31_and"
1840 [(set (match_operand:SI 0 "register_operand" "=d,d")
1841 (and:SI (match_operand:QI 1 "address_operand" "ZQZR,ZSZT")
1842 (const_int 2147483647)))]
1843 "!TARGET_64BIT"
1844 "@
1845 la\t%0,%a1
1846 lay\t%0,%a1"
1847 [(set_attr "op_type" "RX,RXY")
1848 (set_attr "type" "la")
1849 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1850
1851 (define_insn_and_split "*la_31_and_cc"
1852 [(set (match_operand:SI 0 "register_operand" "=d")
1853 (and:SI (match_operand:QI 1 "address_operand" "p")
1854 (const_int 2147483647)))
1855 (clobber (reg:CC CC_REGNUM))]
1856 "!TARGET_64BIT"
1857 "#"
1858 "&& reload_completed"
1859 [(set (match_dup 0)
1860 (and:SI (match_dup 1) (const_int 2147483647)))]
1861 ""
1862 [(set_attr "op_type" "RX")
1863 (set_attr "type" "la")])
1864
1865 (define_insn "force_la_31"
1866 [(set (match_operand:SI 0 "register_operand" "=d,d")
1867 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))
1868 (use (const_int 0))]
1869 "!TARGET_64BIT"
1870 "@
1871 la\t%0,%a1
1872 lay\t%0,%a1"
1873 [(set_attr "op_type" "RX")
1874 (set_attr "type" "la")
1875 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1876
1877 ;
1878 ; movhi instruction pattern(s).
1879 ;
1880
1881 (define_expand "movhi"
1882 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1883 (match_operand:HI 1 "general_operand" ""))]
1884 ""
1885 {
1886 /* Make it explicit that loading a register from memory
1887 always sign-extends (at least) to SImode. */
1888 if (optimize && can_create_pseudo_p ()
1889 && register_operand (operands[0], VOIDmode)
1890 && GET_CODE (operands[1]) == MEM)
1891 {
1892 rtx tmp = gen_reg_rtx (SImode);
1893 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1894 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1895 operands[1] = gen_lowpart (HImode, tmp);
1896 }
1897 })
1898
1899 (define_insn "*movhi"
1900 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q")
1901 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K"))]
1902 ""
1903 "@
1904 lr\t%0,%1
1905 lhi\t%0,%h1
1906 lh\t%0,%1
1907 lhy\t%0,%1
1908 lhrl\t%0,%1
1909 sth\t%1,%0
1910 sthy\t%1,%0
1911 sthrl\t%1,%0
1912 mvhhi\t%0,%1"
1913 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL")
1914 (set_attr "type" "lr,*,*,*,larl,store,store,store,*")
1915 (set_attr "cpu_facility" "*,*,*,*,z10,*,*,z10,z10")
1916 (set_attr "z10prop" "z10_fr_E1,
1917 z10_fwd_A1,
1918 z10_super_E1,
1919 z10_super_E1,
1920 z10_super_E1,
1921 z10_rec,
1922 z10_rec,
1923 z10_rec,
1924 z10_super")])
1925
1926 (define_peephole2
1927 [(set (match_operand:HI 0 "register_operand" "")
1928 (mem:HI (match_operand 1 "address_operand" "")))]
1929 "GET_CODE (operands[1]) == SYMBOL_REF
1930 && CONSTANT_POOL_ADDRESS_P (operands[1])
1931 && get_pool_mode (operands[1]) == HImode
1932 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1933 [(set (match_dup 0) (match_dup 2))]
1934 "operands[2] = get_pool_constant (operands[1]);")
1935
1936 ;
1937 ; movqi instruction pattern(s).
1938 ;
1939
1940 (define_expand "movqi"
1941 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1942 (match_operand:QI 1 "general_operand" ""))]
1943 ""
1944 {
1945 /* On z/Architecture, zero-extending from memory to register
1946 is just as fast as a QImode load. */
1947 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
1948 && register_operand (operands[0], VOIDmode)
1949 && GET_CODE (operands[1]) == MEM)
1950 {
1951 rtx tmp = gen_reg_rtx (DImode);
1952 rtx ext = gen_rtx_ZERO_EXTEND (DImode, operands[1]);
1953 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1954 operands[1] = gen_lowpart (QImode, tmp);
1955 }
1956 })
1957
1958 (define_insn "*movqi"
1959 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1960 (match_operand:QI 1 "general_operand" " d,n,R,T,d,d,n,n,?Q"))]
1961 ""
1962 "@
1963 lr\t%0,%1
1964 lhi\t%0,%b1
1965 ic\t%0,%1
1966 icy\t%0,%1
1967 stc\t%1,%0
1968 stcy\t%1,%0
1969 mvi\t%S0,%b1
1970 mviy\t%S0,%b1
1971 #"
1972 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1973 (set_attr "type" "lr,*,*,*,store,store,store,store,*")
1974 (set_attr "z10prop" "z10_fr_E1,
1975 z10_fwd_A1,
1976 z10_super_E1,
1977 z10_super_E1,
1978 z10_rec,
1979 z10_rec,
1980 z10_super,
1981 z10_super,
1982 *")])
1983
1984 (define_peephole2
1985 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1986 (mem:QI (match_operand 1 "address_operand" "")))]
1987 "GET_CODE (operands[1]) == SYMBOL_REF
1988 && CONSTANT_POOL_ADDRESS_P (operands[1])
1989 && get_pool_mode (operands[1]) == QImode
1990 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1991 [(set (match_dup 0) (match_dup 2))]
1992 "operands[2] = get_pool_constant (operands[1]);")
1993
1994 ;
1995 ; movstrictqi instruction pattern(s).
1996 ;
1997
1998 (define_insn "*movstrictqi"
1999 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
2000 (match_operand:QI 1 "memory_operand" "R,T"))]
2001 ""
2002 "@
2003 ic\t%0,%1
2004 icy\t%0,%1"
2005 [(set_attr "op_type" "RX,RXY")
2006 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
2007
2008 ;
2009 ; movstricthi instruction pattern(s).
2010 ;
2011
2012 (define_insn "*movstricthi"
2013 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
2014 (match_operand:HI 1 "memory_operand" "Q,S"))
2015 (clobber (reg:CC CC_REGNUM))]
2016 ""
2017 "@
2018 icm\t%0,3,%S1
2019 icmy\t%0,3,%S1"
2020 [(set_attr "op_type" "RS,RSY")
2021 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
2022
2023 ;
2024 ; movstrictsi instruction pattern(s).
2025 ;
2026
2027 (define_insn "movstrictsi"
2028 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
2029 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
2030 "TARGET_ZARCH"
2031 "@
2032 lr\t%0,%1
2033 l\t%0,%1
2034 ly\t%0,%1
2035 ear\t%0,%1"
2036 [(set_attr "op_type" "RR,RX,RXY,RRE")
2037 (set_attr "type" "lr,load,load,*")
2038 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
2039
2040 ;
2041 ; mov(tf|td) instruction pattern(s).
2042 ;
2043
2044 (define_expand "mov<mode>"
2045 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2046 (match_operand:TD_TF 1 "general_operand" ""))]
2047 ""
2048 "")
2049
2050 (define_insn "*mov<mode>_64"
2051 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o, d,QS, d,o")
2052 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,QS, d,dRT,d"))]
2053 "TARGET_ZARCH"
2054 "@
2055 lzxr\t%0
2056 lxr\t%0,%1
2057 #
2058 #
2059 lmg\t%0,%N0,%S1
2060 stmg\t%1,%N1,%S0
2061 #
2062 #"
2063 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
2064 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")
2065 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*")])
2066
2067 (define_insn "*mov<mode>_31"
2068 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
2069 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
2070 "!TARGET_ZARCH"
2071 "@
2072 lzxr\t%0
2073 lxr\t%0,%1
2074 #
2075 #"
2076 [(set_attr "op_type" "RRE,RRE,*,*")
2077 (set_attr "type" "fsimptf,fsimptf,*,*")
2078 (set_attr "cpu_facility" "z196,*,*,*")])
2079
2080 ; TFmode in GPRs splitters
2081
2082 (define_split
2083 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2084 (match_operand:TD_TF 1 "general_operand" ""))]
2085 "TARGET_ZARCH && reload_completed
2086 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2087 [(set (match_dup 2) (match_dup 4))
2088 (set (match_dup 3) (match_dup 5))]
2089 {
2090 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2091 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2092 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2093 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2094 })
2095
2096 (define_split
2097 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2098 (match_operand:TD_TF 1 "general_operand" ""))]
2099 "TARGET_ZARCH && reload_completed
2100 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2101 [(set (match_dup 2) (match_dup 4))
2102 (set (match_dup 3) (match_dup 5))]
2103 {
2104 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2105 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2106 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2107 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2108 })
2109
2110 (define_split
2111 [(set (match_operand:TD_TF 0 "register_operand" "")
2112 (match_operand:TD_TF 1 "memory_operand" ""))]
2113 "TARGET_ZARCH && reload_completed
2114 && !FP_REG_P (operands[0])
2115 && !s_operand (operands[1], VOIDmode)"
2116 [(set (match_dup 0) (match_dup 1))]
2117 {
2118 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2119 addr = gen_lowpart (Pmode, addr);
2120 s390_load_address (addr, XEXP (operands[1], 0));
2121 operands[1] = replace_equiv_address (operands[1], addr);
2122 })
2123
2124 ; TFmode in BFPs splitters
2125
2126 (define_split
2127 [(set (match_operand:TD_TF 0 "register_operand" "")
2128 (match_operand:TD_TF 1 "memory_operand" ""))]
2129 "reload_completed && offsettable_memref_p (operands[1])
2130 && FP_REG_P (operands[0])"
2131 [(set (match_dup 2) (match_dup 4))
2132 (set (match_dup 3) (match_dup 5))]
2133 {
2134 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2135 <MODE>mode, 0);
2136 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2137 <MODE>mode, 8);
2138 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
2139 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
2140 })
2141
2142 (define_split
2143 [(set (match_operand:TD_TF 0 "memory_operand" "")
2144 (match_operand:TD_TF 1 "register_operand" ""))]
2145 "reload_completed && offsettable_memref_p (operands[0])
2146 && FP_REG_P (operands[1])"
2147 [(set (match_dup 2) (match_dup 4))
2148 (set (match_dup 3) (match_dup 5))]
2149 {
2150 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
2151 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
2152 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2153 <MODE>mode, 0);
2154 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2155 <MODE>mode, 8);
2156 })
2157
2158 ;
2159 ; mov(df|dd) instruction pattern(s).
2160 ;
2161
2162 (define_expand "mov<mode>"
2163 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2164 (match_operand:DD_DF 1 "general_operand" ""))]
2165 ""
2166 "")
2167
2168 (define_insn "*mov<mode>_64dfp"
2169 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2170 "=f,f,f,d,f,f,R,T,d,d, d,RT")
2171 (match_operand:DD_DF 1 "general_operand"
2172 " G,f,d,f,R,T,f,f,G,d,RT, d"))]
2173 "TARGET_DFP"
2174 "@
2175 lzdr\t%0
2176 ldr\t%0,%1
2177 ldgr\t%0,%1
2178 lgdr\t%0,%1
2179 ld\t%0,%1
2180 ldy\t%0,%1
2181 std\t%1,%0
2182 stdy\t%1,%0
2183 lghi\t%0,0
2184 lgr\t%0,%1
2185 lg\t%0,%1
2186 stg\t%1,%0"
2187 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RI,RRE,RXY,RXY")
2188 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
2189 fstoredf,fstoredf,*,lr,load,store")
2190 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec")
2191 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*,*,*")])
2192
2193 (define_insn "*mov<mode>_64"
2194 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d, d,RT")
2195 (match_operand:DD_DF 1 "general_operand" " G,f,R,T,f,f,G,d,RT, d"))]
2196 "TARGET_ZARCH"
2197 "@
2198 lzdr\t%0
2199 ldr\t%0,%1
2200 ld\t%0,%1
2201 ldy\t%0,%1
2202 std\t%1,%0
2203 stdy\t%1,%0
2204 lghi\t%0,0
2205 lgr\t%0,%1
2206 lg\t%0,%1
2207 stg\t%1,%0"
2208 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RRE,RXY,RXY")
2209 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2210 fstore<mode>,fstore<mode>,*,lr,load,store")
2211 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec")
2212 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*")])
2213
2214 (define_insn "*mov<mode>_31"
2215 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2216 "=f,f,f,f,R,T,d,d,Q,S, d,o")
2217 (match_operand:DD_DF 1 "general_operand"
2218 " G,f,R,T,f,f,Q,S,d,d,dPRT,d"))]
2219 "!TARGET_ZARCH"
2220 "@
2221 lzdr\t%0
2222 ldr\t%0,%1
2223 ld\t%0,%1
2224 ldy\t%0,%1
2225 std\t%1,%0
2226 stdy\t%1,%0
2227 lm\t%0,%N0,%S1
2228 lmy\t%0,%N0,%S1
2229 stm\t%1,%N1,%S0
2230 stmy\t%1,%N1,%S0
2231 #
2232 #"
2233 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2234 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2235 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")
2236 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*,*,*")])
2237
2238 (define_split
2239 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2240 (match_operand:DD_DF 1 "general_operand" ""))]
2241 "!TARGET_ZARCH && reload_completed
2242 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2243 [(set (match_dup 2) (match_dup 4))
2244 (set (match_dup 3) (match_dup 5))]
2245 {
2246 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2247 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2248 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2249 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2250 })
2251
2252 (define_split
2253 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2254 (match_operand:DD_DF 1 "general_operand" ""))]
2255 "!TARGET_ZARCH && reload_completed
2256 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2257 [(set (match_dup 2) (match_dup 4))
2258 (set (match_dup 3) (match_dup 5))]
2259 {
2260 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2261 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2262 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2263 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2264 })
2265
2266 (define_split
2267 [(set (match_operand:DD_DF 0 "register_operand" "")
2268 (match_operand:DD_DF 1 "memory_operand" ""))]
2269 "!TARGET_ZARCH && reload_completed
2270 && !FP_REG_P (operands[0])
2271 && !s_operand (operands[1], VOIDmode)"
2272 [(set (match_dup 0) (match_dup 1))]
2273 {
2274 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2275 s390_load_address (addr, XEXP (operands[1], 0));
2276 operands[1] = replace_equiv_address (operands[1], addr);
2277 })
2278
2279 ;
2280 ; mov(sf|sd) instruction pattern(s).
2281 ;
2282
2283 (define_insn "mov<mode>"
2284 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
2285 "=f,f,f,f,R,T,d,d,d,d,R,T")
2286 (match_operand:SD_SF 1 "general_operand"
2287 " G,f,R,T,f,f,G,d,R,T,d,d"))]
2288 ""
2289 "@
2290 lzer\t%0
2291 ler\t%0,%1
2292 le\t%0,%1
2293 ley\t%0,%1
2294 ste\t%1,%0
2295 stey\t%1,%0
2296 lhi\t%0,0
2297 lr\t%0,%1
2298 l\t%0,%1
2299 ly\t%0,%1
2300 st\t%1,%0
2301 sty\t%1,%0"
2302 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RR,RX,RXY,RX,RXY")
2303 (set_attr "type" "fsimpsf,fload<mode>,fload<mode>,fload<mode>,
2304 fstore<mode>,fstore<mode>,*,lr,load,load,store,store")
2305 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
2306 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*,*,*")])
2307
2308 ;
2309 ; movcc instruction pattern
2310 ;
2311
2312 (define_insn "movcc"
2313 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
2314 (match_operand:CC 1 "nonimmediate_operand" " d,d,c,R,T,d,d"))]
2315 ""
2316 "@
2317 lr\t%0,%1
2318 tmh\t%1,12288
2319 ipm\t%0
2320 l\t%0,%1
2321 ly\t%0,%1
2322 st\t%1,%0
2323 sty\t%1,%0"
2324 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
2325 (set_attr "type" "lr,*,*,load,load,store,store")
2326 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
2327 (set_attr "z196prop" "*,*,z196_ends,*,*,*,*")])
2328
2329 ;
2330 ; Block move (MVC) patterns.
2331 ;
2332
2333 (define_insn "*mvc"
2334 [(set (match_operand:BLK 0 "memory_operand" "=Q")
2335 (match_operand:BLK 1 "memory_operand" "Q"))
2336 (use (match_operand 2 "const_int_operand" "n"))]
2337 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
2338 "mvc\t%O0(%2,%R0),%S1"
2339 [(set_attr "op_type" "SS")])
2340
2341 ; This splitter converts a QI to QI mode copy into a BLK mode copy in
2342 ; order to have it implemented with mvc.
2343
2344 (define_split
2345 [(set (match_operand:QI 0 "memory_operand" "")
2346 (match_operand:QI 1 "memory_operand" ""))]
2347 "reload_completed"
2348 [(parallel
2349 [(set (match_dup 0) (match_dup 1))
2350 (use (const_int 1))])]
2351 {
2352 operands[0] = adjust_address (operands[0], BLKmode, 0);
2353 operands[1] = adjust_address (operands[1], BLKmode, 0);
2354 })
2355
2356
2357 (define_peephole2
2358 [(parallel
2359 [(set (match_operand:BLK 0 "memory_operand" "")
2360 (match_operand:BLK 1 "memory_operand" ""))
2361 (use (match_operand 2 "const_int_operand" ""))])
2362 (parallel
2363 [(set (match_operand:BLK 3 "memory_operand" "")
2364 (match_operand:BLK 4 "memory_operand" ""))
2365 (use (match_operand 5 "const_int_operand" ""))])]
2366 "s390_offset_p (operands[0], operands[3], operands[2])
2367 && s390_offset_p (operands[1], operands[4], operands[2])
2368 && !s390_overlap_p (operands[0], operands[1],
2369 INTVAL (operands[2]) + INTVAL (operands[5]))
2370 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2371 [(parallel
2372 [(set (match_dup 6) (match_dup 7))
2373 (use (match_dup 8))])]
2374 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2375 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2376 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2377
2378
2379 ;
2380 ; load_multiple pattern(s).
2381 ;
2382 ; ??? Due to reload problems with replacing registers inside match_parallel
2383 ; we currently support load_multiple/store_multiple only after reload.
2384 ;
2385
2386 (define_expand "load_multiple"
2387 [(match_par_dup 3 [(set (match_operand 0 "" "")
2388 (match_operand 1 "" ""))
2389 (use (match_operand 2 "" ""))])]
2390 "reload_completed"
2391 {
2392 enum machine_mode mode;
2393 int regno;
2394 int count;
2395 rtx from;
2396 int i, off;
2397
2398 /* Support only loading a constant number of fixed-point registers from
2399 memory and only bother with this if more than two */
2400 if (GET_CODE (operands[2]) != CONST_INT
2401 || INTVAL (operands[2]) < 2
2402 || INTVAL (operands[2]) > 16
2403 || GET_CODE (operands[1]) != MEM
2404 || GET_CODE (operands[0]) != REG
2405 || REGNO (operands[0]) >= 16)
2406 FAIL;
2407
2408 count = INTVAL (operands[2]);
2409 regno = REGNO (operands[0]);
2410 mode = GET_MODE (operands[0]);
2411 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
2412 FAIL;
2413
2414 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2415 if (!can_create_pseudo_p ())
2416 {
2417 if (GET_CODE (XEXP (operands[1], 0)) == REG)
2418 {
2419 from = XEXP (operands[1], 0);
2420 off = 0;
2421 }
2422 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2423 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2424 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2425 {
2426 from = XEXP (XEXP (operands[1], 0), 0);
2427 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2428 }
2429 else
2430 FAIL;
2431 }
2432 else
2433 {
2434 from = force_reg (Pmode, XEXP (operands[1], 0));
2435 off = 0;
2436 }
2437
2438 for (i = 0; i < count; i++)
2439 XVECEXP (operands[3], 0, i)
2440 = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
2441 change_address (operands[1], mode,
2442 plus_constant (Pmode, from,
2443 off + i * GET_MODE_SIZE (mode))));
2444 })
2445
2446 (define_insn "*load_multiple_di"
2447 [(match_parallel 0 "load_multiple_operation"
2448 [(set (match_operand:DI 1 "register_operand" "=r")
2449 (match_operand:DI 2 "s_operand" "QS"))])]
2450 "reload_completed && TARGET_ZARCH"
2451 {
2452 int words = XVECLEN (operands[0], 0);
2453 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
2454 return "lmg\t%1,%0,%S2";
2455 }
2456 [(set_attr "op_type" "RSY")
2457 (set_attr "type" "lm")])
2458
2459 (define_insn "*load_multiple_si"
2460 [(match_parallel 0 "load_multiple_operation"
2461 [(set (match_operand:SI 1 "register_operand" "=r,r")
2462 (match_operand:SI 2 "s_operand" "Q,S"))])]
2463 "reload_completed"
2464 {
2465 int words = XVECLEN (operands[0], 0);
2466 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
2467 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
2468 }
2469 [(set_attr "op_type" "RS,RSY")
2470 (set_attr "type" "lm")])
2471
2472 ;
2473 ; store multiple pattern(s).
2474 ;
2475
2476 (define_expand "store_multiple"
2477 [(match_par_dup 3 [(set (match_operand 0 "" "")
2478 (match_operand 1 "" ""))
2479 (use (match_operand 2 "" ""))])]
2480 "reload_completed"
2481 {
2482 enum machine_mode mode;
2483 int regno;
2484 int count;
2485 rtx to;
2486 int i, off;
2487
2488 /* Support only storing a constant number of fixed-point registers to
2489 memory and only bother with this if more than two. */
2490 if (GET_CODE (operands[2]) != CONST_INT
2491 || INTVAL (operands[2]) < 2
2492 || INTVAL (operands[2]) > 16
2493 || GET_CODE (operands[0]) != MEM
2494 || GET_CODE (operands[1]) != REG
2495 || REGNO (operands[1]) >= 16)
2496 FAIL;
2497
2498 count = INTVAL (operands[2]);
2499 regno = REGNO (operands[1]);
2500 mode = GET_MODE (operands[1]);
2501 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
2502 FAIL;
2503
2504 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2505
2506 if (!can_create_pseudo_p ())
2507 {
2508 if (GET_CODE (XEXP (operands[0], 0)) == REG)
2509 {
2510 to = XEXP (operands[0], 0);
2511 off = 0;
2512 }
2513 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2514 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2515 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2516 {
2517 to = XEXP (XEXP (operands[0], 0), 0);
2518 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2519 }
2520 else
2521 FAIL;
2522 }
2523 else
2524 {
2525 to = force_reg (Pmode, XEXP (operands[0], 0));
2526 off = 0;
2527 }
2528
2529 for (i = 0; i < count; i++)
2530 XVECEXP (operands[3], 0, i)
2531 = gen_rtx_SET (VOIDmode,
2532 change_address (operands[0], mode,
2533 plus_constant (Pmode, to,
2534 off + i * GET_MODE_SIZE (mode))),
2535 gen_rtx_REG (mode, regno + i));
2536 })
2537
2538 (define_insn "*store_multiple_di"
2539 [(match_parallel 0 "store_multiple_operation"
2540 [(set (match_operand:DI 1 "s_operand" "=QS")
2541 (match_operand:DI 2 "register_operand" "r"))])]
2542 "reload_completed && TARGET_ZARCH"
2543 {
2544 int words = XVECLEN (operands[0], 0);
2545 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
2546 return "stmg\t%2,%0,%S1";
2547 }
2548 [(set_attr "op_type" "RSY")
2549 (set_attr "type" "stm")])
2550
2551
2552 (define_insn "*store_multiple_si"
2553 [(match_parallel 0 "store_multiple_operation"
2554 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2555 (match_operand:SI 2 "register_operand" "r,r"))])]
2556 "reload_completed"
2557 {
2558 int words = XVECLEN (operands[0], 0);
2559 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
2560 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
2561 }
2562 [(set_attr "op_type" "RS,RSY")
2563 (set_attr "type" "stm")])
2564
2565 ;;
2566 ;; String instructions.
2567 ;;
2568
2569 (define_insn "*execute_rl"
2570 [(match_parallel 0 "execute_operation"
2571 [(unspec [(match_operand 1 "register_operand" "a")
2572 (match_operand 2 "" "")
2573 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2574 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2575 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2576 "exrl\t%1,%3"
2577 [(set_attr "op_type" "RIL")
2578 (set_attr "type" "cs")])
2579
2580 (define_insn "*execute"
2581 [(match_parallel 0 "execute_operation"
2582 [(unspec [(match_operand 1 "register_operand" "a")
2583 (match_operand:BLK 2 "memory_operand" "R")
2584 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2585 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2586 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2587 "ex\t%1,%2"
2588 [(set_attr "op_type" "RX")
2589 (set_attr "type" "cs")])
2590
2591
2592 ;
2593 ; strlenM instruction pattern(s).
2594 ;
2595
2596 (define_expand "strlen<mode>"
2597 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2598 (parallel
2599 [(set (match_dup 4)
2600 (unspec:P [(const_int 0)
2601 (match_operand:BLK 1 "memory_operand" "")
2602 (reg:SI 0)
2603 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
2604 (clobber (scratch:P))
2605 (clobber (reg:CC CC_REGNUM))])
2606 (parallel
2607 [(set (match_operand:P 0 "register_operand" "")
2608 (minus:P (match_dup 4) (match_dup 5)))
2609 (clobber (reg:CC CC_REGNUM))])]
2610 ""
2611 {
2612 operands[4] = gen_reg_rtx (Pmode);
2613 operands[5] = gen_reg_rtx (Pmode);
2614 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2615 operands[1] = replace_equiv_address (operands[1], operands[5]);
2616 })
2617
2618 (define_insn "*strlen<mode>"
2619 [(set (match_operand:P 0 "register_operand" "=a")
2620 (unspec:P [(match_operand:P 2 "general_operand" "0")
2621 (mem:BLK (match_operand:P 3 "register_operand" "1"))
2622 (reg:SI 0)
2623 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
2624 (clobber (match_scratch:P 1 "=a"))
2625 (clobber (reg:CC CC_REGNUM))]
2626 ""
2627 "srst\t%0,%1\;jo\t.-4"
2628 [(set_attr "length" "8")
2629 (set_attr "type" "vs")])
2630
2631 ;
2632 ; cmpstrM instruction pattern(s).
2633 ;
2634
2635 (define_expand "cmpstrsi"
2636 [(set (reg:SI 0) (const_int 0))
2637 (parallel
2638 [(clobber (match_operand 3 "" ""))
2639 (clobber (match_dup 4))
2640 (set (reg:CCU CC_REGNUM)
2641 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2642 (match_operand:BLK 2 "memory_operand" "")))
2643 (use (reg:SI 0))])
2644 (parallel
2645 [(set (match_operand:SI 0 "register_operand" "=d")
2646 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_STRCMPCC_TO_INT))
2647 (clobber (reg:CC CC_REGNUM))])]
2648 ""
2649 {
2650 /* As the result of CMPINT is inverted compared to what we need,
2651 we have to swap the operands. */
2652 rtx op1 = operands[2];
2653 rtx op2 = operands[1];
2654 rtx addr1 = gen_reg_rtx (Pmode);
2655 rtx addr2 = gen_reg_rtx (Pmode);
2656
2657 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2658 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2659 operands[1] = replace_equiv_address_nv (op1, addr1);
2660 operands[2] = replace_equiv_address_nv (op2, addr2);
2661 operands[3] = addr1;
2662 operands[4] = addr2;
2663 })
2664
2665 (define_insn "*cmpstr<mode>"
2666 [(clobber (match_operand:P 0 "register_operand" "=d"))
2667 (clobber (match_operand:P 1 "register_operand" "=d"))
2668 (set (reg:CCU CC_REGNUM)
2669 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2670 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2671 (use (reg:SI 0))]
2672 ""
2673 "clst\t%0,%1\;jo\t.-4"
2674 [(set_attr "length" "8")
2675 (set_attr "type" "vs")])
2676
2677 ;
2678 ; movstr instruction pattern.
2679 ;
2680
2681 (define_expand "movstr"
2682 [(set (reg:SI 0) (const_int 0))
2683 (parallel
2684 [(clobber (match_dup 3))
2685 (set (match_operand:BLK 1 "memory_operand" "")
2686 (match_operand:BLK 2 "memory_operand" ""))
2687 (set (match_operand 0 "register_operand" "")
2688 (unspec [(match_dup 1)
2689 (match_dup 2)
2690 (reg:SI 0)] UNSPEC_MVST))
2691 (clobber (reg:CC CC_REGNUM))])]
2692 ""
2693 {
2694 rtx addr1 = gen_reg_rtx (Pmode);
2695 rtx addr2 = gen_reg_rtx (Pmode);
2696
2697 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2698 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
2699 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2700 operands[2] = replace_equiv_address_nv (operands[2], addr2);
2701 operands[3] = addr2;
2702 })
2703
2704 (define_insn "*movstr"
2705 [(clobber (match_operand:P 2 "register_operand" "=d"))
2706 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
2707 (mem:BLK (match_operand:P 3 "register_operand" "2")))
2708 (set (match_operand:P 0 "register_operand" "=d")
2709 (unspec [(mem:BLK (match_dup 1))
2710 (mem:BLK (match_dup 3))
2711 (reg:SI 0)] UNSPEC_MVST))
2712 (clobber (reg:CC CC_REGNUM))]
2713 ""
2714 "mvst\t%1,%2\;jo\t.-4"
2715 [(set_attr "length" "8")
2716 (set_attr "type" "vs")])
2717
2718
2719 ;
2720 ; movmemM instruction pattern(s).
2721 ;
2722
2723 (define_expand "movmem<mode>"
2724 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
2725 (match_operand:BLK 1 "memory_operand" "")) ; source
2726 (use (match_operand:GPR 2 "general_operand" "")) ; count
2727 (match_operand 3 "" "")]
2728 ""
2729 {
2730 if (s390_expand_movmem (operands[0], operands[1], operands[2]))
2731 DONE;
2732 else
2733 FAIL;
2734 })
2735
2736 ; Move a block that is up to 256 bytes in length.
2737 ; The block length is taken as (operands[2] % 256) + 1.
2738
2739 (define_expand "movmem_short"
2740 [(parallel
2741 [(set (match_operand:BLK 0 "memory_operand" "")
2742 (match_operand:BLK 1 "memory_operand" ""))
2743 (use (match_operand 2 "nonmemory_operand" ""))
2744 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2745 (clobber (match_dup 3))])]
2746 ""
2747 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2748
2749 (define_insn "*movmem_short"
2750 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2751 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
2752 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2753 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
2754 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
2755 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
2756 "#"
2757 [(set_attr "type" "cs")
2758 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
2759
2760 (define_split
2761 [(set (match_operand:BLK 0 "memory_operand" "")
2762 (match_operand:BLK 1 "memory_operand" ""))
2763 (use (match_operand 2 "const_int_operand" ""))
2764 (use (match_operand 3 "immediate_operand" ""))
2765 (clobber (scratch))]
2766 "reload_completed"
2767 [(parallel
2768 [(set (match_dup 0) (match_dup 1))
2769 (use (match_dup 2))])]
2770 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2771
2772 (define_split
2773 [(set (match_operand:BLK 0 "memory_operand" "")
2774 (match_operand:BLK 1 "memory_operand" ""))
2775 (use (match_operand 2 "register_operand" ""))
2776 (use (match_operand 3 "memory_operand" ""))
2777 (clobber (scratch))]
2778 "reload_completed"
2779 [(parallel
2780 [(unspec [(match_dup 2) (match_dup 3)
2781 (const_int 0)] UNSPEC_EXECUTE)
2782 (set (match_dup 0) (match_dup 1))
2783 (use (const_int 1))])]
2784 "")
2785
2786 (define_split
2787 [(set (match_operand:BLK 0 "memory_operand" "")
2788 (match_operand:BLK 1 "memory_operand" ""))
2789 (use (match_operand 2 "register_operand" ""))
2790 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2791 (clobber (scratch))]
2792 "TARGET_Z10 && reload_completed"
2793 [(parallel
2794 [(unspec [(match_dup 2) (const_int 0)
2795 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2796 (set (match_dup 0) (match_dup 1))
2797 (use (const_int 1))])]
2798 "operands[3] = gen_label_rtx ();")
2799
2800 (define_split
2801 [(set (match_operand:BLK 0 "memory_operand" "")
2802 (match_operand:BLK 1 "memory_operand" ""))
2803 (use (match_operand 2 "register_operand" ""))
2804 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2805 (clobber (match_operand 3 "register_operand" ""))]
2806 "reload_completed && TARGET_CPU_ZARCH"
2807 [(set (match_dup 3) (label_ref (match_dup 4)))
2808 (parallel
2809 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2810 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2811 (set (match_dup 0) (match_dup 1))
2812 (use (const_int 1))])]
2813 "operands[4] = gen_label_rtx ();")
2814
2815 ; Move a block of arbitrary length.
2816
2817 (define_expand "movmem_long"
2818 [(parallel
2819 [(clobber (match_dup 2))
2820 (clobber (match_dup 3))
2821 (set (match_operand:BLK 0 "memory_operand" "")
2822 (match_operand:BLK 1 "memory_operand" ""))
2823 (use (match_operand 2 "general_operand" ""))
2824 (use (match_dup 3))
2825 (clobber (reg:CC CC_REGNUM))])]
2826 ""
2827 {
2828 enum machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
2829 enum machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
2830 rtx reg0 = gen_reg_rtx (dreg_mode);
2831 rtx reg1 = gen_reg_rtx (dreg_mode);
2832 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
2833 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
2834 rtx len0 = gen_lowpart (Pmode, reg0);
2835 rtx len1 = gen_lowpart (Pmode, reg1);
2836
2837 emit_clobber (reg0);
2838 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2839 emit_move_insn (len0, operands[2]);
2840
2841 emit_clobber (reg1);
2842 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2843 emit_move_insn (len1, operands[2]);
2844
2845 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2846 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2847 operands[2] = reg0;
2848 operands[3] = reg1;
2849 })
2850
2851 (define_insn "*movmem_long"
2852 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2853 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2854 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2855 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
2856 (use (match_dup 2))
2857 (use (match_dup 3))
2858 (clobber (reg:CC CC_REGNUM))]
2859 "TARGET_64BIT || !TARGET_ZARCH"
2860 "mvcle\t%0,%1,0\;jo\t.-4"
2861 [(set_attr "length" "8")
2862 (set_attr "type" "vs")])
2863
2864 (define_insn "*movmem_long_31z"
2865 [(clobber (match_operand:TI 0 "register_operand" "=d"))
2866 (clobber (match_operand:TI 1 "register_operand" "=d"))
2867 (set (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
2868 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4)))
2869 (use (match_dup 2))
2870 (use (match_dup 3))
2871 (clobber (reg:CC CC_REGNUM))]
2872 "!TARGET_64BIT && TARGET_ZARCH"
2873 "mvcle\t%0,%1,0\;jo\t.-4"
2874 [(set_attr "length" "8")
2875 (set_attr "type" "vs")])
2876
2877
2878 ;
2879 ; Test data class.
2880 ;
2881
2882 (define_expand "signbit<mode>2"
2883 [(set (reg:CCZ CC_REGNUM)
2884 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2885 (match_dup 2)]
2886 UNSPEC_TDC_INSN))
2887 (set (match_operand:SI 0 "register_operand" "=d")
2888 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
2889 "TARGET_HARD_FLOAT"
2890 {
2891 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
2892 })
2893
2894 (define_expand "isinf<mode>2"
2895 [(set (reg:CCZ CC_REGNUM)
2896 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2897 (match_dup 2)]
2898 UNSPEC_TDC_INSN))
2899 (set (match_operand:SI 0 "register_operand" "=d")
2900 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
2901 "TARGET_HARD_FLOAT"
2902 {
2903 operands[2] = GEN_INT (S390_TDC_INFINITY);
2904 })
2905
2906 (define_insn_and_split "*cc_to_int"
2907 [(set (match_operand:SI 0 "register_operand" "=d")
2908 (unspec:SI [(match_operand 1 "register_operand" "0")]
2909 UNSPEC_CC_TO_INT))]
2910 "operands != NULL"
2911 "#"
2912 "reload_completed"
2913 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
2914
2915 ; This insn is used to generate all variants of the Test Data Class
2916 ; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
2917 ; is the register to be tested and the second one is the bit mask
2918 ; specifying the required test(s).
2919 ;
2920 ; tcxb, tcdb, tceb, tdcxt, tdcdt, tdcet
2921 (define_insn "*TDC_insn_<mode>"
2922 [(set (reg:CCZ CC_REGNUM)
2923 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
2924 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
2925 "TARGET_HARD_FLOAT"
2926 "t<_d>c<xde><bt>\t%0,%1"
2927 [(set_attr "op_type" "RXE")
2928 (set_attr "type" "fsimp<mode>")])
2929
2930
2931
2932 ;
2933 ; setmemM instruction pattern(s).
2934 ;
2935
2936 (define_expand "setmem<mode>"
2937 [(set (match_operand:BLK 0 "memory_operand" "")
2938 (match_operand:QI 2 "general_operand" ""))
2939 (use (match_operand:GPR 1 "general_operand" ""))
2940 (match_operand 3 "" "")]
2941 ""
2942 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
2943
2944 ; Clear a block that is up to 256 bytes in length.
2945 ; The block length is taken as (operands[1] % 256) + 1.
2946
2947 (define_expand "clrmem_short"
2948 [(parallel
2949 [(set (match_operand:BLK 0 "memory_operand" "")
2950 (const_int 0))
2951 (use (match_operand 1 "nonmemory_operand" ""))
2952 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2953 (clobber (match_dup 2))
2954 (clobber (reg:CC CC_REGNUM))])]
2955 ""
2956 "operands[2] = gen_rtx_SCRATCH (Pmode);")
2957
2958 (define_insn "*clrmem_short"
2959 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2960 (const_int 0))
2961 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
2962 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
2963 (clobber (match_scratch:P 3 "=X,X,X,&a"))
2964 (clobber (reg:CC CC_REGNUM))]
2965 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)"
2966 "#"
2967 [(set_attr "type" "cs")
2968 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
2969
2970 (define_split
2971 [(set (match_operand:BLK 0 "memory_operand" "")
2972 (const_int 0))
2973 (use (match_operand 1 "const_int_operand" ""))
2974 (use (match_operand 2 "immediate_operand" ""))
2975 (clobber (scratch))
2976 (clobber (reg:CC CC_REGNUM))]
2977 "reload_completed"
2978 [(parallel
2979 [(set (match_dup 0) (const_int 0))
2980 (use (match_dup 1))
2981 (clobber (reg:CC CC_REGNUM))])]
2982 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
2983
2984 (define_split
2985 [(set (match_operand:BLK 0 "memory_operand" "")
2986 (const_int 0))
2987 (use (match_operand 1 "register_operand" ""))
2988 (use (match_operand 2 "memory_operand" ""))
2989 (clobber (scratch))
2990 (clobber (reg:CC CC_REGNUM))]
2991 "reload_completed"
2992 [(parallel
2993 [(unspec [(match_dup 1) (match_dup 2)
2994 (const_int 0)] UNSPEC_EXECUTE)
2995 (set (match_dup 0) (const_int 0))
2996 (use (const_int 1))
2997 (clobber (reg:CC CC_REGNUM))])]
2998 "")
2999
3000 (define_split
3001 [(set (match_operand:BLK 0 "memory_operand" "")
3002 (const_int 0))
3003 (use (match_operand 1 "register_operand" ""))
3004 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3005 (clobber (scratch))
3006 (clobber (reg:CC CC_REGNUM))]
3007 "TARGET_Z10 && reload_completed"
3008 [(parallel
3009 [(unspec [(match_dup 1) (const_int 0)
3010 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3011 (set (match_dup 0) (const_int 0))
3012 (use (const_int 1))
3013 (clobber (reg:CC CC_REGNUM))])]
3014 "operands[3] = gen_label_rtx ();")
3015
3016 (define_split
3017 [(set (match_operand:BLK 0 "memory_operand" "")
3018 (const_int 0))
3019 (use (match_operand 1 "register_operand" ""))
3020 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3021 (clobber (match_operand 2 "register_operand" ""))
3022 (clobber (reg:CC CC_REGNUM))]
3023 "reload_completed && TARGET_CPU_ZARCH"
3024 [(set (match_dup 2) (label_ref (match_dup 3)))
3025 (parallel
3026 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
3027 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3028 (set (match_dup 0) (const_int 0))
3029 (use (const_int 1))
3030 (clobber (reg:CC CC_REGNUM))])]
3031 "operands[3] = gen_label_rtx ();")
3032
3033 ; Initialize a block of arbitrary length with (operands[2] % 256).
3034
3035 (define_expand "setmem_long"
3036 [(parallel
3037 [(clobber (match_dup 1))
3038 (set (match_operand:BLK 0 "memory_operand" "")
3039 (match_operand 2 "shift_count_or_setmem_operand" ""))
3040 (use (match_operand 1 "general_operand" ""))
3041 (use (match_dup 3))
3042 (clobber (reg:CC CC_REGNUM))])]
3043 ""
3044 {
3045 enum machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3046 enum machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
3047 rtx reg0 = gen_reg_rtx (dreg_mode);
3048 rtx reg1 = gen_reg_rtx (dreg_mode);
3049 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3050 rtx len0 = gen_lowpart (Pmode, reg0);
3051
3052 emit_clobber (reg0);
3053 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3054 emit_move_insn (len0, operands[1]);
3055
3056 emit_move_insn (reg1, const0_rtx);
3057
3058 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3059 operands[1] = reg0;
3060 operands[3] = reg1;
3061 })
3062
3063 (define_insn "*setmem_long"
3064 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3065 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3066 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
3067 (use (match_dup 3))
3068 (use (match_operand:<DBL> 1 "register_operand" "d"))
3069 (clobber (reg:CC CC_REGNUM))]
3070 "TARGET_64BIT || !TARGET_ZARCH"
3071 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3072 [(set_attr "length" "8")
3073 (set_attr "type" "vs")])
3074
3075 (define_insn "*setmem_long_and"
3076 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3077 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3078 (and (match_operand 2 "shift_count_or_setmem_operand" "Y")
3079 (match_operand 4 "const_int_operand" "n")))
3080 (use (match_dup 3))
3081 (use (match_operand:<DBL> 1 "register_operand" "d"))
3082 (clobber (reg:CC CC_REGNUM))]
3083 "(TARGET_64BIT || !TARGET_ZARCH) &&
3084 (INTVAL (operands[4]) & 255) == 255"
3085 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3086 [(set_attr "length" "8")
3087 (set_attr "type" "vs")])
3088
3089 (define_insn "*setmem_long_31z"
3090 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3091 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
3092 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
3093 (use (match_dup 3))
3094 (use (match_operand:TI 1 "register_operand" "d"))
3095 (clobber (reg:CC CC_REGNUM))]
3096 "!TARGET_64BIT && TARGET_ZARCH"
3097 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3098 [(set_attr "length" "8")
3099 (set_attr "type" "vs")])
3100
3101 ;
3102 ; cmpmemM instruction pattern(s).
3103 ;
3104
3105 (define_expand "cmpmemsi"
3106 [(set (match_operand:SI 0 "register_operand" "")
3107 (compare:SI (match_operand:BLK 1 "memory_operand" "")
3108 (match_operand:BLK 2 "memory_operand" "") ) )
3109 (use (match_operand:SI 3 "general_operand" ""))
3110 (use (match_operand:SI 4 "" ""))]
3111 ""
3112 {
3113 if (s390_expand_cmpmem (operands[0], operands[1],
3114 operands[2], operands[3]))
3115 DONE;
3116 else
3117 FAIL;
3118 })
3119
3120 ; Compare a block that is up to 256 bytes in length.
3121 ; The block length is taken as (operands[2] % 256) + 1.
3122
3123 (define_expand "cmpmem_short"
3124 [(parallel
3125 [(set (reg:CCU CC_REGNUM)
3126 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3127 (match_operand:BLK 1 "memory_operand" "")))
3128 (use (match_operand 2 "nonmemory_operand" ""))
3129 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3130 (clobber (match_dup 3))])]
3131 ""
3132 "operands[3] = gen_rtx_SCRATCH (Pmode);")
3133
3134 (define_insn "*cmpmem_short"
3135 [(set (reg:CCU CC_REGNUM)
3136 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
3137 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
3138 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3139 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
3140 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3141 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
3142 "#"
3143 [(set_attr "type" "cs")
3144 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
3145
3146 (define_split
3147 [(set (reg:CCU CC_REGNUM)
3148 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3149 (match_operand:BLK 1 "memory_operand" "")))
3150 (use (match_operand 2 "const_int_operand" ""))
3151 (use (match_operand 3 "immediate_operand" ""))
3152 (clobber (scratch))]
3153 "reload_completed"
3154 [(parallel
3155 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3156 (use (match_dup 2))])]
3157 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
3158
3159 (define_split
3160 [(set (reg:CCU CC_REGNUM)
3161 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3162 (match_operand:BLK 1 "memory_operand" "")))
3163 (use (match_operand 2 "register_operand" ""))
3164 (use (match_operand 3 "memory_operand" ""))
3165 (clobber (scratch))]
3166 "reload_completed"
3167 [(parallel
3168 [(unspec [(match_dup 2) (match_dup 3)
3169 (const_int 0)] UNSPEC_EXECUTE)
3170 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3171 (use (const_int 1))])]
3172 "")
3173
3174 (define_split
3175 [(set (reg:CCU CC_REGNUM)
3176 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3177 (match_operand:BLK 1 "memory_operand" "")))
3178 (use (match_operand 2 "register_operand" ""))
3179 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3180 (clobber (scratch))]
3181 "TARGET_Z10 && reload_completed"
3182 [(parallel
3183 [(unspec [(match_dup 2) (const_int 0)
3184 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3185 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3186 (use (const_int 1))])]
3187 "operands[4] = gen_label_rtx ();")
3188
3189 (define_split
3190 [(set (reg:CCU CC_REGNUM)
3191 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3192 (match_operand:BLK 1 "memory_operand" "")))
3193 (use (match_operand 2 "register_operand" ""))
3194 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3195 (clobber (match_operand 3 "register_operand" ""))]
3196 "reload_completed && TARGET_CPU_ZARCH"
3197 [(set (match_dup 3) (label_ref (match_dup 4)))
3198 (parallel
3199 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
3200 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3201 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3202 (use (const_int 1))])]
3203 "operands[4] = gen_label_rtx ();")
3204
3205 ; Compare a block of arbitrary length.
3206
3207 (define_expand "cmpmem_long"
3208 [(parallel
3209 [(clobber (match_dup 2))
3210 (clobber (match_dup 3))
3211 (set (reg:CCU CC_REGNUM)
3212 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3213 (match_operand:BLK 1 "memory_operand" "")))
3214 (use (match_operand 2 "general_operand" ""))
3215 (use (match_dup 3))])]
3216 ""
3217 {
3218 enum machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3219 enum machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
3220 rtx reg0 = gen_reg_rtx (dreg_mode);
3221 rtx reg1 = gen_reg_rtx (dreg_mode);
3222 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3223 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
3224 rtx len0 = gen_lowpart (Pmode, reg0);
3225 rtx len1 = gen_lowpart (Pmode, reg1);
3226
3227 emit_clobber (reg0);
3228 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3229 emit_move_insn (len0, operands[2]);
3230
3231 emit_clobber (reg1);
3232 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3233 emit_move_insn (len1, operands[2]);
3234
3235 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3236 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3237 operands[2] = reg0;
3238 operands[3] = reg1;
3239 })
3240
3241 (define_insn "*cmpmem_long"
3242 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3243 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3244 (set (reg:CCU CC_REGNUM)
3245 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3246 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
3247 (use (match_dup 2))
3248 (use (match_dup 3))]
3249 "TARGET_64BIT || !TARGET_ZARCH"
3250 "clcle\t%0,%1,0\;jo\t.-4"
3251 [(set_attr "length" "8")
3252 (set_attr "type" "vs")])
3253
3254 (define_insn "*cmpmem_long_31z"
3255 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3256 (clobber (match_operand:TI 1 "register_operand" "=d"))
3257 (set (reg:CCU CC_REGNUM)
3258 (compare:CCU (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3259 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4))))
3260 (use (match_dup 2))
3261 (use (match_dup 3))]
3262 "!TARGET_64BIT && TARGET_ZARCH"
3263 "clcle\t%0,%1,0\;jo\t.-4"
3264 [(set_attr "op_type" "NN")
3265 (set_attr "type" "vs")
3266 (set_attr "length" "8")])
3267
3268 ; Convert CCUmode condition code to integer.
3269 ; Result is zero if EQ, positive if LTU, negative if GTU.
3270
3271 (define_insn_and_split "cmpint"
3272 [(set (match_operand:SI 0 "register_operand" "=d")
3273 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3274 UNSPEC_STRCMPCC_TO_INT))
3275 (clobber (reg:CC CC_REGNUM))]
3276 ""
3277 "#"
3278 "reload_completed"
3279 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3280 (parallel
3281 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
3282 (clobber (reg:CC CC_REGNUM))])])
3283
3284 (define_insn_and_split "*cmpint_cc"
3285 [(set (reg CC_REGNUM)
3286 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3287 UNSPEC_STRCMPCC_TO_INT)
3288 (const_int 0)))
3289 (set (match_operand:SI 0 "register_operand" "=d")
3290 (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT))]
3291 "s390_match_ccmode (insn, CCSmode)"
3292 "#"
3293 "&& reload_completed"
3294 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3295 (parallel
3296 [(set (match_dup 2) (match_dup 3))
3297 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
3298 {
3299 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3300 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3301 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3302 })
3303
3304 (define_insn_and_split "*cmpint_sign"
3305 [(set (match_operand:DI 0 "register_operand" "=d")
3306 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3307 UNSPEC_STRCMPCC_TO_INT)))
3308 (clobber (reg:CC CC_REGNUM))]
3309 "TARGET_ZARCH"
3310 "#"
3311 "&& reload_completed"
3312 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3313 (parallel
3314 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
3315 (clobber (reg:CC CC_REGNUM))])])
3316
3317 (define_insn_and_split "*cmpint_sign_cc"
3318 [(set (reg CC_REGNUM)
3319 (compare (ashiftrt:DI (ashift:DI (subreg:DI
3320 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3321 UNSPEC_STRCMPCC_TO_INT) 0)
3322 (const_int 32)) (const_int 32))
3323 (const_int 0)))
3324 (set (match_operand:DI 0 "register_operand" "=d")
3325 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT)))]
3326 "s390_match_ccmode (insn, CCSmode) && TARGET_ZARCH"
3327 "#"
3328 "&& reload_completed"
3329 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3330 (parallel
3331 [(set (match_dup 2) (match_dup 3))
3332 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
3333 {
3334 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3335 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3336 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3337 })
3338
3339
3340 ;;
3341 ;;- Conversion instructions.
3342 ;;
3343
3344 (define_insn "*sethighpartsi"
3345 [(set (match_operand:SI 0 "register_operand" "=d,d")
3346 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3347 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3348 (clobber (reg:CC CC_REGNUM))]
3349 ""
3350 "@
3351 icm\t%0,%2,%S1
3352 icmy\t%0,%2,%S1"
3353 [(set_attr "op_type" "RS,RSY")
3354 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3355
3356 (define_insn "*sethighpartdi_64"
3357 [(set (match_operand:DI 0 "register_operand" "=d")
3358 (unspec:DI [(match_operand:BLK 1 "s_operand" "QS")
3359 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
3360 (clobber (reg:CC CC_REGNUM))]
3361 "TARGET_ZARCH"
3362 "icmh\t%0,%2,%S1"
3363 [(set_attr "op_type" "RSY")
3364 (set_attr "z10prop" "z10_super")])
3365
3366 (define_insn "*sethighpartdi_31"
3367 [(set (match_operand:DI 0 "register_operand" "=d,d")
3368 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3369 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3370 (clobber (reg:CC CC_REGNUM))]
3371 "!TARGET_ZARCH"
3372 "@
3373 icm\t%0,%2,%S1
3374 icmy\t%0,%2,%S1"
3375 [(set_attr "op_type" "RS,RSY")
3376 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3377
3378 ;
3379 ; extv instruction patterns
3380 ;
3381
3382 ; FIXME: This expander needs to be converted from DI to GPR as well
3383 ; after resolving some issues with it.
3384
3385 (define_expand "extzv"
3386 [(parallel
3387 [(set (match_operand:DI 0 "register_operand" "=d")
3388 (zero_extract:DI
3389 (match_operand:DI 1 "register_operand" "d")
3390 (match_operand 2 "const_int_operand" "") ; size
3391 (match_operand 3 "const_int_operand" ""))) ; start
3392 (clobber (reg:CC CC_REGNUM))])]
3393 "TARGET_Z10"
3394 {
3395 /* Starting with zEC12 there is risbgn not clobbering CC. */
3396 if (TARGET_ZEC12)
3397 {
3398 emit_move_insn (operands[0],
3399 gen_rtx_ZERO_EXTRACT (DImode,
3400 operands[1],
3401 operands[2],
3402 operands[3]));
3403 DONE;
3404 }
3405 })
3406
3407 (define_insn "*extzv<mode>_zEC12"
3408 [(set (match_operand:GPR 0 "register_operand" "=d")
3409 (zero_extract:GPR
3410 (match_operand:GPR 1 "register_operand" "d")
3411 (match_operand 2 "const_int_operand" "") ; size
3412 (match_operand 3 "const_int_operand" "")))] ; start]
3413 "TARGET_ZEC12"
3414 "risbgn\t%0,%1,64-%2,128+63,<bitsize>+%3+%2" ; dst, src, start, end, shift
3415 [(set_attr "op_type" "RIE")])
3416
3417 (define_insn "*extzv<mode>_z10"
3418 [(set (match_operand:GPR 0 "register_operand" "=d")
3419 (zero_extract:GPR
3420 (match_operand:GPR 1 "register_operand" "d")
3421 (match_operand 2 "const_int_operand" "") ; size
3422 (match_operand 3 "const_int_operand" ""))) ; start
3423 (clobber (reg:CC CC_REGNUM))]
3424 "TARGET_Z10"
3425 "risbg\t%0,%1,64-%2,128+63,<bitsize>+%3+%2" ; dst, src, start, end, shift
3426 [(set_attr "op_type" "RIE")
3427 (set_attr "z10prop" "z10_super_E1")])
3428
3429 (define_insn_and_split "*pre_z10_extzv<mode>"
3430 [(set (match_operand:GPR 0 "register_operand" "=d")
3431 (zero_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3432 (match_operand 2 "nonzero_shift_count_operand" "")
3433 (const_int 0)))
3434 (clobber (reg:CC CC_REGNUM))]
3435 "!TARGET_Z10"
3436 "#"
3437 "&& reload_completed"
3438 [(parallel
3439 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3440 (clobber (reg:CC CC_REGNUM))])
3441 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
3442 {
3443 int bitsize = INTVAL (operands[2]);
3444 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3445 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3446
3447 operands[1] = adjust_address (operands[1], BLKmode, 0);
3448 set_mem_size (operands[1], size);
3449 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
3450 operands[3] = GEN_INT (mask);
3451 })
3452
3453 (define_insn_and_split "*pre_z10_extv<mode>"
3454 [(set (match_operand:GPR 0 "register_operand" "=d")
3455 (sign_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3456 (match_operand 2 "nonzero_shift_count_operand" "")
3457 (const_int 0)))
3458 (clobber (reg:CC CC_REGNUM))]
3459 ""
3460 "#"
3461 "&& reload_completed"
3462 [(parallel
3463 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3464 (clobber (reg:CC CC_REGNUM))])
3465 (parallel
3466 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3467 (clobber (reg:CC CC_REGNUM))])]
3468 {
3469 int bitsize = INTVAL (operands[2]);
3470 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3471 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3472
3473 operands[1] = adjust_address (operands[1], BLKmode, 0);
3474 set_mem_size (operands[1], size);
3475 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
3476 operands[3] = GEN_INT (mask);
3477 })
3478
3479 ;
3480 ; insv instruction patterns
3481 ;
3482
3483 (define_expand "insv"
3484 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3485 (match_operand 1 "const_int_operand" "")
3486 (match_operand 2 "const_int_operand" ""))
3487 (match_operand 3 "general_operand" ""))]
3488 ""
3489 {
3490 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3491 DONE;
3492 FAIL;
3493 })
3494
3495
3496 ; The normal RTL expansion will never generate a zero_extract where
3497 ; the location operand isn't word mode. However, we do this in the
3498 ; back-end when generating atomic operations. See s390_two_part_insv.
3499 (define_insn "*insv<mode>_zEC12"
3500 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
3501 (match_operand 1 "const_int_operand" "I") ; size
3502 (match_operand 2 "const_int_operand" "I")) ; pos
3503 (match_operand:GPR 3 "nonimmediate_operand" "d"))]
3504 "TARGET_ZEC12
3505 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
3506 "risbgn\t%0,%3,64-<bitsize>+%2,64-<bitsize>+%2+%1-1,<bitsize>-%2-%1"
3507 [(set_attr "op_type" "RIE")])
3508
3509 (define_insn "*insv<mode>_z10"
3510 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
3511 (match_operand 1 "const_int_operand" "I") ; size
3512 (match_operand 2 "const_int_operand" "I")) ; pos
3513 (match_operand:GPR 3 "nonimmediate_operand" "d"))
3514 (clobber (reg:CC CC_REGNUM))]
3515 "TARGET_Z10
3516 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
3517 "risbg\t%0,%3,64-<bitsize>+%2,64-<bitsize>+%2+%1-1,<bitsize>-%2-%1"
3518 [(set_attr "op_type" "RIE")
3519 (set_attr "z10prop" "z10_super_E1")])
3520
3521 ; and op1 with a mask being 1 for the selected bits and 0 for the rest
3522 ; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
3523 (define_insn "*insv<mode>_zEC12_noshift"
3524 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3525 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3526 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3527 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
3528 (match_operand:GPR 4 "const_int_operand" ""))))]
3529 "TARGET_ZEC12 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3530 "risbgn\t%0,%1,%<bfstart>2,%<bfend>2,0"
3531 [(set_attr "op_type" "RIE")])
3532
3533 (define_insn "*insv<mode>_z10_noshift"
3534 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3535 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3536 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3537 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
3538 (match_operand:GPR 4 "const_int_operand" ""))))
3539 (clobber (reg:CC CC_REGNUM))]
3540 "TARGET_Z10 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3541 "risbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
3542 [(set_attr "op_type" "RIE")
3543 (set_attr "z10prop" "z10_super_E1")])
3544
3545 (define_insn "*r<noxa>sbg_<mode>_noshift"
3546 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3547 (IXOR:GPR
3548 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3549 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3550 (match_operand:GPR 3 "nonimmediate_operand" "0")))
3551 (clobber (reg:CC CC_REGNUM))]
3552 "TARGET_Z10"
3553 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
3554 [(set_attr "op_type" "RIE")])
3555
3556 (define_insn "*r<noxa>sbg_di_rotl"
3557 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3558 (IXOR:DI
3559 (and:DI
3560 (rotate:DI
3561 (match_operand:DI 1 "nonimmediate_operand" "d")
3562 (match_operand:DI 3 "const_int_operand" ""))
3563 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
3564 (match_operand:DI 4 "nonimmediate_operand" "0")))
3565 (clobber (reg:CC CC_REGNUM))]
3566 "TARGET_Z10"
3567 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%b3"
3568 [(set_attr "op_type" "RIE")])
3569
3570 (define_insn "*r<noxa>sbg_<mode>_srl"
3571 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3572 (IXOR:GPR
3573 (and:GPR
3574 (lshiftrt:GPR
3575 (match_operand:GPR 1 "nonimmediate_operand" "d")
3576 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
3577 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3578 (match_operand:GPR 4 "nonimmediate_operand" "0")))
3579 (clobber (reg:CC CC_REGNUM))]
3580 "TARGET_Z10
3581 && s390_extzv_shift_ok (<bitsize>, 64 - INTVAL (operands[3]),
3582 INTVAL (operands[2]))"
3583 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,64-%3"
3584 [(set_attr "op_type" "RIE")])
3585
3586 (define_insn "*r<noxa>sbg_<mode>_sll"
3587 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3588 (IXOR:GPR
3589 (and:GPR
3590 (ashift:GPR
3591 (match_operand:GPR 1 "nonimmediate_operand" "d")
3592 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
3593 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3594 (match_operand:GPR 4 "nonimmediate_operand" "0")))
3595 (clobber (reg:CC CC_REGNUM))]
3596 "TARGET_Z10
3597 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[3]),
3598 INTVAL (operands[2]))"
3599 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%3"
3600 [(set_attr "op_type" "RIE")])
3601
3602 ;; These two are generated by combine for s.bf &= val.
3603 ;; ??? For bitfields smaller than 32-bits, we wind up with SImode
3604 ;; shifts and ands, which results in some truly awful patterns
3605 ;; including subregs of operations. Rather unnecessisarily, IMO.
3606 ;; Instead of
3607 ;;
3608 ;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
3609 ;; (const_int 24 [0x18])
3610 ;; (const_int 0 [0]))
3611 ;; (subreg:DI (and:SI (subreg:SI (lshiftrt:DI (reg/v:DI 50 [ s ])
3612 ;; (const_int 40 [0x28])) 4)
3613 ;; (reg:SI 4 %r4 [ y+4 ])) 0))
3614 ;;
3615 ;; we should instead generate
3616 ;;
3617 ;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
3618 ;; (const_int 24 [0x18])
3619 ;; (const_int 0 [0]))
3620 ;; (and:DI (lshiftrt:DI (reg/v:DI 50 [ s ])
3621 ;; (const_int 40 [0x28]))
3622 ;; (subreg:DI (reg:SI 4 %r4 [ y+4 ]) 0)))
3623 ;;
3624 ;; by noticing that we can push down the outer paradoxical subreg
3625 ;; into the operation.
3626
3627 (define_insn "*insv_rnsbg_noshift"
3628 [(set (zero_extract:DI
3629 (match_operand:DI 0 "nonimmediate_operand" "+d")
3630 (match_operand 1 "const_int_operand" "")
3631 (match_operand 2 "const_int_operand" ""))
3632 (and:DI
3633 (match_dup 0)
3634 (match_operand:DI 3 "nonimmediate_operand" "d")))
3635 (clobber (reg:CC CC_REGNUM))]
3636 "TARGET_Z10
3637 && INTVAL (operands[1]) + INTVAL (operands[2]) == 64"
3638 "rnsbg\t%0,%3,%2,63,0"
3639 [(set_attr "op_type" "RIE")])
3640
3641 (define_insn "*insv_rnsbg_srl"
3642 [(set (zero_extract:DI
3643 (match_operand:DI 0 "nonimmediate_operand" "+d")
3644 (match_operand 1 "const_int_operand" "")
3645 (match_operand 2 "const_int_operand" ""))
3646 (and:DI
3647 (lshiftrt:DI
3648 (match_dup 0)
3649 (match_operand 3 "const_int_operand" ""))
3650 (match_operand:DI 4 "nonimmediate_operand" "d")))
3651 (clobber (reg:CC CC_REGNUM))]
3652 "TARGET_Z10
3653 && INTVAL (operands[3]) == 64 - INTVAL (operands[1]) - INTVAL (operands[2])"
3654 "rnsbg\t%0,%4,%2,%2+%1-1,%3"
3655 [(set_attr "op_type" "RIE")])
3656
3657 (define_insn "*insv<mode>_mem_reg"
3658 [(set (zero_extract:W (match_operand:QI 0 "memory_operand" "+Q,S")
3659 (match_operand 1 "const_int_operand" "n,n")
3660 (const_int 0))
3661 (match_operand:W 2 "register_operand" "d,d"))]
3662 "INTVAL (operands[1]) > 0
3663 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3664 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3665 {
3666 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3667
3668 operands[1] = GEN_INT ((1ul << size) - 1);
3669 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
3670 : "stcmy\t%2,%1,%S0";
3671 }
3672 [(set_attr "op_type" "RS,RSY")
3673 (set_attr "z10prop" "z10_super,z10_super")])
3674
3675 (define_insn "*insvdi_mem_reghigh"
3676 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+QS")
3677 (match_operand 1 "const_int_operand" "n")
3678 (const_int 0))
3679 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
3680 (const_int 32)))]
3681 "TARGET_ZARCH
3682 && INTVAL (operands[1]) > 0
3683 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3684 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3685 {
3686 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3687
3688 operands[1] = GEN_INT ((1ul << size) - 1);
3689 return "stcmh\t%2,%1,%S0";
3690 }
3691 [(set_attr "op_type" "RSY")
3692 (set_attr "z10prop" "z10_super")])
3693
3694 (define_insn "*insvdi_reg_imm"
3695 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3696 (const_int 16)
3697 (match_operand 1 "const_int_operand" "n"))
3698 (match_operand:DI 2 "const_int_operand" "n"))]
3699 "TARGET_ZARCH
3700 && INTVAL (operands[1]) >= 0
3701 && INTVAL (operands[1]) < BITS_PER_WORD
3702 && INTVAL (operands[1]) % 16 == 0"
3703 {
3704 switch (BITS_PER_WORD - INTVAL (operands[1]))
3705 {
3706 case 64: return "iihh\t%0,%x2"; break;
3707 case 48: return "iihl\t%0,%x2"; break;
3708 case 32: return "iilh\t%0,%x2"; break;
3709 case 16: return "iill\t%0,%x2"; break;
3710 default: gcc_unreachable();
3711 }
3712 }
3713 [(set_attr "op_type" "RI")
3714 (set_attr "z10prop" "z10_super_E1")])
3715
3716 ; Update the left-most 32 bit of a DI.
3717 (define_insn "*insv_h_di_reg_extimm"
3718 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3719 (const_int 32)
3720 (const_int 0))
3721 (match_operand:DI 1 "const_int_operand" "n"))]
3722 "TARGET_EXTIMM"
3723 "iihf\t%0,%o1"
3724 [(set_attr "op_type" "RIL")
3725 (set_attr "z10prop" "z10_fwd_E1")])
3726
3727 ; Update the right-most 32 bit of a DI.
3728 (define_insn "*insv_l_di_reg_extimm"
3729 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3730 (const_int 32)
3731 (const_int 32))
3732 (match_operand:DI 1 "const_int_operand" "n"))]
3733 "TARGET_EXTIMM"
3734 "iilf\t%0,%o1"
3735 [(set_attr "op_type" "RIL")
3736 (set_attr "z10prop" "z10_fwd_A1")])
3737
3738 ;
3739 ; extendsidi2 instruction pattern(s).
3740 ;
3741
3742 (define_expand "extendsidi2"
3743 [(set (match_operand:DI 0 "register_operand" "")
3744 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3745 ""
3746 {
3747 if (!TARGET_ZARCH)
3748 {
3749 emit_clobber (operands[0]);
3750 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
3751 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
3752 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
3753 DONE;
3754 }
3755 })
3756
3757 (define_insn "*extendsidi2"
3758 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3759 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3760 "TARGET_ZARCH"
3761 "@
3762 lgfr\t%0,%1
3763 lgf\t%0,%1
3764 lgfrl\t%0,%1"
3765 [(set_attr "op_type" "RRE,RXY,RIL")
3766 (set_attr "type" "*,*,larl")
3767 (set_attr "cpu_facility" "*,*,z10")
3768 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3769
3770 ;
3771 ; extend(hi|qi)(si|di)2 instruction pattern(s).
3772 ;
3773
3774 (define_expand "extend<HQI:mode><DSI:mode>2"
3775 [(set (match_operand:DSI 0 "register_operand" "")
3776 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3777 ""
3778 {
3779 if (<DSI:MODE>mode == DImode && !TARGET_ZARCH)
3780 {
3781 rtx tmp = gen_reg_rtx (SImode);
3782 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
3783 emit_insn (gen_extendsidi2 (operands[0], tmp));
3784 DONE;
3785 }
3786 else if (!TARGET_EXTIMM)
3787 {
3788 rtx bitcount = GEN_INT (<DSI:bitsize> - <HQI:bitsize>);
3789
3790 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
3791 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
3792 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
3793 DONE;
3794 }
3795 })
3796
3797 ;
3798 ; extendhidi2 instruction pattern(s).
3799 ;
3800
3801 (define_insn "*extendhidi2_extimm"
3802 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3803 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,RT,b")))]
3804 "TARGET_ZARCH && TARGET_EXTIMM"
3805 "@
3806 lghr\t%0,%1
3807 lgh\t%0,%1
3808 lghrl\t%0,%1"
3809 [(set_attr "op_type" "RRE,RXY,RIL")
3810 (set_attr "type" "*,*,larl")
3811 (set_attr "cpu_facility" "extimm,extimm,z10")
3812 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3813
3814 (define_insn "*extendhidi2"
3815 [(set (match_operand:DI 0 "register_operand" "=d")
3816 (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT")))]
3817 "TARGET_ZARCH"
3818 "lgh\t%0,%1"
3819 [(set_attr "op_type" "RXY")
3820 (set_attr "z10prop" "z10_super_E1")])
3821
3822 ;
3823 ; extendhisi2 instruction pattern(s).
3824 ;
3825
3826 (define_insn "*extendhisi2_extimm"
3827 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3828 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
3829 "TARGET_EXTIMM"
3830 "@
3831 lhr\t%0,%1
3832 lh\t%0,%1
3833 lhy\t%0,%1
3834 lhrl\t%0,%1"
3835 [(set_attr "op_type" "RRE,RX,RXY,RIL")
3836 (set_attr "type" "*,*,*,larl")
3837 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
3838 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
3839
3840 (define_insn "*extendhisi2"
3841 [(set (match_operand:SI 0 "register_operand" "=d,d")
3842 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
3843 "!TARGET_EXTIMM"
3844 "@
3845 lh\t%0,%1
3846 lhy\t%0,%1"
3847 [(set_attr "op_type" "RX,RXY")
3848 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3849
3850 ;
3851 ; extendqi(si|di)2 instruction pattern(s).
3852 ;
3853
3854 ; lbr, lgbr, lb, lgb
3855 (define_insn "*extendqi<mode>2_extimm"
3856 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3857 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,RT")))]
3858 "TARGET_EXTIMM"
3859 "@
3860 l<g>br\t%0,%1
3861 l<g>b\t%0,%1"
3862 [(set_attr "op_type" "RRE,RXY")
3863 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3864
3865 ; lb, lgb
3866 (define_insn "*extendqi<mode>2"
3867 [(set (match_operand:GPR 0 "register_operand" "=d")
3868 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "RT")))]
3869 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
3870 "l<g>b\t%0,%1"
3871 [(set_attr "op_type" "RXY")
3872 (set_attr "z10prop" "z10_super_E1")])
3873
3874 (define_insn_and_split "*extendqi<mode>2_short_displ"
3875 [(set (match_operand:GPR 0 "register_operand" "=d")
3876 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
3877 (clobber (reg:CC CC_REGNUM))]
3878 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
3879 "#"
3880 "&& reload_completed"
3881 [(parallel
3882 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
3883 (clobber (reg:CC CC_REGNUM))])
3884 (parallel
3885 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3886 (clobber (reg:CC CC_REGNUM))])]
3887 {
3888 operands[1] = adjust_address (operands[1], BLKmode, 0);
3889 set_mem_size (operands[1], GET_MODE_SIZE (QImode));
3890 operands[2] = GEN_INT (<GPR:bitsize> - BITS_PER_UNIT);
3891 })
3892
3893 ;
3894 ; zero_extendsidi2 instruction pattern(s).
3895 ;
3896
3897 (define_expand "zero_extendsidi2"
3898 [(set (match_operand:DI 0 "register_operand" "")
3899 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3900 ""
3901 {
3902 if (!TARGET_ZARCH)
3903 {
3904 emit_clobber (operands[0]);
3905 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
3906 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
3907 DONE;
3908 }
3909 })
3910
3911 (define_insn "*zero_extendsidi2"
3912 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3913 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3914 "TARGET_ZARCH"
3915 "@
3916 llgfr\t%0,%1
3917 llgf\t%0,%1
3918 llgfrl\t%0,%1"
3919 [(set_attr "op_type" "RRE,RXY,RIL")
3920 (set_attr "type" "*,*,larl")
3921 (set_attr "cpu_facility" "*,*,z10")
3922 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
3923
3924 ;
3925 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
3926 ;
3927
3928 (define_insn "*llgt_sidi"
3929 [(set (match_operand:DI 0 "register_operand" "=d")
3930 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3931 (const_int 2147483647)))]
3932 "TARGET_ZARCH"
3933 "llgt\t%0,%1"
3934 [(set_attr "op_type" "RXE")
3935 (set_attr "z10prop" "z10_super_E1")])
3936
3937 (define_insn_and_split "*llgt_sidi_split"
3938 [(set (match_operand:DI 0 "register_operand" "=d")
3939 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3940 (const_int 2147483647)))
3941 (clobber (reg:CC CC_REGNUM))]
3942 "TARGET_ZARCH"
3943 "#"
3944 "&& reload_completed"
3945 [(set (match_dup 0)
3946 (and:DI (subreg:DI (match_dup 1) 0)
3947 (const_int 2147483647)))]
3948 "")
3949
3950 (define_insn "*llgt_sisi"
3951 [(set (match_operand:SI 0 "register_operand" "=d,d")
3952 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,RT")
3953 (const_int 2147483647)))]
3954 "TARGET_ZARCH"
3955 "@
3956 llgtr\t%0,%1
3957 llgt\t%0,%1"
3958 [(set_attr "op_type" "RRE,RXE")
3959 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3960
3961 (define_insn "*llgt_didi"
3962 [(set (match_operand:DI 0 "register_operand" "=d,d")
3963 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
3964 (const_int 2147483647)))]
3965 "TARGET_ZARCH"
3966 "@
3967 llgtr\t%0,%1
3968 llgt\t%0,%N1"
3969 [(set_attr "op_type" "RRE,RXE")
3970 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3971
3972 (define_split
3973 [(set (match_operand:DSI 0 "register_operand" "")
3974 (and:DSI (match_operand:DSI 1 "nonimmediate_operand" "")
3975 (const_int 2147483647)))
3976 (clobber (reg:CC CC_REGNUM))]
3977 "TARGET_ZARCH && reload_completed"
3978 [(set (match_dup 0)
3979 (and:DSI (match_dup 1)
3980 (const_int 2147483647)))]
3981 "")
3982
3983 ;
3984 ; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
3985 ;
3986
3987 (define_expand "zero_extend<mode>di2"
3988 [(set (match_operand:DI 0 "register_operand" "")
3989 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3990 ""
3991 {
3992 if (!TARGET_ZARCH)
3993 {
3994 rtx tmp = gen_reg_rtx (SImode);
3995 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
3996 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
3997 DONE;
3998 }
3999 else if (!TARGET_EXTIMM)
4000 {
4001 rtx bitcount = GEN_INT (64 - <HQI:bitsize>);
4002 operands[1] = gen_lowpart (DImode, operands[1]);
4003 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
4004 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
4005 DONE;
4006 }
4007 })
4008
4009 (define_expand "zero_extend<mode>si2"
4010 [(set (match_operand:SI 0 "register_operand" "")
4011 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4012 ""
4013 {
4014 if (!TARGET_EXTIMM)
4015 {
4016 operands[1] = gen_lowpart (SImode, operands[1]);
4017 emit_insn (gen_andsi3 (operands[0], operands[1],
4018 GEN_INT ((1 << <HQI:bitsize>) - 1)));
4019 DONE;
4020 }
4021 })
4022
4023 ; llhrl, llghrl
4024 (define_insn "*zero_extendhi<mode>2_z10"
4025 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
4026 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,RT,b")))]
4027 "TARGET_Z10"
4028 "@
4029 ll<g>hr\t%0,%1
4030 ll<g>h\t%0,%1
4031 ll<g>hrl\t%0,%1"
4032 [(set_attr "op_type" "RXY,RRE,RIL")
4033 (set_attr "type" "*,*,larl")
4034 (set_attr "cpu_facility" "*,*,z10")
4035 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
4036
4037 ; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
4038 (define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
4039 [(set (match_operand:GPR 0 "register_operand" "=d,d")
4040 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,RT")))]
4041 "TARGET_EXTIMM"
4042 "@
4043 ll<g><hc>r\t%0,%1
4044 ll<g><hc>\t%0,%1"
4045 [(set_attr "op_type" "RRE,RXY")
4046 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
4047
4048 ; llgh, llgc
4049 (define_insn "*zero_extend<HQI:mode><GPR:mode>2"
4050 [(set (match_operand:GPR 0 "register_operand" "=d")
4051 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "RT")))]
4052 "TARGET_ZARCH && !TARGET_EXTIMM"
4053 "llg<hc>\t%0,%1"
4054 [(set_attr "op_type" "RXY")
4055 (set_attr "z10prop" "z10_fwd_A3")])
4056
4057 (define_insn_and_split "*zero_extendhisi2_31"
4058 [(set (match_operand:SI 0 "register_operand" "=&d")
4059 (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
4060 (clobber (reg:CC CC_REGNUM))]
4061 "!TARGET_ZARCH"
4062 "#"
4063 "&& reload_completed"
4064 [(set (match_dup 0) (const_int 0))
4065 (parallel
4066 [(set (strict_low_part (match_dup 2)) (match_dup 1))
4067 (clobber (reg:CC CC_REGNUM))])]
4068 "operands[2] = gen_lowpart (HImode, operands[0]);")
4069
4070 (define_insn_and_split "*zero_extendqisi2_31"
4071 [(set (match_operand:SI 0 "register_operand" "=&d")
4072 (zero_extend:SI (match_operand:QI 1 "memory_operand" "RT")))]
4073 "!TARGET_ZARCH"
4074 "#"
4075 "&& reload_completed"
4076 [(set (match_dup 0) (const_int 0))
4077 (set (strict_low_part (match_dup 2)) (match_dup 1))]
4078 "operands[2] = gen_lowpart (QImode, operands[0]);")
4079
4080 ;
4081 ; zero_extendqihi2 instruction pattern(s).
4082 ;
4083
4084 (define_expand "zero_extendqihi2"
4085 [(set (match_operand:HI 0 "register_operand" "")
4086 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
4087 "TARGET_ZARCH && !TARGET_EXTIMM"
4088 {
4089 operands[1] = gen_lowpart (HImode, operands[1]);
4090 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
4091 DONE;
4092 })
4093
4094 (define_insn "*zero_extendqihi2_64"
4095 [(set (match_operand:HI 0 "register_operand" "=d")
4096 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
4097 "TARGET_ZARCH && !TARGET_EXTIMM"
4098 "llgc\t%0,%1"
4099 [(set_attr "op_type" "RXY")
4100 (set_attr "z10prop" "z10_fwd_A3")])
4101
4102 (define_insn_and_split "*zero_extendqihi2_31"
4103 [(set (match_operand:HI 0 "register_operand" "=&d")
4104 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
4105 "!TARGET_ZARCH"
4106 "#"
4107 "&& reload_completed"
4108 [(set (match_dup 0) (const_int 0))
4109 (set (strict_low_part (match_dup 2)) (match_dup 1))]
4110 "operands[2] = gen_lowpart (QImode, operands[0]);")
4111
4112 ;
4113 ; fixuns_trunc(dd|td)di2 instruction pattern(s).
4114 ;
4115
4116 (define_expand "fixuns_truncdddi2"
4117 [(parallel
4118 [(set (match_operand:DI 0 "register_operand" "")
4119 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
4120 (unspec:DI [(const_int 5)] UNSPEC_ROUND)
4121 (clobber (reg:CC CC_REGNUM))])]
4122
4123 "TARGET_HARD_DFP"
4124 {
4125 if (!TARGET_Z196)
4126 {
4127 rtx label1 = gen_label_rtx ();
4128 rtx label2 = gen_label_rtx ();
4129 rtx temp = gen_reg_rtx (TDmode);
4130 REAL_VALUE_TYPE cmp, sub;
4131
4132 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4133 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4134
4135 /* 2^63 can't be represented as 64bit DFP number with full precision. The
4136 solution is doing the check and the subtraction in TD mode and using a
4137 TD -> DI convert afterwards. */
4138 emit_insn (gen_extendddtd2 (temp, operands[1]));
4139 temp = force_reg (TDmode, temp);
4140 emit_cmp_and_jump_insns (temp,
4141 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode),
4142 LT, NULL_RTX, VOIDmode, 0, label1);
4143 emit_insn (gen_subtd3 (temp, temp,
4144 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
4145 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
4146 emit_jump (label2);
4147
4148 emit_label (label1);
4149 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1], GEN_INT (9)));
4150 emit_label (label2);
4151 DONE;
4152 }
4153 })
4154
4155 (define_expand "fixuns_trunctddi2"
4156 [(parallel
4157 [(set (match_operand:DI 0 "register_operand" "")
4158 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))
4159 (unspec:DI [(const_int 5)] UNSPEC_ROUND)
4160 (clobber (reg:CC CC_REGNUM))])]
4161
4162 "TARGET_HARD_DFP"
4163 {
4164 if (!TARGET_Z196)
4165 {
4166 rtx label1 = gen_label_rtx ();
4167 rtx label2 = gen_label_rtx ();
4168 rtx temp = gen_reg_rtx (TDmode);
4169 REAL_VALUE_TYPE cmp, sub;
4170
4171 operands[1] = force_reg (TDmode, operands[1]);
4172 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4173 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4174
4175 emit_cmp_and_jump_insns (operands[1],
4176 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode),
4177 LT, NULL_RTX, VOIDmode, 0, label1);
4178 emit_insn (gen_subtd3 (temp, operands[1],
4179 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
4180 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
4181 emit_jump (label2);
4182
4183 emit_label (label1);
4184 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1], GEN_INT (9)));
4185 emit_label (label2);
4186 DONE;
4187 }
4188 })
4189
4190 ;
4191 ; fixuns_trunc(sf|df|tf)(si|di)2 and fix_trunc(sf|df|tf)(si|di)2
4192 ; instruction pattern(s).
4193 ;
4194
4195 (define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
4196 [(parallel
4197 [(set (match_operand:GPR 0 "register_operand" "")
4198 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))
4199 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
4200 (clobber (reg:CC CC_REGNUM))])]
4201 "TARGET_HARD_FLOAT"
4202 {
4203 if (!TARGET_Z196)
4204 {
4205 rtx label1 = gen_label_rtx ();
4206 rtx label2 = gen_label_rtx ();
4207 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
4208 REAL_VALUE_TYPE cmp, sub;
4209
4210 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
4211 real_2expN (&cmp, <GPR:bitsize> - 1, <BFP:MODE>mode);
4212 real_2expN (&sub, <GPR:bitsize>, <BFP:MODE>mode);
4213
4214 emit_cmp_and_jump_insns (operands[1],
4215 CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode),
4216 LT, NULL_RTX, VOIDmode, 0, label1);
4217 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
4218 CONST_DOUBLE_FROM_REAL_VALUE (sub, <BFP:MODE>mode)));
4219 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
4220 GEN_INT (7)));
4221 emit_jump (label2);
4222
4223 emit_label (label1);
4224 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
4225 operands[1], GEN_INT (5)));
4226 emit_label (label2);
4227 DONE;
4228 }
4229 })
4230
4231 ; fixuns_trunc(td|dd)si2 expander
4232 (define_expand "fixuns_trunc<mode>si2"
4233 [(parallel
4234 [(set (match_operand:SI 0 "register_operand" "")
4235 (unsigned_fix:SI (match_operand:DFP 1 "register_operand" "")))
4236 (unspec:SI [(const_int 5)] UNSPEC_ROUND)
4237 (clobber (reg:CC CC_REGNUM))])]
4238 "TARGET_Z196 && TARGET_HARD_DFP"
4239 "")
4240
4241 ; fixuns_trunc(tf|df|sf|td|dd)(di|si)2 instruction patterns.
4242
4243 ; clfebr, clfdbr, clfxbr, clgebr, clgdbr, clgxbr
4244 ; clfdtr, clfxtr, clgdtr, clgxtr
4245 (define_insn "*fixuns_trunc<FP:mode><GPR:mode>2_z196"
4246 [(set (match_operand:GPR 0 "register_operand" "=r")
4247 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "f")))
4248 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4249 (clobber (reg:CC CC_REGNUM))]
4250 "TARGET_Z196"
4251 "cl<GPR:gf><FP:xde><FP:bt>r\t%0,%h2,%1,0"
4252 [(set_attr "op_type" "RRF")
4253 (set_attr "type" "ftoi")])
4254
4255 (define_expand "fix_trunc<DSF:mode><GPR:mode>2"
4256 [(set (match_operand:GPR 0 "register_operand" "")
4257 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
4258 "TARGET_HARD_FLOAT"
4259 {
4260 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
4261 GEN_INT (5)));
4262 DONE;
4263 })
4264
4265 ; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
4266 (define_insn "fix_trunc<BFP:mode><GPR:mode>2_bfp"
4267 [(set (match_operand:GPR 0 "register_operand" "=d")
4268 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
4269 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4270 (clobber (reg:CC CC_REGNUM))]
4271 "TARGET_HARD_FLOAT"
4272 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
4273 [(set_attr "op_type" "RRE")
4274 (set_attr "type" "ftoi")])
4275
4276
4277 ;
4278 ; fix_trunc(td|dd)di2 instruction pattern(s).
4279 ;
4280
4281 (define_expand "fix_trunc<mode>di2"
4282 [(set (match_operand:DI 0 "register_operand" "")
4283 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
4284 "TARGET_ZARCH && TARGET_HARD_DFP"
4285 {
4286 operands[1] = force_reg (<MODE>mode, operands[1]);
4287 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
4288 GEN_INT (9)));
4289 DONE;
4290 })
4291
4292 ; cgxtr, cgdtr
4293 (define_insn "fix_trunc<DFP:mode>di2_dfp"
4294 [(set (match_operand:DI 0 "register_operand" "=d")
4295 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
4296 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
4297 (clobber (reg:CC CC_REGNUM))]
4298 "TARGET_ZARCH && TARGET_HARD_DFP"
4299 "cg<DFP:xde>tr\t%0,%h2,%1"
4300 [(set_attr "op_type" "RRF")
4301 (set_attr "type" "ftoidfp")])
4302
4303
4304 ;
4305 ; fix_trunctf(si|di)2 instruction pattern(s).
4306 ;
4307
4308 (define_expand "fix_trunctf<mode>2"
4309 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
4310 (fix:GPR (match_operand:TF 1 "register_operand" "")))
4311 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
4312 (clobber (reg:CC CC_REGNUM))])]
4313 "TARGET_HARD_FLOAT"
4314 "")
4315
4316
4317 ;
4318 ; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
4319 ;
4320
4321 ; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
4322 (define_insn "floatdi<mode>2"
4323 [(set (match_operand:FP 0 "register_operand" "=f")
4324 (float:FP (match_operand:DI 1 "register_operand" "d")))]
4325 "TARGET_ZARCH && TARGET_HARD_FLOAT"
4326 "c<xde>g<bt>r\t%0,%1"
4327 [(set_attr "op_type" "RRE")
4328 (set_attr "type" "itof<mode>" )])
4329
4330 ; cxfbr, cdfbr, cefbr
4331 (define_insn "floatsi<mode>2"
4332 [(set (match_operand:BFP 0 "register_operand" "=f")
4333 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
4334 "TARGET_HARD_FLOAT"
4335 "c<xde>fbr\t%0,%1"
4336 [(set_attr "op_type" "RRE")
4337 (set_attr "type" "itof<mode>" )])
4338
4339 ; cxftr, cdftr
4340 (define_insn "floatsi<mode>2"
4341 [(set (match_operand:DFP 0 "register_operand" "=f")
4342 (float:DFP (match_operand:SI 1 "register_operand" "d")))]
4343 "TARGET_Z196 && TARGET_HARD_FLOAT"
4344 "c<xde>ftr\t%0,0,%1,0"
4345 [(set_attr "op_type" "RRE")
4346 (set_attr "type" "itof<mode>" )])
4347
4348 ;
4349 ; floatuns(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
4350 ;
4351
4352 ; cxlgbr, cdlgbr, celgbr, cxlgtr, cdlgtr
4353 ; cxlfbr, cdlfbr, celfbr, cxlftr, cdlftr
4354 (define_insn "floatuns<GPR:mode><FP:mode>2"
4355 [(set (match_operand:FP 0 "register_operand" "=f")
4356 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "d")))]
4357 "TARGET_Z196 && TARGET_HARD_FLOAT"
4358 "c<FP:xde>l<GPR:gf><FP:bt>r\t%0,0,%1,0"
4359 [(set_attr "op_type" "RRE")
4360 (set_attr "type" "itof<FP:mode>" )])
4361
4362 ;
4363 ; truncdfsf2 instruction pattern(s).
4364 ;
4365
4366 (define_insn "truncdfsf2"
4367 [(set (match_operand:SF 0 "register_operand" "=f")
4368 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
4369 "TARGET_HARD_FLOAT"
4370 "ledbr\t%0,%1"
4371 [(set_attr "op_type" "RRE")
4372 (set_attr "type" "ftruncdf")])
4373
4374 ;
4375 ; trunctf(df|sf)2 instruction pattern(s).
4376 ;
4377
4378 ; ldxbr, lexbr
4379 (define_insn "trunctf<mode>2"
4380 [(set (match_operand:DSF 0 "register_operand" "=f")
4381 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
4382 (clobber (match_scratch:TF 2 "=f"))]
4383 "TARGET_HARD_FLOAT"
4384 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
4385 [(set_attr "length" "6")
4386 (set_attr "type" "ftrunctf")])
4387
4388 ;
4389 ; trunctddd2 and truncddsd2 instruction pattern(s).
4390 ;
4391
4392 (define_insn "trunctddd2"
4393 [(set (match_operand:DD 0 "register_operand" "=f")
4394 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
4395 (clobber (match_scratch:TD 2 "=f"))]
4396 "TARGET_HARD_DFP"
4397 "ldxtr\t%2,0,%1,0\;ldr\t%0,%2"
4398 [(set_attr "length" "6")
4399 (set_attr "type" "ftruncdd")])
4400
4401 (define_insn "truncddsd2"
4402 [(set (match_operand:SD 0 "register_operand" "=f")
4403 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
4404 "TARGET_HARD_DFP"
4405 "ledtr\t%0,0,%1,0"
4406 [(set_attr "op_type" "RRF")
4407 (set_attr "type" "ftruncsd")])
4408
4409 ;
4410 ; extend(sf|df)(df|tf)2 instruction pattern(s).
4411 ;
4412
4413 ; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
4414 (define_insn "extend<DSF:mode><BFP:mode>2"
4415 [(set (match_operand:BFP 0 "register_operand" "=f,f")
4416 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
4417 "TARGET_HARD_FLOAT
4418 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)"
4419 "@
4420 l<BFP:xde><DSF:xde>br\t%0,%1
4421 l<BFP:xde><DSF:xde>b\t%0,%1"
4422 [(set_attr "op_type" "RRE,RXE")
4423 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
4424
4425 ;
4426 ; extendddtd2 and extendsddd2 instruction pattern(s).
4427 ;
4428
4429 (define_insn "extendddtd2"
4430 [(set (match_operand:TD 0 "register_operand" "=f")
4431 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
4432 "TARGET_HARD_DFP"
4433 "lxdtr\t%0,%1,0"
4434 [(set_attr "op_type" "RRF")
4435 (set_attr "type" "fsimptf")])
4436
4437 (define_insn "extendsddd2"
4438 [(set (match_operand:DD 0 "register_operand" "=f")
4439 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
4440 "TARGET_HARD_DFP"
4441 "ldetr\t%0,%1,0"
4442 [(set_attr "op_type" "RRF")
4443 (set_attr "type" "fsimptf")])
4444
4445 ; Binary Floating Point - load fp integer
4446
4447 ; Expanders for: floor, btrunc, round, ceil, and nearbyint
4448 ; For all of them the inexact exceptions are suppressed.
4449
4450 ; fiebra, fidbra, fixbra
4451 (define_insn "<FPINT:fpint_name><BFP:mode>2"
4452 [(set (match_operand:BFP 0 "register_operand" "=f")
4453 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
4454 FPINT))]
4455 "TARGET_Z196"
4456 "fi<BFP:xde>bra\t%0,<FPINT:fpint_roundingmode>,%1,4"
4457 [(set_attr "op_type" "RRF")
4458 (set_attr "type" "fsimp<BFP:mode>")])
4459
4460 ; rint is supposed to raise an inexact exception so we can use the
4461 ; older instructions.
4462
4463 ; fiebr, fidbr, fixbr
4464 (define_insn "rint<BFP:mode>2"
4465 [(set (match_operand:BFP 0 "register_operand" "=f")
4466 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
4467 UNSPEC_FPINT_RINT))]
4468 ""
4469 "fi<BFP:xde>br\t%0,0,%1"
4470 [(set_attr "op_type" "RRF")
4471 (set_attr "type" "fsimp<BFP:mode>")])
4472
4473
4474 ; Decimal Floating Point - load fp integer
4475
4476 ; fidtr, fixtr
4477 (define_insn "<FPINT:fpint_name><DFP:mode>2"
4478 [(set (match_operand:DFP 0 "register_operand" "=f")
4479 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
4480 FPINT))]
4481 "TARGET_HARD_DFP"
4482 "fi<DFP:xde>tr\t%0,<FPINT:fpint_roundingmode>,%1,4"
4483 [(set_attr "op_type" "RRF")
4484 (set_attr "type" "fsimp<DFP:mode>")])
4485
4486 ; fidtr, fixtr
4487 (define_insn "rint<DFP:mode>2"
4488 [(set (match_operand:DFP 0 "register_operand" "=f")
4489 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
4490 UNSPEC_FPINT_RINT))]
4491 "TARGET_HARD_DFP"
4492 "fi<DFP:xde>tr\t%0,0,%1,0"
4493 [(set_attr "op_type" "RRF")
4494 (set_attr "type" "fsimp<DFP:mode>")])
4495
4496 ;
4497 ; Binary <-> Decimal floating point trunc patterns
4498 ;
4499
4500 (define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
4501 [(set (reg:DFP_ALL FPR0_REGNUM)
4502 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
4503 (use (reg:SI GPR0_REGNUM))
4504 (clobber (reg:CC CC_REGNUM))]
4505 "TARGET_HARD_DFP"
4506 "pfpo")
4507
4508 (define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
4509 [(set (reg:BFP FPR0_REGNUM)
4510 (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
4511 (use (reg:SI GPR0_REGNUM))
4512 (clobber (reg:CC CC_REGNUM))]
4513 "TARGET_HARD_DFP"
4514 "pfpo")
4515
4516 (define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
4517 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4518 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4519 (parallel
4520 [(set (reg:DFP_ALL FPR0_REGNUM)
4521 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
4522 (use (reg:SI GPR0_REGNUM))
4523 (clobber (reg:CC CC_REGNUM))])
4524 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4525 (reg:DFP_ALL FPR0_REGNUM))]
4526 "TARGET_HARD_DFP
4527 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4528 {
4529 HOST_WIDE_INT flags;
4530
4531 flags = (PFPO_CONVERT |
4532 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4533 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4534
4535 operands[2] = GEN_INT (flags);
4536 })
4537
4538 (define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
4539 [(set (reg:DFP_ALL FPR4_REGNUM)
4540 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4541 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4542 (parallel
4543 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
4544 (use (reg:SI GPR0_REGNUM))
4545 (clobber (reg:CC CC_REGNUM))])
4546 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4547 "TARGET_HARD_DFP
4548 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
4549 {
4550 HOST_WIDE_INT flags;
4551
4552 flags = (PFPO_CONVERT |
4553 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4554 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4555
4556 operands[2] = GEN_INT (flags);
4557 })
4558
4559 ;
4560 ; Binary <-> Decimal floating point extend patterns
4561 ;
4562
4563 (define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
4564 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
4565 (use (reg:SI GPR0_REGNUM))
4566 (clobber (reg:CC CC_REGNUM))]
4567 "TARGET_HARD_DFP"
4568 "pfpo")
4569
4570 (define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
4571 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
4572 (use (reg:SI GPR0_REGNUM))
4573 (clobber (reg:CC CC_REGNUM))]
4574 "TARGET_HARD_DFP"
4575 "pfpo")
4576
4577 (define_expand "extend<BFP:mode><DFP_ALL:mode>2"
4578 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4579 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4580 (parallel
4581 [(set (reg:DFP_ALL FPR0_REGNUM)
4582 (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
4583 (use (reg:SI GPR0_REGNUM))
4584 (clobber (reg:CC CC_REGNUM))])
4585 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4586 (reg:DFP_ALL FPR0_REGNUM))]
4587 "TARGET_HARD_DFP
4588 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4589 {
4590 HOST_WIDE_INT flags;
4591
4592 flags = (PFPO_CONVERT |
4593 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4594 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4595
4596 operands[2] = GEN_INT (flags);
4597 })
4598
4599 (define_expand "extend<DFP_ALL:mode><BFP:mode>2"
4600 [(set (reg:DFP_ALL FPR4_REGNUM)
4601 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4602 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4603 (parallel
4604 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
4605 (use (reg:SI GPR0_REGNUM))
4606 (clobber (reg:CC CC_REGNUM))])
4607 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4608 "TARGET_HARD_DFP
4609 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
4610 {
4611 HOST_WIDE_INT flags;
4612
4613 flags = (PFPO_CONVERT |
4614 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4615 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4616
4617 operands[2] = GEN_INT (flags);
4618 })
4619
4620
4621 ;;
4622 ;; ARITHMETIC OPERATIONS
4623 ;;
4624 ; arithmetic operations set the ConditionCode,
4625 ; because of unpredictable Bits in Register for Halfword and Byte
4626 ; the ConditionCode can be set wrong in operations for Halfword and Byte
4627
4628 ;;
4629 ;;- Add instructions.
4630 ;;
4631
4632 ;
4633 ; addti3 instruction pattern(s).
4634 ;
4635
4636 (define_insn_and_split "addti3"
4637 [(set (match_operand:TI 0 "register_operand" "=&d")
4638 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
4639 (match_operand:TI 2 "general_operand" "do") ) )
4640 (clobber (reg:CC CC_REGNUM))]
4641 "TARGET_ZARCH"
4642 "#"
4643 "&& reload_completed"
4644 [(parallel
4645 [(set (reg:CCL1 CC_REGNUM)
4646 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
4647 (match_dup 7)))
4648 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
4649 (parallel
4650 [(set (match_dup 3) (plus:DI
4651 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
4652 (match_dup 4)) (match_dup 5)))
4653 (clobber (reg:CC CC_REGNUM))])]
4654 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4655 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4656 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4657 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4658 operands[7] = operand_subword (operands[1], 1, 0, TImode);
4659 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4660
4661 ;
4662 ; adddi3 instruction pattern(s).
4663 ;
4664
4665 (define_expand "adddi3"
4666 [(parallel
4667 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4668 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4669 (match_operand:DI 2 "general_operand" "")))
4670 (clobber (reg:CC CC_REGNUM))])]
4671 ""
4672 "")
4673
4674 (define_insn "*adddi3_sign"
4675 [(set (match_operand:DI 0 "register_operand" "=d,d")
4676 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4677 (match_operand:DI 1 "register_operand" "0,0")))
4678 (clobber (reg:CC CC_REGNUM))]
4679 "TARGET_ZARCH"
4680 "@
4681 agfr\t%0,%2
4682 agf\t%0,%2"
4683 [(set_attr "op_type" "RRE,RXY")
4684 (set_attr "z196prop" "z196_cracked,z196_cracked")])
4685
4686 (define_insn "*adddi3_zero_cc"
4687 [(set (reg CC_REGNUM)
4688 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4689 (match_operand:DI 1 "register_operand" "0,0"))
4690 (const_int 0)))
4691 (set (match_operand:DI 0 "register_operand" "=d,d")
4692 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
4693 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
4694 "@
4695 algfr\t%0,%2
4696 algf\t%0,%2"
4697 [(set_attr "op_type" "RRE,RXY")
4698 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4699
4700 (define_insn "*adddi3_zero_cconly"
4701 [(set (reg CC_REGNUM)
4702 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4703 (match_operand:DI 1 "register_operand" "0,0"))
4704 (const_int 0)))
4705 (clobber (match_scratch:DI 0 "=d,d"))]
4706 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
4707 "@
4708 algfr\t%0,%2
4709 algf\t%0,%2"
4710 [(set_attr "op_type" "RRE,RXY")
4711 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4712
4713 (define_insn "*adddi3_zero"
4714 [(set (match_operand:DI 0 "register_operand" "=d,d")
4715 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4716 (match_operand:DI 1 "register_operand" "0,0")))
4717 (clobber (reg:CC CC_REGNUM))]
4718 "TARGET_ZARCH"
4719 "@
4720 algfr\t%0,%2
4721 algf\t%0,%2"
4722 [(set_attr "op_type" "RRE,RXY")
4723 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4724
4725 (define_insn_and_split "*adddi3_31z"
4726 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4727 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4728 (match_operand:DI 2 "general_operand" "do") ) )
4729 (clobber (reg:CC CC_REGNUM))]
4730 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
4731 "#"
4732 "&& reload_completed"
4733 [(parallel
4734 [(set (reg:CCL1 CC_REGNUM)
4735 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4736 (match_dup 7)))
4737 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4738 (parallel
4739 [(set (match_dup 3) (plus:SI
4740 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
4741 (match_dup 4)) (match_dup 5)))
4742 (clobber (reg:CC CC_REGNUM))])]
4743 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4744 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4745 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4746 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4747 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4748 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4749
4750 (define_insn_and_split "*adddi3_31"
4751 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4752 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4753 (match_operand:DI 2 "general_operand" "do") ) )
4754 (clobber (reg:CC CC_REGNUM))]
4755 "!TARGET_CPU_ZARCH"
4756 "#"
4757 "&& reload_completed"
4758 [(parallel
4759 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
4760 (clobber (reg:CC CC_REGNUM))])
4761 (parallel
4762 [(set (reg:CCL1 CC_REGNUM)
4763 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4764 (match_dup 7)))
4765 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4766 (set (pc)
4767 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
4768 (pc)
4769 (label_ref (match_dup 9))))
4770 (parallel
4771 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
4772 (clobber (reg:CC CC_REGNUM))])
4773 (match_dup 9)]
4774 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4775 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4776 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4777 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4778 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4779 operands[8] = operand_subword (operands[2], 1, 0, DImode);
4780 operands[9] = gen_label_rtx ();")
4781
4782 ;
4783 ; addsi3 instruction pattern(s).
4784 ;
4785
4786 (define_expand "addsi3"
4787 [(parallel
4788 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4789 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
4790 (match_operand:SI 2 "general_operand" "")))
4791 (clobber (reg:CC CC_REGNUM))])]
4792 ""
4793 "")
4794
4795 (define_insn "*addsi3_sign"
4796 [(set (match_operand:SI 0 "register_operand" "=d,d")
4797 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
4798 (match_operand:SI 1 "register_operand" "0,0")))
4799 (clobber (reg:CC CC_REGNUM))]
4800 ""
4801 "@
4802 ah\t%0,%2
4803 ahy\t%0,%2"
4804 [(set_attr "op_type" "RX,RXY")
4805 (set_attr "z196prop" "z196_cracked,z196_cracked")])
4806
4807 ;
4808 ; add(di|si)3 instruction pattern(s).
4809 ;
4810
4811 ; ark, agrk, ar, ahi, ahik, aghik, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
4812 (define_insn "*add<mode>3"
4813 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d, d, d,d,d,QS")
4814 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,d, 0, 0,0,0, 0")
4815 (match_operand:GPR 2 "general_operand" " d,d,K,K,Op,On,R,T, C") ) )
4816 (clobber (reg:CC CC_REGNUM))]
4817 ""
4818 "@
4819 a<g>r\t%0,%2
4820 a<g>rk\t%0,%1,%2
4821 a<g>hi\t%0,%h2
4822 a<g>hik\t%0,%1,%h2
4823 al<g>fi\t%0,%2
4824 sl<g>fi\t%0,%n2
4825 a<g>\t%0,%2
4826 a<y>\t%0,%2
4827 a<g>si\t%0,%c2"
4828 [(set_attr "op_type" "RR<E>,RRF,RI,RIE,RIL,RIL,RX<Y>,RXY,SIY")
4829 (set_attr "cpu_facility" "*,z196,*,z196,extimm,extimm,*,*,z10")
4830 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,z10_super_E1,z10_super_E1,
4831 z10_super_E1,z10_super_E1,z10_super_E1")])
4832
4833 ; alr, alfi, slfi, al, aly, alrk, alhsik, algr, algfi, slgfi, alg, alsi, algsi, algrk, alghsik
4834 (define_insn "*add<mode>3_carry1_cc"
4835 [(set (reg CC_REGNUM)
4836 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
4837 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
4838 (match_dup 1)))
4839 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,d")
4840 (plus:GPR (match_dup 1) (match_dup 2)))]
4841 "s390_match_ccmode (insn, CCL1mode)"
4842 "@
4843 al<g>r\t%0,%2
4844 al<g>rk\t%0,%1,%2
4845 al<g>fi\t%0,%2
4846 sl<g>fi\t%0,%n2
4847 al<g>hsik\t%0,%1,%h2
4848 al<g>\t%0,%2
4849 al<y>\t%0,%2
4850 al<g>si\t%0,%c2"
4851 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
4852 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
4853 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
4854 z10_super_E1,z10_super_E1,z10_super_E1")])
4855
4856 ; alr, al, aly, algr, alg, alrk, algrk
4857 (define_insn "*add<mode>3_carry1_cconly"
4858 [(set (reg CC_REGNUM)
4859 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
4860 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
4861 (match_dup 1)))
4862 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
4863 "s390_match_ccmode (insn, CCL1mode)"
4864 "@
4865 al<g>r\t%0,%2
4866 al<g>rk\t%0,%1,%2
4867 al<g>\t%0,%2
4868 al<y>\t%0,%2"
4869 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
4870 (set_attr "cpu_facility" "*,z196,*,*")
4871 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4872
4873 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
4874 (define_insn "*add<mode>3_carry2_cc"
4875 [(set (reg CC_REGNUM)
4876 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0, 0")
4877 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T, C"))
4878 (match_dup 2)))
4879 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,RS")
4880 (plus:GPR (match_dup 1) (match_dup 2)))]
4881 "s390_match_ccmode (insn, CCL1mode)"
4882 "@
4883 al<g>r\t%0,%2
4884 al<g>rk\t%0,%1,%2
4885 al<g>fi\t%0,%2
4886 sl<g>fi\t%0,%n2
4887 al<g>hsik\t%0,%1,%h2
4888 al<g>\t%0,%2
4889 al<y>\t%0,%2
4890 al<g>si\t%0,%c2"
4891 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
4892 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
4893 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
4894 z10_super_E1,z10_super_E1,z10_super_E1")])
4895
4896 ; alr, al, aly, algr, alg, alrk, algrk
4897 (define_insn "*add<mode>3_carry2_cconly"
4898 [(set (reg CC_REGNUM)
4899 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
4900 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
4901 (match_dup 2)))
4902 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
4903 "s390_match_ccmode (insn, CCL1mode)"
4904 "@
4905 al<g>r\t%0,%2
4906 al<g>rk\t%0,%1,%2
4907 al<g>\t%0,%2
4908 al<y>\t%0,%2"
4909 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
4910 (set_attr "cpu_facility" "*,z196,*,*")
4911 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4912
4913 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
4914 (define_insn "*add<mode>3_cc"
4915 [(set (reg CC_REGNUM)
4916 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0, 0")
4917 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T, C"))
4918 (const_int 0)))
4919 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,RS")
4920 (plus:GPR (match_dup 1) (match_dup 2)))]
4921 "s390_match_ccmode (insn, CCLmode)"
4922 "@
4923 al<g>r\t%0,%2
4924 al<g>rk\t%0,%1,%2
4925 al<g>fi\t%0,%2
4926 sl<g>fi\t%0,%n2
4927 al<g>hsik\t%0,%1,%h2
4928 al<g>\t%0,%2
4929 al<y>\t%0,%2
4930 al<g>si\t%0,%c2"
4931 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
4932 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
4933 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,
4934 *,z10_super_E1,z10_super_E1,z10_super_E1")])
4935
4936 ; alr, al, aly, algr, alg, alrk, algrk
4937 (define_insn "*add<mode>3_cconly"
4938 [(set (reg CC_REGNUM)
4939 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
4940 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
4941 (const_int 0)))
4942 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
4943 "s390_match_ccmode (insn, CCLmode)"
4944 "@
4945 al<g>r\t%0,%2
4946 al<g>rk\t%0,%1,%2
4947 al<g>\t%0,%2
4948 al<y>\t%0,%2"
4949 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
4950 (set_attr "cpu_facility" "*,z196,*,*")
4951 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4952
4953 ; alr, al, aly, algr, alg, alrk, algrk
4954 (define_insn "*add<mode>3_cconly2"
4955 [(set (reg CC_REGNUM)
4956 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
4957 (neg:GPR (match_operand:GPR 2 "general_operand" "d,d,R,T"))))
4958 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
4959 "s390_match_ccmode(insn, CCLmode)"
4960 "@
4961 al<g>r\t%0,%2
4962 al<g>rk\t%0,%1,%2
4963 al<g>\t%0,%2
4964 al<y>\t%0,%2"
4965 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
4966 (set_attr "cpu_facility" "*,z196,*,*")
4967 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4968
4969 ; ahi, afi, aghi, agfi, asi, agsi
4970 (define_insn "*add<mode>3_imm_cc"
4971 [(set (reg CC_REGNUM)
4972 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" " 0, d,0, 0")
4973 (match_operand:GPR 2 "const_int_operand" " K, K,Os, C"))
4974 (const_int 0)))
4975 (set (match_operand:GPR 0 "nonimmediate_operand" "=d, d,d,QS")
4976 (plus:GPR (match_dup 1) (match_dup 2)))]
4977 "s390_match_ccmode (insn, CCAmode)
4978 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
4979 || (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
4980 /* Avoid INT32_MIN on 32 bit. */
4981 && (!TARGET_ZARCH || INTVAL (operands[2]) != -0x7fffffff - 1)))"
4982 "@
4983 a<g>hi\t%0,%h2
4984 a<g>hik\t%0,%1,%h2
4985 a<g>fi\t%0,%2
4986 a<g>si\t%0,%c2"
4987 [(set_attr "op_type" "RI,RIE,RIL,SIY")
4988 (set_attr "cpu_facility" "*,z196,extimm,z10")
4989 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4990
4991 ;
4992 ; add(tf|df|sf|td|dd)3 instruction pattern(s).
4993 ;
4994
4995 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4996 (define_insn "add<mode>3"
4997 [(set (match_operand:FP 0 "register_operand" "=f, f")
4998 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4999 (match_operand:FP 2 "general_operand" " f,<Rf>")))
5000 (clobber (reg:CC CC_REGNUM))]
5001 "TARGET_HARD_FLOAT"
5002 "@
5003 a<xde><bt>r\t%0,<op1>%2
5004 a<xde>b\t%0,%2"
5005 [(set_attr "op_type" "<RRer>,RXE")
5006 (set_attr "type" "fsimp<mode>")])
5007
5008 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
5009 (define_insn "*add<mode>3_cc"
5010 [(set (reg CC_REGNUM)
5011 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5012 (match_operand:FP 2 "general_operand" " f,<Rf>"))
5013 (match_operand:FP 3 "const0_operand" "")))
5014 (set (match_operand:FP 0 "register_operand" "=f,f")
5015 (plus:FP (match_dup 1) (match_dup 2)))]
5016 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
5017 "@
5018 a<xde><bt>r\t%0,<op1>%2
5019 a<xde>b\t%0,%2"
5020 [(set_attr "op_type" "<RRer>,RXE")
5021 (set_attr "type" "fsimp<mode>")])
5022
5023 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
5024 (define_insn "*add<mode>3_cconly"
5025 [(set (reg CC_REGNUM)
5026 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5027 (match_operand:FP 2 "general_operand" " f,<Rf>"))
5028 (match_operand:FP 3 "const0_operand" "")))
5029 (clobber (match_scratch:FP 0 "=f,f"))]
5030 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
5031 "@
5032 a<xde><bt>r\t%0,<op1>%2
5033 a<xde>b\t%0,%2"
5034 [(set_attr "op_type" "<RRer>,RXE")
5035 (set_attr "type" "fsimp<mode>")])
5036
5037
5038 ;;
5039 ;;- Subtract instructions.
5040 ;;
5041
5042 ;
5043 ; subti3 instruction pattern(s).
5044 ;
5045
5046 (define_insn_and_split "subti3"
5047 [(set (match_operand:TI 0 "register_operand" "=&d")
5048 (minus:TI (match_operand:TI 1 "register_operand" "0")
5049 (match_operand:TI 2 "general_operand" "do") ) )
5050 (clobber (reg:CC CC_REGNUM))]
5051 "TARGET_ZARCH"
5052 "#"
5053 "&& reload_completed"
5054 [(parallel
5055 [(set (reg:CCL2 CC_REGNUM)
5056 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
5057 (match_dup 7)))
5058 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
5059 (parallel
5060 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
5061 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
5062 (clobber (reg:CC CC_REGNUM))])]
5063 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
5064 operands[4] = operand_subword (operands[1], 0, 0, TImode);
5065 operands[5] = operand_subword (operands[2], 0, 0, TImode);
5066 operands[6] = operand_subword (operands[0], 1, 0, TImode);
5067 operands[7] = operand_subword (operands[1], 1, 0, TImode);
5068 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
5069
5070 ;
5071 ; subdi3 instruction pattern(s).
5072 ;
5073
5074 (define_expand "subdi3"
5075 [(parallel
5076 [(set (match_operand:DI 0 "register_operand" "")
5077 (minus:DI (match_operand:DI 1 "register_operand" "")
5078 (match_operand:DI 2 "general_operand" "")))
5079 (clobber (reg:CC CC_REGNUM))])]
5080 ""
5081 "")
5082
5083 (define_insn "*subdi3_sign"
5084 [(set (match_operand:DI 0 "register_operand" "=d,d")
5085 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
5086 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
5087 (clobber (reg:CC CC_REGNUM))]
5088 "TARGET_ZARCH"
5089 "@
5090 sgfr\t%0,%2
5091 sgf\t%0,%2"
5092 [(set_attr "op_type" "RRE,RXY")
5093 (set_attr "z10prop" "z10_c,*")
5094 (set_attr "z196prop" "z196_cracked")])
5095
5096 (define_insn "*subdi3_zero_cc"
5097 [(set (reg CC_REGNUM)
5098 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
5099 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
5100 (const_int 0)))
5101 (set (match_operand:DI 0 "register_operand" "=d,d")
5102 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
5103 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
5104 "@
5105 slgfr\t%0,%2
5106 slgf\t%0,%2"
5107 [(set_attr "op_type" "RRE,RXY")
5108 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
5109
5110 (define_insn "*subdi3_zero_cconly"
5111 [(set (reg CC_REGNUM)
5112 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
5113 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
5114 (const_int 0)))
5115 (clobber (match_scratch:DI 0 "=d,d"))]
5116 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
5117 "@
5118 slgfr\t%0,%2
5119 slgf\t%0,%2"
5120 [(set_attr "op_type" "RRE,RXY")
5121 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
5122
5123 (define_insn "*subdi3_zero"
5124 [(set (match_operand:DI 0 "register_operand" "=d,d")
5125 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
5126 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
5127 (clobber (reg:CC CC_REGNUM))]
5128 "TARGET_ZARCH"
5129 "@
5130 slgfr\t%0,%2
5131 slgf\t%0,%2"
5132 [(set_attr "op_type" "RRE,RXY")
5133 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
5134
5135 (define_insn_and_split "*subdi3_31z"
5136 [(set (match_operand:DI 0 "register_operand" "=&d")
5137 (minus:DI (match_operand:DI 1 "register_operand" "0")
5138 (match_operand:DI 2 "general_operand" "do") ) )
5139 (clobber (reg:CC CC_REGNUM))]
5140 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
5141 "#"
5142 "&& reload_completed"
5143 [(parallel
5144 [(set (reg:CCL2 CC_REGNUM)
5145 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5146 (match_dup 7)))
5147 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5148 (parallel
5149 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
5150 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
5151 (clobber (reg:CC CC_REGNUM))])]
5152 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5153 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5154 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5155 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5156 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5157 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
5158
5159 (define_insn_and_split "*subdi3_31"
5160 [(set (match_operand:DI 0 "register_operand" "=&d")
5161 (minus:DI (match_operand:DI 1 "register_operand" "0")
5162 (match_operand:DI 2 "general_operand" "do") ) )
5163 (clobber (reg:CC CC_REGNUM))]
5164 "!TARGET_CPU_ZARCH"
5165 "#"
5166 "&& reload_completed"
5167 [(parallel
5168 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
5169 (clobber (reg:CC CC_REGNUM))])
5170 (parallel
5171 [(set (reg:CCL2 CC_REGNUM)
5172 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5173 (match_dup 7)))
5174 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5175 (set (pc)
5176 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
5177 (pc)
5178 (label_ref (match_dup 9))))
5179 (parallel
5180 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
5181 (clobber (reg:CC CC_REGNUM))])
5182 (match_dup 9)]
5183 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5184 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5185 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5186 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5187 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5188 operands[8] = operand_subword (operands[2], 1, 0, DImode);
5189 operands[9] = gen_label_rtx ();")
5190
5191 ;
5192 ; subsi3 instruction pattern(s).
5193 ;
5194
5195 (define_expand "subsi3"
5196 [(parallel
5197 [(set (match_operand:SI 0 "register_operand" "")
5198 (minus:SI (match_operand:SI 1 "register_operand" "")
5199 (match_operand:SI 2 "general_operand" "")))
5200 (clobber (reg:CC CC_REGNUM))])]
5201 ""
5202 "")
5203
5204 (define_insn "*subsi3_sign"
5205 [(set (match_operand:SI 0 "register_operand" "=d,d")
5206 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
5207 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
5208 (clobber (reg:CC CC_REGNUM))]
5209 ""
5210 "@
5211 sh\t%0,%2
5212 shy\t%0,%2"
5213 [(set_attr "op_type" "RX,RXY")
5214 (set_attr "z196prop" "z196_cracked,z196_cracked")])
5215
5216 ;
5217 ; sub(di|si)3 instruction pattern(s).
5218 ;
5219
5220 ; sr, s, sy, sgr, sg, srk, sgrk
5221 (define_insn "*sub<mode>3"
5222 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5223 (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5224 (match_operand:GPR 2 "general_operand" "d,d,R,T") ) )
5225 (clobber (reg:CC CC_REGNUM))]
5226 ""
5227 "@
5228 s<g>r\t%0,%2
5229 s<g>rk\t%0,%1,%2
5230 s<g>\t%0,%2
5231 s<y>\t%0,%2"
5232 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5233 (set_attr "cpu_facility" "*,z196,*,*")
5234 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5235
5236 ; slr, sl, sly, slgr, slg, slrk, slgrk
5237 (define_insn "*sub<mode>3_borrow_cc"
5238 [(set (reg CC_REGNUM)
5239 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5240 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5241 (match_dup 1)))
5242 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5243 (minus:GPR (match_dup 1) (match_dup 2)))]
5244 "s390_match_ccmode (insn, CCL2mode)"
5245 "@
5246 sl<g>r\t%0,%2
5247 sl<g>rk\t%0,%1,%2
5248 sl<g>\t%0,%2
5249 sl<y>\t%0,%2"
5250 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5251 (set_attr "cpu_facility" "*,z196,*,*")
5252 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5253
5254 ; slr, sl, sly, slgr, slg, slrk, slgrk
5255 (define_insn "*sub<mode>3_borrow_cconly"
5256 [(set (reg CC_REGNUM)
5257 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5258 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5259 (match_dup 1)))
5260 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5261 "s390_match_ccmode (insn, CCL2mode)"
5262 "@
5263 sl<g>r\t%0,%2
5264 sl<g>rk\t%0,%1,%2
5265 sl<g>\t%0,%2
5266 sl<y>\t%0,%2"
5267 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5268 (set_attr "cpu_facility" "*,z196,*,*")
5269 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5270
5271 ; slr, sl, sly, slgr, slg, slrk, slgrk
5272 (define_insn "*sub<mode>3_cc"
5273 [(set (reg CC_REGNUM)
5274 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5275 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5276 (const_int 0)))
5277 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5278 (minus:GPR (match_dup 1) (match_dup 2)))]
5279 "s390_match_ccmode (insn, CCLmode)"
5280 "@
5281 sl<g>r\t%0,%2
5282 sl<g>rk\t%0,%1,%2
5283 sl<g>\t%0,%2
5284 sl<y>\t%0,%2"
5285 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5286 (set_attr "cpu_facility" "*,z196,*,*")
5287 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5288
5289 ; slr, sl, sly, slgr, slg, slrk, slgrk
5290 (define_insn "*sub<mode>3_cc2"
5291 [(set (reg CC_REGNUM)
5292 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
5293 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
5294 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5295 (minus:GPR (match_dup 1) (match_dup 2)))]
5296 "s390_match_ccmode (insn, CCL3mode)"
5297 "@
5298 sl<g>r\t%0,%2
5299 sl<g>rk\t%0,%1,%2
5300 sl<g>\t%0,%2
5301 sl<y>\t%0,%2"
5302 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5303 (set_attr "cpu_facility" "*,z196,*,*")
5304 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5305
5306 ; slr, sl, sly, slgr, slg, slrk, slgrk
5307 (define_insn "*sub<mode>3_cconly"
5308 [(set (reg CC_REGNUM)
5309 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5310 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5311 (const_int 0)))
5312 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5313 "s390_match_ccmode (insn, CCLmode)"
5314 "@
5315 sl<g>r\t%0,%2
5316 sl<g>rk\t%0,%1,%2
5317 sl<g>\t%0,%2
5318 sl<y>\t%0,%2"
5319 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5320 (set_attr "cpu_facility" "*,z196,*,*")
5321 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5322
5323
5324 ; slr, sl, sly, slgr, slg, slrk, slgrk
5325 (define_insn "*sub<mode>3_cconly2"
5326 [(set (reg CC_REGNUM)
5327 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
5328 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
5329 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5330 "s390_match_ccmode (insn, CCL3mode)"
5331 "@
5332 sl<g>r\t%0,%2
5333 sl<g>rk\t%0,%1,%2
5334 sl<g>\t%0,%2
5335 sl<y>\t%0,%2"
5336 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5337 (set_attr "cpu_facility" "*,z196,*,*")
5338 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5339
5340
5341 ;
5342 ; sub(tf|df|sf|td|dd)3 instruction pattern(s).
5343 ;
5344
5345 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
5346 (define_insn "sub<mode>3"
5347 [(set (match_operand:FP 0 "register_operand" "=f, f")
5348 (minus:FP (match_operand:FP 1 "register_operand" "<f0>,0")
5349 (match_operand:FP 2 "general_operand" "f,<Rf>")))
5350 (clobber (reg:CC CC_REGNUM))]
5351 "TARGET_HARD_FLOAT"
5352 "@
5353 s<xde><bt>r\t%0,<op1>%2
5354 s<xde>b\t%0,%2"
5355 [(set_attr "op_type" "<RRer>,RXE")
5356 (set_attr "type" "fsimp<mode>")])
5357
5358 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
5359 (define_insn "*sub<mode>3_cc"
5360 [(set (reg CC_REGNUM)
5361 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
5362 (match_operand:FP 2 "general_operand" "f,<Rf>"))
5363 (match_operand:FP 3 "const0_operand" "")))
5364 (set (match_operand:FP 0 "register_operand" "=f,f")
5365 (minus:FP (match_dup 1) (match_dup 2)))]
5366 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
5367 "@
5368 s<xde><bt>r\t%0,<op1>%2
5369 s<xde>b\t%0,%2"
5370 [(set_attr "op_type" "<RRer>,RXE")
5371 (set_attr "type" "fsimp<mode>")])
5372
5373 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
5374 (define_insn "*sub<mode>3_cconly"
5375 [(set (reg CC_REGNUM)
5376 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
5377 (match_operand:FP 2 "general_operand" "f,<Rf>"))
5378 (match_operand:FP 3 "const0_operand" "")))
5379 (clobber (match_scratch:FP 0 "=f,f"))]
5380 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
5381 "@
5382 s<xde><bt>r\t%0,<op1>%2
5383 s<xde>b\t%0,%2"
5384 [(set_attr "op_type" "<RRer>,RXE")
5385 (set_attr "type" "fsimp<mode>")])
5386
5387
5388 ;;
5389 ;;- Conditional add/subtract instructions.
5390 ;;
5391
5392 ;
5393 ; add(di|si)cc instruction pattern(s).
5394 ;
5395
5396 ; the following 4 patterns are used when the result of an add with
5397 ; carry is checked for an overflow condition
5398
5399 ; op1 + op2 + c < op1
5400
5401 ; alcr, alc, alcgr, alcg
5402 (define_insn "*add<mode>3_alc_carry1_cc"
5403 [(set (reg CC_REGNUM)
5404 (compare
5405 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5406 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5407 (match_operand:GPR 2 "general_operand" "d,RT"))
5408 (match_dup 1)))
5409 (set (match_operand:GPR 0 "register_operand" "=d,d")
5410 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5411 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5412 "@
5413 alc<g>r\t%0,%2
5414 alc<g>\t%0,%2"
5415 [(set_attr "op_type" "RRE,RXY")
5416 (set_attr "z196prop" "z196_alone,z196_alone")])
5417
5418 ; alcr, alc, alcgr, alcg
5419 (define_insn "*add<mode>3_alc_carry1_cconly"
5420 [(set (reg CC_REGNUM)
5421 (compare
5422 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5423 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5424 (match_operand:GPR 2 "general_operand" "d,RT"))
5425 (match_dup 1)))
5426 (clobber (match_scratch:GPR 0 "=d,d"))]
5427 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5428 "@
5429 alc<g>r\t%0,%2
5430 alc<g>\t%0,%2"
5431 [(set_attr "op_type" "RRE,RXY")
5432 (set_attr "z196prop" "z196_alone,z196_alone")])
5433
5434 ; op1 + op2 + c < op2
5435
5436 ; alcr, alc, alcgr, alcg
5437 (define_insn "*add<mode>3_alc_carry2_cc"
5438 [(set (reg CC_REGNUM)
5439 (compare
5440 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5441 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5442 (match_operand:GPR 2 "general_operand" "d,RT"))
5443 (match_dup 2)))
5444 (set (match_operand:GPR 0 "register_operand" "=d,d")
5445 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5446 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5447 "@
5448 alc<g>r\t%0,%2
5449 alc<g>\t%0,%2"
5450 [(set_attr "op_type" "RRE,RXY")])
5451
5452 ; alcr, alc, alcgr, alcg
5453 (define_insn "*add<mode>3_alc_carry2_cconly"
5454 [(set (reg CC_REGNUM)
5455 (compare
5456 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5457 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5458 (match_operand:GPR 2 "general_operand" "d,RT"))
5459 (match_dup 2)))
5460 (clobber (match_scratch:GPR 0 "=d,d"))]
5461 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5462 "@
5463 alc<g>r\t%0,%2
5464 alc<g>\t%0,%2"
5465 [(set_attr "op_type" "RRE,RXY")])
5466
5467 ; alcr, alc, alcgr, alcg
5468 (define_insn "*add<mode>3_alc_cc"
5469 [(set (reg CC_REGNUM)
5470 (compare
5471 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5472 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5473 (match_operand:GPR 2 "general_operand" "d,RT"))
5474 (const_int 0)))
5475 (set (match_operand:GPR 0 "register_operand" "=d,d")
5476 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5477 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5478 "@
5479 alc<g>r\t%0,%2
5480 alc<g>\t%0,%2"
5481 [(set_attr "op_type" "RRE,RXY")])
5482
5483 ; alcr, alc, alcgr, alcg
5484 (define_insn "*add<mode>3_alc"
5485 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5486 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5487 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5488 (match_operand:GPR 2 "general_operand" "d,RT")))
5489 (clobber (reg:CC CC_REGNUM))]
5490 "TARGET_CPU_ZARCH"
5491 "@
5492 alc<g>r\t%0,%2
5493 alc<g>\t%0,%2"
5494 [(set_attr "op_type" "RRE,RXY")])
5495
5496 ; slbr, slb, slbgr, slbg
5497 (define_insn "*sub<mode>3_slb_cc"
5498 [(set (reg CC_REGNUM)
5499 (compare
5500 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5501 (match_operand:GPR 2 "general_operand" "d,RT"))
5502 (match_operand:GPR 3 "s390_slb_comparison" ""))
5503 (const_int 0)))
5504 (set (match_operand:GPR 0 "register_operand" "=d,d")
5505 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
5506 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5507 "@
5508 slb<g>r\t%0,%2
5509 slb<g>\t%0,%2"
5510 [(set_attr "op_type" "RRE,RXY")
5511 (set_attr "z10prop" "z10_c,*")])
5512
5513 ; slbr, slb, slbgr, slbg
5514 (define_insn "*sub<mode>3_slb"
5515 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5516 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5517 (match_operand:GPR 2 "general_operand" "d,RT"))
5518 (match_operand:GPR 3 "s390_slb_comparison" "")))
5519 (clobber (reg:CC CC_REGNUM))]
5520 "TARGET_CPU_ZARCH"
5521 "@
5522 slb<g>r\t%0,%2
5523 slb<g>\t%0,%2"
5524 [(set_attr "op_type" "RRE,RXY")
5525 (set_attr "z10prop" "z10_c,*")])
5526
5527 (define_expand "add<mode>cc"
5528 [(match_operand:GPR 0 "register_operand" "")
5529 (match_operand 1 "comparison_operator" "")
5530 (match_operand:GPR 2 "register_operand" "")
5531 (match_operand:GPR 3 "const_int_operand" "")]
5532 "TARGET_CPU_ZARCH"
5533 "if (!s390_expand_addcc (GET_CODE (operands[1]),
5534 XEXP (operands[1], 0), XEXP (operands[1], 1),
5535 operands[0], operands[2],
5536 operands[3])) FAIL; DONE;")
5537
5538 ;
5539 ; scond instruction pattern(s).
5540 ;
5541
5542 (define_insn_and_split "*scond<mode>"
5543 [(set (match_operand:GPR 0 "register_operand" "=&d")
5544 (match_operand:GPR 1 "s390_alc_comparison" ""))
5545 (clobber (reg:CC CC_REGNUM))]
5546 "TARGET_CPU_ZARCH"
5547 "#"
5548 "&& reload_completed"
5549 [(set (match_dup 0) (const_int 0))
5550 (parallel
5551 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
5552 (match_dup 0)))
5553 (clobber (reg:CC CC_REGNUM))])]
5554 "")
5555
5556 (define_insn_and_split "*scond<mode>_neg"
5557 [(set (match_operand:GPR 0 "register_operand" "=&d")
5558 (match_operand:GPR 1 "s390_slb_comparison" ""))
5559 (clobber (reg:CC CC_REGNUM))]
5560 "TARGET_CPU_ZARCH"
5561 "#"
5562 "&& reload_completed"
5563 [(set (match_dup 0) (const_int 0))
5564 (parallel
5565 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
5566 (match_dup 1)))
5567 (clobber (reg:CC CC_REGNUM))])
5568 (parallel
5569 [(set (match_dup 0) (neg:GPR (match_dup 0)))
5570 (clobber (reg:CC CC_REGNUM))])]
5571 "")
5572
5573
5574 (define_expand "cstore<mode>4"
5575 [(set (match_operand:SI 0 "register_operand" "")
5576 (match_operator:SI 1 "s390_scond_operator"
5577 [(match_operand:GPR 2 "register_operand" "")
5578 (match_operand:GPR 3 "general_operand" "")]))]
5579 "TARGET_CPU_ZARCH"
5580 "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3],
5581 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
5582
5583 (define_expand "cstorecc4"
5584 [(parallel
5585 [(set (match_operand:SI 0 "register_operand" "")
5586 (match_operator:SI 1 "s390_eqne_operator"
5587 [(match_operand:CCZ1 2 "register_operand")
5588 (match_operand 3 "const0_operand")]))
5589 (clobber (reg:CC CC_REGNUM))])]
5590 ""
5591 "emit_insn (gen_sne (operands[0], operands[2]));
5592 if (GET_CODE (operands[1]) == EQ)
5593 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
5594 DONE;")
5595
5596 (define_insn_and_split "sne"
5597 [(set (match_operand:SI 0 "register_operand" "=d")
5598 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
5599 (const_int 0)))
5600 (clobber (reg:CC CC_REGNUM))]
5601 ""
5602 "#"
5603 "reload_completed"
5604 [(parallel
5605 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
5606 (clobber (reg:CC CC_REGNUM))])])
5607
5608
5609 ;;
5610 ;; - Conditional move instructions (introduced with z196)
5611 ;;
5612
5613 (define_expand "mov<mode>cc"
5614 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
5615 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
5616 (match_operand:GPR 2 "nonimmediate_operand" "")
5617 (match_operand:GPR 3 "nonimmediate_operand" "")))]
5618 "TARGET_Z196"
5619 "operands[1] = s390_emit_compare (GET_CODE (operands[1]),
5620 XEXP (operands[1], 0), XEXP (operands[1], 1));")
5621
5622 ; locr, loc, stoc, locgr, locg, stocg
5623 (define_insn_and_split "*mov<mode>cc"
5624 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,QS,QS,&d")
5625 (if_then_else:GPR
5626 (match_operator 1 "s390_comparison"
5627 [(match_operand 2 "cc_reg_operand" " c,c, c, c, c, c, c")
5628 (match_operand 5 "const_int_operand" "")])
5629 (match_operand:GPR 3 "nonimmediate_operand" " d,0,QS, 0, d, 0,QS")
5630 (match_operand:GPR 4 "nonimmediate_operand" " 0,d, 0,QS, 0, d,QS")))]
5631 "TARGET_Z196"
5632 "@
5633 loc<g>r%C1\t%0,%3
5634 loc<g>r%D1\t%0,%4
5635 loc<g>%C1\t%0,%3
5636 loc<g>%D1\t%0,%4
5637 stoc<g>%C1\t%3,%0
5638 stoc<g>%D1\t%4,%0
5639 #"
5640 "&& reload_completed
5641 && MEM_P (operands[3]) && MEM_P (operands[4])"
5642 [(set (match_dup 0)
5643 (if_then_else:GPR
5644 (match_op_dup 1 [(match_dup 2) (const_int 0)])
5645 (match_dup 3)
5646 (match_dup 0)))
5647 (set (match_dup 0)
5648 (if_then_else:GPR
5649 (match_op_dup 1 [(match_dup 2) (const_int 0)])
5650 (match_dup 0)
5651 (match_dup 4)))]
5652 ""
5653 [(set_attr "op_type" "RRF,RRF,RSY,RSY,RSY,RSY,*")])
5654
5655 ;;
5656 ;;- Multiply instructions.
5657 ;;
5658
5659 ;
5660 ; muldi3 instruction pattern(s).
5661 ;
5662
5663 (define_insn "*muldi3_sign"
5664 [(set (match_operand:DI 0 "register_operand" "=d,d")
5665 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
5666 (match_operand:DI 1 "register_operand" "0,0")))]
5667 "TARGET_ZARCH"
5668 "@
5669 msgfr\t%0,%2
5670 msgf\t%0,%2"
5671 [(set_attr "op_type" "RRE,RXY")
5672 (set_attr "type" "imuldi")])
5673
5674 (define_insn "muldi3"
5675 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
5676 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5677 (match_operand:DI 2 "general_operand" "d,K,RT,Os")))]
5678 "TARGET_ZARCH"
5679 "@
5680 msgr\t%0,%2
5681 mghi\t%0,%h2
5682 msg\t%0,%2
5683 msgfi\t%0,%2"
5684 [(set_attr "op_type" "RRE,RI,RXY,RIL")
5685 (set_attr "type" "imuldi")
5686 (set_attr "cpu_facility" "*,*,*,z10")])
5687
5688 ;
5689 ; mulsi3 instruction pattern(s).
5690 ;
5691
5692 (define_insn "*mulsi3_sign"
5693 [(set (match_operand:SI 0 "register_operand" "=d,d")
5694 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5695 (match_operand:SI 1 "register_operand" "0,0")))]
5696 ""
5697 "@
5698 mh\t%0,%2
5699 mhy\t%0,%2"
5700 [(set_attr "op_type" "RX,RXY")
5701 (set_attr "type" "imulhi")
5702 (set_attr "cpu_facility" "*,z10")])
5703
5704 (define_insn "mulsi3"
5705 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
5706 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
5707 (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
5708 ""
5709 "@
5710 msr\t%0,%2
5711 mhi\t%0,%h2
5712 ms\t%0,%2
5713 msy\t%0,%2
5714 msfi\t%0,%2"
5715 [(set_attr "op_type" "RRE,RI,RX,RXY,RIL")
5716 (set_attr "type" "imulsi,imulhi,imulsi,imulsi,imulsi")
5717 (set_attr "cpu_facility" "*,*,*,*,z10")])
5718
5719 ;
5720 ; mulsidi3 instruction pattern(s).
5721 ;
5722
5723 (define_insn "mulsidi3"
5724 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
5725 (mult:DI (sign_extend:DI
5726 (match_operand:SI 1 "register_operand" "%0,0,0"))
5727 (sign_extend:DI
5728 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
5729 "!TARGET_ZARCH"
5730 "@
5731 mr\t%0,%2
5732 m\t%0,%2
5733 mfy\t%0,%2"
5734 [(set_attr "op_type" "RR,RX,RXY")
5735 (set_attr "type" "imulsi")
5736 (set_attr "cpu_facility" "*,*,z10")])
5737
5738 ;
5739 ; umul instruction pattern(s).
5740 ;
5741
5742 ; mlr, ml, mlgr, mlg
5743 (define_insn "umul<dwh><mode>3"
5744 [(set (match_operand:DW 0 "register_operand" "=d, d")
5745 (mult:DW (zero_extend:DW
5746 (match_operand:<DWH> 1 "register_operand" "%0, 0"))
5747 (zero_extend:DW
5748 (match_operand:<DWH> 2 "nonimmediate_operand" " d,RT"))))]
5749 "TARGET_CPU_ZARCH"
5750 "@
5751 ml<tg>r\t%0,%2
5752 ml<tg>\t%0,%2"
5753 [(set_attr "op_type" "RRE,RXY")
5754 (set_attr "type" "imul<dwh>")])
5755
5756 ;
5757 ; mul(tf|df|sf|td|dd)3 instruction pattern(s).
5758 ;
5759
5760 ; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
5761 (define_insn "mul<mode>3"
5762 [(set (match_operand:FP 0 "register_operand" "=f,f")
5763 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5764 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
5765 "TARGET_HARD_FLOAT"
5766 "@
5767 m<xdee><bt>r\t%0,<op1>%2
5768 m<xdee>b\t%0,%2"
5769 [(set_attr "op_type" "<RRer>,RXE")
5770 (set_attr "type" "fmul<mode>")])
5771
5772 ; madbr, maebr, maxb, madb, maeb
5773 (define_insn "fma<mode>4"
5774 [(set (match_operand:DSF 0 "register_operand" "=f,f")
5775 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f")
5776 (match_operand:DSF 2 "nonimmediate_operand" "f,R")
5777 (match_operand:DSF 3 "register_operand" "0,0")))]
5778 "TARGET_HARD_FLOAT"
5779 "@
5780 ma<xde>br\t%0,%1,%2
5781 ma<xde>b\t%0,%1,%2"
5782 [(set_attr "op_type" "RRE,RXE")
5783 (set_attr "type" "fmadd<mode>")])
5784
5785 ; msxbr, msdbr, msebr, msxb, msdb, mseb
5786 (define_insn "fms<mode>4"
5787 [(set (match_operand:DSF 0 "register_operand" "=f,f")
5788 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f")
5789 (match_operand:DSF 2 "nonimmediate_operand" "f,R")
5790 (neg:DSF (match_operand:DSF 3 "register_operand" "0,0"))))]
5791 "TARGET_HARD_FLOAT"
5792 "@
5793 ms<xde>br\t%0,%1,%2
5794 ms<xde>b\t%0,%1,%2"
5795 [(set_attr "op_type" "RRE,RXE")
5796 (set_attr "type" "fmadd<mode>")])
5797
5798 ;;
5799 ;;- Divide and modulo instructions.
5800 ;;
5801
5802 ;
5803 ; divmoddi4 instruction pattern(s).
5804 ;
5805
5806 (define_expand "divmoddi4"
5807 [(parallel [(set (match_operand:DI 0 "general_operand" "")
5808 (div:DI (match_operand:DI 1 "register_operand" "")
5809 (match_operand:DI 2 "general_operand" "")))
5810 (set (match_operand:DI 3 "general_operand" "")
5811 (mod:DI (match_dup 1) (match_dup 2)))])
5812 (clobber (match_dup 4))]
5813 "TARGET_ZARCH"
5814 {
5815 rtx insn, div_equal, mod_equal;
5816
5817 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
5818 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
5819
5820 operands[4] = gen_reg_rtx(TImode);
5821 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
5822
5823 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5824 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5825
5826 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5827 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5828
5829 DONE;
5830 })
5831
5832 (define_insn "divmodtidi3"
5833 [(set (match_operand:TI 0 "register_operand" "=d,d")
5834 (ior:TI
5835 (ashift:TI
5836 (zero_extend:TI
5837 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5838 (match_operand:DI 2 "general_operand" "d,RT")))
5839 (const_int 64))
5840 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
5841 "TARGET_ZARCH"
5842 "@
5843 dsgr\t%0,%2
5844 dsg\t%0,%2"
5845 [(set_attr "op_type" "RRE,RXY")
5846 (set_attr "type" "idiv")])
5847
5848 (define_insn "divmodtisi3"
5849 [(set (match_operand:TI 0 "register_operand" "=d,d")
5850 (ior:TI
5851 (ashift:TI
5852 (zero_extend:TI
5853 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5854 (sign_extend:DI
5855 (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))
5856 (const_int 64))
5857 (zero_extend:TI
5858 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
5859 "TARGET_ZARCH"
5860 "@
5861 dsgfr\t%0,%2
5862 dsgf\t%0,%2"
5863 [(set_attr "op_type" "RRE,RXY")
5864 (set_attr "type" "idiv")])
5865
5866 ;
5867 ; udivmoddi4 instruction pattern(s).
5868 ;
5869
5870 (define_expand "udivmoddi4"
5871 [(parallel [(set (match_operand:DI 0 "general_operand" "")
5872 (udiv:DI (match_operand:DI 1 "general_operand" "")
5873 (match_operand:DI 2 "nonimmediate_operand" "")))
5874 (set (match_operand:DI 3 "general_operand" "")
5875 (umod:DI (match_dup 1) (match_dup 2)))])
5876 (clobber (match_dup 4))]
5877 "TARGET_ZARCH"
5878 {
5879 rtx insn, div_equal, mod_equal, equal;
5880
5881 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
5882 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
5883 equal = gen_rtx_IOR (TImode,
5884 gen_rtx_ASHIFT (TImode,
5885 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
5886 GEN_INT (64)),
5887 gen_rtx_ZERO_EXTEND (TImode, div_equal));
5888
5889 operands[4] = gen_reg_rtx(TImode);
5890 emit_clobber (operands[4]);
5891 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
5892 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
5893
5894 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
5895 set_unique_reg_note (insn, REG_EQUAL, equal);
5896
5897 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5898 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5899
5900 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5901 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5902
5903 DONE;
5904 })
5905
5906 (define_insn "udivmodtidi3"
5907 [(set (match_operand:TI 0 "register_operand" "=d,d")
5908 (ior:TI
5909 (ashift:TI
5910 (zero_extend:TI
5911 (truncate:DI
5912 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
5913 (zero_extend:TI
5914 (match_operand:DI 2 "nonimmediate_operand" "d,RT")))))
5915 (const_int 64))
5916 (zero_extend:TI
5917 (truncate:DI
5918 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
5919 "TARGET_ZARCH"
5920 "@
5921 dlgr\t%0,%2
5922 dlg\t%0,%2"
5923 [(set_attr "op_type" "RRE,RXY")
5924 (set_attr "type" "idiv")])
5925
5926 ;
5927 ; divmodsi4 instruction pattern(s).
5928 ;
5929
5930 (define_expand "divmodsi4"
5931 [(parallel [(set (match_operand:SI 0 "general_operand" "")
5932 (div:SI (match_operand:SI 1 "general_operand" "")
5933 (match_operand:SI 2 "nonimmediate_operand" "")))
5934 (set (match_operand:SI 3 "general_operand" "")
5935 (mod:SI (match_dup 1) (match_dup 2)))])
5936 (clobber (match_dup 4))]
5937 "!TARGET_ZARCH"
5938 {
5939 rtx insn, div_equal, mod_equal, equal;
5940
5941 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
5942 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
5943 equal = gen_rtx_IOR (DImode,
5944 gen_rtx_ASHIFT (DImode,
5945 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5946 GEN_INT (32)),
5947 gen_rtx_ZERO_EXTEND (DImode, div_equal));
5948
5949 operands[4] = gen_reg_rtx(DImode);
5950 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
5951
5952 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
5953 set_unique_reg_note (insn, REG_EQUAL, equal);
5954
5955 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5956 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5957
5958 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5959 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5960
5961 DONE;
5962 })
5963
5964 (define_insn "divmoddisi3"
5965 [(set (match_operand:DI 0 "register_operand" "=d,d")
5966 (ior:DI
5967 (ashift:DI
5968 (zero_extend:DI
5969 (truncate:SI
5970 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5971 (sign_extend:DI
5972 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
5973 (const_int 32))
5974 (zero_extend:DI
5975 (truncate:SI
5976 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
5977 "!TARGET_ZARCH"
5978 "@
5979 dr\t%0,%2
5980 d\t%0,%2"
5981 [(set_attr "op_type" "RR,RX")
5982 (set_attr "type" "idiv")])
5983
5984 ;
5985 ; udivsi3 and umodsi3 instruction pattern(s).
5986 ;
5987
5988 (define_expand "udivmodsi4"
5989 [(parallel [(set (match_operand:SI 0 "general_operand" "")
5990 (udiv:SI (match_operand:SI 1 "general_operand" "")
5991 (match_operand:SI 2 "nonimmediate_operand" "")))
5992 (set (match_operand:SI 3 "general_operand" "")
5993 (umod:SI (match_dup 1) (match_dup 2)))])
5994 (clobber (match_dup 4))]
5995 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
5996 {
5997 rtx insn, div_equal, mod_equal, equal;
5998
5999 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6000 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6001 equal = gen_rtx_IOR (DImode,
6002 gen_rtx_ASHIFT (DImode,
6003 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
6004 GEN_INT (32)),
6005 gen_rtx_ZERO_EXTEND (DImode, div_equal));
6006
6007 operands[4] = gen_reg_rtx(DImode);
6008 emit_clobber (operands[4]);
6009 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
6010 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
6011
6012 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
6013 set_unique_reg_note (insn, REG_EQUAL, equal);
6014
6015 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
6016 set_unique_reg_note (insn, REG_EQUAL, div_equal);
6017
6018 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
6019 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
6020
6021 DONE;
6022 })
6023
6024 (define_insn "udivmoddisi3"
6025 [(set (match_operand:DI 0 "register_operand" "=d,d")
6026 (ior:DI
6027 (ashift:DI
6028 (zero_extend:DI
6029 (truncate:SI
6030 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
6031 (zero_extend:DI
6032 (match_operand:SI 2 "nonimmediate_operand" "d,RT")))))
6033 (const_int 32))
6034 (zero_extend:DI
6035 (truncate:SI
6036 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
6037 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
6038 "@
6039 dlr\t%0,%2
6040 dl\t%0,%2"
6041 [(set_attr "op_type" "RRE,RXY")
6042 (set_attr "type" "idiv")])
6043
6044 (define_expand "udivsi3"
6045 [(set (match_operand:SI 0 "register_operand" "=d")
6046 (udiv:SI (match_operand:SI 1 "general_operand" "")
6047 (match_operand:SI 2 "general_operand" "")))
6048 (clobber (match_dup 3))]
6049 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
6050 {
6051 rtx insn, udiv_equal, umod_equal, equal;
6052
6053 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6054 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6055 equal = gen_rtx_IOR (DImode,
6056 gen_rtx_ASHIFT (DImode,
6057 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
6058 GEN_INT (32)),
6059 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
6060
6061 operands[3] = gen_reg_rtx (DImode);
6062
6063 if (CONSTANT_P (operands[2]))
6064 {
6065 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
6066 {
6067 rtx label1 = gen_label_rtx ();
6068
6069 operands[1] = make_safe_from (operands[1], operands[0]);
6070 emit_move_insn (operands[0], const0_rtx);
6071 emit_cmp_and_jump_insns (operands[1], operands[2], LT, NULL_RTX,
6072 SImode, 1, label1);
6073 emit_move_insn (operands[0], const1_rtx);
6074 emit_label (label1);
6075 }
6076 else
6077 {
6078 operands[2] = force_reg (SImode, operands[2]);
6079 operands[2] = make_safe_from (operands[2], operands[0]);
6080
6081 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6082 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6083 operands[2]));
6084 set_unique_reg_note (insn, REG_EQUAL, equal);
6085
6086 insn = emit_move_insn (operands[0],
6087 gen_lowpart (SImode, operands[3]));
6088 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
6089 }
6090 }
6091 else
6092 {
6093 rtx label1 = gen_label_rtx ();
6094 rtx label2 = gen_label_rtx ();
6095 rtx label3 = gen_label_rtx ();
6096
6097 operands[1] = force_reg (SImode, operands[1]);
6098 operands[1] = make_safe_from (operands[1], operands[0]);
6099 operands[2] = force_reg (SImode, operands[2]);
6100 operands[2] = make_safe_from (operands[2], operands[0]);
6101
6102 emit_move_insn (operands[0], const0_rtx);
6103 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
6104 SImode, 1, label3);
6105 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
6106 SImode, 0, label2);
6107 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
6108 SImode, 0, label1);
6109 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6110 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6111 operands[2]));
6112 set_unique_reg_note (insn, REG_EQUAL, equal);
6113
6114 insn = emit_move_insn (operands[0],
6115 gen_lowpart (SImode, operands[3]));
6116 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
6117
6118 emit_jump (label3);
6119 emit_label (label1);
6120 emit_move_insn (operands[0], operands[1]);
6121 emit_jump (label3);
6122 emit_label (label2);
6123 emit_move_insn (operands[0], const1_rtx);
6124 emit_label (label3);
6125 }
6126 emit_move_insn (operands[0], operands[0]);
6127 DONE;
6128 })
6129
6130 (define_expand "umodsi3"
6131 [(set (match_operand:SI 0 "register_operand" "=d")
6132 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
6133 (match_operand:SI 2 "nonimmediate_operand" "")))
6134 (clobber (match_dup 3))]
6135 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
6136 {
6137 rtx insn, udiv_equal, umod_equal, equal;
6138
6139 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6140 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6141 equal = gen_rtx_IOR (DImode,
6142 gen_rtx_ASHIFT (DImode,
6143 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
6144 GEN_INT (32)),
6145 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
6146
6147 operands[3] = gen_reg_rtx (DImode);
6148
6149 if (CONSTANT_P (operands[2]))
6150 {
6151 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
6152 {
6153 rtx label1 = gen_label_rtx ();
6154
6155 operands[1] = make_safe_from (operands[1], operands[0]);
6156 emit_move_insn (operands[0], operands[1]);
6157 emit_cmp_and_jump_insns (operands[0], operands[2], LT, NULL_RTX,
6158 SImode, 1, label1);
6159 emit_insn (gen_abssi2 (operands[0], operands[2]));
6160 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
6161 emit_label (label1);
6162 }
6163 else
6164 {
6165 operands[2] = force_reg (SImode, operands[2]);
6166 operands[2] = make_safe_from (operands[2], operands[0]);
6167
6168 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6169 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6170 operands[2]));
6171 set_unique_reg_note (insn, REG_EQUAL, equal);
6172
6173 insn = emit_move_insn (operands[0],
6174 gen_highpart (SImode, operands[3]));
6175 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
6176 }
6177 }
6178 else
6179 {
6180 rtx label1 = gen_label_rtx ();
6181 rtx label2 = gen_label_rtx ();
6182 rtx label3 = gen_label_rtx ();
6183
6184 operands[1] = force_reg (SImode, operands[1]);
6185 operands[1] = make_safe_from (operands[1], operands[0]);
6186 operands[2] = force_reg (SImode, operands[2]);
6187 operands[2] = make_safe_from (operands[2], operands[0]);
6188
6189 emit_move_insn(operands[0], operands[1]);
6190 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
6191 SImode, 1, label3);
6192 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
6193 SImode, 0, label2);
6194 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
6195 SImode, 0, label1);
6196 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6197 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6198 operands[2]));
6199 set_unique_reg_note (insn, REG_EQUAL, equal);
6200
6201 insn = emit_move_insn (operands[0],
6202 gen_highpart (SImode, operands[3]));
6203 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
6204
6205 emit_jump (label3);
6206 emit_label (label1);
6207 emit_move_insn (operands[0], const0_rtx);
6208 emit_jump (label3);
6209 emit_label (label2);
6210 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
6211 emit_label (label3);
6212 }
6213 DONE;
6214 })
6215
6216 ;
6217 ; div(df|sf)3 instruction pattern(s).
6218 ;
6219
6220 ; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
6221 (define_insn "div<mode>3"
6222 [(set (match_operand:FP 0 "register_operand" "=f,f")
6223 (div:FP (match_operand:FP 1 "register_operand" "<f0>,0")
6224 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
6225 "TARGET_HARD_FLOAT"
6226 "@
6227 d<xde><bt>r\t%0,<op1>%2
6228 d<xde>b\t%0,%2"
6229 [(set_attr "op_type" "<RRer>,RXE")
6230 (set_attr "type" "fdiv<mode>")])
6231
6232
6233 ;;
6234 ;;- And instructions.
6235 ;;
6236
6237 (define_expand "and<mode>3"
6238 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6239 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
6240 (match_operand:INT 2 "general_operand" "")))
6241 (clobber (reg:CC CC_REGNUM))]
6242 ""
6243 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
6244
6245 ;
6246 ; anddi3 instruction pattern(s).
6247 ;
6248
6249 (define_insn "*anddi3_cc"
6250 [(set (reg CC_REGNUM)
6251 (compare
6252 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0, d")
6253 (match_operand:DI 2 "general_operand" " d,d,RT,NxxDq"))
6254 (const_int 0)))
6255 (set (match_operand:DI 0 "register_operand" "=d,d, d, d")
6256 (and:DI (match_dup 1) (match_dup 2)))]
6257 "TARGET_ZARCH && s390_match_ccmode(insn, CCTmode)"
6258 "@
6259 ngr\t%0,%2
6260 ngrk\t%0,%1,%2
6261 ng\t%0,%2
6262 risbg\t%0,%1,%s2,128+%e2,0"
6263 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
6264 (set_attr "cpu_facility" "*,z196,*,z10")
6265 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6266
6267 (define_insn "*anddi3_cconly"
6268 [(set (reg CC_REGNUM)
6269 (compare
6270 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0, d")
6271 (match_operand:DI 2 "general_operand" " d,d,RT,NxxDq"))
6272 (const_int 0)))
6273 (clobber (match_scratch:DI 0 "=d,d, d, d"))]
6274 "TARGET_ZARCH
6275 && s390_match_ccmode(insn, CCTmode)
6276 /* Do not steal TM patterns. */
6277 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
6278 "@
6279 ngr\t%0,%2
6280 ngrk\t%0,%1,%2
6281 ng\t%0,%2
6282 risbg\t%0,%1,%s2,128+%e2,0"
6283 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
6284 (set_attr "cpu_facility" "*,z196,*,z10")
6285 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6286
6287 (define_insn "*anddi3"
6288 [(set (match_operand:DI 0 "nonimmediate_operand"
6289 "=d,d, d, d, d, d, d, d,d,d, d, d, AQ,Q")
6290 (and:DI
6291 (match_operand:DI 1 "nonimmediate_operand"
6292 "%d,o, 0, 0, 0, 0, 0, 0,0,d, 0, d, 0,0")
6293 (match_operand:DI 2 "general_operand"
6294 "M, M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,d,RT,NxxDq,NxQDF,Q")))
6295 (clobber (reg:CC CC_REGNUM))]
6296 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6297 "@
6298 #
6299 #
6300 nihh\t%0,%j2
6301 nihl\t%0,%j2
6302 nilh\t%0,%j2
6303 nill\t%0,%j2
6304 nihf\t%0,%m2
6305 nilf\t%0,%m2
6306 ngr\t%0,%2
6307 ngrk\t%0,%1,%2
6308 ng\t%0,%2
6309 risbg\t%0,%1,%s2,128+%e2,0
6310 #
6311 #"
6312 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,RIE,SI,SS")
6313 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,z196,*,z10,*,*")
6314 (set_attr "z10prop" "*,
6315 *,
6316 z10_super_E1,
6317 z10_super_E1,
6318 z10_super_E1,
6319 z10_super_E1,
6320 z10_super_E1,
6321 z10_super_E1,
6322 z10_super_E1,
6323 *,
6324 z10_super_E1,
6325 z10_super_E1,
6326 *,
6327 *")])
6328
6329 (define_split
6330 [(set (match_operand:DI 0 "s_operand" "")
6331 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6332 (clobber (reg:CC CC_REGNUM))]
6333 "reload_completed"
6334 [(parallel
6335 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
6336 (clobber (reg:CC CC_REGNUM))])]
6337 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
6338
6339 ;; These two are what combine generates for (ashift (zero_extract)).
6340 (define_insn "*extzv_<mode>_srl"
6341 [(set (match_operand:GPR 0 "register_operand" "=d")
6342 (and:GPR (lshiftrt:GPR
6343 (match_operand:GPR 1 "register_operand" "d")
6344 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
6345 (match_operand:GPR 3 "contiguous_bitmask_operand" "")))
6346 (clobber (reg:CC CC_REGNUM))]
6347 "TARGET_Z10
6348 /* Note that even for the SImode pattern, the rotate is always DImode. */
6349 && s390_extzv_shift_ok (<bitsize>, -INTVAL (operands[2]),
6350 INTVAL (operands[3]))"
6351 "risbg\t%0,%1,%<bfstart>3,128+%<bfend>3,64-%2"
6352 [(set_attr "op_type" "RIE")
6353 (set_attr "z10prop" "z10_super_E1")])
6354
6355 (define_insn "*extzv_<mode>_sll"
6356 [(set (match_operand:GPR 0 "register_operand" "=d")
6357 (and:GPR (ashift:GPR
6358 (match_operand:GPR 1 "register_operand" "d")
6359 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
6360 (match_operand:GPR 3 "contiguous_bitmask_operand" "")))
6361 (clobber (reg:CC CC_REGNUM))]
6362 "TARGET_Z10
6363 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[2]),
6364 INTVAL (operands[3]))"
6365 "risbg\t%0,%1,%<bfstart>3,128+%<bfend>3,%2"
6366 [(set_attr "op_type" "RIE")
6367 (set_attr "z10prop" "z10_super_E1")])
6368
6369
6370 ;
6371 ; andsi3 instruction pattern(s).
6372 ;
6373
6374 (define_insn "*andsi3_cc"
6375 [(set (reg CC_REGNUM)
6376 (compare
6377 (and:SI
6378 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
6379 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
6380 (const_int 0)))
6381 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d, d")
6382 (and:SI (match_dup 1) (match_dup 2)))]
6383 "s390_match_ccmode(insn, CCTmode)"
6384 "@
6385 nilf\t%0,%o2
6386 nr\t%0,%2
6387 nrk\t%0,%1,%2
6388 n\t%0,%2
6389 ny\t%0,%2
6390 risbg\t%0,%1,%t2,128+%f2,0"
6391 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
6392 (set_attr "cpu_facility" "*,*,z196,*,*,z10")
6393 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
6394 z10_super_E1,z10_super_E1,z10_super_E1")])
6395
6396 (define_insn "*andsi3_cconly"
6397 [(set (reg CC_REGNUM)
6398 (compare
6399 (and:SI
6400 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
6401 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
6402 (const_int 0)))
6403 (clobber (match_scratch:SI 0 "=d,d,d,d,d, d"))]
6404 "s390_match_ccmode(insn, CCTmode)
6405 /* Do not steal TM patterns. */
6406 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
6407 "@
6408 nilf\t%0,%o2
6409 nr\t%0,%2
6410 nrk\t%0,%1,%2
6411 n\t%0,%2
6412 ny\t%0,%2
6413 risbg\t%0,%1,%t2,128+%f2,0"
6414 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
6415 (set_attr "cpu_facility" "*,*,z196,*,*,z10")
6416 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
6417 z10_super_E1,z10_super_E1,z10_super_E1")])
6418
6419 (define_insn "*andsi3_zarch"
6420 [(set (match_operand:SI 0 "nonimmediate_operand"
6421 "=d,d, d, d, d,d,d,d,d, d, AQ,Q")
6422 (and:SI (match_operand:SI 1 "nonimmediate_operand"
6423 "%d,o, 0, 0, 0,0,d,0,0, d, 0,0")
6424 (match_operand:SI 2 "general_operand"
6425 " M,M,N0HSF,N1HSF,Os,d,d,R,T,NxxSq,NxQSF,Q")))
6426 (clobber (reg:CC CC_REGNUM))]
6427 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6428 "@
6429 #
6430 #
6431 nilh\t%0,%j2
6432 nill\t%0,%j2
6433 nilf\t%0,%o2
6434 nr\t%0,%2
6435 nrk\t%0,%1,%2
6436 n\t%0,%2
6437 ny\t%0,%2
6438 risbg\t%0,%1,%t2,128+%f2,0
6439 #
6440 #"
6441 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RRF,RX,RXY,RIE,SI,SS")
6442 (set_attr "cpu_facility" "*,*,*,*,*,*,z196,*,*,z10,*,*")
6443 (set_attr "z10prop" "*,
6444 *,
6445 z10_super_E1,
6446 z10_super_E1,
6447 z10_super_E1,
6448 z10_super_E1,
6449 *,
6450 z10_super_E1,
6451 z10_super_E1,
6452 z10_super_E1,
6453 *,
6454 *")])
6455
6456 (define_insn "*andsi3_esa"
6457 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d, AQ,Q")
6458 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0, 0,0")
6459 (match_operand:SI 2 "general_operand" " d,R,NxQSF,Q")))
6460 (clobber (reg:CC CC_REGNUM))]
6461 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6462 "@
6463 nr\t%0,%2
6464 n\t%0,%2
6465 #
6466 #"
6467 [(set_attr "op_type" "RR,RX,SI,SS")
6468 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6469
6470
6471 (define_split
6472 [(set (match_operand:SI 0 "s_operand" "")
6473 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6474 (clobber (reg:CC CC_REGNUM))]
6475 "reload_completed"
6476 [(parallel
6477 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
6478 (clobber (reg:CC CC_REGNUM))])]
6479 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
6480
6481 ;
6482 ; andhi3 instruction pattern(s).
6483 ;
6484
6485 (define_insn "*andhi3_zarch"
6486 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
6487 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
6488 (match_operand:HI 2 "general_operand" " d,d,n,NxQHF,Q")))
6489 (clobber (reg:CC CC_REGNUM))]
6490 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6491 "@
6492 nr\t%0,%2
6493 nrk\t%0,%1,%2
6494 nill\t%0,%x2
6495 #
6496 #"
6497 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
6498 (set_attr "cpu_facility" "*,z196,*,*,*")
6499 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")
6500 ])
6501
6502 (define_insn "*andhi3_esa"
6503 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
6504 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
6505 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
6506 (clobber (reg:CC CC_REGNUM))]
6507 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6508 "@
6509 nr\t%0,%2
6510 #
6511 #"
6512 [(set_attr "op_type" "RR,SI,SS")
6513 (set_attr "z10prop" "z10_super_E1,*,*")
6514 ])
6515
6516 (define_split
6517 [(set (match_operand:HI 0 "s_operand" "")
6518 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6519 (clobber (reg:CC CC_REGNUM))]
6520 "reload_completed"
6521 [(parallel
6522 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
6523 (clobber (reg:CC CC_REGNUM))])]
6524 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
6525
6526 ;
6527 ; andqi3 instruction pattern(s).
6528 ;
6529
6530 (define_insn "*andqi3_zarch"
6531 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
6532 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
6533 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
6534 (clobber (reg:CC CC_REGNUM))]
6535 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6536 "@
6537 nr\t%0,%2
6538 nrk\t%0,%1,%2
6539 nill\t%0,%b2
6540 ni\t%S0,%b2
6541 niy\t%S0,%b2
6542 #"
6543 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
6544 (set_attr "cpu_facility" "*,z196,*,*,*,*")
6545 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super,z10_super,*")])
6546
6547 (define_insn "*andqi3_esa"
6548 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
6549 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6550 (match_operand:QI 2 "general_operand" "d,n,Q")))
6551 (clobber (reg:CC CC_REGNUM))]
6552 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6553 "@
6554 nr\t%0,%2
6555 ni\t%S0,%b2
6556 #"
6557 [(set_attr "op_type" "RR,SI,SS")
6558 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
6559
6560 ;
6561 ; Block and (NC) patterns.
6562 ;
6563
6564 (define_insn "*nc"
6565 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6566 (and:BLK (match_dup 0)
6567 (match_operand:BLK 1 "memory_operand" "Q")))
6568 (use (match_operand 2 "const_int_operand" "n"))
6569 (clobber (reg:CC CC_REGNUM))]
6570 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6571 "nc\t%O0(%2,%R0),%S1"
6572 [(set_attr "op_type" "SS")
6573 (set_attr "z196prop" "z196_cracked")])
6574
6575 (define_split
6576 [(set (match_operand 0 "memory_operand" "")
6577 (and (match_dup 0)
6578 (match_operand 1 "memory_operand" "")))
6579 (clobber (reg:CC CC_REGNUM))]
6580 "reload_completed
6581 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6582 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6583 [(parallel
6584 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
6585 (use (match_dup 2))
6586 (clobber (reg:CC CC_REGNUM))])]
6587 {
6588 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6589 operands[0] = adjust_address (operands[0], BLKmode, 0);
6590 operands[1] = adjust_address (operands[1], BLKmode, 0);
6591 })
6592
6593 (define_peephole2
6594 [(parallel
6595 [(set (match_operand:BLK 0 "memory_operand" "")
6596 (and:BLK (match_dup 0)
6597 (match_operand:BLK 1 "memory_operand" "")))
6598 (use (match_operand 2 "const_int_operand" ""))
6599 (clobber (reg:CC CC_REGNUM))])
6600 (parallel
6601 [(set (match_operand:BLK 3 "memory_operand" "")
6602 (and:BLK (match_dup 3)
6603 (match_operand:BLK 4 "memory_operand" "")))
6604 (use (match_operand 5 "const_int_operand" ""))
6605 (clobber (reg:CC CC_REGNUM))])]
6606 "s390_offset_p (operands[0], operands[3], operands[2])
6607 && s390_offset_p (operands[1], operands[4], operands[2])
6608 && !s390_overlap_p (operands[0], operands[1],
6609 INTVAL (operands[2]) + INTVAL (operands[5]))
6610 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6611 [(parallel
6612 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
6613 (use (match_dup 8))
6614 (clobber (reg:CC CC_REGNUM))])]
6615 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6616 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6617 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6618
6619
6620 ;;
6621 ;;- Bit set (inclusive or) instructions.
6622 ;;
6623
6624 (define_expand "ior<mode>3"
6625 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6626 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
6627 (match_operand:INT 2 "general_operand" "")))
6628 (clobber (reg:CC CC_REGNUM))]
6629 ""
6630 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
6631
6632 ;
6633 ; iordi3 instruction pattern(s).
6634 ;
6635
6636 (define_insn "*iordi3_cc"
6637 [(set (reg CC_REGNUM)
6638 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
6639 (match_operand:DI 2 "general_operand" " d,d,RT"))
6640 (const_int 0)))
6641 (set (match_operand:DI 0 "register_operand" "=d,d, d")
6642 (ior:DI (match_dup 1) (match_dup 2)))]
6643 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
6644 "@
6645 ogr\t%0,%2
6646 ogrk\t%0,%1,%2
6647 og\t%0,%2"
6648 [(set_attr "op_type" "RRE,RRF,RXY")
6649 (set_attr "cpu_facility" "*,z196,*")
6650 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6651
6652 (define_insn "*iordi3_cconly"
6653 [(set (reg CC_REGNUM)
6654 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
6655 (match_operand:DI 2 "general_operand" " d,d,RT"))
6656 (const_int 0)))
6657 (clobber (match_scratch:DI 0 "=d,d,d"))]
6658 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
6659 "@
6660 ogr\t%0,%2
6661 ogrk\t%0,%1,%2
6662 og\t%0,%2"
6663 [(set_attr "op_type" "RRE,RRF,RXY")
6664 (set_attr "cpu_facility" "*,z196,*")
6665 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6666
6667 (define_insn "*iordi3"
6668 [(set (match_operand:DI 0 "nonimmediate_operand"
6669 "=d, d, d, d, d, d,d,d, d, AQ,Q")
6670 (ior:DI (match_operand:DI 1 "nonimmediate_operand"
6671 " %0, 0, 0, 0, 0, 0,0,d, 0, 0,0")
6672 (match_operand:DI 2 "general_operand"
6673 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,d,RT,NxQD0,Q")))
6674 (clobber (reg:CC CC_REGNUM))]
6675 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6676 "@
6677 oihh\t%0,%i2
6678 oihl\t%0,%i2
6679 oilh\t%0,%i2
6680 oill\t%0,%i2
6681 oihf\t%0,%k2
6682 oilf\t%0,%k2
6683 ogr\t%0,%2
6684 ogrk\t%0,%1,%2
6685 og\t%0,%2
6686 #
6687 #"
6688 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,SI,SS")
6689 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,z196,*,*,*")
6690 (set_attr "z10prop" "z10_super_E1,
6691 z10_super_E1,
6692 z10_super_E1,
6693 z10_super_E1,
6694 z10_super_E1,
6695 z10_super_E1,
6696 z10_super_E1,
6697 *,
6698 z10_super_E1,
6699 *,
6700 *")])
6701
6702 (define_split
6703 [(set (match_operand:DI 0 "s_operand" "")
6704 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6705 (clobber (reg:CC CC_REGNUM))]
6706 "reload_completed"
6707 [(parallel
6708 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6709 (clobber (reg:CC CC_REGNUM))])]
6710 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6711
6712 ;
6713 ; iorsi3 instruction pattern(s).
6714 ;
6715
6716 (define_insn "*iorsi3_cc"
6717 [(set (reg CC_REGNUM)
6718 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
6719 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
6720 (const_int 0)))
6721 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
6722 (ior:SI (match_dup 1) (match_dup 2)))]
6723 "s390_match_ccmode(insn, CCTmode)"
6724 "@
6725 oilf\t%0,%o2
6726 or\t%0,%2
6727 ork\t%0,%1,%2
6728 o\t%0,%2
6729 oy\t%0,%2"
6730 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
6731 (set_attr "cpu_facility" "*,*,z196,*,*")
6732 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
6733
6734 (define_insn "*iorsi3_cconly"
6735 [(set (reg CC_REGNUM)
6736 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
6737 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
6738 (const_int 0)))
6739 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
6740 "s390_match_ccmode(insn, CCTmode)"
6741 "@
6742 oilf\t%0,%o2
6743 or\t%0,%2
6744 ork\t%0,%1,%2
6745 o\t%0,%2
6746 oy\t%0,%2"
6747 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
6748 (set_attr "cpu_facility" "*,*,z196,*,*")
6749 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
6750
6751 (define_insn "*iorsi3_zarch"
6752 [(set (match_operand:SI 0 "nonimmediate_operand" "=d, d, d,d,d,d,d, AQ,Q")
6753 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0, 0, 0,0,d,0,0, 0,0")
6754 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,d,R,T,NxQS0,Q")))
6755 (clobber (reg:CC CC_REGNUM))]
6756 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6757 "@
6758 oilh\t%0,%i2
6759 oill\t%0,%i2
6760 oilf\t%0,%o2
6761 or\t%0,%2
6762 ork\t%0,%1,%2
6763 o\t%0,%2
6764 oy\t%0,%2
6765 #
6766 #"
6767 [(set_attr "op_type" "RI,RI,RIL,RR,RRF,RX,RXY,SI,SS")
6768 (set_attr "cpu_facility" "*,*,*,*,z196,*,*,*,*")
6769 (set_attr "z10prop" "z10_super_E1,
6770 z10_super_E1,
6771 z10_super_E1,
6772 z10_super_E1,
6773 *,
6774 z10_super_E1,
6775 z10_super_E1,
6776 *,
6777 *")])
6778
6779 (define_insn "*iorsi3_esa"
6780 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6781 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6782 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
6783 (clobber (reg:CC CC_REGNUM))]
6784 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6785 "@
6786 or\t%0,%2
6787 o\t%0,%2
6788 #
6789 #"
6790 [(set_attr "op_type" "RR,RX,SI,SS")
6791 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6792
6793 (define_split
6794 [(set (match_operand:SI 0 "s_operand" "")
6795 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6796 (clobber (reg:CC CC_REGNUM))]
6797 "reload_completed"
6798 [(parallel
6799 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6800 (clobber (reg:CC CC_REGNUM))])]
6801 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6802
6803 ;
6804 ; iorhi3 instruction pattern(s).
6805 ;
6806
6807 (define_insn "*iorhi3_zarch"
6808 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
6809 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
6810 (match_operand:HI 2 "general_operand" " d,d,n,NxQH0,Q")))
6811 (clobber (reg:CC CC_REGNUM))]
6812 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6813 "@
6814 or\t%0,%2
6815 ork\t%0,%1,%2
6816 oill\t%0,%x2
6817 #
6818 #"
6819 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
6820 (set_attr "cpu_facility" "*,z196,*,*,*")
6821 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")])
6822
6823 (define_insn "*iorhi3_esa"
6824 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
6825 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
6826 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
6827 (clobber (reg:CC CC_REGNUM))]
6828 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6829 "@
6830 or\t%0,%2
6831 #
6832 #"
6833 [(set_attr "op_type" "RR,SI,SS")
6834 (set_attr "z10prop" "z10_super_E1,*,*")])
6835
6836 (define_split
6837 [(set (match_operand:HI 0 "s_operand" "")
6838 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6839 (clobber (reg:CC CC_REGNUM))]
6840 "reload_completed"
6841 [(parallel
6842 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6843 (clobber (reg:CC CC_REGNUM))])]
6844 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6845
6846 ;
6847 ; iorqi3 instruction pattern(s).
6848 ;
6849
6850 (define_insn "*iorqi3_zarch"
6851 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
6852 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
6853 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
6854 (clobber (reg:CC CC_REGNUM))]
6855 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6856 "@
6857 or\t%0,%2
6858 ork\t%0,%1,%2
6859 oill\t%0,%b2
6860 oi\t%S0,%b2
6861 oiy\t%S0,%b2
6862 #"
6863 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
6864 (set_attr "cpu_facility" "*,z196,*,*,*,*")
6865 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,
6866 z10_super,z10_super,*")])
6867
6868 (define_insn "*iorqi3_esa"
6869 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
6870 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6871 (match_operand:QI 2 "general_operand" "d,n,Q")))
6872 (clobber (reg:CC CC_REGNUM))]
6873 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6874 "@
6875 or\t%0,%2
6876 oi\t%S0,%b2
6877 #"
6878 [(set_attr "op_type" "RR,SI,SS")
6879 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
6880
6881 ;
6882 ; Block inclusive or (OC) patterns.
6883 ;
6884
6885 (define_insn "*oc"
6886 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6887 (ior:BLK (match_dup 0)
6888 (match_operand:BLK 1 "memory_operand" "Q")))
6889 (use (match_operand 2 "const_int_operand" "n"))
6890 (clobber (reg:CC CC_REGNUM))]
6891 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6892 "oc\t%O0(%2,%R0),%S1"
6893 [(set_attr "op_type" "SS")
6894 (set_attr "z196prop" "z196_cracked")])
6895
6896 (define_split
6897 [(set (match_operand 0 "memory_operand" "")
6898 (ior (match_dup 0)
6899 (match_operand 1 "memory_operand" "")))
6900 (clobber (reg:CC CC_REGNUM))]
6901 "reload_completed
6902 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6903 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6904 [(parallel
6905 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
6906 (use (match_dup 2))
6907 (clobber (reg:CC CC_REGNUM))])]
6908 {
6909 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6910 operands[0] = adjust_address (operands[0], BLKmode, 0);
6911 operands[1] = adjust_address (operands[1], BLKmode, 0);
6912 })
6913
6914 (define_peephole2
6915 [(parallel
6916 [(set (match_operand:BLK 0 "memory_operand" "")
6917 (ior:BLK (match_dup 0)
6918 (match_operand:BLK 1 "memory_operand" "")))
6919 (use (match_operand 2 "const_int_operand" ""))
6920 (clobber (reg:CC CC_REGNUM))])
6921 (parallel
6922 [(set (match_operand:BLK 3 "memory_operand" "")
6923 (ior:BLK (match_dup 3)
6924 (match_operand:BLK 4 "memory_operand" "")))
6925 (use (match_operand 5 "const_int_operand" ""))
6926 (clobber (reg:CC CC_REGNUM))])]
6927 "s390_offset_p (operands[0], operands[3], operands[2])
6928 && s390_offset_p (operands[1], operands[4], operands[2])
6929 && !s390_overlap_p (operands[0], operands[1],
6930 INTVAL (operands[2]) + INTVAL (operands[5]))
6931 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6932 [(parallel
6933 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
6934 (use (match_dup 8))
6935 (clobber (reg:CC CC_REGNUM))])]
6936 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6937 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6938 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6939
6940
6941 ;;
6942 ;;- Xor instructions.
6943 ;;
6944
6945 (define_expand "xor<mode>3"
6946 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6947 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
6948 (match_operand:INT 2 "general_operand" "")))
6949 (clobber (reg:CC CC_REGNUM))]
6950 ""
6951 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
6952
6953 ;
6954 ; xordi3 instruction pattern(s).
6955 ;
6956
6957 (define_insn "*xordi3_cc"
6958 [(set (reg CC_REGNUM)
6959 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
6960 (match_operand:DI 2 "general_operand" " d,d,RT"))
6961 (const_int 0)))
6962 (set (match_operand:DI 0 "register_operand" "=d,d, d")
6963 (xor:DI (match_dup 1) (match_dup 2)))]
6964 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
6965 "@
6966 xgr\t%0,%2
6967 xgrk\t%0,%1,%2
6968 xg\t%0,%2"
6969 [(set_attr "op_type" "RRE,RRF,RXY")
6970 (set_attr "cpu_facility" "*,z196,*")
6971 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6972
6973 (define_insn "*xordi3_cconly"
6974 [(set (reg CC_REGNUM)
6975 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
6976 (match_operand:DI 2 "general_operand" " d,d,RT"))
6977 (const_int 0)))
6978 (clobber (match_scratch:DI 0 "=d,d, d"))]
6979 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
6980 "@
6981 xgr\t%0,%2
6982 xgrk\t%0,%1,%2
6983 xg\t%0,%2"
6984 [(set_attr "op_type" "RRE,RRF,RXY")
6985 (set_attr "cpu_facility" "*,z196,*")
6986 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6987
6988 (define_insn "*xordi3"
6989 [(set (match_operand:DI 0 "nonimmediate_operand" "=d, d,d,d, d, AQ,Q")
6990 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0, 0,0,d, 0, 0,0")
6991 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,d,RT,NxQD0,Q")))
6992 (clobber (reg:CC CC_REGNUM))]
6993 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6994 "@
6995 xihf\t%0,%k2
6996 xilf\t%0,%k2
6997 xgr\t%0,%2
6998 xgrk\t%0,%1,%2
6999 xg\t%0,%2
7000 #
7001 #"
7002 [(set_attr "op_type" "RIL,RIL,RRE,RRF,RXY,SI,SS")
7003 (set_attr "cpu_facility" "extimm,extimm,*,z196,*,*,*")
7004 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,
7005 *,z10_super_E1,*,*")])
7006
7007 (define_split
7008 [(set (match_operand:DI 0 "s_operand" "")
7009 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
7010 (clobber (reg:CC CC_REGNUM))]
7011 "reload_completed"
7012 [(parallel
7013 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
7014 (clobber (reg:CC CC_REGNUM))])]
7015 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
7016
7017 ;
7018 ; xorsi3 instruction pattern(s).
7019 ;
7020
7021 (define_insn "*xorsi3_cc"
7022 [(set (reg CC_REGNUM)
7023 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7024 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
7025 (const_int 0)))
7026 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
7027 (xor:SI (match_dup 1) (match_dup 2)))]
7028 "s390_match_ccmode(insn, CCTmode)"
7029 "@
7030 xilf\t%0,%o2
7031 xr\t%0,%2
7032 xrk\t%0,%1,%2
7033 x\t%0,%2
7034 xy\t%0,%2"
7035 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
7036 (set_attr "cpu_facility" "*,*,z196,*,*")
7037 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7038 z10_super_E1,z10_super_E1")])
7039
7040 (define_insn "*xorsi3_cconly"
7041 [(set (reg CC_REGNUM)
7042 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7043 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
7044 (const_int 0)))
7045 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
7046 "s390_match_ccmode(insn, CCTmode)"
7047 "@
7048 xilf\t%0,%o2
7049 xr\t%0,%2
7050 xrk\t%0,%1,%2
7051 x\t%0,%2
7052 xy\t%0,%2"
7053 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
7054 (set_attr "cpu_facility" "*,*,z196,*,*")
7055 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7056 z10_super_E1,z10_super_E1")])
7057
7058 (define_insn "*xorsi3"
7059 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d, AQ,Q")
7060 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, 0,0")
7061 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxQS0,Q")))
7062 (clobber (reg:CC CC_REGNUM))]
7063 "s390_logical_operator_ok_p (operands)"
7064 "@
7065 xilf\t%0,%o2
7066 xr\t%0,%2
7067 xrk\t%0,%1,%2
7068 x\t%0,%2
7069 xy\t%0,%2
7070 #
7071 #"
7072 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,SI,SS")
7073 (set_attr "cpu_facility" "*,*,z196,*,*,*,*")
7074 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7075 z10_super_E1,z10_super_E1,*,*")])
7076
7077 (define_split
7078 [(set (match_operand:SI 0 "s_operand" "")
7079 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
7080 (clobber (reg:CC CC_REGNUM))]
7081 "reload_completed"
7082 [(parallel
7083 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
7084 (clobber (reg:CC CC_REGNUM))])]
7085 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
7086
7087 ;
7088 ; xorhi3 instruction pattern(s).
7089 ;
7090
7091 (define_insn "*xorhi3"
7092 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7093 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,d, 0,0")
7094 (match_operand:HI 2 "general_operand" "Os,d,d,NxQH0,Q")))
7095 (clobber (reg:CC CC_REGNUM))]
7096 "s390_logical_operator_ok_p (operands)"
7097 "@
7098 xilf\t%0,%x2
7099 xr\t%0,%2
7100 xrk\t%0,%1,%2
7101 #
7102 #"
7103 [(set_attr "op_type" "RIL,RR,RRF,SI,SS")
7104 (set_attr "cpu_facility" "*,*,z196,*,*")
7105 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*,*")])
7106
7107 (define_split
7108 [(set (match_operand:HI 0 "s_operand" "")
7109 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
7110 (clobber (reg:CC CC_REGNUM))]
7111 "reload_completed"
7112 [(parallel
7113 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
7114 (clobber (reg:CC CC_REGNUM))])]
7115 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
7116
7117 ;
7118 ; xorqi3 instruction pattern(s).
7119 ;
7120
7121 (define_insn "*xorqi3"
7122 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7123 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,d,0,0,0")
7124 (match_operand:QI 2 "general_operand" "Os,d,d,n,n,Q")))
7125 (clobber (reg:CC CC_REGNUM))]
7126 "s390_logical_operator_ok_p (operands)"
7127 "@
7128 xilf\t%0,%b2
7129 xr\t%0,%2
7130 xrk\t%0,%1,%2
7131 xi\t%S0,%b2
7132 xiy\t%S0,%b2
7133 #"
7134 [(set_attr "op_type" "RIL,RR,RRF,SI,SIY,SS")
7135 (set_attr "cpu_facility" "*,*,z196,*,*,*")
7136 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super,z10_super,*")])
7137
7138
7139 ;
7140 ; Block exclusive or (XC) patterns.
7141 ;
7142
7143 (define_insn "*xc"
7144 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7145 (xor:BLK (match_dup 0)
7146 (match_operand:BLK 1 "memory_operand" "Q")))
7147 (use (match_operand 2 "const_int_operand" "n"))
7148 (clobber (reg:CC CC_REGNUM))]
7149 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
7150 "xc\t%O0(%2,%R0),%S1"
7151 [(set_attr "op_type" "SS")])
7152
7153 (define_split
7154 [(set (match_operand 0 "memory_operand" "")
7155 (xor (match_dup 0)
7156 (match_operand 1 "memory_operand" "")))
7157 (clobber (reg:CC CC_REGNUM))]
7158 "reload_completed
7159 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7160 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7161 [(parallel
7162 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
7163 (use (match_dup 2))
7164 (clobber (reg:CC CC_REGNUM))])]
7165 {
7166 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7167 operands[0] = adjust_address (operands[0], BLKmode, 0);
7168 operands[1] = adjust_address (operands[1], BLKmode, 0);
7169 })
7170
7171 (define_peephole2
7172 [(parallel
7173 [(set (match_operand:BLK 0 "memory_operand" "")
7174 (xor:BLK (match_dup 0)
7175 (match_operand:BLK 1 "memory_operand" "")))
7176 (use (match_operand 2 "const_int_operand" ""))
7177 (clobber (reg:CC CC_REGNUM))])
7178 (parallel
7179 [(set (match_operand:BLK 3 "memory_operand" "")
7180 (xor:BLK (match_dup 3)
7181 (match_operand:BLK 4 "memory_operand" "")))
7182 (use (match_operand 5 "const_int_operand" ""))
7183 (clobber (reg:CC CC_REGNUM))])]
7184 "s390_offset_p (operands[0], operands[3], operands[2])
7185 && s390_offset_p (operands[1], operands[4], operands[2])
7186 && !s390_overlap_p (operands[0], operands[1],
7187 INTVAL (operands[2]) + INTVAL (operands[5]))
7188 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7189 [(parallel
7190 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
7191 (use (match_dup 8))
7192 (clobber (reg:CC CC_REGNUM))])]
7193 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7194 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7195 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7196
7197 ;
7198 ; Block xor (XC) patterns with src == dest.
7199 ;
7200
7201 (define_insn "*xc_zero"
7202 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7203 (const_int 0))
7204 (use (match_operand 1 "const_int_operand" "n"))
7205 (clobber (reg:CC CC_REGNUM))]
7206 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
7207 "xc\t%O0(%1,%R0),%S0"
7208 [(set_attr "op_type" "SS")
7209 (set_attr "z196prop" "z196_cracked")])
7210
7211 (define_peephole2
7212 [(parallel
7213 [(set (match_operand:BLK 0 "memory_operand" "")
7214 (const_int 0))
7215 (use (match_operand 1 "const_int_operand" ""))
7216 (clobber (reg:CC CC_REGNUM))])
7217 (parallel
7218 [(set (match_operand:BLK 2 "memory_operand" "")
7219 (const_int 0))
7220 (use (match_operand 3 "const_int_operand" ""))
7221 (clobber (reg:CC CC_REGNUM))])]
7222 "s390_offset_p (operands[0], operands[2], operands[1])
7223 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
7224 [(parallel
7225 [(set (match_dup 4) (const_int 0))
7226 (use (match_dup 5))
7227 (clobber (reg:CC CC_REGNUM))])]
7228 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7229 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
7230
7231
7232 ;;
7233 ;;- Negate instructions.
7234 ;;
7235
7236 ;
7237 ; neg(di|si)2 instruction pattern(s).
7238 ;
7239
7240 (define_expand "neg<mode>2"
7241 [(parallel
7242 [(set (match_operand:DSI 0 "register_operand" "=d")
7243 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
7244 (clobber (reg:CC CC_REGNUM))])]
7245 ""
7246 "")
7247
7248 (define_insn "*negdi2_sign_cc"
7249 [(set (reg CC_REGNUM)
7250 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
7251 (match_operand:SI 1 "register_operand" "d") 0)
7252 (const_int 32)) (const_int 32)))
7253 (const_int 0)))
7254 (set (match_operand:DI 0 "register_operand" "=d")
7255 (neg:DI (sign_extend:DI (match_dup 1))))]
7256 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
7257 "lcgfr\t%0,%1"
7258 [(set_attr "op_type" "RRE")
7259 (set_attr "z10prop" "z10_c")])
7260
7261 (define_insn "*negdi2_sign"
7262 [(set (match_operand:DI 0 "register_operand" "=d")
7263 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
7264 (clobber (reg:CC CC_REGNUM))]
7265 "TARGET_ZARCH"
7266 "lcgfr\t%0,%1"
7267 [(set_attr "op_type" "RRE")
7268 (set_attr "z10prop" "z10_c")])
7269
7270 ; lcr, lcgr
7271 (define_insn "*neg<mode>2_cc"
7272 [(set (reg CC_REGNUM)
7273 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
7274 (const_int 0)))
7275 (set (match_operand:GPR 0 "register_operand" "=d")
7276 (neg:GPR (match_dup 1)))]
7277 "s390_match_ccmode (insn, CCAmode)"
7278 "lc<g>r\t%0,%1"
7279 [(set_attr "op_type" "RR<E>")
7280 (set_attr "z10prop" "z10_super_c_E1")])
7281
7282 ; lcr, lcgr
7283 (define_insn "*neg<mode>2_cconly"
7284 [(set (reg CC_REGNUM)
7285 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
7286 (const_int 0)))
7287 (clobber (match_scratch:GPR 0 "=d"))]
7288 "s390_match_ccmode (insn, CCAmode)"
7289 "lc<g>r\t%0,%1"
7290 [(set_attr "op_type" "RR<E>")
7291 (set_attr "z10prop" "z10_super_c_E1")])
7292
7293 ; lcr, lcgr
7294 (define_insn "*neg<mode>2"
7295 [(set (match_operand:GPR 0 "register_operand" "=d")
7296 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
7297 (clobber (reg:CC CC_REGNUM))]
7298 ""
7299 "lc<g>r\t%0,%1"
7300 [(set_attr "op_type" "RR<E>")
7301 (set_attr "z10prop" "z10_super_c_E1")])
7302
7303 (define_insn_and_split "*negdi2_31"
7304 [(set (match_operand:DI 0 "register_operand" "=d")
7305 (neg:DI (match_operand:DI 1 "register_operand" "d")))
7306 (clobber (reg:CC CC_REGNUM))]
7307 "!TARGET_ZARCH"
7308 "#"
7309 "&& reload_completed"
7310 [(parallel
7311 [(set (match_dup 2) (neg:SI (match_dup 3)))
7312 (clobber (reg:CC CC_REGNUM))])
7313 (parallel
7314 [(set (reg:CCAP CC_REGNUM)
7315 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
7316 (set (match_dup 4) (neg:SI (match_dup 5)))])
7317 (set (pc)
7318 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
7319 (pc)
7320 (label_ref (match_dup 6))))
7321 (parallel
7322 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
7323 (clobber (reg:CC CC_REGNUM))])
7324 (match_dup 6)]
7325 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
7326 operands[3] = operand_subword (operands[1], 0, 0, DImode);
7327 operands[4] = operand_subword (operands[0], 1, 0, DImode);
7328 operands[5] = operand_subword (operands[1], 1, 0, DImode);
7329 operands[6] = gen_label_rtx ();")
7330
7331 ;
7332 ; neg(df|sf)2 instruction pattern(s).
7333 ;
7334
7335 (define_expand "neg<mode>2"
7336 [(parallel
7337 [(set (match_operand:BFP 0 "register_operand" "=f")
7338 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
7339 (clobber (reg:CC CC_REGNUM))])]
7340 "TARGET_HARD_FLOAT"
7341 "")
7342
7343 ; lcxbr, lcdbr, lcebr
7344 (define_insn "*neg<mode>2_cc"
7345 [(set (reg CC_REGNUM)
7346 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
7347 (match_operand:BFP 2 "const0_operand" "")))
7348 (set (match_operand:BFP 0 "register_operand" "=f")
7349 (neg:BFP (match_dup 1)))]
7350 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7351 "lc<xde>br\t%0,%1"
7352 [(set_attr "op_type" "RRE")
7353 (set_attr "type" "fsimp<mode>")])
7354
7355 ; lcxbr, lcdbr, lcebr
7356 (define_insn "*neg<mode>2_cconly"
7357 [(set (reg CC_REGNUM)
7358 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
7359 (match_operand:BFP 2 "const0_operand" "")))
7360 (clobber (match_scratch:BFP 0 "=f"))]
7361 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7362 "lc<xde>br\t%0,%1"
7363 [(set_attr "op_type" "RRE")
7364 (set_attr "type" "fsimp<mode>")])
7365
7366 ; lcdfr
7367 (define_insn "*neg<mode>2_nocc"
7368 [(set (match_operand:FP 0 "register_operand" "=f")
7369 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
7370 "TARGET_DFP"
7371 "lcdfr\t%0,%1"
7372 [(set_attr "op_type" "RRE")
7373 (set_attr "type" "fsimp<mode>")])
7374
7375 ; lcxbr, lcdbr, lcebr
7376 (define_insn "*neg<mode>2"
7377 [(set (match_operand:BFP 0 "register_operand" "=f")
7378 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
7379 (clobber (reg:CC CC_REGNUM))]
7380 "TARGET_HARD_FLOAT"
7381 "lc<xde>br\t%0,%1"
7382 [(set_attr "op_type" "RRE")
7383 (set_attr "type" "fsimp<mode>")])
7384
7385
7386 ;;
7387 ;;- Absolute value instructions.
7388 ;;
7389
7390 ;
7391 ; abs(di|si)2 instruction pattern(s).
7392 ;
7393
7394 (define_insn "*absdi2_sign_cc"
7395 [(set (reg CC_REGNUM)
7396 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
7397 (match_operand:SI 1 "register_operand" "d") 0)
7398 (const_int 32)) (const_int 32)))
7399 (const_int 0)))
7400 (set (match_operand:DI 0 "register_operand" "=d")
7401 (abs:DI (sign_extend:DI (match_dup 1))))]
7402 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
7403 "lpgfr\t%0,%1"
7404 [(set_attr "op_type" "RRE")
7405 (set_attr "z10prop" "z10_c")])
7406
7407 (define_insn "*absdi2_sign"
7408 [(set (match_operand:DI 0 "register_operand" "=d")
7409 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
7410 (clobber (reg:CC CC_REGNUM))]
7411 "TARGET_ZARCH"
7412 "lpgfr\t%0,%1"
7413 [(set_attr "op_type" "RRE")
7414 (set_attr "z10prop" "z10_c")])
7415
7416 ; lpr, lpgr
7417 (define_insn "*abs<mode>2_cc"
7418 [(set (reg CC_REGNUM)
7419 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
7420 (const_int 0)))
7421 (set (match_operand:GPR 0 "register_operand" "=d")
7422 (abs:GPR (match_dup 1)))]
7423 "s390_match_ccmode (insn, CCAmode)"
7424 "lp<g>r\t%0,%1"
7425 [(set_attr "op_type" "RR<E>")
7426 (set_attr "z10prop" "z10_c")])
7427
7428 ; lpr, lpgr
7429 (define_insn "*abs<mode>2_cconly"
7430 [(set (reg CC_REGNUM)
7431 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
7432 (const_int 0)))
7433 (clobber (match_scratch:GPR 0 "=d"))]
7434 "s390_match_ccmode (insn, CCAmode)"
7435 "lp<g>r\t%0,%1"
7436 [(set_attr "op_type" "RR<E>")
7437 (set_attr "z10prop" "z10_c")])
7438
7439 ; lpr, lpgr
7440 (define_insn "abs<mode>2"
7441 [(set (match_operand:GPR 0 "register_operand" "=d")
7442 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
7443 (clobber (reg:CC CC_REGNUM))]
7444 ""
7445 "lp<g>r\t%0,%1"
7446 [(set_attr "op_type" "RR<E>")
7447 (set_attr "z10prop" "z10_c")])
7448
7449 ;
7450 ; abs(df|sf)2 instruction pattern(s).
7451 ;
7452
7453 (define_expand "abs<mode>2"
7454 [(parallel
7455 [(set (match_operand:BFP 0 "register_operand" "=f")
7456 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7457 (clobber (reg:CC CC_REGNUM))])]
7458 "TARGET_HARD_FLOAT"
7459 "")
7460
7461 ; lpxbr, lpdbr, lpebr
7462 (define_insn "*abs<mode>2_cc"
7463 [(set (reg CC_REGNUM)
7464 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
7465 (match_operand:BFP 2 "const0_operand" "")))
7466 (set (match_operand:BFP 0 "register_operand" "=f")
7467 (abs:BFP (match_dup 1)))]
7468 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7469 "lp<xde>br\t%0,%1"
7470 [(set_attr "op_type" "RRE")
7471 (set_attr "type" "fsimp<mode>")])
7472
7473 ; lpxbr, lpdbr, lpebr
7474 (define_insn "*abs<mode>2_cconly"
7475 [(set (reg CC_REGNUM)
7476 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
7477 (match_operand:BFP 2 "const0_operand" "")))
7478 (clobber (match_scratch:BFP 0 "=f"))]
7479 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7480 "lp<xde>br\t%0,%1"
7481 [(set_attr "op_type" "RRE")
7482 (set_attr "type" "fsimp<mode>")])
7483
7484 ; lpdfr
7485 (define_insn "*abs<mode>2_nocc"
7486 [(set (match_operand:FP 0 "register_operand" "=f")
7487 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
7488 "TARGET_DFP"
7489 "lpdfr\t%0,%1"
7490 [(set_attr "op_type" "RRE")
7491 (set_attr "type" "fsimp<mode>")])
7492
7493 ; lpxbr, lpdbr, lpebr
7494 (define_insn "*abs<mode>2"
7495 [(set (match_operand:BFP 0 "register_operand" "=f")
7496 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7497 (clobber (reg:CC CC_REGNUM))]
7498 "TARGET_HARD_FLOAT"
7499 "lp<xde>br\t%0,%1"
7500 [(set_attr "op_type" "RRE")
7501 (set_attr "type" "fsimp<mode>")])
7502
7503
7504 ;;
7505 ;;- Negated absolute value instructions
7506 ;;
7507
7508 ;
7509 ; Integer
7510 ;
7511
7512 (define_insn "*negabsdi2_sign_cc"
7513 [(set (reg CC_REGNUM)
7514 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
7515 (match_operand:SI 1 "register_operand" "d") 0)
7516 (const_int 32)) (const_int 32))))
7517 (const_int 0)))
7518 (set (match_operand:DI 0 "register_operand" "=d")
7519 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
7520 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
7521 "lngfr\t%0,%1"
7522 [(set_attr "op_type" "RRE")
7523 (set_attr "z10prop" "z10_c")])
7524
7525 (define_insn "*negabsdi2_sign"
7526 [(set (match_operand:DI 0 "register_operand" "=d")
7527 (neg:DI (abs:DI (sign_extend:DI
7528 (match_operand:SI 1 "register_operand" "d")))))
7529 (clobber (reg:CC CC_REGNUM))]
7530 "TARGET_ZARCH"
7531 "lngfr\t%0,%1"
7532 [(set_attr "op_type" "RRE")
7533 (set_attr "z10prop" "z10_c")])
7534
7535 ; lnr, lngr
7536 (define_insn "*negabs<mode>2_cc"
7537 [(set (reg CC_REGNUM)
7538 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
7539 (const_int 0)))
7540 (set (match_operand:GPR 0 "register_operand" "=d")
7541 (neg:GPR (abs:GPR (match_dup 1))))]
7542 "s390_match_ccmode (insn, CCAmode)"
7543 "ln<g>r\t%0,%1"
7544 [(set_attr "op_type" "RR<E>")
7545 (set_attr "z10prop" "z10_c")])
7546
7547 ; lnr, lngr
7548 (define_insn "*negabs<mode>2_cconly"
7549 [(set (reg CC_REGNUM)
7550 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
7551 (const_int 0)))
7552 (clobber (match_scratch:GPR 0 "=d"))]
7553 "s390_match_ccmode (insn, CCAmode)"
7554 "ln<g>r\t%0,%1"
7555 [(set_attr "op_type" "RR<E>")
7556 (set_attr "z10prop" "z10_c")])
7557
7558 ; lnr, lngr
7559 (define_insn "*negabs<mode>2"
7560 [(set (match_operand:GPR 0 "register_operand" "=d")
7561 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
7562 (clobber (reg:CC CC_REGNUM))]
7563 ""
7564 "ln<g>r\t%0,%1"
7565 [(set_attr "op_type" "RR<E>")
7566 (set_attr "z10prop" "z10_c")])
7567
7568 ;
7569 ; Floating point
7570 ;
7571
7572 ; lnxbr, lndbr, lnebr
7573 (define_insn "*negabs<mode>2_cc"
7574 [(set (reg CC_REGNUM)
7575 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7576 (match_operand:BFP 2 "const0_operand" "")))
7577 (set (match_operand:BFP 0 "register_operand" "=f")
7578 (neg:BFP (abs:BFP (match_dup 1))))]
7579 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7580 "ln<xde>br\t%0,%1"
7581 [(set_attr "op_type" "RRE")
7582 (set_attr "type" "fsimp<mode>")])
7583
7584 ; lnxbr, lndbr, lnebr
7585 (define_insn "*negabs<mode>2_cconly"
7586 [(set (reg CC_REGNUM)
7587 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7588 (match_operand:BFP 2 "const0_operand" "")))
7589 (clobber (match_scratch:BFP 0 "=f"))]
7590 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7591 "ln<xde>br\t%0,%1"
7592 [(set_attr "op_type" "RRE")
7593 (set_attr "type" "fsimp<mode>")])
7594
7595 ; lndfr
7596 (define_insn "*negabs<mode>2_nocc"
7597 [(set (match_operand:FP 0 "register_operand" "=f")
7598 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
7599 "TARGET_DFP"
7600 "lndfr\t%0,%1"
7601 [(set_attr "op_type" "RRE")
7602 (set_attr "type" "fsimp<mode>")])
7603
7604 ; lnxbr, lndbr, lnebr
7605 (define_insn "*negabs<mode>2"
7606 [(set (match_operand:BFP 0 "register_operand" "=f")
7607 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f"))))
7608 (clobber (reg:CC CC_REGNUM))]
7609 "TARGET_HARD_FLOAT"
7610 "ln<xde>br\t%0,%1"
7611 [(set_attr "op_type" "RRE")
7612 (set_attr "type" "fsimp<mode>")])
7613
7614 ;;
7615 ;;- Square root instructions.
7616 ;;
7617
7618 ;
7619 ; sqrt(df|sf)2 instruction pattern(s).
7620 ;
7621
7622 ; sqxbr, sqdbr, sqebr, sqdb, sqeb
7623 (define_insn "sqrt<mode>2"
7624 [(set (match_operand:BFP 0 "register_operand" "=f,f")
7625 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,<Rf>")))]
7626 "TARGET_HARD_FLOAT"
7627 "@
7628 sq<xde>br\t%0,%1
7629 sq<xde>b\t%0,%1"
7630 [(set_attr "op_type" "RRE,RXE")
7631 (set_attr "type" "fsqrt<mode>")])
7632
7633
7634 ;;
7635 ;;- One complement instructions.
7636 ;;
7637
7638 ;
7639 ; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
7640 ;
7641
7642 (define_expand "one_cmpl<mode>2"
7643 [(parallel
7644 [(set (match_operand:INT 0 "register_operand" "")
7645 (xor:INT (match_operand:INT 1 "register_operand" "")
7646 (const_int -1)))
7647 (clobber (reg:CC CC_REGNUM))])]
7648 ""
7649 "")
7650
7651
7652 ;;
7653 ;; Find leftmost bit instructions.
7654 ;;
7655
7656 (define_expand "clzdi2"
7657 [(set (match_operand:DI 0 "register_operand" "=d")
7658 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
7659 "TARGET_EXTIMM && TARGET_ZARCH"
7660 {
7661 rtx insn, clz_equal;
7662 rtx wide_reg = gen_reg_rtx (TImode);
7663 rtx msb = gen_rtx_CONST_INT (DImode, (unsigned HOST_WIDE_INT) 1 << 63);
7664
7665 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
7666
7667 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
7668
7669 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
7670 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
7671
7672 DONE;
7673 })
7674
7675 (define_insn "clztidi2"
7676 [(set (match_operand:TI 0 "register_operand" "=d")
7677 (ior:TI
7678 (ashift:TI
7679 (zero_extend:TI
7680 (xor:DI (match_operand:DI 1 "register_operand" "d")
7681 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
7682 (subreg:SI (clz:DI (match_dup 1)) 4))))
7683
7684 (const_int 64))
7685 (zero_extend:TI (clz:DI (match_dup 1)))))
7686 (clobber (reg:CC CC_REGNUM))]
7687 "(unsigned HOST_WIDE_INT) INTVAL (operands[2])
7688 == (unsigned HOST_WIDE_INT) 1 << 63
7689 && TARGET_EXTIMM && TARGET_ZARCH"
7690 "flogr\t%0,%1"
7691 [(set_attr "op_type" "RRE")])
7692
7693
7694 ;;
7695 ;;- Rotate instructions.
7696 ;;
7697
7698 ;
7699 ; rotl(di|si)3 instruction pattern(s).
7700 ;
7701
7702 ; rll, rllg
7703 (define_insn "rotl<mode>3"
7704 [(set (match_operand:GPR 0 "register_operand" "=d")
7705 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7706 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7707 "TARGET_CPU_ZARCH"
7708 "rll<g>\t%0,%1,%Y2"
7709 [(set_attr "op_type" "RSE")
7710 (set_attr "atype" "reg")
7711 (set_attr "z10prop" "z10_super_E1")])
7712
7713 ; rll, rllg
7714 (define_insn "*rotl<mode>3_and"
7715 [(set (match_operand:GPR 0 "register_operand" "=d")
7716 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7717 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7718 (match_operand:SI 3 "const_int_operand" "n"))))]
7719 "TARGET_CPU_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7720 "rll<g>\t%0,%1,%Y2"
7721 [(set_attr "op_type" "RSE")
7722 (set_attr "atype" "reg")
7723 (set_attr "z10prop" "z10_super_E1")])
7724
7725
7726 ;;
7727 ;;- Shift instructions.
7728 ;;
7729
7730 ;
7731 ; (ashl|lshr)(di|si)3 instruction pattern(s).
7732 ; Left shifts and logical right shifts
7733
7734 (define_expand "<shift><mode>3"
7735 [(set (match_operand:DSI 0 "register_operand" "")
7736 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
7737 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))]
7738 ""
7739 "")
7740
7741 ; sldl, srdl
7742 (define_insn "*<shift>di3_31"
7743 [(set (match_operand:DI 0 "register_operand" "=d")
7744 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7745 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7746 "!TARGET_ZARCH"
7747 "s<lr>dl\t%0,%Y2"
7748 [(set_attr "op_type" "RS")
7749 (set_attr "atype" "reg")
7750 (set_attr "z196prop" "z196_cracked")])
7751
7752 ; sll, srl, sllg, srlg, sllk, srlk
7753 (define_insn "*<shift><mode>3"
7754 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7755 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7756 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")))]
7757 ""
7758 "@
7759 s<lr>l<g>\t%0,<1>%Y2
7760 s<lr>l<gk>\t%0,%1,%Y2"
7761 [(set_attr "op_type" "RS<E>,RSY")
7762 (set_attr "atype" "reg,reg")
7763 (set_attr "cpu_facility" "*,z196")
7764 (set_attr "z10prop" "z10_super_E1,*")])
7765
7766 ; sldl, srdl
7767 (define_insn "*<shift>di3_31_and"
7768 [(set (match_operand:DI 0 "register_operand" "=d")
7769 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7770 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7771 (match_operand:SI 3 "const_int_operand" "n"))))]
7772 "!TARGET_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7773 "s<lr>dl\t%0,%Y2"
7774 [(set_attr "op_type" "RS")
7775 (set_attr "atype" "reg")])
7776
7777 ; sll, srl, sllg, srlg, sllk, srlk
7778 (define_insn "*<shift><mode>3_and"
7779 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7780 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7781 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
7782 (match_operand:SI 3 "const_int_operand" "n,n"))))]
7783 "(INTVAL (operands[3]) & 63) == 63"
7784 "@
7785 s<lr>l<g>\t%0,<1>%Y2
7786 s<lr>l<gk>\t%0,%1,%Y2"
7787 [(set_attr "op_type" "RS<E>,RSY")
7788 (set_attr "atype" "reg,reg")
7789 (set_attr "cpu_facility" "*,z196")
7790 (set_attr "z10prop" "z10_super_E1,*")])
7791
7792 ;
7793 ; ashr(di|si)3 instruction pattern(s).
7794 ; Arithmetic right shifts
7795
7796 (define_expand "ashr<mode>3"
7797 [(parallel
7798 [(set (match_operand:DSI 0 "register_operand" "")
7799 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
7800 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))
7801 (clobber (reg:CC CC_REGNUM))])]
7802 ""
7803 "")
7804
7805 (define_insn "*ashrdi3_cc_31"
7806 [(set (reg CC_REGNUM)
7807 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7808 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7809 (const_int 0)))
7810 (set (match_operand:DI 0 "register_operand" "=d")
7811 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7812 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)"
7813 "srda\t%0,%Y2"
7814 [(set_attr "op_type" "RS")
7815 (set_attr "atype" "reg")])
7816
7817 (define_insn "*ashrdi3_cconly_31"
7818 [(set (reg CC_REGNUM)
7819 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7820 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7821 (const_int 0)))
7822 (clobber (match_scratch:DI 0 "=d"))]
7823 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)"
7824 "srda\t%0,%Y2"
7825 [(set_attr "op_type" "RS")
7826 (set_attr "atype" "reg")])
7827
7828 (define_insn "*ashrdi3_31"
7829 [(set (match_operand:DI 0 "register_operand" "=d")
7830 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7831 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
7832 (clobber (reg:CC CC_REGNUM))]
7833 "!TARGET_ZARCH"
7834 "srda\t%0,%Y2"
7835 [(set_attr "op_type" "RS")
7836 (set_attr "atype" "reg")])
7837
7838 ; sra, srag, srak
7839 (define_insn "*ashr<mode>3_cc"
7840 [(set (reg CC_REGNUM)
7841 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7842 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y"))
7843 (const_int 0)))
7844 (set (match_operand:GPR 0 "register_operand" "=d,d")
7845 (ashiftrt:GPR (match_dup 1) (match_dup 2)))]
7846 "s390_match_ccmode(insn, CCSmode)"
7847 "@
7848 sra<g>\t%0,<1>%Y2
7849 sra<gk>\t%0,%1,%Y2"
7850 [(set_attr "op_type" "RS<E>,RSY")
7851 (set_attr "atype" "reg,reg")
7852 (set_attr "cpu_facility" "*,z196")
7853 (set_attr "z10prop" "z10_super_E1,*")])
7854
7855 ; sra, srag, srak
7856 (define_insn "*ashr<mode>3_cconly"
7857 [(set (reg CC_REGNUM)
7858 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7859 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y"))
7860 (const_int 0)))
7861 (clobber (match_scratch:GPR 0 "=d,d"))]
7862 "s390_match_ccmode(insn, CCSmode)"
7863 "@
7864 sra<g>\t%0,<1>%Y2
7865 sra<gk>\t%0,%1,%Y2"
7866 [(set_attr "op_type" "RS<E>,RSY")
7867 (set_attr "atype" "reg,reg")
7868 (set_attr "cpu_facility" "*,z196")
7869 (set_attr "z10prop" "z10_super_E1,*")])
7870
7871 ; sra, srag
7872 (define_insn "*ashr<mode>3"
7873 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7874 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7875 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")))
7876 (clobber (reg:CC CC_REGNUM))]
7877 ""
7878 "@
7879 sra<g>\t%0,<1>%Y2
7880 sra<gk>\t%0,%1,%Y2"
7881 [(set_attr "op_type" "RS<E>,RSY")
7882 (set_attr "atype" "reg,reg")
7883 (set_attr "cpu_facility" "*,z196")
7884 (set_attr "z10prop" "z10_super_E1,*")])
7885
7886
7887 ; shift pattern with implicit ANDs
7888
7889 (define_insn "*ashrdi3_cc_31_and"
7890 [(set (reg CC_REGNUM)
7891 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7892 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7893 (match_operand:SI 3 "const_int_operand" "n")))
7894 (const_int 0)))
7895 (set (match_operand:DI 0 "register_operand" "=d")
7896 (ashiftrt:DI (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7897 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)
7898 && (INTVAL (operands[3]) & 63) == 63"
7899 "srda\t%0,%Y2"
7900 [(set_attr "op_type" "RS")
7901 (set_attr "atype" "reg")])
7902
7903 (define_insn "*ashrdi3_cconly_31_and"
7904 [(set (reg CC_REGNUM)
7905 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7906 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7907 (match_operand:SI 3 "const_int_operand" "n")))
7908 (const_int 0)))
7909 (clobber (match_scratch:DI 0 "=d"))]
7910 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)
7911 && (INTVAL (operands[3]) & 63) == 63"
7912 "srda\t%0,%Y2"
7913 [(set_attr "op_type" "RS")
7914 (set_attr "atype" "reg")])
7915
7916 (define_insn "*ashrdi3_31_and"
7917 [(set (match_operand:DI 0 "register_operand" "=d")
7918 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7919 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7920 (match_operand:SI 3 "const_int_operand" "n"))))
7921 (clobber (reg:CC CC_REGNUM))]
7922 "!TARGET_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7923 "srda\t%0,%Y2"
7924 [(set_attr "op_type" "RS")
7925 (set_attr "atype" "reg")])
7926
7927 ; sra, srag, srak
7928 (define_insn "*ashr<mode>3_cc_and"
7929 [(set (reg CC_REGNUM)
7930 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7931 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
7932 (match_operand:SI 3 "const_int_operand" "n,n")))
7933 (const_int 0)))
7934 (set (match_operand:GPR 0 "register_operand" "=d,d")
7935 (ashiftrt:GPR (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7936 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7937 "@
7938 sra<g>\t%0,<1>%Y2
7939 sra<gk>\t%0,%1,%Y2"
7940 [(set_attr "op_type" "RS<E>,RSY")
7941 (set_attr "atype" "reg,reg")
7942 (set_attr "cpu_facility" "*,z196")
7943 (set_attr "z10prop" "z10_super_E1,*")])
7944
7945 ; sra, srag, srak
7946 (define_insn "*ashr<mode>3_cconly_and"
7947 [(set (reg CC_REGNUM)
7948 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7949 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
7950 (match_operand:SI 3 "const_int_operand" "n,n")))
7951 (const_int 0)))
7952 (clobber (match_scratch:GPR 0 "=d,d"))]
7953 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7954 "@
7955 sra<g>\t%0,<1>%Y2
7956 sra<gk>\t%0,%1,%Y2"
7957 [(set_attr "op_type" "RS<E>,RSY")
7958 (set_attr "atype" "reg,reg")
7959 (set_attr "cpu_facility" "*,z196")
7960 (set_attr "z10prop" "z10_super_E1,*")])
7961
7962 ; sra, srag, srak
7963 (define_insn "*ashr<mode>3_and"
7964 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7965 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7966 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
7967 (match_operand:SI 3 "const_int_operand" "n,n"))))
7968 (clobber (reg:CC CC_REGNUM))]
7969 "(INTVAL (operands[3]) & 63) == 63"
7970 "@
7971 sra<g>\t%0,<1>%Y2
7972 sra<gk>\t%0,%1,%Y2"
7973 [(set_attr "op_type" "RS<E>,RSY")
7974 (set_attr "atype" "reg,reg")
7975 (set_attr "cpu_facility" "*,z196")
7976 (set_attr "z10prop" "z10_super_E1,*")])
7977
7978
7979 ;;
7980 ;; Branch instruction patterns.
7981 ;;
7982
7983 (define_expand "cbranch<mode>4"
7984 [(set (pc)
7985 (if_then_else (match_operator 0 "comparison_operator"
7986 [(match_operand:GPR 1 "register_operand" "")
7987 (match_operand:GPR 2 "general_operand" "")])
7988 (label_ref (match_operand 3 "" ""))
7989 (pc)))]
7990 ""
7991 "s390_emit_jump (operands[3],
7992 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
7993 DONE;")
7994
7995 (define_expand "cbranch<mode>4"
7996 [(set (pc)
7997 (if_then_else (match_operator 0 "comparison_operator"
7998 [(match_operand:FP 1 "register_operand" "")
7999 (match_operand:FP 2 "general_operand" "")])
8000 (label_ref (match_operand 3 "" ""))
8001 (pc)))]
8002 "TARGET_HARD_FLOAT"
8003 "s390_emit_jump (operands[3],
8004 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8005 DONE;")
8006
8007 (define_expand "cbranchcc4"
8008 [(set (pc)
8009 (if_then_else (match_operator 0 "s390_eqne_operator"
8010 [(match_operand 1 "cc_reg_operand" "")
8011 (match_operand 2 "const0_operand" "")])
8012 (label_ref (match_operand 3 "" ""))
8013 (pc)))]
8014 "TARGET_HARD_FLOAT"
8015 "s390_emit_jump (operands[3],
8016 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8017 DONE;")
8018
8019
8020
8021 ;;
8022 ;;- Conditional jump instructions.
8023 ;;
8024
8025 (define_insn "*cjump_64"
8026 [(set (pc)
8027 (if_then_else
8028 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8029 (match_operand 2 "const_int_operand" "")])
8030 (label_ref (match_operand 0 "" ""))
8031 (pc)))]
8032 "TARGET_CPU_ZARCH"
8033 {
8034 if (get_attr_length (insn) == 4)
8035 return "j%C1\t%l0";
8036 else
8037 return "jg%C1\t%l0";
8038 }
8039 [(set_attr "op_type" "RI")
8040 (set_attr "type" "branch")
8041 (set (attr "length")
8042 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8043 (const_int 4) (const_int 6)))])
8044
8045 (define_insn "*cjump_31"
8046 [(set (pc)
8047 (if_then_else
8048 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8049 (match_operand 2 "const_int_operand" "")])
8050 (label_ref (match_operand 0 "" ""))
8051 (pc)))]
8052 "!TARGET_CPU_ZARCH"
8053 {
8054 gcc_assert (get_attr_length (insn) == 4);
8055 return "j%C1\t%l0";
8056 }
8057 [(set_attr "op_type" "RI")
8058 (set_attr "type" "branch")
8059 (set (attr "length")
8060 (if_then_else (not (match_test "flag_pic"))
8061 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8062 (const_int 4) (const_int 6))
8063 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8064 (const_int 4) (const_int 8))))])
8065
8066 (define_insn "*cjump_long"
8067 [(set (pc)
8068 (if_then_else
8069 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8070 (match_operand 0 "address_operand" "ZQZR")
8071 (pc)))]
8072 ""
8073 {
8074 if (get_attr_op_type (insn) == OP_TYPE_RR)
8075 return "b%C1r\t%0";
8076 else
8077 return "b%C1\t%a0";
8078 }
8079 [(set (attr "op_type")
8080 (if_then_else (match_operand 0 "register_operand" "")
8081 (const_string "RR") (const_string "RX")))
8082 (set_attr "type" "branch")
8083 (set_attr "atype" "agen")])
8084
8085 ;; A conditional return instruction.
8086 (define_insn "*c<code>"
8087 [(set (pc)
8088 (if_then_else
8089 (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8090 (ANY_RETURN)
8091 (pc)))]
8092 "s390_can_use_<code>_insn ()"
8093 "b%C0r\t%%r14"
8094 [(set_attr "op_type" "RR")
8095 (set_attr "type" "jsr")
8096 (set_attr "atype" "agen")])
8097
8098 ;;
8099 ;;- Negated conditional jump instructions.
8100 ;;
8101
8102 (define_insn "*icjump_64"
8103 [(set (pc)
8104 (if_then_else
8105 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8106 (pc)
8107 (label_ref (match_operand 0 "" ""))))]
8108 "TARGET_CPU_ZARCH"
8109 {
8110 if (get_attr_length (insn) == 4)
8111 return "j%D1\t%l0";
8112 else
8113 return "jg%D1\t%l0";
8114 }
8115 [(set_attr "op_type" "RI")
8116 (set_attr "type" "branch")
8117 (set (attr "length")
8118 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8119 (const_int 4) (const_int 6)))])
8120
8121 (define_insn "*icjump_31"
8122 [(set (pc)
8123 (if_then_else
8124 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8125 (pc)
8126 (label_ref (match_operand 0 "" ""))))]
8127 "!TARGET_CPU_ZARCH"
8128 {
8129 gcc_assert (get_attr_length (insn) == 4);
8130 return "j%D1\t%l0";
8131 }
8132 [(set_attr "op_type" "RI")
8133 (set_attr "type" "branch")
8134 (set (attr "length")
8135 (if_then_else (not (match_test "flag_pic"))
8136 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8137 (const_int 4) (const_int 6))
8138 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8139 (const_int 4) (const_int 8))))])
8140
8141 (define_insn "*icjump_long"
8142 [(set (pc)
8143 (if_then_else
8144 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8145 (pc)
8146 (match_operand 0 "address_operand" "ZQZR")))]
8147 ""
8148 {
8149 if (get_attr_op_type (insn) == OP_TYPE_RR)
8150 return "b%D1r\t%0";
8151 else
8152 return "b%D1\t%a0";
8153 }
8154 [(set (attr "op_type")
8155 (if_then_else (match_operand 0 "register_operand" "")
8156 (const_string "RR") (const_string "RX")))
8157 (set_attr "type" "branch")
8158 (set_attr "atype" "agen")])
8159
8160 ;;
8161 ;;- Trap instructions.
8162 ;;
8163
8164 (define_insn "trap"
8165 [(trap_if (const_int 1) (const_int 0))]
8166 ""
8167 "j\t.+2"
8168 [(set_attr "op_type" "RI")
8169 (set_attr "type" "branch")])
8170
8171 (define_expand "ctrap<mode>4"
8172 [(trap_if (match_operator 0 "comparison_operator"
8173 [(match_operand:GPR 1 "register_operand" "")
8174 (match_operand:GPR 2 "general_operand" "")])
8175 (match_operand 3 "const0_operand" ""))]
8176 ""
8177 {
8178 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8179 operands[1], operands[2]);
8180 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8181 DONE;
8182 })
8183
8184 (define_expand "ctrap<mode>4"
8185 [(trap_if (match_operator 0 "comparison_operator"
8186 [(match_operand:FP 1 "register_operand" "")
8187 (match_operand:FP 2 "general_operand" "")])
8188 (match_operand 3 "const0_operand" ""))]
8189 ""
8190 {
8191 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8192 operands[1], operands[2]);
8193 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8194 DONE;
8195 })
8196
8197 (define_insn "condtrap"
8198 [(trap_if (match_operator 0 "s390_comparison"
8199 [(match_operand 1 "cc_reg_operand" "c")
8200 (const_int 0)])
8201 (const_int 0))]
8202 ""
8203 "j%C0\t.+2";
8204 [(set_attr "op_type" "RI")
8205 (set_attr "type" "branch")])
8206
8207 ; crt, cgrt, cit, cgit
8208 (define_insn "*cmp_and_trap_signed_int<mode>"
8209 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
8210 [(match_operand:GPR 1 "register_operand" "d,d")
8211 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
8212 (const_int 0))]
8213 "TARGET_Z10"
8214 "@
8215 c<g>rt%C0\t%1,%2
8216 c<g>it%C0\t%1,%h2"
8217 [(set_attr "op_type" "RRF,RIE")
8218 (set_attr "type" "branch")
8219 (set_attr "z10prop" "z10_super_c,z10_super")])
8220
8221 ; clrt, clgrt, clfit, clgit, clt, clgt
8222 (define_insn "*cmp_and_trap_unsigned_int<mode>"
8223 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
8224 [(match_operand:GPR 1 "register_operand" "d,d, d")
8225 (match_operand:GPR 2 "general_operand" "d,D,RT")])
8226 (const_int 0))]
8227 "TARGET_Z10"
8228 "@
8229 cl<g>rt%C0\t%1,%2
8230 cl<gf>it%C0\t%1,%x2
8231 cl<g>t%C0\t%1,%2"
8232 [(set_attr "op_type" "RRF,RIE,RSY")
8233 (set_attr "type" "branch")
8234 (set_attr "z10prop" "z10_super_c,z10_super,*")
8235 (set_attr "cpu_facility" "z10,z10,zEC12")])
8236
8237 ; lat, lgat
8238 (define_insn "*load_and_trap<mode>"
8239 [(trap_if (eq (match_operand:GPR 0 "memory_operand" "RT")
8240 (const_int 0))
8241 (const_int 0))
8242 (set (match_operand:GPR 1 "register_operand" "=d")
8243 (match_dup 0))]
8244 "TARGET_ZEC12"
8245 "l<g>at\t%1,%0"
8246 [(set_attr "op_type" "RXY")])
8247
8248
8249 ;;
8250 ;;- Loop instructions.
8251 ;;
8252 ;; This is all complicated by the fact that since this is a jump insn
8253 ;; we must handle our own output reloads.
8254
8255 ;; branch on index
8256
8257 ; This splitter will be matched by combine and has to add the 2 moves
8258 ; necessary to load the compare and the increment values into a
8259 ; register pair as needed by brxle.
8260
8261 (define_insn_and_split "*brx_stage1_<GPR:mode>"
8262 [(set (pc)
8263 (if_then_else
8264 (match_operator 6 "s390_brx_operator"
8265 [(plus:GPR (match_operand:GPR 1 "register_operand" "")
8266 (match_operand:GPR 2 "general_operand" ""))
8267 (match_operand:GPR 3 "register_operand" "")])
8268 (label_ref (match_operand 0 "" ""))
8269 (pc)))
8270 (set (match_operand:GPR 4 "nonimmediate_operand" "")
8271 (plus:GPR (match_dup 1) (match_dup 2)))
8272 (clobber (match_scratch:GPR 5 ""))]
8273 "TARGET_CPU_ZARCH"
8274 "#"
8275 "!reload_completed && !reload_in_progress"
8276 [(set (match_dup 7) (match_dup 2)) ; the increment
8277 (set (match_dup 8) (match_dup 3)) ; the comparison value
8278 (parallel [(set (pc)
8279 (if_then_else
8280 (match_op_dup 6
8281 [(plus:GPR (match_dup 1) (match_dup 7))
8282 (match_dup 8)])
8283 (label_ref (match_dup 0))
8284 (pc)))
8285 (set (match_dup 4)
8286 (plus:GPR (match_dup 1) (match_dup 7)))
8287 (clobber (match_dup 5))
8288 (clobber (reg:CC CC_REGNUM))])]
8289 {
8290 rtx dreg = gen_reg_rtx (word_mode == DImode ? TImode : DImode);
8291 operands[7] = gen_lowpart (<GPR:MODE>mode,
8292 gen_highpart (word_mode, dreg));
8293 operands[8] = gen_lowpart (<GPR:MODE>mode,
8294 gen_lowpart (word_mode, dreg));
8295 })
8296
8297 ; brxlg, brxhg
8298
8299 (define_insn_and_split "*brxg_64bit"
8300 [(set (pc)
8301 (if_then_else
8302 (match_operator 5 "s390_brx_operator"
8303 [(plus:DI (match_operand:DI 1 "register_operand" "d,d,d")
8304 (subreg:DI (match_operand:TI 2 "register_operand" "d,d,d") 0))
8305 (subreg:DI (match_dup 2) 8)])
8306 (label_ref (match_operand 0 "" ""))
8307 (pc)))
8308 (set (match_operand:DI 3 "nonimmediate_operand" "=1,?X,?X")
8309 (plus:DI (match_dup 1)
8310 (subreg:DI (match_dup 2) 0)))
8311 (clobber (match_scratch:DI 4 "=X,&1,&?d"))
8312 (clobber (reg:CC CC_REGNUM))]
8313 "TARGET_ZARCH"
8314 {
8315 if (which_alternative != 0)
8316 return "#";
8317 else if (get_attr_length (insn) == 6)
8318 return "brx%E5g\t%1,%2,%l0";
8319 else
8320 return "agr\t%1,%2\;cgr\t%1,%M2\;jg%C5\t%l0";
8321 }
8322 "&& reload_completed
8323 && (!REG_P (operands[3])
8324 || !rtx_equal_p (operands[1], operands[3]))"
8325 [(set (match_dup 4) (match_dup 1))
8326 (parallel [(set (match_dup 4) (plus:DI (match_dup 4) (subreg:DI (match_dup 2) 0)))
8327 (clobber (reg:CC CC_REGNUM))])
8328 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:DI (match_dup 2) 8)))
8329 (set (match_dup 3) (match_dup 4))
8330 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8331 (label_ref (match_dup 0))
8332 (pc)))]
8333 ""
8334 [(set_attr "op_type" "RIE")
8335 (set_attr "type" "branch")
8336 (set (attr "length")
8337 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8338 (const_int 6) (const_int 16)))])
8339
8340 ; brxle, brxh
8341
8342 (define_insn_and_split "*brx_64bit"
8343 [(set (pc)
8344 (if_then_else
8345 (match_operator 5 "s390_brx_operator"
8346 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
8347 (subreg:SI (match_operand:TI 2 "register_operand" "d,d,d") 4))
8348 (subreg:SI (match_dup 2) 12)])
8349 (label_ref (match_operand 0 "" ""))
8350 (pc)))
8351 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
8352 (plus:SI (match_dup 1)
8353 (subreg:SI (match_dup 2) 4)))
8354 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
8355 (clobber (reg:CC CC_REGNUM))]
8356 "TARGET_ZARCH"
8357 {
8358 if (which_alternative != 0)
8359 return "#";
8360 else if (get_attr_length (insn) == 6)
8361 return "brx%C5\t%1,%2,%l0";
8362 else
8363 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
8364 }
8365 "&& reload_completed
8366 && (!REG_P (operands[3])
8367 || !rtx_equal_p (operands[1], operands[3]))"
8368 [(set (match_dup 4) (match_dup 1))
8369 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 4)))
8370 (clobber (reg:CC CC_REGNUM))])
8371 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 12)))
8372 (set (match_dup 3) (match_dup 4))
8373 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8374 (label_ref (match_dup 0))
8375 (pc)))]
8376 ""
8377 [(set_attr "op_type" "RSI")
8378 (set_attr "type" "branch")
8379 (set (attr "length")
8380 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8381 (const_int 6) (const_int 14)))])
8382
8383 ; brxle, brxh
8384
8385 (define_insn_and_split "*brx_31bit"
8386 [(set (pc)
8387 (if_then_else
8388 (match_operator 5 "s390_brx_operator"
8389 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
8390 (subreg:SI (match_operand:DI 2 "register_operand" "d,d,d") 0))
8391 (subreg:SI (match_dup 2) 4)])
8392 (label_ref (match_operand 0 "" ""))
8393 (pc)))
8394 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
8395 (plus:SI (match_dup 1)
8396 (subreg:SI (match_dup 2) 0)))
8397 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
8398 (clobber (reg:CC CC_REGNUM))]
8399 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
8400 {
8401 if (which_alternative != 0)
8402 return "#";
8403 else if (get_attr_length (insn) == 6)
8404 return "brx%C5\t%1,%2,%l0";
8405 else
8406 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
8407 }
8408 "&& reload_completed
8409 && (!REG_P (operands[3])
8410 || !rtx_equal_p (operands[1], operands[3]))"
8411 [(set (match_dup 4) (match_dup 1))
8412 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 0)))
8413 (clobber (reg:CC CC_REGNUM))])
8414 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 4)))
8415 (set (match_dup 3) (match_dup 4))
8416 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8417 (label_ref (match_dup 0))
8418 (pc)))]
8419 ""
8420 [(set_attr "op_type" "RSI")
8421 (set_attr "type" "branch")
8422 (set (attr "length")
8423 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8424 (const_int 6) (const_int 14)))])
8425
8426
8427 ;; branch on count
8428
8429 (define_expand "doloop_end"
8430 [(use (match_operand 0 "" "")) ; loop pseudo
8431 (use (match_operand 1 "" ""))] ; label
8432 ""
8433 {
8434 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
8435 emit_jump_insn (gen_doloop_si31 (operands[1], operands[0], operands[0]));
8436 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
8437 emit_jump_insn (gen_doloop_si64 (operands[1], operands[0], operands[0]));
8438 else if (GET_MODE (operands[0]) == DImode && TARGET_ZARCH)
8439 emit_jump_insn (gen_doloop_di (operands[1], operands[0], operands[0]));
8440 else
8441 FAIL;
8442
8443 DONE;
8444 })
8445
8446 (define_insn_and_split "doloop_si64"
8447 [(set (pc)
8448 (if_then_else
8449 (ne (match_operand:SI 1 "register_operand" "d,d,d")
8450 (const_int 1))
8451 (label_ref (match_operand 0 "" ""))
8452 (pc)))
8453 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
8454 (plus:SI (match_dup 1) (const_int -1)))
8455 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
8456 (clobber (reg:CC CC_REGNUM))]
8457 "TARGET_CPU_ZARCH"
8458 {
8459 if (which_alternative != 0)
8460 return "#";
8461 else if (get_attr_length (insn) == 4)
8462 return "brct\t%1,%l0";
8463 else
8464 return "ahi\t%1,-1\;jgne\t%l0";
8465 }
8466 "&& reload_completed
8467 && (! REG_P (operands[2])
8468 || ! rtx_equal_p (operands[1], operands[2]))"
8469 [(set (match_dup 3) (match_dup 1))
8470 (parallel [(set (reg:CCAN CC_REGNUM)
8471 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
8472 (const_int 0)))
8473 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
8474 (set (match_dup 2) (match_dup 3))
8475 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
8476 (label_ref (match_dup 0))
8477 (pc)))]
8478 ""
8479 [(set_attr "op_type" "RI")
8480 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8481 ; hurt us in the (rare) case of ahi.
8482 (set_attr "z10prop" "z10_super_E1")
8483 (set_attr "type" "branch")
8484 (set (attr "length")
8485 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8486 (const_int 4) (const_int 10)))])
8487
8488 (define_insn_and_split "doloop_si31"
8489 [(set (pc)
8490 (if_then_else
8491 (ne (match_operand:SI 1 "register_operand" "d,d,d")
8492 (const_int 1))
8493 (label_ref (match_operand 0 "" ""))
8494 (pc)))
8495 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
8496 (plus:SI (match_dup 1) (const_int -1)))
8497 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
8498 (clobber (reg:CC CC_REGNUM))]
8499 "!TARGET_CPU_ZARCH"
8500 {
8501 if (which_alternative != 0)
8502 return "#";
8503 else if (get_attr_length (insn) == 4)
8504 return "brct\t%1,%l0";
8505 else
8506 gcc_unreachable ();
8507 }
8508 "&& reload_completed
8509 && (! REG_P (operands[2])
8510 || ! rtx_equal_p (operands[1], operands[2]))"
8511 [(set (match_dup 3) (match_dup 1))
8512 (parallel [(set (reg:CCAN CC_REGNUM)
8513 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
8514 (const_int 0)))
8515 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
8516 (set (match_dup 2) (match_dup 3))
8517 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
8518 (label_ref (match_dup 0))
8519 (pc)))]
8520 ""
8521 [(set_attr "op_type" "RI")
8522 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8523 ; hurt us in the (rare) case of ahi.
8524 (set_attr "z10prop" "z10_super_E1")
8525 (set_attr "type" "branch")
8526 (set (attr "length")
8527 (if_then_else (not (match_test "flag_pic"))
8528 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8529 (const_int 4) (const_int 6))
8530 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8531 (const_int 4) (const_int 8))))])
8532
8533 (define_insn "*doloop_si_long"
8534 [(set (pc)
8535 (if_then_else
8536 (ne (match_operand:SI 1 "register_operand" "d")
8537 (const_int 1))
8538 (match_operand 0 "address_operand" "ZQZR")
8539 (pc)))
8540 (set (match_operand:SI 2 "register_operand" "=1")
8541 (plus:SI (match_dup 1) (const_int -1)))
8542 (clobber (match_scratch:SI 3 "=X"))
8543 (clobber (reg:CC CC_REGNUM))]
8544 "!TARGET_CPU_ZARCH"
8545 {
8546 if (get_attr_op_type (insn) == OP_TYPE_RR)
8547 return "bctr\t%1,%0";
8548 else
8549 return "bct\t%1,%a0";
8550 }
8551 [(set (attr "op_type")
8552 (if_then_else (match_operand 0 "register_operand" "")
8553 (const_string "RR") (const_string "RX")))
8554 (set_attr "type" "branch")
8555 (set_attr "atype" "agen")
8556 (set_attr "z10prop" "z10_c")
8557 (set_attr "z196prop" "z196_cracked")])
8558
8559 (define_insn_and_split "doloop_di"
8560 [(set (pc)
8561 (if_then_else
8562 (ne (match_operand:DI 1 "register_operand" "d,d,d")
8563 (const_int 1))
8564 (label_ref (match_operand 0 "" ""))
8565 (pc)))
8566 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
8567 (plus:DI (match_dup 1) (const_int -1)))
8568 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
8569 (clobber (reg:CC CC_REGNUM))]
8570 "TARGET_ZARCH"
8571 {
8572 if (which_alternative != 0)
8573 return "#";
8574 else if (get_attr_length (insn) == 4)
8575 return "brctg\t%1,%l0";
8576 else
8577 return "aghi\t%1,-1\;jgne\t%l0";
8578 }
8579 "&& reload_completed
8580 && (! REG_P (operands[2])
8581 || ! rtx_equal_p (operands[1], operands[2]))"
8582 [(set (match_dup 3) (match_dup 1))
8583 (parallel [(set (reg:CCAN CC_REGNUM)
8584 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
8585 (const_int 0)))
8586 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
8587 (set (match_dup 2) (match_dup 3))
8588 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
8589 (label_ref (match_dup 0))
8590 (pc)))]
8591 ""
8592 [(set_attr "op_type" "RI")
8593 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8594 ; hurt us in the (rare) case of ahi.
8595 (set_attr "z10prop" "z10_super_E1")
8596 (set_attr "type" "branch")
8597 (set (attr "length")
8598 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8599 (const_int 4) (const_int 10)))])
8600
8601 ;;
8602 ;;- Unconditional jump instructions.
8603 ;;
8604
8605 ;
8606 ; jump instruction pattern(s).
8607 ;
8608
8609 (define_expand "jump"
8610 [(match_operand 0 "" "")]
8611 ""
8612 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
8613
8614 (define_insn "*jump64"
8615 [(set (pc) (label_ref (match_operand 0 "" "")))]
8616 "TARGET_CPU_ZARCH"
8617 {
8618 if (get_attr_length (insn) == 4)
8619 return "j\t%l0";
8620 else
8621 return "jg\t%l0";
8622 }
8623 [(set_attr "op_type" "RI")
8624 (set_attr "type" "branch")
8625 (set (attr "length")
8626 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8627 (const_int 4) (const_int 6)))])
8628
8629 (define_insn "*jump31"
8630 [(set (pc) (label_ref (match_operand 0 "" "")))]
8631 "!TARGET_CPU_ZARCH"
8632 {
8633 gcc_assert (get_attr_length (insn) == 4);
8634 return "j\t%l0";
8635 }
8636 [(set_attr "op_type" "RI")
8637 (set_attr "type" "branch")
8638 (set (attr "length")
8639 (if_then_else (not (match_test "flag_pic"))
8640 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8641 (const_int 4) (const_int 6))
8642 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8643 (const_int 4) (const_int 8))))])
8644
8645 ;
8646 ; indirect-jump instruction pattern(s).
8647 ;
8648
8649 (define_insn "indirect_jump"
8650 [(set (pc) (match_operand 0 "address_operand" "ZQZR"))]
8651 ""
8652 {
8653 if (get_attr_op_type (insn) == OP_TYPE_RR)
8654 return "br\t%0";
8655 else
8656 return "b\t%a0";
8657 }
8658 [(set (attr "op_type")
8659 (if_then_else (match_operand 0 "register_operand" "")
8660 (const_string "RR") (const_string "RX")))
8661 (set_attr "type" "branch")
8662 (set_attr "atype" "agen")])
8663
8664 ;
8665 ; casesi instruction pattern(s).
8666 ;
8667
8668 (define_insn "casesi_jump"
8669 [(set (pc) (match_operand 0 "address_operand" "ZQZR"))
8670 (use (label_ref (match_operand 1 "" "")))]
8671 ""
8672 {
8673 if (get_attr_op_type (insn) == OP_TYPE_RR)
8674 return "br\t%0";
8675 else
8676 return "b\t%a0";
8677 }
8678 [(set (attr "op_type")
8679 (if_then_else (match_operand 0 "register_operand" "")
8680 (const_string "RR") (const_string "RX")))
8681 (set_attr "type" "branch")
8682 (set_attr "atype" "agen")])
8683
8684 (define_expand "casesi"
8685 [(match_operand:SI 0 "general_operand" "")
8686 (match_operand:SI 1 "general_operand" "")
8687 (match_operand:SI 2 "general_operand" "")
8688 (label_ref (match_operand 3 "" ""))
8689 (label_ref (match_operand 4 "" ""))]
8690 ""
8691 {
8692 rtx index = gen_reg_rtx (SImode);
8693 rtx base = gen_reg_rtx (Pmode);
8694 rtx target = gen_reg_rtx (Pmode);
8695
8696 emit_move_insn (index, operands[0]);
8697 emit_insn (gen_subsi3 (index, index, operands[1]));
8698 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
8699 operands[4]);
8700
8701 if (Pmode != SImode)
8702 index = convert_to_mode (Pmode, index, 1);
8703 if (GET_CODE (index) != REG)
8704 index = copy_to_mode_reg (Pmode, index);
8705
8706 if (TARGET_64BIT)
8707 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
8708 else
8709 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
8710
8711 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
8712
8713 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
8714 emit_move_insn (target, index);
8715
8716 if (flag_pic)
8717 target = gen_rtx_PLUS (Pmode, base, target);
8718 emit_jump_insn (gen_casesi_jump (target, operands[3]));
8719
8720 DONE;
8721 })
8722
8723
8724 ;;
8725 ;;- Jump to subroutine.
8726 ;;
8727 ;;
8728
8729 ;
8730 ; untyped call instruction pattern(s).
8731 ;
8732
8733 ;; Call subroutine returning any type.
8734 (define_expand "untyped_call"
8735 [(parallel [(call (match_operand 0 "" "")
8736 (const_int 0))
8737 (match_operand 1 "" "")
8738 (match_operand 2 "" "")])]
8739 ""
8740 {
8741 int i;
8742
8743 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
8744
8745 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8746 {
8747 rtx set = XVECEXP (operands[2], 0, i);
8748 emit_move_insn (SET_DEST (set), SET_SRC (set));
8749 }
8750
8751 /* The optimizer does not know that the call sets the function value
8752 registers we stored in the result block. We avoid problems by
8753 claiming that all hard registers are used and clobbered at this
8754 point. */
8755 emit_insn (gen_blockage ());
8756
8757 DONE;
8758 })
8759
8760 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
8761 ;; all of memory. This blocks insns from being moved across this point.
8762
8763 (define_insn "blockage"
8764 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
8765 ""
8766 ""
8767 [(set_attr "type" "none")
8768 (set_attr "length" "0")])
8769
8770 ;
8771 ; sibcall patterns
8772 ;
8773
8774 (define_expand "sibcall"
8775 [(call (match_operand 0 "" "")
8776 (match_operand 1 "" ""))]
8777 ""
8778 {
8779 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
8780 DONE;
8781 })
8782
8783 (define_insn "*sibcall_br"
8784 [(call (mem:QI (reg SIBCALL_REGNUM))
8785 (match_operand 0 "const_int_operand" "n"))]
8786 "SIBLING_CALL_P (insn)
8787 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
8788 "br\t%%r1"
8789 [(set_attr "op_type" "RR")
8790 (set_attr "type" "branch")
8791 (set_attr "atype" "agen")])
8792
8793 (define_insn "*sibcall_brc"
8794 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8795 (match_operand 1 "const_int_operand" "n"))]
8796 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
8797 "j\t%0"
8798 [(set_attr "op_type" "RI")
8799 (set_attr "type" "branch")])
8800
8801 (define_insn "*sibcall_brcl"
8802 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8803 (match_operand 1 "const_int_operand" "n"))]
8804 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
8805 "jg\t%0"
8806 [(set_attr "op_type" "RIL")
8807 (set_attr "type" "branch")])
8808
8809 ;
8810 ; sibcall_value patterns
8811 ;
8812
8813 (define_expand "sibcall_value"
8814 [(set (match_operand 0 "" "")
8815 (call (match_operand 1 "" "")
8816 (match_operand 2 "" "")))]
8817 ""
8818 {
8819 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
8820 DONE;
8821 })
8822
8823 (define_insn "*sibcall_value_br"
8824 [(set (match_operand 0 "" "")
8825 (call (mem:QI (reg SIBCALL_REGNUM))
8826 (match_operand 1 "const_int_operand" "n")))]
8827 "SIBLING_CALL_P (insn)
8828 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
8829 "br\t%%r1"
8830 [(set_attr "op_type" "RR")
8831 (set_attr "type" "branch")
8832 (set_attr "atype" "agen")])
8833
8834 (define_insn "*sibcall_value_brc"
8835 [(set (match_operand 0 "" "")
8836 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8837 (match_operand 2 "const_int_operand" "n")))]
8838 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
8839 "j\t%1"
8840 [(set_attr "op_type" "RI")
8841 (set_attr "type" "branch")])
8842
8843 (define_insn "*sibcall_value_brcl"
8844 [(set (match_operand 0 "" "")
8845 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8846 (match_operand 2 "const_int_operand" "n")))]
8847 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
8848 "jg\t%1"
8849 [(set_attr "op_type" "RIL")
8850 (set_attr "type" "branch")])
8851
8852
8853 ;
8854 ; call instruction pattern(s).
8855 ;
8856
8857 (define_expand "call"
8858 [(call (match_operand 0 "" "")
8859 (match_operand 1 "" ""))
8860 (use (match_operand 2 "" ""))]
8861 ""
8862 {
8863 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
8864 gen_rtx_REG (Pmode, RETURN_REGNUM));
8865 DONE;
8866 })
8867
8868 (define_insn "*bras"
8869 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8870 (match_operand 1 "const_int_operand" "n"))
8871 (clobber (match_operand 2 "register_operand" "=r"))]
8872 "!SIBLING_CALL_P (insn)
8873 && TARGET_SMALL_EXEC
8874 && GET_MODE (operands[2]) == Pmode"
8875 "bras\t%2,%0"
8876 [(set_attr "op_type" "RI")
8877 (set_attr "type" "jsr")
8878 (set_attr "z196prop" "z196_cracked")])
8879
8880 (define_insn "*brasl"
8881 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8882 (match_operand 1 "const_int_operand" "n"))
8883 (clobber (match_operand 2 "register_operand" "=r"))]
8884 "!SIBLING_CALL_P (insn)
8885 && TARGET_CPU_ZARCH
8886 && GET_MODE (operands[2]) == Pmode"
8887 "brasl\t%2,%0"
8888 [(set_attr "op_type" "RIL")
8889 (set_attr "type" "jsr")
8890 (set_attr "z196prop" "z196_cracked")])
8891
8892 (define_insn "*basr"
8893 [(call (mem:QI (match_operand 0 "address_operand" "ZQZR"))
8894 (match_operand 1 "const_int_operand" "n"))
8895 (clobber (match_operand 2 "register_operand" "=r"))]
8896 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
8897 {
8898 if (get_attr_op_type (insn) == OP_TYPE_RR)
8899 return "basr\t%2,%0";
8900 else
8901 return "bas\t%2,%a0";
8902 }
8903 [(set (attr "op_type")
8904 (if_then_else (match_operand 0 "register_operand" "")
8905 (const_string "RR") (const_string "RX")))
8906 (set_attr "type" "jsr")
8907 (set_attr "atype" "agen")
8908 (set_attr "z196prop" "z196_cracked")])
8909
8910 ;
8911 ; call_value instruction pattern(s).
8912 ;
8913
8914 (define_expand "call_value"
8915 [(set (match_operand 0 "" "")
8916 (call (match_operand 1 "" "")
8917 (match_operand 2 "" "")))
8918 (use (match_operand 3 "" ""))]
8919 ""
8920 {
8921 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
8922 gen_rtx_REG (Pmode, RETURN_REGNUM));
8923 DONE;
8924 })
8925
8926 (define_insn "*bras_r"
8927 [(set (match_operand 0 "" "")
8928 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8929 (match_operand:SI 2 "const_int_operand" "n")))
8930 (clobber (match_operand 3 "register_operand" "=r"))]
8931 "!SIBLING_CALL_P (insn)
8932 && TARGET_SMALL_EXEC
8933 && GET_MODE (operands[3]) == Pmode"
8934 "bras\t%3,%1"
8935 [(set_attr "op_type" "RI")
8936 (set_attr "type" "jsr")
8937 (set_attr "z196prop" "z196_cracked")])
8938
8939 (define_insn "*brasl_r"
8940 [(set (match_operand 0 "" "")
8941 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8942 (match_operand 2 "const_int_operand" "n")))
8943 (clobber (match_operand 3 "register_operand" "=r"))]
8944 "!SIBLING_CALL_P (insn)
8945 && TARGET_CPU_ZARCH
8946 && GET_MODE (operands[3]) == Pmode"
8947 "brasl\t%3,%1"
8948 [(set_attr "op_type" "RIL")
8949 (set_attr "type" "jsr")
8950 (set_attr "z196prop" "z196_cracked")])
8951
8952 (define_insn "*basr_r"
8953 [(set (match_operand 0 "" "")
8954 (call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
8955 (match_operand 2 "const_int_operand" "n")))
8956 (clobber (match_operand 3 "register_operand" "=r"))]
8957 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8958 {
8959 if (get_attr_op_type (insn) == OP_TYPE_RR)
8960 return "basr\t%3,%1";
8961 else
8962 return "bas\t%3,%a1";
8963 }
8964 [(set (attr "op_type")
8965 (if_then_else (match_operand 1 "register_operand" "")
8966 (const_string "RR") (const_string "RX")))
8967 (set_attr "type" "jsr")
8968 (set_attr "atype" "agen")
8969 (set_attr "z196prop" "z196_cracked")])
8970
8971 ;;
8972 ;;- Thread-local storage support.
8973 ;;
8974
8975 (define_expand "get_thread_pointer<mode>"
8976 [(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))]
8977 ""
8978 "")
8979
8980 (define_expand "set_thread_pointer<mode>"
8981 [(set (reg:P TP_REGNUM) (match_operand:P 0 "nonimmediate_operand" ""))
8982 (set (reg:P TP_REGNUM) (unspec_volatile:P [(reg:P TP_REGNUM)] UNSPECV_SET_TP))]
8983 ""
8984 "")
8985
8986 (define_insn "*set_tp"
8987 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
8988 ""
8989 ""
8990 [(set_attr "type" "none")
8991 (set_attr "length" "0")])
8992
8993 (define_insn "*tls_load_64"
8994 [(set (match_operand:DI 0 "register_operand" "=d")
8995 (unspec:DI [(match_operand:DI 1 "memory_operand" "RT")
8996 (match_operand:DI 2 "" "")]
8997 UNSPEC_TLS_LOAD))]
8998 "TARGET_64BIT"
8999 "lg\t%0,%1%J2"
9000 [(set_attr "op_type" "RXE")
9001 (set_attr "z10prop" "z10_fwd_A3")])
9002
9003 (define_insn "*tls_load_31"
9004 [(set (match_operand:SI 0 "register_operand" "=d,d")
9005 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
9006 (match_operand:SI 2 "" "")]
9007 UNSPEC_TLS_LOAD))]
9008 "!TARGET_64BIT"
9009 "@
9010 l\t%0,%1%J2
9011 ly\t%0,%1%J2"
9012 [(set_attr "op_type" "RX,RXY")
9013 (set_attr "type" "load")
9014 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
9015
9016 (define_insn "*bras_tls"
9017 [(set (match_operand 0 "" "")
9018 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9019 (match_operand 2 "const_int_operand" "n")))
9020 (clobber (match_operand 3 "register_operand" "=r"))
9021 (use (match_operand 4 "" ""))]
9022 "!SIBLING_CALL_P (insn)
9023 && TARGET_SMALL_EXEC
9024 && GET_MODE (operands[3]) == Pmode"
9025 "bras\t%3,%1%J4"
9026 [(set_attr "op_type" "RI")
9027 (set_attr "type" "jsr")
9028 (set_attr "z196prop" "z196_cracked")])
9029
9030 (define_insn "*brasl_tls"
9031 [(set (match_operand 0 "" "")
9032 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9033 (match_operand 2 "const_int_operand" "n")))
9034 (clobber (match_operand 3 "register_operand" "=r"))
9035 (use (match_operand 4 "" ""))]
9036 "!SIBLING_CALL_P (insn)
9037 && TARGET_CPU_ZARCH
9038 && GET_MODE (operands[3]) == Pmode"
9039 "brasl\t%3,%1%J4"
9040 [(set_attr "op_type" "RIL")
9041 (set_attr "type" "jsr")
9042 (set_attr "z196prop" "z196_cracked")])
9043
9044 (define_insn "*basr_tls"
9045 [(set (match_operand 0 "" "")
9046 (call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
9047 (match_operand 2 "const_int_operand" "n")))
9048 (clobber (match_operand 3 "register_operand" "=r"))
9049 (use (match_operand 4 "" ""))]
9050 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9051 {
9052 if (get_attr_op_type (insn) == OP_TYPE_RR)
9053 return "basr\t%3,%1%J4";
9054 else
9055 return "bas\t%3,%a1%J4";
9056 }
9057 [(set (attr "op_type")
9058 (if_then_else (match_operand 1 "register_operand" "")
9059 (const_string "RR") (const_string "RX")))
9060 (set_attr "type" "jsr")
9061 (set_attr "atype" "agen")
9062 (set_attr "z196prop" "z196_cracked")])
9063
9064 ;;
9065 ;;- Atomic operations
9066 ;;
9067
9068 ;
9069 ; memory barrier patterns.
9070 ;
9071
9072 (define_expand "mem_signal_fence"
9073 [(match_operand:SI 0 "const_int_operand")] ;; model
9074 ""
9075 {
9076 /* The s390 memory model is strong enough not to require any
9077 barrier in order to synchronize a thread with itself. */
9078 DONE;
9079 })
9080
9081 (define_expand "mem_thread_fence"
9082 [(match_operand:SI 0 "const_int_operand")] ;; model
9083 ""
9084 {
9085 /* Unless this is a SEQ_CST fence, the s390 memory model is strong
9086 enough not to require barriers of any kind. */
9087 if (INTVAL (operands[0]) == MEMMODEL_SEQ_CST)
9088 {
9089 rtx mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
9090 MEM_VOLATILE_P (mem) = 1;
9091 emit_insn (gen_mem_thread_fence_1 (mem));
9092 }
9093 DONE;
9094 })
9095
9096 ; Although bcr is superscalar on Z10, this variant will never
9097 ; become part of an execution group.
9098 ; With z196 we can make use of the fast-BCR-serialization facility.
9099 ; This allows for a slightly faster sync which is sufficient for our
9100 ; purposes.
9101 (define_insn "mem_thread_fence_1"
9102 [(set (match_operand:BLK 0 "" "")
9103 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
9104 ""
9105 {
9106 if (TARGET_Z196)
9107 return "bcr\t14,0";
9108 else
9109 return "bcr\t15,0";
9110 }
9111 [(set_attr "op_type" "RR")
9112 (set_attr "mnemonic" "bcr_flush")
9113 (set_attr "z196prop" "z196_alone")])
9114
9115 ;
9116 ; atomic load/store operations
9117 ;
9118
9119 ; Atomic loads need not examine the memory model at all.
9120 (define_expand "atomic_load<mode>"
9121 [(match_operand:DINT 0 "register_operand") ;; output
9122 (match_operand:DINT 1 "memory_operand") ;; memory
9123 (match_operand:SI 2 "const_int_operand")] ;; model
9124 ""
9125 {
9126 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
9127 FAIL;
9128
9129 if (<MODE>mode == TImode)
9130 emit_insn (gen_atomic_loadti_1 (operands[0], operands[1]));
9131 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9132 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
9133 else
9134 emit_move_insn (operands[0], operands[1]);
9135 DONE;
9136 })
9137
9138 ; Different from movdi_31 in that we want no splitters.
9139 (define_insn "atomic_loaddi_1"
9140 [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f")
9141 (unspec:DI [(match_operand:DI 1 "memory_operand" "Q,S,R,T")]
9142 UNSPEC_MOVA))]
9143 "!TARGET_ZARCH"
9144 "@
9145 lm\t%0,%M0,%S1
9146 lmy\t%0,%M0,%S1
9147 ld\t%0,%1
9148 ldy\t%0,%1"
9149 [(set_attr "op_type" "RS,RSY,RS,RSY")
9150 (set_attr "type" "lm,lm,floaddf,floaddf")])
9151
9152 (define_insn "atomic_loadti_1"
9153 [(set (match_operand:TI 0 "register_operand" "=r")
9154 (unspec:TI [(match_operand:TI 1 "memory_operand" "RT")]
9155 UNSPEC_MOVA))]
9156 "TARGET_ZARCH"
9157 "lpq\t%0,%1"
9158 [(set_attr "op_type" "RXY")
9159 (set_attr "type" "other")])
9160
9161 ; Atomic stores must(?) enforce sequential consistency.
9162 (define_expand "atomic_store<mode>"
9163 [(match_operand:DINT 0 "memory_operand") ;; memory
9164 (match_operand:DINT 1 "register_operand") ;; input
9165 (match_operand:SI 2 "const_int_operand")] ;; model
9166 ""
9167 {
9168 enum memmodel model = (enum memmodel) INTVAL (operands[2]);
9169
9170 if (MEM_ALIGN (operands[0]) < GET_MODE_BITSIZE (GET_MODE (operands[0])))
9171 FAIL;
9172
9173 if (<MODE>mode == TImode)
9174 emit_insn (gen_atomic_storeti_1 (operands[0], operands[1]));
9175 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9176 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
9177 else
9178 emit_move_insn (operands[0], operands[1]);
9179 if (model == MEMMODEL_SEQ_CST)
9180 emit_insn (gen_mem_thread_fence (operands[2]));
9181 DONE;
9182 })
9183
9184 ; Different from movdi_31 in that we want no splitters.
9185 (define_insn "atomic_storedi_1"
9186 [(set (match_operand:DI 0 "memory_operand" "=Q,S,R,T")
9187 (unspec:DI [(match_operand:DI 1 "register_operand" "d,d,!*f,!*f")]
9188 UNSPEC_MOVA))]
9189 "!TARGET_ZARCH"
9190 "@
9191 stm\t%1,%N1,%S0
9192 stmy\t%1,%N1,%S0
9193 std %1,%0
9194 stdy %1,%0"
9195 [(set_attr "op_type" "RS,RSY,RS,RSY")
9196 (set_attr "type" "stm,stm,fstoredf,fstoredf")])
9197
9198 (define_insn "atomic_storeti_1"
9199 [(set (match_operand:TI 0 "memory_operand" "=RT")
9200 (unspec:TI [(match_operand:TI 1 "register_operand" "r")]
9201 UNSPEC_MOVA))]
9202 "TARGET_ZARCH"
9203 "stpq\t%1,%0"
9204 [(set_attr "op_type" "RXY")
9205 (set_attr "type" "other")])
9206
9207 ;
9208 ; compare and swap patterns.
9209 ;
9210
9211 (define_expand "atomic_compare_and_swap<mode>"
9212 [(match_operand:SI 0 "register_operand") ;; bool success output
9213 (match_operand:DGPR 1 "nonimmediate_operand");; oldval output
9214 (match_operand:DGPR 2 "memory_operand") ;; memory
9215 (match_operand:DGPR 3 "register_operand") ;; expected intput
9216 (match_operand:DGPR 4 "register_operand") ;; newval intput
9217 (match_operand:SI 5 "const_int_operand") ;; is_weak
9218 (match_operand:SI 6 "const_int_operand") ;; success model
9219 (match_operand:SI 7 "const_int_operand")] ;; failure model
9220 ""
9221 {
9222 rtx cc, cmp, output = operands[1];
9223
9224 if (!register_operand (output, <MODE>mode))
9225 output = gen_reg_rtx (<MODE>mode);
9226
9227 if (MEM_ALIGN (operands[2]) < GET_MODE_BITSIZE (GET_MODE (operands[2])))
9228 FAIL;
9229
9230 emit_insn (gen_atomic_compare_and_swap<mode>_internal
9231 (output, operands[2], operands[3], operands[4]));
9232
9233 /* We deliberately accept non-register operands in the predicate
9234 to ensure the write back to the output operand happens *before*
9235 the store-flags code below. This makes it easier for combine
9236 to merge the store-flags code with a potential test-and-branch
9237 pattern following (immediately!) afterwards. */
9238 if (output != operands[1])
9239 emit_move_insn (operands[1], output);
9240
9241 cc = gen_rtx_REG (CCZ1mode, CC_REGNUM);
9242 cmp = gen_rtx_EQ (SImode, cc, const0_rtx);
9243 emit_insn (gen_cstorecc4 (operands[0], cmp, cc, const0_rtx));
9244 DONE;
9245 })
9246
9247 (define_expand "atomic_compare_and_swap<mode>"
9248 [(match_operand:SI 0 "register_operand") ;; bool success output
9249 (match_operand:HQI 1 "nonimmediate_operand") ;; oldval output
9250 (match_operand:HQI 2 "memory_operand") ;; memory
9251 (match_operand:HQI 3 "general_operand") ;; expected intput
9252 (match_operand:HQI 4 "general_operand") ;; newval intput
9253 (match_operand:SI 5 "const_int_operand") ;; is_weak
9254 (match_operand:SI 6 "const_int_operand") ;; success model
9255 (match_operand:SI 7 "const_int_operand")] ;; failure model
9256 ""
9257 {
9258 s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1], operands[2],
9259 operands[3], operands[4], INTVAL (operands[5]));
9260 DONE;
9261 })
9262
9263 (define_expand "atomic_compare_and_swap<mode>_internal"
9264 [(parallel
9265 [(set (match_operand:DGPR 0 "register_operand")
9266 (match_operand:DGPR 1 "memory_operand"))
9267 (set (match_dup 1)
9268 (unspec_volatile:DGPR
9269 [(match_dup 1)
9270 (match_operand:DGPR 2 "register_operand")
9271 (match_operand:DGPR 3 "register_operand")]
9272 UNSPECV_CAS))
9273 (set (reg:CCZ1 CC_REGNUM)
9274 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
9275 "")
9276
9277 ; cdsg, csg
9278 (define_insn "*atomic_compare_and_swap<mode>_1"
9279 [(set (match_operand:TDI 0 "register_operand" "=r")
9280 (match_operand:TDI 1 "memory_operand" "+QS"))
9281 (set (match_dup 1)
9282 (unspec_volatile:TDI
9283 [(match_dup 1)
9284 (match_operand:TDI 2 "register_operand" "0")
9285 (match_operand:TDI 3 "register_operand" "r")]
9286 UNSPECV_CAS))
9287 (set (reg:CCZ1 CC_REGNUM)
9288 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9289 "TARGET_ZARCH"
9290 "c<td>sg\t%0,%3,%S1"
9291 [(set_attr "op_type" "RSY")
9292 (set_attr "type" "sem")])
9293
9294 ; cds, cdsy
9295 (define_insn "*atomic_compare_and_swapdi_2"
9296 [(set (match_operand:DI 0 "register_operand" "=r,r")
9297 (match_operand:DI 1 "memory_operand" "+Q,S"))
9298 (set (match_dup 1)
9299 (unspec_volatile:DI
9300 [(match_dup 1)
9301 (match_operand:DI 2 "register_operand" "0,0")
9302 (match_operand:DI 3 "register_operand" "r,r")]
9303 UNSPECV_CAS))
9304 (set (reg:CCZ1 CC_REGNUM)
9305 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9306 "!TARGET_ZARCH"
9307 "@
9308 cds\t%0,%3,%S1
9309 cdsy\t%0,%3,%S1"
9310 [(set_attr "op_type" "RS,RSY")
9311 (set_attr "type" "sem")])
9312
9313 ; cs, csy
9314 (define_insn "*atomic_compare_and_swapsi_3"
9315 [(set (match_operand:SI 0 "register_operand" "=r,r")
9316 (match_operand:SI 1 "memory_operand" "+Q,S"))
9317 (set (match_dup 1)
9318 (unspec_volatile:SI
9319 [(match_dup 1)
9320 (match_operand:SI 2 "register_operand" "0,0")
9321 (match_operand:SI 3 "register_operand" "r,r")]
9322 UNSPECV_CAS))
9323 (set (reg:CCZ1 CC_REGNUM)
9324 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9325 ""
9326 "@
9327 cs\t%0,%3,%S1
9328 csy\t%0,%3,%S1"
9329 [(set_attr "op_type" "RS,RSY")
9330 (set_attr "type" "sem")])
9331
9332 ;
9333 ; Other atomic instruction patterns.
9334 ;
9335
9336 ; z196 load and add, xor, or and and instructions
9337
9338 (define_expand "atomic_fetch_<atomic><mode>"
9339 [(match_operand:GPR 0 "register_operand") ;; val out
9340 (ATOMIC_Z196:GPR
9341 (match_operand:GPR 1 "memory_operand") ;; memory
9342 (match_operand:GPR 2 "register_operand")) ;; val in
9343 (match_operand:SI 3 "const_int_operand")] ;; model
9344 "TARGET_Z196"
9345 {
9346 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
9347 FAIL;
9348
9349 emit_insn (gen_atomic_fetch_<atomic><mode>_iaf
9350 (operands[0], operands[1], operands[2]));
9351 DONE;
9352 })
9353
9354 ; lan, lang, lao, laog, lax, laxg, laa, laag
9355 (define_insn "atomic_fetch_<atomic><mode>_iaf"
9356 [(set (match_operand:GPR 0 "register_operand" "=d")
9357 (match_operand:GPR 1 "memory_operand" "+QS"))
9358 (set (match_dup 1)
9359 (unspec_volatile:GPR
9360 [(ATOMIC_Z196:GPR (match_dup 1)
9361 (match_operand:GPR 2 "general_operand" "d"))]
9362 UNSPECV_ATOMIC_OP))
9363 (clobber (reg:CC CC_REGNUM))]
9364 "TARGET_Z196"
9365 "la<noxa><g>\t%0,%2,%1"
9366 [(set_attr "op_type" "RSY")
9367 (set_attr "type" "sem")])
9368
9369 ;; For SImode and larger, the optabs.c code will do just fine in
9370 ;; expanding a compare-and-swap loop. For QI/HImode, we can do
9371 ;; better by expanding our own loop.
9372
9373 (define_expand "atomic_<atomic><mode>"
9374 [(ATOMIC:HQI
9375 (match_operand:HQI 0 "memory_operand") ;; memory
9376 (match_operand:HQI 1 "general_operand")) ;; val in
9377 (match_operand:SI 2 "const_int_operand")] ;; model
9378 ""
9379 {
9380 s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
9381 operands[1], false);
9382 DONE;
9383 })
9384
9385 (define_expand "atomic_fetch_<atomic><mode>"
9386 [(match_operand:HQI 0 "register_operand") ;; val out
9387 (ATOMIC:HQI
9388 (match_operand:HQI 1 "memory_operand") ;; memory
9389 (match_operand:HQI 2 "general_operand")) ;; val in
9390 (match_operand:SI 3 "const_int_operand")] ;; model
9391 ""
9392 {
9393 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
9394 operands[2], false);
9395 DONE;
9396 })
9397
9398 (define_expand "atomic_<atomic>_fetch<mode>"
9399 [(match_operand:HQI 0 "register_operand") ;; val out
9400 (ATOMIC:HQI
9401 (match_operand:HQI 1 "memory_operand") ;; memory
9402 (match_operand:HQI 2 "general_operand")) ;; val in
9403 (match_operand:SI 3 "const_int_operand")] ;; model
9404 ""
9405 {
9406 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
9407 operands[2], true);
9408 DONE;
9409 })
9410
9411 (define_expand "atomic_exchange<mode>"
9412 [(match_operand:HQI 0 "register_operand") ;; val out
9413 (match_operand:HQI 1 "memory_operand") ;; memory
9414 (match_operand:HQI 2 "general_operand") ;; val in
9415 (match_operand:SI 3 "const_int_operand")] ;; model
9416 ""
9417 {
9418 s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
9419 operands[2], false);
9420 DONE;
9421 })
9422
9423 ;;
9424 ;;- Miscellaneous instructions.
9425 ;;
9426
9427 ;
9428 ; allocate stack instruction pattern(s).
9429 ;
9430
9431 (define_expand "allocate_stack"
9432 [(match_operand 0 "general_operand" "")
9433 (match_operand 1 "general_operand" "")]
9434 "TARGET_BACKCHAIN"
9435 {
9436 rtx temp = gen_reg_rtx (Pmode);
9437
9438 emit_move_insn (temp, s390_back_chain_rtx ());
9439 anti_adjust_stack (operands[1]);
9440 emit_move_insn (s390_back_chain_rtx (), temp);
9441
9442 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9443 DONE;
9444 })
9445
9446
9447 ;
9448 ; setjmp instruction pattern.
9449 ;
9450
9451 (define_expand "builtin_setjmp_receiver"
9452 [(match_operand 0 "" "")]
9453 "flag_pic"
9454 {
9455 emit_insn (s390_load_got ());
9456 emit_use (pic_offset_table_rtx);
9457 DONE;
9458 })
9459
9460 ;; These patterns say how to save and restore the stack pointer. We need not
9461 ;; save the stack pointer at function level since we are careful to
9462 ;; preserve the backchain. At block level, we have to restore the backchain
9463 ;; when we restore the stack pointer.
9464 ;;
9465 ;; For nonlocal gotos, we must save both the stack pointer and its
9466 ;; backchain and restore both. Note that in the nonlocal case, the
9467 ;; save area is a memory location.
9468
9469 (define_expand "save_stack_function"
9470 [(match_operand 0 "general_operand" "")
9471 (match_operand 1 "general_operand" "")]
9472 ""
9473 "DONE;")
9474
9475 (define_expand "restore_stack_function"
9476 [(match_operand 0 "general_operand" "")
9477 (match_operand 1 "general_operand" "")]
9478 ""
9479 "DONE;")
9480
9481 (define_expand "restore_stack_block"
9482 [(match_operand 0 "register_operand" "")
9483 (match_operand 1 "register_operand" "")]
9484 "TARGET_BACKCHAIN"
9485 {
9486 rtx temp = gen_reg_rtx (Pmode);
9487
9488 emit_move_insn (temp, s390_back_chain_rtx ());
9489 emit_move_insn (operands[0], operands[1]);
9490 emit_move_insn (s390_back_chain_rtx (), temp);
9491
9492 DONE;
9493 })
9494
9495 (define_expand "save_stack_nonlocal"
9496 [(match_operand 0 "memory_operand" "")
9497 (match_operand 1 "register_operand" "")]
9498 ""
9499 {
9500 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
9501
9502 /* Copy the backchain to the first word, sp to the second and the
9503 literal pool base to the third. */
9504
9505 rtx save_bc = adjust_address (operands[0], Pmode, 0);
9506 rtx save_sp = adjust_address (operands[0], Pmode, GET_MODE_SIZE (Pmode));
9507 rtx save_bp = adjust_address (operands[0], Pmode, 2 * GET_MODE_SIZE (Pmode));
9508
9509 if (TARGET_BACKCHAIN)
9510 emit_move_insn (save_bc, force_reg (Pmode, s390_back_chain_rtx ()));
9511
9512 emit_move_insn (save_sp, operands[1]);
9513 emit_move_insn (save_bp, base);
9514
9515 DONE;
9516 })
9517
9518 (define_expand "restore_stack_nonlocal"
9519 [(match_operand 0 "register_operand" "")
9520 (match_operand 1 "memory_operand" "")]
9521 ""
9522 {
9523 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
9524 rtx temp = NULL_RTX;
9525
9526 /* Restore the backchain from the first word, sp from the second and the
9527 literal pool base from the third. */
9528
9529 rtx save_bc = adjust_address (operands[1], Pmode, 0);
9530 rtx save_sp = adjust_address (operands[1], Pmode, GET_MODE_SIZE (Pmode));
9531 rtx save_bp = adjust_address (operands[1], Pmode, 2 * GET_MODE_SIZE (Pmode));
9532
9533 if (TARGET_BACKCHAIN)
9534 temp = force_reg (Pmode, save_bc);
9535
9536 emit_move_insn (base, save_bp);
9537 emit_move_insn (operands[0], save_sp);
9538
9539 if (temp)
9540 emit_move_insn (s390_back_chain_rtx (), temp);
9541
9542 emit_use (base);
9543 DONE;
9544 })
9545
9546 (define_expand "exception_receiver"
9547 [(const_int 0)]
9548 ""
9549 {
9550 s390_set_has_landing_pad_p (true);
9551 DONE;
9552 })
9553
9554 ;
9555 ; nop instruction pattern(s).
9556 ;
9557
9558 (define_insn "nop"
9559 [(const_int 0)]
9560 ""
9561 "lr\t0,0"
9562 [(set_attr "op_type" "RR")
9563 (set_attr "z10prop" "z10_fr_E1")])
9564
9565 (define_insn "nop1"
9566 [(const_int 1)]
9567 ""
9568 "lr\t1,1"
9569 [(set_attr "op_type" "RR")])
9570
9571
9572 ;
9573 ; Special literal pool access instruction pattern(s).
9574 ;
9575
9576 (define_insn "*pool_entry"
9577 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
9578 UNSPECV_POOL_ENTRY)]
9579 ""
9580 {
9581 enum machine_mode mode = GET_MODE (PATTERN (insn));
9582 unsigned int align = GET_MODE_BITSIZE (mode);
9583 s390_output_pool_entry (operands[0], mode, align);
9584 return "";
9585 }
9586 [(set (attr "length")
9587 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
9588
9589 (define_insn "pool_align"
9590 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
9591 UNSPECV_POOL_ALIGN)]
9592 ""
9593 ".align\t%0"
9594 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
9595
9596 (define_insn "pool_section_start"
9597 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
9598 ""
9599 ".section\t.rodata"
9600 [(set_attr "length" "0")])
9601
9602 (define_insn "pool_section_end"
9603 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
9604 ""
9605 ".previous"
9606 [(set_attr "length" "0")])
9607
9608 (define_insn "main_base_31_small"
9609 [(set (match_operand 0 "register_operand" "=a")
9610 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
9611 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9612 "basr\t%0,0"
9613 [(set_attr "op_type" "RR")
9614 (set_attr "type" "la")
9615 (set_attr "z196prop" "z196_cracked")])
9616
9617 (define_insn "main_base_31_large"
9618 [(set (match_operand 0 "register_operand" "=a")
9619 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
9620 (set (pc) (label_ref (match_operand 2 "" "")))]
9621 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9622 "bras\t%0,%2"
9623 [(set_attr "op_type" "RI")
9624 (set_attr "z196prop" "z196_cracked")])
9625
9626 (define_insn "main_base_64"
9627 [(set (match_operand 0 "register_operand" "=a")
9628 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
9629 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9630 "larl\t%0,%1"
9631 [(set_attr "op_type" "RIL")
9632 (set_attr "type" "larl")
9633 (set_attr "z10prop" "z10_fwd_A1")])
9634
9635 (define_insn "main_pool"
9636 [(set (match_operand 0 "register_operand" "=a")
9637 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
9638 "GET_MODE (operands[0]) == Pmode"
9639 {
9640 gcc_unreachable ();
9641 }
9642 [(set (attr "type")
9643 (if_then_else (match_test "TARGET_CPU_ZARCH")
9644 (const_string "larl") (const_string "la")))])
9645
9646 (define_insn "reload_base_31"
9647 [(set (match_operand 0 "register_operand" "=a")
9648 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
9649 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9650 "basr\t%0,0\;la\t%0,%1-.(%0)"
9651 [(set_attr "length" "6")
9652 (set_attr "type" "la")
9653 (set_attr "z196prop" "z196_cracked")])
9654
9655 (define_insn "reload_base_64"
9656 [(set (match_operand 0 "register_operand" "=a")
9657 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
9658 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9659 "larl\t%0,%1"
9660 [(set_attr "op_type" "RIL")
9661 (set_attr "type" "larl")
9662 (set_attr "z10prop" "z10_fwd_A1")])
9663
9664 (define_insn "pool"
9665 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
9666 ""
9667 {
9668 gcc_unreachable ();
9669 }
9670 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
9671
9672 ;;
9673 ;; Insns related to generating the function prologue and epilogue.
9674 ;;
9675
9676
9677 (define_expand "prologue"
9678 [(use (const_int 0))]
9679 ""
9680 "s390_emit_prologue (); DONE;")
9681
9682 (define_expand "epilogue"
9683 [(use (const_int 1))]
9684 ""
9685 "s390_emit_epilogue (false); DONE;")
9686
9687 (define_expand "sibcall_epilogue"
9688 [(use (const_int 0))]
9689 ""
9690 "s390_emit_epilogue (true); DONE;")
9691
9692 ;; A direct return instruction, without using an epilogue.
9693 (define_insn "<code>"
9694 [(ANY_RETURN)]
9695 "s390_can_use_<code>_insn ()"
9696 "br\t%%r14"
9697 [(set_attr "op_type" "RR")
9698 (set_attr "type" "jsr")
9699 (set_attr "atype" "agen")])
9700
9701 (define_insn "*return"
9702 [(return)
9703 (use (match_operand 0 "register_operand" "a"))]
9704 "GET_MODE (operands[0]) == Pmode"
9705 "br\t%0"
9706 [(set_attr "op_type" "RR")
9707 (set_attr "type" "jsr")
9708 (set_attr "atype" "agen")])
9709
9710
9711 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
9712 ;; pointer. This is used for compatibility.
9713
9714 (define_expand "ptr_extend"
9715 [(set (match_operand:DI 0 "register_operand" "=r")
9716 (match_operand:SI 1 "register_operand" "r"))]
9717 "TARGET_64BIT"
9718 {
9719 emit_insn (gen_anddi3 (operands[0],
9720 gen_lowpart (DImode, operands[1]),
9721 GEN_INT (0x7fffffff)));
9722 DONE;
9723 })
9724
9725 ;; Instruction definition to expand eh_return macro to support
9726 ;; swapping in special linkage return addresses.
9727
9728 (define_expand "eh_return"
9729 [(use (match_operand 0 "register_operand" ""))]
9730 "TARGET_TPF"
9731 {
9732 s390_emit_tpf_eh_return (operands[0]);
9733 DONE;
9734 })
9735
9736 ;
9737 ; Stack Protector Patterns
9738 ;
9739
9740 (define_expand "stack_protect_set"
9741 [(set (match_operand 0 "memory_operand" "")
9742 (match_operand 1 "memory_operand" ""))]
9743 ""
9744 {
9745 #ifdef TARGET_THREAD_SSP_OFFSET
9746 operands[1]
9747 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
9748 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
9749 #endif
9750 if (TARGET_64BIT)
9751 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
9752 else
9753 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
9754
9755 DONE;
9756 })
9757
9758 (define_insn "stack_protect_set<mode>"
9759 [(set (match_operand:DSI 0 "memory_operand" "=Q")
9760 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
9761 ""
9762 "mvc\t%O0(%G0,%R0),%S1"
9763 [(set_attr "op_type" "SS")])
9764
9765 (define_expand "stack_protect_test"
9766 [(set (reg:CC CC_REGNUM)
9767 (compare (match_operand 0 "memory_operand" "")
9768 (match_operand 1 "memory_operand" "")))
9769 (match_operand 2 "" "")]
9770 ""
9771 {
9772 rtx cc_reg, test;
9773 #ifdef TARGET_THREAD_SSP_OFFSET
9774 operands[1]
9775 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
9776 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
9777 #endif
9778 if (TARGET_64BIT)
9779 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
9780 else
9781 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
9782
9783 cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM);
9784 test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx);
9785 emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2]));
9786 DONE;
9787 })
9788
9789 (define_insn "stack_protect_test<mode>"
9790 [(set (reg:CCZ CC_REGNUM)
9791 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
9792 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
9793 ""
9794 "clc\t%O0(%G0,%R0),%S1"
9795 [(set_attr "op_type" "SS")])
9796
9797 ; This is used in s390_emit_prologue in order to prevent insns
9798 ; adjusting the stack pointer to be moved over insns writing stack
9799 ; slots using a copy of the stack pointer in a different register.
9800 (define_insn "stack_tie"
9801 [(set (match_operand:BLK 0 "memory_operand" "+m")
9802 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
9803 ""
9804 ""
9805 [(set_attr "length" "0")])
9806
9807
9808 ;
9809 ; Data prefetch patterns
9810 ;
9811
9812 (define_insn "prefetch"
9813 [(prefetch (match_operand 0 "address_operand" "ZQZRZSZT,X")
9814 (match_operand:SI 1 "const_int_operand" " n,n")
9815 (match_operand:SI 2 "const_int_operand" " n,n"))]
9816 "TARGET_Z10"
9817 {
9818 switch (which_alternative)
9819 {
9820 case 0:
9821 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
9822 case 1:
9823 if (larl_operand (operands[0], Pmode))
9824 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
9825 default:
9826
9827 /* This might be reached for symbolic operands with an odd
9828 addend. We simply omit the prefetch for such rare cases. */
9829
9830 return "";
9831 }
9832 }
9833 [(set_attr "type" "load,larl")
9834 (set_attr "op_type" "RXY,RIL")
9835 (set_attr "z10prop" "z10_super")
9836 (set_attr "z196prop" "z196_alone")])
9837
9838
9839 ;
9840 ; Byte swap instructions
9841 ;
9842
9843 (define_insn "bswap<mode>2"
9844 [(set (match_operand:GPR 0 "register_operand" "=d, d")
9845 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,RT")))]
9846 "TARGET_CPU_ZARCH"
9847 "@
9848 lrv<g>r\t%0,%1
9849 lrv<g>\t%0,%1"
9850 [(set_attr "type" "*,load")
9851 (set_attr "op_type" "RRE,RXY")
9852 (set_attr "z10prop" "z10_super")])
9853
9854
9855 ;
9856 ; Population count instruction
9857 ;
9858
9859 ; The S/390 popcount instruction counts the bits of op1 in 8 byte
9860 ; portions and stores the result in the corresponding bytes in op0.
9861 (define_insn "*popcount<mode>"
9862 [(set (match_operand:INT 0 "register_operand" "=d")
9863 (unspec:INT [(match_operand:INT 1 "register_operand" "d")] UNSPEC_POPCNT))
9864 (clobber (reg:CC CC_REGNUM))]
9865 "TARGET_Z196"
9866 "popcnt\t%0,%1"
9867 [(set_attr "op_type" "RRE")])
9868
9869 (define_expand "popcountdi2"
9870 [; popcnt op0, op1
9871 (parallel [(set (match_operand:DI 0 "register_operand" "")
9872 (unspec:DI [(match_operand:DI 1 "register_operand")]
9873 UNSPEC_POPCNT))
9874 (clobber (reg:CC CC_REGNUM))])
9875 ; sllg op2, op0, 32
9876 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 32)))
9877 ; agr op0, op2
9878 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
9879 (clobber (reg:CC CC_REGNUM))])
9880 ; sllg op2, op0, 16
9881 (set (match_dup 2)
9882 (ashift:DI (match_dup 0) (const_int 16)))
9883 ; agr op0, op2
9884 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
9885 (clobber (reg:CC CC_REGNUM))])
9886 ; sllg op2, op0, 8
9887 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 8)))
9888 ; agr op0, op2
9889 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
9890 (clobber (reg:CC CC_REGNUM))])
9891 ; srlg op0, op0, 56
9892 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (const_int 56)))]
9893 "TARGET_Z196 && TARGET_64BIT"
9894 "operands[2] = gen_reg_rtx (DImode);")
9895
9896 (define_expand "popcountsi2"
9897 [; popcnt op0, op1
9898 (parallel [(set (match_operand:SI 0 "register_operand" "")
9899 (unspec:SI [(match_operand:SI 1 "register_operand")]
9900 UNSPEC_POPCNT))
9901 (clobber (reg:CC CC_REGNUM))])
9902 ; sllk op2, op0, 16
9903 (set (match_dup 2)
9904 (ashift:SI (match_dup 0) (const_int 16)))
9905 ; ar op0, op2
9906 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
9907 (clobber (reg:CC CC_REGNUM))])
9908 ; sllk op2, op0, 8
9909 (set (match_dup 2) (ashift:SI (match_dup 0) (const_int 8)))
9910 ; ar op0, op2
9911 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
9912 (clobber (reg:CC CC_REGNUM))])
9913 ; srl op0, op0, 24
9914 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 24)))]
9915 "TARGET_Z196"
9916 "operands[2] = gen_reg_rtx (SImode);")
9917
9918 (define_expand "popcounthi2"
9919 [; popcnt op0, op1
9920 (parallel [(set (match_operand:HI 0 "register_operand" "")
9921 (unspec:HI [(match_operand:HI 1 "register_operand")]
9922 UNSPEC_POPCNT))
9923 (clobber (reg:CC CC_REGNUM))])
9924 ; sllk op2, op0, 8
9925 (set (match_dup 2)
9926 (ashift:SI (match_dup 0) (const_int 8)))
9927 ; ar op0, op2
9928 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
9929 (clobber (reg:CC CC_REGNUM))])
9930 ; srl op0, op0, 8
9931 (set (match_dup 0) (lshiftrt:HI (match_dup 0) (const_int 8)))]
9932 "TARGET_Z196"
9933 "operands[2] = gen_reg_rtx (SImode);")
9934
9935 (define_expand "popcountqi2"
9936 [; popcnt op0, op1
9937 (parallel [(set (match_operand:QI 0 "register_operand" "")
9938 (unspec:QI [(match_operand:QI 1 "register_operand")]
9939 UNSPEC_POPCNT))
9940 (clobber (reg:CC CC_REGNUM))])]
9941 "TARGET_Z196"
9942 "")
9943
9944 ;;
9945 ;;- Copy sign instructions
9946 ;;
9947
9948 (define_insn "copysign<mode>3"
9949 [(set (match_operand:FP 0 "register_operand" "=f")
9950 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
9951 (match_operand:FP 2 "register_operand" "f")]
9952 UNSPEC_COPYSIGN))]
9953 "TARGET_Z196"
9954 "cpsdr\t%0,%2,%1"
9955 [(set_attr "op_type" "RRF")
9956 (set_attr "type" "fsimp<mode>")])
9957
9958
9959 ;;
9960 ;;- Transactional execution instructions
9961 ;;
9962
9963 ; This splitter helps combine to make use of CC directly when
9964 ; comparing the integer result of a tbegin builtin with a constant.
9965 ; The unspec is already removed by canonicalize_comparison. So this
9966 ; splitters only job is to turn the PARALLEL into separate insns
9967 ; again. Unfortunately this only works with the very first cc/int
9968 ; compare since combine is not able to deal with data flow across
9969 ; basic block boundaries.
9970
9971 ; It needs to be an insn pattern as well since combine does not apply
9972 ; the splitter directly. Combine would only use it if it actually
9973 ; would reduce the number of instructions.
9974 (define_insn_and_split "*ccraw_to_int"
9975 [(set (pc)
9976 (if_then_else
9977 (match_operator 0 "s390_eqne_operator"
9978 [(reg:CCRAW CC_REGNUM)
9979 (match_operand 1 "const_int_operand" "")])
9980 (label_ref (match_operand 2 "" ""))
9981 (pc)))
9982 (set (match_operand:SI 3 "register_operand" "=d")
9983 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
9984 ""
9985 "#"
9986 ""
9987 [(set (match_dup 3)
9988 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))
9989 (set (pc)
9990 (if_then_else (match_op_dup 0 [(reg:CCRAW CC_REGNUM) (match_dup 1)])
9991 (label_ref (match_dup 2))
9992 (pc)))]
9993 "")
9994
9995 ; Non-constrained transaction begin
9996
9997 (define_expand "tbegin"
9998 [(match_operand:SI 0 "register_operand" "")
9999 (match_operand:BLK 1 "memory_operand" "")]
10000 "TARGET_HTM"
10001 {
10002 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, true);
10003 DONE;
10004 })
10005
10006 (define_expand "tbegin_nofloat"
10007 [(match_operand:SI 0 "register_operand" "")
10008 (match_operand:BLK 1 "memory_operand" "")]
10009 "TARGET_HTM"
10010 {
10011 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, false);
10012 DONE;
10013 })
10014
10015 (define_expand "tbegin_retry"
10016 [(match_operand:SI 0 "register_operand" "")
10017 (match_operand:BLK 1 "memory_operand" "")
10018 (match_operand:SI 2 "general_operand" "")]
10019 "TARGET_HTM"
10020 {
10021 s390_expand_tbegin (operands[0], operands[1], operands[2], true);
10022 DONE;
10023 })
10024
10025 (define_expand "tbegin_retry_nofloat"
10026 [(match_operand:SI 0 "register_operand" "")
10027 (match_operand:BLK 1 "memory_operand" "")
10028 (match_operand:SI 2 "general_operand" "")]
10029 "TARGET_HTM"
10030 {
10031 s390_expand_tbegin (operands[0], operands[1], operands[2], false);
10032 DONE;
10033 })
10034
10035 (define_insn "tbegin_1"
10036 [(set (reg:CCRAW CC_REGNUM)
10037 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10038 UNSPECV_TBEGIN))
10039 (set (match_operand:BLK 1 "memory_operand" "=Q")
10040 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
10041 (clobber (reg:DF 16))
10042 (clobber (reg:DF 17))
10043 (clobber (reg:DF 18))
10044 (clobber (reg:DF 19))
10045 (clobber (reg:DF 20))
10046 (clobber (reg:DF 21))
10047 (clobber (reg:DF 22))
10048 (clobber (reg:DF 23))
10049 (clobber (reg:DF 24))
10050 (clobber (reg:DF 25))
10051 (clobber (reg:DF 26))
10052 (clobber (reg:DF 27))
10053 (clobber (reg:DF 28))
10054 (clobber (reg:DF 29))
10055 (clobber (reg:DF 30))
10056 (clobber (reg:DF 31))]
10057 ; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
10058 ; not supposed to be used for immediates (see genpreds.c).
10059 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10060 "tbegin\t%1,%x0"
10061 [(set_attr "op_type" "SIL")])
10062
10063 ; Same as above but without the FPR clobbers
10064 (define_insn "tbegin_nofloat_1"
10065 [(set (reg:CCRAW CC_REGNUM)
10066 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10067 UNSPECV_TBEGIN))
10068 (set (match_operand:BLK 1 "memory_operand" "=Q")
10069 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))]
10070 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10071 "tbegin\t%1,%x0"
10072 [(set_attr "op_type" "SIL")])
10073
10074
10075 ; Constrained transaction begin
10076
10077 (define_expand "tbeginc"
10078 [(set (reg:CCRAW CC_REGNUM)
10079 (unspec_volatile:CCRAW [(const_int TBEGINC_MASK)]
10080 UNSPECV_TBEGINC))]
10081 "TARGET_HTM"
10082 "")
10083
10084 (define_insn "*tbeginc_1"
10085 [(set (reg:CCRAW CC_REGNUM)
10086 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" " D")]
10087 UNSPECV_TBEGINC))]
10088 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10089 "tbeginc\t0,%x0"
10090 [(set_attr "op_type" "SIL")])
10091
10092 ; Transaction end
10093
10094 (define_expand "tend"
10095 [(set (reg:CCRAW CC_REGNUM)
10096 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))
10097 (set (match_operand:SI 0 "register_operand" "")
10098 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
10099 "TARGET_HTM"
10100 "")
10101
10102 (define_insn "*tend_1"
10103 [(set (reg:CCRAW CC_REGNUM)
10104 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))]
10105 "TARGET_HTM"
10106 "tend"
10107 [(set_attr "op_type" "S")])
10108
10109 ; Transaction abort
10110
10111 (define_expand "tabort"
10112 [(unspec_volatile [(match_operand:SI 0 "shift_count_or_setmem_operand" "")]
10113 UNSPECV_TABORT)]
10114 "TARGET_HTM && operands != NULL"
10115 {
10116 if (CONST_INT_P (operands[0])
10117 && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 255)
10118 {
10119 error ("Invalid transaction abort code: " HOST_WIDE_INT_PRINT_DEC
10120 ". Values in range 0 through 255 are reserved.",
10121 INTVAL (operands[0]));
10122 FAIL;
10123 }
10124 })
10125
10126 (define_insn "*tabort_1"
10127 [(unspec_volatile [(match_operand:SI 0 "shift_count_or_setmem_operand" "Y")]
10128 UNSPECV_TABORT)]
10129 "TARGET_HTM && operands != NULL"
10130 "tabort\t%Y0"
10131 [(set_attr "op_type" "S")])
10132
10133 ; Transaction extract nesting depth
10134
10135 (define_insn "etnd"
10136 [(set (match_operand:SI 0 "register_operand" "=d")
10137 (unspec_volatile:SI [(const_int 0)] UNSPECV_ETND))]
10138 "TARGET_HTM"
10139 "etnd\t%0"
10140 [(set_attr "op_type" "RRE")])
10141
10142 ; Non-transactional store
10143
10144 (define_insn "ntstg"
10145 [(set (match_operand:DI 0 "memory_operand" "=RT")
10146 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "d")]
10147 UNSPECV_NTSTG))]
10148 "TARGET_HTM"
10149 "ntstg\t%1,%0"
10150 [(set_attr "op_type" "RXY")])
10151
10152 ; Transaction perform processor assist
10153
10154 (define_expand "tx_assist"
10155 [(unspec_volatile [(match_operand:SI 0 "register_operand" "")
10156 (reg:SI GPR0_REGNUM)
10157 (const_int 1)]
10158 UNSPECV_PPA)]
10159 "TARGET_HTM"
10160 "")
10161
10162 (define_insn "*ppa"
10163 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")
10164 (match_operand:SI 1 "register_operand" "d")
10165 (match_operand 2 "const_int_operand" "I")]
10166 UNSPECV_PPA)]
10167 "TARGET_HTM && INTVAL (operands[2]) < 16"
10168 "ppa\t%0,%1,%2"
10169 [(set_attr "op_type" "RRF")])