s390.md (cpu_facility): Add cpu_zarch.
[gcc.git] / gcc / config / s390 / s390.md
1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;; Copyright (C) 1999-2013 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_CCU_TO_INT
63 UNSPEC_CCZ_TO_INT
64 UNSPEC_ICM
65 UNSPEC_TIE
66
67 ; GOT/PLT and lt-relative accesses
68 UNSPEC_LTREL_OFFSET
69 UNSPEC_LTREL_BASE
70 UNSPEC_POOL_OFFSET
71 UNSPEC_GOTENT
72 UNSPEC_GOT
73 UNSPEC_GOTOFF
74 UNSPEC_PLT
75 UNSPEC_PLTOFF
76
77 ; Literal pool
78 UNSPEC_RELOAD_BASE
79 UNSPEC_MAIN_BASE
80 UNSPEC_LTREF
81 UNSPEC_INSN
82 UNSPEC_EXECUTE
83
84 ; Atomic Support
85 UNSPEC_MB
86 UNSPEC_MOVA
87
88 ; TLS relocation specifiers
89 UNSPEC_TLSGD
90 UNSPEC_TLSLDM
91 UNSPEC_NTPOFF
92 UNSPEC_DTPOFF
93 UNSPEC_GOTNTPOFF
94 UNSPEC_INDNTPOFF
95
96 ; TLS support
97 UNSPEC_TLSLDM_NTPOFF
98 UNSPEC_TLS_LOAD
99
100 ; String Functions
101 UNSPEC_SRST
102 UNSPEC_MVST
103
104 ; Stack Smashing Protector
105 UNSPEC_SP_SET
106 UNSPEC_SP_TEST
107
108 ; Test Data Class (TDC)
109 UNSPEC_TDC_INSN
110
111 ; Population Count
112 UNSPEC_POPCNT
113 UNSPEC_COPYSIGN
114 ])
115
116 ;;
117 ;; UNSPEC_VOLATILE usage
118 ;;
119
120 (define_c_enum "unspecv" [
121 ; Blockage
122 UNSPECV_BLOCKAGE
123
124 ; TPF Support
125 UNSPECV_TPF_PROLOGUE
126 UNSPECV_TPF_EPILOGUE
127
128 ; Literal pool
129 UNSPECV_POOL
130 UNSPECV_POOL_SECTION
131 UNSPECV_POOL_ALIGN
132 UNSPECV_POOL_ENTRY
133 UNSPECV_MAIN_POOL
134
135 ; TLS support
136 UNSPECV_SET_TP
137
138 ; Atomic Support
139 UNSPECV_CAS
140 UNSPECV_ATOMIC_OP
141 ])
142
143 ;;
144 ;; Registers
145 ;;
146
147 ; Registers with special meaning
148
149 (define_constants
150 [
151 ; Sibling call register.
152 (SIBCALL_REGNUM 1)
153 ; Literal pool base register.
154 (BASE_REGNUM 13)
155 ; Return address register.
156 (RETURN_REGNUM 14)
157 ; Condition code register.
158 (CC_REGNUM 33)
159 ; Thread local storage pointer register.
160 (TP_REGNUM 36)
161 ])
162
163 ; Hardware register names
164
165 (define_constants
166 [
167 ; General purpose registers
168 (GPR0_REGNUM 0)
169 ; Floating point registers.
170 (FPR0_REGNUM 16)
171 (FPR2_REGNUM 18)
172 ])
173
174 ;;
175 ;; PFPO GPR0 argument format
176 ;;
177
178 (define_constants
179 [
180 ; PFPO operation type
181 (PFPO_CONVERT 0x1000000)
182 ; PFPO operand types
183 (PFPO_OP_TYPE_SF 0x5)
184 (PFPO_OP_TYPE_DF 0x6)
185 (PFPO_OP_TYPE_TF 0x7)
186 (PFPO_OP_TYPE_SD 0x8)
187 (PFPO_OP_TYPE_DD 0x9)
188 (PFPO_OP_TYPE_TD 0xa)
189 ; Bitposition of operand types
190 (PFPO_OP0_TYPE_SHIFT 16)
191 (PFPO_OP1_TYPE_SHIFT 8)
192 ])
193
194
195 ;; Instruction operand type as used in the Principles of Operation.
196 ;; Used to determine defaults for length and other attribute values.
197
198 (define_attr "op_type"
199 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR,SIL,RRS,RIS"
200 (const_string "NN"))
201
202 ;; Instruction type attribute used for scheduling.
203
204 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
205 cs,vs,store,sem,idiv,
206 imulhi,imulsi,imuldi,
207 branch,jsr,fsimptf,fsimpdf,fsimpsf,fhex,
208 floadtf,floaddf,floadsf,fstoredf,fstoresf,
209 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
210 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
211 fmadddf,fmaddsf,
212 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
213 itoftf, itofdf, itofsf, itofdd, itoftd,
214 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
215 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
216 ftoidfp, other"
217 (cond [(eq_attr "op_type" "NN") (const_string "other")
218 (eq_attr "op_type" "SS") (const_string "cs")]
219 (const_string "integer")))
220
221 ;; Another attribute used for scheduling purposes:
222 ;; agen: Instruction uses the address generation unit
223 ;; reg: Instruction does not use the agen unit
224
225 (define_attr "atype" "agen,reg"
226 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF,RRR")
227 (const_string "reg")
228 (const_string "agen")))
229
230 ;; Properties concerning Z10 execution grouping and value forwarding.
231 ;; z10_super: instruction is superscalar.
232 ;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
233 ;; z10_fwd: The instruction reads the value of an operand and stores it into a
234 ;; target register. It can forward this value to a second instruction that reads
235 ;; the same register if that second instruction is issued in the same group.
236 ;; z10_rec: The instruction is in the T pipeline and reads a register. If the
237 ;; instruction in the S pipe writes to the register, then the T instruction
238 ;; can immediately read the new value.
239 ;; z10_fr: union of Z10_fwd and z10_rec.
240 ;; z10_c: second operand of instruction is a register and read with complemented bits.
241 ;;
242 ;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
243
244
245 (define_attr "z10prop" "none,
246 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
247 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
248 z10_rec,
249 z10_fr, z10_fr_A3, z10_fr_E1,
250 z10_c"
251 (const_string "none"))
252
253 ;; Properties concerning Z196 decoding
254 ;; z196_alone: must group alone
255 ;; z196_end: ends a group
256 ;; z196_cracked: instruction is cracked or expanded
257 (define_attr "z196prop" "none,
258 z196_alone, z196_ends,
259 z196_cracked"
260 (const_string "none"))
261
262 (define_attr "mnemonic" "unknown" (const_string "unknown"))
263
264 ;; Length in bytes.
265
266 (define_attr "length" ""
267 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
268 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF,RRR") (const_int 4)]
269 (const_int 6)))
270
271
272 ;; Processor type. This attribute must exactly match the processor_type
273 ;; enumeration in s390.h. The current machine description does not
274 ;; distinguish between g5 and g6, but there are differences between the two
275 ;; CPUs could in theory be modeled.
276
277 (define_attr "cpu" "g5,g6,z900,z990,z9_109,z9_ec,z10,z196,zEC12"
278 (const (symbol_ref "s390_tune_attr")))
279
280 (define_attr "cpu_facility"
281 "standard,ieee,zarch,cpu_zarch,longdisp,extimm,dfp,z10,z196,zEC12"
282 (const_string "standard"))
283
284 (define_attr "enabled" ""
285 (cond [(eq_attr "cpu_facility" "standard")
286 (const_int 1)
287
288 (and (eq_attr "cpu_facility" "ieee")
289 (match_test "TARGET_CPU_IEEE_FLOAT"))
290 (const_int 1)
291
292 (and (eq_attr "cpu_facility" "zarch")
293 (match_test "TARGET_ZARCH"))
294 (const_int 1)
295
296 (and (eq_attr "cpu_facility" "longdisp")
297 (match_test "TARGET_LONG_DISPLACEMENT"))
298 (const_int 1)
299
300 (and (eq_attr "cpu_facility" "extimm")
301 (match_test "TARGET_EXTIMM"))
302 (const_int 1)
303
304 (and (eq_attr "cpu_facility" "dfp")
305 (match_test "TARGET_DFP"))
306 (const_int 1)
307
308 (and (eq_attr "cpu_facility" "cpu_zarch")
309 (match_test "TARGET_CPU_ZARCH"))
310 (const_int 1)
311
312 (and (eq_attr "cpu_facility" "z10")
313 (match_test "TARGET_Z10"))
314 (const_int 1)
315
316 (and (eq_attr "cpu_facility" "z196")
317 (match_test "TARGET_Z196"))
318 (const_int 1)
319
320 (and (eq_attr "cpu_facility" "zEC12")
321 (match_test "TARGET_ZEC12"))
322 (const_int 1)]
323 (const_int 0)))
324
325 ;; Pipeline description for z900. For lack of anything better,
326 ;; this description is also used for the g5 and g6.
327 (include "2064.md")
328
329 ;; Pipeline description for z990, z9-109 and z9-ec.
330 (include "2084.md")
331
332 ;; Pipeline description for z10
333 (include "2097.md")
334
335 ;; Pipeline description for z196
336 (include "2817.md")
337
338 ;; Pipeline description for zEC12
339 (include "2827.md")
340
341 ;; Predicates
342 (include "predicates.md")
343
344 ;; Constraint definitions
345 (include "constraints.md")
346
347 ;; Other includes
348 (include "tpf.md")
349
350 ;; Iterators
351
352 ;; These mode iterators allow floating point patterns to be generated from the
353 ;; same template.
354 (define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
355 (SD "TARGET_HARD_DFP")])
356 (define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
357 (define_mode_iterator FPALL [TF DF SF TD DD SD])
358 (define_mode_iterator BFP [TF DF SF])
359 (define_mode_iterator DFP [TD DD])
360 (define_mode_iterator DFP_ALL [TD DD SD])
361 (define_mode_iterator DSF [DF SF])
362 (define_mode_iterator SD_SF [SF SD])
363 (define_mode_iterator DD_DF [DF DD])
364 (define_mode_iterator TD_TF [TF TD])
365
366 ;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
367 ;; from the same template.
368 (define_mode_iterator GPR [(DI "TARGET_ZARCH") SI])
369 (define_mode_iterator DGPR [(TI "TARGET_ZARCH") DI SI])
370 (define_mode_iterator DSI [DI SI])
371 (define_mode_iterator TDI [TI DI])
372
373 ;; These mode iterators allow :P to be used for patterns that operate on
374 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
375 (define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
376
377 ;; These macros refer to the actual word_mode of the configuration.
378 ;; This is equal to Pmode except on 31-bit machines in zarch mode.
379 (define_mode_iterator DW [(TI "TARGET_ZARCH") (DI "!TARGET_ZARCH")])
380 (define_mode_iterator W [(DI "TARGET_ZARCH") (SI "!TARGET_ZARCH")])
381
382 ;; Used by the umul pattern to express modes having half the size.
383 (define_mode_attr DWH [(TI "DI") (DI "SI")])
384 (define_mode_attr dwh [(TI "di") (DI "si")])
385
386 ;; This mode iterator allows the QI and HI patterns to be defined from
387 ;; the same template.
388 (define_mode_iterator HQI [HI QI])
389
390 ;; This mode iterator allows the integer patterns to be defined from the
391 ;; same template.
392 (define_mode_iterator INT [(DI "TARGET_ZARCH") SI HI QI])
393 (define_mode_iterator INTALL [TI DI SI HI QI])
394 (define_mode_iterator DINT [(TI "TARGET_ZARCH") DI SI HI QI])
395
396 ;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
397 ;; the same template.
398 (define_code_iterator SHIFT [ashift lshiftrt])
399
400 ;; This iterator allow r[ox]sbg to be defined with the same template
401 (define_code_iterator IXOR [ior xor])
402
403 ;; This iterator and attribute allow to combine most atomic operations.
404 (define_code_iterator ATOMIC [and ior xor plus minus mult])
405 (define_code_iterator ATOMIC_Z196 [and ior xor plus])
406 (define_code_attr atomic [(and "and") (ior "ior") (xor "xor")
407 (plus "add") (minus "sub") (mult "nand")])
408 (define_code_attr noxa [(and "n") (ior "o") (xor "x") (plus "a")])
409
410 ;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
411 ;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
412 (define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
413
414 ;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
415 ;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
416 ;; SDmode.
417 (define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
418
419 ;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
420 ;; Likewise for "<RXe>".
421 (define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
422 (define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
423
424 ;; The decimal floating point variants of add, sub, div and mul support 3
425 ;; fp register operands. The following attributes allow to merge the bfp and
426 ;; dfp variants in a single insn definition.
427
428 ;; This attribute is used to set op_type accordingly.
429 (define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
430 (DD "RRR") (SD "RRR")])
431
432 ;; This attribute is used in the operand constraint list in order to have the
433 ;; first and the second operand match for bfp modes.
434 (define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
435
436 ;; This attribute is used in the operand list of the instruction to have an
437 ;; additional operand for the dfp instructions.
438 (define_mode_attr op1 [(TF "") (DF "") (SF "")
439 (TD "%1,") (DD "%1,") (SD "%1,")])
440
441
442 ;; This attribute is used in the operand constraint list
443 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
444 ;; TFmode values are represented by a fp register pair. Since the
445 ;; sign bit instructions only handle single source and target fp registers
446 ;; these instructions can only be used for TFmode values if the source and
447 ;; target operand uses the same fp register.
448 (define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
449
450 ;; In FP templates, "<Rf>" will expand to "f" in TFmode and "R" otherwise.
451 ;; This is used to disable the memory alternative in TFmode patterns.
452 (define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
453
454 ;; This attribute adds b for bfp instructions and t for dfp instructions and is used
455 ;; within instruction mnemonics.
456 (define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
457
458 ;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
459 ;; modes and to an empty string for bfp modes.
460 (define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
461
462 ;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
463 ;; and "0" in SImode. This allows to combine instructions of which the 31bit
464 ;; version only operates on one register.
465 (define_mode_attr d0 [(DI "d") (SI "0")])
466
467 ;; In combination with d0 this allows to combine instructions of which the 31bit
468 ;; version only operates on one register. The DImode version needs an additional
469 ;; register for the assembler output.
470 (define_mode_attr 1 [(DI "%1,") (SI "")])
471
472 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
473 ;; 'ashift' and "srdl" in 'lshiftrt'.
474 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
475
476 ;; In SHIFT templates, this attribute holds the correct standard name for the
477 ;; pattern itself and the corresponding function calls.
478 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
479
480 ;; This attribute handles differences in the instruction 'type' and will result
481 ;; in "RRE" for DImode and "RR" for SImode.
482 (define_mode_attr E [(DI "E") (SI "")])
483
484 ;; This attribute handles differences in the instruction 'type' and makes RX<Y>
485 ;; to result in "RXY" for DImode and "RX" for SImode.
486 (define_mode_attr Y [(DI "Y") (SI "")])
487
488 ;; This attribute handles differences in the instruction 'type' and will result
489 ;; in "RSE" for TImode and "RS" for DImode.
490 (define_mode_attr TE [(TI "E") (DI "")])
491
492 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
493 ;; and "lcr" in SImode.
494 (define_mode_attr g [(DI "g") (SI "")])
495
496 ;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
497 ;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
498 ;; were enhanced with long displacements whereas 31bit instructions got a ..y
499 ;; variant for long displacements.
500 (define_mode_attr y [(DI "g") (SI "y")])
501
502 ;; In DW templates, a string like "cds<g>" will expand to "cdsg" in TImode
503 ;; and "cds" in DImode.
504 (define_mode_attr tg [(TI "g") (DI "")])
505
506 ;; In TDI templates, a string like "c<d>sg".
507 (define_mode_attr td [(TI "d") (DI "")])
508
509 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
510 ;; and "cfdbr" in SImode.
511 (define_mode_attr gf [(DI "g") (SI "f")])
512
513 ;; In GPR templates, a string like sll<gk> will expand to sllg for DI
514 ;; and sllk for SI. This way it is possible to merge the new z196 SI
515 ;; 3 operands shift instructions into the existing patterns.
516 (define_mode_attr gk [(DI "g") (SI "k")])
517
518 ;; ICM mask required to load MODE value into the lowest subreg
519 ;; of a SImode register.
520 (define_mode_attr icm_lo [(HI "3") (QI "1")])
521
522 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
523 ;; HImode and "llgc" in QImode.
524 (define_mode_attr hc [(HI "h") (QI "c")])
525
526 ;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
527 ;; in SImode.
528 (define_mode_attr DBL [(DI "TI") (SI "DI")])
529
530 ;; This attribute expands to DF for TFmode and to DD for TDmode . It is
531 ;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
532 (define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
533
534 ;; Maximum unsigned integer that fits in MODE.
535 (define_mode_attr max_uint [(HI "65535") (QI "255")])
536
537 ;; Start and end field computations for RISBG et al.
538 (define_mode_attr bfstart [(DI "s") (SI "t")])
539 (define_mode_attr bfend [(DI "e") (SI "f")])
540
541 ;; In place of GET_MODE_BITSIZE (<MODE>mode)
542 (define_mode_attr bitsize [(DI "64") (SI "32") (HI "16") (QI "8")])
543
544 ;;
545 ;;- Compare instructions.
546 ;;
547
548 ; Test-under-Mask instructions
549
550 (define_insn "*tmqi_mem"
551 [(set (reg CC_REGNUM)
552 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
553 (match_operand:QI 1 "immediate_operand" "n,n"))
554 (match_operand:QI 2 "immediate_operand" "n,n")))]
555 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
556 "@
557 tm\t%S0,%b1
558 tmy\t%S0,%b1"
559 [(set_attr "op_type" "SI,SIY")
560 (set_attr "z10prop" "z10_super,z10_super")])
561
562 (define_insn "*tmdi_reg"
563 [(set (reg CC_REGNUM)
564 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
565 (match_operand:DI 1 "immediate_operand"
566 "N0HD0,N1HD0,N2HD0,N3HD0"))
567 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
568 "TARGET_ZARCH
569 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
570 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
571 "@
572 tmhh\t%0,%i1
573 tmhl\t%0,%i1
574 tmlh\t%0,%i1
575 tmll\t%0,%i1"
576 [(set_attr "op_type" "RI")
577 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
578
579 (define_insn "*tmsi_reg"
580 [(set (reg CC_REGNUM)
581 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
582 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
583 (match_operand:SI 2 "immediate_operand" "n,n")))]
584 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
585 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
586 "@
587 tmh\t%0,%i1
588 tml\t%0,%i1"
589 [(set_attr "op_type" "RI")
590 (set_attr "z10prop" "z10_super,z10_super")])
591
592 (define_insn "*tm<mode>_full"
593 [(set (reg CC_REGNUM)
594 (compare (match_operand:HQI 0 "register_operand" "d")
595 (match_operand:HQI 1 "immediate_operand" "n")))]
596 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
597 "tml\t%0,<max_uint>"
598 [(set_attr "op_type" "RI")
599 (set_attr "z10prop" "z10_super")])
600
601
602 ;
603 ; Load-and-Test instructions
604 ;
605
606 ; tst(di|si) instruction pattern(s).
607
608 (define_insn "*tstdi_sign"
609 [(set (reg CC_REGNUM)
610 (compare
611 (ashiftrt:DI
612 (ashift:DI
613 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,RT") 0)
614 (const_int 32)) (const_int 32))
615 (match_operand:DI 1 "const0_operand" "")))
616 (set (match_operand:DI 2 "register_operand" "=d,d")
617 (sign_extend:DI (match_dup 0)))]
618 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH"
619 "ltgfr\t%2,%0
620 ltgf\t%2,%0"
621 [(set_attr "op_type" "RRE,RXY")
622 (set_attr "cpu_facility" "*,z10")
623 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
624
625 ; ltr, lt, ltgr, ltg
626 (define_insn "*tst<mode>_extimm"
627 [(set (reg CC_REGNUM)
628 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
629 (match_operand:GPR 1 "const0_operand" "")))
630 (set (match_operand:GPR 2 "register_operand" "=d,d")
631 (match_dup 0))]
632 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
633 "@
634 lt<g>r\t%2,%0
635 lt<g>\t%2,%0"
636 [(set_attr "op_type" "RR<E>,RXY")
637 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
638
639 ; ltr, lt, ltgr, ltg
640 (define_insn "*tst<mode>_cconly_extimm"
641 [(set (reg CC_REGNUM)
642 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
643 (match_operand:GPR 1 "const0_operand" "")))
644 (clobber (match_scratch:GPR 2 "=X,d"))]
645 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
646 "@
647 lt<g>r\t%0,%0
648 lt<g>\t%2,%0"
649 [(set_attr "op_type" "RR<E>,RXY")
650 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
651
652 (define_insn "*tstdi"
653 [(set (reg CC_REGNUM)
654 (compare (match_operand:DI 0 "register_operand" "d")
655 (match_operand:DI 1 "const0_operand" "")))
656 (set (match_operand:DI 2 "register_operand" "=d")
657 (match_dup 0))]
658 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH && !TARGET_EXTIMM"
659 "ltgr\t%2,%0"
660 [(set_attr "op_type" "RRE")
661 (set_attr "z10prop" "z10_fr_E1")])
662
663 (define_insn "*tstsi"
664 [(set (reg CC_REGNUM)
665 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
666 (match_operand:SI 1 "const0_operand" "")))
667 (set (match_operand:SI 2 "register_operand" "=d,d,d")
668 (match_dup 0))]
669 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
670 "@
671 ltr\t%2,%0
672 icm\t%2,15,%S0
673 icmy\t%2,15,%S0"
674 [(set_attr "op_type" "RR,RS,RSY")
675 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
676
677 (define_insn "*tstsi_cconly"
678 [(set (reg CC_REGNUM)
679 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
680 (match_operand:SI 1 "const0_operand" "")))
681 (clobber (match_scratch:SI 2 "=X,d,d"))]
682 "s390_match_ccmode(insn, CCSmode)"
683 "@
684 ltr\t%0,%0
685 icm\t%2,15,%S0
686 icmy\t%2,15,%S0"
687 [(set_attr "op_type" "RR,RS,RSY")
688 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
689
690 (define_insn "*tstdi_cconly_31"
691 [(set (reg CC_REGNUM)
692 (compare (match_operand:DI 0 "register_operand" "d")
693 (match_operand:DI 1 "const0_operand" "")))]
694 "s390_match_ccmode(insn, CCSmode) && !TARGET_ZARCH"
695 "srda\t%0,0"
696 [(set_attr "op_type" "RS")
697 (set_attr "atype" "reg")])
698
699 ; ltr, ltgr
700 (define_insn "*tst<mode>_cconly2"
701 [(set (reg CC_REGNUM)
702 (compare (match_operand:GPR 0 "register_operand" "d")
703 (match_operand:GPR 1 "const0_operand" "")))]
704 "s390_match_ccmode(insn, CCSmode)"
705 "lt<g>r\t%0,%0"
706 [(set_attr "op_type" "RR<E>")
707 (set_attr "z10prop" "z10_fr_E1")])
708
709 ; tst(hi|qi) instruction pattern(s).
710
711 (define_insn "*tst<mode>CCT"
712 [(set (reg CC_REGNUM)
713 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
714 (match_operand:HQI 1 "const0_operand" "")))
715 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
716 (match_dup 0))]
717 "s390_match_ccmode(insn, CCTmode)"
718 "@
719 icm\t%2,<icm_lo>,%S0
720 icmy\t%2,<icm_lo>,%S0
721 tml\t%0,<max_uint>"
722 [(set_attr "op_type" "RS,RSY,RI")
723 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
724
725 (define_insn "*tsthiCCT_cconly"
726 [(set (reg CC_REGNUM)
727 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
728 (match_operand:HI 1 "const0_operand" "")))
729 (clobber (match_scratch:HI 2 "=d,d,X"))]
730 "s390_match_ccmode(insn, CCTmode)"
731 "@
732 icm\t%2,3,%S0
733 icmy\t%2,3,%S0
734 tml\t%0,65535"
735 [(set_attr "op_type" "RS,RSY,RI")
736 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
737
738 (define_insn "*tstqiCCT_cconly"
739 [(set (reg CC_REGNUM)
740 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
741 (match_operand:QI 1 "const0_operand" "")))]
742 "s390_match_ccmode(insn, CCTmode)"
743 "@
744 cli\t%S0,0
745 cliy\t%S0,0
746 tml\t%0,255"
747 [(set_attr "op_type" "SI,SIY,RI")
748 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
749
750 (define_insn "*tst<mode>"
751 [(set (reg CC_REGNUM)
752 (compare (match_operand:HQI 0 "s_operand" "Q,S")
753 (match_operand:HQI 1 "const0_operand" "")))
754 (set (match_operand:HQI 2 "register_operand" "=d,d")
755 (match_dup 0))]
756 "s390_match_ccmode(insn, CCSmode)"
757 "@
758 icm\t%2,<icm_lo>,%S0
759 icmy\t%2,<icm_lo>,%S0"
760 [(set_attr "op_type" "RS,RSY")
761 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
762
763 (define_insn "*tst<mode>_cconly"
764 [(set (reg CC_REGNUM)
765 (compare (match_operand:HQI 0 "s_operand" "Q,S")
766 (match_operand:HQI 1 "const0_operand" "")))
767 (clobber (match_scratch:HQI 2 "=d,d"))]
768 "s390_match_ccmode(insn, CCSmode)"
769 "@
770 icm\t%2,<icm_lo>,%S0
771 icmy\t%2,<icm_lo>,%S0"
772 [(set_attr "op_type" "RS,RSY")
773 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
774
775
776 ; Compare (equality) instructions
777
778 (define_insn "*cmpdi_cct"
779 [(set (reg CC_REGNUM)
780 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
781 (match_operand:DI 1 "general_operand" "d,K,Os,RT,BQ")))]
782 "s390_match_ccmode (insn, CCTmode) && TARGET_ZARCH"
783 "@
784 cgr\t%0,%1
785 cghi\t%0,%h1
786 cgfi\t%0,%1
787 cg\t%0,%1
788 #"
789 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
790 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
791
792 (define_insn "*cmpsi_cct"
793 [(set (reg CC_REGNUM)
794 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
795 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
796 "s390_match_ccmode (insn, CCTmode)"
797 "@
798 cr\t%0,%1
799 chi\t%0,%h1
800 cfi\t%0,%1
801 c\t%0,%1
802 cy\t%0,%1
803 #"
804 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
805 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*")])
806
807 ; Compare (signed) instructions
808
809 (define_insn "*cmpdi_ccs_sign"
810 [(set (reg CC_REGNUM)
811 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
812 "d,RT,b"))
813 (match_operand:DI 0 "register_operand" "d, d,d")))]
814 "s390_match_ccmode(insn, CCSRmode) && TARGET_ZARCH"
815 "@
816 cgfr\t%0,%1
817 cgf\t%0,%1
818 cgfrl\t%0,%1"
819 [(set_attr "op_type" "RRE,RXY,RIL")
820 (set_attr "z10prop" "z10_c,*,*")
821 (set_attr "type" "*,*,larl")])
822
823
824
825 (define_insn "*cmpsi_ccs_sign"
826 [(set (reg CC_REGNUM)
827 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
828 (match_operand:SI 0 "register_operand" "d,d,d")))]
829 "s390_match_ccmode(insn, CCSRmode)"
830 "@
831 ch\t%0,%1
832 chy\t%0,%1
833 chrl\t%0,%1"
834 [(set_attr "op_type" "RX,RXY,RIL")
835 (set_attr "cpu_facility" "*,*,z10")
836 (set_attr "type" "*,*,larl")
837 (set_attr "z196prop" "z196_cracked,z196_cracked,z196_cracked")])
838
839 (define_insn "*cmphi_ccs_z10"
840 [(set (reg CC_REGNUM)
841 (compare (match_operand:HI 0 "s_operand" "Q")
842 (match_operand:HI 1 "immediate_operand" "K")))]
843 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
844 "chhsi\t%0,%1"
845 [(set_attr "op_type" "SIL")
846 (set_attr "z196prop" "z196_cracked")])
847
848 (define_insn "*cmpdi_ccs_signhi_rl"
849 [(set (reg CC_REGNUM)
850 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT,b"))
851 (match_operand:GPR 0 "register_operand" "d,d")))]
852 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
853 "@
854 cgh\t%0,%1
855 cghrl\t%0,%1"
856 [(set_attr "op_type" "RXY,RIL")
857 (set_attr "type" "*,larl")])
858
859 ; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
860 (define_insn "*cmp<mode>_ccs"
861 [(set (reg CC_REGNUM)
862 (compare (match_operand:GPR 0 "nonimmediate_operand"
863 "d,d,Q, d,d,d,d")
864 (match_operand:GPR 1 "general_operand"
865 "d,K,K,Os,R,T,b")))]
866 "s390_match_ccmode(insn, CCSmode)"
867 "@
868 c<g>r\t%0,%1
869 c<g>hi\t%0,%h1
870 c<g>hsi\t%0,%h1
871 c<g>fi\t%0,%1
872 c<g>\t%0,%1
873 c<y>\t%0,%1
874 c<g>rl\t%0,%1"
875 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
876 (set_attr "cpu_facility" "*,*,z10,extimm,*,*,z10")
877 (set_attr "type" "*,*,*,*,*,*,larl")
878 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
879
880
881 ; Compare (unsigned) instructions
882
883 (define_insn "*cmpsi_ccu_zerohi_rlsi"
884 [(set (reg CC_REGNUM)
885 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
886 "larl_operand" "X")))
887 (match_operand:SI 0 "register_operand" "d")))]
888 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
889 "clhrl\t%0,%1"
890 [(set_attr "op_type" "RIL")
891 (set_attr "type" "larl")
892 (set_attr "z10prop" "z10_super")])
893
894 ; clhrl, clghrl
895 (define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
896 [(set (reg CC_REGNUM)
897 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
898 "larl_operand" "X")))
899 (match_operand:GPR 0 "register_operand" "d")))]
900 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
901 "cl<g>hrl\t%0,%1"
902 [(set_attr "op_type" "RIL")
903 (set_attr "type" "larl")
904 (set_attr "z10prop" "z10_super")])
905
906 (define_insn "*cmpdi_ccu_zero"
907 [(set (reg CC_REGNUM)
908 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
909 "d,RT,b"))
910 (match_operand:DI 0 "register_operand" "d, d,d")))]
911 "s390_match_ccmode (insn, CCURmode) && TARGET_ZARCH"
912 "@
913 clgfr\t%0,%1
914 clgf\t%0,%1
915 clgfrl\t%0,%1"
916 [(set_attr "op_type" "RRE,RXY,RIL")
917 (set_attr "cpu_facility" "*,*,z10")
918 (set_attr "type" "*,*,larl")
919 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
920
921 (define_insn "*cmpdi_ccu"
922 [(set (reg CC_REGNUM)
923 (compare (match_operand:DI 0 "nonimmediate_operand"
924 "d, d,d,Q, d, Q,BQ")
925 (match_operand:DI 1 "general_operand"
926 "d,Op,b,D,RT,BQ,Q")))]
927 "s390_match_ccmode (insn, CCUmode) && TARGET_ZARCH"
928 "@
929 clgr\t%0,%1
930 clgfi\t%0,%1
931 clgrl\t%0,%1
932 clghsi\t%0,%x1
933 clg\t%0,%1
934 #
935 #"
936 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
937 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
938 (set_attr "type" "*,*,larl,*,*,*,*")
939 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
940
941 (define_insn "*cmpsi_ccu"
942 [(set (reg CC_REGNUM)
943 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
944 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
945 "s390_match_ccmode (insn, CCUmode)"
946 "@
947 clr\t%0,%1
948 clfi\t%0,%o1
949 clrl\t%0,%1
950 clfhsi\t%0,%x1
951 cl\t%0,%1
952 cly\t%0,%1
953 #
954 #"
955 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
956 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*,*")
957 (set_attr "type" "*,*,larl,*,*,*,*,*")
958 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
959
960 (define_insn "*cmphi_ccu"
961 [(set (reg CC_REGNUM)
962 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
963 (match_operand:HI 1 "general_operand" "Q,S,D,BQ,Q")))]
964 "s390_match_ccmode (insn, CCUmode)
965 && !register_operand (operands[1], HImode)"
966 "@
967 clm\t%0,3,%S1
968 clmy\t%0,3,%S1
969 clhhsi\t%0,%1
970 #
971 #"
972 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
973 (set_attr "cpu_facility" "*,*,z10,*,*")
974 (set_attr "z10prop" "*,*,z10_super,*,*")])
975
976 (define_insn "*cmpqi_ccu"
977 [(set (reg CC_REGNUM)
978 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
979 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
980 "s390_match_ccmode (insn, CCUmode)
981 && !register_operand (operands[1], QImode)"
982 "@
983 clm\t%0,1,%S1
984 clmy\t%0,1,%S1
985 cli\t%S0,%b1
986 cliy\t%S0,%b1
987 #
988 #"
989 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
990 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
991
992
993 ; Block compare (CLC) instruction patterns.
994
995 (define_insn "*clc"
996 [(set (reg CC_REGNUM)
997 (compare (match_operand:BLK 0 "memory_operand" "Q")
998 (match_operand:BLK 1 "memory_operand" "Q")))
999 (use (match_operand 2 "const_int_operand" "n"))]
1000 "s390_match_ccmode (insn, CCUmode)
1001 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1002 "clc\t%O0(%2,%R0),%S1"
1003 [(set_attr "op_type" "SS")])
1004
1005 (define_split
1006 [(set (reg CC_REGNUM)
1007 (compare (match_operand 0 "memory_operand" "")
1008 (match_operand 1 "memory_operand" "")))]
1009 "reload_completed
1010 && s390_match_ccmode (insn, CCUmode)
1011 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1012 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1013 [(parallel
1014 [(set (match_dup 0) (match_dup 1))
1015 (use (match_dup 2))])]
1016 {
1017 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1018 operands[0] = adjust_address (operands[0], BLKmode, 0);
1019 operands[1] = adjust_address (operands[1], BLKmode, 0);
1020
1021 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
1022 operands[0], operands[1]);
1023 operands[0] = SET_DEST (PATTERN (curr_insn));
1024 })
1025
1026
1027 ; (TF|DF|SF|TD|DD|SD) instructions
1028
1029 ; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
1030 (define_insn "*cmp<mode>_ccs_0"
1031 [(set (reg CC_REGNUM)
1032 (compare (match_operand:FP 0 "register_operand" "f")
1033 (match_operand:FP 1 "const0_operand" "")))]
1034 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1035 "lt<xde><bt>r\t%0,%0"
1036 [(set_attr "op_type" "RRE")
1037 (set_attr "type" "fsimp<mode>")])
1038
1039 ; cxtr, cxbr, cdtr, cdbr, cebr, cdb, ceb
1040 (define_insn "*cmp<mode>_ccs"
1041 [(set (reg CC_REGNUM)
1042 (compare (match_operand:FP 0 "register_operand" "f,f")
1043 (match_operand:FP 1 "general_operand" "f,<Rf>")))]
1044 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1045 "@
1046 c<xde><bt>r\t%0,%1
1047 c<xde>b\t%0,%1"
1048 [(set_attr "op_type" "RRE,RXE")
1049 (set_attr "type" "fsimp<mode>")])
1050
1051
1052 ; Compare and Branch instructions
1053
1054 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1055 ; The following instructions do a complementary access of their second
1056 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1057 (define_insn "*cmp_and_br_signed_<mode>"
1058 [(set (pc)
1059 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1060 [(match_operand:GPR 1 "register_operand" "d,d")
1061 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1062 (label_ref (match_operand 3 "" ""))
1063 (pc)))
1064 (clobber (reg:CC CC_REGNUM))]
1065 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1066 {
1067 if (get_attr_length (insn) == 6)
1068 return which_alternative ?
1069 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1070 else
1071 return which_alternative ?
1072 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1073 }
1074 [(set_attr "op_type" "RIE")
1075 (set_attr "type" "branch")
1076 (set_attr "z10prop" "z10_super_c,z10_super")
1077 (set (attr "length")
1078 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1079 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1080 ; 10 byte for cgr/jg
1081
1082 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1083 ; The following instructions do a complementary access of their second
1084 ; operand (z10 only): clrj, clgrj, clr, clgr
1085 (define_insn "*cmp_and_br_unsigned_<mode>"
1086 [(set (pc)
1087 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1088 [(match_operand:GPR 1 "register_operand" "d,d")
1089 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1090 (label_ref (match_operand 3 "" ""))
1091 (pc)))
1092 (clobber (reg:CC CC_REGNUM))]
1093 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1094 {
1095 if (get_attr_length (insn) == 6)
1096 return which_alternative ?
1097 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1098 else
1099 return which_alternative ?
1100 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1101 }
1102 [(set_attr "op_type" "RIE")
1103 (set_attr "type" "branch")
1104 (set_attr "z10prop" "z10_super_c,z10_super")
1105 (set (attr "length")
1106 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1107 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1108 ; 10 byte for clgr/jg
1109
1110 ; And now the same two patterns as above but with a negated CC mask.
1111
1112 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1113 ; The following instructions do a complementary access of their second
1114 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1115 (define_insn "*icmp_and_br_signed_<mode>"
1116 [(set (pc)
1117 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1118 [(match_operand:GPR 1 "register_operand" "d,d")
1119 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1120 (pc)
1121 (label_ref (match_operand 3 "" ""))))
1122 (clobber (reg:CC CC_REGNUM))]
1123 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1124 {
1125 if (get_attr_length (insn) == 6)
1126 return which_alternative ?
1127 "c<g>ij%D0\t%1,%c2,%l3" : "c<g>rj%D0\t%1,%2,%l3";
1128 else
1129 return which_alternative ?
1130 "c<g>fi\t%1,%c2\;jg%D0\t%l3" : "c<g>r\t%1,%2\;jg%D0\t%l3";
1131 }
1132 [(set_attr "op_type" "RIE")
1133 (set_attr "type" "branch")
1134 (set_attr "z10prop" "z10_super_c,z10_super")
1135 (set (attr "length")
1136 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1137 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1138 ; 10 byte for cgr/jg
1139
1140 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1141 ; The following instructions do a complementary access of their second
1142 ; operand (z10 only): clrj, clgrj, clr, clgr
1143 (define_insn "*icmp_and_br_unsigned_<mode>"
1144 [(set (pc)
1145 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1146 [(match_operand:GPR 1 "register_operand" "d,d")
1147 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1148 (pc)
1149 (label_ref (match_operand 3 "" ""))))
1150 (clobber (reg:CC CC_REGNUM))]
1151 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1152 {
1153 if (get_attr_length (insn) == 6)
1154 return which_alternative ?
1155 "cl<g>ij%D0\t%1,%b2,%l3" : "cl<g>rj%D0\t%1,%2,%l3";
1156 else
1157 return which_alternative ?
1158 "cl<g>fi\t%1,%b2\;jg%D0\t%l3" : "cl<g>r\t%1,%2\;jg%D0\t%l3";
1159 }
1160 [(set_attr "op_type" "RIE")
1161 (set_attr "type" "branch")
1162 (set_attr "z10prop" "z10_super_c,z10_super")
1163 (set (attr "length")
1164 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1165 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1166 ; 10 byte for clgr/jg
1167
1168 ;;
1169 ;;- Move instructions.
1170 ;;
1171
1172 ;
1173 ; movti instruction pattern(s).
1174 ;
1175
1176 (define_insn "movti"
1177 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o")
1178 (match_operand:TI 1 "general_operand" "QS,d,dPRT,d"))]
1179 "TARGET_ZARCH"
1180 "@
1181 lmg\t%0,%N0,%S1
1182 stmg\t%1,%N1,%S0
1183 #
1184 #"
1185 [(set_attr "op_type" "RSY,RSY,*,*")
1186 (set_attr "type" "lm,stm,*,*")])
1187
1188 (define_split
1189 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1190 (match_operand:TI 1 "general_operand" ""))]
1191 "TARGET_ZARCH && reload_completed
1192 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
1193 [(set (match_dup 2) (match_dup 4))
1194 (set (match_dup 3) (match_dup 5))]
1195 {
1196 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1197 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1198 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1199 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1200 })
1201
1202 (define_split
1203 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1204 (match_operand:TI 1 "general_operand" ""))]
1205 "TARGET_ZARCH && reload_completed
1206 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1207 [(set (match_dup 2) (match_dup 4))
1208 (set (match_dup 3) (match_dup 5))]
1209 {
1210 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1211 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1212 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1213 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1214 })
1215
1216 (define_split
1217 [(set (match_operand:TI 0 "register_operand" "")
1218 (match_operand:TI 1 "memory_operand" ""))]
1219 "TARGET_ZARCH && reload_completed
1220 && !s_operand (operands[1], VOIDmode)"
1221 [(set (match_dup 0) (match_dup 1))]
1222 {
1223 rtx addr = operand_subword (operands[0], 1, 0, TImode);
1224 addr = gen_lowpart (Pmode, addr);
1225 s390_load_address (addr, XEXP (operands[1], 0));
1226 operands[1] = replace_equiv_address (operands[1], addr);
1227 })
1228
1229
1230 ;
1231 ; Patterns used for secondary reloads
1232 ;
1233
1234 ; z10 provides move instructions accepting larl memory operands.
1235 ; Unfortunately there is no such variant for QI, TI and FP mode moves.
1236 ; These patterns are also used for unaligned SI and DI accesses.
1237
1238 (define_expand "reload<INTALL:mode><P:mode>_tomem_z10"
1239 [(parallel [(match_operand:INTALL 0 "memory_operand" "")
1240 (match_operand:INTALL 1 "register_operand" "=d")
1241 (match_operand:P 2 "register_operand" "=&a")])]
1242 "TARGET_Z10"
1243 {
1244 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1245 DONE;
1246 })
1247
1248 (define_expand "reload<INTALL:mode><P:mode>_toreg_z10"
1249 [(parallel [(match_operand:INTALL 0 "register_operand" "=d")
1250 (match_operand:INTALL 1 "memory_operand" "")
1251 (match_operand:P 2 "register_operand" "=a")])]
1252 "TARGET_Z10"
1253 {
1254 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1255 DONE;
1256 })
1257
1258 (define_expand "reload<FPALL:mode><P:mode>_tomem_z10"
1259 [(parallel [(match_operand:FPALL 0 "memory_operand" "")
1260 (match_operand:FPALL 1 "register_operand" "=d")
1261 (match_operand:P 2 "register_operand" "=&a")])]
1262 "TARGET_Z10"
1263 {
1264 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1265 DONE;
1266 })
1267
1268 (define_expand "reload<FPALL:mode><P:mode>_toreg_z10"
1269 [(parallel [(match_operand:FPALL 0 "register_operand" "=d")
1270 (match_operand:FPALL 1 "memory_operand" "")
1271 (match_operand:P 2 "register_operand" "=a")])]
1272 "TARGET_Z10"
1273 {
1274 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1275 DONE;
1276 })
1277
1278 (define_expand "reload<P:mode>_larl_odd_addend_z10"
1279 [(parallel [(match_operand:P 0 "register_operand" "=d")
1280 (match_operand:P 1 "larl_operand" "")
1281 (match_operand:P 2 "register_operand" "=a")])]
1282 "TARGET_Z10"
1283 {
1284 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1285 DONE;
1286 })
1287
1288 ; Handles loading a PLUS (load address) expression
1289
1290 (define_expand "reload<mode>_plus"
1291 [(parallel [(match_operand:P 0 "register_operand" "=a")
1292 (match_operand:P 1 "s390_plus_operand" "")
1293 (match_operand:P 2 "register_operand" "=&a")])]
1294 ""
1295 {
1296 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1297 DONE;
1298 })
1299
1300 ; Handles assessing a non-offsetable memory address
1301
1302 (define_expand "reload<mode>_nonoffmem_in"
1303 [(parallel [(match_operand 0 "register_operand" "")
1304 (match_operand 1 "" "")
1305 (match_operand:P 2 "register_operand" "=&a")])]
1306 ""
1307 {
1308 gcc_assert (MEM_P (operands[1]));
1309 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1310 operands[1] = replace_equiv_address (operands[1], operands[2]);
1311 emit_move_insn (operands[0], operands[1]);
1312 DONE;
1313 })
1314
1315 (define_expand "reload<mode>_nonoffmem_out"
1316 [(parallel [(match_operand 0 "" "")
1317 (match_operand 1 "register_operand" "")
1318 (match_operand:P 2 "register_operand" "=&a")])]
1319 ""
1320 {
1321 gcc_assert (MEM_P (operands[0]));
1322 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1323 operands[0] = replace_equiv_address (operands[0], operands[2]);
1324 emit_move_insn (operands[0], operands[1]);
1325 DONE;
1326 })
1327
1328 (define_expand "reload<mode>_PIC_addr"
1329 [(parallel [(match_operand 0 "register_operand" "=d")
1330 (match_operand 1 "larl_operand" "")
1331 (match_operand:P 2 "register_operand" "=a")])]
1332 ""
1333 {
1334 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1335 emit_move_insn (operands[0], new_rtx);
1336 })
1337
1338 ;
1339 ; movdi instruction pattern(s).
1340 ;
1341
1342 (define_expand "movdi"
1343 [(set (match_operand:DI 0 "general_operand" "")
1344 (match_operand:DI 1 "general_operand" ""))]
1345 ""
1346 {
1347 /* Handle symbolic constants. */
1348 if (TARGET_64BIT
1349 && (SYMBOLIC_CONST (operands[1])
1350 || (GET_CODE (operands[1]) == PLUS
1351 && XEXP (operands[1], 0) == pic_offset_table_rtx
1352 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
1353 emit_symbolic_move (operands);
1354 })
1355
1356 (define_insn "*movdi_larl"
1357 [(set (match_operand:DI 0 "register_operand" "=d")
1358 (match_operand:DI 1 "larl_operand" "X"))]
1359 "TARGET_64BIT
1360 && !FP_REG_P (operands[0])"
1361 "larl\t%0,%1"
1362 [(set_attr "op_type" "RIL")
1363 (set_attr "type" "larl")
1364 (set_attr "z10prop" "z10_super_A1")])
1365
1366 (define_insn "*movdi_64"
1367 [(set (match_operand:DI 0 "nonimmediate_operand"
1368 "=d,d,d,d,d,d,d,d,f,d,d,d,d,d,
1369 RT,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t")
1370 (match_operand:DI 1 "general_operand"
1371 "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,RT,
1372 d,*f,R,T,*f,*f,d,K,t,d,t,Q"))]
1373 "TARGET_ZARCH"
1374 "@
1375 lghi\t%0,%h1
1376 llihh\t%0,%i1
1377 llihl\t%0,%i1
1378 llilh\t%0,%i1
1379 llill\t%0,%i1
1380 lgfi\t%0,%1
1381 llihf\t%0,%k1
1382 llilf\t%0,%k1
1383 ldgr\t%0,%1
1384 lgdr\t%0,%1
1385 lay\t%0,%a1
1386 lgrl\t%0,%1
1387 lgr\t%0,%1
1388 lg\t%0,%1
1389 stg\t%1,%0
1390 ldr\t%0,%1
1391 ld\t%0,%1
1392 ldy\t%0,%1
1393 std\t%1,%0
1394 stdy\t%1,%0
1395 stgrl\t%1,%0
1396 mvghi\t%0,%1
1397 #
1398 #
1399 stam\t%1,%N1,%S0
1400 lam\t%0,%N0,%S1"
1401 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
1402 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS")
1403 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
1404 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,
1405 *,*")
1406 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
1407 z10,*,*,*,*,*,longdisp,*,longdisp,
1408 z10,z10,*,*,*,*")
1409 (set_attr "z10prop" "z10_fwd_A1,
1410 z10_fwd_E1,
1411 z10_fwd_E1,
1412 z10_fwd_E1,
1413 z10_fwd_E1,
1414 z10_fwd_A1,
1415 z10_fwd_E1,
1416 z10_fwd_E1,
1417 *,
1418 *,
1419 z10_fwd_A1,
1420 z10_fwd_A3,
1421 z10_fr_E1,
1422 z10_fwd_A3,
1423 z10_rec,
1424 *,
1425 *,
1426 *,
1427 *,
1428 *,
1429 z10_rec,
1430 z10_super,
1431 *,
1432 *,
1433 *,
1434 *")
1435 ])
1436
1437 (define_split
1438 [(set (match_operand:DI 0 "register_operand" "")
1439 (match_operand:DI 1 "register_operand" ""))]
1440 "TARGET_ZARCH && ACCESS_REG_P (operands[1])"
1441 [(set (match_dup 2) (match_dup 3))
1442 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1443 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1444 "operands[2] = gen_lowpart (SImode, operands[0]);
1445 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1446
1447 (define_split
1448 [(set (match_operand:DI 0 "register_operand" "")
1449 (match_operand:DI 1 "register_operand" ""))]
1450 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
1451 && dead_or_set_p (insn, operands[1])"
1452 [(set (match_dup 3) (match_dup 2))
1453 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1454 (set (match_dup 4) (match_dup 2))]
1455 "operands[2] = gen_lowpart (SImode, operands[1]);
1456 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1457
1458 (define_split
1459 [(set (match_operand:DI 0 "register_operand" "")
1460 (match_operand:DI 1 "register_operand" ""))]
1461 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
1462 && !dead_or_set_p (insn, operands[1])"
1463 [(set (match_dup 3) (match_dup 2))
1464 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1465 (set (match_dup 4) (match_dup 2))
1466 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1467 "operands[2] = gen_lowpart (SImode, operands[1]);
1468 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1469
1470 (define_insn "*movdi_31"
1471 [(set (match_operand:DI 0 "nonimmediate_operand"
1472 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!R,!T,d")
1473 (match_operand:DI 1 "general_operand"
1474 " Q,S,d,d,dPRT,d, *f, R, T,*f,*f,b"))]
1475 "!TARGET_ZARCH"
1476 "@
1477 lm\t%0,%N0,%S1
1478 lmy\t%0,%N0,%S1
1479 stm\t%1,%N1,%S0
1480 stmy\t%1,%N1,%S0
1481 #
1482 #
1483 ldr\t%0,%1
1484 ld\t%0,%1
1485 ldy\t%0,%1
1486 std\t%1,%0
1487 stdy\t%1,%0
1488 #"
1489 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1490 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
1491 (set_attr "cpu_facility" "*,*,*,*,*,*,*,*,*,*,*,z10")])
1492
1493 ; For a load from a symbol ref we can use one of the target registers
1494 ; together with larl to load the address.
1495 (define_split
1496 [(set (match_operand:DI 0 "register_operand" "")
1497 (match_operand:DI 1 "memory_operand" ""))]
1498 "!TARGET_ZARCH && reload_completed && TARGET_Z10
1499 && larl_operand (XEXP (operands[1], 0), SImode)"
1500 [(set (match_dup 2) (match_dup 3))
1501 (set (match_dup 0) (match_dup 1))]
1502 {
1503 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1504 operands[3] = XEXP (operands[1], 0);
1505 operands[1] = replace_equiv_address (operands[1], operands[2]);
1506 })
1507
1508 (define_split
1509 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1510 (match_operand:DI 1 "general_operand" ""))]
1511 "!TARGET_ZARCH && reload_completed
1512 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
1513 [(set (match_dup 2) (match_dup 4))
1514 (set (match_dup 3) (match_dup 5))]
1515 {
1516 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1517 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1518 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1519 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1520 })
1521
1522 (define_split
1523 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1524 (match_operand:DI 1 "general_operand" ""))]
1525 "!TARGET_ZARCH && reload_completed
1526 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1527 [(set (match_dup 2) (match_dup 4))
1528 (set (match_dup 3) (match_dup 5))]
1529 {
1530 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1531 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1532 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1533 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1534 })
1535
1536 (define_split
1537 [(set (match_operand:DI 0 "register_operand" "")
1538 (match_operand:DI 1 "memory_operand" ""))]
1539 "!TARGET_ZARCH && reload_completed
1540 && !FP_REG_P (operands[0])
1541 && !s_operand (operands[1], VOIDmode)"
1542 [(set (match_dup 0) (match_dup 1))]
1543 {
1544 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1545 s390_load_address (addr, XEXP (operands[1], 0));
1546 operands[1] = replace_equiv_address (operands[1], addr);
1547 })
1548
1549 (define_peephole2
1550 [(set (match_operand:DI 0 "register_operand" "")
1551 (mem:DI (match_operand 1 "address_operand" "")))]
1552 "TARGET_ZARCH
1553 && !FP_REG_P (operands[0])
1554 && GET_CODE (operands[1]) == SYMBOL_REF
1555 && CONSTANT_POOL_ADDRESS_P (operands[1])
1556 && get_pool_mode (operands[1]) == DImode
1557 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1558 [(set (match_dup 0) (match_dup 2))]
1559 "operands[2] = get_pool_constant (operands[1]);")
1560
1561 (define_insn "*la_64"
1562 [(set (match_operand:DI 0 "register_operand" "=d,d")
1563 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))]
1564 "TARGET_64BIT"
1565 "@
1566 la\t%0,%a1
1567 lay\t%0,%a1"
1568 [(set_attr "op_type" "RX,RXY")
1569 (set_attr "type" "la")
1570 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1571
1572 (define_peephole2
1573 [(parallel
1574 [(set (match_operand:DI 0 "register_operand" "")
1575 (match_operand:QI 1 "address_operand" ""))
1576 (clobber (reg:CC CC_REGNUM))])]
1577 "TARGET_64BIT
1578 && preferred_la_operand_p (operands[1], const0_rtx)"
1579 [(set (match_dup 0) (match_dup 1))]
1580 "")
1581
1582 (define_peephole2
1583 [(set (match_operand:DI 0 "register_operand" "")
1584 (match_operand:DI 1 "register_operand" ""))
1585 (parallel
1586 [(set (match_dup 0)
1587 (plus:DI (match_dup 0)
1588 (match_operand:DI 2 "nonmemory_operand" "")))
1589 (clobber (reg:CC CC_REGNUM))])]
1590 "TARGET_64BIT
1591 && !reg_overlap_mentioned_p (operands[0], operands[2])
1592 && preferred_la_operand_p (operands[1], operands[2])"
1593 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1594 "")
1595
1596 ;
1597 ; movsi instruction pattern(s).
1598 ;
1599
1600 (define_expand "movsi"
1601 [(set (match_operand:SI 0 "general_operand" "")
1602 (match_operand:SI 1 "general_operand" ""))]
1603 ""
1604 {
1605 /* Handle symbolic constants. */
1606 if (!TARGET_64BIT
1607 && (SYMBOLIC_CONST (operands[1])
1608 || (GET_CODE (operands[1]) == PLUS
1609 && XEXP (operands[1], 0) == pic_offset_table_rtx
1610 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
1611 emit_symbolic_move (operands);
1612 })
1613
1614 (define_insn "*movsi_larl"
1615 [(set (match_operand:SI 0 "register_operand" "=d")
1616 (match_operand:SI 1 "larl_operand" "X"))]
1617 "!TARGET_64BIT && TARGET_CPU_ZARCH
1618 && !FP_REG_P (operands[0])"
1619 "larl\t%0,%1"
1620 [(set_attr "op_type" "RIL")
1621 (set_attr "type" "larl")
1622 (set_attr "z10prop" "z10_fwd_A1")])
1623
1624 (define_insn "*movsi_zarch"
1625 [(set (match_operand:SI 0 "nonimmediate_operand"
1626 "=d,d,d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,b,Q,t")
1627 (match_operand:SI 1 "general_operand"
1628 "K,N0HS0,N1HS0,Os,L,b,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,d,K,Q"))]
1629 "TARGET_ZARCH"
1630 "@
1631 lhi\t%0,%h1
1632 llilh\t%0,%i1
1633 llill\t%0,%i1
1634 iilf\t%0,%o1
1635 lay\t%0,%a1
1636 lrl\t%0,%1
1637 lr\t%0,%1
1638 l\t%0,%1
1639 ly\t%0,%1
1640 st\t%1,%0
1641 sty\t%1,%0
1642 ler\t%0,%1
1643 le\t%0,%1
1644 ley\t%0,%1
1645 ste\t%1,%0
1646 stey\t%1,%0
1647 ear\t%0,%1
1648 sar\t%0,%1
1649 stam\t%1,%1,%S0
1650 strl\t%1,%0
1651 mvhi\t%0,%1
1652 lam\t%0,%0,%S1"
1653 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
1654 RR,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS")
1655 (set_attr "type" "*,
1656 *,
1657 *,
1658 *,
1659 la,
1660 larl,
1661 lr,
1662 load,
1663 load,
1664 store,
1665 store,
1666 floadsf,
1667 floadsf,
1668 floadsf,
1669 fstoresf,
1670 fstoresf,
1671 *,
1672 *,
1673 *,
1674 larl,
1675 *,
1676 *")
1677 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
1678 *,*,longdisp,*,longdisp,*,*,*,z10,z10,*")
1679 (set_attr "z10prop" "z10_fwd_A1,
1680 z10_fwd_E1,
1681 z10_fwd_E1,
1682 z10_fwd_A1,
1683 z10_fwd_A1,
1684 z10_fwd_A3,
1685 z10_fr_E1,
1686 z10_fwd_A3,
1687 z10_fwd_A3,
1688 z10_rec,
1689 z10_rec,
1690 *,
1691 *,
1692 *,
1693 *,
1694 *,
1695 z10_super_E1,
1696 z10_super,
1697 *,
1698 z10_rec,
1699 z10_super,
1700 *")])
1701
1702 (define_insn "*movsi_esa"
1703 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t")
1704 (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q"))]
1705 "!TARGET_ZARCH"
1706 "@
1707 lhi\t%0,%h1
1708 lr\t%0,%1
1709 l\t%0,%1
1710 st\t%1,%0
1711 ler\t%0,%1
1712 le\t%0,%1
1713 ste\t%1,%0
1714 ear\t%0,%1
1715 sar\t%0,%1
1716 stam\t%1,%1,%S0
1717 lam\t%0,%0,%S1"
1718 [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS")
1719 (set_attr "type" "*,lr,load,store,floadsf,floadsf,fstoresf,*,*,*,*")
1720 (set_attr "z10prop" "z10_fwd_A1,
1721 z10_fr_E1,
1722 z10_fwd_A3,
1723 z10_rec,
1724 *,
1725 *,
1726 *,
1727 z10_super_E1,
1728 z10_super,
1729 *,
1730 *")
1731 ])
1732
1733 (define_peephole2
1734 [(set (match_operand:SI 0 "register_operand" "")
1735 (mem:SI (match_operand 1 "address_operand" "")))]
1736 "!FP_REG_P (operands[0])
1737 && GET_CODE (operands[1]) == SYMBOL_REF
1738 && CONSTANT_POOL_ADDRESS_P (operands[1])
1739 && get_pool_mode (operands[1]) == SImode
1740 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1741 [(set (match_dup 0) (match_dup 2))]
1742 "operands[2] = get_pool_constant (operands[1]);")
1743
1744 (define_insn "*la_31"
1745 [(set (match_operand:SI 0 "register_operand" "=d,d")
1746 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))]
1747 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1748 "@
1749 la\t%0,%a1
1750 lay\t%0,%a1"
1751 [(set_attr "op_type" "RX,RXY")
1752 (set_attr "type" "la")
1753 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1754
1755 (define_peephole2
1756 [(parallel
1757 [(set (match_operand:SI 0 "register_operand" "")
1758 (match_operand:QI 1 "address_operand" ""))
1759 (clobber (reg:CC CC_REGNUM))])]
1760 "!TARGET_64BIT
1761 && preferred_la_operand_p (operands[1], const0_rtx)"
1762 [(set (match_dup 0) (match_dup 1))]
1763 "")
1764
1765 (define_peephole2
1766 [(set (match_operand:SI 0 "register_operand" "")
1767 (match_operand:SI 1 "register_operand" ""))
1768 (parallel
1769 [(set (match_dup 0)
1770 (plus:SI (match_dup 0)
1771 (match_operand:SI 2 "nonmemory_operand" "")))
1772 (clobber (reg:CC CC_REGNUM))])]
1773 "!TARGET_64BIT
1774 && !reg_overlap_mentioned_p (operands[0], operands[2])
1775 && preferred_la_operand_p (operands[1], operands[2])"
1776 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1777 "")
1778
1779 (define_insn "*la_31_and"
1780 [(set (match_operand:SI 0 "register_operand" "=d,d")
1781 (and:SI (match_operand:QI 1 "address_operand" "ZQZR,ZSZT")
1782 (const_int 2147483647)))]
1783 "!TARGET_64BIT"
1784 "@
1785 la\t%0,%a1
1786 lay\t%0,%a1"
1787 [(set_attr "op_type" "RX,RXY")
1788 (set_attr "type" "la")
1789 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1790
1791 (define_insn_and_split "*la_31_and_cc"
1792 [(set (match_operand:SI 0 "register_operand" "=d")
1793 (and:SI (match_operand:QI 1 "address_operand" "p")
1794 (const_int 2147483647)))
1795 (clobber (reg:CC CC_REGNUM))]
1796 "!TARGET_64BIT"
1797 "#"
1798 "&& reload_completed"
1799 [(set (match_dup 0)
1800 (and:SI (match_dup 1) (const_int 2147483647)))]
1801 ""
1802 [(set_attr "op_type" "RX")
1803 (set_attr "type" "la")])
1804
1805 (define_insn "force_la_31"
1806 [(set (match_operand:SI 0 "register_operand" "=d,d")
1807 (match_operand:QI 1 "address_operand" "ZQZR,ZSZT"))
1808 (use (const_int 0))]
1809 "!TARGET_64BIT"
1810 "@
1811 la\t%0,%a1
1812 lay\t%0,%a1"
1813 [(set_attr "op_type" "RX")
1814 (set_attr "type" "la")
1815 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1816
1817 ;
1818 ; movhi instruction pattern(s).
1819 ;
1820
1821 (define_expand "movhi"
1822 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1823 (match_operand:HI 1 "general_operand" ""))]
1824 ""
1825 {
1826 /* Make it explicit that loading a register from memory
1827 always sign-extends (at least) to SImode. */
1828 if (optimize && can_create_pseudo_p ()
1829 && register_operand (operands[0], VOIDmode)
1830 && GET_CODE (operands[1]) == MEM)
1831 {
1832 rtx tmp = gen_reg_rtx (SImode);
1833 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1834 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1835 operands[1] = gen_lowpart (HImode, tmp);
1836 }
1837 })
1838
1839 (define_insn "*movhi"
1840 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q")
1841 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K"))]
1842 ""
1843 "@
1844 lr\t%0,%1
1845 lhi\t%0,%h1
1846 lh\t%0,%1
1847 lhy\t%0,%1
1848 lhrl\t%0,%1
1849 sth\t%1,%0
1850 sthy\t%1,%0
1851 sthrl\t%1,%0
1852 mvhhi\t%0,%1"
1853 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL")
1854 (set_attr "type" "lr,*,*,*,larl,store,store,store,*")
1855 (set_attr "cpu_facility" "*,*,*,*,z10,*,*,z10,z10")
1856 (set_attr "z10prop" "z10_fr_E1,
1857 z10_fwd_A1,
1858 z10_super_E1,
1859 z10_super_E1,
1860 z10_super_E1,
1861 z10_rec,
1862 z10_rec,
1863 z10_rec,
1864 z10_super")])
1865
1866 (define_peephole2
1867 [(set (match_operand:HI 0 "register_operand" "")
1868 (mem:HI (match_operand 1 "address_operand" "")))]
1869 "GET_CODE (operands[1]) == SYMBOL_REF
1870 && CONSTANT_POOL_ADDRESS_P (operands[1])
1871 && get_pool_mode (operands[1]) == HImode
1872 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1873 [(set (match_dup 0) (match_dup 2))]
1874 "operands[2] = get_pool_constant (operands[1]);")
1875
1876 ;
1877 ; movqi instruction pattern(s).
1878 ;
1879
1880 (define_expand "movqi"
1881 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1882 (match_operand:QI 1 "general_operand" ""))]
1883 ""
1884 {
1885 /* On z/Architecture, zero-extending from memory to register
1886 is just as fast as a QImode load. */
1887 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
1888 && register_operand (operands[0], VOIDmode)
1889 && GET_CODE (operands[1]) == MEM)
1890 {
1891 rtx tmp = gen_reg_rtx (DImode);
1892 rtx ext = gen_rtx_ZERO_EXTEND (DImode, operands[1]);
1893 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1894 operands[1] = gen_lowpart (QImode, tmp);
1895 }
1896 })
1897
1898 (define_insn "*movqi"
1899 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q")
1900 (match_operand:QI 1 "general_operand" " d,n,R,T,d,d,n,n,?Q"))]
1901 ""
1902 "@
1903 lr\t%0,%1
1904 lhi\t%0,%b1
1905 ic\t%0,%1
1906 icy\t%0,%1
1907 stc\t%1,%0
1908 stcy\t%1,%0
1909 mvi\t%S0,%b1
1910 mviy\t%S0,%b1
1911 #"
1912 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS")
1913 (set_attr "type" "lr,*,*,*,store,store,store,store,*")
1914 (set_attr "z10prop" "z10_fr_E1,
1915 z10_fwd_A1,
1916 z10_super_E1,
1917 z10_super_E1,
1918 z10_rec,
1919 z10_rec,
1920 z10_super,
1921 z10_super,
1922 *")])
1923
1924 (define_peephole2
1925 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1926 (mem:QI (match_operand 1 "address_operand" "")))]
1927 "GET_CODE (operands[1]) == SYMBOL_REF
1928 && CONSTANT_POOL_ADDRESS_P (operands[1])
1929 && get_pool_mode (operands[1]) == QImode
1930 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1931 [(set (match_dup 0) (match_dup 2))]
1932 "operands[2] = get_pool_constant (operands[1]);")
1933
1934 ;
1935 ; movstrictqi instruction pattern(s).
1936 ;
1937
1938 (define_insn "*movstrictqi"
1939 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1940 (match_operand:QI 1 "memory_operand" "R,T"))]
1941 ""
1942 "@
1943 ic\t%0,%1
1944 icy\t%0,%1"
1945 [(set_attr "op_type" "RX,RXY")
1946 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1947
1948 ;
1949 ; movstricthi instruction pattern(s).
1950 ;
1951
1952 (define_insn "*movstricthi"
1953 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1954 (match_operand:HI 1 "memory_operand" "Q,S"))
1955 (clobber (reg:CC CC_REGNUM))]
1956 ""
1957 "@
1958 icm\t%0,3,%S1
1959 icmy\t%0,3,%S1"
1960 [(set_attr "op_type" "RS,RSY")
1961 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1962
1963 ;
1964 ; movstrictsi instruction pattern(s).
1965 ;
1966
1967 (define_insn "movstrictsi"
1968 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1969 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1970 "TARGET_ZARCH"
1971 "@
1972 lr\t%0,%1
1973 l\t%0,%1
1974 ly\t%0,%1
1975 ear\t%0,%1"
1976 [(set_attr "op_type" "RR,RX,RXY,RRE")
1977 (set_attr "type" "lr,load,load,*")
1978 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
1979
1980 ;
1981 ; mov(tf|td) instruction pattern(s).
1982 ;
1983
1984 (define_expand "mov<mode>"
1985 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1986 (match_operand:TD_TF 1 "general_operand" ""))]
1987 ""
1988 "")
1989
1990 (define_insn "*mov<mode>_64"
1991 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o, d,QS, d,o")
1992 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,QS, d,dRT,d"))]
1993 "TARGET_ZARCH"
1994 "@
1995 lzxr\t%0
1996 lxr\t%0,%1
1997 #
1998 #
1999 lmg\t%0,%N0,%S1
2000 stmg\t%1,%N1,%S0
2001 #
2002 #"
2003 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
2004 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")
2005 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*")])
2006
2007 (define_insn "*mov<mode>_31"
2008 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
2009 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
2010 "!TARGET_ZARCH"
2011 "@
2012 lzxr\t%0
2013 lxr\t%0,%1
2014 #
2015 #"
2016 [(set_attr "op_type" "RRE,RRE,*,*")
2017 (set_attr "type" "fsimptf,fsimptf,*,*")
2018 (set_attr "cpu_facility" "z196,*,*,*")])
2019
2020 ; TFmode in GPRs splitters
2021
2022 (define_split
2023 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2024 (match_operand:TD_TF 1 "general_operand" ""))]
2025 "TARGET_ZARCH && reload_completed
2026 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2027 [(set (match_dup 2) (match_dup 4))
2028 (set (match_dup 3) (match_dup 5))]
2029 {
2030 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2031 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2032 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2033 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2034 })
2035
2036 (define_split
2037 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2038 (match_operand:TD_TF 1 "general_operand" ""))]
2039 "TARGET_ZARCH && reload_completed
2040 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2041 [(set (match_dup 2) (match_dup 4))
2042 (set (match_dup 3) (match_dup 5))]
2043 {
2044 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2045 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2046 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2047 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2048 })
2049
2050 (define_split
2051 [(set (match_operand:TD_TF 0 "register_operand" "")
2052 (match_operand:TD_TF 1 "memory_operand" ""))]
2053 "TARGET_ZARCH && reload_completed
2054 && !FP_REG_P (operands[0])
2055 && !s_operand (operands[1], VOIDmode)"
2056 [(set (match_dup 0) (match_dup 1))]
2057 {
2058 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2059 addr = gen_lowpart (Pmode, addr);
2060 s390_load_address (addr, XEXP (operands[1], 0));
2061 operands[1] = replace_equiv_address (operands[1], addr);
2062 })
2063
2064 ; TFmode in BFPs splitters
2065
2066 (define_split
2067 [(set (match_operand:TD_TF 0 "register_operand" "")
2068 (match_operand:TD_TF 1 "memory_operand" ""))]
2069 "reload_completed && offsettable_memref_p (operands[1])
2070 && FP_REG_P (operands[0])"
2071 [(set (match_dup 2) (match_dup 4))
2072 (set (match_dup 3) (match_dup 5))]
2073 {
2074 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2075 <MODE>mode, 0);
2076 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2077 <MODE>mode, 8);
2078 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
2079 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
2080 })
2081
2082 (define_split
2083 [(set (match_operand:TD_TF 0 "memory_operand" "")
2084 (match_operand:TD_TF 1 "register_operand" ""))]
2085 "reload_completed && offsettable_memref_p (operands[0])
2086 && FP_REG_P (operands[1])"
2087 [(set (match_dup 2) (match_dup 4))
2088 (set (match_dup 3) (match_dup 5))]
2089 {
2090 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
2091 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
2092 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2093 <MODE>mode, 0);
2094 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2095 <MODE>mode, 8);
2096 })
2097
2098 ;
2099 ; mov(df|dd) instruction pattern(s).
2100 ;
2101
2102 (define_expand "mov<mode>"
2103 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2104 (match_operand:DD_DF 1 "general_operand" ""))]
2105 ""
2106 "")
2107
2108 (define_insn "*mov<mode>_64dfp"
2109 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2110 "=f,f,f,d,f,f,R,T,d,d, d,RT")
2111 (match_operand:DD_DF 1 "general_operand"
2112 " G,f,d,f,R,T,f,f,G,d,RT, d"))]
2113 "TARGET_DFP"
2114 "@
2115 lzdr\t%0
2116 ldr\t%0,%1
2117 ldgr\t%0,%1
2118 lgdr\t%0,%1
2119 ld\t%0,%1
2120 ldy\t%0,%1
2121 std\t%1,%0
2122 stdy\t%1,%0
2123 lghi\t%0,0
2124 lgr\t%0,%1
2125 lg\t%0,%1
2126 stg\t%1,%0"
2127 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RI,RRE,RXY,RXY")
2128 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
2129 fstoredf,fstoredf,*,lr,load,store")
2130 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec")
2131 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*,*,*")])
2132
2133 (define_insn "*mov<mode>_64"
2134 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d, d,RT")
2135 (match_operand:DD_DF 1 "general_operand" " G,f,R,T,f,f,G,d,RT, d"))]
2136 "TARGET_ZARCH"
2137 "@
2138 lzdr\t%0
2139 ldr\t%0,%1
2140 ld\t%0,%1
2141 ldy\t%0,%1
2142 std\t%1,%0
2143 stdy\t%1,%0
2144 lghi\t%0,0
2145 lgr\t%0,%1
2146 lg\t%0,%1
2147 stg\t%1,%0"
2148 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RRE,RXY,RXY")
2149 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2150 fstore<mode>,fstore<mode>,*,lr,load,store")
2151 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec")
2152 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*")])
2153
2154 (define_insn "*mov<mode>_31"
2155 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2156 "=f,f,f,f,R,T,d,d,Q,S, d,o")
2157 (match_operand:DD_DF 1 "general_operand"
2158 " G,f,R,T,f,f,Q,S,d,d,dPRT,d"))]
2159 "!TARGET_ZARCH"
2160 "@
2161 lzdr\t%0
2162 ldr\t%0,%1
2163 ld\t%0,%1
2164 ldy\t%0,%1
2165 std\t%1,%0
2166 stdy\t%1,%0
2167 lm\t%0,%N0,%S1
2168 lmy\t%0,%N0,%S1
2169 stm\t%1,%N1,%S0
2170 stmy\t%1,%N1,%S0
2171 #
2172 #"
2173 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2174 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2175 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")
2176 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*,*,*")])
2177
2178 (define_split
2179 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2180 (match_operand:DD_DF 1 "general_operand" ""))]
2181 "!TARGET_ZARCH && reload_completed
2182 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2183 [(set (match_dup 2) (match_dup 4))
2184 (set (match_dup 3) (match_dup 5))]
2185 {
2186 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2187 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2188 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2189 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2190 })
2191
2192 (define_split
2193 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2194 (match_operand:DD_DF 1 "general_operand" ""))]
2195 "!TARGET_ZARCH && reload_completed
2196 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2197 [(set (match_dup 2) (match_dup 4))
2198 (set (match_dup 3) (match_dup 5))]
2199 {
2200 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2201 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2202 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2203 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2204 })
2205
2206 (define_split
2207 [(set (match_operand:DD_DF 0 "register_operand" "")
2208 (match_operand:DD_DF 1 "memory_operand" ""))]
2209 "!TARGET_ZARCH && reload_completed
2210 && !FP_REG_P (operands[0])
2211 && !s_operand (operands[1], VOIDmode)"
2212 [(set (match_dup 0) (match_dup 1))]
2213 {
2214 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2215 s390_load_address (addr, XEXP (operands[1], 0));
2216 operands[1] = replace_equiv_address (operands[1], addr);
2217 })
2218
2219 ;
2220 ; mov(sf|sd) instruction pattern(s).
2221 ;
2222
2223 (define_insn "mov<mode>"
2224 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
2225 "=f,f,f,f,R,T,d,d,d,d,R,T")
2226 (match_operand:SD_SF 1 "general_operand"
2227 " G,f,R,T,f,f,G,d,R,T,d,d"))]
2228 ""
2229 "@
2230 lzer\t%0
2231 ler\t%0,%1
2232 le\t%0,%1
2233 ley\t%0,%1
2234 ste\t%1,%0
2235 stey\t%1,%0
2236 lhi\t%0,0
2237 lr\t%0,%1
2238 l\t%0,%1
2239 ly\t%0,%1
2240 st\t%1,%0
2241 sty\t%1,%0"
2242 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RR,RX,RXY,RX,RXY")
2243 (set_attr "type" "fsimpsf,fload<mode>,fload<mode>,fload<mode>,
2244 fstore<mode>,fstore<mode>,*,lr,load,load,store,store")
2245 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
2246 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*,*,*,*,*")])
2247
2248 ;
2249 ; movcc instruction pattern
2250 ;
2251
2252 (define_insn "movcc"
2253 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
2254 (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
2255 ""
2256 "@
2257 lr\t%0,%1
2258 tmh\t%1,12288
2259 ipm\t%0
2260 st\t%0,%1
2261 sty\t%0,%1
2262 l\t%1,%0
2263 ly\t%1,%0"
2264 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
2265 (set_attr "type" "lr,*,*,store,store,load,load")
2266 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_rec,z10_rec,z10_fwd_A3,z10_fwd_A3")
2267 (set_attr "z196prop" "*,*,z196_ends,*,*,*,*")])
2268
2269 ;
2270 ; Block move (MVC) patterns.
2271 ;
2272
2273 (define_insn "*mvc"
2274 [(set (match_operand:BLK 0 "memory_operand" "=Q")
2275 (match_operand:BLK 1 "memory_operand" "Q"))
2276 (use (match_operand 2 "const_int_operand" "n"))]
2277 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
2278 "mvc\t%O0(%2,%R0),%S1"
2279 [(set_attr "op_type" "SS")])
2280
2281 ; This splitter converts a QI to QI mode copy into a BLK mode copy in
2282 ; order to have it implemented with mvc.
2283
2284 (define_split
2285 [(set (match_operand:QI 0 "memory_operand" "")
2286 (match_operand:QI 1 "memory_operand" ""))]
2287 "reload_completed"
2288 [(parallel
2289 [(set (match_dup 0) (match_dup 1))
2290 (use (const_int 1))])]
2291 {
2292 operands[0] = adjust_address (operands[0], BLKmode, 0);
2293 operands[1] = adjust_address (operands[1], BLKmode, 0);
2294 })
2295
2296
2297 (define_peephole2
2298 [(parallel
2299 [(set (match_operand:BLK 0 "memory_operand" "")
2300 (match_operand:BLK 1 "memory_operand" ""))
2301 (use (match_operand 2 "const_int_operand" ""))])
2302 (parallel
2303 [(set (match_operand:BLK 3 "memory_operand" "")
2304 (match_operand:BLK 4 "memory_operand" ""))
2305 (use (match_operand 5 "const_int_operand" ""))])]
2306 "s390_offset_p (operands[0], operands[3], operands[2])
2307 && s390_offset_p (operands[1], operands[4], operands[2])
2308 && !s390_overlap_p (operands[0], operands[1],
2309 INTVAL (operands[2]) + INTVAL (operands[5]))
2310 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2311 [(parallel
2312 [(set (match_dup 6) (match_dup 7))
2313 (use (match_dup 8))])]
2314 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2315 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2316 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2317
2318
2319 ;
2320 ; load_multiple pattern(s).
2321 ;
2322 ; ??? Due to reload problems with replacing registers inside match_parallel
2323 ; we currently support load_multiple/store_multiple only after reload.
2324 ;
2325
2326 (define_expand "load_multiple"
2327 [(match_par_dup 3 [(set (match_operand 0 "" "")
2328 (match_operand 1 "" ""))
2329 (use (match_operand 2 "" ""))])]
2330 "reload_completed"
2331 {
2332 enum machine_mode mode;
2333 int regno;
2334 int count;
2335 rtx from;
2336 int i, off;
2337
2338 /* Support only loading a constant number of fixed-point registers from
2339 memory and only bother with this if more than two */
2340 if (GET_CODE (operands[2]) != CONST_INT
2341 || INTVAL (operands[2]) < 2
2342 || INTVAL (operands[2]) > 16
2343 || GET_CODE (operands[1]) != MEM
2344 || GET_CODE (operands[0]) != REG
2345 || REGNO (operands[0]) >= 16)
2346 FAIL;
2347
2348 count = INTVAL (operands[2]);
2349 regno = REGNO (operands[0]);
2350 mode = GET_MODE (operands[0]);
2351 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
2352 FAIL;
2353
2354 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2355 if (!can_create_pseudo_p ())
2356 {
2357 if (GET_CODE (XEXP (operands[1], 0)) == REG)
2358 {
2359 from = XEXP (operands[1], 0);
2360 off = 0;
2361 }
2362 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2363 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2364 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2365 {
2366 from = XEXP (XEXP (operands[1], 0), 0);
2367 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2368 }
2369 else
2370 FAIL;
2371 }
2372 else
2373 {
2374 from = force_reg (Pmode, XEXP (operands[1], 0));
2375 off = 0;
2376 }
2377
2378 for (i = 0; i < count; i++)
2379 XVECEXP (operands[3], 0, i)
2380 = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
2381 change_address (operands[1], mode,
2382 plus_constant (Pmode, from,
2383 off + i * GET_MODE_SIZE (mode))));
2384 })
2385
2386 (define_insn "*load_multiple_di"
2387 [(match_parallel 0 "load_multiple_operation"
2388 [(set (match_operand:DI 1 "register_operand" "=r")
2389 (match_operand:DI 2 "s_operand" "QS"))])]
2390 "reload_completed && TARGET_ZARCH"
2391 {
2392 int words = XVECLEN (operands[0], 0);
2393 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
2394 return "lmg\t%1,%0,%S2";
2395 }
2396 [(set_attr "op_type" "RSY")
2397 (set_attr "type" "lm")])
2398
2399 (define_insn "*load_multiple_si"
2400 [(match_parallel 0 "load_multiple_operation"
2401 [(set (match_operand:SI 1 "register_operand" "=r,r")
2402 (match_operand:SI 2 "s_operand" "Q,S"))])]
2403 "reload_completed"
2404 {
2405 int words = XVECLEN (operands[0], 0);
2406 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
2407 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
2408 }
2409 [(set_attr "op_type" "RS,RSY")
2410 (set_attr "type" "lm")])
2411
2412 ;
2413 ; store multiple pattern(s).
2414 ;
2415
2416 (define_expand "store_multiple"
2417 [(match_par_dup 3 [(set (match_operand 0 "" "")
2418 (match_operand 1 "" ""))
2419 (use (match_operand 2 "" ""))])]
2420 "reload_completed"
2421 {
2422 enum machine_mode mode;
2423 int regno;
2424 int count;
2425 rtx to;
2426 int i, off;
2427
2428 /* Support only storing a constant number of fixed-point registers to
2429 memory and only bother with this if more than two. */
2430 if (GET_CODE (operands[2]) != CONST_INT
2431 || INTVAL (operands[2]) < 2
2432 || INTVAL (operands[2]) > 16
2433 || GET_CODE (operands[0]) != MEM
2434 || GET_CODE (operands[1]) != REG
2435 || REGNO (operands[1]) >= 16)
2436 FAIL;
2437
2438 count = INTVAL (operands[2]);
2439 regno = REGNO (operands[1]);
2440 mode = GET_MODE (operands[1]);
2441 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
2442 FAIL;
2443
2444 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2445
2446 if (!can_create_pseudo_p ())
2447 {
2448 if (GET_CODE (XEXP (operands[0], 0)) == REG)
2449 {
2450 to = XEXP (operands[0], 0);
2451 off = 0;
2452 }
2453 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2454 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2455 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2456 {
2457 to = XEXP (XEXP (operands[0], 0), 0);
2458 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2459 }
2460 else
2461 FAIL;
2462 }
2463 else
2464 {
2465 to = force_reg (Pmode, XEXP (operands[0], 0));
2466 off = 0;
2467 }
2468
2469 for (i = 0; i < count; i++)
2470 XVECEXP (operands[3], 0, i)
2471 = gen_rtx_SET (VOIDmode,
2472 change_address (operands[0], mode,
2473 plus_constant (Pmode, to,
2474 off + i * GET_MODE_SIZE (mode))),
2475 gen_rtx_REG (mode, regno + i));
2476 })
2477
2478 (define_insn "*store_multiple_di"
2479 [(match_parallel 0 "store_multiple_operation"
2480 [(set (match_operand:DI 1 "s_operand" "=QS")
2481 (match_operand:DI 2 "register_operand" "r"))])]
2482 "reload_completed && TARGET_ZARCH"
2483 {
2484 int words = XVECLEN (operands[0], 0);
2485 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
2486 return "stmg\t%2,%0,%S1";
2487 }
2488 [(set_attr "op_type" "RSY")
2489 (set_attr "type" "stm")])
2490
2491
2492 (define_insn "*store_multiple_si"
2493 [(match_parallel 0 "store_multiple_operation"
2494 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2495 (match_operand:SI 2 "register_operand" "r,r"))])]
2496 "reload_completed"
2497 {
2498 int words = XVECLEN (operands[0], 0);
2499 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
2500 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
2501 }
2502 [(set_attr "op_type" "RS,RSY")
2503 (set_attr "type" "stm")])
2504
2505 ;;
2506 ;; String instructions.
2507 ;;
2508
2509 (define_insn "*execute_rl"
2510 [(match_parallel 0 "execute_operation"
2511 [(unspec [(match_operand 1 "register_operand" "a")
2512 (match_operand 2 "" "")
2513 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2514 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2515 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2516 "exrl\t%1,%3"
2517 [(set_attr "op_type" "RIL")
2518 (set_attr "type" "cs")])
2519
2520 (define_insn "*execute"
2521 [(match_parallel 0 "execute_operation"
2522 [(unspec [(match_operand 1 "register_operand" "a")
2523 (match_operand:BLK 2 "memory_operand" "R")
2524 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2525 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2526 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2527 "ex\t%1,%2"
2528 [(set_attr "op_type" "RX")
2529 (set_attr "type" "cs")])
2530
2531
2532 ;
2533 ; strlenM instruction pattern(s).
2534 ;
2535
2536 (define_expand "strlen<mode>"
2537 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2538 (parallel
2539 [(set (match_dup 4)
2540 (unspec:P [(const_int 0)
2541 (match_operand:BLK 1 "memory_operand" "")
2542 (reg:SI 0)
2543 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
2544 (clobber (scratch:P))
2545 (clobber (reg:CC CC_REGNUM))])
2546 (parallel
2547 [(set (match_operand:P 0 "register_operand" "")
2548 (minus:P (match_dup 4) (match_dup 5)))
2549 (clobber (reg:CC CC_REGNUM))])]
2550 ""
2551 {
2552 operands[4] = gen_reg_rtx (Pmode);
2553 operands[5] = gen_reg_rtx (Pmode);
2554 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2555 operands[1] = replace_equiv_address (operands[1], operands[5]);
2556 })
2557
2558 (define_insn "*strlen<mode>"
2559 [(set (match_operand:P 0 "register_operand" "=a")
2560 (unspec:P [(match_operand:P 2 "general_operand" "0")
2561 (mem:BLK (match_operand:P 3 "register_operand" "1"))
2562 (reg:SI 0)
2563 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
2564 (clobber (match_scratch:P 1 "=a"))
2565 (clobber (reg:CC CC_REGNUM))]
2566 ""
2567 "srst\t%0,%1\;jo\t.-4"
2568 [(set_attr "length" "8")
2569 (set_attr "type" "vs")])
2570
2571 ;
2572 ; cmpstrM instruction pattern(s).
2573 ;
2574
2575 (define_expand "cmpstrsi"
2576 [(set (reg:SI 0) (const_int 0))
2577 (parallel
2578 [(clobber (match_operand 3 "" ""))
2579 (clobber (match_dup 4))
2580 (set (reg:CCU CC_REGNUM)
2581 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2582 (match_operand:BLK 2 "memory_operand" "")))
2583 (use (reg:SI 0))])
2584 (parallel
2585 [(set (match_operand:SI 0 "register_operand" "=d")
2586 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_CCU_TO_INT))
2587 (clobber (reg:CC CC_REGNUM))])]
2588 ""
2589 {
2590 /* As the result of CMPINT is inverted compared to what we need,
2591 we have to swap the operands. */
2592 rtx op1 = operands[2];
2593 rtx op2 = operands[1];
2594 rtx addr1 = gen_reg_rtx (Pmode);
2595 rtx addr2 = gen_reg_rtx (Pmode);
2596
2597 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2598 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2599 operands[1] = replace_equiv_address_nv (op1, addr1);
2600 operands[2] = replace_equiv_address_nv (op2, addr2);
2601 operands[3] = addr1;
2602 operands[4] = addr2;
2603 })
2604
2605 (define_insn "*cmpstr<mode>"
2606 [(clobber (match_operand:P 0 "register_operand" "=d"))
2607 (clobber (match_operand:P 1 "register_operand" "=d"))
2608 (set (reg:CCU CC_REGNUM)
2609 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2610 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2611 (use (reg:SI 0))]
2612 ""
2613 "clst\t%0,%1\;jo\t.-4"
2614 [(set_attr "length" "8")
2615 (set_attr "type" "vs")])
2616
2617 ;
2618 ; movstr instruction pattern.
2619 ;
2620
2621 (define_expand "movstr"
2622 [(set (reg:SI 0) (const_int 0))
2623 (parallel
2624 [(clobber (match_dup 3))
2625 (set (match_operand:BLK 1 "memory_operand" "")
2626 (match_operand:BLK 2 "memory_operand" ""))
2627 (set (match_operand 0 "register_operand" "")
2628 (unspec [(match_dup 1)
2629 (match_dup 2)
2630 (reg:SI 0)] UNSPEC_MVST))
2631 (clobber (reg:CC CC_REGNUM))])]
2632 ""
2633 {
2634 rtx addr1 = gen_reg_rtx (Pmode);
2635 rtx addr2 = gen_reg_rtx (Pmode);
2636
2637 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2638 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
2639 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2640 operands[2] = replace_equiv_address_nv (operands[2], addr2);
2641 operands[3] = addr2;
2642 })
2643
2644 (define_insn "*movstr"
2645 [(clobber (match_operand:P 2 "register_operand" "=d"))
2646 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
2647 (mem:BLK (match_operand:P 3 "register_operand" "2")))
2648 (set (match_operand:P 0 "register_operand" "=d")
2649 (unspec [(mem:BLK (match_dup 1))
2650 (mem:BLK (match_dup 3))
2651 (reg:SI 0)] UNSPEC_MVST))
2652 (clobber (reg:CC CC_REGNUM))]
2653 ""
2654 "mvst\t%1,%2\;jo\t.-4"
2655 [(set_attr "length" "8")
2656 (set_attr "type" "vs")])
2657
2658
2659 ;
2660 ; movmemM instruction pattern(s).
2661 ;
2662
2663 (define_expand "movmem<mode>"
2664 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
2665 (match_operand:BLK 1 "memory_operand" "")) ; source
2666 (use (match_operand:GPR 2 "general_operand" "")) ; count
2667 (match_operand 3 "" "")]
2668 ""
2669 {
2670 if (s390_expand_movmem (operands[0], operands[1], operands[2]))
2671 DONE;
2672 else
2673 FAIL;
2674 })
2675
2676 ; Move a block that is up to 256 bytes in length.
2677 ; The block length is taken as (operands[2] % 256) + 1.
2678
2679 (define_expand "movmem_short"
2680 [(parallel
2681 [(set (match_operand:BLK 0 "memory_operand" "")
2682 (match_operand:BLK 1 "memory_operand" ""))
2683 (use (match_operand 2 "nonmemory_operand" ""))
2684 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2685 (clobber (match_dup 3))])]
2686 ""
2687 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2688
2689 (define_insn "*movmem_short"
2690 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2691 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
2692 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2693 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
2694 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
2695 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
2696 "#"
2697 [(set_attr "type" "cs")
2698 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
2699
2700 (define_split
2701 [(set (match_operand:BLK 0 "memory_operand" "")
2702 (match_operand:BLK 1 "memory_operand" ""))
2703 (use (match_operand 2 "const_int_operand" ""))
2704 (use (match_operand 3 "immediate_operand" ""))
2705 (clobber (scratch))]
2706 "reload_completed"
2707 [(parallel
2708 [(set (match_dup 0) (match_dup 1))
2709 (use (match_dup 2))])]
2710 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2711
2712 (define_split
2713 [(set (match_operand:BLK 0 "memory_operand" "")
2714 (match_operand:BLK 1 "memory_operand" ""))
2715 (use (match_operand 2 "register_operand" ""))
2716 (use (match_operand 3 "memory_operand" ""))
2717 (clobber (scratch))]
2718 "reload_completed"
2719 [(parallel
2720 [(unspec [(match_dup 2) (match_dup 3)
2721 (const_int 0)] UNSPEC_EXECUTE)
2722 (set (match_dup 0) (match_dup 1))
2723 (use (const_int 1))])]
2724 "")
2725
2726 (define_split
2727 [(set (match_operand:BLK 0 "memory_operand" "")
2728 (match_operand:BLK 1 "memory_operand" ""))
2729 (use (match_operand 2 "register_operand" ""))
2730 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2731 (clobber (scratch))]
2732 "TARGET_Z10 && reload_completed"
2733 [(parallel
2734 [(unspec [(match_dup 2) (const_int 0)
2735 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2736 (set (match_dup 0) (match_dup 1))
2737 (use (const_int 1))])]
2738 "operands[3] = gen_label_rtx ();")
2739
2740 (define_split
2741 [(set (match_operand:BLK 0 "memory_operand" "")
2742 (match_operand:BLK 1 "memory_operand" ""))
2743 (use (match_operand 2 "register_operand" ""))
2744 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2745 (clobber (match_operand 3 "register_operand" ""))]
2746 "reload_completed && TARGET_CPU_ZARCH"
2747 [(set (match_dup 3) (label_ref (match_dup 4)))
2748 (parallel
2749 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2750 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2751 (set (match_dup 0) (match_dup 1))
2752 (use (const_int 1))])]
2753 "operands[4] = gen_label_rtx ();")
2754
2755 ; Move a block of arbitrary length.
2756
2757 (define_expand "movmem_long"
2758 [(parallel
2759 [(clobber (match_dup 2))
2760 (clobber (match_dup 3))
2761 (set (match_operand:BLK 0 "memory_operand" "")
2762 (match_operand:BLK 1 "memory_operand" ""))
2763 (use (match_operand 2 "general_operand" ""))
2764 (use (match_dup 3))
2765 (clobber (reg:CC CC_REGNUM))])]
2766 ""
2767 {
2768 enum machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
2769 enum machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
2770 rtx reg0 = gen_reg_rtx (dreg_mode);
2771 rtx reg1 = gen_reg_rtx (dreg_mode);
2772 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
2773 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
2774 rtx len0 = gen_lowpart (Pmode, reg0);
2775 rtx len1 = gen_lowpart (Pmode, reg1);
2776
2777 emit_clobber (reg0);
2778 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2779 emit_move_insn (len0, operands[2]);
2780
2781 emit_clobber (reg1);
2782 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2783 emit_move_insn (len1, operands[2]);
2784
2785 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2786 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2787 operands[2] = reg0;
2788 operands[3] = reg1;
2789 })
2790
2791 (define_insn "*movmem_long"
2792 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2793 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2794 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2795 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
2796 (use (match_dup 2))
2797 (use (match_dup 3))
2798 (clobber (reg:CC CC_REGNUM))]
2799 "TARGET_64BIT || !TARGET_ZARCH"
2800 "mvcle\t%0,%1,0\;jo\t.-4"
2801 [(set_attr "length" "8")
2802 (set_attr "type" "vs")])
2803
2804 (define_insn "*movmem_long_31z"
2805 [(clobber (match_operand:TI 0 "register_operand" "=d"))
2806 (clobber (match_operand:TI 1 "register_operand" "=d"))
2807 (set (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
2808 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4)))
2809 (use (match_dup 2))
2810 (use (match_dup 3))
2811 (clobber (reg:CC CC_REGNUM))]
2812 "!TARGET_64BIT && TARGET_ZARCH"
2813 "mvcle\t%0,%1,0\;jo\t.-4"
2814 [(set_attr "length" "8")
2815 (set_attr "type" "vs")])
2816
2817
2818 ;
2819 ; Test data class.
2820 ;
2821
2822 (define_expand "signbit<mode>2"
2823 [(set (reg:CCZ CC_REGNUM)
2824 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2825 (match_dup 2)]
2826 UNSPEC_TDC_INSN))
2827 (set (match_operand:SI 0 "register_operand" "=d")
2828 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2829 "TARGET_HARD_FLOAT"
2830 {
2831 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
2832 })
2833
2834 (define_expand "isinf<mode>2"
2835 [(set (reg:CCZ CC_REGNUM)
2836 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2837 (match_dup 2)]
2838 UNSPEC_TDC_INSN))
2839 (set (match_operand:SI 0 "register_operand" "=d")
2840 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2841 "TARGET_HARD_FLOAT"
2842 {
2843 operands[2] = GEN_INT (S390_TDC_INFINITY);
2844 })
2845
2846 ; This insn is used to generate all variants of the Test Data Class
2847 ; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
2848 ; is the register to be tested and the second one is the bit mask
2849 ; specifying the required test(s).
2850 ;
2851 ; tcxb, tcdb, tceb, tdcxt, tdcdt, tdcet
2852 (define_insn "*TDC_insn_<mode>"
2853 [(set (reg:CCZ CC_REGNUM)
2854 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
2855 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
2856 "TARGET_HARD_FLOAT"
2857 "t<_d>c<xde><bt>\t%0,%1"
2858 [(set_attr "op_type" "RXE")
2859 (set_attr "type" "fsimp<mode>")])
2860
2861 (define_insn_and_split "*ccz_to_int"
2862 [(set (match_operand:SI 0 "register_operand" "=d")
2863 (unspec:SI [(match_operand:CCZ 1 "register_operand" "0")]
2864 UNSPEC_CCZ_TO_INT))]
2865 ""
2866 "#"
2867 "reload_completed"
2868 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
2869
2870
2871 ;
2872 ; setmemM instruction pattern(s).
2873 ;
2874
2875 (define_expand "setmem<mode>"
2876 [(set (match_operand:BLK 0 "memory_operand" "")
2877 (match_operand:QI 2 "general_operand" ""))
2878 (use (match_operand:GPR 1 "general_operand" ""))
2879 (match_operand 3 "" "")]
2880 ""
2881 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
2882
2883 ; Clear a block that is up to 256 bytes in length.
2884 ; The block length is taken as (operands[1] % 256) + 1.
2885
2886 (define_expand "clrmem_short"
2887 [(parallel
2888 [(set (match_operand:BLK 0 "memory_operand" "")
2889 (const_int 0))
2890 (use (match_operand 1 "nonmemory_operand" ""))
2891 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2892 (clobber (match_dup 2))
2893 (clobber (reg:CC CC_REGNUM))])]
2894 ""
2895 "operands[2] = gen_rtx_SCRATCH (Pmode);")
2896
2897 (define_insn "*clrmem_short"
2898 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2899 (const_int 0))
2900 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
2901 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
2902 (clobber (match_scratch:P 3 "=X,X,X,&a"))
2903 (clobber (reg:CC CC_REGNUM))]
2904 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)"
2905 "#"
2906 [(set_attr "type" "cs")
2907 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
2908
2909 (define_split
2910 [(set (match_operand:BLK 0 "memory_operand" "")
2911 (const_int 0))
2912 (use (match_operand 1 "const_int_operand" ""))
2913 (use (match_operand 2 "immediate_operand" ""))
2914 (clobber (scratch))
2915 (clobber (reg:CC CC_REGNUM))]
2916 "reload_completed"
2917 [(parallel
2918 [(set (match_dup 0) (const_int 0))
2919 (use (match_dup 1))
2920 (clobber (reg:CC CC_REGNUM))])]
2921 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
2922
2923 (define_split
2924 [(set (match_operand:BLK 0 "memory_operand" "")
2925 (const_int 0))
2926 (use (match_operand 1 "register_operand" ""))
2927 (use (match_operand 2 "memory_operand" ""))
2928 (clobber (scratch))
2929 (clobber (reg:CC CC_REGNUM))]
2930 "reload_completed"
2931 [(parallel
2932 [(unspec [(match_dup 1) (match_dup 2)
2933 (const_int 0)] UNSPEC_EXECUTE)
2934 (set (match_dup 0) (const_int 0))
2935 (use (const_int 1))
2936 (clobber (reg:CC CC_REGNUM))])]
2937 "")
2938
2939 (define_split
2940 [(set (match_operand:BLK 0 "memory_operand" "")
2941 (const_int 0))
2942 (use (match_operand 1 "register_operand" ""))
2943 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2944 (clobber (scratch))
2945 (clobber (reg:CC CC_REGNUM))]
2946 "TARGET_Z10 && reload_completed"
2947 [(parallel
2948 [(unspec [(match_dup 1) (const_int 0)
2949 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2950 (set (match_dup 0) (const_int 0))
2951 (use (const_int 1))
2952 (clobber (reg:CC CC_REGNUM))])]
2953 "operands[3] = gen_label_rtx ();")
2954
2955 (define_split
2956 [(set (match_operand:BLK 0 "memory_operand" "")
2957 (const_int 0))
2958 (use (match_operand 1 "register_operand" ""))
2959 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2960 (clobber (match_operand 2 "register_operand" ""))
2961 (clobber (reg:CC CC_REGNUM))]
2962 "reload_completed && TARGET_CPU_ZARCH"
2963 [(set (match_dup 2) (label_ref (match_dup 3)))
2964 (parallel
2965 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
2966 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2967 (set (match_dup 0) (const_int 0))
2968 (use (const_int 1))
2969 (clobber (reg:CC CC_REGNUM))])]
2970 "operands[3] = gen_label_rtx ();")
2971
2972 ; Initialize a block of arbitrary length with (operands[2] % 256).
2973
2974 (define_expand "setmem_long"
2975 [(parallel
2976 [(clobber (match_dup 1))
2977 (set (match_operand:BLK 0 "memory_operand" "")
2978 (match_operand 2 "shift_count_or_setmem_operand" ""))
2979 (use (match_operand 1 "general_operand" ""))
2980 (use (match_dup 3))
2981 (clobber (reg:CC CC_REGNUM))])]
2982 ""
2983 {
2984 enum machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
2985 enum machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
2986 rtx reg0 = gen_reg_rtx (dreg_mode);
2987 rtx reg1 = gen_reg_rtx (dreg_mode);
2988 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
2989 rtx len0 = gen_lowpart (Pmode, reg0);
2990
2991 emit_clobber (reg0);
2992 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2993 emit_move_insn (len0, operands[1]);
2994
2995 emit_move_insn (reg1, const0_rtx);
2996
2997 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2998 operands[1] = reg0;
2999 operands[3] = reg1;
3000 })
3001
3002 (define_insn "*setmem_long"
3003 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3004 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3005 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
3006 (use (match_dup 3))
3007 (use (match_operand:<DBL> 1 "register_operand" "d"))
3008 (clobber (reg:CC CC_REGNUM))]
3009 "TARGET_64BIT || !TARGET_ZARCH"
3010 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3011 [(set_attr "length" "8")
3012 (set_attr "type" "vs")])
3013
3014 (define_insn "*setmem_long_and"
3015 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3016 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3017 (and (match_operand 2 "shift_count_or_setmem_operand" "Y")
3018 (match_operand 4 "const_int_operand" "n")))
3019 (use (match_dup 3))
3020 (use (match_operand:<DBL> 1 "register_operand" "d"))
3021 (clobber (reg:CC CC_REGNUM))]
3022 "(TARGET_64BIT || !TARGET_ZARCH) &&
3023 (INTVAL (operands[4]) & 255) == 255"
3024 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3025 [(set_attr "length" "8")
3026 (set_attr "type" "vs")])
3027
3028 (define_insn "*setmem_long_31z"
3029 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3030 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
3031 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
3032 (use (match_dup 3))
3033 (use (match_operand:TI 1 "register_operand" "d"))
3034 (clobber (reg:CC CC_REGNUM))]
3035 "!TARGET_64BIT && TARGET_ZARCH"
3036 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3037 [(set_attr "length" "8")
3038 (set_attr "type" "vs")])
3039
3040 ;
3041 ; cmpmemM instruction pattern(s).
3042 ;
3043
3044 (define_expand "cmpmemsi"
3045 [(set (match_operand:SI 0 "register_operand" "")
3046 (compare:SI (match_operand:BLK 1 "memory_operand" "")
3047 (match_operand:BLK 2 "memory_operand" "") ) )
3048 (use (match_operand:SI 3 "general_operand" ""))
3049 (use (match_operand:SI 4 "" ""))]
3050 ""
3051 {
3052 if (s390_expand_cmpmem (operands[0], operands[1],
3053 operands[2], operands[3]))
3054 DONE;
3055 else
3056 FAIL;
3057 })
3058
3059 ; Compare a block that is up to 256 bytes in length.
3060 ; The block length is taken as (operands[2] % 256) + 1.
3061
3062 (define_expand "cmpmem_short"
3063 [(parallel
3064 [(set (reg:CCU CC_REGNUM)
3065 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3066 (match_operand:BLK 1 "memory_operand" "")))
3067 (use (match_operand 2 "nonmemory_operand" ""))
3068 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3069 (clobber (match_dup 3))])]
3070 ""
3071 "operands[3] = gen_rtx_SCRATCH (Pmode);")
3072
3073 (define_insn "*cmpmem_short"
3074 [(set (reg:CCU CC_REGNUM)
3075 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
3076 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
3077 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3078 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
3079 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3080 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
3081 "#"
3082 [(set_attr "type" "cs")
3083 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
3084
3085 (define_split
3086 [(set (reg:CCU CC_REGNUM)
3087 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3088 (match_operand:BLK 1 "memory_operand" "")))
3089 (use (match_operand 2 "const_int_operand" ""))
3090 (use (match_operand 3 "immediate_operand" ""))
3091 (clobber (scratch))]
3092 "reload_completed"
3093 [(parallel
3094 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3095 (use (match_dup 2))])]
3096 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
3097
3098 (define_split
3099 [(set (reg:CCU CC_REGNUM)
3100 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3101 (match_operand:BLK 1 "memory_operand" "")))
3102 (use (match_operand 2 "register_operand" ""))
3103 (use (match_operand 3 "memory_operand" ""))
3104 (clobber (scratch))]
3105 "reload_completed"
3106 [(parallel
3107 [(unspec [(match_dup 2) (match_dup 3)
3108 (const_int 0)] UNSPEC_EXECUTE)
3109 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3110 (use (const_int 1))])]
3111 "")
3112
3113 (define_split
3114 [(set (reg:CCU CC_REGNUM)
3115 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3116 (match_operand:BLK 1 "memory_operand" "")))
3117 (use (match_operand 2 "register_operand" ""))
3118 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3119 (clobber (scratch))]
3120 "TARGET_Z10 && reload_completed"
3121 [(parallel
3122 [(unspec [(match_dup 2) (const_int 0)
3123 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3124 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3125 (use (const_int 1))])]
3126 "operands[4] = gen_label_rtx ();")
3127
3128 (define_split
3129 [(set (reg:CCU CC_REGNUM)
3130 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3131 (match_operand:BLK 1 "memory_operand" "")))
3132 (use (match_operand 2 "register_operand" ""))
3133 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3134 (clobber (match_operand 3 "register_operand" ""))]
3135 "reload_completed && TARGET_CPU_ZARCH"
3136 [(set (match_dup 3) (label_ref (match_dup 4)))
3137 (parallel
3138 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
3139 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3140 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3141 (use (const_int 1))])]
3142 "operands[4] = gen_label_rtx ();")
3143
3144 ; Compare a block of arbitrary length.
3145
3146 (define_expand "cmpmem_long"
3147 [(parallel
3148 [(clobber (match_dup 2))
3149 (clobber (match_dup 3))
3150 (set (reg:CCU CC_REGNUM)
3151 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3152 (match_operand:BLK 1 "memory_operand" "")))
3153 (use (match_operand 2 "general_operand" ""))
3154 (use (match_dup 3))])]
3155 ""
3156 {
3157 enum machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3158 enum machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
3159 rtx reg0 = gen_reg_rtx (dreg_mode);
3160 rtx reg1 = gen_reg_rtx (dreg_mode);
3161 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3162 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
3163 rtx len0 = gen_lowpart (Pmode, reg0);
3164 rtx len1 = gen_lowpart (Pmode, reg1);
3165
3166 emit_clobber (reg0);
3167 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3168 emit_move_insn (len0, operands[2]);
3169
3170 emit_clobber (reg1);
3171 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3172 emit_move_insn (len1, operands[2]);
3173
3174 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3175 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3176 operands[2] = reg0;
3177 operands[3] = reg1;
3178 })
3179
3180 (define_insn "*cmpmem_long"
3181 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3182 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3183 (set (reg:CCU CC_REGNUM)
3184 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3185 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
3186 (use (match_dup 2))
3187 (use (match_dup 3))]
3188 "TARGET_64BIT || !TARGET_ZARCH"
3189 "clcle\t%0,%1,0\;jo\t.-4"
3190 [(set_attr "length" "8")
3191 (set_attr "type" "vs")])
3192
3193 (define_insn "*cmpmem_long_31z"
3194 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3195 (clobber (match_operand:TI 1 "register_operand" "=d"))
3196 (set (reg:CCU CC_REGNUM)
3197 (compare:CCU (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3198 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4))))
3199 (use (match_dup 2))
3200 (use (match_dup 3))]
3201 "!TARGET_64BIT && TARGET_ZARCH"
3202 "clcle\t%0,%1,0\;jo\t.-4"
3203 [(set_attr "op_type" "NN")
3204 (set_attr "type" "vs")
3205 (set_attr "length" "8")])
3206
3207 ; Convert CCUmode condition code to integer.
3208 ; Result is zero if EQ, positive if LTU, negative if GTU.
3209
3210 (define_insn_and_split "cmpint"
3211 [(set (match_operand:SI 0 "register_operand" "=d")
3212 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3213 UNSPEC_CCU_TO_INT))
3214 (clobber (reg:CC CC_REGNUM))]
3215 ""
3216 "#"
3217 "reload_completed"
3218 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3219 (parallel
3220 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
3221 (clobber (reg:CC CC_REGNUM))])])
3222
3223 (define_insn_and_split "*cmpint_cc"
3224 [(set (reg CC_REGNUM)
3225 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3226 UNSPEC_CCU_TO_INT)
3227 (const_int 0)))
3228 (set (match_operand:SI 0 "register_operand" "=d")
3229 (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT))]
3230 "s390_match_ccmode (insn, CCSmode)"
3231 "#"
3232 "&& reload_completed"
3233 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3234 (parallel
3235 [(set (match_dup 2) (match_dup 3))
3236 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
3237 {
3238 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3239 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3240 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3241 })
3242
3243 (define_insn_and_split "*cmpint_sign"
3244 [(set (match_operand:DI 0 "register_operand" "=d")
3245 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3246 UNSPEC_CCU_TO_INT)))
3247 (clobber (reg:CC CC_REGNUM))]
3248 "TARGET_ZARCH"
3249 "#"
3250 "&& reload_completed"
3251 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3252 (parallel
3253 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
3254 (clobber (reg:CC CC_REGNUM))])])
3255
3256 (define_insn_and_split "*cmpint_sign_cc"
3257 [(set (reg CC_REGNUM)
3258 (compare (ashiftrt:DI (ashift:DI (subreg:DI
3259 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3260 UNSPEC_CCU_TO_INT) 0)
3261 (const_int 32)) (const_int 32))
3262 (const_int 0)))
3263 (set (match_operand:DI 0 "register_operand" "=d")
3264 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT)))]
3265 "s390_match_ccmode (insn, CCSmode) && TARGET_ZARCH"
3266 "#"
3267 "&& reload_completed"
3268 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3269 (parallel
3270 [(set (match_dup 2) (match_dup 3))
3271 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
3272 {
3273 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3274 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3275 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3276 })
3277
3278
3279 ;;
3280 ;;- Conversion instructions.
3281 ;;
3282
3283 (define_insn "*sethighpartsi"
3284 [(set (match_operand:SI 0 "register_operand" "=d,d")
3285 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3286 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3287 (clobber (reg:CC CC_REGNUM))]
3288 ""
3289 "@
3290 icm\t%0,%2,%S1
3291 icmy\t%0,%2,%S1"
3292 [(set_attr "op_type" "RS,RSY")
3293 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3294
3295 (define_insn "*sethighpartdi_64"
3296 [(set (match_operand:DI 0 "register_operand" "=d")
3297 (unspec:DI [(match_operand:BLK 1 "s_operand" "QS")
3298 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
3299 (clobber (reg:CC CC_REGNUM))]
3300 "TARGET_ZARCH"
3301 "icmh\t%0,%2,%S1"
3302 [(set_attr "op_type" "RSY")
3303 (set_attr "z10prop" "z10_super")])
3304
3305 (define_insn "*sethighpartdi_31"
3306 [(set (match_operand:DI 0 "register_operand" "=d,d")
3307 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3308 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3309 (clobber (reg:CC CC_REGNUM))]
3310 "!TARGET_ZARCH"
3311 "@
3312 icm\t%0,%2,%S1
3313 icmy\t%0,%2,%S1"
3314 [(set_attr "op_type" "RS,RSY")
3315 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3316
3317 ;
3318 ; extv instruction patterns
3319 ;
3320
3321 ; FIXME: This expander needs to be converted from DI to GPR as well
3322 ; after resolving some issues with it.
3323
3324 (define_expand "extzv"
3325 [(parallel
3326 [(set (match_operand:DI 0 "register_operand" "=d")
3327 (zero_extract:DI
3328 (match_operand:DI 1 "register_operand" "d")
3329 (match_operand 2 "const_int_operand" "") ; size
3330 (match_operand 3 "const_int_operand" ""))) ; start
3331 (clobber (reg:CC CC_REGNUM))])]
3332 "TARGET_Z10"
3333 {
3334 /* Starting with zEC12 there is risbgn not clobbering CC. */
3335 if (TARGET_ZEC12)
3336 {
3337 emit_move_insn (operands[0],
3338 gen_rtx_ZERO_EXTRACT (DImode,
3339 operands[1],
3340 operands[2],
3341 operands[3]));
3342 DONE;
3343 }
3344 })
3345
3346 (define_insn "*extzv<mode>_zEC12"
3347 [(set (match_operand:GPR 0 "register_operand" "=d")
3348 (zero_extract:GPR
3349 (match_operand:GPR 1 "register_operand" "d")
3350 (match_operand 2 "const_int_operand" "") ; size
3351 (match_operand 3 "const_int_operand" "")))] ; start]
3352 "TARGET_ZEC12"
3353 "risbgn\t%0,%1,64-%2,128+63,<bitsize>+%3+%2" ; dst, src, start, end, shift
3354 [(set_attr "op_type" "RIE")])
3355
3356 (define_insn "*extzv<mode>_z10"
3357 [(set (match_operand:GPR 0 "register_operand" "=d")
3358 (zero_extract:GPR
3359 (match_operand:GPR 1 "register_operand" "d")
3360 (match_operand 2 "const_int_operand" "") ; size
3361 (match_operand 3 "const_int_operand" ""))) ; start
3362 (clobber (reg:CC CC_REGNUM))]
3363 "TARGET_Z10"
3364 "risbg\t%0,%1,64-%2,128+63,<bitsize>+%3+%2" ; dst, src, start, end, shift
3365 [(set_attr "op_type" "RIE")
3366 (set_attr "z10prop" "z10_super_E1")])
3367
3368 (define_insn_and_split "*pre_z10_extzv<mode>"
3369 [(set (match_operand:GPR 0 "register_operand" "=d")
3370 (zero_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3371 (match_operand 2 "nonzero_shift_count_operand" "")
3372 (const_int 0)))
3373 (clobber (reg:CC CC_REGNUM))]
3374 "!TARGET_Z10"
3375 "#"
3376 "&& reload_completed"
3377 [(parallel
3378 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3379 (clobber (reg:CC CC_REGNUM))])
3380 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
3381 {
3382 int bitsize = INTVAL (operands[2]);
3383 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3384 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3385
3386 operands[1] = adjust_address (operands[1], BLKmode, 0);
3387 set_mem_size (operands[1], size);
3388 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
3389 operands[3] = GEN_INT (mask);
3390 })
3391
3392 (define_insn_and_split "*pre_z10_extv<mode>"
3393 [(set (match_operand:GPR 0 "register_operand" "=d")
3394 (sign_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3395 (match_operand 2 "nonzero_shift_count_operand" "")
3396 (const_int 0)))
3397 (clobber (reg:CC CC_REGNUM))]
3398 ""
3399 "#"
3400 "&& reload_completed"
3401 [(parallel
3402 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3403 (clobber (reg:CC CC_REGNUM))])
3404 (parallel
3405 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3406 (clobber (reg:CC CC_REGNUM))])]
3407 {
3408 int bitsize = INTVAL (operands[2]);
3409 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3410 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3411
3412 operands[1] = adjust_address (operands[1], BLKmode, 0);
3413 set_mem_size (operands[1], size);
3414 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
3415 operands[3] = GEN_INT (mask);
3416 })
3417
3418 ;
3419 ; insv instruction patterns
3420 ;
3421
3422 (define_expand "insv"
3423 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3424 (match_operand 1 "const_int_operand" "")
3425 (match_operand 2 "const_int_operand" ""))
3426 (match_operand 3 "general_operand" ""))]
3427 ""
3428 {
3429 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3430 DONE;
3431 FAIL;
3432 })
3433
3434
3435 ; The normal RTL expansion will never generate a zero_extract where
3436 ; the location operand isn't word mode. However, we do this in the
3437 ; back-end when generating atomic operations. See s390_two_part_insv.
3438 (define_insn "*insv<mode>_zEC12"
3439 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
3440 (match_operand 1 "const_int_operand" "I") ; size
3441 (match_operand 2 "const_int_operand" "I")) ; pos
3442 (match_operand:GPR 3 "nonimmediate_operand" "d"))]
3443 "TARGET_ZEC12
3444 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
3445 "risbgn\t%0,%3,64-<bitsize>+%2,64-<bitsize>+%2+%1-1,<bitsize>-%2-%1"
3446 [(set_attr "op_type" "RIE")])
3447
3448 (define_insn "*insv<mode>_z10"
3449 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
3450 (match_operand 1 "const_int_operand" "I") ; size
3451 (match_operand 2 "const_int_operand" "I")) ; pos
3452 (match_operand:GPR 3 "nonimmediate_operand" "d"))
3453 (clobber (reg:CC CC_REGNUM))]
3454 "TARGET_Z10
3455 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
3456 "risbg\t%0,%3,64-<bitsize>+%2,64-<bitsize>+%2+%1-1,<bitsize>-%2-%1"
3457 [(set_attr "op_type" "RIE")
3458 (set_attr "z10prop" "z10_super_E1")])
3459
3460 ; and op1 with a mask being 1 for the selected bits and 0 for the rest
3461 ; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
3462 (define_insn "*insv<mode>_zEC12_noshift"
3463 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3464 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3465 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3466 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
3467 (match_operand:GPR 4 "const_int_operand" ""))))]
3468 "TARGET_ZEC12 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3469 "risbgn\t%0,%1,%<bfstart>2,%<bfend>2,0"
3470 [(set_attr "op_type" "RIE")])
3471
3472 (define_insn "*insv<mode>_z10_noshift"
3473 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3474 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3475 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3476 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
3477 (match_operand:GPR 4 "const_int_operand" ""))))
3478 (clobber (reg:CC CC_REGNUM))]
3479 "TARGET_Z10 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3480 "risbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
3481 [(set_attr "op_type" "RIE")
3482 (set_attr "z10prop" "z10_super_E1")])
3483
3484 (define_insn "*r<noxa>sbg_<mode>_noshift"
3485 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3486 (IXOR:GPR
3487 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3488 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3489 (match_operand:GPR 3 "nonimmediate_operand" "0")))
3490 (clobber (reg:CC CC_REGNUM))]
3491 "TARGET_Z10"
3492 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
3493 [(set_attr "op_type" "RIE")])
3494
3495 (define_insn "*r<noxa>sbg_di_rotl"
3496 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3497 (IXOR:DI
3498 (and:DI
3499 (rotate:DI
3500 (match_operand:DI 1 "nonimmediate_operand" "d")
3501 (match_operand:DI 3 "const_int_operand" ""))
3502 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
3503 (match_operand:DI 4 "nonimmediate_operand" "0")))
3504 (clobber (reg:CC CC_REGNUM))]
3505 "TARGET_Z10"
3506 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%b3"
3507 [(set_attr "op_type" "RIE")])
3508
3509 (define_insn "*r<noxa>sbg_<mode>_srl"
3510 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3511 (IXOR:GPR
3512 (and:GPR
3513 (lshiftrt:GPR
3514 (match_operand:GPR 1 "nonimmediate_operand" "d")
3515 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
3516 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3517 (match_operand:GPR 4 "nonimmediate_operand" "0")))
3518 (clobber (reg:CC CC_REGNUM))]
3519 "TARGET_Z10
3520 && s390_extzv_shift_ok (<bitsize>, 64 - INTVAL (operands[3]),
3521 INTVAL (operands[2]))"
3522 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,64-%3"
3523 [(set_attr "op_type" "RIE")])
3524
3525 (define_insn "*r<noxa>sbg_<mode>_sll"
3526 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3527 (IXOR:GPR
3528 (and:GPR
3529 (ashift:GPR
3530 (match_operand:GPR 1 "nonimmediate_operand" "d")
3531 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
3532 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3533 (match_operand:GPR 4 "nonimmediate_operand" "0")))
3534 (clobber (reg:CC CC_REGNUM))]
3535 "TARGET_Z10
3536 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[3]),
3537 INTVAL (operands[2]))"
3538 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%3"
3539 [(set_attr "op_type" "RIE")])
3540
3541 ;; These two are generated by combine for s.bf &= val.
3542 ;; ??? For bitfields smaller than 32-bits, we wind up with SImode
3543 ;; shifts and ands, which results in some truly awful patterns
3544 ;; including subregs of operations. Rather unnecessisarily, IMO.
3545 ;; Instead of
3546 ;;
3547 ;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
3548 ;; (const_int 24 [0x18])
3549 ;; (const_int 0 [0]))
3550 ;; (subreg:DI (and:SI (subreg:SI (lshiftrt:DI (reg/v:DI 50 [ s ])
3551 ;; (const_int 40 [0x28])) 4)
3552 ;; (reg:SI 4 %r4 [ y+4 ])) 0))
3553 ;;
3554 ;; we should instead generate
3555 ;;
3556 ;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
3557 ;; (const_int 24 [0x18])
3558 ;; (const_int 0 [0]))
3559 ;; (and:DI (lshiftrt:DI (reg/v:DI 50 [ s ])
3560 ;; (const_int 40 [0x28]))
3561 ;; (subreg:DI (reg:SI 4 %r4 [ y+4 ]) 0)))
3562 ;;
3563 ;; by noticing that we can push down the outer paradoxical subreg
3564 ;; into the operation.
3565
3566 (define_insn "*insv_rnsbg_noshift"
3567 [(set (zero_extract:DI
3568 (match_operand:DI 0 "nonimmediate_operand" "+d")
3569 (match_operand 1 "const_int_operand" "")
3570 (match_operand 2 "const_int_operand" ""))
3571 (and:DI
3572 (match_dup 0)
3573 (match_operand:DI 3 "nonimmediate_operand" "d")))
3574 (clobber (reg:CC CC_REGNUM))]
3575 "TARGET_Z10
3576 && INTVAL (operands[1]) + INTVAL (operands[2]) == 64"
3577 "rnsbg\t%0,%3,%2,63,0"
3578 [(set_attr "op_type" "RIE")])
3579
3580 (define_insn "*insv_rnsbg_srl"
3581 [(set (zero_extract:DI
3582 (match_operand:DI 0 "nonimmediate_operand" "+d")
3583 (match_operand 1 "const_int_operand" "")
3584 (match_operand 2 "const_int_operand" ""))
3585 (and:DI
3586 (lshiftrt:DI
3587 (match_dup 0)
3588 (match_operand 3 "const_int_operand" ""))
3589 (match_operand:DI 4 "nonimmediate_operand" "d")))
3590 (clobber (reg:CC CC_REGNUM))]
3591 "TARGET_Z10
3592 && INTVAL (operands[3]) == 64 - INTVAL (operands[1]) - INTVAL (operands[2])"
3593 "rnsbg\t%0,%4,%2,%2+%1-1,%3"
3594 [(set_attr "op_type" "RIE")])
3595
3596 (define_insn "*insv<mode>_mem_reg"
3597 [(set (zero_extract:W (match_operand:QI 0 "memory_operand" "+Q,S")
3598 (match_operand 1 "const_int_operand" "n,n")
3599 (const_int 0))
3600 (match_operand:W 2 "register_operand" "d,d"))]
3601 "INTVAL (operands[1]) > 0
3602 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3603 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3604 {
3605 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3606
3607 operands[1] = GEN_INT ((1ul << size) - 1);
3608 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
3609 : "stcmy\t%2,%1,%S0";
3610 }
3611 [(set_attr "op_type" "RS,RSY")
3612 (set_attr "z10prop" "z10_super,z10_super")])
3613
3614 (define_insn "*insvdi_mem_reghigh"
3615 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+QS")
3616 (match_operand 1 "const_int_operand" "n")
3617 (const_int 0))
3618 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
3619 (const_int 32)))]
3620 "TARGET_ZARCH
3621 && INTVAL (operands[1]) > 0
3622 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3623 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3624 {
3625 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3626
3627 operands[1] = GEN_INT ((1ul << size) - 1);
3628 return "stcmh\t%2,%1,%S0";
3629 }
3630 [(set_attr "op_type" "RSY")
3631 (set_attr "z10prop" "z10_super")])
3632
3633 (define_insn "*insvdi_reg_imm"
3634 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3635 (const_int 16)
3636 (match_operand 1 "const_int_operand" "n"))
3637 (match_operand:DI 2 "const_int_operand" "n"))]
3638 "TARGET_ZARCH
3639 && INTVAL (operands[1]) >= 0
3640 && INTVAL (operands[1]) < BITS_PER_WORD
3641 && INTVAL (operands[1]) % 16 == 0"
3642 {
3643 switch (BITS_PER_WORD - INTVAL (operands[1]))
3644 {
3645 case 64: return "iihh\t%0,%x2"; break;
3646 case 48: return "iihl\t%0,%x2"; break;
3647 case 32: return "iilh\t%0,%x2"; break;
3648 case 16: return "iill\t%0,%x2"; break;
3649 default: gcc_unreachable();
3650 }
3651 }
3652 [(set_attr "op_type" "RI")
3653 (set_attr "z10prop" "z10_super_E1")])
3654
3655 ; Update the left-most 32 bit of a DI.
3656 (define_insn "*insv_h_di_reg_extimm"
3657 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3658 (const_int 32)
3659 (const_int 0))
3660 (match_operand:DI 1 "const_int_operand" "n"))]
3661 "TARGET_EXTIMM"
3662 "iihf\t%0,%o1"
3663 [(set_attr "op_type" "RIL")
3664 (set_attr "z10prop" "z10_fwd_E1")])
3665
3666 ; Update the right-most 32 bit of a DI.
3667 (define_insn "*insv_l_di_reg_extimm"
3668 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3669 (const_int 32)
3670 (const_int 32))
3671 (match_operand:DI 1 "const_int_operand" "n"))]
3672 "TARGET_EXTIMM"
3673 "iilf\t%0,%o1"
3674 [(set_attr "op_type" "RIL")
3675 (set_attr "z10prop" "z10_fwd_A1")])
3676
3677 ;
3678 ; extendsidi2 instruction pattern(s).
3679 ;
3680
3681 (define_expand "extendsidi2"
3682 [(set (match_operand:DI 0 "register_operand" "")
3683 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3684 ""
3685 {
3686 if (!TARGET_ZARCH)
3687 {
3688 emit_clobber (operands[0]);
3689 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
3690 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
3691 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
3692 DONE;
3693 }
3694 })
3695
3696 (define_insn "*extendsidi2"
3697 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3698 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3699 "TARGET_ZARCH"
3700 "@
3701 lgfr\t%0,%1
3702 lgf\t%0,%1
3703 lgfrl\t%0,%1"
3704 [(set_attr "op_type" "RRE,RXY,RIL")
3705 (set_attr "type" "*,*,larl")
3706 (set_attr "cpu_facility" "*,*,z10")
3707 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3708
3709 ;
3710 ; extend(hi|qi)(si|di)2 instruction pattern(s).
3711 ;
3712
3713 (define_expand "extend<HQI:mode><DSI:mode>2"
3714 [(set (match_operand:DSI 0 "register_operand" "")
3715 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3716 ""
3717 {
3718 if (<DSI:MODE>mode == DImode && !TARGET_ZARCH)
3719 {
3720 rtx tmp = gen_reg_rtx (SImode);
3721 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
3722 emit_insn (gen_extendsidi2 (operands[0], tmp));
3723 DONE;
3724 }
3725 else if (!TARGET_EXTIMM)
3726 {
3727 rtx bitcount = GEN_INT (<DSI:bitsize> - <HQI:bitsize>);
3728
3729 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
3730 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
3731 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
3732 DONE;
3733 }
3734 })
3735
3736 ;
3737 ; extendhidi2 instruction pattern(s).
3738 ;
3739
3740 (define_insn "*extendhidi2_extimm"
3741 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3742 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,RT,b")))]
3743 "TARGET_ZARCH && TARGET_EXTIMM"
3744 "@
3745 lghr\t%0,%1
3746 lgh\t%0,%1
3747 lghrl\t%0,%1"
3748 [(set_attr "op_type" "RRE,RXY,RIL")
3749 (set_attr "type" "*,*,larl")
3750 (set_attr "cpu_facility" "extimm,extimm,z10")
3751 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3752
3753 (define_insn "*extendhidi2"
3754 [(set (match_operand:DI 0 "register_operand" "=d")
3755 (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT")))]
3756 "TARGET_ZARCH"
3757 "lgh\t%0,%1"
3758 [(set_attr "op_type" "RXY")
3759 (set_attr "z10prop" "z10_super_E1")])
3760
3761 ;
3762 ; extendhisi2 instruction pattern(s).
3763 ;
3764
3765 (define_insn "*extendhisi2_extimm"
3766 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3767 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
3768 "TARGET_EXTIMM"
3769 "@
3770 lhr\t%0,%1
3771 lh\t%0,%1
3772 lhy\t%0,%1
3773 lhrl\t%0,%1"
3774 [(set_attr "op_type" "RRE,RX,RXY,RIL")
3775 (set_attr "type" "*,*,*,larl")
3776 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
3777 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
3778
3779 (define_insn "*extendhisi2"
3780 [(set (match_operand:SI 0 "register_operand" "=d,d")
3781 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
3782 "!TARGET_EXTIMM"
3783 "@
3784 lh\t%0,%1
3785 lhy\t%0,%1"
3786 [(set_attr "op_type" "RX,RXY")
3787 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3788
3789 ;
3790 ; extendqi(si|di)2 instruction pattern(s).
3791 ;
3792
3793 ; lbr, lgbr, lb, lgb
3794 (define_insn "*extendqi<mode>2_extimm"
3795 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3796 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,RT")))]
3797 "TARGET_EXTIMM"
3798 "@
3799 l<g>br\t%0,%1
3800 l<g>b\t%0,%1"
3801 [(set_attr "op_type" "RRE,RXY")
3802 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3803
3804 ; lb, lgb
3805 (define_insn "*extendqi<mode>2"
3806 [(set (match_operand:GPR 0 "register_operand" "=d")
3807 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "RT")))]
3808 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
3809 "l<g>b\t%0,%1"
3810 [(set_attr "op_type" "RXY")
3811 (set_attr "z10prop" "z10_super_E1")])
3812
3813 (define_insn_and_split "*extendqi<mode>2_short_displ"
3814 [(set (match_operand:GPR 0 "register_operand" "=d")
3815 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
3816 (clobber (reg:CC CC_REGNUM))]
3817 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
3818 "#"
3819 "&& reload_completed"
3820 [(parallel
3821 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
3822 (clobber (reg:CC CC_REGNUM))])
3823 (parallel
3824 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3825 (clobber (reg:CC CC_REGNUM))])]
3826 {
3827 operands[1] = adjust_address (operands[1], BLKmode, 0);
3828 set_mem_size (operands[1], GET_MODE_SIZE (QImode));
3829 operands[2] = GEN_INT (<GPR:bitsize> - BITS_PER_UNIT);
3830 })
3831
3832 ;
3833 ; zero_extendsidi2 instruction pattern(s).
3834 ;
3835
3836 (define_expand "zero_extendsidi2"
3837 [(set (match_operand:DI 0 "register_operand" "")
3838 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3839 ""
3840 {
3841 if (!TARGET_ZARCH)
3842 {
3843 emit_clobber (operands[0]);
3844 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
3845 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
3846 DONE;
3847 }
3848 })
3849
3850 (define_insn "*zero_extendsidi2"
3851 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3852 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3853 "TARGET_ZARCH"
3854 "@
3855 llgfr\t%0,%1
3856 llgf\t%0,%1
3857 llgfrl\t%0,%1"
3858 [(set_attr "op_type" "RRE,RXY,RIL")
3859 (set_attr "type" "*,*,larl")
3860 (set_attr "cpu_facility" "*,*,z10")
3861 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
3862
3863 ;
3864 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
3865 ;
3866
3867 (define_insn "*llgt_sidi"
3868 [(set (match_operand:DI 0 "register_operand" "=d")
3869 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3870 (const_int 2147483647)))]
3871 "TARGET_ZARCH"
3872 "llgt\t%0,%1"
3873 [(set_attr "op_type" "RXE")
3874 (set_attr "z10prop" "z10_super_E1")])
3875
3876 (define_insn_and_split "*llgt_sidi_split"
3877 [(set (match_operand:DI 0 "register_operand" "=d")
3878 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3879 (const_int 2147483647)))
3880 (clobber (reg:CC CC_REGNUM))]
3881 "TARGET_ZARCH"
3882 "#"
3883 "&& reload_completed"
3884 [(set (match_dup 0)
3885 (and:DI (subreg:DI (match_dup 1) 0)
3886 (const_int 2147483647)))]
3887 "")
3888
3889 (define_insn "*llgt_sisi"
3890 [(set (match_operand:SI 0 "register_operand" "=d,d")
3891 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,RT")
3892 (const_int 2147483647)))]
3893 "TARGET_ZARCH"
3894 "@
3895 llgtr\t%0,%1
3896 llgt\t%0,%1"
3897 [(set_attr "op_type" "RRE,RXE")
3898 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3899
3900 (define_insn "*llgt_didi"
3901 [(set (match_operand:DI 0 "register_operand" "=d,d")
3902 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
3903 (const_int 2147483647)))]
3904 "TARGET_ZARCH"
3905 "@
3906 llgtr\t%0,%1
3907 llgt\t%0,%N1"
3908 [(set_attr "op_type" "RRE,RXE")
3909 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3910
3911 (define_split
3912 [(set (match_operand:DSI 0 "register_operand" "")
3913 (and:DSI (match_operand:DSI 1 "nonimmediate_operand" "")
3914 (const_int 2147483647)))
3915 (clobber (reg:CC CC_REGNUM))]
3916 "TARGET_ZARCH && reload_completed"
3917 [(set (match_dup 0)
3918 (and:DSI (match_dup 1)
3919 (const_int 2147483647)))]
3920 "")
3921
3922 ;
3923 ; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
3924 ;
3925
3926 (define_expand "zero_extend<mode>di2"
3927 [(set (match_operand:DI 0 "register_operand" "")
3928 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3929 ""
3930 {
3931 if (!TARGET_ZARCH)
3932 {
3933 rtx tmp = gen_reg_rtx (SImode);
3934 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
3935 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
3936 DONE;
3937 }
3938 else if (!TARGET_EXTIMM)
3939 {
3940 rtx bitcount = GEN_INT (64 - <HQI:bitsize>);
3941 operands[1] = gen_lowpart (DImode, operands[1]);
3942 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
3943 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
3944 DONE;
3945 }
3946 })
3947
3948 (define_expand "zero_extend<mode>si2"
3949 [(set (match_operand:SI 0 "register_operand" "")
3950 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3951 ""
3952 {
3953 if (!TARGET_EXTIMM)
3954 {
3955 operands[1] = gen_lowpart (SImode, operands[1]);
3956 emit_insn (gen_andsi3 (operands[0], operands[1],
3957 GEN_INT ((1 << <HQI:bitsize>) - 1)));
3958 DONE;
3959 }
3960 })
3961
3962 ; llhrl, llghrl
3963 (define_insn "*zero_extendhi<mode>2_z10"
3964 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
3965 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,RT,b")))]
3966 "TARGET_Z10"
3967 "@
3968 ll<g>hr\t%0,%1
3969 ll<g>h\t%0,%1
3970 ll<g>hrl\t%0,%1"
3971 [(set_attr "op_type" "RXY,RRE,RIL")
3972 (set_attr "type" "*,*,larl")
3973 (set_attr "cpu_facility" "*,*,z10")
3974 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
3975
3976 ; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
3977 (define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
3978 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3979 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,RT")))]
3980 "TARGET_EXTIMM"
3981 "@
3982 ll<g><hc>r\t%0,%1
3983 ll<g><hc>\t%0,%1"
3984 [(set_attr "op_type" "RRE,RXY")
3985 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
3986
3987 ; llgh, llgc
3988 (define_insn "*zero_extend<HQI:mode><GPR:mode>2"
3989 [(set (match_operand:GPR 0 "register_operand" "=d")
3990 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "RT")))]
3991 "TARGET_ZARCH && !TARGET_EXTIMM"
3992 "llg<hc>\t%0,%1"
3993 [(set_attr "op_type" "RXY")
3994 (set_attr "z10prop" "z10_fwd_A3")])
3995
3996 (define_insn_and_split "*zero_extendhisi2_31"
3997 [(set (match_operand:SI 0 "register_operand" "=&d")
3998 (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
3999 (clobber (reg:CC CC_REGNUM))]
4000 "!TARGET_ZARCH"
4001 "#"
4002 "&& reload_completed"
4003 [(set (match_dup 0) (const_int 0))
4004 (parallel
4005 [(set (strict_low_part (match_dup 2)) (match_dup 1))
4006 (clobber (reg:CC CC_REGNUM))])]
4007 "operands[2] = gen_lowpart (HImode, operands[0]);")
4008
4009 (define_insn_and_split "*zero_extendqisi2_31"
4010 [(set (match_operand:SI 0 "register_operand" "=&d")
4011 (zero_extend:SI (match_operand:QI 1 "memory_operand" "RT")))]
4012 "!TARGET_ZARCH"
4013 "#"
4014 "&& reload_completed"
4015 [(set (match_dup 0) (const_int 0))
4016 (set (strict_low_part (match_dup 2)) (match_dup 1))]
4017 "operands[2] = gen_lowpart (QImode, operands[0]);")
4018
4019 ;
4020 ; zero_extendqihi2 instruction pattern(s).
4021 ;
4022
4023 (define_expand "zero_extendqihi2"
4024 [(set (match_operand:HI 0 "register_operand" "")
4025 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
4026 "TARGET_ZARCH && !TARGET_EXTIMM"
4027 {
4028 operands[1] = gen_lowpart (HImode, operands[1]);
4029 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
4030 DONE;
4031 })
4032
4033 (define_insn "*zero_extendqihi2_64"
4034 [(set (match_operand:HI 0 "register_operand" "=d")
4035 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
4036 "TARGET_ZARCH && !TARGET_EXTIMM"
4037 "llgc\t%0,%1"
4038 [(set_attr "op_type" "RXY")
4039 (set_attr "z10prop" "z10_fwd_A3")])
4040
4041 (define_insn_and_split "*zero_extendqihi2_31"
4042 [(set (match_operand:HI 0 "register_operand" "=&d")
4043 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
4044 "!TARGET_ZARCH"
4045 "#"
4046 "&& reload_completed"
4047 [(set (match_dup 0) (const_int 0))
4048 (set (strict_low_part (match_dup 2)) (match_dup 1))]
4049 "operands[2] = gen_lowpart (QImode, operands[0]);")
4050
4051 ;
4052 ; fixuns_trunc(dd|td)di2 instruction pattern(s).
4053 ;
4054
4055 (define_expand "fixuns_truncdddi2"
4056 [(parallel
4057 [(set (match_operand:DI 0 "register_operand" "")
4058 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
4059 (unspec:DI [(const_int 5)] UNSPEC_ROUND)
4060 (clobber (reg:CC CC_REGNUM))])]
4061
4062 "TARGET_HARD_DFP"
4063 {
4064 if (!TARGET_Z196)
4065 {
4066 rtx label1 = gen_label_rtx ();
4067 rtx label2 = gen_label_rtx ();
4068 rtx temp = gen_reg_rtx (TDmode);
4069 REAL_VALUE_TYPE cmp, sub;
4070
4071 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4072 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4073
4074 /* 2^63 can't be represented as 64bit DFP number with full precision. The
4075 solution is doing the check and the subtraction in TD mode and using a
4076 TD -> DI convert afterwards. */
4077 emit_insn (gen_extendddtd2 (temp, operands[1]));
4078 temp = force_reg (TDmode, temp);
4079 emit_cmp_and_jump_insns (temp,
4080 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode),
4081 LT, NULL_RTX, VOIDmode, 0, label1);
4082 emit_insn (gen_subtd3 (temp, temp,
4083 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
4084 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
4085 emit_jump (label2);
4086
4087 emit_label (label1);
4088 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1], GEN_INT (9)));
4089 emit_label (label2);
4090 DONE;
4091 }
4092 })
4093
4094 (define_expand "fixuns_trunctddi2"
4095 [(parallel
4096 [(set (match_operand:DI 0 "register_operand" "")
4097 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))
4098 (unspec:DI [(const_int 5)] UNSPEC_ROUND)
4099 (clobber (reg:CC CC_REGNUM))])]
4100
4101 "TARGET_HARD_DFP"
4102 {
4103 if (!TARGET_Z196)
4104 {
4105 rtx label1 = gen_label_rtx ();
4106 rtx label2 = gen_label_rtx ();
4107 rtx temp = gen_reg_rtx (TDmode);
4108 REAL_VALUE_TYPE cmp, sub;
4109
4110 operands[1] = force_reg (TDmode, operands[1]);
4111 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4112 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4113
4114 emit_cmp_and_jump_insns (operands[1],
4115 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode),
4116 LT, NULL_RTX, VOIDmode, 0, label1);
4117 emit_insn (gen_subtd3 (temp, operands[1],
4118 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
4119 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
4120 emit_jump (label2);
4121
4122 emit_label (label1);
4123 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1], GEN_INT (9)));
4124 emit_label (label2);
4125 DONE;
4126 }
4127 })
4128
4129 ;
4130 ; fixuns_trunc(sf|df|tf)(si|di)2 and fix_trunc(sf|df|tf)(si|di)2
4131 ; instruction pattern(s).
4132 ;
4133
4134 (define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
4135 [(parallel
4136 [(set (match_operand:GPR 0 "register_operand" "")
4137 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))
4138 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
4139 (clobber (reg:CC CC_REGNUM))])]
4140 "TARGET_HARD_FLOAT"
4141 {
4142 if (!TARGET_Z196)
4143 {
4144 rtx label1 = gen_label_rtx ();
4145 rtx label2 = gen_label_rtx ();
4146 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
4147 REAL_VALUE_TYPE cmp, sub;
4148
4149 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
4150 real_2expN (&cmp, <GPR:bitsize> - 1, <BFP:MODE>mode);
4151 real_2expN (&sub, <GPR:bitsize>, <BFP:MODE>mode);
4152
4153 emit_cmp_and_jump_insns (operands[1],
4154 CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode),
4155 LT, NULL_RTX, VOIDmode, 0, label1);
4156 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
4157 CONST_DOUBLE_FROM_REAL_VALUE (sub, <BFP:MODE>mode)));
4158 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
4159 GEN_INT (7)));
4160 emit_jump (label2);
4161
4162 emit_label (label1);
4163 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
4164 operands[1], GEN_INT (5)));
4165 emit_label (label2);
4166 DONE;
4167 }
4168 })
4169
4170 ; fixuns_trunc(td|dd)si2 expander
4171 (define_expand "fixuns_trunc<mode>si2"
4172 [(parallel
4173 [(set (match_operand:SI 0 "register_operand" "")
4174 (unsigned_fix:SI (match_operand:DFP 1 "register_operand" "")))
4175 (unspec:SI [(const_int 5)] UNSPEC_ROUND)
4176 (clobber (reg:CC CC_REGNUM))])]
4177 "TARGET_Z196 && TARGET_HARD_DFP"
4178 "")
4179
4180 ; fixuns_trunc(tf|df|sf|td|dd)(di|si)2 instruction patterns.
4181
4182 ; clfebr, clfdbr, clfxbr, clgebr, clgdbr, clgxbr
4183 ; clfdtr, clfxtr, clgdtr, clgxtr
4184 (define_insn "*fixuns_trunc<FP:mode><GPR:mode>2_z196"
4185 [(set (match_operand:GPR 0 "register_operand" "=r")
4186 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "f")))
4187 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4188 (clobber (reg:CC CC_REGNUM))]
4189 "TARGET_Z196"
4190 "cl<GPR:gf><FP:xde><FP:bt>r\t%0,%h2,%1,0"
4191 [(set_attr "op_type" "RRF")
4192 (set_attr "type" "ftoi")])
4193
4194 (define_expand "fix_trunc<DSF:mode><GPR:mode>2"
4195 [(set (match_operand:GPR 0 "register_operand" "")
4196 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
4197 "TARGET_HARD_FLOAT"
4198 {
4199 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
4200 GEN_INT (5)));
4201 DONE;
4202 })
4203
4204 ; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
4205 (define_insn "fix_trunc<BFP:mode><GPR:mode>2_bfp"
4206 [(set (match_operand:GPR 0 "register_operand" "=d")
4207 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
4208 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4209 (clobber (reg:CC CC_REGNUM))]
4210 "TARGET_HARD_FLOAT"
4211 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
4212 [(set_attr "op_type" "RRE")
4213 (set_attr "type" "ftoi")])
4214
4215
4216 ;
4217 ; fix_trunc(td|dd)di2 instruction pattern(s).
4218 ;
4219
4220 (define_expand "fix_trunc<mode>di2"
4221 [(set (match_operand:DI 0 "register_operand" "")
4222 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
4223 "TARGET_ZARCH && TARGET_HARD_DFP"
4224 {
4225 operands[1] = force_reg (<MODE>mode, operands[1]);
4226 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
4227 GEN_INT (9)));
4228 DONE;
4229 })
4230
4231 ; cgxtr, cgdtr
4232 (define_insn "fix_trunc<DFP:mode>di2_dfp"
4233 [(set (match_operand:DI 0 "register_operand" "=d")
4234 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
4235 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
4236 (clobber (reg:CC CC_REGNUM))]
4237 "TARGET_ZARCH && TARGET_HARD_DFP"
4238 "cg<DFP:xde>tr\t%0,%h2,%1"
4239 [(set_attr "op_type" "RRF")
4240 (set_attr "type" "ftoidfp")])
4241
4242
4243 ;
4244 ; fix_trunctf(si|di)2 instruction pattern(s).
4245 ;
4246
4247 (define_expand "fix_trunctf<mode>2"
4248 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
4249 (fix:GPR (match_operand:TF 1 "register_operand" "")))
4250 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
4251 (clobber (reg:CC CC_REGNUM))])]
4252 "TARGET_HARD_FLOAT"
4253 "")
4254
4255
4256 ;
4257 ; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
4258 ;
4259
4260 ; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
4261 (define_insn "floatdi<mode>2"
4262 [(set (match_operand:FP 0 "register_operand" "=f")
4263 (float:FP (match_operand:DI 1 "register_operand" "d")))]
4264 "TARGET_ZARCH && TARGET_HARD_FLOAT"
4265 "c<xde>g<bt>r\t%0,%1"
4266 [(set_attr "op_type" "RRE")
4267 (set_attr "type" "itof<mode>" )])
4268
4269 ; cxfbr, cdfbr, cefbr
4270 (define_insn "floatsi<mode>2"
4271 [(set (match_operand:BFP 0 "register_operand" "=f")
4272 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
4273 "TARGET_HARD_FLOAT"
4274 "c<xde>fbr\t%0,%1"
4275 [(set_attr "op_type" "RRE")
4276 (set_attr "type" "itof<mode>" )])
4277
4278 ; cxftr, cdftr
4279 (define_insn "floatsi<mode>2"
4280 [(set (match_operand:DFP 0 "register_operand" "=f")
4281 (float:DFP (match_operand:SI 1 "register_operand" "d")))]
4282 "TARGET_Z196 && TARGET_HARD_FLOAT"
4283 "c<xde>ftr\t%0,0,%1,0"
4284 [(set_attr "op_type" "RRE")
4285 (set_attr "type" "itof<mode>" )])
4286
4287 ;
4288 ; floatuns(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
4289 ;
4290
4291 ; cxlgbr, cdlgbr, celgbr, cxlgtr, cdlgtr
4292 ; cxlfbr, cdlfbr, celfbr, cxlftr, cdlftr
4293 (define_insn "floatuns<GPR:mode><FP:mode>2"
4294 [(set (match_operand:FP 0 "register_operand" "=f")
4295 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "d")))]
4296 "TARGET_Z196 && TARGET_HARD_FLOAT"
4297 "c<FP:xde>l<GPR:gf><FP:bt>r\t%0,0,%1,0"
4298 [(set_attr "op_type" "RRE")
4299 (set_attr "type" "itof<FP:mode>" )])
4300
4301 ;
4302 ; truncdfsf2 instruction pattern(s).
4303 ;
4304
4305 (define_insn "truncdfsf2"
4306 [(set (match_operand:SF 0 "register_operand" "=f")
4307 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
4308 "TARGET_HARD_FLOAT"
4309 "ledbr\t%0,%1"
4310 [(set_attr "op_type" "RRE")
4311 (set_attr "type" "ftruncdf")])
4312
4313 ;
4314 ; trunctf(df|sf)2 instruction pattern(s).
4315 ;
4316
4317 ; ldxbr, lexbr
4318 (define_insn "trunctf<mode>2"
4319 [(set (match_operand:DSF 0 "register_operand" "=f")
4320 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
4321 (clobber (match_scratch:TF 2 "=f"))]
4322 "TARGET_HARD_FLOAT"
4323 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
4324 [(set_attr "length" "6")
4325 (set_attr "type" "ftrunctf")])
4326
4327 ;
4328 ; trunctddd2 and truncddsd2 instruction pattern(s).
4329 ;
4330
4331 (define_insn "trunctddd2"
4332 [(set (match_operand:DD 0 "register_operand" "=f")
4333 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
4334 (clobber (match_scratch:TD 2 "=f"))]
4335 "TARGET_HARD_DFP"
4336 "ldxtr\t%2,0,%1,0\;ldr\t%0,%2"
4337 [(set_attr "length" "6")
4338 (set_attr "type" "ftruncdd")])
4339
4340 (define_insn "truncddsd2"
4341 [(set (match_operand:SD 0 "register_operand" "=f")
4342 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
4343 "TARGET_HARD_DFP"
4344 "ledtr\t%0,0,%1,0"
4345 [(set_attr "op_type" "RRF")
4346 (set_attr "type" "ftruncsd")])
4347
4348 ;
4349 ; extend(sf|df)(df|tf)2 instruction pattern(s).
4350 ;
4351
4352 ; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
4353 (define_insn "extend<DSF:mode><BFP:mode>2"
4354 [(set (match_operand:BFP 0 "register_operand" "=f,f")
4355 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
4356 "TARGET_HARD_FLOAT
4357 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)"
4358 "@
4359 l<BFP:xde><DSF:xde>br\t%0,%1
4360 l<BFP:xde><DSF:xde>b\t%0,%1"
4361 [(set_attr "op_type" "RRE,RXE")
4362 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
4363
4364 ;
4365 ; extendddtd2 and extendsddd2 instruction pattern(s).
4366 ;
4367
4368 (define_insn "extendddtd2"
4369 [(set (match_operand:TD 0 "register_operand" "=f")
4370 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
4371 "TARGET_HARD_DFP"
4372 "lxdtr\t%0,%1,0"
4373 [(set_attr "op_type" "RRF")
4374 (set_attr "type" "fsimptf")])
4375
4376 (define_insn "extendsddd2"
4377 [(set (match_operand:DD 0 "register_operand" "=f")
4378 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
4379 "TARGET_HARD_DFP"
4380 "ldetr\t%0,%1,0"
4381 [(set_attr "op_type" "RRF")
4382 (set_attr "type" "fsimptf")])
4383
4384 ; Binary <-> Decimal floating point trunc patterns
4385 ;
4386
4387 (define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
4388 [(set (reg:DFP_ALL FPR0_REGNUM)
4389 (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
4390 (use (reg:SI GPR0_REGNUM))
4391 (clobber (reg:CC CC_REGNUM))]
4392 "TARGET_HARD_DFP"
4393 "pfpo")
4394
4395 (define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
4396 [(set (reg:BFP FPR0_REGNUM)
4397 (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
4398 (use (reg:SI GPR0_REGNUM))
4399 (clobber (reg:CC CC_REGNUM))]
4400 "TARGET_HARD_DFP"
4401 "pfpo")
4402
4403 (define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
4404 [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4405 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4406 (parallel
4407 [(set (reg:DFP_ALL FPR0_REGNUM)
4408 (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
4409 (use (reg:SI GPR0_REGNUM))
4410 (clobber (reg:CC CC_REGNUM))])
4411 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4412 (reg:DFP_ALL FPR0_REGNUM))]
4413 "TARGET_HARD_DFP
4414 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4415 {
4416 HOST_WIDE_INT flags;
4417
4418 flags = (PFPO_CONVERT |
4419 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4420 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4421
4422 operands[2] = GEN_INT (flags);
4423 })
4424
4425 (define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
4426 [(set (reg:DFP_ALL FPR2_REGNUM)
4427 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4428 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4429 (parallel
4430 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
4431 (use (reg:SI GPR0_REGNUM))
4432 (clobber (reg:CC CC_REGNUM))])
4433 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4434 "TARGET_HARD_DFP
4435 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
4436 {
4437 HOST_WIDE_INT flags;
4438
4439 flags = (PFPO_CONVERT |
4440 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4441 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4442
4443 operands[2] = GEN_INT (flags);
4444 })
4445
4446 ;
4447 ; Binary <-> Decimal floating point extend patterns
4448 ;
4449
4450 (define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
4451 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR2_REGNUM)))
4452 (use (reg:SI GPR0_REGNUM))
4453 (clobber (reg:CC CC_REGNUM))]
4454 "TARGET_HARD_DFP"
4455 "pfpo")
4456
4457 (define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
4458 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR2_REGNUM)))
4459 (use (reg:SI GPR0_REGNUM))
4460 (clobber (reg:CC CC_REGNUM))]
4461 "TARGET_HARD_DFP"
4462 "pfpo")
4463
4464 (define_expand "extend<BFP:mode><DFP_ALL:mode>2"
4465 [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4466 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4467 (parallel
4468 [(set (reg:DFP_ALL FPR0_REGNUM)
4469 (float_extend:DFP_ALL (reg:BFP FPR2_REGNUM)))
4470 (use (reg:SI GPR0_REGNUM))
4471 (clobber (reg:CC CC_REGNUM))])
4472 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4473 (reg:DFP_ALL FPR0_REGNUM))]
4474 "TARGET_HARD_DFP
4475 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4476 {
4477 HOST_WIDE_INT flags;
4478
4479 flags = (PFPO_CONVERT |
4480 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4481 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4482
4483 operands[2] = GEN_INT (flags);
4484 })
4485
4486 (define_expand "extend<DFP_ALL:mode><BFP:mode>2"
4487 [(set (reg:DFP_ALL FPR2_REGNUM)
4488 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4489 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4490 (parallel
4491 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR2_REGNUM)))
4492 (use (reg:SI GPR0_REGNUM))
4493 (clobber (reg:CC CC_REGNUM))])
4494 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4495 "TARGET_HARD_DFP
4496 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
4497 {
4498 HOST_WIDE_INT flags;
4499
4500 flags = (PFPO_CONVERT |
4501 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4502 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4503
4504 operands[2] = GEN_INT (flags);
4505 })
4506
4507
4508 ;;
4509 ;; ARITHMETIC OPERATIONS
4510 ;;
4511 ; arithmetic operations set the ConditionCode,
4512 ; because of unpredictable Bits in Register for Halfword and Byte
4513 ; the ConditionCode can be set wrong in operations for Halfword and Byte
4514
4515 ;;
4516 ;;- Add instructions.
4517 ;;
4518
4519 ;
4520 ; addti3 instruction pattern(s).
4521 ;
4522
4523 (define_insn_and_split "addti3"
4524 [(set (match_operand:TI 0 "register_operand" "=&d")
4525 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
4526 (match_operand:TI 2 "general_operand" "do") ) )
4527 (clobber (reg:CC CC_REGNUM))]
4528 "TARGET_ZARCH"
4529 "#"
4530 "&& reload_completed"
4531 [(parallel
4532 [(set (reg:CCL1 CC_REGNUM)
4533 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
4534 (match_dup 7)))
4535 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
4536 (parallel
4537 [(set (match_dup 3) (plus:DI
4538 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
4539 (match_dup 4)) (match_dup 5)))
4540 (clobber (reg:CC CC_REGNUM))])]
4541 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4542 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4543 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4544 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4545 operands[7] = operand_subword (operands[1], 1, 0, TImode);
4546 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4547
4548 ;
4549 ; adddi3 instruction pattern(s).
4550 ;
4551
4552 (define_expand "adddi3"
4553 [(parallel
4554 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4555 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4556 (match_operand:DI 2 "general_operand" "")))
4557 (clobber (reg:CC CC_REGNUM))])]
4558 ""
4559 "")
4560
4561 (define_insn "*adddi3_sign"
4562 [(set (match_operand:DI 0 "register_operand" "=d,d")
4563 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4564 (match_operand:DI 1 "register_operand" "0,0")))
4565 (clobber (reg:CC CC_REGNUM))]
4566 "TARGET_ZARCH"
4567 "@
4568 agfr\t%0,%2
4569 agf\t%0,%2"
4570 [(set_attr "op_type" "RRE,RXY")
4571 (set_attr "z196prop" "z196_cracked,z196_cracked")])
4572
4573 (define_insn "*adddi3_zero_cc"
4574 [(set (reg CC_REGNUM)
4575 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4576 (match_operand:DI 1 "register_operand" "0,0"))
4577 (const_int 0)))
4578 (set (match_operand:DI 0 "register_operand" "=d,d")
4579 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
4580 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
4581 "@
4582 algfr\t%0,%2
4583 algf\t%0,%2"
4584 [(set_attr "op_type" "RRE,RXY")
4585 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4586
4587 (define_insn "*adddi3_zero_cconly"
4588 [(set (reg CC_REGNUM)
4589 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4590 (match_operand:DI 1 "register_operand" "0,0"))
4591 (const_int 0)))
4592 (clobber (match_scratch:DI 0 "=d,d"))]
4593 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
4594 "@
4595 algfr\t%0,%2
4596 algf\t%0,%2"
4597 [(set_attr "op_type" "RRE,RXY")
4598 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4599
4600 (define_insn "*adddi3_zero"
4601 [(set (match_operand:DI 0 "register_operand" "=d,d")
4602 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4603 (match_operand:DI 1 "register_operand" "0,0")))
4604 (clobber (reg:CC CC_REGNUM))]
4605 "TARGET_ZARCH"
4606 "@
4607 algfr\t%0,%2
4608 algf\t%0,%2"
4609 [(set_attr "op_type" "RRE,RXY")
4610 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4611
4612 (define_insn_and_split "*adddi3_31z"
4613 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4614 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4615 (match_operand:DI 2 "general_operand" "do") ) )
4616 (clobber (reg:CC CC_REGNUM))]
4617 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
4618 "#"
4619 "&& reload_completed"
4620 [(parallel
4621 [(set (reg:CCL1 CC_REGNUM)
4622 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4623 (match_dup 7)))
4624 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4625 (parallel
4626 [(set (match_dup 3) (plus:SI
4627 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
4628 (match_dup 4)) (match_dup 5)))
4629 (clobber (reg:CC CC_REGNUM))])]
4630 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4631 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4632 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4633 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4634 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4635 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4636
4637 (define_insn_and_split "*adddi3_31"
4638 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4639 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4640 (match_operand:DI 2 "general_operand" "do") ) )
4641 (clobber (reg:CC CC_REGNUM))]
4642 "!TARGET_CPU_ZARCH"
4643 "#"
4644 "&& reload_completed"
4645 [(parallel
4646 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
4647 (clobber (reg:CC CC_REGNUM))])
4648 (parallel
4649 [(set (reg:CCL1 CC_REGNUM)
4650 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4651 (match_dup 7)))
4652 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4653 (set (pc)
4654 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
4655 (pc)
4656 (label_ref (match_dup 9))))
4657 (parallel
4658 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
4659 (clobber (reg:CC CC_REGNUM))])
4660 (match_dup 9)]
4661 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4662 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4663 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4664 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4665 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4666 operands[8] = operand_subword (operands[2], 1, 0, DImode);
4667 operands[9] = gen_label_rtx ();")
4668
4669 ;
4670 ; addsi3 instruction pattern(s).
4671 ;
4672
4673 (define_expand "addsi3"
4674 [(parallel
4675 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4676 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
4677 (match_operand:SI 2 "general_operand" "")))
4678 (clobber (reg:CC CC_REGNUM))])]
4679 ""
4680 "")
4681
4682 (define_insn "*addsi3_sign"
4683 [(set (match_operand:SI 0 "register_operand" "=d,d")
4684 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
4685 (match_operand:SI 1 "register_operand" "0,0")))
4686 (clobber (reg:CC CC_REGNUM))]
4687 ""
4688 "@
4689 ah\t%0,%2
4690 ahy\t%0,%2"
4691 [(set_attr "op_type" "RX,RXY")
4692 (set_attr "z196prop" "z196_cracked,z196_cracked")])
4693
4694 ;
4695 ; add(di|si)3 instruction pattern(s).
4696 ;
4697
4698 ; ark, agrk, ar, ahi, ahik, aghik, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
4699 (define_insn "*add<mode>3"
4700 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d, d, d,d,d,QS")
4701 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,d, 0, 0,0,0, 0")
4702 (match_operand:GPR 2 "general_operand" " d,d,K,K,Op,On,R,T, C") ) )
4703 (clobber (reg:CC CC_REGNUM))]
4704 ""
4705 "@
4706 a<g>r\t%0,%2
4707 a<g>rk\t%0,%1,%2
4708 a<g>hi\t%0,%h2
4709 a<g>hik\t%0,%1,%h2
4710 al<g>fi\t%0,%2
4711 sl<g>fi\t%0,%n2
4712 a<g>\t%0,%2
4713 a<y>\t%0,%2
4714 a<g>si\t%0,%c2"
4715 [(set_attr "op_type" "RR<E>,RRF,RI,RIE,RIL,RIL,RX<Y>,RXY,SIY")
4716 (set_attr "cpu_facility" "*,z196,*,z196,extimm,extimm,*,*,z10")
4717 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,z10_super_E1,z10_super_E1,
4718 z10_super_E1,z10_super_E1,z10_super_E1")])
4719
4720 ; alr, alfi, slfi, al, aly, alrk, alhsik, algr, algfi, slgfi, alg, alsi, algsi, algrk, alghsik
4721 (define_insn "*add<mode>3_carry1_cc"
4722 [(set (reg CC_REGNUM)
4723 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
4724 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
4725 (match_dup 1)))
4726 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,d")
4727 (plus:GPR (match_dup 1) (match_dup 2)))]
4728 "s390_match_ccmode (insn, CCL1mode)"
4729 "@
4730 al<g>r\t%0,%2
4731 al<g>rk\t%0,%1,%2
4732 al<g>fi\t%0,%2
4733 sl<g>fi\t%0,%n2
4734 al<g>hsik\t%0,%1,%h2
4735 al<g>\t%0,%2
4736 al<y>\t%0,%2
4737 al<g>si\t%0,%c2"
4738 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
4739 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
4740 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
4741 z10_super_E1,z10_super_E1,z10_super_E1")])
4742
4743 ; alr, al, aly, algr, alg, alrk, algrk
4744 (define_insn "*add<mode>3_carry1_cconly"
4745 [(set (reg CC_REGNUM)
4746 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
4747 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
4748 (match_dup 1)))
4749 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
4750 "s390_match_ccmode (insn, CCL1mode)"
4751 "@
4752 al<g>r\t%0,%2
4753 al<g>rk\t%0,%1,%2
4754 al<g>\t%0,%2
4755 al<y>\t%0,%2"
4756 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
4757 (set_attr "cpu_facility" "*,z196,*,*")
4758 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4759
4760 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
4761 (define_insn "*add<mode>3_carry2_cc"
4762 [(set (reg CC_REGNUM)
4763 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0, 0")
4764 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T, C"))
4765 (match_dup 2)))
4766 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,RS")
4767 (plus:GPR (match_dup 1) (match_dup 2)))]
4768 "s390_match_ccmode (insn, CCL1mode)"
4769 "@
4770 al<g>r\t%0,%2
4771 al<g>rk\t%0,%1,%2
4772 al<g>fi\t%0,%2
4773 sl<g>fi\t%0,%n2
4774 al<g>hsik\t%0,%1,%h2
4775 al<g>\t%0,%2
4776 al<y>\t%0,%2
4777 al<g>si\t%0,%c2"
4778 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
4779 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
4780 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
4781 z10_super_E1,z10_super_E1,z10_super_E1")])
4782
4783 ; alr, al, aly, algr, alg, alrk, algrk
4784 (define_insn "*add<mode>3_carry2_cconly"
4785 [(set (reg CC_REGNUM)
4786 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
4787 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
4788 (match_dup 2)))
4789 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
4790 "s390_match_ccmode (insn, CCL1mode)"
4791 "@
4792 al<g>r\t%0,%2
4793 al<g>rk\t%0,%1,%2
4794 al<g>\t%0,%2
4795 al<y>\t%0,%2"
4796 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
4797 (set_attr "cpu_facility" "*,z196,*,*")
4798 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4799
4800 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
4801 (define_insn "*add<mode>3_cc"
4802 [(set (reg CC_REGNUM)
4803 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0, 0")
4804 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T, C"))
4805 (const_int 0)))
4806 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,RS")
4807 (plus:GPR (match_dup 1) (match_dup 2)))]
4808 "s390_match_ccmode (insn, CCLmode)"
4809 "@
4810 al<g>r\t%0,%2
4811 al<g>rk\t%0,%1,%2
4812 al<g>fi\t%0,%2
4813 sl<g>fi\t%0,%n2
4814 al<g>hsik\t%0,%1,%h2
4815 al<g>\t%0,%2
4816 al<y>\t%0,%2
4817 al<g>si\t%0,%c2"
4818 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
4819 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,*,z10")
4820 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,
4821 *,z10_super_E1,z10_super_E1,z10_super_E1")])
4822
4823 ; alr, al, aly, algr, alg, alrk, algrk
4824 (define_insn "*add<mode>3_cconly"
4825 [(set (reg CC_REGNUM)
4826 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
4827 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
4828 (const_int 0)))
4829 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
4830 "s390_match_ccmode (insn, CCLmode)"
4831 "@
4832 al<g>r\t%0,%2
4833 al<g>rk\t%0,%1,%2
4834 al<g>\t%0,%2
4835 al<y>\t%0,%2"
4836 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
4837 (set_attr "cpu_facility" "*,z196,*,*")
4838 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4839
4840 ; alr, al, aly, algr, alg, alrk, algrk
4841 (define_insn "*add<mode>3_cconly2"
4842 [(set (reg CC_REGNUM)
4843 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
4844 (neg:GPR (match_operand:GPR 2 "general_operand" "d,d,R,T"))))
4845 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
4846 "s390_match_ccmode(insn, CCLmode)"
4847 "@
4848 al<g>r\t%0,%2
4849 al<g>rk\t%0,%1,%2
4850 al<g>\t%0,%2
4851 al<y>\t%0,%2"
4852 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
4853 (set_attr "cpu_facility" "*,z196,*,*")
4854 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4855
4856 ; ahi, afi, aghi, agfi, asi, agsi
4857 (define_insn "*add<mode>3_imm_cc"
4858 [(set (reg CC_REGNUM)
4859 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" " 0, d,0, 0")
4860 (match_operand:GPR 2 "const_int_operand" " K, K,Os, C"))
4861 (const_int 0)))
4862 (set (match_operand:GPR 0 "nonimmediate_operand" "=d, d,d,QS")
4863 (plus:GPR (match_dup 1) (match_dup 2)))]
4864 "s390_match_ccmode (insn, CCAmode)
4865 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
4866 || (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
4867 /* Avoid INT32_MIN on 32 bit. */
4868 && (!TARGET_ZARCH || INTVAL (operands[2]) != -0x7fffffff - 1)))"
4869 "@
4870 a<g>hi\t%0,%h2
4871 a<g>hik\t%0,%1,%h2
4872 a<g>fi\t%0,%2
4873 a<g>si\t%0,%c2"
4874 [(set_attr "op_type" "RI,RIE,RIL,SIY")
4875 (set_attr "cpu_facility" "*,z196,extimm,z10")
4876 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
4877
4878 ;
4879 ; add(tf|df|sf|td|dd)3 instruction pattern(s).
4880 ;
4881
4882 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4883 (define_insn "add<mode>3"
4884 [(set (match_operand:FP 0 "register_operand" "=f, f")
4885 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4886 (match_operand:FP 2 "general_operand" " f,<Rf>")))
4887 (clobber (reg:CC CC_REGNUM))]
4888 "TARGET_HARD_FLOAT"
4889 "@
4890 a<xde><bt>r\t%0,<op1>%2
4891 a<xde>b\t%0,%2"
4892 [(set_attr "op_type" "<RRer>,RXE")
4893 (set_attr "type" "fsimp<mode>")])
4894
4895 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4896 (define_insn "*add<mode>3_cc"
4897 [(set (reg CC_REGNUM)
4898 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4899 (match_operand:FP 2 "general_operand" " f,<Rf>"))
4900 (match_operand:FP 3 "const0_operand" "")))
4901 (set (match_operand:FP 0 "register_operand" "=f,f")
4902 (plus:FP (match_dup 1) (match_dup 2)))]
4903 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4904 "@
4905 a<xde><bt>r\t%0,<op1>%2
4906 a<xde>b\t%0,%2"
4907 [(set_attr "op_type" "<RRer>,RXE")
4908 (set_attr "type" "fsimp<mode>")])
4909
4910 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4911 (define_insn "*add<mode>3_cconly"
4912 [(set (reg CC_REGNUM)
4913 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4914 (match_operand:FP 2 "general_operand" " f,<Rf>"))
4915 (match_operand:FP 3 "const0_operand" "")))
4916 (clobber (match_scratch:FP 0 "=f,f"))]
4917 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4918 "@
4919 a<xde><bt>r\t%0,<op1>%2
4920 a<xde>b\t%0,%2"
4921 [(set_attr "op_type" "<RRer>,RXE")
4922 (set_attr "type" "fsimp<mode>")])
4923
4924
4925 ;;
4926 ;;- Subtract instructions.
4927 ;;
4928
4929 ;
4930 ; subti3 instruction pattern(s).
4931 ;
4932
4933 (define_insn_and_split "subti3"
4934 [(set (match_operand:TI 0 "register_operand" "=&d")
4935 (minus:TI (match_operand:TI 1 "register_operand" "0")
4936 (match_operand:TI 2 "general_operand" "do") ) )
4937 (clobber (reg:CC CC_REGNUM))]
4938 "TARGET_ZARCH"
4939 "#"
4940 "&& reload_completed"
4941 [(parallel
4942 [(set (reg:CCL2 CC_REGNUM)
4943 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
4944 (match_dup 7)))
4945 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
4946 (parallel
4947 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
4948 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
4949 (clobber (reg:CC CC_REGNUM))])]
4950 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4951 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4952 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4953 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4954 operands[7] = operand_subword (operands[1], 1, 0, TImode);
4955 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4956
4957 ;
4958 ; subdi3 instruction pattern(s).
4959 ;
4960
4961 (define_expand "subdi3"
4962 [(parallel
4963 [(set (match_operand:DI 0 "register_operand" "")
4964 (minus:DI (match_operand:DI 1 "register_operand" "")
4965 (match_operand:DI 2 "general_operand" "")))
4966 (clobber (reg:CC CC_REGNUM))])]
4967 ""
4968 "")
4969
4970 (define_insn "*subdi3_sign"
4971 [(set (match_operand:DI 0 "register_operand" "=d,d")
4972 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4973 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
4974 (clobber (reg:CC CC_REGNUM))]
4975 "TARGET_ZARCH"
4976 "@
4977 sgfr\t%0,%2
4978 sgf\t%0,%2"
4979 [(set_attr "op_type" "RRE,RXY")
4980 (set_attr "z10prop" "z10_c,*")
4981 (set_attr "z196prop" "z196_cracked")])
4982
4983 (define_insn "*subdi3_zero_cc"
4984 [(set (reg CC_REGNUM)
4985 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4986 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
4987 (const_int 0)))
4988 (set (match_operand:DI 0 "register_operand" "=d,d")
4989 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
4990 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
4991 "@
4992 slgfr\t%0,%2
4993 slgf\t%0,%2"
4994 [(set_attr "op_type" "RRE,RXY")
4995 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4996
4997 (define_insn "*subdi3_zero_cconly"
4998 [(set (reg CC_REGNUM)
4999 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
5000 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
5001 (const_int 0)))
5002 (clobber (match_scratch:DI 0 "=d,d"))]
5003 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
5004 "@
5005 slgfr\t%0,%2
5006 slgf\t%0,%2"
5007 [(set_attr "op_type" "RRE,RXY")
5008 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
5009
5010 (define_insn "*subdi3_zero"
5011 [(set (match_operand:DI 0 "register_operand" "=d,d")
5012 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
5013 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
5014 (clobber (reg:CC CC_REGNUM))]
5015 "TARGET_ZARCH"
5016 "@
5017 slgfr\t%0,%2
5018 slgf\t%0,%2"
5019 [(set_attr "op_type" "RRE,RXY")
5020 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
5021
5022 (define_insn_and_split "*subdi3_31z"
5023 [(set (match_operand:DI 0 "register_operand" "=&d")
5024 (minus:DI (match_operand:DI 1 "register_operand" "0")
5025 (match_operand:DI 2 "general_operand" "do") ) )
5026 (clobber (reg:CC CC_REGNUM))]
5027 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
5028 "#"
5029 "&& reload_completed"
5030 [(parallel
5031 [(set (reg:CCL2 CC_REGNUM)
5032 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5033 (match_dup 7)))
5034 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5035 (parallel
5036 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
5037 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
5038 (clobber (reg:CC CC_REGNUM))])]
5039 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5040 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5041 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5042 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5043 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5044 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
5045
5046 (define_insn_and_split "*subdi3_31"
5047 [(set (match_operand:DI 0 "register_operand" "=&d")
5048 (minus:DI (match_operand:DI 1 "register_operand" "0")
5049 (match_operand:DI 2 "general_operand" "do") ) )
5050 (clobber (reg:CC CC_REGNUM))]
5051 "!TARGET_CPU_ZARCH"
5052 "#"
5053 "&& reload_completed"
5054 [(parallel
5055 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
5056 (clobber (reg:CC CC_REGNUM))])
5057 (parallel
5058 [(set (reg:CCL2 CC_REGNUM)
5059 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
5060 (match_dup 7)))
5061 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
5062 (set (pc)
5063 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
5064 (pc)
5065 (label_ref (match_dup 9))))
5066 (parallel
5067 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
5068 (clobber (reg:CC CC_REGNUM))])
5069 (match_dup 9)]
5070 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5071 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5072 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5073 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5074 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5075 operands[8] = operand_subword (operands[2], 1, 0, DImode);
5076 operands[9] = gen_label_rtx ();")
5077
5078 ;
5079 ; subsi3 instruction pattern(s).
5080 ;
5081
5082 (define_expand "subsi3"
5083 [(parallel
5084 [(set (match_operand:SI 0 "register_operand" "")
5085 (minus:SI (match_operand:SI 1 "register_operand" "")
5086 (match_operand:SI 2 "general_operand" "")))
5087 (clobber (reg:CC CC_REGNUM))])]
5088 ""
5089 "")
5090
5091 (define_insn "*subsi3_sign"
5092 [(set (match_operand:SI 0 "register_operand" "=d,d")
5093 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
5094 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
5095 (clobber (reg:CC CC_REGNUM))]
5096 ""
5097 "@
5098 sh\t%0,%2
5099 shy\t%0,%2"
5100 [(set_attr "op_type" "RX,RXY")
5101 (set_attr "z196prop" "z196_cracked,z196_cracked")])
5102
5103 ;
5104 ; sub(di|si)3 instruction pattern(s).
5105 ;
5106
5107 ; sr, s, sy, sgr, sg, srk, sgrk
5108 (define_insn "*sub<mode>3"
5109 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5110 (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5111 (match_operand:GPR 2 "general_operand" "d,d,R,T") ) )
5112 (clobber (reg:CC CC_REGNUM))]
5113 ""
5114 "@
5115 s<g>r\t%0,%2
5116 s<g>rk\t%0,%1,%2
5117 s<g>\t%0,%2
5118 s<y>\t%0,%2"
5119 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5120 (set_attr "cpu_facility" "*,z196,*,*")
5121 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5122
5123 ; slr, sl, sly, slgr, slg, slrk, slgrk
5124 (define_insn "*sub<mode>3_borrow_cc"
5125 [(set (reg CC_REGNUM)
5126 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5127 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5128 (match_dup 1)))
5129 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5130 (minus:GPR (match_dup 1) (match_dup 2)))]
5131 "s390_match_ccmode (insn, CCL2mode)"
5132 "@
5133 sl<g>r\t%0,%2
5134 sl<g>rk\t%0,%1,%2
5135 sl<g>\t%0,%2
5136 sl<y>\t%0,%2"
5137 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5138 (set_attr "cpu_facility" "*,z196,*,*")
5139 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5140
5141 ; slr, sl, sly, slgr, slg, slrk, slgrk
5142 (define_insn "*sub<mode>3_borrow_cconly"
5143 [(set (reg CC_REGNUM)
5144 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5145 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5146 (match_dup 1)))
5147 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5148 "s390_match_ccmode (insn, CCL2mode)"
5149 "@
5150 sl<g>r\t%0,%2
5151 sl<g>rk\t%0,%1,%2
5152 sl<g>\t%0,%2
5153 sl<y>\t%0,%2"
5154 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5155 (set_attr "cpu_facility" "*,z196,*,*")
5156 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5157
5158 ; slr, sl, sly, slgr, slg, slrk, slgrk
5159 (define_insn "*sub<mode>3_cc"
5160 [(set (reg CC_REGNUM)
5161 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5162 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5163 (const_int 0)))
5164 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5165 (minus:GPR (match_dup 1) (match_dup 2)))]
5166 "s390_match_ccmode (insn, CCLmode)"
5167 "@
5168 sl<g>r\t%0,%2
5169 sl<g>rk\t%0,%1,%2
5170 sl<g>\t%0,%2
5171 sl<y>\t%0,%2"
5172 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5173 (set_attr "cpu_facility" "*,z196,*,*")
5174 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5175
5176 ; slr, sl, sly, slgr, slg, slrk, slgrk
5177 (define_insn "*sub<mode>3_cc2"
5178 [(set (reg CC_REGNUM)
5179 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
5180 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
5181 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
5182 (minus:GPR (match_dup 1) (match_dup 2)))]
5183 "s390_match_ccmode (insn, CCL3mode)"
5184 "@
5185 sl<g>r\t%0,%2
5186 sl<g>rk\t%0,%1,%2
5187 sl<g>\t%0,%2
5188 sl<y>\t%0,%2"
5189 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5190 (set_attr "cpu_facility" "*,z196,*,*")
5191 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5192
5193 ; slr, sl, sly, slgr, slg, slrk, slgrk
5194 (define_insn "*sub<mode>3_cconly"
5195 [(set (reg CC_REGNUM)
5196 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
5197 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5198 (const_int 0)))
5199 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5200 "s390_match_ccmode (insn, CCLmode)"
5201 "@
5202 sl<g>r\t%0,%2
5203 sl<g>rk\t%0,%1,%2
5204 sl<g>\t%0,%2
5205 sl<y>\t%0,%2"
5206 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5207 (set_attr "cpu_facility" "*,z196,*,*")
5208 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5209
5210
5211 ; slr, sl, sly, slgr, slg, slrk, slgrk
5212 (define_insn "*sub<mode>3_cconly2"
5213 [(set (reg CC_REGNUM)
5214 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
5215 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
5216 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5217 "s390_match_ccmode (insn, CCL3mode)"
5218 "@
5219 sl<g>r\t%0,%2
5220 sl<g>rk\t%0,%1,%2
5221 sl<g>\t%0,%2
5222 sl<y>\t%0,%2"
5223 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5224 (set_attr "cpu_facility" "*,z196,*,*")
5225 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
5226
5227
5228 ;
5229 ; sub(tf|df|sf|td|dd)3 instruction pattern(s).
5230 ;
5231
5232 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
5233 (define_insn "sub<mode>3"
5234 [(set (match_operand:FP 0 "register_operand" "=f, f")
5235 (minus:FP (match_operand:FP 1 "register_operand" "<f0>,0")
5236 (match_operand:FP 2 "general_operand" "f,<Rf>")))
5237 (clobber (reg:CC CC_REGNUM))]
5238 "TARGET_HARD_FLOAT"
5239 "@
5240 s<xde><bt>r\t%0,<op1>%2
5241 s<xde>b\t%0,%2"
5242 [(set_attr "op_type" "<RRer>,RXE")
5243 (set_attr "type" "fsimp<mode>")])
5244
5245 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
5246 (define_insn "*sub<mode>3_cc"
5247 [(set (reg CC_REGNUM)
5248 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
5249 (match_operand:FP 2 "general_operand" "f,<Rf>"))
5250 (match_operand:FP 3 "const0_operand" "")))
5251 (set (match_operand:FP 0 "register_operand" "=f,f")
5252 (minus:FP (match_dup 1) (match_dup 2)))]
5253 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
5254 "@
5255 s<xde><bt>r\t%0,<op1>%2
5256 s<xde>b\t%0,%2"
5257 [(set_attr "op_type" "<RRer>,RXE")
5258 (set_attr "type" "fsimp<mode>")])
5259
5260 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
5261 (define_insn "*sub<mode>3_cconly"
5262 [(set (reg CC_REGNUM)
5263 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
5264 (match_operand:FP 2 "general_operand" "f,<Rf>"))
5265 (match_operand:FP 3 "const0_operand" "")))
5266 (clobber (match_scratch:FP 0 "=f,f"))]
5267 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
5268 "@
5269 s<xde><bt>r\t%0,<op1>%2
5270 s<xde>b\t%0,%2"
5271 [(set_attr "op_type" "<RRer>,RXE")
5272 (set_attr "type" "fsimp<mode>")])
5273
5274
5275 ;;
5276 ;;- Conditional add/subtract instructions.
5277 ;;
5278
5279 ;
5280 ; add(di|si)cc instruction pattern(s).
5281 ;
5282
5283 ; the following 4 patterns are used when the result of an add with
5284 ; carry is checked for an overflow condition
5285
5286 ; op1 + op2 + c < op1
5287
5288 ; alcr, alc, alcgr, alcg
5289 (define_insn "*add<mode>3_alc_carry1_cc"
5290 [(set (reg CC_REGNUM)
5291 (compare
5292 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5293 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5294 (match_operand:GPR 2 "general_operand" "d,RT"))
5295 (match_dup 1)))
5296 (set (match_operand:GPR 0 "register_operand" "=d,d")
5297 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5298 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5299 "@
5300 alc<g>r\t%0,%2
5301 alc<g>\t%0,%2"
5302 [(set_attr "op_type" "RRE,RXY")
5303 (set_attr "z196prop" "z196_alone,z196_alone")])
5304
5305 ; alcr, alc, alcgr, alcg
5306 (define_insn "*add<mode>3_alc_carry1_cconly"
5307 [(set (reg CC_REGNUM)
5308 (compare
5309 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5310 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5311 (match_operand:GPR 2 "general_operand" "d,RT"))
5312 (match_dup 1)))
5313 (clobber (match_scratch:GPR 0 "=d,d"))]
5314 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5315 "@
5316 alc<g>r\t%0,%2
5317 alc<g>\t%0,%2"
5318 [(set_attr "op_type" "RRE,RXY")
5319 (set_attr "z196prop" "z196_alone,z196_alone")])
5320
5321 ; op1 + op2 + c < op2
5322
5323 ; alcr, alc, alcgr, alcg
5324 (define_insn "*add<mode>3_alc_carry2_cc"
5325 [(set (reg CC_REGNUM)
5326 (compare
5327 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5328 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5329 (match_operand:GPR 2 "general_operand" "d,RT"))
5330 (match_dup 2)))
5331 (set (match_operand:GPR 0 "register_operand" "=d,d")
5332 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5333 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5334 "@
5335 alc<g>r\t%0,%2
5336 alc<g>\t%0,%2"
5337 [(set_attr "op_type" "RRE,RXY")])
5338
5339 ; alcr, alc, alcgr, alcg
5340 (define_insn "*add<mode>3_alc_carry2_cconly"
5341 [(set (reg CC_REGNUM)
5342 (compare
5343 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5344 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5345 (match_operand:GPR 2 "general_operand" "d,RT"))
5346 (match_dup 2)))
5347 (clobber (match_scratch:GPR 0 "=d,d"))]
5348 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
5349 "@
5350 alc<g>r\t%0,%2
5351 alc<g>\t%0,%2"
5352 [(set_attr "op_type" "RRE,RXY")])
5353
5354 ; alcr, alc, alcgr, alcg
5355 (define_insn "*add<mode>3_alc_cc"
5356 [(set (reg CC_REGNUM)
5357 (compare
5358 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5359 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5360 (match_operand:GPR 2 "general_operand" "d,RT"))
5361 (const_int 0)))
5362 (set (match_operand:GPR 0 "register_operand" "=d,d")
5363 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5364 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5365 "@
5366 alc<g>r\t%0,%2
5367 alc<g>\t%0,%2"
5368 [(set_attr "op_type" "RRE,RXY")])
5369
5370 ; alcr, alc, alcgr, alcg
5371 (define_insn "*add<mode>3_alc"
5372 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5373 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5374 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5375 (match_operand:GPR 2 "general_operand" "d,RT")))
5376 (clobber (reg:CC CC_REGNUM))]
5377 "TARGET_CPU_ZARCH"
5378 "@
5379 alc<g>r\t%0,%2
5380 alc<g>\t%0,%2"
5381 [(set_attr "op_type" "RRE,RXY")])
5382
5383 ; slbr, slb, slbgr, slbg
5384 (define_insn "*sub<mode>3_slb_cc"
5385 [(set (reg CC_REGNUM)
5386 (compare
5387 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5388 (match_operand:GPR 2 "general_operand" "d,RT"))
5389 (match_operand:GPR 3 "s390_slb_comparison" ""))
5390 (const_int 0)))
5391 (set (match_operand:GPR 0 "register_operand" "=d,d")
5392 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
5393 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5394 "@
5395 slb<g>r\t%0,%2
5396 slb<g>\t%0,%2"
5397 [(set_attr "op_type" "RRE,RXY")
5398 (set_attr "z10prop" "z10_c,*")])
5399
5400 ; slbr, slb, slbgr, slbg
5401 (define_insn "*sub<mode>3_slb"
5402 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5403 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5404 (match_operand:GPR 2 "general_operand" "d,RT"))
5405 (match_operand:GPR 3 "s390_slb_comparison" "")))
5406 (clobber (reg:CC CC_REGNUM))]
5407 "TARGET_CPU_ZARCH"
5408 "@
5409 slb<g>r\t%0,%2
5410 slb<g>\t%0,%2"
5411 [(set_attr "op_type" "RRE,RXY")
5412 (set_attr "z10prop" "z10_c,*")])
5413
5414 (define_expand "add<mode>cc"
5415 [(match_operand:GPR 0 "register_operand" "")
5416 (match_operand 1 "comparison_operator" "")
5417 (match_operand:GPR 2 "register_operand" "")
5418 (match_operand:GPR 3 "const_int_operand" "")]
5419 "TARGET_CPU_ZARCH"
5420 "if (!s390_expand_addcc (GET_CODE (operands[1]),
5421 XEXP (operands[1], 0), XEXP (operands[1], 1),
5422 operands[0], operands[2],
5423 operands[3])) FAIL; DONE;")
5424
5425 ;
5426 ; scond instruction pattern(s).
5427 ;
5428
5429 (define_insn_and_split "*scond<mode>"
5430 [(set (match_operand:GPR 0 "register_operand" "=&d")
5431 (match_operand:GPR 1 "s390_alc_comparison" ""))
5432 (clobber (reg:CC CC_REGNUM))]
5433 "TARGET_CPU_ZARCH"
5434 "#"
5435 "&& reload_completed"
5436 [(set (match_dup 0) (const_int 0))
5437 (parallel
5438 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
5439 (match_dup 0)))
5440 (clobber (reg:CC CC_REGNUM))])]
5441 "")
5442
5443 (define_insn_and_split "*scond<mode>_neg"
5444 [(set (match_operand:GPR 0 "register_operand" "=&d")
5445 (match_operand:GPR 1 "s390_slb_comparison" ""))
5446 (clobber (reg:CC CC_REGNUM))]
5447 "TARGET_CPU_ZARCH"
5448 "#"
5449 "&& reload_completed"
5450 [(set (match_dup 0) (const_int 0))
5451 (parallel
5452 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
5453 (match_dup 1)))
5454 (clobber (reg:CC CC_REGNUM))])
5455 (parallel
5456 [(set (match_dup 0) (neg:GPR (match_dup 0)))
5457 (clobber (reg:CC CC_REGNUM))])]
5458 "")
5459
5460
5461 (define_expand "cstore<mode>4"
5462 [(set (match_operand:SI 0 "register_operand" "")
5463 (match_operator:SI 1 "s390_scond_operator"
5464 [(match_operand:GPR 2 "register_operand" "")
5465 (match_operand:GPR 3 "general_operand" "")]))]
5466 "TARGET_CPU_ZARCH"
5467 "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3],
5468 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
5469
5470 (define_expand "cstorecc4"
5471 [(parallel
5472 [(set (match_operand:SI 0 "register_operand" "")
5473 (match_operator:SI 1 "s390_eqne_operator"
5474 [(match_operand:CCZ1 2 "register_operand")
5475 (match_operand 3 "const0_operand")]))
5476 (clobber (reg:CC CC_REGNUM))])]
5477 ""
5478 "emit_insn (gen_sne (operands[0], operands[2]));
5479 if (GET_CODE (operands[1]) == EQ)
5480 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
5481 DONE;")
5482
5483 (define_insn_and_split "sne"
5484 [(set (match_operand:SI 0 "register_operand" "=d")
5485 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
5486 (const_int 0)))
5487 (clobber (reg:CC CC_REGNUM))]
5488 ""
5489 "#"
5490 "reload_completed"
5491 [(parallel
5492 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
5493 (clobber (reg:CC CC_REGNUM))])])
5494
5495
5496 ;;
5497 ;; - Conditional move instructions (introduced with z196)
5498 ;;
5499
5500 (define_expand "mov<mode>cc"
5501 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
5502 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
5503 (match_operand:GPR 2 "nonimmediate_operand" "")
5504 (match_operand:GPR 3 "nonimmediate_operand" "")))]
5505 "TARGET_Z196"
5506 "operands[1] = s390_emit_compare (GET_CODE (operands[1]),
5507 XEXP (operands[1], 0), XEXP (operands[1], 1));")
5508
5509 ; locr, loc, stoc, locgr, locg, stocg
5510 (define_insn_and_split "*mov<mode>cc"
5511 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,QS,QS,&d")
5512 (if_then_else:GPR
5513 (match_operator 1 "s390_comparison"
5514 [(match_operand 2 "cc_reg_operand" " c,c, c, c, c, c, c")
5515 (const_int 0)])
5516 (match_operand:GPR 3 "nonimmediate_operand" " d,0,QS, 0, d, 0,QS")
5517 (match_operand:GPR 4 "nonimmediate_operand" " 0,d, 0,QS, 0, d,QS")))]
5518 "TARGET_Z196"
5519 "@
5520 loc<g>r%C1\t%0,%3
5521 loc<g>r%D1\t%0,%4
5522 loc<g>%C1\t%0,%3
5523 loc<g>%D1\t%0,%4
5524 stoc<g>%C1\t%3,%0
5525 stoc<g>%D1\t%4,%0
5526 #"
5527 "&& reload_completed
5528 && MEM_P (operands[3]) && MEM_P (operands[4])"
5529 [(set (match_dup 0)
5530 (if_then_else:GPR
5531 (match_op_dup 1 [(match_dup 2) (const_int 0)])
5532 (match_dup 3)
5533 (match_dup 0)))
5534 (set (match_dup 0)
5535 (if_then_else:GPR
5536 (match_op_dup 1 [(match_dup 2) (const_int 0)])
5537 (match_dup 0)
5538 (match_dup 4)))]
5539 ""
5540 [(set_attr "op_type" "RRF,RRF,RSY,RSY,RSY,RSY,*")])
5541
5542 ;;
5543 ;;- Multiply instructions.
5544 ;;
5545
5546 ;
5547 ; muldi3 instruction pattern(s).
5548 ;
5549
5550 (define_insn "*muldi3_sign"
5551 [(set (match_operand:DI 0 "register_operand" "=d,d")
5552 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
5553 (match_operand:DI 1 "register_operand" "0,0")))]
5554 "TARGET_ZARCH"
5555 "@
5556 msgfr\t%0,%2
5557 msgf\t%0,%2"
5558 [(set_attr "op_type" "RRE,RXY")
5559 (set_attr "type" "imuldi")])
5560
5561 (define_insn "muldi3"
5562 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
5563 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5564 (match_operand:DI 2 "general_operand" "d,K,RT,Os")))]
5565 "TARGET_ZARCH"
5566 "@
5567 msgr\t%0,%2
5568 mghi\t%0,%h2
5569 msg\t%0,%2
5570 msgfi\t%0,%2"
5571 [(set_attr "op_type" "RRE,RI,RXY,RIL")
5572 (set_attr "type" "imuldi")
5573 (set_attr "cpu_facility" "*,*,*,z10")])
5574
5575 ;
5576 ; mulsi3 instruction pattern(s).
5577 ;
5578
5579 (define_insn "*mulsi3_sign"
5580 [(set (match_operand:SI 0 "register_operand" "=d,d")
5581 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5582 (match_operand:SI 1 "register_operand" "0,0")))]
5583 ""
5584 "@
5585 mh\t%0,%2
5586 mhy\t%0,%2"
5587 [(set_attr "op_type" "RX,RXY")
5588 (set_attr "type" "imulhi")
5589 (set_attr "cpu_facility" "*,z10")])
5590
5591 (define_insn "mulsi3"
5592 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
5593 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
5594 (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
5595 ""
5596 "@
5597 msr\t%0,%2
5598 mhi\t%0,%h2
5599 ms\t%0,%2
5600 msy\t%0,%2
5601 msfi\t%0,%2"
5602 [(set_attr "op_type" "RRE,RI,RX,RXY,RIL")
5603 (set_attr "type" "imulsi,imulhi,imulsi,imulsi,imulsi")
5604 (set_attr "cpu_facility" "*,*,*,*,z10")])
5605
5606 ;
5607 ; mulsidi3 instruction pattern(s).
5608 ;
5609
5610 (define_insn "mulsidi3"
5611 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
5612 (mult:DI (sign_extend:DI
5613 (match_operand:SI 1 "register_operand" "%0,0,0"))
5614 (sign_extend:DI
5615 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
5616 "!TARGET_ZARCH"
5617 "@
5618 mr\t%0,%2
5619 m\t%0,%2
5620 mfy\t%0,%2"
5621 [(set_attr "op_type" "RR,RX,RXY")
5622 (set_attr "type" "imulsi")
5623 (set_attr "cpu_facility" "*,*,z10")])
5624
5625 ;
5626 ; umul instruction pattern(s).
5627 ;
5628
5629 ; mlr, ml, mlgr, mlg
5630 (define_insn "umul<dwh><mode>3"
5631 [(set (match_operand:DW 0 "register_operand" "=d, d")
5632 (mult:DW (zero_extend:DW
5633 (match_operand:<DWH> 1 "register_operand" "%0, 0"))
5634 (zero_extend:DW
5635 (match_operand:<DWH> 2 "nonimmediate_operand" " d,RT"))))]
5636 "TARGET_CPU_ZARCH"
5637 "@
5638 ml<tg>r\t%0,%2
5639 ml<tg>\t%0,%2"
5640 [(set_attr "op_type" "RRE,RXY")
5641 (set_attr "type" "imul<dwh>")])
5642
5643 ;
5644 ; mul(tf|df|sf|td|dd)3 instruction pattern(s).
5645 ;
5646
5647 ; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
5648 (define_insn "mul<mode>3"
5649 [(set (match_operand:FP 0 "register_operand" "=f,f")
5650 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5651 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
5652 "TARGET_HARD_FLOAT"
5653 "@
5654 m<xdee><bt>r\t%0,<op1>%2
5655 m<xdee>b\t%0,%2"
5656 [(set_attr "op_type" "<RRer>,RXE")
5657 (set_attr "type" "fmul<mode>")])
5658
5659 ; madbr, maebr, maxb, madb, maeb
5660 (define_insn "fma<mode>4"
5661 [(set (match_operand:DSF 0 "register_operand" "=f,f")
5662 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f")
5663 (match_operand:DSF 2 "nonimmediate_operand" "f,R")
5664 (match_operand:DSF 3 "register_operand" "0,0")))]
5665 "TARGET_HARD_FLOAT"
5666 "@
5667 ma<xde>br\t%0,%1,%2
5668 ma<xde>b\t%0,%1,%2"
5669 [(set_attr "op_type" "RRE,RXE")
5670 (set_attr "type" "fmadd<mode>")])
5671
5672 ; msxbr, msdbr, msebr, msxb, msdb, mseb
5673 (define_insn "fms<mode>4"
5674 [(set (match_operand:DSF 0 "register_operand" "=f,f")
5675 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f")
5676 (match_operand:DSF 2 "nonimmediate_operand" "f,R")
5677 (neg:DSF (match_operand:DSF 3 "register_operand" "0,0"))))]
5678 "TARGET_HARD_FLOAT"
5679 "@
5680 ms<xde>br\t%0,%1,%2
5681 ms<xde>b\t%0,%1,%2"
5682 [(set_attr "op_type" "RRE,RXE")
5683 (set_attr "type" "fmadd<mode>")])
5684
5685 ;;
5686 ;;- Divide and modulo instructions.
5687 ;;
5688
5689 ;
5690 ; divmoddi4 instruction pattern(s).
5691 ;
5692
5693 (define_expand "divmoddi4"
5694 [(parallel [(set (match_operand:DI 0 "general_operand" "")
5695 (div:DI (match_operand:DI 1 "register_operand" "")
5696 (match_operand:DI 2 "general_operand" "")))
5697 (set (match_operand:DI 3 "general_operand" "")
5698 (mod:DI (match_dup 1) (match_dup 2)))])
5699 (clobber (match_dup 4))]
5700 "TARGET_ZARCH"
5701 {
5702 rtx insn, div_equal, mod_equal;
5703
5704 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
5705 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
5706
5707 operands[4] = gen_reg_rtx(TImode);
5708 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
5709
5710 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5711 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5712
5713 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5714 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5715
5716 DONE;
5717 })
5718
5719 (define_insn "divmodtidi3"
5720 [(set (match_operand:TI 0 "register_operand" "=d,d")
5721 (ior:TI
5722 (ashift:TI
5723 (zero_extend:TI
5724 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5725 (match_operand:DI 2 "general_operand" "d,RT")))
5726 (const_int 64))
5727 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
5728 "TARGET_ZARCH"
5729 "@
5730 dsgr\t%0,%2
5731 dsg\t%0,%2"
5732 [(set_attr "op_type" "RRE,RXY")
5733 (set_attr "type" "idiv")])
5734
5735 (define_insn "divmodtisi3"
5736 [(set (match_operand:TI 0 "register_operand" "=d,d")
5737 (ior:TI
5738 (ashift:TI
5739 (zero_extend:TI
5740 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5741 (sign_extend:DI
5742 (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))
5743 (const_int 64))
5744 (zero_extend:TI
5745 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
5746 "TARGET_ZARCH"
5747 "@
5748 dsgfr\t%0,%2
5749 dsgf\t%0,%2"
5750 [(set_attr "op_type" "RRE,RXY")
5751 (set_attr "type" "idiv")])
5752
5753 ;
5754 ; udivmoddi4 instruction pattern(s).
5755 ;
5756
5757 (define_expand "udivmoddi4"
5758 [(parallel [(set (match_operand:DI 0 "general_operand" "")
5759 (udiv:DI (match_operand:DI 1 "general_operand" "")
5760 (match_operand:DI 2 "nonimmediate_operand" "")))
5761 (set (match_operand:DI 3 "general_operand" "")
5762 (umod:DI (match_dup 1) (match_dup 2)))])
5763 (clobber (match_dup 4))]
5764 "TARGET_ZARCH"
5765 {
5766 rtx insn, div_equal, mod_equal, equal;
5767
5768 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
5769 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
5770 equal = gen_rtx_IOR (TImode,
5771 gen_rtx_ASHIFT (TImode,
5772 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
5773 GEN_INT (64)),
5774 gen_rtx_ZERO_EXTEND (TImode, div_equal));
5775
5776 operands[4] = gen_reg_rtx(TImode);
5777 emit_clobber (operands[4]);
5778 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
5779 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
5780
5781 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
5782 set_unique_reg_note (insn, REG_EQUAL, equal);
5783
5784 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5785 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5786
5787 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5788 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5789
5790 DONE;
5791 })
5792
5793 (define_insn "udivmodtidi3"
5794 [(set (match_operand:TI 0 "register_operand" "=d,d")
5795 (ior:TI
5796 (ashift:TI
5797 (zero_extend:TI
5798 (truncate:DI
5799 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
5800 (zero_extend:TI
5801 (match_operand:DI 2 "nonimmediate_operand" "d,RT")))))
5802 (const_int 64))
5803 (zero_extend:TI
5804 (truncate:DI
5805 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
5806 "TARGET_ZARCH"
5807 "@
5808 dlgr\t%0,%2
5809 dlg\t%0,%2"
5810 [(set_attr "op_type" "RRE,RXY")
5811 (set_attr "type" "idiv")])
5812
5813 ;
5814 ; divmodsi4 instruction pattern(s).
5815 ;
5816
5817 (define_expand "divmodsi4"
5818 [(parallel [(set (match_operand:SI 0 "general_operand" "")
5819 (div:SI (match_operand:SI 1 "general_operand" "")
5820 (match_operand:SI 2 "nonimmediate_operand" "")))
5821 (set (match_operand:SI 3 "general_operand" "")
5822 (mod:SI (match_dup 1) (match_dup 2)))])
5823 (clobber (match_dup 4))]
5824 "!TARGET_ZARCH"
5825 {
5826 rtx insn, div_equal, mod_equal, equal;
5827
5828 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
5829 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
5830 equal = gen_rtx_IOR (DImode,
5831 gen_rtx_ASHIFT (DImode,
5832 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5833 GEN_INT (32)),
5834 gen_rtx_ZERO_EXTEND (DImode, div_equal));
5835
5836 operands[4] = gen_reg_rtx(DImode);
5837 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
5838
5839 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
5840 set_unique_reg_note (insn, REG_EQUAL, equal);
5841
5842 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5843 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5844
5845 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5846 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5847
5848 DONE;
5849 })
5850
5851 (define_insn "divmoddisi3"
5852 [(set (match_operand:DI 0 "register_operand" "=d,d")
5853 (ior:DI
5854 (ashift:DI
5855 (zero_extend:DI
5856 (truncate:SI
5857 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5858 (sign_extend:DI
5859 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
5860 (const_int 32))
5861 (zero_extend:DI
5862 (truncate:SI
5863 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
5864 "!TARGET_ZARCH"
5865 "@
5866 dr\t%0,%2
5867 d\t%0,%2"
5868 [(set_attr "op_type" "RR,RX")
5869 (set_attr "type" "idiv")])
5870
5871 ;
5872 ; udivsi3 and umodsi3 instruction pattern(s).
5873 ;
5874
5875 (define_expand "udivmodsi4"
5876 [(parallel [(set (match_operand:SI 0 "general_operand" "")
5877 (udiv:SI (match_operand:SI 1 "general_operand" "")
5878 (match_operand:SI 2 "nonimmediate_operand" "")))
5879 (set (match_operand:SI 3 "general_operand" "")
5880 (umod:SI (match_dup 1) (match_dup 2)))])
5881 (clobber (match_dup 4))]
5882 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
5883 {
5884 rtx insn, div_equal, mod_equal, equal;
5885
5886 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5887 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5888 equal = gen_rtx_IOR (DImode,
5889 gen_rtx_ASHIFT (DImode,
5890 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5891 GEN_INT (32)),
5892 gen_rtx_ZERO_EXTEND (DImode, div_equal));
5893
5894 operands[4] = gen_reg_rtx(DImode);
5895 emit_clobber (operands[4]);
5896 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
5897 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
5898
5899 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
5900 set_unique_reg_note (insn, REG_EQUAL, equal);
5901
5902 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5903 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5904
5905 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5906 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5907
5908 DONE;
5909 })
5910
5911 (define_insn "udivmoddisi3"
5912 [(set (match_operand:DI 0 "register_operand" "=d,d")
5913 (ior:DI
5914 (ashift:DI
5915 (zero_extend:DI
5916 (truncate:SI
5917 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
5918 (zero_extend:DI
5919 (match_operand:SI 2 "nonimmediate_operand" "d,RT")))))
5920 (const_int 32))
5921 (zero_extend:DI
5922 (truncate:SI
5923 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
5924 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
5925 "@
5926 dlr\t%0,%2
5927 dl\t%0,%2"
5928 [(set_attr "op_type" "RRE,RXY")
5929 (set_attr "type" "idiv")])
5930
5931 (define_expand "udivsi3"
5932 [(set (match_operand:SI 0 "register_operand" "=d")
5933 (udiv:SI (match_operand:SI 1 "general_operand" "")
5934 (match_operand:SI 2 "general_operand" "")))
5935 (clobber (match_dup 3))]
5936 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
5937 {
5938 rtx insn, udiv_equal, umod_equal, equal;
5939
5940 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5941 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5942 equal = gen_rtx_IOR (DImode,
5943 gen_rtx_ASHIFT (DImode,
5944 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5945 GEN_INT (32)),
5946 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5947
5948 operands[3] = gen_reg_rtx (DImode);
5949
5950 if (CONSTANT_P (operands[2]))
5951 {
5952 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
5953 {
5954 rtx label1 = gen_label_rtx ();
5955
5956 operands[1] = make_safe_from (operands[1], operands[0]);
5957 emit_move_insn (operands[0], const0_rtx);
5958 emit_cmp_and_jump_insns (operands[1], operands[2], LT, NULL_RTX,
5959 SImode, 1, label1);
5960 emit_move_insn (operands[0], const1_rtx);
5961 emit_label (label1);
5962 }
5963 else
5964 {
5965 operands[2] = force_reg (SImode, operands[2]);
5966 operands[2] = make_safe_from (operands[2], operands[0]);
5967
5968 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5969 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5970 operands[2]));
5971 set_unique_reg_note (insn, REG_EQUAL, equal);
5972
5973 insn = emit_move_insn (operands[0],
5974 gen_lowpart (SImode, operands[3]));
5975 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5976 }
5977 }
5978 else
5979 {
5980 rtx label1 = gen_label_rtx ();
5981 rtx label2 = gen_label_rtx ();
5982 rtx label3 = gen_label_rtx ();
5983
5984 operands[1] = force_reg (SImode, operands[1]);
5985 operands[1] = make_safe_from (operands[1], operands[0]);
5986 operands[2] = force_reg (SImode, operands[2]);
5987 operands[2] = make_safe_from (operands[2], operands[0]);
5988
5989 emit_move_insn (operands[0], const0_rtx);
5990 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
5991 SImode, 1, label3);
5992 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
5993 SImode, 0, label2);
5994 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
5995 SImode, 0, label1);
5996 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5997 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5998 operands[2]));
5999 set_unique_reg_note (insn, REG_EQUAL, equal);
6000
6001 insn = emit_move_insn (operands[0],
6002 gen_lowpart (SImode, operands[3]));
6003 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
6004
6005 emit_jump (label3);
6006 emit_label (label1);
6007 emit_move_insn (operands[0], operands[1]);
6008 emit_jump (label3);
6009 emit_label (label2);
6010 emit_move_insn (operands[0], const1_rtx);
6011 emit_label (label3);
6012 }
6013 emit_move_insn (operands[0], operands[0]);
6014 DONE;
6015 })
6016
6017 (define_expand "umodsi3"
6018 [(set (match_operand:SI 0 "register_operand" "=d")
6019 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
6020 (match_operand:SI 2 "nonimmediate_operand" "")))
6021 (clobber (match_dup 3))]
6022 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
6023 {
6024 rtx insn, udiv_equal, umod_equal, equal;
6025
6026 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6027 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6028 equal = gen_rtx_IOR (DImode,
6029 gen_rtx_ASHIFT (DImode,
6030 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
6031 GEN_INT (32)),
6032 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
6033
6034 operands[3] = gen_reg_rtx (DImode);
6035
6036 if (CONSTANT_P (operands[2]))
6037 {
6038 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
6039 {
6040 rtx label1 = gen_label_rtx ();
6041
6042 operands[1] = make_safe_from (operands[1], operands[0]);
6043 emit_move_insn (operands[0], operands[1]);
6044 emit_cmp_and_jump_insns (operands[0], operands[2], LT, NULL_RTX,
6045 SImode, 1, label1);
6046 emit_insn (gen_abssi2 (operands[0], operands[2]));
6047 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
6048 emit_label (label1);
6049 }
6050 else
6051 {
6052 operands[2] = force_reg (SImode, operands[2]);
6053 operands[2] = make_safe_from (operands[2], operands[0]);
6054
6055 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6056 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6057 operands[2]));
6058 set_unique_reg_note (insn, REG_EQUAL, equal);
6059
6060 insn = emit_move_insn (operands[0],
6061 gen_highpart (SImode, operands[3]));
6062 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
6063 }
6064 }
6065 else
6066 {
6067 rtx label1 = gen_label_rtx ();
6068 rtx label2 = gen_label_rtx ();
6069 rtx label3 = gen_label_rtx ();
6070
6071 operands[1] = force_reg (SImode, operands[1]);
6072 operands[1] = make_safe_from (operands[1], operands[0]);
6073 operands[2] = force_reg (SImode, operands[2]);
6074 operands[2] = make_safe_from (operands[2], operands[0]);
6075
6076 emit_move_insn(operands[0], operands[1]);
6077 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
6078 SImode, 1, label3);
6079 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
6080 SImode, 0, label2);
6081 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
6082 SImode, 0, label1);
6083 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
6084 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
6085 operands[2]));
6086 set_unique_reg_note (insn, REG_EQUAL, equal);
6087
6088 insn = emit_move_insn (operands[0],
6089 gen_highpart (SImode, operands[3]));
6090 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
6091
6092 emit_jump (label3);
6093 emit_label (label1);
6094 emit_move_insn (operands[0], const0_rtx);
6095 emit_jump (label3);
6096 emit_label (label2);
6097 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
6098 emit_label (label3);
6099 }
6100 DONE;
6101 })
6102
6103 ;
6104 ; div(df|sf)3 instruction pattern(s).
6105 ;
6106
6107 ; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
6108 (define_insn "div<mode>3"
6109 [(set (match_operand:FP 0 "register_operand" "=f,f")
6110 (div:FP (match_operand:FP 1 "register_operand" "<f0>,0")
6111 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
6112 "TARGET_HARD_FLOAT"
6113 "@
6114 d<xde><bt>r\t%0,<op1>%2
6115 d<xde>b\t%0,%2"
6116 [(set_attr "op_type" "<RRer>,RXE")
6117 (set_attr "type" "fdiv<mode>")])
6118
6119
6120 ;;
6121 ;;- And instructions.
6122 ;;
6123
6124 (define_expand "and<mode>3"
6125 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6126 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
6127 (match_operand:INT 2 "general_operand" "")))
6128 (clobber (reg:CC CC_REGNUM))]
6129 ""
6130 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
6131
6132 ;
6133 ; anddi3 instruction pattern(s).
6134 ;
6135
6136 (define_insn "*anddi3_cc"
6137 [(set (reg CC_REGNUM)
6138 (compare
6139 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0, d")
6140 (match_operand:DI 2 "general_operand" " d,d,RT,NxxDq"))
6141 (const_int 0)))
6142 (set (match_operand:DI 0 "register_operand" "=d,d, d, d")
6143 (and:DI (match_dup 1) (match_dup 2)))]
6144 "TARGET_ZARCH && s390_match_ccmode(insn, CCTmode)"
6145 "@
6146 ngr\t%0,%2
6147 ngrk\t%0,%1,%2
6148 ng\t%0,%2
6149 risbg\t%0,%1,%s2,128+%e2,0"
6150 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
6151 (set_attr "cpu_facility" "*,z196,*,z10")
6152 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6153
6154 (define_insn "*anddi3_cconly"
6155 [(set (reg CC_REGNUM)
6156 (compare
6157 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0, d")
6158 (match_operand:DI 2 "general_operand" " d,d,RT,NxxDq"))
6159 (const_int 0)))
6160 (clobber (match_scratch:DI 0 "=d,d, d, d"))]
6161 "TARGET_ZARCH
6162 && s390_match_ccmode(insn, CCTmode)
6163 /* Do not steal TM patterns. */
6164 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
6165 "@
6166 ngr\t%0,%2
6167 ngrk\t%0,%1,%2
6168 ng\t%0,%2
6169 risbg\t%0,%1,%s2,128+%e2,0"
6170 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
6171 (set_attr "cpu_facility" "*,z196,*,z10")
6172 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
6173
6174 (define_insn "*anddi3"
6175 [(set (match_operand:DI 0 "nonimmediate_operand"
6176 "=d,d, d, d, d, d, d, d,d,d, d, d, AQ,Q")
6177 (and:DI
6178 (match_operand:DI 1 "nonimmediate_operand"
6179 "%d,o, 0, 0, 0, 0, 0, 0,0,d, 0, d, 0,0")
6180 (match_operand:DI 2 "general_operand"
6181 "M, M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,d,RT,NxxDq,NxQDF,Q")))
6182 (clobber (reg:CC CC_REGNUM))]
6183 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6184 "@
6185 #
6186 #
6187 nihh\t%0,%j2
6188 nihl\t%0,%j2
6189 nilh\t%0,%j2
6190 nill\t%0,%j2
6191 nihf\t%0,%m2
6192 nilf\t%0,%m2
6193 ngr\t%0,%2
6194 ngrk\t%0,%1,%2
6195 ng\t%0,%2
6196 risbg\t%0,%1,%s2,128+%e2,0
6197 #
6198 #"
6199 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,RIE,SI,SS")
6200 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,z196,*,z10,*,*")
6201 (set_attr "z10prop" "*,
6202 *,
6203 z10_super_E1,
6204 z10_super_E1,
6205 z10_super_E1,
6206 z10_super_E1,
6207 z10_super_E1,
6208 z10_super_E1,
6209 z10_super_E1,
6210 *,
6211 z10_super_E1,
6212 z10_super_E1,
6213 *,
6214 *")])
6215
6216 (define_split
6217 [(set (match_operand:DI 0 "s_operand" "")
6218 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6219 (clobber (reg:CC CC_REGNUM))]
6220 "reload_completed"
6221 [(parallel
6222 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
6223 (clobber (reg:CC CC_REGNUM))])]
6224 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
6225
6226 ;; These two are what combine generates for (ashift (zero_extract)).
6227 (define_insn "*extzv_<mode>_srl"
6228 [(set (match_operand:GPR 0 "register_operand" "=d")
6229 (and:GPR (lshiftrt:GPR
6230 (match_operand:GPR 1 "register_operand" "d")
6231 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
6232 (match_operand:GPR 3 "contiguous_bitmask_operand" "")))
6233 (clobber (reg:CC CC_REGNUM))]
6234 "TARGET_Z10
6235 /* Note that even for the SImode pattern, the rotate is always DImode. */
6236 && s390_extzv_shift_ok (<bitsize>, -INTVAL (operands[2]),
6237 INTVAL (operands[3]))"
6238 "risbg\t%0,%1,%<bfstart>3,128+%<bfend>3,64-%2"
6239 [(set_attr "op_type" "RIE")
6240 (set_attr "z10prop" "z10_super_E1")])
6241
6242 (define_insn "*extzv_<mode>_sll"
6243 [(set (match_operand:GPR 0 "register_operand" "=d")
6244 (and:GPR (ashift:GPR
6245 (match_operand:GPR 1 "register_operand" "d")
6246 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
6247 (match_operand:GPR 3 "contiguous_bitmask_operand" "")))
6248 (clobber (reg:CC CC_REGNUM))]
6249 "TARGET_Z10
6250 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[2]),
6251 INTVAL (operands[3]))"
6252 "risbg\t%0,%1,%<bfstart>3,128+%<bfend>3,%2"
6253 [(set_attr "op_type" "RIE")
6254 (set_attr "z10prop" "z10_super_E1")])
6255
6256
6257 ;
6258 ; andsi3 instruction pattern(s).
6259 ;
6260
6261 (define_insn "*andsi3_cc"
6262 [(set (reg CC_REGNUM)
6263 (compare
6264 (and:SI
6265 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
6266 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
6267 (const_int 0)))
6268 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d, d")
6269 (and:SI (match_dup 1) (match_dup 2)))]
6270 "s390_match_ccmode(insn, CCTmode)"
6271 "@
6272 nilf\t%0,%o2
6273 nr\t%0,%2
6274 nrk\t%0,%1,%2
6275 n\t%0,%2
6276 ny\t%0,%2
6277 risbg\t%0,%1,%t2,128+%f2,0"
6278 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
6279 (set_attr "cpu_facility" "*,*,z196,*,*,z10")
6280 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
6281 z10_super_E1,z10_super_E1,z10_super_E1")])
6282
6283 (define_insn "*andsi3_cconly"
6284 [(set (reg CC_REGNUM)
6285 (compare
6286 (and:SI
6287 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
6288 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
6289 (const_int 0)))
6290 (clobber (match_scratch:SI 0 "=d,d,d,d,d, d"))]
6291 "s390_match_ccmode(insn, CCTmode)
6292 /* Do not steal TM patterns. */
6293 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
6294 "@
6295 nilf\t%0,%o2
6296 nr\t%0,%2
6297 nrk\t%0,%1,%2
6298 n\t%0,%2
6299 ny\t%0,%2
6300 risbg\t%0,%1,%t2,128+%f2,0"
6301 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
6302 (set_attr "cpu_facility" "*,*,z196,*,*,z10")
6303 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
6304 z10_super_E1,z10_super_E1,z10_super_E1")])
6305
6306 (define_insn "*andsi3_zarch"
6307 [(set (match_operand:SI 0 "nonimmediate_operand"
6308 "=d,d, d, d, d,d,d,d,d, d, AQ,Q")
6309 (and:SI (match_operand:SI 1 "nonimmediate_operand"
6310 "%d,o, 0, 0, 0,0,d,0,0, d, 0,0")
6311 (match_operand:SI 2 "general_operand"
6312 " M,M,N0HSF,N1HSF,Os,d,d,R,T,NxxSq,NxQSF,Q")))
6313 (clobber (reg:CC CC_REGNUM))]
6314 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6315 "@
6316 #
6317 #
6318 nilh\t%0,%j2
6319 nill\t%0,%j2
6320 nilf\t%0,%o2
6321 nr\t%0,%2
6322 nrk\t%0,%1,%2
6323 n\t%0,%2
6324 ny\t%0,%2
6325 risbg\t%0,%1,%t2,128+%f2,0
6326 #
6327 #"
6328 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RRF,RX,RXY,RIE,SI,SS")
6329 (set_attr "cpu_facility" "*,*,*,*,*,*,z196,*,*,z10,*,*")
6330 (set_attr "z10prop" "*,
6331 *,
6332 z10_super_E1,
6333 z10_super_E1,
6334 z10_super_E1,
6335 z10_super_E1,
6336 *,
6337 z10_super_E1,
6338 z10_super_E1,
6339 z10_super_E1,
6340 *,
6341 *")])
6342
6343 (define_insn "*andsi3_esa"
6344 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d, AQ,Q")
6345 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0, 0,0")
6346 (match_operand:SI 2 "general_operand" " d,R,NxQSF,Q")))
6347 (clobber (reg:CC CC_REGNUM))]
6348 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6349 "@
6350 nr\t%0,%2
6351 n\t%0,%2
6352 #
6353 #"
6354 [(set_attr "op_type" "RR,RX,SI,SS")
6355 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6356
6357
6358 (define_split
6359 [(set (match_operand:SI 0 "s_operand" "")
6360 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6361 (clobber (reg:CC CC_REGNUM))]
6362 "reload_completed"
6363 [(parallel
6364 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
6365 (clobber (reg:CC CC_REGNUM))])]
6366 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
6367
6368 ;
6369 ; andhi3 instruction pattern(s).
6370 ;
6371
6372 (define_insn "*andhi3_zarch"
6373 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
6374 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
6375 (match_operand:HI 2 "general_operand" " d,d,n,NxQHF,Q")))
6376 (clobber (reg:CC CC_REGNUM))]
6377 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6378 "@
6379 nr\t%0,%2
6380 nrk\t%0,%1,%2
6381 nill\t%0,%x2
6382 #
6383 #"
6384 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
6385 (set_attr "cpu_facility" "*,z196,*,*,*")
6386 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")
6387 ])
6388
6389 (define_insn "*andhi3_esa"
6390 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
6391 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
6392 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
6393 (clobber (reg:CC CC_REGNUM))]
6394 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6395 "@
6396 nr\t%0,%2
6397 #
6398 #"
6399 [(set_attr "op_type" "RR,SI,SS")
6400 (set_attr "z10prop" "z10_super_E1,*,*")
6401 ])
6402
6403 (define_split
6404 [(set (match_operand:HI 0 "s_operand" "")
6405 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6406 (clobber (reg:CC CC_REGNUM))]
6407 "reload_completed"
6408 [(parallel
6409 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
6410 (clobber (reg:CC CC_REGNUM))])]
6411 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
6412
6413 ;
6414 ; andqi3 instruction pattern(s).
6415 ;
6416
6417 (define_insn "*andqi3_zarch"
6418 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
6419 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
6420 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
6421 (clobber (reg:CC CC_REGNUM))]
6422 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6423 "@
6424 nr\t%0,%2
6425 nrk\t%0,%1,%2
6426 nill\t%0,%b2
6427 ni\t%S0,%b2
6428 niy\t%S0,%b2
6429 #"
6430 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
6431 (set_attr "cpu_facility" "*,z196,*,*,*,*")
6432 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super,z10_super,*")])
6433
6434 (define_insn "*andqi3_esa"
6435 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
6436 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6437 (match_operand:QI 2 "general_operand" "d,n,Q")))
6438 (clobber (reg:CC CC_REGNUM))]
6439 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6440 "@
6441 nr\t%0,%2
6442 ni\t%S0,%b2
6443 #"
6444 [(set_attr "op_type" "RR,SI,SS")
6445 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
6446
6447 ;
6448 ; Block and (NC) patterns.
6449 ;
6450
6451 (define_insn "*nc"
6452 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6453 (and:BLK (match_dup 0)
6454 (match_operand:BLK 1 "memory_operand" "Q")))
6455 (use (match_operand 2 "const_int_operand" "n"))
6456 (clobber (reg:CC CC_REGNUM))]
6457 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6458 "nc\t%O0(%2,%R0),%S1"
6459 [(set_attr "op_type" "SS")
6460 (set_attr "z196prop" "z196_cracked")])
6461
6462 (define_split
6463 [(set (match_operand 0 "memory_operand" "")
6464 (and (match_dup 0)
6465 (match_operand 1 "memory_operand" "")))
6466 (clobber (reg:CC CC_REGNUM))]
6467 "reload_completed
6468 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6469 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6470 [(parallel
6471 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
6472 (use (match_dup 2))
6473 (clobber (reg:CC CC_REGNUM))])]
6474 {
6475 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6476 operands[0] = adjust_address (operands[0], BLKmode, 0);
6477 operands[1] = adjust_address (operands[1], BLKmode, 0);
6478 })
6479
6480 (define_peephole2
6481 [(parallel
6482 [(set (match_operand:BLK 0 "memory_operand" "")
6483 (and:BLK (match_dup 0)
6484 (match_operand:BLK 1 "memory_operand" "")))
6485 (use (match_operand 2 "const_int_operand" ""))
6486 (clobber (reg:CC CC_REGNUM))])
6487 (parallel
6488 [(set (match_operand:BLK 3 "memory_operand" "")
6489 (and:BLK (match_dup 3)
6490 (match_operand:BLK 4 "memory_operand" "")))
6491 (use (match_operand 5 "const_int_operand" ""))
6492 (clobber (reg:CC CC_REGNUM))])]
6493 "s390_offset_p (operands[0], operands[3], operands[2])
6494 && s390_offset_p (operands[1], operands[4], operands[2])
6495 && !s390_overlap_p (operands[0], operands[1],
6496 INTVAL (operands[2]) + INTVAL (operands[5]))
6497 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6498 [(parallel
6499 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
6500 (use (match_dup 8))
6501 (clobber (reg:CC CC_REGNUM))])]
6502 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6503 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6504 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6505
6506
6507 ;;
6508 ;;- Bit set (inclusive or) instructions.
6509 ;;
6510
6511 (define_expand "ior<mode>3"
6512 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6513 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
6514 (match_operand:INT 2 "general_operand" "")))
6515 (clobber (reg:CC CC_REGNUM))]
6516 ""
6517 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
6518
6519 ;
6520 ; iordi3 instruction pattern(s).
6521 ;
6522
6523 (define_insn "*iordi3_cc"
6524 [(set (reg CC_REGNUM)
6525 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
6526 (match_operand:DI 2 "general_operand" " d,d,RT"))
6527 (const_int 0)))
6528 (set (match_operand:DI 0 "register_operand" "=d,d, d")
6529 (ior:DI (match_dup 1) (match_dup 2)))]
6530 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
6531 "@
6532 ogr\t%0,%2
6533 ogrk\t%0,%1,%2
6534 og\t%0,%2"
6535 [(set_attr "op_type" "RRE,RRF,RXY")
6536 (set_attr "cpu_facility" "*,z196,*")
6537 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6538
6539 (define_insn "*iordi3_cconly"
6540 [(set (reg CC_REGNUM)
6541 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
6542 (match_operand:DI 2 "general_operand" " d,d,RT"))
6543 (const_int 0)))
6544 (clobber (match_scratch:DI 0 "=d,d,d"))]
6545 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
6546 "@
6547 ogr\t%0,%2
6548 ogrk\t%0,%1,%2
6549 og\t%0,%2"
6550 [(set_attr "op_type" "RRE,RRF,RXY")
6551 (set_attr "cpu_facility" "*,z196,*")
6552 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6553
6554 (define_insn "*iordi3"
6555 [(set (match_operand:DI 0 "nonimmediate_operand"
6556 "=d, d, d, d, d, d,d,d, d, AQ,Q")
6557 (ior:DI (match_operand:DI 1 "nonimmediate_operand"
6558 " %0, 0, 0, 0, 0, 0,0,d, 0, 0,0")
6559 (match_operand:DI 2 "general_operand"
6560 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,d,RT,NxQD0,Q")))
6561 (clobber (reg:CC CC_REGNUM))]
6562 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6563 "@
6564 oihh\t%0,%i2
6565 oihl\t%0,%i2
6566 oilh\t%0,%i2
6567 oill\t%0,%i2
6568 oihf\t%0,%k2
6569 oilf\t%0,%k2
6570 ogr\t%0,%2
6571 ogrk\t%0,%1,%2
6572 og\t%0,%2
6573 #
6574 #"
6575 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,SI,SS")
6576 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,z196,*,*,*")
6577 (set_attr "z10prop" "z10_super_E1,
6578 z10_super_E1,
6579 z10_super_E1,
6580 z10_super_E1,
6581 z10_super_E1,
6582 z10_super_E1,
6583 z10_super_E1,
6584 *,
6585 z10_super_E1,
6586 *,
6587 *")])
6588
6589 (define_split
6590 [(set (match_operand:DI 0 "s_operand" "")
6591 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6592 (clobber (reg:CC CC_REGNUM))]
6593 "reload_completed"
6594 [(parallel
6595 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6596 (clobber (reg:CC CC_REGNUM))])]
6597 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6598
6599 ;
6600 ; iorsi3 instruction pattern(s).
6601 ;
6602
6603 (define_insn "*iorsi3_cc"
6604 [(set (reg CC_REGNUM)
6605 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
6606 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
6607 (const_int 0)))
6608 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
6609 (ior:SI (match_dup 1) (match_dup 2)))]
6610 "s390_match_ccmode(insn, CCTmode)"
6611 "@
6612 oilf\t%0,%o2
6613 or\t%0,%2
6614 ork\t%0,%1,%2
6615 o\t%0,%2
6616 oy\t%0,%2"
6617 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
6618 (set_attr "cpu_facility" "*,*,z196,*,*")
6619 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
6620
6621 (define_insn "*iorsi3_cconly"
6622 [(set (reg CC_REGNUM)
6623 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
6624 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
6625 (const_int 0)))
6626 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
6627 "s390_match_ccmode(insn, CCTmode)"
6628 "@
6629 oilf\t%0,%o2
6630 or\t%0,%2
6631 ork\t%0,%1,%2
6632 o\t%0,%2
6633 oy\t%0,%2"
6634 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
6635 (set_attr "cpu_facility" "*,*,z196,*,*")
6636 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
6637
6638 (define_insn "*iorsi3_zarch"
6639 [(set (match_operand:SI 0 "nonimmediate_operand" "=d, d, d,d,d,d,d, AQ,Q")
6640 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0, 0, 0,0,d,0,0, 0,0")
6641 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,d,R,T,NxQS0,Q")))
6642 (clobber (reg:CC CC_REGNUM))]
6643 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6644 "@
6645 oilh\t%0,%i2
6646 oill\t%0,%i2
6647 oilf\t%0,%o2
6648 or\t%0,%2
6649 ork\t%0,%1,%2
6650 o\t%0,%2
6651 oy\t%0,%2
6652 #
6653 #"
6654 [(set_attr "op_type" "RI,RI,RIL,RR,RRF,RX,RXY,SI,SS")
6655 (set_attr "cpu_facility" "*,*,*,*,z196,*,*,*,*")
6656 (set_attr "z10prop" "z10_super_E1,
6657 z10_super_E1,
6658 z10_super_E1,
6659 z10_super_E1,
6660 *,
6661 z10_super_E1,
6662 z10_super_E1,
6663 *,
6664 *")])
6665
6666 (define_insn "*iorsi3_esa"
6667 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6668 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6669 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
6670 (clobber (reg:CC CC_REGNUM))]
6671 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6672 "@
6673 or\t%0,%2
6674 o\t%0,%2
6675 #
6676 #"
6677 [(set_attr "op_type" "RR,RX,SI,SS")
6678 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6679
6680 (define_split
6681 [(set (match_operand:SI 0 "s_operand" "")
6682 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6683 (clobber (reg:CC CC_REGNUM))]
6684 "reload_completed"
6685 [(parallel
6686 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6687 (clobber (reg:CC CC_REGNUM))])]
6688 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6689
6690 ;
6691 ; iorhi3 instruction pattern(s).
6692 ;
6693
6694 (define_insn "*iorhi3_zarch"
6695 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
6696 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
6697 (match_operand:HI 2 "general_operand" " d,d,n,NxQH0,Q")))
6698 (clobber (reg:CC CC_REGNUM))]
6699 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6700 "@
6701 or\t%0,%2
6702 ork\t%0,%1,%2
6703 oill\t%0,%x2
6704 #
6705 #"
6706 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
6707 (set_attr "cpu_facility" "*,z196,*,*,*")
6708 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")])
6709
6710 (define_insn "*iorhi3_esa"
6711 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
6712 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
6713 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
6714 (clobber (reg:CC CC_REGNUM))]
6715 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6716 "@
6717 or\t%0,%2
6718 #
6719 #"
6720 [(set_attr "op_type" "RR,SI,SS")
6721 (set_attr "z10prop" "z10_super_E1,*,*")])
6722
6723 (define_split
6724 [(set (match_operand:HI 0 "s_operand" "")
6725 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6726 (clobber (reg:CC CC_REGNUM))]
6727 "reload_completed"
6728 [(parallel
6729 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6730 (clobber (reg:CC CC_REGNUM))])]
6731 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6732
6733 ;
6734 ; iorqi3 instruction pattern(s).
6735 ;
6736
6737 (define_insn "*iorqi3_zarch"
6738 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
6739 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
6740 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
6741 (clobber (reg:CC CC_REGNUM))]
6742 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6743 "@
6744 or\t%0,%2
6745 ork\t%0,%1,%2
6746 oill\t%0,%b2
6747 oi\t%S0,%b2
6748 oiy\t%S0,%b2
6749 #"
6750 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
6751 (set_attr "cpu_facility" "*,z196,*,*,*,*")
6752 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,
6753 z10_super,z10_super,*")])
6754
6755 (define_insn "*iorqi3_esa"
6756 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
6757 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6758 (match_operand:QI 2 "general_operand" "d,n,Q")))
6759 (clobber (reg:CC CC_REGNUM))]
6760 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6761 "@
6762 or\t%0,%2
6763 oi\t%S0,%b2
6764 #"
6765 [(set_attr "op_type" "RR,SI,SS")
6766 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
6767
6768 ;
6769 ; Block inclusive or (OC) patterns.
6770 ;
6771
6772 (define_insn "*oc"
6773 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6774 (ior:BLK (match_dup 0)
6775 (match_operand:BLK 1 "memory_operand" "Q")))
6776 (use (match_operand 2 "const_int_operand" "n"))
6777 (clobber (reg:CC CC_REGNUM))]
6778 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6779 "oc\t%O0(%2,%R0),%S1"
6780 [(set_attr "op_type" "SS")
6781 (set_attr "z196prop" "z196_cracked")])
6782
6783 (define_split
6784 [(set (match_operand 0 "memory_operand" "")
6785 (ior (match_dup 0)
6786 (match_operand 1 "memory_operand" "")))
6787 (clobber (reg:CC CC_REGNUM))]
6788 "reload_completed
6789 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6790 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6791 [(parallel
6792 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
6793 (use (match_dup 2))
6794 (clobber (reg:CC CC_REGNUM))])]
6795 {
6796 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6797 operands[0] = adjust_address (operands[0], BLKmode, 0);
6798 operands[1] = adjust_address (operands[1], BLKmode, 0);
6799 })
6800
6801 (define_peephole2
6802 [(parallel
6803 [(set (match_operand:BLK 0 "memory_operand" "")
6804 (ior:BLK (match_dup 0)
6805 (match_operand:BLK 1 "memory_operand" "")))
6806 (use (match_operand 2 "const_int_operand" ""))
6807 (clobber (reg:CC CC_REGNUM))])
6808 (parallel
6809 [(set (match_operand:BLK 3 "memory_operand" "")
6810 (ior:BLK (match_dup 3)
6811 (match_operand:BLK 4 "memory_operand" "")))
6812 (use (match_operand 5 "const_int_operand" ""))
6813 (clobber (reg:CC CC_REGNUM))])]
6814 "s390_offset_p (operands[0], operands[3], operands[2])
6815 && s390_offset_p (operands[1], operands[4], operands[2])
6816 && !s390_overlap_p (operands[0], operands[1],
6817 INTVAL (operands[2]) + INTVAL (operands[5]))
6818 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6819 [(parallel
6820 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
6821 (use (match_dup 8))
6822 (clobber (reg:CC CC_REGNUM))])]
6823 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6824 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6825 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6826
6827
6828 ;;
6829 ;;- Xor instructions.
6830 ;;
6831
6832 (define_expand "xor<mode>3"
6833 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6834 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
6835 (match_operand:INT 2 "general_operand" "")))
6836 (clobber (reg:CC CC_REGNUM))]
6837 ""
6838 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
6839
6840 ;
6841 ; xordi3 instruction pattern(s).
6842 ;
6843
6844 (define_insn "*xordi3_cc"
6845 [(set (reg CC_REGNUM)
6846 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
6847 (match_operand:DI 2 "general_operand" " d,d,RT"))
6848 (const_int 0)))
6849 (set (match_operand:DI 0 "register_operand" "=d,d, d")
6850 (xor:DI (match_dup 1) (match_dup 2)))]
6851 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
6852 "@
6853 xgr\t%0,%2
6854 xgrk\t%0,%1,%2
6855 xg\t%0,%2"
6856 [(set_attr "op_type" "RRE,RRF,RXY")
6857 (set_attr "cpu_facility" "*,z196,*")
6858 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6859
6860 (define_insn "*xordi3_cconly"
6861 [(set (reg CC_REGNUM)
6862 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d, 0")
6863 (match_operand:DI 2 "general_operand" " d,d,RT"))
6864 (const_int 0)))
6865 (clobber (match_scratch:DI 0 "=d,d, d"))]
6866 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
6867 "@
6868 xgr\t%0,%2
6869 xgrk\t%0,%1,%2
6870 xg\t%0,%2"
6871 [(set_attr "op_type" "RRE,RRF,RXY")
6872 (set_attr "cpu_facility" "*,z196,*")
6873 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
6874
6875 (define_insn "*xordi3"
6876 [(set (match_operand:DI 0 "nonimmediate_operand" "=d, d,d,d, d, AQ,Q")
6877 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0, 0,0,d, 0, 0,0")
6878 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,d,RT,NxQD0,Q")))
6879 (clobber (reg:CC CC_REGNUM))]
6880 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6881 "@
6882 xihf\t%0,%k2
6883 xilf\t%0,%k2
6884 xgr\t%0,%2
6885 xgrk\t%0,%1,%2
6886 xg\t%0,%2
6887 #
6888 #"
6889 [(set_attr "op_type" "RIL,RIL,RRE,RRF,RXY,SI,SS")
6890 (set_attr "cpu_facility" "extimm,extimm,*,z196,*,*,*")
6891 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,
6892 *,z10_super_E1,*,*")])
6893
6894 (define_split
6895 [(set (match_operand:DI 0 "s_operand" "")
6896 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6897 (clobber (reg:CC CC_REGNUM))]
6898 "reload_completed"
6899 [(parallel
6900 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6901 (clobber (reg:CC CC_REGNUM))])]
6902 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6903
6904 ;
6905 ; xorsi3 instruction pattern(s).
6906 ;
6907
6908 (define_insn "*xorsi3_cc"
6909 [(set (reg CC_REGNUM)
6910 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
6911 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
6912 (const_int 0)))
6913 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
6914 (xor:SI (match_dup 1) (match_dup 2)))]
6915 "s390_match_ccmode(insn, CCTmode)"
6916 "@
6917 xilf\t%0,%o2
6918 xr\t%0,%2
6919 xrk\t%0,%1,%2
6920 x\t%0,%2
6921 xy\t%0,%2"
6922 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
6923 (set_attr "cpu_facility" "*,*,z196,*,*")
6924 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
6925 z10_super_E1,z10_super_E1")])
6926
6927 (define_insn "*xorsi3_cconly"
6928 [(set (reg CC_REGNUM)
6929 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
6930 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
6931 (const_int 0)))
6932 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
6933 "s390_match_ccmode(insn, CCTmode)"
6934 "@
6935 xilf\t%0,%o2
6936 xr\t%0,%2
6937 xrk\t%0,%1,%2
6938 x\t%0,%2
6939 xy\t%0,%2"
6940 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
6941 (set_attr "cpu_facility" "*,*,z196,*,*")
6942 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
6943 z10_super_E1,z10_super_E1")])
6944
6945 (define_insn "*xorsi3"
6946 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d, AQ,Q")
6947 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, 0,0")
6948 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxQS0,Q")))
6949 (clobber (reg:CC CC_REGNUM))]
6950 "s390_logical_operator_ok_p (operands)"
6951 "@
6952 xilf\t%0,%o2
6953 xr\t%0,%2
6954 xrk\t%0,%1,%2
6955 x\t%0,%2
6956 xy\t%0,%2
6957 #
6958 #"
6959 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,SI,SS")
6960 (set_attr "cpu_facility" "*,*,z196,*,*,*,*")
6961 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
6962 z10_super_E1,z10_super_E1,*,*")])
6963
6964 (define_split
6965 [(set (match_operand:SI 0 "s_operand" "")
6966 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6967 (clobber (reg:CC CC_REGNUM))]
6968 "reload_completed"
6969 [(parallel
6970 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6971 (clobber (reg:CC CC_REGNUM))])]
6972 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6973
6974 ;
6975 ; xorhi3 instruction pattern(s).
6976 ;
6977
6978 (define_insn "*xorhi3"
6979 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
6980 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,d, 0,0")
6981 (match_operand:HI 2 "general_operand" "Os,d,d,NxQH0,Q")))
6982 (clobber (reg:CC CC_REGNUM))]
6983 "s390_logical_operator_ok_p (operands)"
6984 "@
6985 xilf\t%0,%x2
6986 xr\t%0,%2
6987 xrk\t%0,%1,%2
6988 #
6989 #"
6990 [(set_attr "op_type" "RIL,RR,RRF,SI,SS")
6991 (set_attr "cpu_facility" "*,*,z196,*,*")
6992 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*,*")])
6993
6994 (define_split
6995 [(set (match_operand:HI 0 "s_operand" "")
6996 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6997 (clobber (reg:CC CC_REGNUM))]
6998 "reload_completed"
6999 [(parallel
7000 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
7001 (clobber (reg:CC CC_REGNUM))])]
7002 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
7003
7004 ;
7005 ; xorqi3 instruction pattern(s).
7006 ;
7007
7008 (define_insn "*xorqi3"
7009 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7010 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,d,0,0,0")
7011 (match_operand:QI 2 "general_operand" "Os,d,d,n,n,Q")))
7012 (clobber (reg:CC CC_REGNUM))]
7013 "s390_logical_operator_ok_p (operands)"
7014 "@
7015 xilf\t%0,%b2
7016 xr\t%0,%2
7017 xrk\t%0,%1,%2
7018 xi\t%S0,%b2
7019 xiy\t%S0,%b2
7020 #"
7021 [(set_attr "op_type" "RIL,RR,RRF,SI,SIY,SS")
7022 (set_attr "cpu_facility" "*,*,z196,*,*,*")
7023 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super,z10_super,*")])
7024
7025
7026 ;
7027 ; Block exclusive or (XC) patterns.
7028 ;
7029
7030 (define_insn "*xc"
7031 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7032 (xor:BLK (match_dup 0)
7033 (match_operand:BLK 1 "memory_operand" "Q")))
7034 (use (match_operand 2 "const_int_operand" "n"))
7035 (clobber (reg:CC CC_REGNUM))]
7036 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
7037 "xc\t%O0(%2,%R0),%S1"
7038 [(set_attr "op_type" "SS")])
7039
7040 (define_split
7041 [(set (match_operand 0 "memory_operand" "")
7042 (xor (match_dup 0)
7043 (match_operand 1 "memory_operand" "")))
7044 (clobber (reg:CC CC_REGNUM))]
7045 "reload_completed
7046 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7047 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7048 [(parallel
7049 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
7050 (use (match_dup 2))
7051 (clobber (reg:CC CC_REGNUM))])]
7052 {
7053 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7054 operands[0] = adjust_address (operands[0], BLKmode, 0);
7055 operands[1] = adjust_address (operands[1], BLKmode, 0);
7056 })
7057
7058 (define_peephole2
7059 [(parallel
7060 [(set (match_operand:BLK 0 "memory_operand" "")
7061 (xor:BLK (match_dup 0)
7062 (match_operand:BLK 1 "memory_operand" "")))
7063 (use (match_operand 2 "const_int_operand" ""))
7064 (clobber (reg:CC CC_REGNUM))])
7065 (parallel
7066 [(set (match_operand:BLK 3 "memory_operand" "")
7067 (xor:BLK (match_dup 3)
7068 (match_operand:BLK 4 "memory_operand" "")))
7069 (use (match_operand 5 "const_int_operand" ""))
7070 (clobber (reg:CC CC_REGNUM))])]
7071 "s390_offset_p (operands[0], operands[3], operands[2])
7072 && s390_offset_p (operands[1], operands[4], operands[2])
7073 && !s390_overlap_p (operands[0], operands[1],
7074 INTVAL (operands[2]) + INTVAL (operands[5]))
7075 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7076 [(parallel
7077 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
7078 (use (match_dup 8))
7079 (clobber (reg:CC CC_REGNUM))])]
7080 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7081 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7082 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7083
7084 ;
7085 ; Block xor (XC) patterns with src == dest.
7086 ;
7087
7088 (define_insn "*xc_zero"
7089 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7090 (const_int 0))
7091 (use (match_operand 1 "const_int_operand" "n"))
7092 (clobber (reg:CC CC_REGNUM))]
7093 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
7094 "xc\t%O0(%1,%R0),%S0"
7095 [(set_attr "op_type" "SS")
7096 (set_attr "z196prop" "z196_cracked")])
7097
7098 (define_peephole2
7099 [(parallel
7100 [(set (match_operand:BLK 0 "memory_operand" "")
7101 (const_int 0))
7102 (use (match_operand 1 "const_int_operand" ""))
7103 (clobber (reg:CC CC_REGNUM))])
7104 (parallel
7105 [(set (match_operand:BLK 2 "memory_operand" "")
7106 (const_int 0))
7107 (use (match_operand 3 "const_int_operand" ""))
7108 (clobber (reg:CC CC_REGNUM))])]
7109 "s390_offset_p (operands[0], operands[2], operands[1])
7110 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
7111 [(parallel
7112 [(set (match_dup 4) (const_int 0))
7113 (use (match_dup 5))
7114 (clobber (reg:CC CC_REGNUM))])]
7115 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7116 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
7117
7118
7119 ;;
7120 ;;- Negate instructions.
7121 ;;
7122
7123 ;
7124 ; neg(di|si)2 instruction pattern(s).
7125 ;
7126
7127 (define_expand "neg<mode>2"
7128 [(parallel
7129 [(set (match_operand:DSI 0 "register_operand" "=d")
7130 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
7131 (clobber (reg:CC CC_REGNUM))])]
7132 ""
7133 "")
7134
7135 (define_insn "*negdi2_sign_cc"
7136 [(set (reg CC_REGNUM)
7137 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
7138 (match_operand:SI 1 "register_operand" "d") 0)
7139 (const_int 32)) (const_int 32)))
7140 (const_int 0)))
7141 (set (match_operand:DI 0 "register_operand" "=d")
7142 (neg:DI (sign_extend:DI (match_dup 1))))]
7143 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
7144 "lcgfr\t%0,%1"
7145 [(set_attr "op_type" "RRE")
7146 (set_attr "z10prop" "z10_c")])
7147
7148 (define_insn "*negdi2_sign"
7149 [(set (match_operand:DI 0 "register_operand" "=d")
7150 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
7151 (clobber (reg:CC CC_REGNUM))]
7152 "TARGET_ZARCH"
7153 "lcgfr\t%0,%1"
7154 [(set_attr "op_type" "RRE")
7155 (set_attr "z10prop" "z10_c")])
7156
7157 ; lcr, lcgr
7158 (define_insn "*neg<mode>2_cc"
7159 [(set (reg CC_REGNUM)
7160 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
7161 (const_int 0)))
7162 (set (match_operand:GPR 0 "register_operand" "=d")
7163 (neg:GPR (match_dup 1)))]
7164 "s390_match_ccmode (insn, CCAmode)"
7165 "lc<g>r\t%0,%1"
7166 [(set_attr "op_type" "RR<E>")
7167 (set_attr "z10prop" "z10_super_c_E1")])
7168
7169 ; lcr, lcgr
7170 (define_insn "*neg<mode>2_cconly"
7171 [(set (reg CC_REGNUM)
7172 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
7173 (const_int 0)))
7174 (clobber (match_scratch:GPR 0 "=d"))]
7175 "s390_match_ccmode (insn, CCAmode)"
7176 "lc<g>r\t%0,%1"
7177 [(set_attr "op_type" "RR<E>")
7178 (set_attr "z10prop" "z10_super_c_E1")])
7179
7180 ; lcr, lcgr
7181 (define_insn "*neg<mode>2"
7182 [(set (match_operand:GPR 0 "register_operand" "=d")
7183 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
7184 (clobber (reg:CC CC_REGNUM))]
7185 ""
7186 "lc<g>r\t%0,%1"
7187 [(set_attr "op_type" "RR<E>")
7188 (set_attr "z10prop" "z10_super_c_E1")])
7189
7190 (define_insn_and_split "*negdi2_31"
7191 [(set (match_operand:DI 0 "register_operand" "=d")
7192 (neg:DI (match_operand:DI 1 "register_operand" "d")))
7193 (clobber (reg:CC CC_REGNUM))]
7194 "!TARGET_ZARCH"
7195 "#"
7196 "&& reload_completed"
7197 [(parallel
7198 [(set (match_dup 2) (neg:SI (match_dup 3)))
7199 (clobber (reg:CC CC_REGNUM))])
7200 (parallel
7201 [(set (reg:CCAP CC_REGNUM)
7202 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
7203 (set (match_dup 4) (neg:SI (match_dup 5)))])
7204 (set (pc)
7205 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
7206 (pc)
7207 (label_ref (match_dup 6))))
7208 (parallel
7209 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
7210 (clobber (reg:CC CC_REGNUM))])
7211 (match_dup 6)]
7212 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
7213 operands[3] = operand_subword (operands[1], 0, 0, DImode);
7214 operands[4] = operand_subword (operands[0], 1, 0, DImode);
7215 operands[5] = operand_subword (operands[1], 1, 0, DImode);
7216 operands[6] = gen_label_rtx ();")
7217
7218 ;
7219 ; neg(df|sf)2 instruction pattern(s).
7220 ;
7221
7222 (define_expand "neg<mode>2"
7223 [(parallel
7224 [(set (match_operand:BFP 0 "register_operand" "=f")
7225 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
7226 (clobber (reg:CC CC_REGNUM))])]
7227 "TARGET_HARD_FLOAT"
7228 "")
7229
7230 ; lcxbr, lcdbr, lcebr
7231 (define_insn "*neg<mode>2_cc"
7232 [(set (reg CC_REGNUM)
7233 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
7234 (match_operand:BFP 2 "const0_operand" "")))
7235 (set (match_operand:BFP 0 "register_operand" "=f")
7236 (neg:BFP (match_dup 1)))]
7237 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7238 "lc<xde>br\t%0,%1"
7239 [(set_attr "op_type" "RRE")
7240 (set_attr "type" "fsimp<mode>")])
7241
7242 ; lcxbr, lcdbr, lcebr
7243 (define_insn "*neg<mode>2_cconly"
7244 [(set (reg CC_REGNUM)
7245 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
7246 (match_operand:BFP 2 "const0_operand" "")))
7247 (clobber (match_scratch:BFP 0 "=f"))]
7248 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7249 "lc<xde>br\t%0,%1"
7250 [(set_attr "op_type" "RRE")
7251 (set_attr "type" "fsimp<mode>")])
7252
7253 ; lcdfr
7254 (define_insn "*neg<mode>2_nocc"
7255 [(set (match_operand:FP 0 "register_operand" "=f")
7256 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
7257 "TARGET_DFP"
7258 "lcdfr\t%0,%1"
7259 [(set_attr "op_type" "RRE")
7260 (set_attr "type" "fsimp<mode>")])
7261
7262 ; lcxbr, lcdbr, lcebr
7263 (define_insn "*neg<mode>2"
7264 [(set (match_operand:BFP 0 "register_operand" "=f")
7265 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
7266 (clobber (reg:CC CC_REGNUM))]
7267 "TARGET_HARD_FLOAT"
7268 "lc<xde>br\t%0,%1"
7269 [(set_attr "op_type" "RRE")
7270 (set_attr "type" "fsimp<mode>")])
7271
7272
7273 ;;
7274 ;;- Absolute value instructions.
7275 ;;
7276
7277 ;
7278 ; abs(di|si)2 instruction pattern(s).
7279 ;
7280
7281 (define_insn "*absdi2_sign_cc"
7282 [(set (reg CC_REGNUM)
7283 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
7284 (match_operand:SI 1 "register_operand" "d") 0)
7285 (const_int 32)) (const_int 32)))
7286 (const_int 0)))
7287 (set (match_operand:DI 0 "register_operand" "=d")
7288 (abs:DI (sign_extend:DI (match_dup 1))))]
7289 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
7290 "lpgfr\t%0,%1"
7291 [(set_attr "op_type" "RRE")
7292 (set_attr "z10prop" "z10_c")])
7293
7294 (define_insn "*absdi2_sign"
7295 [(set (match_operand:DI 0 "register_operand" "=d")
7296 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
7297 (clobber (reg:CC CC_REGNUM))]
7298 "TARGET_ZARCH"
7299 "lpgfr\t%0,%1"
7300 [(set_attr "op_type" "RRE")
7301 (set_attr "z10prop" "z10_c")])
7302
7303 ; lpr, lpgr
7304 (define_insn "*abs<mode>2_cc"
7305 [(set (reg CC_REGNUM)
7306 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
7307 (const_int 0)))
7308 (set (match_operand:GPR 0 "register_operand" "=d")
7309 (abs:GPR (match_dup 1)))]
7310 "s390_match_ccmode (insn, CCAmode)"
7311 "lp<g>r\t%0,%1"
7312 [(set_attr "op_type" "RR<E>")
7313 (set_attr "z10prop" "z10_c")])
7314
7315 ; lpr, lpgr
7316 (define_insn "*abs<mode>2_cconly"
7317 [(set (reg CC_REGNUM)
7318 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
7319 (const_int 0)))
7320 (clobber (match_scratch:GPR 0 "=d"))]
7321 "s390_match_ccmode (insn, CCAmode)"
7322 "lp<g>r\t%0,%1"
7323 [(set_attr "op_type" "RR<E>")
7324 (set_attr "z10prop" "z10_c")])
7325
7326 ; lpr, lpgr
7327 (define_insn "abs<mode>2"
7328 [(set (match_operand:GPR 0 "register_operand" "=d")
7329 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
7330 (clobber (reg:CC CC_REGNUM))]
7331 ""
7332 "lp<g>r\t%0,%1"
7333 [(set_attr "op_type" "RR<E>")
7334 (set_attr "z10prop" "z10_c")])
7335
7336 ;
7337 ; abs(df|sf)2 instruction pattern(s).
7338 ;
7339
7340 (define_expand "abs<mode>2"
7341 [(parallel
7342 [(set (match_operand:BFP 0 "register_operand" "=f")
7343 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7344 (clobber (reg:CC CC_REGNUM))])]
7345 "TARGET_HARD_FLOAT"
7346 "")
7347
7348 ; lpxbr, lpdbr, lpebr
7349 (define_insn "*abs<mode>2_cc"
7350 [(set (reg CC_REGNUM)
7351 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
7352 (match_operand:BFP 2 "const0_operand" "")))
7353 (set (match_operand:BFP 0 "register_operand" "=f")
7354 (abs:BFP (match_dup 1)))]
7355 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7356 "lp<xde>br\t%0,%1"
7357 [(set_attr "op_type" "RRE")
7358 (set_attr "type" "fsimp<mode>")])
7359
7360 ; lpxbr, lpdbr, lpebr
7361 (define_insn "*abs<mode>2_cconly"
7362 [(set (reg CC_REGNUM)
7363 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
7364 (match_operand:BFP 2 "const0_operand" "")))
7365 (clobber (match_scratch:BFP 0 "=f"))]
7366 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7367 "lp<xde>br\t%0,%1"
7368 [(set_attr "op_type" "RRE")
7369 (set_attr "type" "fsimp<mode>")])
7370
7371 ; lpdfr
7372 (define_insn "*abs<mode>2_nocc"
7373 [(set (match_operand:FP 0 "register_operand" "=f")
7374 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
7375 "TARGET_DFP"
7376 "lpdfr\t%0,%1"
7377 [(set_attr "op_type" "RRE")
7378 (set_attr "type" "fsimp<mode>")])
7379
7380 ; lpxbr, lpdbr, lpebr
7381 (define_insn "*abs<mode>2"
7382 [(set (match_operand:BFP 0 "register_operand" "=f")
7383 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7384 (clobber (reg:CC CC_REGNUM))]
7385 "TARGET_HARD_FLOAT"
7386 "lp<xde>br\t%0,%1"
7387 [(set_attr "op_type" "RRE")
7388 (set_attr "type" "fsimp<mode>")])
7389
7390
7391 ;;
7392 ;;- Negated absolute value instructions
7393 ;;
7394
7395 ;
7396 ; Integer
7397 ;
7398
7399 (define_insn "*negabsdi2_sign_cc"
7400 [(set (reg CC_REGNUM)
7401 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
7402 (match_operand:SI 1 "register_operand" "d") 0)
7403 (const_int 32)) (const_int 32))))
7404 (const_int 0)))
7405 (set (match_operand:DI 0 "register_operand" "=d")
7406 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
7407 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
7408 "lngfr\t%0,%1"
7409 [(set_attr "op_type" "RRE")
7410 (set_attr "z10prop" "z10_c")])
7411
7412 (define_insn "*negabsdi2_sign"
7413 [(set (match_operand:DI 0 "register_operand" "=d")
7414 (neg:DI (abs:DI (sign_extend:DI
7415 (match_operand:SI 1 "register_operand" "d")))))
7416 (clobber (reg:CC CC_REGNUM))]
7417 "TARGET_ZARCH"
7418 "lngfr\t%0,%1"
7419 [(set_attr "op_type" "RRE")
7420 (set_attr "z10prop" "z10_c")])
7421
7422 ; lnr, lngr
7423 (define_insn "*negabs<mode>2_cc"
7424 [(set (reg CC_REGNUM)
7425 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
7426 (const_int 0)))
7427 (set (match_operand:GPR 0 "register_operand" "=d")
7428 (neg:GPR (abs:GPR (match_dup 1))))]
7429 "s390_match_ccmode (insn, CCAmode)"
7430 "ln<g>r\t%0,%1"
7431 [(set_attr "op_type" "RR<E>")
7432 (set_attr "z10prop" "z10_c")])
7433
7434 ; lnr, lngr
7435 (define_insn "*negabs<mode>2_cconly"
7436 [(set (reg CC_REGNUM)
7437 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
7438 (const_int 0)))
7439 (clobber (match_scratch:GPR 0 "=d"))]
7440 "s390_match_ccmode (insn, CCAmode)"
7441 "ln<g>r\t%0,%1"
7442 [(set_attr "op_type" "RR<E>")
7443 (set_attr "z10prop" "z10_c")])
7444
7445 ; lnr, lngr
7446 (define_insn "*negabs<mode>2"
7447 [(set (match_operand:GPR 0 "register_operand" "=d")
7448 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
7449 (clobber (reg:CC CC_REGNUM))]
7450 ""
7451 "ln<g>r\t%0,%1"
7452 [(set_attr "op_type" "RR<E>")
7453 (set_attr "z10prop" "z10_c")])
7454
7455 ;
7456 ; Floating point
7457 ;
7458
7459 ; lnxbr, lndbr, lnebr
7460 (define_insn "*negabs<mode>2_cc"
7461 [(set (reg CC_REGNUM)
7462 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7463 (match_operand:BFP 2 "const0_operand" "")))
7464 (set (match_operand:BFP 0 "register_operand" "=f")
7465 (neg:BFP (abs:BFP (match_dup 1))))]
7466 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7467 "ln<xde>br\t%0,%1"
7468 [(set_attr "op_type" "RRE")
7469 (set_attr "type" "fsimp<mode>")])
7470
7471 ; lnxbr, lndbr, lnebr
7472 (define_insn "*negabs<mode>2_cconly"
7473 [(set (reg CC_REGNUM)
7474 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
7475 (match_operand:BFP 2 "const0_operand" "")))
7476 (clobber (match_scratch:BFP 0 "=f"))]
7477 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
7478 "ln<xde>br\t%0,%1"
7479 [(set_attr "op_type" "RRE")
7480 (set_attr "type" "fsimp<mode>")])
7481
7482 ; lndfr
7483 (define_insn "*negabs<mode>2_nocc"
7484 [(set (match_operand:FP 0 "register_operand" "=f")
7485 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
7486 "TARGET_DFP"
7487 "lndfr\t%0,%1"
7488 [(set_attr "op_type" "RRE")
7489 (set_attr "type" "fsimp<mode>")])
7490
7491 ; lnxbr, lndbr, lnebr
7492 (define_insn "*negabs<mode>2"
7493 [(set (match_operand:BFP 0 "register_operand" "=f")
7494 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f"))))
7495 (clobber (reg:CC CC_REGNUM))]
7496 "TARGET_HARD_FLOAT"
7497 "ln<xde>br\t%0,%1"
7498 [(set_attr "op_type" "RRE")
7499 (set_attr "type" "fsimp<mode>")])
7500
7501 ;;
7502 ;;- Square root instructions.
7503 ;;
7504
7505 ;
7506 ; sqrt(df|sf)2 instruction pattern(s).
7507 ;
7508
7509 ; sqxbr, sqdbr, sqebr, sqdb, sqeb
7510 (define_insn "sqrt<mode>2"
7511 [(set (match_operand:BFP 0 "register_operand" "=f,f")
7512 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,<Rf>")))]
7513 "TARGET_HARD_FLOAT"
7514 "@
7515 sq<xde>br\t%0,%1
7516 sq<xde>b\t%0,%1"
7517 [(set_attr "op_type" "RRE,RXE")
7518 (set_attr "type" "fsqrt<mode>")])
7519
7520
7521 ;;
7522 ;;- One complement instructions.
7523 ;;
7524
7525 ;
7526 ; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
7527 ;
7528
7529 (define_expand "one_cmpl<mode>2"
7530 [(parallel
7531 [(set (match_operand:INT 0 "register_operand" "")
7532 (xor:INT (match_operand:INT 1 "register_operand" "")
7533 (const_int -1)))
7534 (clobber (reg:CC CC_REGNUM))])]
7535 ""
7536 "")
7537
7538
7539 ;;
7540 ;; Find leftmost bit instructions.
7541 ;;
7542
7543 (define_expand "clzdi2"
7544 [(set (match_operand:DI 0 "register_operand" "=d")
7545 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
7546 "TARGET_EXTIMM && TARGET_ZARCH"
7547 {
7548 rtx insn, clz_equal;
7549 rtx wide_reg = gen_reg_rtx (TImode);
7550 rtx msb = gen_rtx_CONST_INT (DImode, (unsigned HOST_WIDE_INT) 1 << 63);
7551
7552 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
7553
7554 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
7555
7556 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
7557 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
7558
7559 DONE;
7560 })
7561
7562 (define_insn "clztidi2"
7563 [(set (match_operand:TI 0 "register_operand" "=d")
7564 (ior:TI
7565 (ashift:TI
7566 (zero_extend:TI
7567 (xor:DI (match_operand:DI 1 "register_operand" "d")
7568 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
7569 (subreg:SI (clz:DI (match_dup 1)) 4))))
7570
7571 (const_int 64))
7572 (zero_extend:TI (clz:DI (match_dup 1)))))
7573 (clobber (reg:CC CC_REGNUM))]
7574 "(unsigned HOST_WIDE_INT) INTVAL (operands[2])
7575 == (unsigned HOST_WIDE_INT) 1 << 63
7576 && TARGET_EXTIMM && TARGET_ZARCH"
7577 "flogr\t%0,%1"
7578 [(set_attr "op_type" "RRE")])
7579
7580
7581 ;;
7582 ;;- Rotate instructions.
7583 ;;
7584
7585 ;
7586 ; rotl(di|si)3 instruction pattern(s).
7587 ;
7588
7589 ; rll, rllg
7590 (define_insn "rotl<mode>3"
7591 [(set (match_operand:GPR 0 "register_operand" "=d")
7592 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7593 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7594 "TARGET_CPU_ZARCH"
7595 "rll<g>\t%0,%1,%Y2"
7596 [(set_attr "op_type" "RSE")
7597 (set_attr "atype" "reg")
7598 (set_attr "z10prop" "z10_super_E1")])
7599
7600 ; rll, rllg
7601 (define_insn "*rotl<mode>3_and"
7602 [(set (match_operand:GPR 0 "register_operand" "=d")
7603 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7604 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7605 (match_operand:SI 3 "const_int_operand" "n"))))]
7606 "TARGET_CPU_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7607 "rll<g>\t%0,%1,%Y2"
7608 [(set_attr "op_type" "RSE")
7609 (set_attr "atype" "reg")
7610 (set_attr "z10prop" "z10_super_E1")])
7611
7612
7613 ;;
7614 ;;- Shift instructions.
7615 ;;
7616
7617 ;
7618 ; (ashl|lshr)(di|si)3 instruction pattern(s).
7619 ; Left shifts and logical right shifts
7620
7621 (define_expand "<shift><mode>3"
7622 [(set (match_operand:DSI 0 "register_operand" "")
7623 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
7624 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))]
7625 ""
7626 "")
7627
7628 ; sldl, srdl
7629 (define_insn "*<shift>di3_31"
7630 [(set (match_operand:DI 0 "register_operand" "=d")
7631 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7632 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7633 "!TARGET_ZARCH"
7634 "s<lr>dl\t%0,%Y2"
7635 [(set_attr "op_type" "RS")
7636 (set_attr "atype" "reg")
7637 (set_attr "z196prop" "z196_cracked")])
7638
7639 ; sll, srl, sllg, srlg, sllk, srlk
7640 (define_insn "*<shift><mode>3"
7641 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7642 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7643 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")))]
7644 ""
7645 "@
7646 s<lr>l<g>\t%0,<1>%Y2
7647 s<lr>l<gk>\t%0,%1,%Y2"
7648 [(set_attr "op_type" "RS<E>,RSY")
7649 (set_attr "atype" "reg,reg")
7650 (set_attr "cpu_facility" "*,z196")
7651 (set_attr "z10prop" "z10_super_E1,*")])
7652
7653 ; sldl, srdl
7654 (define_insn "*<shift>di3_31_and"
7655 [(set (match_operand:DI 0 "register_operand" "=d")
7656 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7657 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7658 (match_operand:SI 3 "const_int_operand" "n"))))]
7659 "!TARGET_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7660 "s<lr>dl\t%0,%Y2"
7661 [(set_attr "op_type" "RS")
7662 (set_attr "atype" "reg")])
7663
7664 ; sll, srl, sllg, srlg, sllk, srlk
7665 (define_insn "*<shift><mode>3_and"
7666 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7667 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7668 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
7669 (match_operand:SI 3 "const_int_operand" "n,n"))))]
7670 "(INTVAL (operands[3]) & 63) == 63"
7671 "@
7672 s<lr>l<g>\t%0,<1>%Y2
7673 s<lr>l<gk>\t%0,%1,%Y2"
7674 [(set_attr "op_type" "RS<E>,RSY")
7675 (set_attr "atype" "reg,reg")
7676 (set_attr "cpu_facility" "*,z196")
7677 (set_attr "z10prop" "z10_super_E1,*")])
7678
7679 ;
7680 ; ashr(di|si)3 instruction pattern(s).
7681 ; Arithmetic right shifts
7682
7683 (define_expand "ashr<mode>3"
7684 [(parallel
7685 [(set (match_operand:DSI 0 "register_operand" "")
7686 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
7687 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))
7688 (clobber (reg:CC CC_REGNUM))])]
7689 ""
7690 "")
7691
7692 (define_insn "*ashrdi3_cc_31"
7693 [(set (reg CC_REGNUM)
7694 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7695 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7696 (const_int 0)))
7697 (set (match_operand:DI 0 "register_operand" "=d")
7698 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7699 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)"
7700 "srda\t%0,%Y2"
7701 [(set_attr "op_type" "RS")
7702 (set_attr "atype" "reg")])
7703
7704 (define_insn "*ashrdi3_cconly_31"
7705 [(set (reg CC_REGNUM)
7706 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7707 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7708 (const_int 0)))
7709 (clobber (match_scratch:DI 0 "=d"))]
7710 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)"
7711 "srda\t%0,%Y2"
7712 [(set_attr "op_type" "RS")
7713 (set_attr "atype" "reg")])
7714
7715 (define_insn "*ashrdi3_31"
7716 [(set (match_operand:DI 0 "register_operand" "=d")
7717 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7718 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
7719 (clobber (reg:CC CC_REGNUM))]
7720 "!TARGET_ZARCH"
7721 "srda\t%0,%Y2"
7722 [(set_attr "op_type" "RS")
7723 (set_attr "atype" "reg")])
7724
7725 ; sra, srag, srak
7726 (define_insn "*ashr<mode>3_cc"
7727 [(set (reg CC_REGNUM)
7728 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7729 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y"))
7730 (const_int 0)))
7731 (set (match_operand:GPR 0 "register_operand" "=d,d")
7732 (ashiftrt:GPR (match_dup 1) (match_dup 2)))]
7733 "s390_match_ccmode(insn, CCSmode)"
7734 "@
7735 sra<g>\t%0,<1>%Y2
7736 sra<gk>\t%0,%1,%Y2"
7737 [(set_attr "op_type" "RS<E>,RSY")
7738 (set_attr "atype" "reg,reg")
7739 (set_attr "cpu_facility" "*,z196")
7740 (set_attr "z10prop" "z10_super_E1,*")])
7741
7742 ; sra, srag, srak
7743 (define_insn "*ashr<mode>3_cconly"
7744 [(set (reg CC_REGNUM)
7745 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7746 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y"))
7747 (const_int 0)))
7748 (clobber (match_scratch:GPR 0 "=d,d"))]
7749 "s390_match_ccmode(insn, CCSmode)"
7750 "@
7751 sra<g>\t%0,<1>%Y2
7752 sra<gk>\t%0,%1,%Y2"
7753 [(set_attr "op_type" "RS<E>,RSY")
7754 (set_attr "atype" "reg,reg")
7755 (set_attr "cpu_facility" "*,z196")
7756 (set_attr "z10prop" "z10_super_E1,*")])
7757
7758 ; sra, srag
7759 (define_insn "*ashr<mode>3"
7760 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7761 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7762 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")))
7763 (clobber (reg:CC CC_REGNUM))]
7764 ""
7765 "@
7766 sra<g>\t%0,<1>%Y2
7767 sra<gk>\t%0,%1,%Y2"
7768 [(set_attr "op_type" "RS<E>,RSY")
7769 (set_attr "atype" "reg,reg")
7770 (set_attr "cpu_facility" "*,z196")
7771 (set_attr "z10prop" "z10_super_E1,*")])
7772
7773
7774 ; shift pattern with implicit ANDs
7775
7776 (define_insn "*ashrdi3_cc_31_and"
7777 [(set (reg CC_REGNUM)
7778 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7779 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7780 (match_operand:SI 3 "const_int_operand" "n")))
7781 (const_int 0)))
7782 (set (match_operand:DI 0 "register_operand" "=d")
7783 (ashiftrt:DI (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7784 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)
7785 && (INTVAL (operands[3]) & 63) == 63"
7786 "srda\t%0,%Y2"
7787 [(set_attr "op_type" "RS")
7788 (set_attr "atype" "reg")])
7789
7790 (define_insn "*ashrdi3_cconly_31_and"
7791 [(set (reg CC_REGNUM)
7792 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7793 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7794 (match_operand:SI 3 "const_int_operand" "n")))
7795 (const_int 0)))
7796 (clobber (match_scratch:DI 0 "=d"))]
7797 "!TARGET_ZARCH && s390_match_ccmode(insn, CCSmode)
7798 && (INTVAL (operands[3]) & 63) == 63"
7799 "srda\t%0,%Y2"
7800 [(set_attr "op_type" "RS")
7801 (set_attr "atype" "reg")])
7802
7803 (define_insn "*ashrdi3_31_and"
7804 [(set (match_operand:DI 0 "register_operand" "=d")
7805 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7806 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7807 (match_operand:SI 3 "const_int_operand" "n"))))
7808 (clobber (reg:CC CC_REGNUM))]
7809 "!TARGET_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7810 "srda\t%0,%Y2"
7811 [(set_attr "op_type" "RS")
7812 (set_attr "atype" "reg")])
7813
7814 ; sra, srag, srak
7815 (define_insn "*ashr<mode>3_cc_and"
7816 [(set (reg CC_REGNUM)
7817 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7818 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
7819 (match_operand:SI 3 "const_int_operand" "n,n")))
7820 (const_int 0)))
7821 (set (match_operand:GPR 0 "register_operand" "=d,d")
7822 (ashiftrt:GPR (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7823 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7824 "@
7825 sra<g>\t%0,<1>%Y2
7826 sra<gk>\t%0,%1,%Y2"
7827 [(set_attr "op_type" "RS<E>,RSY")
7828 (set_attr "atype" "reg,reg")
7829 (set_attr "cpu_facility" "*,z196")
7830 (set_attr "z10prop" "z10_super_E1,*")])
7831
7832 ; sra, srag, srak
7833 (define_insn "*ashr<mode>3_cconly_and"
7834 [(set (reg CC_REGNUM)
7835 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7836 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
7837 (match_operand:SI 3 "const_int_operand" "n,n")))
7838 (const_int 0)))
7839 (clobber (match_scratch:GPR 0 "=d,d"))]
7840 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7841 "@
7842 sra<g>\t%0,<1>%Y2
7843 sra<gk>\t%0,%1,%Y2"
7844 [(set_attr "op_type" "RS<E>,RSY")
7845 (set_attr "atype" "reg,reg")
7846 (set_attr "cpu_facility" "*,z196")
7847 (set_attr "z10prop" "z10_super_E1,*")])
7848
7849 ; sra, srag, srak
7850 (define_insn "*ashr<mode>3_and"
7851 [(set (match_operand:GPR 0 "register_operand" "=d,d")
7852 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>,d")
7853 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y,Y")
7854 (match_operand:SI 3 "const_int_operand" "n,n"))))
7855 (clobber (reg:CC CC_REGNUM))]
7856 "(INTVAL (operands[3]) & 63) == 63"
7857 "@
7858 sra<g>\t%0,<1>%Y2
7859 sra<gk>\t%0,%1,%Y2"
7860 [(set_attr "op_type" "RS<E>,RSY")
7861 (set_attr "atype" "reg,reg")
7862 (set_attr "cpu_facility" "*,z196")
7863 (set_attr "z10prop" "z10_super_E1,*")])
7864
7865
7866 ;;
7867 ;; Branch instruction patterns.
7868 ;;
7869
7870 (define_expand "cbranch<mode>4"
7871 [(set (pc)
7872 (if_then_else (match_operator 0 "comparison_operator"
7873 [(match_operand:GPR 1 "register_operand" "")
7874 (match_operand:GPR 2 "general_operand" "")])
7875 (label_ref (match_operand 3 "" ""))
7876 (pc)))]
7877 ""
7878 "s390_emit_jump (operands[3],
7879 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
7880 DONE;")
7881
7882 (define_expand "cbranch<mode>4"
7883 [(set (pc)
7884 (if_then_else (match_operator 0 "comparison_operator"
7885 [(match_operand:FP 1 "register_operand" "")
7886 (match_operand:FP 2 "general_operand" "")])
7887 (label_ref (match_operand 3 "" ""))
7888 (pc)))]
7889 "TARGET_HARD_FLOAT"
7890 "s390_emit_jump (operands[3],
7891 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
7892 DONE;")
7893
7894 (define_expand "cbranchcc4"
7895 [(set (pc)
7896 (if_then_else (match_operator 0 "s390_eqne_operator"
7897 [(match_operand 1 "cc_reg_operand" "")
7898 (match_operand 2 "const0_operand" "")])
7899 (label_ref (match_operand 3 "" ""))
7900 (pc)))]
7901 "TARGET_HARD_FLOAT"
7902 "s390_emit_jump (operands[3],
7903 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
7904 DONE;")
7905
7906
7907
7908 ;;
7909 ;;- Conditional jump instructions.
7910 ;;
7911
7912 (define_insn "*cjump_64"
7913 [(set (pc)
7914 (if_then_else
7915 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7916 (label_ref (match_operand 0 "" ""))
7917 (pc)))]
7918 "TARGET_CPU_ZARCH"
7919 {
7920 if (get_attr_length (insn) == 4)
7921 return "j%C1\t%l0";
7922 else
7923 return "jg%C1\t%l0";
7924 }
7925 [(set_attr "op_type" "RI")
7926 (set_attr "type" "branch")
7927 (set (attr "length")
7928 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7929 (const_int 4) (const_int 6)))])
7930
7931 (define_insn "*cjump_31"
7932 [(set (pc)
7933 (if_then_else
7934 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7935 (label_ref (match_operand 0 "" ""))
7936 (pc)))]
7937 "!TARGET_CPU_ZARCH"
7938 {
7939 gcc_assert (get_attr_length (insn) == 4);
7940 return "j%C1\t%l0";
7941 }
7942 [(set_attr "op_type" "RI")
7943 (set_attr "type" "branch")
7944 (set (attr "length")
7945 (if_then_else (not (match_test "flag_pic"))
7946 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7947 (const_int 4) (const_int 6))
7948 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7949 (const_int 4) (const_int 8))))])
7950
7951 (define_insn "*cjump_long"
7952 [(set (pc)
7953 (if_then_else
7954 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7955 (match_operand 0 "address_operand" "ZQZR")
7956 (pc)))]
7957 ""
7958 {
7959 if (get_attr_op_type (insn) == OP_TYPE_RR)
7960 return "b%C1r\t%0";
7961 else
7962 return "b%C1\t%a0";
7963 }
7964 [(set (attr "op_type")
7965 (if_then_else (match_operand 0 "register_operand" "")
7966 (const_string "RR") (const_string "RX")))
7967 (set_attr "type" "branch")
7968 (set_attr "atype" "agen")])
7969
7970
7971 ;;
7972 ;;- Negated conditional jump instructions.
7973 ;;
7974
7975 (define_insn "*icjump_64"
7976 [(set (pc)
7977 (if_then_else
7978 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7979 (pc)
7980 (label_ref (match_operand 0 "" ""))))]
7981 "TARGET_CPU_ZARCH"
7982 {
7983 if (get_attr_length (insn) == 4)
7984 return "j%D1\t%l0";
7985 else
7986 return "jg%D1\t%l0";
7987 }
7988 [(set_attr "op_type" "RI")
7989 (set_attr "type" "branch")
7990 (set (attr "length")
7991 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7992 (const_int 4) (const_int 6)))])
7993
7994 (define_insn "*icjump_31"
7995 [(set (pc)
7996 (if_then_else
7997 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7998 (pc)
7999 (label_ref (match_operand 0 "" ""))))]
8000 "!TARGET_CPU_ZARCH"
8001 {
8002 gcc_assert (get_attr_length (insn) == 4);
8003 return "j%D1\t%l0";
8004 }
8005 [(set_attr "op_type" "RI")
8006 (set_attr "type" "branch")
8007 (set (attr "length")
8008 (if_then_else (not (match_test "flag_pic"))
8009 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8010 (const_int 4) (const_int 6))
8011 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8012 (const_int 4) (const_int 8))))])
8013
8014 (define_insn "*icjump_long"
8015 [(set (pc)
8016 (if_then_else
8017 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8018 (pc)
8019 (match_operand 0 "address_operand" "ZQZR")))]
8020 ""
8021 {
8022 if (get_attr_op_type (insn) == OP_TYPE_RR)
8023 return "b%D1r\t%0";
8024 else
8025 return "b%D1\t%a0";
8026 }
8027 [(set (attr "op_type")
8028 (if_then_else (match_operand 0 "register_operand" "")
8029 (const_string "RR") (const_string "RX")))
8030 (set_attr "type" "branch")
8031 (set_attr "atype" "agen")])
8032
8033 ;;
8034 ;;- Trap instructions.
8035 ;;
8036
8037 (define_insn "trap"
8038 [(trap_if (const_int 1) (const_int 0))]
8039 ""
8040 "j\t.+2"
8041 [(set_attr "op_type" "RI")
8042 (set_attr "type" "branch")])
8043
8044 (define_expand "ctrap<mode>4"
8045 [(trap_if (match_operator 0 "comparison_operator"
8046 [(match_operand:GPR 1 "register_operand" "")
8047 (match_operand:GPR 2 "general_operand" "")])
8048 (match_operand 3 "const0_operand" ""))]
8049 ""
8050 {
8051 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8052 operands[1], operands[2]);
8053 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8054 DONE;
8055 })
8056
8057 (define_expand "ctrap<mode>4"
8058 [(trap_if (match_operator 0 "comparison_operator"
8059 [(match_operand:FP 1 "register_operand" "")
8060 (match_operand:FP 2 "general_operand" "")])
8061 (match_operand 3 "const0_operand" ""))]
8062 ""
8063 {
8064 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
8065 operands[1], operands[2]);
8066 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
8067 DONE;
8068 })
8069
8070 (define_insn "condtrap"
8071 [(trap_if (match_operator 0 "s390_comparison"
8072 [(match_operand 1 "cc_reg_operand" "c")
8073 (const_int 0)])
8074 (const_int 0))]
8075 ""
8076 "j%C0\t.+2";
8077 [(set_attr "op_type" "RI")
8078 (set_attr "type" "branch")])
8079
8080 ; crt, cgrt, cit, cgit
8081 (define_insn "*cmp_and_trap_signed_int<mode>"
8082 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
8083 [(match_operand:GPR 1 "register_operand" "d,d")
8084 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
8085 (const_int 0))]
8086 "TARGET_Z10"
8087 "@
8088 c<g>rt%C0\t%1,%2
8089 c<g>it%C0\t%1,%h2"
8090 [(set_attr "op_type" "RRF,RIE")
8091 (set_attr "type" "branch")
8092 (set_attr "z10prop" "z10_super_c,z10_super")])
8093
8094 ; clrt, clgrt, clfit, clgit, clt, clgt
8095 (define_insn "*cmp_and_trap_unsigned_int<mode>"
8096 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
8097 [(match_operand:GPR 1 "register_operand" "d,d, d")
8098 (match_operand:GPR 2 "general_operand" "d,D,RT")])
8099 (const_int 0))]
8100 "TARGET_Z10"
8101 "@
8102 cl<g>rt%C0\t%1,%2
8103 cl<gf>it%C0\t%1,%x2
8104 cl<g>t%C0\t%1,%2"
8105 [(set_attr "op_type" "RRF,RIE,RSY")
8106 (set_attr "type" "branch")
8107 (set_attr "z10prop" "z10_super_c,z10_super,*")
8108 (set_attr "cpu_facility" "z10,z10,zEC12")])
8109
8110 ; lat, lgat
8111 (define_insn "*load_and_trap<mode>"
8112 [(trap_if (eq (match_operand:GPR 0 "memory_operand" "RT")
8113 (const_int 0))
8114 (const_int 0))
8115 (set (match_operand:GPR 1 "register_operand" "=d")
8116 (match_dup 0))]
8117 "TARGET_ZEC12"
8118 "l<g>at\t%1,%0"
8119 [(set_attr "op_type" "RXY")])
8120
8121
8122 ;;
8123 ;;- Loop instructions.
8124 ;;
8125 ;; This is all complicated by the fact that since this is a jump insn
8126 ;; we must handle our own output reloads.
8127
8128 ;; branch on index
8129
8130 ; This splitter will be matched by combine and has to add the 2 moves
8131 ; necessary to load the compare and the increment values into a
8132 ; register pair as needed by brxle.
8133
8134 (define_insn_and_split "*brx_stage1_<GPR:mode>"
8135 [(set (pc)
8136 (if_then_else
8137 (match_operator 6 "s390_brx_operator"
8138 [(plus:GPR (match_operand:GPR 1 "register_operand" "")
8139 (match_operand:GPR 2 "general_operand" ""))
8140 (match_operand:GPR 3 "register_operand" "")])
8141 (label_ref (match_operand 0 "" ""))
8142 (pc)))
8143 (set (match_operand:GPR 4 "nonimmediate_operand" "")
8144 (plus:GPR (match_dup 1) (match_dup 2)))
8145 (clobber (match_scratch:GPR 5 ""))]
8146 "TARGET_CPU_ZARCH"
8147 "#"
8148 "!reload_completed && !reload_in_progress"
8149 [(set (match_dup 7) (match_dup 2)) ; the increment
8150 (set (match_dup 8) (match_dup 3)) ; the comparison value
8151 (parallel [(set (pc)
8152 (if_then_else
8153 (match_op_dup 6
8154 [(plus:GPR (match_dup 1) (match_dup 7))
8155 (match_dup 8)])
8156 (label_ref (match_dup 0))
8157 (pc)))
8158 (set (match_dup 4)
8159 (plus:GPR (match_dup 1) (match_dup 7)))
8160 (clobber (match_dup 5))
8161 (clobber (reg:CC CC_REGNUM))])]
8162 {
8163 rtx dreg = gen_reg_rtx (word_mode == DImode ? TImode : DImode);
8164 operands[7] = gen_lowpart (<GPR:MODE>mode,
8165 gen_highpart (word_mode, dreg));
8166 operands[8] = gen_lowpart (<GPR:MODE>mode,
8167 gen_lowpart (word_mode, dreg));
8168 })
8169
8170 ; brxlg, brxhg
8171
8172 (define_insn_and_split "*brxg_64bit"
8173 [(set (pc)
8174 (if_then_else
8175 (match_operator 5 "s390_brx_operator"
8176 [(plus:DI (match_operand:DI 1 "register_operand" "d,d,d")
8177 (subreg:DI (match_operand:TI 2 "register_operand" "d,d,d") 0))
8178 (subreg:DI (match_dup 2) 8)])
8179 (label_ref (match_operand 0 "" ""))
8180 (pc)))
8181 (set (match_operand:DI 3 "nonimmediate_operand" "=1,?X,?X")
8182 (plus:DI (match_dup 1)
8183 (subreg:DI (match_dup 2) 0)))
8184 (clobber (match_scratch:DI 4 "=X,&1,&?d"))
8185 (clobber (reg:CC CC_REGNUM))]
8186 "TARGET_ZARCH"
8187 {
8188 if (which_alternative != 0)
8189 return "#";
8190 else if (get_attr_length (insn) == 6)
8191 return "brx%E5g\t%1,%2,%l0";
8192 else
8193 return "agr\t%1,%2\;cgr\t%1,%M2\;jg%C5\t%l0";
8194 }
8195 "&& reload_completed
8196 && (!REG_P (operands[3])
8197 || !rtx_equal_p (operands[1], operands[3]))"
8198 [(set (match_dup 4) (match_dup 1))
8199 (parallel [(set (match_dup 4) (plus:DI (match_dup 4) (subreg:DI (match_dup 2) 0)))
8200 (clobber (reg:CC CC_REGNUM))])
8201 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:DI (match_dup 2) 8)))
8202 (set (match_dup 3) (match_dup 4))
8203 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8204 (label_ref (match_dup 0))
8205 (pc)))]
8206 ""
8207 [(set_attr "op_type" "RIE")
8208 (set_attr "type" "branch")
8209 (set (attr "length")
8210 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8211 (const_int 6) (const_int 16)))])
8212
8213 ; brxle, brxh
8214
8215 (define_insn_and_split "*brx_64bit"
8216 [(set (pc)
8217 (if_then_else
8218 (match_operator 5 "s390_brx_operator"
8219 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
8220 (subreg:SI (match_operand:TI 2 "register_operand" "d,d,d") 4))
8221 (subreg:SI (match_dup 2) 12)])
8222 (label_ref (match_operand 0 "" ""))
8223 (pc)))
8224 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
8225 (plus:SI (match_dup 1)
8226 (subreg:SI (match_dup 2) 4)))
8227 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
8228 (clobber (reg:CC CC_REGNUM))]
8229 "TARGET_ZARCH"
8230 {
8231 if (which_alternative != 0)
8232 return "#";
8233 else if (get_attr_length (insn) == 6)
8234 return "brx%C5\t%1,%2,%l0";
8235 else
8236 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
8237 }
8238 "&& reload_completed
8239 && (!REG_P (operands[3])
8240 || !rtx_equal_p (operands[1], operands[3]))"
8241 [(set (match_dup 4) (match_dup 1))
8242 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 4)))
8243 (clobber (reg:CC CC_REGNUM))])
8244 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 12)))
8245 (set (match_dup 3) (match_dup 4))
8246 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8247 (label_ref (match_dup 0))
8248 (pc)))]
8249 ""
8250 [(set_attr "op_type" "RSI")
8251 (set_attr "type" "branch")
8252 (set (attr "length")
8253 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8254 (const_int 6) (const_int 14)))])
8255
8256 ; brxle, brxh
8257
8258 (define_insn_and_split "*brx_31bit"
8259 [(set (pc)
8260 (if_then_else
8261 (match_operator 5 "s390_brx_operator"
8262 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
8263 (subreg:SI (match_operand:DI 2 "register_operand" "d,d,d") 0))
8264 (subreg:SI (match_dup 2) 4)])
8265 (label_ref (match_operand 0 "" ""))
8266 (pc)))
8267 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
8268 (plus:SI (match_dup 1)
8269 (subreg:SI (match_dup 2) 0)))
8270 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
8271 (clobber (reg:CC CC_REGNUM))]
8272 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
8273 {
8274 if (which_alternative != 0)
8275 return "#";
8276 else if (get_attr_length (insn) == 6)
8277 return "brx%C5\t%1,%2,%l0";
8278 else
8279 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
8280 }
8281 "&& reload_completed
8282 && (!REG_P (operands[3])
8283 || !rtx_equal_p (operands[1], operands[3]))"
8284 [(set (match_dup 4) (match_dup 1))
8285 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 0)))
8286 (clobber (reg:CC CC_REGNUM))])
8287 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 4)))
8288 (set (match_dup 3) (match_dup 4))
8289 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
8290 (label_ref (match_dup 0))
8291 (pc)))]
8292 ""
8293 [(set_attr "op_type" "RSI")
8294 (set_attr "type" "branch")
8295 (set (attr "length")
8296 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8297 (const_int 6) (const_int 14)))])
8298
8299
8300 ;; branch on count
8301
8302 (define_expand "doloop_end"
8303 [(use (match_operand 0 "" "")) ; loop pseudo
8304 (use (match_operand 1 "" "")) ; iterations; zero if unknown
8305 (use (match_operand 2 "" "")) ; max iterations
8306 (use (match_operand 3 "" "")) ; loop level
8307 (use (match_operand 4 "" "")) ; label
8308 (use (match_operand 5 "" ""))] ; flag: 1 if loop entered at top, else 0
8309 ""
8310 {
8311 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
8312 emit_jump_insn (gen_doloop_si31 (operands[4], operands[0], operands[0]));
8313 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
8314 emit_jump_insn (gen_doloop_si64 (operands[4], operands[0], operands[0]));
8315 else if (GET_MODE (operands[0]) == DImode && TARGET_ZARCH)
8316 emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
8317 else
8318 FAIL;
8319
8320 DONE;
8321 })
8322
8323 (define_insn_and_split "doloop_si64"
8324 [(set (pc)
8325 (if_then_else
8326 (ne (match_operand:SI 1 "register_operand" "d,d,d")
8327 (const_int 1))
8328 (label_ref (match_operand 0 "" ""))
8329 (pc)))
8330 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
8331 (plus:SI (match_dup 1) (const_int -1)))
8332 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
8333 (clobber (reg:CC CC_REGNUM))]
8334 "TARGET_CPU_ZARCH"
8335 {
8336 if (which_alternative != 0)
8337 return "#";
8338 else if (get_attr_length (insn) == 4)
8339 return "brct\t%1,%l0";
8340 else
8341 return "ahi\t%1,-1\;jgne\t%l0";
8342 }
8343 "&& reload_completed
8344 && (! REG_P (operands[2])
8345 || ! rtx_equal_p (operands[1], operands[2]))"
8346 [(set (match_dup 3) (match_dup 1))
8347 (parallel [(set (reg:CCAN CC_REGNUM)
8348 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
8349 (const_int 0)))
8350 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
8351 (set (match_dup 2) (match_dup 3))
8352 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
8353 (label_ref (match_dup 0))
8354 (pc)))]
8355 ""
8356 [(set_attr "op_type" "RI")
8357 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8358 ; hurt us in the (rare) case of ahi.
8359 (set_attr "z10prop" "z10_super_E1")
8360 (set_attr "type" "branch")
8361 (set (attr "length")
8362 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8363 (const_int 4) (const_int 10)))])
8364
8365 (define_insn_and_split "doloop_si31"
8366 [(set (pc)
8367 (if_then_else
8368 (ne (match_operand:SI 1 "register_operand" "d,d,d")
8369 (const_int 1))
8370 (label_ref (match_operand 0 "" ""))
8371 (pc)))
8372 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
8373 (plus:SI (match_dup 1) (const_int -1)))
8374 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
8375 (clobber (reg:CC CC_REGNUM))]
8376 "!TARGET_CPU_ZARCH"
8377 {
8378 if (which_alternative != 0)
8379 return "#";
8380 else if (get_attr_length (insn) == 4)
8381 return "brct\t%1,%l0";
8382 else
8383 gcc_unreachable ();
8384 }
8385 "&& reload_completed
8386 && (! REG_P (operands[2])
8387 || ! rtx_equal_p (operands[1], operands[2]))"
8388 [(set (match_dup 3) (match_dup 1))
8389 (parallel [(set (reg:CCAN CC_REGNUM)
8390 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
8391 (const_int 0)))
8392 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
8393 (set (match_dup 2) (match_dup 3))
8394 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
8395 (label_ref (match_dup 0))
8396 (pc)))]
8397 ""
8398 [(set_attr "op_type" "RI")
8399 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8400 ; hurt us in the (rare) case of ahi.
8401 (set_attr "z10prop" "z10_super_E1")
8402 (set_attr "type" "branch")
8403 (set (attr "length")
8404 (if_then_else (not (match_test "flag_pic"))
8405 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8406 (const_int 4) (const_int 6))
8407 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8408 (const_int 4) (const_int 8))))])
8409
8410 (define_insn "*doloop_si_long"
8411 [(set (pc)
8412 (if_then_else
8413 (ne (match_operand:SI 1 "register_operand" "d")
8414 (const_int 1))
8415 (match_operand 0 "address_operand" "ZQZR")
8416 (pc)))
8417 (set (match_operand:SI 2 "register_operand" "=1")
8418 (plus:SI (match_dup 1) (const_int -1)))
8419 (clobber (match_scratch:SI 3 "=X"))
8420 (clobber (reg:CC CC_REGNUM))]
8421 "!TARGET_CPU_ZARCH"
8422 {
8423 if (get_attr_op_type (insn) == OP_TYPE_RR)
8424 return "bctr\t%1,%0";
8425 else
8426 return "bct\t%1,%a0";
8427 }
8428 [(set (attr "op_type")
8429 (if_then_else (match_operand 0 "register_operand" "")
8430 (const_string "RR") (const_string "RX")))
8431 (set_attr "type" "branch")
8432 (set_attr "atype" "agen")
8433 (set_attr "z10prop" "z10_c")
8434 (set_attr "z196prop" "z196_cracked")])
8435
8436 (define_insn_and_split "doloop_di"
8437 [(set (pc)
8438 (if_then_else
8439 (ne (match_operand:DI 1 "register_operand" "d,d,d")
8440 (const_int 1))
8441 (label_ref (match_operand 0 "" ""))
8442 (pc)))
8443 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
8444 (plus:DI (match_dup 1) (const_int -1)))
8445 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
8446 (clobber (reg:CC CC_REGNUM))]
8447 "TARGET_ZARCH"
8448 {
8449 if (which_alternative != 0)
8450 return "#";
8451 else if (get_attr_length (insn) == 4)
8452 return "brctg\t%1,%l0";
8453 else
8454 return "aghi\t%1,-1\;jgne\t%l0";
8455 }
8456 "&& reload_completed
8457 && (! REG_P (operands[2])
8458 || ! rtx_equal_p (operands[1], operands[2]))"
8459 [(set (match_dup 3) (match_dup 1))
8460 (parallel [(set (reg:CCAN CC_REGNUM)
8461 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
8462 (const_int 0)))
8463 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
8464 (set (match_dup 2) (match_dup 3))
8465 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
8466 (label_ref (match_dup 0))
8467 (pc)))]
8468 ""
8469 [(set_attr "op_type" "RI")
8470 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
8471 ; hurt us in the (rare) case of ahi.
8472 (set_attr "z10prop" "z10_super_E1")
8473 (set_attr "type" "branch")
8474 (set (attr "length")
8475 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8476 (const_int 4) (const_int 10)))])
8477
8478 ;;
8479 ;;- Unconditional jump instructions.
8480 ;;
8481
8482 ;
8483 ; jump instruction pattern(s).
8484 ;
8485
8486 (define_expand "jump"
8487 [(match_operand 0 "" "")]
8488 ""
8489 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
8490
8491 (define_insn "*jump64"
8492 [(set (pc) (label_ref (match_operand 0 "" "")))]
8493 "TARGET_CPU_ZARCH"
8494 {
8495 if (get_attr_length (insn) == 4)
8496 return "j\t%l0";
8497 else
8498 return "jg\t%l0";
8499 }
8500 [(set_attr "op_type" "RI")
8501 (set_attr "type" "branch")
8502 (set (attr "length")
8503 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8504 (const_int 4) (const_int 6)))])
8505
8506 (define_insn "*jump31"
8507 [(set (pc) (label_ref (match_operand 0 "" "")))]
8508 "!TARGET_CPU_ZARCH"
8509 {
8510 gcc_assert (get_attr_length (insn) == 4);
8511 return "j\t%l0";
8512 }
8513 [(set_attr "op_type" "RI")
8514 (set_attr "type" "branch")
8515 (set (attr "length")
8516 (if_then_else (not (match_test "flag_pic"))
8517 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8518 (const_int 4) (const_int 6))
8519 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8520 (const_int 4) (const_int 8))))])
8521
8522 ;
8523 ; indirect-jump instruction pattern(s).
8524 ;
8525
8526 (define_insn "indirect_jump"
8527 [(set (pc) (match_operand 0 "address_operand" "ZQZR"))]
8528 ""
8529 {
8530 if (get_attr_op_type (insn) == OP_TYPE_RR)
8531 return "br\t%0";
8532 else
8533 return "b\t%a0";
8534 }
8535 [(set (attr "op_type")
8536 (if_then_else (match_operand 0 "register_operand" "")
8537 (const_string "RR") (const_string "RX")))
8538 (set_attr "type" "branch")
8539 (set_attr "atype" "agen")])
8540
8541 ;
8542 ; casesi instruction pattern(s).
8543 ;
8544
8545 (define_insn "casesi_jump"
8546 [(set (pc) (match_operand 0 "address_operand" "ZQZR"))
8547 (use (label_ref (match_operand 1 "" "")))]
8548 ""
8549 {
8550 if (get_attr_op_type (insn) == OP_TYPE_RR)
8551 return "br\t%0";
8552 else
8553 return "b\t%a0";
8554 }
8555 [(set (attr "op_type")
8556 (if_then_else (match_operand 0 "register_operand" "")
8557 (const_string "RR") (const_string "RX")))
8558 (set_attr "type" "branch")
8559 (set_attr "atype" "agen")])
8560
8561 (define_expand "casesi"
8562 [(match_operand:SI 0 "general_operand" "")
8563 (match_operand:SI 1 "general_operand" "")
8564 (match_operand:SI 2 "general_operand" "")
8565 (label_ref (match_operand 3 "" ""))
8566 (label_ref (match_operand 4 "" ""))]
8567 ""
8568 {
8569 rtx index = gen_reg_rtx (SImode);
8570 rtx base = gen_reg_rtx (Pmode);
8571 rtx target = gen_reg_rtx (Pmode);
8572
8573 emit_move_insn (index, operands[0]);
8574 emit_insn (gen_subsi3 (index, index, operands[1]));
8575 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
8576 operands[4]);
8577
8578 if (Pmode != SImode)
8579 index = convert_to_mode (Pmode, index, 1);
8580 if (GET_CODE (index) != REG)
8581 index = copy_to_mode_reg (Pmode, index);
8582
8583 if (TARGET_64BIT)
8584 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
8585 else
8586 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
8587
8588 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
8589
8590 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
8591 emit_move_insn (target, index);
8592
8593 if (flag_pic)
8594 target = gen_rtx_PLUS (Pmode, base, target);
8595 emit_jump_insn (gen_casesi_jump (target, operands[3]));
8596
8597 DONE;
8598 })
8599
8600
8601 ;;
8602 ;;- Jump to subroutine.
8603 ;;
8604 ;;
8605
8606 ;
8607 ; untyped call instruction pattern(s).
8608 ;
8609
8610 ;; Call subroutine returning any type.
8611 (define_expand "untyped_call"
8612 [(parallel [(call (match_operand 0 "" "")
8613 (const_int 0))
8614 (match_operand 1 "" "")
8615 (match_operand 2 "" "")])]
8616 ""
8617 {
8618 int i;
8619
8620 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
8621
8622 for (i = 0; i < XVECLEN (operands[2], 0); i++)
8623 {
8624 rtx set = XVECEXP (operands[2], 0, i);
8625 emit_move_insn (SET_DEST (set), SET_SRC (set));
8626 }
8627
8628 /* The optimizer does not know that the call sets the function value
8629 registers we stored in the result block. We avoid problems by
8630 claiming that all hard registers are used and clobbered at this
8631 point. */
8632 emit_insn (gen_blockage ());
8633
8634 DONE;
8635 })
8636
8637 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
8638 ;; all of memory. This blocks insns from being moved across this point.
8639
8640 (define_insn "blockage"
8641 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
8642 ""
8643 ""
8644 [(set_attr "type" "none")
8645 (set_attr "length" "0")])
8646
8647 ;
8648 ; sibcall patterns
8649 ;
8650
8651 (define_expand "sibcall"
8652 [(call (match_operand 0 "" "")
8653 (match_operand 1 "" ""))]
8654 ""
8655 {
8656 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
8657 DONE;
8658 })
8659
8660 (define_insn "*sibcall_br"
8661 [(call (mem:QI (reg SIBCALL_REGNUM))
8662 (match_operand 0 "const_int_operand" "n"))]
8663 "SIBLING_CALL_P (insn)
8664 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
8665 "br\t%%r1"
8666 [(set_attr "op_type" "RR")
8667 (set_attr "type" "branch")
8668 (set_attr "atype" "agen")])
8669
8670 (define_insn "*sibcall_brc"
8671 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8672 (match_operand 1 "const_int_operand" "n"))]
8673 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
8674 "j\t%0"
8675 [(set_attr "op_type" "RI")
8676 (set_attr "type" "branch")])
8677
8678 (define_insn "*sibcall_brcl"
8679 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8680 (match_operand 1 "const_int_operand" "n"))]
8681 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
8682 "jg\t%0"
8683 [(set_attr "op_type" "RIL")
8684 (set_attr "type" "branch")])
8685
8686 ;
8687 ; sibcall_value patterns
8688 ;
8689
8690 (define_expand "sibcall_value"
8691 [(set (match_operand 0 "" "")
8692 (call (match_operand 1 "" "")
8693 (match_operand 2 "" "")))]
8694 ""
8695 {
8696 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
8697 DONE;
8698 })
8699
8700 (define_insn "*sibcall_value_br"
8701 [(set (match_operand 0 "" "")
8702 (call (mem:QI (reg SIBCALL_REGNUM))
8703 (match_operand 1 "const_int_operand" "n")))]
8704 "SIBLING_CALL_P (insn)
8705 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
8706 "br\t%%r1"
8707 [(set_attr "op_type" "RR")
8708 (set_attr "type" "branch")
8709 (set_attr "atype" "agen")])
8710
8711 (define_insn "*sibcall_value_brc"
8712 [(set (match_operand 0 "" "")
8713 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8714 (match_operand 2 "const_int_operand" "n")))]
8715 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
8716 "j\t%1"
8717 [(set_attr "op_type" "RI")
8718 (set_attr "type" "branch")])
8719
8720 (define_insn "*sibcall_value_brcl"
8721 [(set (match_operand 0 "" "")
8722 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8723 (match_operand 2 "const_int_operand" "n")))]
8724 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
8725 "jg\t%1"
8726 [(set_attr "op_type" "RIL")
8727 (set_attr "type" "branch")])
8728
8729
8730 ;
8731 ; call instruction pattern(s).
8732 ;
8733
8734 (define_expand "call"
8735 [(call (match_operand 0 "" "")
8736 (match_operand 1 "" ""))
8737 (use (match_operand 2 "" ""))]
8738 ""
8739 {
8740 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
8741 gen_rtx_REG (Pmode, RETURN_REGNUM));
8742 DONE;
8743 })
8744
8745 (define_insn "*bras"
8746 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8747 (match_operand 1 "const_int_operand" "n"))
8748 (clobber (match_operand 2 "register_operand" "=r"))]
8749 "!SIBLING_CALL_P (insn)
8750 && TARGET_SMALL_EXEC
8751 && GET_MODE (operands[2]) == Pmode"
8752 "bras\t%2,%0"
8753 [(set_attr "op_type" "RI")
8754 (set_attr "type" "jsr")
8755 (set_attr "z196prop" "z196_cracked")])
8756
8757 (define_insn "*brasl"
8758 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8759 (match_operand 1 "const_int_operand" "n"))
8760 (clobber (match_operand 2 "register_operand" "=r"))]
8761 "!SIBLING_CALL_P (insn)
8762 && TARGET_CPU_ZARCH
8763 && GET_MODE (operands[2]) == Pmode"
8764 "brasl\t%2,%0"
8765 [(set_attr "op_type" "RIL")
8766 (set_attr "type" "jsr")
8767 (set_attr "z196prop" "z196_cracked")])
8768
8769 (define_insn "*basr"
8770 [(call (mem:QI (match_operand 0 "address_operand" "ZQZR"))
8771 (match_operand 1 "const_int_operand" "n"))
8772 (clobber (match_operand 2 "register_operand" "=r"))]
8773 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
8774 {
8775 if (get_attr_op_type (insn) == OP_TYPE_RR)
8776 return "basr\t%2,%0";
8777 else
8778 return "bas\t%2,%a0";
8779 }
8780 [(set (attr "op_type")
8781 (if_then_else (match_operand 0 "register_operand" "")
8782 (const_string "RR") (const_string "RX")))
8783 (set_attr "type" "jsr")
8784 (set_attr "atype" "agen")
8785 (set_attr "z196prop" "z196_cracked")])
8786
8787 ;
8788 ; call_value instruction pattern(s).
8789 ;
8790
8791 (define_expand "call_value"
8792 [(set (match_operand 0 "" "")
8793 (call (match_operand 1 "" "")
8794 (match_operand 2 "" "")))
8795 (use (match_operand 3 "" ""))]
8796 ""
8797 {
8798 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
8799 gen_rtx_REG (Pmode, RETURN_REGNUM));
8800 DONE;
8801 })
8802
8803 (define_insn "*bras_r"
8804 [(set (match_operand 0 "" "")
8805 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8806 (match_operand:SI 2 "const_int_operand" "n")))
8807 (clobber (match_operand 3 "register_operand" "=r"))]
8808 "!SIBLING_CALL_P (insn)
8809 && TARGET_SMALL_EXEC
8810 && GET_MODE (operands[3]) == Pmode"
8811 "bras\t%3,%1"
8812 [(set_attr "op_type" "RI")
8813 (set_attr "type" "jsr")
8814 (set_attr "z196prop" "z196_cracked")])
8815
8816 (define_insn "*brasl_r"
8817 [(set (match_operand 0 "" "")
8818 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8819 (match_operand 2 "const_int_operand" "n")))
8820 (clobber (match_operand 3 "register_operand" "=r"))]
8821 "!SIBLING_CALL_P (insn)
8822 && TARGET_CPU_ZARCH
8823 && GET_MODE (operands[3]) == Pmode"
8824 "brasl\t%3,%1"
8825 [(set_attr "op_type" "RIL")
8826 (set_attr "type" "jsr")
8827 (set_attr "z196prop" "z196_cracked")])
8828
8829 (define_insn "*basr_r"
8830 [(set (match_operand 0 "" "")
8831 (call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
8832 (match_operand 2 "const_int_operand" "n")))
8833 (clobber (match_operand 3 "register_operand" "=r"))]
8834 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8835 {
8836 if (get_attr_op_type (insn) == OP_TYPE_RR)
8837 return "basr\t%3,%1";
8838 else
8839 return "bas\t%3,%a1";
8840 }
8841 [(set (attr "op_type")
8842 (if_then_else (match_operand 1 "register_operand" "")
8843 (const_string "RR") (const_string "RX")))
8844 (set_attr "type" "jsr")
8845 (set_attr "atype" "agen")
8846 (set_attr "z196prop" "z196_cracked")])
8847
8848 ;;
8849 ;;- Thread-local storage support.
8850 ;;
8851
8852 (define_expand "get_thread_pointer<mode>"
8853 [(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))]
8854 ""
8855 "")
8856
8857 (define_expand "set_thread_pointer<mode>"
8858 [(set (reg:P TP_REGNUM) (match_operand:P 0 "nonimmediate_operand" ""))
8859 (set (reg:P TP_REGNUM) (unspec_volatile:P [(reg:P TP_REGNUM)] UNSPECV_SET_TP))]
8860 ""
8861 "")
8862
8863 (define_insn "*set_tp"
8864 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
8865 ""
8866 ""
8867 [(set_attr "type" "none")
8868 (set_attr "length" "0")])
8869
8870 (define_insn "*tls_load_64"
8871 [(set (match_operand:DI 0 "register_operand" "=d")
8872 (unspec:DI [(match_operand:DI 1 "memory_operand" "RT")
8873 (match_operand:DI 2 "" "")]
8874 UNSPEC_TLS_LOAD))]
8875 "TARGET_64BIT"
8876 "lg\t%0,%1%J2"
8877 [(set_attr "op_type" "RXE")
8878 (set_attr "z10prop" "z10_fwd_A3")])
8879
8880 (define_insn "*tls_load_31"
8881 [(set (match_operand:SI 0 "register_operand" "=d,d")
8882 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
8883 (match_operand:SI 2 "" "")]
8884 UNSPEC_TLS_LOAD))]
8885 "!TARGET_64BIT"
8886 "@
8887 l\t%0,%1%J2
8888 ly\t%0,%1%J2"
8889 [(set_attr "op_type" "RX,RXY")
8890 (set_attr "type" "load")
8891 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
8892
8893 (define_insn "*bras_tls"
8894 [(set (match_operand 0 "" "")
8895 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8896 (match_operand 2 "const_int_operand" "n")))
8897 (clobber (match_operand 3 "register_operand" "=r"))
8898 (use (match_operand 4 "" ""))]
8899 "!SIBLING_CALL_P (insn)
8900 && TARGET_SMALL_EXEC
8901 && GET_MODE (operands[3]) == Pmode"
8902 "bras\t%3,%1%J4"
8903 [(set_attr "op_type" "RI")
8904 (set_attr "type" "jsr")
8905 (set_attr "z196prop" "z196_cracked")])
8906
8907 (define_insn "*brasl_tls"
8908 [(set (match_operand 0 "" "")
8909 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8910 (match_operand 2 "const_int_operand" "n")))
8911 (clobber (match_operand 3 "register_operand" "=r"))
8912 (use (match_operand 4 "" ""))]
8913 "!SIBLING_CALL_P (insn)
8914 && TARGET_CPU_ZARCH
8915 && GET_MODE (operands[3]) == Pmode"
8916 "brasl\t%3,%1%J4"
8917 [(set_attr "op_type" "RIL")
8918 (set_attr "type" "jsr")
8919 (set_attr "z196prop" "z196_cracked")])
8920
8921 (define_insn "*basr_tls"
8922 [(set (match_operand 0 "" "")
8923 (call (mem:QI (match_operand 1 "address_operand" "ZQZR"))
8924 (match_operand 2 "const_int_operand" "n")))
8925 (clobber (match_operand 3 "register_operand" "=r"))
8926 (use (match_operand 4 "" ""))]
8927 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8928 {
8929 if (get_attr_op_type (insn) == OP_TYPE_RR)
8930 return "basr\t%3,%1%J4";
8931 else
8932 return "bas\t%3,%a1%J4";
8933 }
8934 [(set (attr "op_type")
8935 (if_then_else (match_operand 1 "register_operand" "")
8936 (const_string "RR") (const_string "RX")))
8937 (set_attr "type" "jsr")
8938 (set_attr "atype" "agen")
8939 (set_attr "z196prop" "z196_cracked")])
8940
8941 ;;
8942 ;;- Atomic operations
8943 ;;
8944
8945 ;
8946 ; memory barrier patterns.
8947 ;
8948
8949 (define_expand "mem_signal_fence"
8950 [(match_operand:SI 0 "const_int_operand")] ;; model
8951 ""
8952 {
8953 /* The s390 memory model is strong enough not to require any
8954 barrier in order to synchronize a thread with itself. */
8955 DONE;
8956 })
8957
8958 (define_expand "mem_thread_fence"
8959 [(match_operand:SI 0 "const_int_operand")] ;; model
8960 ""
8961 {
8962 /* Unless this is a SEQ_CST fence, the s390 memory model is strong
8963 enough not to require barriers of any kind. */
8964 if (INTVAL (operands[0]) == MEMMODEL_SEQ_CST)
8965 {
8966 rtx mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
8967 MEM_VOLATILE_P (mem) = 1;
8968 emit_insn (gen_mem_thread_fence_1 (mem));
8969 }
8970 DONE;
8971 })
8972
8973 ; Although bcr is superscalar on Z10, this variant will never
8974 ; become part of an execution group.
8975 (define_insn "mem_thread_fence_1"
8976 [(set (match_operand:BLK 0 "" "")
8977 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
8978 ""
8979 "bcr\t15,0"
8980 [(set_attr "op_type" "RR")])
8981
8982 ;
8983 ; atomic load/store operations
8984 ;
8985
8986 ; Atomic loads need not examine the memory model at all.
8987 (define_expand "atomic_load<mode>"
8988 [(match_operand:DINT 0 "register_operand") ;; output
8989 (match_operand:DINT 1 "memory_operand") ;; memory
8990 (match_operand:SI 2 "const_int_operand")] ;; model
8991 ""
8992 {
8993 if (<MODE>mode == TImode)
8994 emit_insn (gen_atomic_loadti_1 (operands[0], operands[1]));
8995 else if (<MODE>mode == DImode && !TARGET_ZARCH)
8996 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
8997 else
8998 emit_move_insn (operands[0], operands[1]);
8999 DONE;
9000 })
9001
9002 ; Different from movdi_31 in that we want no splitters.
9003 (define_insn "atomic_loaddi_1"
9004 [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f")
9005 (unspec:DI [(match_operand:DI 1 "memory_operand" "Q,S,R,T")]
9006 UNSPEC_MOVA))]
9007 "!TARGET_ZARCH"
9008 "@
9009 lm\t%0,%M0,%S1
9010 lmy\t%0,%M0,%S1
9011 ld\t%0,%1
9012 ldy\t%0,%1"
9013 [(set_attr "op_type" "RS,RSY,RS,RSY")
9014 (set_attr "type" "lm,lm,floaddf,floaddf")])
9015
9016 (define_insn "atomic_loadti_1"
9017 [(set (match_operand:TI 0 "register_operand" "=r")
9018 (unspec:TI [(match_operand:TI 1 "memory_operand" "RT")]
9019 UNSPEC_MOVA))]
9020 "TARGET_ZARCH"
9021 "lpq\t%0,%1"
9022 [(set_attr "op_type" "RXY")
9023 (set_attr "type" "other")])
9024
9025 ; Atomic stores must(?) enforce sequential consistency.
9026 (define_expand "atomic_store<mode>"
9027 [(match_operand:DINT 0 "memory_operand") ;; memory
9028 (match_operand:DINT 1 "register_operand") ;; input
9029 (match_operand:SI 2 "const_int_operand")] ;; model
9030 ""
9031 {
9032 enum memmodel model = (enum memmodel) INTVAL (operands[2]);
9033
9034 if (<MODE>mode == TImode)
9035 emit_insn (gen_atomic_storeti_1 (operands[0], operands[1]));
9036 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9037 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
9038 else
9039 emit_move_insn (operands[0], operands[1]);
9040 if (model == MEMMODEL_SEQ_CST)
9041 emit_insn (gen_mem_thread_fence (operands[2]));
9042 DONE;
9043 })
9044
9045 ; Different from movdi_31 in that we want no splitters.
9046 (define_insn "atomic_storedi_1"
9047 [(set (match_operand:DI 0 "memory_operand" "=Q,S,R,T")
9048 (unspec:DI [(match_operand:DI 1 "register_operand" "d,d,!*f,!*f")]
9049 UNSPEC_MOVA))]
9050 "!TARGET_ZARCH"
9051 "@
9052 stm\t%1,%N1,%S0
9053 stmy\t%1,%N1,%S0
9054 std %1,%0
9055 stdy %1,%0"
9056 [(set_attr "op_type" "RS,RSY,RS,RSY")
9057 (set_attr "type" "stm,stm,fstoredf,fstoredf")])
9058
9059 (define_insn "atomic_storeti_1"
9060 [(set (match_operand:TI 0 "memory_operand" "=RT")
9061 (unspec:TI [(match_operand:TI 1 "register_operand" "r")]
9062 UNSPEC_MOVA))]
9063 "TARGET_ZARCH"
9064 "stpq\t%1,%0"
9065 [(set_attr "op_type" "RXY")
9066 (set_attr "type" "other")])
9067
9068 ;
9069 ; compare and swap patterns.
9070 ;
9071
9072 (define_expand "atomic_compare_and_swap<mode>"
9073 [(match_operand:SI 0 "register_operand") ;; bool success output
9074 (match_operand:DGPR 1 "nonimmediate_operand");; oldval output
9075 (match_operand:DGPR 2 "memory_operand") ;; memory
9076 (match_operand:DGPR 3 "register_operand") ;; expected intput
9077 (match_operand:DGPR 4 "register_operand") ;; newval intput
9078 (match_operand:SI 5 "const_int_operand") ;; is_weak
9079 (match_operand:SI 6 "const_int_operand") ;; success model
9080 (match_operand:SI 7 "const_int_operand")] ;; failure model
9081 ""
9082 {
9083 rtx cc, cmp, output = operands[1];
9084
9085 if (!register_operand (output, <MODE>mode))
9086 output = gen_reg_rtx (<MODE>mode);
9087
9088 emit_insn (gen_atomic_compare_and_swap<mode>_internal
9089 (output, operands[2], operands[3], operands[4]));
9090
9091 /* We deliberately accept non-register operands in the predicate
9092 to ensure the write back to the output operand happens *before*
9093 the store-flags code below. This makes it easier for combine
9094 to merge the store-flags code with a potential test-and-branch
9095 pattern following (immediately!) afterwards. */
9096 if (output != operands[1])
9097 emit_move_insn (operands[1], output);
9098
9099 cc = gen_rtx_REG (CCZ1mode, CC_REGNUM);
9100 cmp = gen_rtx_EQ (SImode, cc, const0_rtx);
9101 emit_insn (gen_cstorecc4 (operands[0], cmp, cc, const0_rtx));
9102 DONE;
9103 })
9104
9105 (define_expand "atomic_compare_and_swap<mode>"
9106 [(match_operand:SI 0 "register_operand") ;; bool success output
9107 (match_operand:HQI 1 "nonimmediate_operand") ;; oldval output
9108 (match_operand:HQI 2 "memory_operand") ;; memory
9109 (match_operand:HQI 3 "general_operand") ;; expected intput
9110 (match_operand:HQI 4 "general_operand") ;; newval intput
9111 (match_operand:SI 5 "const_int_operand") ;; is_weak
9112 (match_operand:SI 6 "const_int_operand") ;; success model
9113 (match_operand:SI 7 "const_int_operand")] ;; failure model
9114 ""
9115 {
9116 s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1], operands[2],
9117 operands[3], operands[4], INTVAL (operands[5]));
9118 DONE;
9119 })
9120
9121 (define_expand "atomic_compare_and_swap<mode>_internal"
9122 [(parallel
9123 [(set (match_operand:DGPR 0 "register_operand")
9124 (match_operand:DGPR 1 "memory_operand"))
9125 (set (match_dup 1)
9126 (unspec_volatile:DGPR
9127 [(match_dup 1)
9128 (match_operand:DGPR 2 "register_operand")
9129 (match_operand:DGPR 3 "register_operand")]
9130 UNSPECV_CAS))
9131 (set (reg:CCZ1 CC_REGNUM)
9132 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
9133 "")
9134
9135 ; cdsg, csg
9136 (define_insn "*atomic_compare_and_swap<mode>_1"
9137 [(set (match_operand:TDI 0 "register_operand" "=r")
9138 (match_operand:TDI 1 "memory_operand" "+QS"))
9139 (set (match_dup 1)
9140 (unspec_volatile:TDI
9141 [(match_dup 1)
9142 (match_operand:TDI 2 "register_operand" "0")
9143 (match_operand:TDI 3 "register_operand" "r")]
9144 UNSPECV_CAS))
9145 (set (reg:CCZ1 CC_REGNUM)
9146 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9147 "TARGET_ZARCH"
9148 "c<td>sg\t%0,%3,%S1"
9149 [(set_attr "op_type" "RSY")
9150 (set_attr "type" "sem")])
9151
9152 ; cds, cdsy
9153 (define_insn "*atomic_compare_and_swapdi_2"
9154 [(set (match_operand:DI 0 "register_operand" "=r,r")
9155 (match_operand:DI 1 "memory_operand" "+Q,S"))
9156 (set (match_dup 1)
9157 (unspec_volatile:DI
9158 [(match_dup 1)
9159 (match_operand:DI 2 "register_operand" "0,0")
9160 (match_operand:DI 3 "register_operand" "r,r")]
9161 UNSPECV_CAS))
9162 (set (reg:CCZ1 CC_REGNUM)
9163 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9164 "!TARGET_ZARCH"
9165 "@
9166 cds\t%0,%3,%S1
9167 cdsy\t%0,%3,%S1"
9168 [(set_attr "op_type" "RS,RSY")
9169 (set_attr "type" "sem")])
9170
9171 ; cs, csy
9172 (define_insn "*atomic_compare_and_swapsi_3"
9173 [(set (match_operand:SI 0 "register_operand" "=r,r")
9174 (match_operand:SI 1 "memory_operand" "+Q,S"))
9175 (set (match_dup 1)
9176 (unspec_volatile:SI
9177 [(match_dup 1)
9178 (match_operand:SI 2 "register_operand" "0,0")
9179 (match_operand:SI 3 "register_operand" "r,r")]
9180 UNSPECV_CAS))
9181 (set (reg:CCZ1 CC_REGNUM)
9182 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
9183 ""
9184 "@
9185 cs\t%0,%3,%S1
9186 csy\t%0,%3,%S1"
9187 [(set_attr "op_type" "RS,RSY")
9188 (set_attr "type" "sem")])
9189
9190 ;
9191 ; Other atomic instruction patterns.
9192 ;
9193
9194 ; z196 load and add, xor, or and and instructions
9195
9196 (define_expand "atomic_fetch_<atomic><mode>"
9197 [(match_operand:GPR 0 "register_operand") ;; val out
9198 (ATOMIC_Z196:GPR
9199 (match_operand:GPR 1 "memory_operand") ;; memory
9200 (match_operand:GPR 2 "register_operand")) ;; val in
9201 (match_operand:SI 3 "const_int_operand")] ;; model
9202 "TARGET_Z196"
9203 {
9204 emit_insn (gen_atomic_fetch_<atomic><mode>_iaf
9205 (operands[0], operands[1], operands[2]));
9206 DONE;
9207 })
9208
9209 ; lan, lang, lao, laog, lax, laxg, laa, laag
9210 (define_insn "atomic_fetch_<atomic><mode>_iaf"
9211 [(set (match_operand:GPR 0 "register_operand" "=d")
9212 (match_operand:GPR 1 "memory_operand" "+QS"))
9213 (set (match_dup 1)
9214 (unspec_volatile:GPR
9215 [(ATOMIC_Z196:GPR (match_dup 1)
9216 (match_operand:GPR 2 "general_operand" "d"))]
9217 UNSPECV_ATOMIC_OP))
9218 (clobber (reg:CC CC_REGNUM))]
9219 "TARGET_Z196"
9220 "la<noxa><g>\t%0,%2,%1"
9221 [(set_attr "op_type" "RSY")
9222 (set_attr "type" "sem")])
9223
9224 ;; For SImode and larger, the optabs.c code will do just fine in
9225 ;; expanding a compare-and-swap loop. For QI/HImode, we can do
9226 ;; better by expanding our own loop.
9227
9228 (define_expand "atomic_<atomic><mode>"
9229 [(ATOMIC:HQI
9230 (match_operand:HQI 0 "memory_operand") ;; memory
9231 (match_operand:HQI 1 "general_operand")) ;; val in
9232 (match_operand:SI 2 "const_int_operand")] ;; model
9233 ""
9234 {
9235 s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
9236 operands[1], false);
9237 DONE;
9238 })
9239
9240 (define_expand "atomic_fetch_<atomic><mode>"
9241 [(match_operand:HQI 0 "register_operand") ;; val out
9242 (ATOMIC:HQI
9243 (match_operand:HQI 1 "memory_operand") ;; memory
9244 (match_operand:HQI 2 "general_operand")) ;; val in
9245 (match_operand:SI 3 "const_int_operand")] ;; model
9246 ""
9247 {
9248 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
9249 operands[2], false);
9250 DONE;
9251 })
9252
9253 (define_expand "atomic_<atomic>_fetch<mode>"
9254 [(match_operand:HQI 0 "register_operand") ;; val out
9255 (ATOMIC:HQI
9256 (match_operand:HQI 1 "memory_operand") ;; memory
9257 (match_operand:HQI 2 "general_operand")) ;; val in
9258 (match_operand:SI 3 "const_int_operand")] ;; model
9259 ""
9260 {
9261 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
9262 operands[2], true);
9263 DONE;
9264 })
9265
9266 (define_expand "atomic_exchange<mode>"
9267 [(match_operand:HQI 0 "register_operand") ;; val out
9268 (match_operand:HQI 1 "memory_operand") ;; memory
9269 (match_operand:HQI 2 "general_operand") ;; val in
9270 (match_operand:SI 3 "const_int_operand")] ;; model
9271 ""
9272 {
9273 s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
9274 operands[2], false);
9275 DONE;
9276 })
9277
9278 ;;
9279 ;;- Miscellaneous instructions.
9280 ;;
9281
9282 ;
9283 ; allocate stack instruction pattern(s).
9284 ;
9285
9286 (define_expand "allocate_stack"
9287 [(match_operand 0 "general_operand" "")
9288 (match_operand 1 "general_operand" "")]
9289 "TARGET_BACKCHAIN"
9290 {
9291 rtx temp = gen_reg_rtx (Pmode);
9292
9293 emit_move_insn (temp, s390_back_chain_rtx ());
9294 anti_adjust_stack (operands[1]);
9295 emit_move_insn (s390_back_chain_rtx (), temp);
9296
9297 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9298 DONE;
9299 })
9300
9301
9302 ;
9303 ; setjmp instruction pattern.
9304 ;
9305
9306 (define_expand "builtin_setjmp_receiver"
9307 [(match_operand 0 "" "")]
9308 "flag_pic"
9309 {
9310 emit_insn (s390_load_got ());
9311 emit_use (pic_offset_table_rtx);
9312 DONE;
9313 })
9314
9315 ;; These patterns say how to save and restore the stack pointer. We need not
9316 ;; save the stack pointer at function level since we are careful to
9317 ;; preserve the backchain. At block level, we have to restore the backchain
9318 ;; when we restore the stack pointer.
9319 ;;
9320 ;; For nonlocal gotos, we must save both the stack pointer and its
9321 ;; backchain and restore both. Note that in the nonlocal case, the
9322 ;; save area is a memory location.
9323
9324 (define_expand "save_stack_function"
9325 [(match_operand 0 "general_operand" "")
9326 (match_operand 1 "general_operand" "")]
9327 ""
9328 "DONE;")
9329
9330 (define_expand "restore_stack_function"
9331 [(match_operand 0 "general_operand" "")
9332 (match_operand 1 "general_operand" "")]
9333 ""
9334 "DONE;")
9335
9336 (define_expand "restore_stack_block"
9337 [(match_operand 0 "register_operand" "")
9338 (match_operand 1 "register_operand" "")]
9339 "TARGET_BACKCHAIN"
9340 {
9341 rtx temp = gen_reg_rtx (Pmode);
9342
9343 emit_move_insn (temp, s390_back_chain_rtx ());
9344 emit_move_insn (operands[0], operands[1]);
9345 emit_move_insn (s390_back_chain_rtx (), temp);
9346
9347 DONE;
9348 })
9349
9350 (define_expand "save_stack_nonlocal"
9351 [(match_operand 0 "memory_operand" "")
9352 (match_operand 1 "register_operand" "")]
9353 ""
9354 {
9355 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
9356
9357 /* Copy the backchain to the first word, sp to the second and the
9358 literal pool base to the third. */
9359
9360 rtx save_bc = adjust_address (operands[0], Pmode, 0);
9361 rtx save_sp = adjust_address (operands[0], Pmode, GET_MODE_SIZE (Pmode));
9362 rtx save_bp = adjust_address (operands[0], Pmode, 2 * GET_MODE_SIZE (Pmode));
9363
9364 if (TARGET_BACKCHAIN)
9365 emit_move_insn (save_bc, force_reg (Pmode, s390_back_chain_rtx ()));
9366
9367 emit_move_insn (save_sp, operands[1]);
9368 emit_move_insn (save_bp, base);
9369
9370 DONE;
9371 })
9372
9373 (define_expand "restore_stack_nonlocal"
9374 [(match_operand 0 "register_operand" "")
9375 (match_operand 1 "memory_operand" "")]
9376 ""
9377 {
9378 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
9379 rtx temp = NULL_RTX;
9380
9381 /* Restore the backchain from the first word, sp from the second and the
9382 literal pool base from the third. */
9383
9384 rtx save_bc = adjust_address (operands[1], Pmode, 0);
9385 rtx save_sp = adjust_address (operands[1], Pmode, GET_MODE_SIZE (Pmode));
9386 rtx save_bp = adjust_address (operands[1], Pmode, 2 * GET_MODE_SIZE (Pmode));
9387
9388 if (TARGET_BACKCHAIN)
9389 temp = force_reg (Pmode, save_bc);
9390
9391 emit_move_insn (base, save_bp);
9392 emit_move_insn (operands[0], save_sp);
9393
9394 if (temp)
9395 emit_move_insn (s390_back_chain_rtx (), temp);
9396
9397 emit_use (base);
9398 DONE;
9399 })
9400
9401 (define_expand "exception_receiver"
9402 [(const_int 0)]
9403 ""
9404 {
9405 s390_set_has_landing_pad_p (true);
9406 DONE;
9407 })
9408
9409 ;
9410 ; nop instruction pattern(s).
9411 ;
9412
9413 (define_insn "nop"
9414 [(const_int 0)]
9415 ""
9416 "lr\t0,0"
9417 [(set_attr "op_type" "RR")
9418 (set_attr "z10prop" "z10_fr_E1")])
9419
9420 (define_insn "nop1"
9421 [(const_int 1)]
9422 ""
9423 "lr\t1,1"
9424 [(set_attr "op_type" "RR")])
9425
9426
9427 ;
9428 ; Special literal pool access instruction pattern(s).
9429 ;
9430
9431 (define_insn "*pool_entry"
9432 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
9433 UNSPECV_POOL_ENTRY)]
9434 ""
9435 {
9436 enum machine_mode mode = GET_MODE (PATTERN (insn));
9437 unsigned int align = GET_MODE_BITSIZE (mode);
9438 s390_output_pool_entry (operands[0], mode, align);
9439 return "";
9440 }
9441 [(set (attr "length")
9442 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
9443
9444 (define_insn "pool_align"
9445 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
9446 UNSPECV_POOL_ALIGN)]
9447 ""
9448 ".align\t%0"
9449 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
9450
9451 (define_insn "pool_section_start"
9452 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
9453 ""
9454 ".section\t.rodata"
9455 [(set_attr "length" "0")])
9456
9457 (define_insn "pool_section_end"
9458 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
9459 ""
9460 ".previous"
9461 [(set_attr "length" "0")])
9462
9463 (define_insn "main_base_31_small"
9464 [(set (match_operand 0 "register_operand" "=a")
9465 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
9466 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9467 "basr\t%0,0"
9468 [(set_attr "op_type" "RR")
9469 (set_attr "type" "la")
9470 (set_attr "z196prop" "z196_cracked")])
9471
9472 (define_insn "main_base_31_large"
9473 [(set (match_operand 0 "register_operand" "=a")
9474 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
9475 (set (pc) (label_ref (match_operand 2 "" "")))]
9476 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9477 "bras\t%0,%2"
9478 [(set_attr "op_type" "RI")
9479 (set_attr "z196prop" "z196_cracked")])
9480
9481 (define_insn "main_base_64"
9482 [(set (match_operand 0 "register_operand" "=a")
9483 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
9484 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9485 "larl\t%0,%1"
9486 [(set_attr "op_type" "RIL")
9487 (set_attr "type" "larl")
9488 (set_attr "z10prop" "z10_fwd_A1")])
9489
9490 (define_insn "main_pool"
9491 [(set (match_operand 0 "register_operand" "=a")
9492 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
9493 "GET_MODE (operands[0]) == Pmode"
9494 {
9495 gcc_unreachable ();
9496 }
9497 [(set (attr "type")
9498 (if_then_else (match_test "TARGET_CPU_ZARCH")
9499 (const_string "larl") (const_string "la")))])
9500
9501 (define_insn "reload_base_31"
9502 [(set (match_operand 0 "register_operand" "=a")
9503 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
9504 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9505 "basr\t%0,0\;la\t%0,%1-.(%0)"
9506 [(set_attr "length" "6")
9507 (set_attr "type" "la")
9508 (set_attr "z196prop" "z196_cracked")])
9509
9510 (define_insn "reload_base_64"
9511 [(set (match_operand 0 "register_operand" "=a")
9512 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
9513 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
9514 "larl\t%0,%1"
9515 [(set_attr "op_type" "RIL")
9516 (set_attr "type" "larl")
9517 (set_attr "z10prop" "z10_fwd_A1")])
9518
9519 (define_insn "pool"
9520 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
9521 ""
9522 {
9523 gcc_unreachable ();
9524 }
9525 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
9526
9527 ;;
9528 ;; Insns related to generating the function prologue and epilogue.
9529 ;;
9530
9531
9532 (define_expand "prologue"
9533 [(use (const_int 0))]
9534 ""
9535 "s390_emit_prologue (); DONE;")
9536
9537 (define_expand "epilogue"
9538 [(use (const_int 1))]
9539 ""
9540 "s390_emit_epilogue (false); DONE;")
9541
9542 (define_expand "sibcall_epilogue"
9543 [(use (const_int 0))]
9544 ""
9545 "s390_emit_epilogue (true); DONE;")
9546
9547 (define_insn "*return"
9548 [(return)
9549 (use (match_operand 0 "register_operand" "a"))]
9550 "GET_MODE (operands[0]) == Pmode"
9551 "br\t%0"
9552 [(set_attr "op_type" "RR")
9553 (set_attr "type" "jsr")
9554 (set_attr "atype" "agen")])
9555
9556
9557 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
9558 ;; pointer. This is used for compatibility.
9559
9560 (define_expand "ptr_extend"
9561 [(set (match_operand:DI 0 "register_operand" "=r")
9562 (match_operand:SI 1 "register_operand" "r"))]
9563 "TARGET_64BIT"
9564 {
9565 emit_insn (gen_anddi3 (operands[0],
9566 gen_lowpart (DImode, operands[1]),
9567 GEN_INT (0x7fffffff)));
9568 DONE;
9569 })
9570
9571 ;; Instruction definition to expand eh_return macro to support
9572 ;; swapping in special linkage return addresses.
9573
9574 (define_expand "eh_return"
9575 [(use (match_operand 0 "register_operand" ""))]
9576 "TARGET_TPF"
9577 {
9578 s390_emit_tpf_eh_return (operands[0]);
9579 DONE;
9580 })
9581
9582 ;
9583 ; Stack Protector Patterns
9584 ;
9585
9586 (define_expand "stack_protect_set"
9587 [(set (match_operand 0 "memory_operand" "")
9588 (match_operand 1 "memory_operand" ""))]
9589 ""
9590 {
9591 #ifdef TARGET_THREAD_SSP_OFFSET
9592 operands[1]
9593 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
9594 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
9595 #endif
9596 if (TARGET_64BIT)
9597 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
9598 else
9599 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
9600
9601 DONE;
9602 })
9603
9604 (define_insn "stack_protect_set<mode>"
9605 [(set (match_operand:DSI 0 "memory_operand" "=Q")
9606 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
9607 ""
9608 "mvc\t%O0(%G0,%R0),%S1"
9609 [(set_attr "op_type" "SS")])
9610
9611 (define_expand "stack_protect_test"
9612 [(set (reg:CC CC_REGNUM)
9613 (compare (match_operand 0 "memory_operand" "")
9614 (match_operand 1 "memory_operand" "")))
9615 (match_operand 2 "" "")]
9616 ""
9617 {
9618 rtx cc_reg, test;
9619 #ifdef TARGET_THREAD_SSP_OFFSET
9620 operands[1]
9621 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
9622 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
9623 #endif
9624 if (TARGET_64BIT)
9625 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
9626 else
9627 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
9628
9629 cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM);
9630 test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx);
9631 emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2]));
9632 DONE;
9633 })
9634
9635 (define_insn "stack_protect_test<mode>"
9636 [(set (reg:CCZ CC_REGNUM)
9637 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
9638 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
9639 ""
9640 "clc\t%O0(%G0,%R0),%S1"
9641 [(set_attr "op_type" "SS")])
9642
9643 ; This is used in s390_emit_prologue in order to prevent insns
9644 ; adjusting the stack pointer to be moved over insns writing stack
9645 ; slots using a copy of the stack pointer in a different register.
9646 (define_insn "stack_tie"
9647 [(set (match_operand:BLK 0 "memory_operand" "+m")
9648 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
9649 ""
9650 ""
9651 [(set_attr "length" "0")])
9652
9653
9654 ;
9655 ; Data prefetch patterns
9656 ;
9657
9658 (define_insn "prefetch"
9659 [(prefetch (match_operand 0 "address_operand" "ZQZRZSZT,X")
9660 (match_operand:SI 1 "const_int_operand" " n,n")
9661 (match_operand:SI 2 "const_int_operand" " n,n"))]
9662 "TARGET_Z10"
9663 {
9664 switch (which_alternative)
9665 {
9666 case 0:
9667 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
9668 case 1:
9669 if (larl_operand (operands[0], Pmode))
9670 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
9671 default:
9672
9673 /* This might be reached for symbolic operands with an odd
9674 addend. We simply omit the prefetch for such rare cases. */
9675
9676 return "";
9677 }
9678 }
9679 [(set_attr "type" "load,larl")
9680 (set_attr "op_type" "RXY,RIL")
9681 (set_attr "z10prop" "z10_super")
9682 (set_attr "z196prop" "z196_alone")])
9683
9684
9685 ;
9686 ; Byte swap instructions
9687 ;
9688
9689 (define_insn "bswap<mode>2"
9690 [(set (match_operand:GPR 0 "register_operand" "=d, d")
9691 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,RT")))]
9692 "TARGET_CPU_ZARCH"
9693 "@
9694 lrv<g>r\t%0,%1
9695 lrv<g>\t%0,%1"
9696 [(set_attr "type" "*,load")
9697 (set_attr "op_type" "RRE,RXY")
9698 (set_attr "z10prop" "z10_super")])
9699
9700
9701 ;
9702 ; Population count instruction
9703 ;
9704
9705 ; The S/390 popcount instruction counts the bits of op1 in 8 byte
9706 ; portions and stores the result in the corresponding bytes in op0.
9707 (define_insn "*popcount<mode>"
9708 [(set (match_operand:INT 0 "register_operand" "=d")
9709 (unspec:INT [(match_operand:INT 1 "register_operand" "d")] UNSPEC_POPCNT))
9710 (clobber (reg:CC CC_REGNUM))]
9711 "TARGET_Z196"
9712 "popcnt\t%0,%1"
9713 [(set_attr "op_type" "RRE")])
9714
9715 (define_expand "popcountdi2"
9716 [; popcnt op0, op1
9717 (parallel [(set (match_operand:DI 0 "register_operand" "")
9718 (unspec:DI [(match_operand:DI 1 "register_operand")]
9719 UNSPEC_POPCNT))
9720 (clobber (reg:CC CC_REGNUM))])
9721 ; sllg op2, op0, 32
9722 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 32)))
9723 ; agr op0, op2
9724 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
9725 (clobber (reg:CC CC_REGNUM))])
9726 ; sllg op2, op0, 16
9727 (set (match_dup 2)
9728 (ashift:DI (match_dup 0) (const_int 16)))
9729 ; agr op0, op2
9730 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
9731 (clobber (reg:CC CC_REGNUM))])
9732 ; sllg op2, op0, 8
9733 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 8)))
9734 ; agr op0, op2
9735 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
9736 (clobber (reg:CC CC_REGNUM))])
9737 ; srlg op0, op0, 56
9738 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (const_int 56)))]
9739 "TARGET_Z196 && TARGET_64BIT"
9740 "operands[2] = gen_reg_rtx (DImode);")
9741
9742 (define_expand "popcountsi2"
9743 [; popcnt op0, op1
9744 (parallel [(set (match_operand:SI 0 "register_operand" "")
9745 (unspec:SI [(match_operand:SI 1 "register_operand")]
9746 UNSPEC_POPCNT))
9747 (clobber (reg:CC CC_REGNUM))])
9748 ; sllk op2, op0, 16
9749 (set (match_dup 2)
9750 (ashift:SI (match_dup 0) (const_int 16)))
9751 ; ar op0, op2
9752 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
9753 (clobber (reg:CC CC_REGNUM))])
9754 ; sllk op2, op0, 8
9755 (set (match_dup 2) (ashift:SI (match_dup 0) (const_int 8)))
9756 ; ar op0, op2
9757 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
9758 (clobber (reg:CC CC_REGNUM))])
9759 ; srl op0, op0, 24
9760 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 24)))]
9761 "TARGET_Z196"
9762 "operands[2] = gen_reg_rtx (SImode);")
9763
9764 (define_expand "popcounthi2"
9765 [; popcnt op0, op1
9766 (parallel [(set (match_operand:HI 0 "register_operand" "")
9767 (unspec:HI [(match_operand:HI 1 "register_operand")]
9768 UNSPEC_POPCNT))
9769 (clobber (reg:CC CC_REGNUM))])
9770 ; sllk op2, op0, 8
9771 (set (match_dup 2)
9772 (ashift:SI (match_dup 0) (const_int 8)))
9773 ; ar op0, op2
9774 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
9775 (clobber (reg:CC CC_REGNUM))])
9776 ; srl op0, op0, 8
9777 (set (match_dup 0) (lshiftrt:HI (match_dup 0) (const_int 8)))]
9778 "TARGET_Z196"
9779 "operands[2] = gen_reg_rtx (SImode);")
9780
9781 (define_expand "popcountqi2"
9782 [; popcnt op0, op1
9783 (parallel [(set (match_operand:QI 0 "register_operand" "")
9784 (unspec:QI [(match_operand:QI 1 "register_operand")]
9785 UNSPEC_POPCNT))
9786 (clobber (reg:CC CC_REGNUM))])]
9787 "TARGET_Z196"
9788 "")
9789
9790 ;;
9791 ;;- Copy sign instructions
9792 ;;
9793
9794 (define_insn "copysign<mode>3"
9795 [(set (match_operand:FP 0 "register_operand" "=f")
9796 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
9797 (match_operand:FP 2 "register_operand" "f")]
9798 UNSPEC_COPYSIGN))]
9799 "TARGET_Z196"
9800 "cpsdr\t%0,%2,%1"
9801 [(set_attr "op_type" "RRF")
9802 (set_attr "type" "fsimp<mode>")])