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