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 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)
8 ;; This file is part of GCC.
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
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
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/>.
25 ;; See constraints.md for a description of constraints specific to s390.
28 ;; Special formats used for outputting 390 instructions.
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.
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.
51 ;; We have a special constraint for pattern matching.
53 ;; s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
68 ; GOT/PLT and lt-relative accesses
69 (UNSPEC_LTREL_OFFSET 100)
70 (UNSPEC_LTREL_BASE 101)
71 (UNSPEC_POOL_OFFSET 102)
79 (UNSPEC_RELOAD_BASE 210)
80 (UNSPEC_MAIN_BASE 211)
88 ; TLS relocation specifiers
93 (UNSPEC_GOTNTPOFF 504)
94 (UNSPEC_INDNTPOFF 505)
97 (UNSPEC_TLSLDM_NTPOFF 511)
104 ; Stack Smashing Protector
108 ; Copy sign instructions
109 (UNSPEC_COPYSIGN 800)
111 ; Test Data Class (TDC)
112 (UNSPEC_TDC_INSN 900)
116 ;; UNSPEC_VOLATILE usage
124 (UNSPECV_TPF_PROLOGUE 20)
125 (UNSPECV_TPF_EPILOGUE 21)
129 (UNSPECV_POOL_SECTION 201)
130 (UNSPECV_POOL_ALIGN 202)
131 (UNSPECV_POOL_ENTRY 203)
132 (UNSPECV_MAIN_POOL 300)
145 ; Registers with special meaning
149 ; Sibling call register.
151 ; Literal pool base register.
153 ; Return address register.
155 ; Condition code register.
157 ; Thread local storage pointer register.
161 ; Hardware register names
165 ; General purpose registers
167 ; Floating point registers.
173 ;; PFPO GPR0 argument format
178 ; PFPO operation type
179 (PFPO_CONVERT 0x1000000)
181 (PFPO_OP_TYPE_SF 0x5)
182 (PFPO_OP_TYPE_DF 0x6)
183 (PFPO_OP_TYPE_TF 0x7)
184 (PFPO_OP_TYPE_SD 0x8)
185 (PFPO_OP_TYPE_DD 0x9)
186 (PFPO_OP_TYPE_TD 0xa)
187 ; Bitposition of operand types
188 (PFPO_OP0_TYPE_SHIFT 16)
189 (PFPO_OP1_TYPE_SHIFT 8)
193 ;; Instruction operand type as used in the Principles of Operation.
194 ;; Used to determine defaults for length and other attribute values.
196 (define_attr "op_type"
197 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,RRR,SIL,RRS,RIS"
200 ;; Instruction type attribute used for scheduling.
202 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
203 cs,vs,store,sem,idiv,
204 imulhi,imulsi,imuldi,
205 branch,jsr,fsimptf,fsimpdf,fsimpsf,
206 floadtf,floaddf,floadsf,fstoredf,fstoresf,
207 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
208 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
209 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
210 itoftf, itofdf, itofsf, itofdd, itoftd,
211 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
212 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
214 (cond [(eq_attr "op_type" "NN") (const_string "other")
215 (eq_attr "op_type" "SS") (const_string "cs")]
216 (const_string "integer")))
218 ;; Another attribute used for scheduling purposes:
219 ;; agen: Instruction uses the address generation unit
220 ;; reg: Instruction does not use the agen unit
222 (define_attr "atype" "agen,reg"
223 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE")
225 (const_string "agen")))
227 ;; Properties concerning Z10 execution grouping and value forwarding.
228 ;; z10_super: instruction is superscalar.
229 ;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
230 ;; z10_fwd: The instruction reads the value of an operand and stores it into a
231 ;; target register. It can forward this value to a second instruction that reads
232 ;; the same register if that second instruction is issued in the same group.
233 ;; z10_rec: The instruction is in the T pipeline and reads a register. If the
234 ;; instruction in the S pipe writes to the register, then the T instruction
235 ;; can immediately read the new value.
236 ;; z10_fr: union of Z10_fwd and z10_rec.
237 ;; z10_c: second operand of instruction is a register and read with complemented bits.
238 ;; z10_cobra: its a compare and branch instruction
240 ;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
243 (define_attr "z10prop" "none,
244 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
245 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
247 z10_fr, z10_fr_A3, z10_fr_E1,
249 (const_string "none"))
254 (define_attr "length" ""
255 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
256 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF,RRR") (const_int 4)]
260 ;; Processor type. This attribute must exactly match the processor_type
261 ;; enumeration in s390.h. The current machine description does not
262 ;; distinguish between g5 and g6, but there are differences between the two
263 ;; CPUs could in theory be modeled.
265 (define_attr "cpu" "g5,g6,z900,z990,z9_109,z10"
266 (const (symbol_ref "s390_tune")))
268 (define_attr "cpu_facility" "standard,ieee,zarch,longdisp,extimm,dfp,z10"
269 (const_string "standard"))
271 (define_attr "enabled" ""
272 (cond [(eq_attr "cpu_facility" "standard")
275 (and (eq_attr "cpu_facility" "ieee")
276 (ne (symbol_ref "TARGET_CPU_IEEE_FLOAT") (const_int 0)))
279 (and (eq_attr "cpu_facility" "zarch")
280 (ne (symbol_ref "TARGET_ZARCH") (const_int 0)))
283 (and (eq_attr "cpu_facility" "longdisp")
284 (ne (symbol_ref "TARGET_LONG_DISPLACEMENT") (const_int 0)))
287 (and (eq_attr "cpu_facility" "extimm")
288 (ne (symbol_ref "TARGET_EXTIMM") (const_int 0)))
291 (and (eq_attr "cpu_facility" "dfp")
292 (ne (symbol_ref "TARGET_DFP") (const_int 0)))
295 (and (eq_attr "cpu_facility" "z10")
296 (ne (symbol_ref "TARGET_Z10") (const_int 0)))
300 ;; Pipeline description for z900. For lack of anything better,
301 ;; this description is also used for the g5 and g6.
304 ;; Pipeline description for z990, z9-109 and z9-ec.
307 ;; Pipeline description for z10
311 (include "predicates.md")
313 ;; Constraint definitions
314 (include "constraints.md")
321 ;; These mode iterators allow floating point patterns to be generated from the
323 (define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
324 (SD "TARGET_HARD_DFP")])
325 (define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
326 (define_mode_iterator FPALL [TF DF SF TD DD SD])
327 (define_mode_iterator BFP [TF DF SF])
328 (define_mode_iterator DFP [TD DD])
329 (define_mode_iterator DFP_ALL [TD DD SD])
330 (define_mode_iterator DSF [DF SF])
331 (define_mode_iterator SD_SF [SF SD])
332 (define_mode_iterator DD_DF [DF DD])
333 (define_mode_iterator TD_TF [TF TD])
335 ;; This mode iterator allows 31-bit and 64-bit TDSI patterns to be generated
336 ;; from the same template.
337 (define_mode_iterator TDSI [(TI "TARGET_64BIT") DI SI])
339 ;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
340 ;; from the same template.
341 (define_mode_iterator GPR [(DI "TARGET_64BIT") SI])
342 (define_mode_iterator DSI [DI SI])
344 ;; These mode iterators allow :P to be used for patterns that operate on
345 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
346 (define_mode_iterator DP [(TI "TARGET_64BIT") (DI "!TARGET_64BIT")])
347 (define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
349 ;; This mode iterator allows the QI and HI patterns to be defined from
350 ;; the same template.
351 (define_mode_iterator HQI [HI QI])
353 ;; This mode iterator allows the integer patterns to be defined from the
355 (define_mode_iterator INT [(DI "TARGET_64BIT") SI HI QI])
356 (define_mode_iterator INTALL [TI DI SI HI QI])
358 ;; This iterator allows to unify all 'bCOND' expander patterns.
359 (define_code_iterator COMPARE [eq ne gt gtu lt ltu ge geu le leu unordered
360 ordered uneq unlt ungt unle unge ltgt])
362 ;; This iterator allows to unify all 'sCOND' patterns.
363 (define_code_iterator SCOND [ltu gtu leu geu])
365 ;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
366 ;; the same template.
367 (define_code_iterator SHIFT [ashift lshiftrt])
369 ;; This iterator and attribute allow to combine most atomic operations.
370 (define_code_iterator ATOMIC [and ior xor plus minus mult])
371 (define_code_attr atomic [(and "and") (ior "ior") (xor "xor")
372 (plus "add") (minus "sub") (mult "nand")])
374 ;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
375 ;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
376 (define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
378 ;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
379 ;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
381 (define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
383 ;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
384 ;; Likewise for "<RXe>".
385 (define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
386 (define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
388 ;; The decimal floating point variants of add, sub, div and mul support 3
389 ;; fp register operands. The following attributes allow to merge the bfp and
390 ;; dfp variants in a single insn definition.
392 ;; This attribute is used to set op_type accordingly.
393 (define_mode_attr RRer [(TF "RRE") (DF "RRE") (SF "RRE") (TD "RRR")
394 (DD "RRR") (SD "RRR")])
396 ;; This attribute is used in the operand constraint list in order to have the
397 ;; first and the second operand match for bfp modes.
398 (define_mode_attr f0 [(TF "0") (DF "0") (SF "0") (TD "f") (DD "f") (DD "f")])
400 ;; This attribute is used in the operand list of the instruction to have an
401 ;; additional operand for the dfp instructions.
402 (define_mode_attr op1 [(TF "") (DF "") (SF "")
403 (TD "%1,") (DD "%1,") (SD "%1,")])
406 ;; This attribute is used in the operand constraint list
407 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
408 ;; TFmode values are represented by a fp register pair. Since the
409 ;; sign bit instructions only handle single source and target fp registers
410 ;; these instructions can only be used for TFmode values if the source and
411 ;; target operand uses the same fp register.
412 (define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
414 ;; In FP templates, "<Rf>" will expand to "f" in TFmode and "R" otherwise.
415 ;; This is used to disable the memory alternative in TFmode patterns.
416 (define_mode_attr Rf [(TF "f") (DF "R") (SF "R") (TD "f") (DD "f") (SD "f")])
418 ;; This attribute adds b for bfp instructions and t for dfp instructions and is used
419 ;; within instruction mnemonics.
420 (define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
422 ;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
423 ;; modes and to an empty string for bfp modes.
424 (define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
426 ;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
427 ;; and "0" in SImode. This allows to combine instructions of which the 31bit
428 ;; version only operates on one register.
429 (define_mode_attr d0 [(DI "d") (SI "0")])
431 ;; In combination with d0 this allows to combine instructions of which the 31bit
432 ;; version only operates on one register. The DImode version needs an additional
433 ;; register for the assembler output.
434 (define_mode_attr 1 [(DI "%1,") (SI "")])
436 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
437 ;; 'ashift' and "srdl" in 'lshiftrt'.
438 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
440 ;; In SHIFT templates, this attribute holds the correct standard name for the
441 ;; pattern itself and the corresponding function calls.
442 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
444 ;; This attribute handles differences in the instruction 'type' and will result
445 ;; in "RRE" for DImode and "RR" for SImode.
446 (define_mode_attr E [(DI "E") (SI "")])
448 ;; This attribute handles differences in the instruction 'type' and makes RX<Y>
449 ;; to result in "RXY" for DImode and "RX" for SImode.
450 (define_mode_attr Y [(DI "Y") (SI "")])
452 ;; This attribute handles differences in the instruction 'type' and will result
453 ;; in "RSE" for TImode and "RS" for DImode.
454 (define_mode_attr TE [(TI "E") (DI "")])
456 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
457 ;; and "lcr" in SImode.
458 (define_mode_attr g [(DI "g") (SI "")])
460 ;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
461 ;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
462 ;; were enhanced with long displacements whereas 31bit instructions got a ..y
463 ;; variant for long displacements.
464 (define_mode_attr y [(DI "g") (SI "y")])
466 ;; In DP templates, a string like "cds<g>" will expand to "cdsg" in TImode
467 ;; and "cds" in DImode.
468 (define_mode_attr tg [(TI "g") (DI "")])
470 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
471 ;; and "cfdbr" in SImode.
472 (define_mode_attr gf [(DI "g") (SI "f")])
474 ;; ICM mask required to load MODE value into the lowest subreg
475 ;; of a SImode register.
476 (define_mode_attr icm_lo [(HI "3") (QI "1")])
478 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
479 ;; HImode and "llgc" in QImode.
480 (define_mode_attr hc [(HI "h") (QI "c")])
482 ;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
484 (define_mode_attr DBL [(DI "TI") (SI "DI")])
486 ;; This attribute expands to DF for TFmode and to DD for TDmode . It is
487 ;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
488 (define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
490 ;; Maximum unsigned integer that fits in MODE.
491 (define_mode_attr max_uint [(HI "65535") (QI "255")])
494 ;;- Compare instructions.
497 (define_expand "cmp<mode>"
498 [(set (reg:CC CC_REGNUM)
499 (compare:CC (match_operand:GPR 0 "register_operand" "")
500 (match_operand:GPR 1 "general_operand" "")))]
503 s390_compare_op0 = operands[0];
504 s390_compare_op1 = operands[1];
508 (define_expand "cmp<mode>"
509 [(set (reg:CC CC_REGNUM)
510 (compare:CC (match_operand:FP 0 "register_operand" "")
511 (match_operand:FP 1 "general_operand" "")))]
514 s390_compare_op0 = operands[0];
515 s390_compare_op1 = operands[1];
520 ; Test-under-Mask instructions
522 (define_insn "*tmqi_mem"
523 [(set (reg CC_REGNUM)
524 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
525 (match_operand:QI 1 "immediate_operand" "n,n"))
526 (match_operand:QI 2 "immediate_operand" "n,n")))]
527 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
531 [(set_attr "op_type" "SI,SIY")
532 (set_attr "z10prop" "z10_super,z10_super")])
534 (define_insn "*tmdi_reg"
535 [(set (reg CC_REGNUM)
536 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
537 (match_operand:DI 1 "immediate_operand"
538 "N0HD0,N1HD0,N2HD0,N3HD0"))
539 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
541 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
542 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
548 [(set_attr "op_type" "RI")
549 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
551 (define_insn "*tmsi_reg"
552 [(set (reg CC_REGNUM)
553 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
554 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
555 (match_operand:SI 2 "immediate_operand" "n,n")))]
556 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
557 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
561 [(set_attr "op_type" "RI")
562 (set_attr "z10prop" "z10_super,z10_super")])
564 (define_insn "*tm<mode>_full"
565 [(set (reg CC_REGNUM)
566 (compare (match_operand:HQI 0 "register_operand" "d")
567 (match_operand:HQI 1 "immediate_operand" "n")))]
568 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
570 [(set_attr "op_type" "RI")
571 (set_attr "z10prop" "z10_super")])
575 ; Load-and-Test instructions
578 ; tst(di|si) instruction pattern(s).
580 (define_insn "*tstdi_sign"
581 [(set (reg CC_REGNUM)
585 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,RT") 0)
586 (const_int 32)) (const_int 32))
587 (match_operand:DI 1 "const0_operand" "")))
588 (set (match_operand:DI 2 "register_operand" "=d,d")
589 (sign_extend:DI (match_dup 0)))]
590 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT"
593 [(set_attr "op_type" "RRE,RXY")
594 (set_attr "cpu_facility" "*,z10")
595 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
598 (define_insn "*tst<mode>_extimm"
599 [(set (reg CC_REGNUM)
600 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
601 (match_operand:GPR 1 "const0_operand" "")))
602 (set (match_operand:GPR 2 "register_operand" "=d,d")
604 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
608 [(set_attr "op_type" "RR<E>,RXY")
609 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
612 (define_insn "*tst<mode>_cconly_extimm"
613 [(set (reg CC_REGNUM)
614 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,RT")
615 (match_operand:GPR 1 "const0_operand" "")))
616 (clobber (match_scratch:GPR 2 "=X,d"))]
617 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
621 [(set_attr "op_type" "RR<E>,RXY")
622 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
624 (define_insn "*tstdi"
625 [(set (reg CC_REGNUM)
626 (compare (match_operand:DI 0 "register_operand" "d")
627 (match_operand:DI 1 "const0_operand" "")))
628 (set (match_operand:DI 2 "register_operand" "=d")
630 "s390_match_ccmode(insn, CCSmode) && TARGET_64BIT && !TARGET_EXTIMM"
632 [(set_attr "op_type" "RRE")
633 (set_attr "z10prop" "z10_fr_E1")])
635 (define_insn "*tstsi"
636 [(set (reg CC_REGNUM)
637 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
638 (match_operand:SI 1 "const0_operand" "")))
639 (set (match_operand:SI 2 "register_operand" "=d,d,d")
641 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
646 [(set_attr "op_type" "RR,RS,RSY")
647 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
649 (define_insn "*tstsi_cconly"
650 [(set (reg CC_REGNUM)
651 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
652 (match_operand:SI 1 "const0_operand" "")))
653 (clobber (match_scratch:SI 2 "=X,d,d"))]
654 "s390_match_ccmode(insn, CCSmode)"
659 [(set_attr "op_type" "RR,RS,RSY")
660 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
662 (define_insn "*tstdi_cconly_31"
663 [(set (reg CC_REGNUM)
664 (compare (match_operand:DI 0 "register_operand" "d")
665 (match_operand:DI 1 "const0_operand" "")))]
666 "s390_match_ccmode(insn, CCSmode) && !TARGET_64BIT"
668 [(set_attr "op_type" "RS")
669 (set_attr "atype" "reg")])
672 (define_insn "*tst<mode>_cconly2"
673 [(set (reg CC_REGNUM)
674 (compare (match_operand:GPR 0 "register_operand" "d")
675 (match_operand:GPR 1 "const0_operand" "")))]
676 "s390_match_ccmode(insn, CCSmode)"
678 [(set_attr "op_type" "RR<E>")
679 (set_attr "z10prop" "z10_fr_E1")])
681 ; tst(hi|qi) instruction pattern(s).
683 (define_insn "*tst<mode>CCT"
684 [(set (reg CC_REGNUM)
685 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
686 (match_operand:HQI 1 "const0_operand" "")))
687 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
689 "s390_match_ccmode(insn, CCTmode)"
692 icmy\t%2,<icm_lo>,%S0
694 [(set_attr "op_type" "RS,RSY,RI")
695 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
697 (define_insn "*tsthiCCT_cconly"
698 [(set (reg CC_REGNUM)
699 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
700 (match_operand:HI 1 "const0_operand" "")))
701 (clobber (match_scratch:HI 2 "=d,d,X"))]
702 "s390_match_ccmode(insn, CCTmode)"
707 [(set_attr "op_type" "RS,RSY,RI")
708 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
710 (define_insn "*tstqiCCT_cconly"
711 [(set (reg CC_REGNUM)
712 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
713 (match_operand:QI 1 "const0_operand" "")))]
714 "s390_match_ccmode(insn, CCTmode)"
719 [(set_attr "op_type" "SI,SIY,RI")
720 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
722 (define_insn "*tst<mode>"
723 [(set (reg CC_REGNUM)
724 (compare (match_operand:HQI 0 "s_operand" "Q,S")
725 (match_operand:HQI 1 "const0_operand" "")))
726 (set (match_operand:HQI 2 "register_operand" "=d,d")
728 "s390_match_ccmode(insn, CCSmode)"
731 icmy\t%2,<icm_lo>,%S0"
732 [(set_attr "op_type" "RS,RSY")
733 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
735 (define_insn "*tst<mode>_cconly"
736 [(set (reg CC_REGNUM)
737 (compare (match_operand:HQI 0 "s_operand" "Q,S")
738 (match_operand:HQI 1 "const0_operand" "")))
739 (clobber (match_scratch:HQI 2 "=d,d"))]
740 "s390_match_ccmode(insn, CCSmode)"
743 icmy\t%2,<icm_lo>,%S0"
744 [(set_attr "op_type" "RS,RSY")
745 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
748 ; Compare (equality) instructions
750 (define_insn "*cmpdi_cct"
751 [(set (reg CC_REGNUM)
752 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
753 (match_operand:DI 1 "general_operand" "d,K,Os,RT,BQ")))]
754 "s390_match_ccmode (insn, CCTmode) && TARGET_64BIT"
761 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
762 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
764 (define_insn "*cmpsi_cct"
765 [(set (reg CC_REGNUM)
766 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
767 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
768 "s390_match_ccmode (insn, CCTmode)"
776 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
777 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super,z10_super,*")])
779 ; Compare (signed) instructions
781 (define_insn "*cmpdi_ccs_sign"
782 [(set (reg CC_REGNUM)
783 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
785 (match_operand:DI 0 "register_operand" "d, d,d")))]
786 "s390_match_ccmode(insn, CCSRmode) && TARGET_64BIT"
791 [(set_attr "op_type" "RRE,RXY,RIL")
792 (set_attr "z10prop" "z10_c,*,*")
793 (set_attr "type" "*,*,larl")])
797 (define_insn "*cmpsi_ccs_sign"
798 [(set (reg CC_REGNUM)
799 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
800 (match_operand:SI 0 "register_operand" "d,d,d")))]
801 "s390_match_ccmode(insn, CCSRmode)"
806 [(set_attr "op_type" "RX,RXY,RIL")
807 (set_attr "cpu_facility" "*,*,z10")
808 (set_attr "type" "*,*,larl")])
810 (define_insn "*cmphi_ccs_z10"
811 [(set (reg CC_REGNUM)
812 (compare (match_operand:HI 0 "s_operand" "Q")
813 (match_operand:HI 1 "immediate_operand" "K")))]
814 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
816 [(set_attr "op_type" "SIL")])
818 (define_insn "*cmpdi_ccs_signhi_rl"
819 [(set (reg CC_REGNUM)
820 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT,b"))
821 (match_operand:GPR 0 "register_operand" "d,d")))]
822 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
826 [(set_attr "op_type" "RXY,RIL")
827 (set_attr "type" "*,larl")])
829 ; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
830 (define_insn "*cmp<mode>_ccs"
831 [(set (reg CC_REGNUM)
832 (compare (match_operand:GPR 0 "nonimmediate_operand"
834 (match_operand:GPR 1 "general_operand"
836 "s390_match_ccmode(insn, CCSmode)"
845 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
846 (set_attr "cpu_facility" "*,*,z10,extimm,*,*,z10")
847 (set_attr "type" "*,*,*,*,*,*,larl")
848 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
851 ; Compare (unsigned) instructions
853 (define_insn "*cmpsi_ccu_zerohi_rlsi"
854 [(set (reg CC_REGNUM)
855 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
856 "larl_operand" "X")))
857 (match_operand:SI 0 "register_operand" "d")))]
858 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
860 [(set_attr "op_type" "RIL")
861 (set_attr "type" "larl")
862 (set_attr "z10prop" "z10_super")])
865 (define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
866 [(set (reg CC_REGNUM)
867 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
868 "larl_operand" "X")))
869 (match_operand:GPR 0 "register_operand" "d")))]
870 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
872 [(set_attr "op_type" "RIL")
873 (set_attr "type" "larl")
874 (set_attr "z10prop" "z10_super")])
876 (define_insn "*cmpdi_ccu_zero"
877 [(set (reg CC_REGNUM)
878 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
880 (match_operand:DI 0 "register_operand" "d, d,d")))]
881 "s390_match_ccmode (insn, CCURmode) && TARGET_64BIT"
886 [(set_attr "op_type" "RRE,RXY,RIL")
887 (set_attr "cpu_facility" "*,*,z10")
888 (set_attr "type" "*,*,larl")
889 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
891 (define_insn "*cmpdi_ccu"
892 [(set (reg CC_REGNUM)
893 (compare (match_operand:DI 0 "nonimmediate_operand"
895 (match_operand:DI 1 "general_operand"
896 "d,Op,b,D,RT,BQ,Q")))]
897 "s390_match_ccmode (insn, CCUmode) && TARGET_64BIT"
906 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
907 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
908 (set_attr "type" "*,*,larl,*,*,*,*")
909 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
911 (define_insn "*cmpsi_ccu"
912 [(set (reg CC_REGNUM)
913 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
914 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
915 "s390_match_ccmode (insn, CCUmode)"
925 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
926 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*,*")
927 (set_attr "type" "*,*,larl,*,*,*,*,*")
928 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
930 (define_insn "*cmphi_ccu"
931 [(set (reg CC_REGNUM)
932 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
933 (match_operand:HI 1 "general_operand" "Q,S,D,BQ,Q")))]
934 "s390_match_ccmode (insn, CCUmode)
935 && !register_operand (operands[1], HImode)"
942 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
943 (set_attr "cpu_facility" "*,*,z10,*,*")
944 (set_attr "z10prop" "*,*,z10_super,*,*")])
946 (define_insn "*cmpqi_ccu"
947 [(set (reg CC_REGNUM)
948 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
949 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
950 "s390_match_ccmode (insn, CCUmode)
951 && !register_operand (operands[1], QImode)"
959 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
960 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
963 ; Block compare (CLC) instruction patterns.
966 [(set (reg CC_REGNUM)
967 (compare (match_operand:BLK 0 "memory_operand" "Q")
968 (match_operand:BLK 1 "memory_operand" "Q")))
969 (use (match_operand 2 "const_int_operand" "n"))]
970 "s390_match_ccmode (insn, CCUmode)
971 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
972 "clc\t%O0(%2,%R0),%S1"
973 [(set_attr "op_type" "SS")])
976 [(set (reg CC_REGNUM)
977 (compare (match_operand 0 "memory_operand" "")
978 (match_operand 1 "memory_operand" "")))]
980 && s390_match_ccmode (insn, CCUmode)
981 && GET_MODE (operands[0]) == GET_MODE (operands[1])
982 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
984 [(set (match_dup 0) (match_dup 1))
985 (use (match_dup 2))])]
987 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
988 operands[0] = adjust_address (operands[0], BLKmode, 0);
989 operands[1] = adjust_address (operands[1], BLKmode, 0);
991 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
992 operands[0], operands[1]);
993 operands[0] = SET_DEST (PATTERN (curr_insn));
997 ; (TF|DF|SF|TD|DD|SD) instructions
999 ; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
1000 (define_insn "*cmp<mode>_ccs_0"
1001 [(set (reg CC_REGNUM)
1002 (compare (match_operand:FP 0 "register_operand" "f")
1003 (match_operand:FP 1 "const0_operand" "")))]
1004 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1005 "lt<xde><bt>r\t%0,%0"
1006 [(set_attr "op_type" "RRE")
1007 (set_attr "type" "fsimp<mode>")])
1009 ; cxtr, cxbr, cdbr, cebr, cdb, ceb, cxbtr, cdbtr
1010 (define_insn "*cmp<mode>_ccs"
1011 [(set (reg CC_REGNUM)
1012 (compare (match_operand:FP 0 "register_operand" "f,f")
1013 (match_operand:FP 1 "general_operand" "f,<Rf>")))]
1014 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1018 [(set_attr "op_type" "RRE,RXE")
1019 (set_attr "type" "fsimp<mode>")])
1022 ; Compare and Branch instructions
1024 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1025 ; The following instructions do a complementary access of their second
1026 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1027 (define_insn "*cmp_and_br_signed_<mode>"
1029 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1030 [(match_operand:GPR 1 "register_operand" "d,d")
1031 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1032 (label_ref (match_operand 3 "" ""))
1034 (clobber (reg:CC CC_REGNUM))]
1037 if (get_attr_length (insn) == 6)
1038 return which_alternative ?
1039 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1041 return which_alternative ?
1042 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1044 [(set_attr "op_type" "RIE")
1045 (set_attr "type" "branch")
1046 (set_attr "z10prop" "z10_cobra,z10_super")
1047 (set (attr "length")
1048 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1049 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1050 ; 10 byte for cgr/jg
1052 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1053 ; The following instructions do a complementary access of their second
1054 ; operand (z10 only): clrj, clgrj, clr, clgr
1055 (define_insn "*cmp_and_br_unsigned_<mode>"
1057 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1058 [(match_operand:GPR 1 "register_operand" "d,d")
1059 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1060 (label_ref (match_operand 3 "" ""))
1062 (clobber (reg:CC CC_REGNUM))]
1065 if (get_attr_length (insn) == 6)
1066 return which_alternative ?
1067 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1069 return which_alternative ?
1070 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1072 [(set_attr "op_type" "RIE")
1073 (set_attr "type" "branch")
1074 (set_attr "z10prop" "z10_cobra,z10_super")
1075 (set (attr "length")
1076 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1077 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1078 ; 10 byte for clgr/jg
1081 ;;- Move instructions.
1085 ; movti instruction pattern(s).
1088 (define_insn "movti"
1089 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,QS,d,o")
1090 (match_operand:TI 1 "general_operand" "QS,d,dPRT,d"))]
1097 [(set_attr "op_type" "RSY,RSY,*,*")
1098 (set_attr "type" "lm,stm,*,*")])
1101 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1102 (match_operand:TI 1 "general_operand" ""))]
1103 "TARGET_64BIT && reload_completed
1104 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
1105 [(set (match_dup 2) (match_dup 4))
1106 (set (match_dup 3) (match_dup 5))]
1108 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1109 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1110 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1111 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1115 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1116 (match_operand:TI 1 "general_operand" ""))]
1117 "TARGET_64BIT && reload_completed
1118 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1119 [(set (match_dup 2) (match_dup 4))
1120 (set (match_dup 3) (match_dup 5))]
1122 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1123 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1124 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1125 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1129 [(set (match_operand:TI 0 "register_operand" "")
1130 (match_operand:TI 1 "memory_operand" ""))]
1131 "TARGET_64BIT && reload_completed
1132 && !s_operand (operands[1], VOIDmode)"
1133 [(set (match_dup 0) (match_dup 1))]
1135 rtx addr = operand_subword (operands[0], 1, 0, TImode);
1136 s390_load_address (addr, XEXP (operands[1], 0));
1137 operands[1] = replace_equiv_address (operands[1], addr);
1142 ; Patterns used for secondary reloads
1145 ; z10 provides move instructions accepting larl memory operands.
1146 ; Unfortunately there is no such variant for QI, TI and FP mode moves.
1147 ; These patterns are also used for unaligned SI and DI accesses.
1149 (define_expand "reload<INTALL:mode><P:mode>_tomem_z10"
1150 [(parallel [(match_operand:INTALL 0 "memory_operand" "")
1151 (match_operand:INTALL 1 "register_operand" "=d")
1152 (match_operand:P 2 "register_operand" "=&a")])]
1155 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1159 (define_expand "reload<INTALL:mode><P:mode>_toreg_z10"
1160 [(parallel [(match_operand:INTALL 0 "register_operand" "=d")
1161 (match_operand:INTALL 1 "memory_operand" "")
1162 (match_operand:P 2 "register_operand" "=a")])]
1165 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1169 (define_expand "reload<FPALL:mode><P:mode>_tomem_z10"
1170 [(parallel [(match_operand:FPALL 0 "memory_operand" "")
1171 (match_operand:FPALL 1 "register_operand" "=d")
1172 (match_operand:P 2 "register_operand" "=&a")])]
1175 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1179 (define_expand "reload<FPALL:mode><P:mode>_toreg_z10"
1180 [(parallel [(match_operand:FPALL 0 "register_operand" "=d")
1181 (match_operand:FPALL 1 "memory_operand" "")
1182 (match_operand:P 2 "register_operand" "=a")])]
1185 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1189 (define_expand "reload<P:mode>_larl_odd_addend_z10"
1190 [(parallel [(match_operand:P 0 "register_operand" "=d")
1191 (match_operand:P 1 "larl_operand" "")
1192 (match_operand:P 2 "register_operand" "=a")])]
1195 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1199 ; Handles loading a PLUS (load address) expression
1201 (define_expand "reload<mode>_plus"
1202 [(parallel [(match_operand:P 0 "register_operand" "=a")
1203 (match_operand:P 1 "s390_plus_operand" "")
1204 (match_operand:P 2 "register_operand" "=&a")])]
1207 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1211 ; Handles assessing a non-offsetable memory address
1213 (define_expand "reload<mode>_nonoffmem_in"
1214 [(parallel [(match_operand 0 "register_operand" "")
1215 (match_operand 1 "" "")
1216 (match_operand:P 2 "register_operand" "=&a")])]
1219 gcc_assert (MEM_P (operands[1]));
1220 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1221 operands[1] = replace_equiv_address (operands[1], operands[2]);
1222 emit_move_insn (operands[0], operands[1]);
1226 (define_expand "reload<mode>_nonoffmem_out"
1227 [(parallel [(match_operand 0 "" "")
1228 (match_operand 1 "register_operand" "")
1229 (match_operand:P 2 "register_operand" "=&a")])]
1232 gcc_assert (MEM_P (operands[0]));
1233 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1234 operands[0] = replace_equiv_address (operands[0], operands[2]);
1235 emit_move_insn (operands[0], operands[1]);
1239 (define_expand "reload<mode>_PIC_addr"
1240 [(parallel [(match_operand 0 "register_operand" "=d")
1241 (match_operand 1 "larl_operand" "")
1242 (match_operand:P 2 "register_operand" "=a")])]
1245 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1246 emit_move_insn (operands[0], new_rtx);
1250 ; movdi instruction pattern(s).
1253 (define_expand "movdi"
1254 [(set (match_operand:DI 0 "general_operand" "")
1255 (match_operand:DI 1 "general_operand" ""))]
1258 /* Handle symbolic constants. */
1260 && (SYMBOLIC_CONST (operands[1])
1261 || (GET_CODE (operands[1]) == PLUS
1262 && XEXP (operands[1], 0) == pic_offset_table_rtx
1263 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
1264 emit_symbolic_move (operands);
1267 (define_insn "*movdi_larl"
1268 [(set (match_operand:DI 0 "register_operand" "=d")
1269 (match_operand:DI 1 "larl_operand" "X"))]
1271 && !FP_REG_P (operands[0])"
1273 [(set_attr "op_type" "RIL")
1274 (set_attr "type" "larl")
1275 (set_attr "z10prop" "z10_super_A1")])
1277 (define_insn "*movdi_64"
1278 [(set (match_operand:DI 0 "nonimmediate_operand"
1279 "=d,d,d,d,d,d,d,d,f,d,d,d,d,d,
1280 RT,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t")
1281 (match_operand:DI 1 "general_operand"
1282 "K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,RT,
1283 d,*f,R,T,*f,*f,d,K,t,d,t,Q"))]
1312 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
1313 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS")
1314 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
1315 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,
1317 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
1318 z10,*,*,*,*,*,longdisp,*,longdisp,
1320 (set_attr "z10prop" "z10_fwd_A1,
1349 [(set (match_operand:DI 0 "register_operand" "")
1350 (match_operand:DI 1 "register_operand" ""))]
1351 "TARGET_64BIT && ACCESS_REG_P (operands[1])"
1352 [(set (match_dup 2) (match_dup 3))
1353 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1354 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1355 "operands[2] = gen_lowpart (SImode, operands[0]);
1356 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1359 [(set (match_operand:DI 0 "register_operand" "")
1360 (match_operand:DI 1 "register_operand" ""))]
1361 "TARGET_64BIT && ACCESS_REG_P (operands[0])
1362 && dead_or_set_p (insn, operands[1])"
1363 [(set (match_dup 3) (match_dup 2))
1364 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1365 (set (match_dup 4) (match_dup 2))]
1366 "operands[2] = gen_lowpart (SImode, operands[1]);
1367 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1370 [(set (match_operand:DI 0 "register_operand" "")
1371 (match_operand:DI 1 "register_operand" ""))]
1372 "TARGET_64BIT && ACCESS_REG_P (operands[0])
1373 && !dead_or_set_p (insn, operands[1])"
1374 [(set (match_dup 3) (match_dup 2))
1375 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1376 (set (match_dup 4) (match_dup 2))
1377 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1378 "operands[2] = gen_lowpart (SImode, operands[1]);
1379 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1381 (define_insn "*movdi_31"
1382 [(set (match_operand:DI 0 "nonimmediate_operand"
1383 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!R,!T,d")
1384 (match_operand:DI 1 "general_operand"
1385 " Q,S,d,d,dPRT,d, *f, R, T,*f,*f,b"))]
1400 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1401 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
1402 (set_attr "cpu_facility" "*,*,*,*,*,*,*,*,*,*,*,z10")])
1404 ; For a load from a symbol ref we can use one of the target registers
1405 ; together with larl to load the address.
1407 [(set (match_operand:DI 0 "register_operand" "")
1408 (match_operand:DI 1 "memory_operand" ""))]
1409 "!TARGET_64BIT && reload_completed && TARGET_Z10
1410 && larl_operand (XEXP (operands[1], 0), SImode)"
1411 [(set (match_dup 2) (match_dup 3))
1412 (set (match_dup 0) (match_dup 1))]
1414 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1415 operands[3] = XEXP (operands[1], 0);
1416 operands[1] = replace_equiv_address (operands[1], operands[2]);
1420 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1421 (match_operand:DI 1 "general_operand" ""))]
1422 "!TARGET_64BIT && reload_completed
1423 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
1424 [(set (match_dup 2) (match_dup 4))
1425 (set (match_dup 3) (match_dup 5))]
1427 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1428 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1429 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1430 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1434 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1435 (match_operand:DI 1 "general_operand" ""))]
1436 "!TARGET_64BIT && reload_completed
1437 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1438 [(set (match_dup 2) (match_dup 4))
1439 (set (match_dup 3) (match_dup 5))]
1441 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1442 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1443 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1444 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1448 [(set (match_operand:DI 0 "register_operand" "")
1449 (match_operand:DI 1 "memory_operand" ""))]
1450 "!TARGET_64BIT && reload_completed
1451 && !FP_REG_P (operands[0])
1452 && !s_operand (operands[1], VOIDmode)"
1453 [(set (match_dup 0) (match_dup 1))]
1455 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1456 s390_load_address (addr, XEXP (operands[1], 0));
1457 operands[1] = replace_equiv_address (operands[1], addr);
1461 [(set (match_operand:DI 0 "register_operand" "")
1462 (mem:DI (match_operand 1 "address_operand" "")))]
1464 && !FP_REG_P (operands[0])
1465 && GET_CODE (operands[1]) == SYMBOL_REF
1466 && CONSTANT_POOL_ADDRESS_P (operands[1])
1467 && get_pool_mode (operands[1]) == DImode
1468 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1469 [(set (match_dup 0) (match_dup 2))]
1470 "operands[2] = get_pool_constant (operands[1]);")
1472 (define_insn "*la_64"
1473 [(set (match_operand:DI 0 "register_operand" "=d,d")
1474 (match_operand:QI 1 "address_operand" "U,W"))]
1479 [(set_attr "op_type" "RX,RXY")
1480 (set_attr "type" "la")
1481 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1485 [(set (match_operand:DI 0 "register_operand" "")
1486 (match_operand:QI 1 "address_operand" ""))
1487 (clobber (reg:CC CC_REGNUM))])]
1489 && preferred_la_operand_p (operands[1], const0_rtx)"
1490 [(set (match_dup 0) (match_dup 1))]
1494 [(set (match_operand:DI 0 "register_operand" "")
1495 (match_operand:DI 1 "register_operand" ""))
1498 (plus:DI (match_dup 0)
1499 (match_operand:DI 2 "nonmemory_operand" "")))
1500 (clobber (reg:CC CC_REGNUM))])]
1502 && !reg_overlap_mentioned_p (operands[0], operands[2])
1503 && preferred_la_operand_p (operands[1], operands[2])"
1504 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1508 ; movsi instruction pattern(s).
1511 (define_expand "movsi"
1512 [(set (match_operand:SI 0 "general_operand" "")
1513 (match_operand:SI 1 "general_operand" ""))]
1516 /* Handle symbolic constants. */
1518 && (SYMBOLIC_CONST (operands[1])
1519 || (GET_CODE (operands[1]) == PLUS
1520 && XEXP (operands[1], 0) == pic_offset_table_rtx
1521 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
1522 emit_symbolic_move (operands);
1525 (define_insn "*movsi_larl"
1526 [(set (match_operand:SI 0 "register_operand" "=d")
1527 (match_operand:SI 1 "larl_operand" "X"))]
1528 "!TARGET_64BIT && TARGET_CPU_ZARCH
1529 && !FP_REG_P (operands[0])"
1531 [(set_attr "op_type" "RIL")
1532 (set_attr "type" "larl")
1533 (set_attr "z10prop" "z10_fwd_A1")])
1535 (define_insn "*movsi_zarch"
1536 [(set (match_operand:SI 0 "nonimmediate_operand"
1537 "=d,d,d,d,d,d,d,d,d,R,T,!*f,!*f,!*f,!R,!T,d,t,Q,b,Q,t")
1538 (match_operand:SI 1 "general_operand"
1539 "K,N0HS0,N1HS0,Os,L,b,d,R,T,d,d,*f,R,T,*f,*f,t,d,t,d,K,Q"))]
1564 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
1565 RR,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS")
1566 (set_attr "type" "*,
1588 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
1589 *,*,longdisp,*,longdisp,*,*,*,z10,z10,*")
1590 (set_attr "z10prop" "z10_fwd_A1,
1613 (define_insn "*movsi_esa"
1614 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!R,d,t,Q,t")
1615 (match_operand:SI 1 "general_operand" "K,d,R,d,*f,R,*f,t,d,t,Q"))]
1629 [(set_attr "op_type" "RI,RR,RX,RX,RR,RX,RX,RRE,RRE,RS,RS")
1630 (set_attr "type" "*,lr,load,store,floadsf,floadsf,fstoresf,*,*,*,*")
1631 (set_attr "z10prop" "z10_fwd_A1,
1645 [(set (match_operand:SI 0 "register_operand" "")
1646 (mem:SI (match_operand 1 "address_operand" "")))]
1647 "!FP_REG_P (operands[0])
1648 && GET_CODE (operands[1]) == SYMBOL_REF
1649 && CONSTANT_POOL_ADDRESS_P (operands[1])
1650 && get_pool_mode (operands[1]) == SImode
1651 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1652 [(set (match_dup 0) (match_dup 2))]
1653 "operands[2] = get_pool_constant (operands[1]);")
1655 (define_insn "*la_31"
1656 [(set (match_operand:SI 0 "register_operand" "=d,d")
1657 (match_operand:QI 1 "address_operand" "U,W"))]
1658 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
1662 [(set_attr "op_type" "RX,RXY")
1663 (set_attr "type" "la")
1664 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1668 [(set (match_operand:SI 0 "register_operand" "")
1669 (match_operand:QI 1 "address_operand" ""))
1670 (clobber (reg:CC CC_REGNUM))])]
1672 && preferred_la_operand_p (operands[1], const0_rtx)"
1673 [(set (match_dup 0) (match_dup 1))]
1677 [(set (match_operand:SI 0 "register_operand" "")
1678 (match_operand:SI 1 "register_operand" ""))
1681 (plus:SI (match_dup 0)
1682 (match_operand:SI 2 "nonmemory_operand" "")))
1683 (clobber (reg:CC CC_REGNUM))])]
1685 && !reg_overlap_mentioned_p (operands[0], operands[2])
1686 && preferred_la_operand_p (operands[1], operands[2])"
1687 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
1690 (define_insn "*la_31_and"
1691 [(set (match_operand:SI 0 "register_operand" "=d,d")
1692 (and:SI (match_operand:QI 1 "address_operand" "U,W")
1693 (const_int 2147483647)))]
1698 [(set_attr "op_type" "RX,RXY")
1699 (set_attr "type" "la")
1700 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1702 (define_insn_and_split "*la_31_and_cc"
1703 [(set (match_operand:SI 0 "register_operand" "=d")
1704 (and:SI (match_operand:QI 1 "address_operand" "p")
1705 (const_int 2147483647)))
1706 (clobber (reg:CC CC_REGNUM))]
1709 "&& reload_completed"
1711 (and:SI (match_dup 1) (const_int 2147483647)))]
1713 [(set_attr "op_type" "RX")
1714 (set_attr "type" "la")])
1716 (define_insn "force_la_31"
1717 [(set (match_operand:SI 0 "register_operand" "=d,d")
1718 (match_operand:QI 1 "address_operand" "U,W"))
1719 (use (const_int 0))]
1724 [(set_attr "op_type" "RX")
1725 (set_attr "type" "la")
1726 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1729 ; movhi instruction pattern(s).
1732 (define_expand "movhi"
1733 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1734 (match_operand:HI 1 "general_operand" ""))]
1737 /* Make it explicit that loading a register from memory
1738 always sign-extends (at least) to SImode. */
1739 if (optimize && can_create_pseudo_p ()
1740 && register_operand (operands[0], VOIDmode)
1741 && GET_CODE (operands[1]) == MEM)
1743 rtx tmp = gen_reg_rtx (SImode);
1744 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
1745 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1746 operands[1] = gen_lowpart (HImode, tmp);
1750 (define_insn "*movhi"
1751 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q")
1752 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K"))]
1764 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL")
1765 (set_attr "type" "lr,*,*,*,larl,store,store,store,*")
1766 (set_attr "cpu_facility" "*,*,*,*,z10,*,*,z10,z10")
1767 (set_attr "z10prop" "z10_fr_E1,
1778 [(set (match_operand:HI 0 "register_operand" "")
1779 (mem:HI (match_operand 1 "address_operand" "")))]
1780 "GET_CODE (operands[1]) == SYMBOL_REF
1781 && CONSTANT_POOL_ADDRESS_P (operands[1])
1782 && get_pool_mode (operands[1]) == HImode
1783 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1784 [(set (match_dup 0) (match_dup 2))]
1785 "operands[2] = get_pool_constant (operands[1]);")
1788 ; movqi instruction pattern(s).
1791 (define_expand "movqi"
1792 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1793 (match_operand:QI 1 "general_operand" ""))]
1796 /* On z/Architecture, zero-extending from memory to register
1797 is just as fast as a QImode load. */
1798 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
1799 && register_operand (operands[0], VOIDmode)
1800 && GET_CODE (operands[1]) == MEM)
1802 rtx tmp = gen_reg_rtx (word_mode);
1803 rtx ext = gen_rtx_ZERO_EXTEND (word_mode, operands[1]);
1804 emit_insn (gen_rtx_SET (VOIDmode, tmp, ext));
1805 operands[1] = gen_lowpart (QImode, tmp);
1809 (define_insn "*movqi"
1810 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S")
1811 (match_operand:QI 1 "general_operand" "d,n,R,T,d,d,n,n"))]
1822 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY")
1823 (set_attr "type" "lr,*,*,*,store,store,store,store")
1824 (set_attr "z10prop" "z10_fr_E1,
1834 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1835 (mem:QI (match_operand 1 "address_operand" "")))]
1836 "GET_CODE (operands[1]) == SYMBOL_REF
1837 && CONSTANT_POOL_ADDRESS_P (operands[1])
1838 && get_pool_mode (operands[1]) == QImode
1839 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
1840 [(set (match_dup 0) (match_dup 2))]
1841 "operands[2] = get_pool_constant (operands[1]);")
1844 ; movstrictqi instruction pattern(s).
1847 (define_insn "*movstrictqi"
1848 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
1849 (match_operand:QI 1 "memory_operand" "R,T"))]
1854 [(set_attr "op_type" "RX,RXY")
1855 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1858 ; movstricthi instruction pattern(s).
1861 (define_insn "*movstricthi"
1862 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
1863 (match_operand:HI 1 "memory_operand" "Q,S"))
1864 (clobber (reg:CC CC_REGNUM))]
1869 [(set_attr "op_type" "RS,RSY")
1870 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1873 ; movstrictsi instruction pattern(s).
1876 (define_insn "movstrictsi"
1877 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
1878 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
1885 [(set_attr "op_type" "RR,RX,RXY,RRE")
1886 (set_attr "type" "lr,load,load,*")
1887 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
1890 ; mov(tf|td) instruction pattern(s).
1893 (define_expand "mov<mode>"
1894 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1895 (match_operand:TD_TF 1 "general_operand" ""))]
1899 (define_insn "*mov<mode>_64"
1900 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o, d,QS, d,o")
1901 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,QS, d,dRT,d"))]
1912 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
1913 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")])
1915 (define_insn "*mov<mode>_31"
1916 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
1917 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
1924 [(set_attr "op_type" "RRE,RRE,*,*")
1925 (set_attr "type" "fsimptf,fsimptf,*,*")])
1927 ; TFmode in GPRs splitters
1930 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1931 (match_operand:TD_TF 1 "general_operand" ""))]
1932 "TARGET_64BIT && reload_completed
1933 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
1934 [(set (match_dup 2) (match_dup 4))
1935 (set (match_dup 3) (match_dup 5))]
1937 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
1938 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
1939 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
1940 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
1944 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
1945 (match_operand:TD_TF 1 "general_operand" ""))]
1946 "TARGET_64BIT && reload_completed
1947 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
1948 [(set (match_dup 2) (match_dup 4))
1949 (set (match_dup 3) (match_dup 5))]
1951 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
1952 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
1953 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
1954 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
1958 [(set (match_operand:TD_TF 0 "register_operand" "")
1959 (match_operand:TD_TF 1 "memory_operand" ""))]
1960 "TARGET_64BIT && reload_completed
1961 && !FP_REG_P (operands[0])
1962 && !s_operand (operands[1], VOIDmode)"
1963 [(set (match_dup 0) (match_dup 1))]
1965 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
1966 s390_load_address (addr, XEXP (operands[1], 0));
1967 operands[1] = replace_equiv_address (operands[1], addr);
1970 ; TFmode in BFPs splitters
1973 [(set (match_operand:TD_TF 0 "register_operand" "")
1974 (match_operand:TD_TF 1 "memory_operand" ""))]
1975 "reload_completed && offsettable_memref_p (operands[1])
1976 && FP_REG_P (operands[0])"
1977 [(set (match_dup 2) (match_dup 4))
1978 (set (match_dup 3) (match_dup 5))]
1980 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
1982 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
1984 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
1985 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
1989 [(set (match_operand:TD_TF 0 "memory_operand" "")
1990 (match_operand:TD_TF 1 "register_operand" ""))]
1991 "reload_completed && offsettable_memref_p (operands[0])
1992 && FP_REG_P (operands[1])"
1993 [(set (match_dup 2) (match_dup 4))
1994 (set (match_dup 3) (match_dup 5))]
1996 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
1997 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
1998 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2000 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2005 ; mov(df|dd) instruction pattern(s).
2008 (define_expand "mov<mode>"
2009 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2010 (match_operand:DD_DF 1 "general_operand" ""))]
2014 (define_insn "*mov<mode>_64dfp"
2015 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2016 "=f,f,f,d,f,f,R,T,d, d,RT")
2017 (match_operand:DD_DF 1 "general_operand"
2018 " G,f,d,f,R,T,f,f,d,RT, d"))]
2019 "TARGET_64BIT && TARGET_DFP"
2032 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RRE,RXY,RXY")
2033 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
2034 fstoredf,fstoredf,lr,load,store")
2035 (set_attr "z10prop" "*,
2048 (define_insn "*mov<mode>_64"
2049 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d, d,RT")
2050 (match_operand:DD_DF 1 "general_operand" "G,f,R,T,f,f,d,RT, d"))]
2062 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RRE,RXY,RXY")
2063 (set_attr "type" "fsimp<mode>,fload<mode>,fload<mode>,fload<mode>,
2064 fstore<mode>,fstore<mode>,lr,load,store")
2065 (set_attr "z10prop" "*,
2075 (define_insn "*mov<mode>_31"
2076 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2077 "=f,f,f,f,R,T,d,d,Q,S, d,o")
2078 (match_operand:DD_DF 1 "general_operand"
2079 " G,f,R,T,f,f,Q,S,d,d,dPRT,d"))]
2094 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2095 (set_attr "type" "fsimp<mode>,fload<mode>,fload<mode>,fload<mode>,
2096 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")])
2099 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2100 (match_operand:DD_DF 1 "general_operand" ""))]
2101 "!TARGET_64BIT && reload_completed
2102 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2103 [(set (match_dup 2) (match_dup 4))
2104 (set (match_dup 3) (match_dup 5))]
2106 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2107 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2108 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2109 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2113 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2114 (match_operand:DD_DF 1 "general_operand" ""))]
2115 "!TARGET_64BIT && reload_completed
2116 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2117 [(set (match_dup 2) (match_dup 4))
2118 (set (match_dup 3) (match_dup 5))]
2120 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2121 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2122 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2123 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2127 [(set (match_operand:DD_DF 0 "register_operand" "")
2128 (match_operand:DD_DF 1 "memory_operand" ""))]
2129 "!TARGET_64BIT && reload_completed
2130 && !FP_REG_P (operands[0])
2131 && !s_operand (operands[1], VOIDmode)"
2132 [(set (match_dup 0) (match_dup 1))]
2134 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2135 s390_load_address (addr, XEXP (operands[1], 0));
2136 operands[1] = replace_equiv_address (operands[1], addr);
2140 ; mov(sf|sd) instruction pattern(s).
2143 (define_insn "mov<mode>"
2144 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
2145 "=f,f,f,f,R,T,d,d,d,R,T")
2146 (match_operand:SD_SF 1 "general_operand"
2147 " G,f,R,T,f,f,d,R,T,d,d"))]
2161 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RR,RX,RXY,RX,RXY")
2162 (set_attr "type" "fsimp<mode>,fload<mode>,fload<mode>,fload<mode>,
2163 fstore<mode>,fstore<mode>,lr,load,load,store,store")
2164 (set_attr "z10prop" "*,
2177 ; movcc instruction pattern
2180 (define_insn "movcc"
2181 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
2182 (match_operand:CC 1 "nonimmediate_operand" "d,d,c,R,T,d,d"))]
2192 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
2193 (set_attr "type" "lr,*,*,store,store,load,load")
2194 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_rec,z10_rec,z10_fwd_A3,z10_fwd_A3")])
2197 ; Block move (MVC) patterns.
2201 [(set (match_operand:BLK 0 "memory_operand" "=Q")
2202 (match_operand:BLK 1 "memory_operand" "Q"))
2203 (use (match_operand 2 "const_int_operand" "n"))]
2204 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
2205 "mvc\t%O0(%2,%R0),%S1"
2206 [(set_attr "op_type" "SS")])
2210 [(set (match_operand:BLK 0 "memory_operand" "")
2211 (match_operand:BLK 1 "memory_operand" ""))
2212 (use (match_operand 2 "const_int_operand" ""))])
2214 [(set (match_operand:BLK 3 "memory_operand" "")
2215 (match_operand:BLK 4 "memory_operand" ""))
2216 (use (match_operand 5 "const_int_operand" ""))])]
2217 "s390_offset_p (operands[0], operands[3], operands[2])
2218 && s390_offset_p (operands[1], operands[4], operands[2])
2219 && !s390_overlap_p (operands[0], operands[1],
2220 INTVAL (operands[2]) + INTVAL (operands[5]))
2221 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2223 [(set (match_dup 6) (match_dup 7))
2224 (use (match_dup 8))])]
2225 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2226 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2227 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2231 ; load_multiple pattern(s).
2233 ; ??? Due to reload problems with replacing registers inside match_parallel
2234 ; we currently support load_multiple/store_multiple only after reload.
2237 (define_expand "load_multiple"
2238 [(match_par_dup 3 [(set (match_operand 0 "" "")
2239 (match_operand 1 "" ""))
2240 (use (match_operand 2 "" ""))])]
2243 enum machine_mode mode;
2249 /* Support only loading a constant number of fixed-point registers from
2250 memory and only bother with this if more than two */
2251 if (GET_CODE (operands[2]) != CONST_INT
2252 || INTVAL (operands[2]) < 2
2253 || INTVAL (operands[2]) > 16
2254 || GET_CODE (operands[1]) != MEM
2255 || GET_CODE (operands[0]) != REG
2256 || REGNO (operands[0]) >= 16)
2259 count = INTVAL (operands[2]);
2260 regno = REGNO (operands[0]);
2261 mode = GET_MODE (operands[0]);
2262 if (mode != SImode && mode != word_mode)
2265 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2266 if (!can_create_pseudo_p ())
2268 if (GET_CODE (XEXP (operands[1], 0)) == REG)
2270 from = XEXP (operands[1], 0);
2273 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2274 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2275 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2277 from = XEXP (XEXP (operands[1], 0), 0);
2278 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2285 from = force_reg (Pmode, XEXP (operands[1], 0));
2289 for (i = 0; i < count; i++)
2290 XVECEXP (operands[3], 0, i)
2291 = gen_rtx_SET (VOIDmode, gen_rtx_REG (mode, regno + i),
2292 change_address (operands[1], mode,
2293 plus_constant (from, off + i * GET_MODE_SIZE (mode))));
2296 (define_insn "*load_multiple_di"
2297 [(match_parallel 0 "load_multiple_operation"
2298 [(set (match_operand:DI 1 "register_operand" "=r")
2299 (match_operand:DI 2 "s_operand" "QS"))])]
2300 "reload_completed && word_mode == DImode"
2302 int words = XVECLEN (operands[0], 0);
2303 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
2304 return "lmg\t%1,%0,%S2";
2306 [(set_attr "op_type" "RSY")
2307 (set_attr "type" "lm")])
2309 (define_insn "*load_multiple_si"
2310 [(match_parallel 0 "load_multiple_operation"
2311 [(set (match_operand:SI 1 "register_operand" "=r,r")
2312 (match_operand:SI 2 "s_operand" "Q,S"))])]
2315 int words = XVECLEN (operands[0], 0);
2316 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
2317 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
2319 [(set_attr "op_type" "RS,RSY")
2320 (set_attr "type" "lm")])
2323 ; store multiple pattern(s).
2326 (define_expand "store_multiple"
2327 [(match_par_dup 3 [(set (match_operand 0 "" "")
2328 (match_operand 1 "" ""))
2329 (use (match_operand 2 "" ""))])]
2332 enum machine_mode mode;
2338 /* Support only storing a constant number of fixed-point registers to
2339 memory and only bother with this if more than two. */
2340 if (GET_CODE (operands[2]) != CONST_INT
2341 || INTVAL (operands[2]) < 2
2342 || INTVAL (operands[2]) > 16
2343 || GET_CODE (operands[0]) != MEM
2344 || GET_CODE (operands[1]) != REG
2345 || REGNO (operands[1]) >= 16)
2348 count = INTVAL (operands[2]);
2349 regno = REGNO (operands[1]);
2350 mode = GET_MODE (operands[1]);
2351 if (mode != SImode && mode != word_mode)
2354 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2356 if (!can_create_pseudo_p ())
2358 if (GET_CODE (XEXP (operands[0], 0)) == REG)
2360 to = XEXP (operands[0], 0);
2363 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2364 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2365 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2367 to = XEXP (XEXP (operands[0], 0), 0);
2368 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2375 to = force_reg (Pmode, XEXP (operands[0], 0));
2379 for (i = 0; i < count; i++)
2380 XVECEXP (operands[3], 0, i)
2381 = gen_rtx_SET (VOIDmode,
2382 change_address (operands[0], mode,
2383 plus_constant (to, off + i * GET_MODE_SIZE (mode))),
2384 gen_rtx_REG (mode, regno + i));
2387 (define_insn "*store_multiple_di"
2388 [(match_parallel 0 "store_multiple_operation"
2389 [(set (match_operand:DI 1 "s_operand" "=QS")
2390 (match_operand:DI 2 "register_operand" "r"))])]
2391 "reload_completed && word_mode == DImode"
2393 int words = XVECLEN (operands[0], 0);
2394 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
2395 return "stmg\t%2,%0,%S1";
2397 [(set_attr "op_type" "RSY")
2398 (set_attr "type" "stm")])
2401 (define_insn "*store_multiple_si"
2402 [(match_parallel 0 "store_multiple_operation"
2403 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2404 (match_operand:SI 2 "register_operand" "r,r"))])]
2407 int words = XVECLEN (operands[0], 0);
2408 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
2409 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
2411 [(set_attr "op_type" "RS,RSY")
2412 (set_attr "type" "stm")])
2415 ;; String instructions.
2418 (define_insn "*execute_rl"
2419 [(match_parallel 0 ""
2420 [(unspec [(match_operand 1 "register_operand" "a")
2421 (match_operand 2 "" "")
2422 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2423 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2424 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2426 [(set_attr "op_type" "RIL")
2427 (set_attr "type" "cs")])
2429 (define_insn "*execute"
2430 [(match_parallel 0 ""
2431 [(unspec [(match_operand 1 "register_operand" "a")
2432 (match_operand:BLK 2 "memory_operand" "R")
2433 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2434 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2435 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2437 [(set_attr "op_type" "RX")
2438 (set_attr "type" "cs")])
2442 ; strlenM instruction pattern(s).
2445 (define_expand "strlen<mode>"
2446 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2449 (unspec:P [(const_int 0)
2450 (match_operand:BLK 1 "memory_operand" "")
2452 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
2453 (clobber (scratch:P))
2454 (clobber (reg:CC CC_REGNUM))])
2456 [(set (match_operand:P 0 "register_operand" "")
2457 (minus:P (match_dup 4) (match_dup 5)))
2458 (clobber (reg:CC CC_REGNUM))])]
2461 operands[4] = gen_reg_rtx (Pmode);
2462 operands[5] = gen_reg_rtx (Pmode);
2463 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2464 operands[1] = replace_equiv_address (operands[1], operands[5]);
2467 (define_insn "*strlen<mode>"
2468 [(set (match_operand:P 0 "register_operand" "=a")
2469 (unspec:P [(match_operand:P 2 "general_operand" "0")
2470 (mem:BLK (match_operand:P 3 "register_operand" "1"))
2472 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
2473 (clobber (match_scratch:P 1 "=a"))
2474 (clobber (reg:CC CC_REGNUM))]
2476 "srst\t%0,%1\;jo\t.-4"
2477 [(set_attr "length" "8")
2478 (set_attr "type" "vs")])
2481 ; cmpstrM instruction pattern(s).
2484 (define_expand "cmpstrsi"
2485 [(set (reg:SI 0) (const_int 0))
2487 [(clobber (match_operand 3 "" ""))
2488 (clobber (match_dup 4))
2489 (set (reg:CCU CC_REGNUM)
2490 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2491 (match_operand:BLK 2 "memory_operand" "")))
2494 [(set (match_operand:SI 0 "register_operand" "=d")
2495 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_CCU_TO_INT))
2496 (clobber (reg:CC CC_REGNUM))])]
2499 /* As the result of CMPINT is inverted compared to what we need,
2500 we have to swap the operands. */
2501 rtx op1 = operands[2];
2502 rtx op2 = operands[1];
2503 rtx addr1 = gen_reg_rtx (Pmode);
2504 rtx addr2 = gen_reg_rtx (Pmode);
2506 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2507 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2508 operands[1] = replace_equiv_address_nv (op1, addr1);
2509 operands[2] = replace_equiv_address_nv (op2, addr2);
2510 operands[3] = addr1;
2511 operands[4] = addr2;
2514 (define_insn "*cmpstr<mode>"
2515 [(clobber (match_operand:P 0 "register_operand" "=d"))
2516 (clobber (match_operand:P 1 "register_operand" "=d"))
2517 (set (reg:CCU CC_REGNUM)
2518 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
2519 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
2522 "clst\t%0,%1\;jo\t.-4"
2523 [(set_attr "length" "8")
2524 (set_attr "type" "vs")])
2527 ; movstr instruction pattern.
2530 (define_expand "movstr"
2531 [(set (reg:SI 0) (const_int 0))
2533 [(clobber (match_dup 3))
2534 (set (match_operand:BLK 1 "memory_operand" "")
2535 (match_operand:BLK 2 "memory_operand" ""))
2536 (set (match_operand 0 "register_operand" "")
2537 (unspec [(match_dup 1)
2539 (reg:SI 0)] UNSPEC_MVST))
2540 (clobber (reg:CC CC_REGNUM))])]
2543 rtx addr1 = gen_reg_rtx (Pmode);
2544 rtx addr2 = gen_reg_rtx (Pmode);
2546 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2547 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
2548 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2549 operands[2] = replace_equiv_address_nv (operands[2], addr2);
2550 operands[3] = addr2;
2553 (define_insn "*movstr"
2554 [(clobber (match_operand:P 2 "register_operand" "=d"))
2555 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
2556 (mem:BLK (match_operand:P 3 "register_operand" "2")))
2557 (set (match_operand:P 0 "register_operand" "=d")
2558 (unspec [(mem:BLK (match_dup 1))
2559 (mem:BLK (match_dup 3))
2560 (reg:SI 0)] UNSPEC_MVST))
2561 (clobber (reg:CC CC_REGNUM))]
2563 "mvst\t%1,%2\;jo\t.-4"
2564 [(set_attr "length" "8")
2565 (set_attr "type" "vs")])
2569 ; movmemM instruction pattern(s).
2572 (define_expand "movmem<mode>"
2573 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
2574 (match_operand:BLK 1 "memory_operand" "")) ; source
2575 (use (match_operand:GPR 2 "general_operand" "")) ; count
2576 (match_operand 3 "" "")]
2578 "s390_expand_movmem (operands[0], operands[1], operands[2]); DONE;")
2580 ; Move a block that is up to 256 bytes in length.
2581 ; The block length is taken as (operands[2] % 256) + 1.
2583 (define_expand "movmem_short"
2585 [(set (match_operand:BLK 0 "memory_operand" "")
2586 (match_operand:BLK 1 "memory_operand" ""))
2587 (use (match_operand 2 "nonmemory_operand" ""))
2588 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2589 (clobber (match_dup 3))])]
2591 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2593 (define_insn "*movmem_short"
2594 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2595 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
2596 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2597 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
2598 (clobber (match_scratch 4 "=X,X,X,&a"))]
2599 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2600 && GET_MODE (operands[4]) == Pmode"
2602 [(set_attr "type" "cs")
2603 (set_attr "cpu_facility" "*,*,z10,*")])
2606 [(set (match_operand:BLK 0 "memory_operand" "")
2607 (match_operand:BLK 1 "memory_operand" ""))
2608 (use (match_operand 2 "const_int_operand" ""))
2609 (use (match_operand 3 "immediate_operand" ""))
2610 (clobber (scratch))]
2613 [(set (match_dup 0) (match_dup 1))
2614 (use (match_dup 2))])]
2615 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2618 [(set (match_operand:BLK 0 "memory_operand" "")
2619 (match_operand:BLK 1 "memory_operand" ""))
2620 (use (match_operand 2 "register_operand" ""))
2621 (use (match_operand 3 "memory_operand" ""))
2622 (clobber (scratch))]
2625 [(unspec [(match_dup 2) (match_dup 3)
2626 (const_int 0)] UNSPEC_EXECUTE)
2627 (set (match_dup 0) (match_dup 1))
2628 (use (const_int 1))])]
2632 [(set (match_operand:BLK 0 "memory_operand" "")
2633 (match_operand:BLK 1 "memory_operand" ""))
2634 (use (match_operand 2 "register_operand" ""))
2635 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2636 (clobber (scratch))]
2637 "TARGET_Z10 && reload_completed"
2639 [(unspec [(match_dup 2) (const_int 0)
2640 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2641 (set (match_dup 0) (match_dup 1))
2642 (use (const_int 1))])]
2643 "operands[3] = gen_label_rtx ();")
2646 [(set (match_operand:BLK 0 "memory_operand" "")
2647 (match_operand:BLK 1 "memory_operand" ""))
2648 (use (match_operand 2 "register_operand" ""))
2649 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2650 (clobber (match_operand 3 "register_operand" ""))]
2651 "reload_completed && TARGET_CPU_ZARCH"
2652 [(set (match_dup 3) (label_ref (match_dup 4)))
2654 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
2655 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2656 (set (match_dup 0) (match_dup 1))
2657 (use (const_int 1))])]
2658 "operands[4] = gen_label_rtx ();")
2660 ; Move a block of arbitrary length.
2662 (define_expand "movmem_long"
2664 [(clobber (match_dup 2))
2665 (clobber (match_dup 3))
2666 (set (match_operand:BLK 0 "memory_operand" "")
2667 (match_operand:BLK 1 "memory_operand" ""))
2668 (use (match_operand 2 "general_operand" ""))
2670 (clobber (reg:CC CC_REGNUM))])]
2673 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2674 rtx reg0 = gen_reg_rtx (dword_mode);
2675 rtx reg1 = gen_reg_rtx (dword_mode);
2676 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2677 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
2678 rtx len0 = gen_lowpart (Pmode, reg0);
2679 rtx len1 = gen_lowpart (Pmode, reg1);
2681 emit_clobber (reg0);
2682 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2683 emit_move_insn (len0, operands[2]);
2685 emit_clobber (reg1);
2686 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
2687 emit_move_insn (len1, operands[2]);
2689 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2690 operands[1] = replace_equiv_address_nv (operands[1], addr1);
2695 (define_insn "*movmem_long"
2696 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2697 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
2698 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
2699 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
2702 (clobber (reg:CC CC_REGNUM))]
2704 "mvcle\t%0,%1,0\;jo\t.-4"
2705 [(set_attr "length" "8")
2706 (set_attr "type" "vs")])
2713 (define_expand "signbit<mode>2"
2714 [(set (reg:CCZ CC_REGNUM)
2715 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2718 (set (match_operand:SI 0 "register_operand" "=d")
2719 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2722 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
2725 (define_expand "isinf<mode>2"
2726 [(set (reg:CCZ CC_REGNUM)
2727 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
2730 (set (match_operand:SI 0 "register_operand" "=d")
2731 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CCZ_TO_INT))]
2734 operands[2] = GEN_INT (S390_TDC_INFINITY);
2737 ; This insn is used to generate all variants of the Test Data Class
2738 ; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
2739 ; is the register to be tested and the second one is the bit mask
2740 ; specifying the required test(s).
2742 (define_insn "*TDC_insn_<mode>"
2743 [(set (reg:CCZ CC_REGNUM)
2744 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
2745 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
2747 "t<_d>c<xde><bt>\t%0,%1"
2748 [(set_attr "op_type" "RXE")
2749 (set_attr "type" "fsimp<mode>")])
2751 (define_insn_and_split "*ccz_to_int"
2752 [(set (match_operand:SI 0 "register_operand" "=d")
2753 (unspec:SI [(match_operand:CCZ 1 "register_operand" "0")]
2754 UNSPEC_CCZ_TO_INT))]
2758 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
2762 ; setmemM instruction pattern(s).
2765 (define_expand "setmem<mode>"
2766 [(set (match_operand:BLK 0 "memory_operand" "")
2767 (match_operand:QI 2 "general_operand" ""))
2768 (use (match_operand:GPR 1 "general_operand" ""))
2769 (match_operand 3 "" "")]
2771 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
2773 ; Clear a block that is up to 256 bytes in length.
2774 ; The block length is taken as (operands[1] % 256) + 1.
2776 (define_expand "clrmem_short"
2778 [(set (match_operand:BLK 0 "memory_operand" "")
2780 (use (match_operand 1 "nonmemory_operand" ""))
2781 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2782 (clobber (match_dup 2))
2783 (clobber (reg:CC CC_REGNUM))])]
2785 "operands[2] = gen_rtx_SCRATCH (Pmode);")
2787 (define_insn "*clrmem_short"
2788 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
2790 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
2791 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
2792 (clobber (match_scratch 3 "=X,X,X,&a"))
2793 (clobber (reg:CC CC_REGNUM))]
2794 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)
2795 && GET_MODE (operands[3]) == Pmode"
2797 [(set_attr "type" "cs")
2798 (set_attr "cpu_facility" "*,*,z10,*")])
2801 [(set (match_operand:BLK 0 "memory_operand" "")
2803 (use (match_operand 1 "const_int_operand" ""))
2804 (use (match_operand 2 "immediate_operand" ""))
2806 (clobber (reg:CC CC_REGNUM))]
2809 [(set (match_dup 0) (const_int 0))
2811 (clobber (reg:CC CC_REGNUM))])]
2812 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
2815 [(set (match_operand:BLK 0 "memory_operand" "")
2817 (use (match_operand 1 "register_operand" ""))
2818 (use (match_operand 2 "memory_operand" ""))
2820 (clobber (reg:CC CC_REGNUM))]
2823 [(unspec [(match_dup 1) (match_dup 2)
2824 (const_int 0)] UNSPEC_EXECUTE)
2825 (set (match_dup 0) (const_int 0))
2827 (clobber (reg:CC CC_REGNUM))])]
2831 [(set (match_operand:BLK 0 "memory_operand" "")
2833 (use (match_operand 1 "register_operand" ""))
2834 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2836 (clobber (reg:CC CC_REGNUM))]
2837 "TARGET_Z10 && reload_completed"
2839 [(unspec [(match_dup 1) (const_int 0)
2840 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2841 (set (match_dup 0) (const_int 0))
2843 (clobber (reg:CC CC_REGNUM))])]
2844 "operands[3] = gen_label_rtx ();")
2847 [(set (match_operand:BLK 0 "memory_operand" "")
2849 (use (match_operand 1 "register_operand" ""))
2850 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2851 (clobber (match_operand 2 "register_operand" ""))
2852 (clobber (reg:CC CC_REGNUM))]
2853 "reload_completed && TARGET_CPU_ZARCH"
2854 [(set (match_dup 2) (label_ref (match_dup 3)))
2856 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
2857 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
2858 (set (match_dup 0) (const_int 0))
2860 (clobber (reg:CC CC_REGNUM))])]
2861 "operands[3] = gen_label_rtx ();")
2863 ; Initialize a block of arbitrary length with (operands[2] % 256).
2865 (define_expand "setmem_long"
2867 [(clobber (match_dup 1))
2868 (set (match_operand:BLK 0 "memory_operand" "")
2869 (match_operand 2 "shift_count_or_setmem_operand" ""))
2870 (use (match_operand 1 "general_operand" ""))
2872 (clobber (reg:CC CC_REGNUM))])]
2875 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
2876 rtx reg0 = gen_reg_rtx (dword_mode);
2877 rtx reg1 = gen_reg_rtx (dword_mode);
2878 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
2879 rtx len0 = gen_lowpart (Pmode, reg0);
2881 emit_clobber (reg0);
2882 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
2883 emit_move_insn (len0, operands[1]);
2885 emit_move_insn (reg1, const0_rtx);
2887 operands[0] = replace_equiv_address_nv (operands[0], addr0);
2892 (define_insn "*setmem_long"
2893 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2894 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
2895 (match_operand 2 "shift_count_or_setmem_operand" "Y"))
2897 (use (match_operand:<DBL> 1 "register_operand" "d"))
2898 (clobber (reg:CC CC_REGNUM))]
2900 "mvcle\t%0,%1,%Y2\;jo\t.-4"
2901 [(set_attr "length" "8")
2902 (set_attr "type" "vs")])
2904 (define_insn "*setmem_long_and"
2905 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
2906 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
2907 (and (match_operand 2 "shift_count_or_setmem_operand" "Y")
2908 (match_operand 4 "const_int_operand" "n")))
2910 (use (match_operand:<DBL> 1 "register_operand" "d"))
2911 (clobber (reg:CC CC_REGNUM))]
2912 "(INTVAL (operands[4]) & 255) == 255"
2913 "mvcle\t%0,%1,%Y2\;jo\t.-4"
2914 [(set_attr "length" "8")
2915 (set_attr "type" "vs")])
2917 ; cmpmemM instruction pattern(s).
2920 (define_expand "cmpmemsi"
2921 [(set (match_operand:SI 0 "register_operand" "")
2922 (compare:SI (match_operand:BLK 1 "memory_operand" "")
2923 (match_operand:BLK 2 "memory_operand" "") ) )
2924 (use (match_operand:SI 3 "general_operand" ""))
2925 (use (match_operand:SI 4 "" ""))]
2927 "s390_expand_cmpmem (operands[0], operands[1],
2928 operands[2], operands[3]); DONE;")
2930 ; Compare a block that is up to 256 bytes in length.
2931 ; The block length is taken as (operands[2] % 256) + 1.
2933 (define_expand "cmpmem_short"
2935 [(set (reg:CCU CC_REGNUM)
2936 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2937 (match_operand:BLK 1 "memory_operand" "")))
2938 (use (match_operand 2 "nonmemory_operand" ""))
2939 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2940 (clobber (match_dup 3))])]
2942 "operands[3] = gen_rtx_SCRATCH (Pmode);")
2944 (define_insn "*cmpmem_short"
2945 [(set (reg:CCU CC_REGNUM)
2946 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
2947 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
2948 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
2949 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
2950 (clobber (match_scratch 4 "=X,X,X,&a"))]
2951 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)
2952 && GET_MODE (operands[4]) == Pmode"
2954 [(set_attr "type" "cs")
2955 (set_attr "cpu_facility" "*,*,z10,*")])
2958 [(set (reg:CCU CC_REGNUM)
2959 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2960 (match_operand:BLK 1 "memory_operand" "")))
2961 (use (match_operand 2 "const_int_operand" ""))
2962 (use (match_operand 3 "immediate_operand" ""))
2963 (clobber (scratch))]
2966 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2967 (use (match_dup 2))])]
2968 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
2971 [(set (reg:CCU CC_REGNUM)
2972 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2973 (match_operand:BLK 1 "memory_operand" "")))
2974 (use (match_operand 2 "register_operand" ""))
2975 (use (match_operand 3 "memory_operand" ""))
2976 (clobber (scratch))]
2979 [(unspec [(match_dup 2) (match_dup 3)
2980 (const_int 0)] UNSPEC_EXECUTE)
2981 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2982 (use (const_int 1))])]
2986 [(set (reg:CCU CC_REGNUM)
2987 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
2988 (match_operand:BLK 1 "memory_operand" "")))
2989 (use (match_operand 2 "register_operand" ""))
2990 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
2991 (clobber (scratch))]
2992 "TARGET_Z10 && reload_completed"
2994 [(unspec [(match_dup 2) (const_int 0)
2995 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
2996 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
2997 (use (const_int 1))])]
2998 "operands[4] = gen_label_rtx ();")
3001 [(set (reg:CCU CC_REGNUM)
3002 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3003 (match_operand:BLK 1 "memory_operand" "")))
3004 (use (match_operand 2 "register_operand" ""))
3005 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3006 (clobber (match_operand 3 "register_operand" ""))]
3007 "reload_completed && TARGET_CPU_ZARCH"
3008 [(set (match_dup 3) (label_ref (match_dup 4)))
3010 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
3011 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3012 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3013 (use (const_int 1))])]
3014 "operands[4] = gen_label_rtx ();")
3016 ; Compare a block of arbitrary length.
3018 (define_expand "cmpmem_long"
3020 [(clobber (match_dup 2))
3021 (clobber (match_dup 3))
3022 (set (reg:CCU CC_REGNUM)
3023 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3024 (match_operand:BLK 1 "memory_operand" "")))
3025 (use (match_operand 2 "general_operand" ""))
3026 (use (match_dup 3))])]
3029 enum machine_mode dword_mode = word_mode == DImode ? TImode : DImode;
3030 rtx reg0 = gen_reg_rtx (dword_mode);
3031 rtx reg1 = gen_reg_rtx (dword_mode);
3032 rtx addr0 = gen_lowpart (Pmode, gen_highpart (word_mode, reg0));
3033 rtx addr1 = gen_lowpart (Pmode, gen_highpart (word_mode, reg1));
3034 rtx len0 = gen_lowpart (Pmode, reg0);
3035 rtx len1 = gen_lowpart (Pmode, reg1);
3037 emit_clobber (reg0);
3038 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3039 emit_move_insn (len0, operands[2]);
3041 emit_clobber (reg1);
3042 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3043 emit_move_insn (len1, operands[2]);
3045 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3046 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3051 (define_insn "*cmpmem_long"
3052 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3053 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3054 (set (reg:CCU CC_REGNUM)
3055 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3056 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
3058 (use (match_dup 3))]
3060 "clcle\t%0,%1,0\;jo\t.-4"
3061 [(set_attr "length" "8")
3062 (set_attr "type" "vs")])
3064 ; Convert CCUmode condition code to integer.
3065 ; Result is zero if EQ, positive if LTU, negative if GTU.
3067 (define_insn_and_split "cmpint"
3068 [(set (match_operand:SI 0 "register_operand" "=d")
3069 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3071 (clobber (reg:CC CC_REGNUM))]
3075 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3077 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
3078 (clobber (reg:CC CC_REGNUM))])])
3080 (define_insn_and_split "*cmpint_cc"
3081 [(set (reg CC_REGNUM)
3082 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3085 (set (match_operand:SI 0 "register_operand" "=d")
3086 (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT))]
3087 "s390_match_ccmode (insn, CCSmode)"
3089 "&& reload_completed"
3090 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3092 [(set (match_dup 2) (match_dup 3))
3093 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
3095 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3096 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3097 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3100 (define_insn_and_split "*cmpint_sign"
3101 [(set (match_operand:DI 0 "register_operand" "=d")
3102 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3103 UNSPEC_CCU_TO_INT)))
3104 (clobber (reg:CC CC_REGNUM))]
3107 "&& reload_completed"
3108 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3110 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
3111 (clobber (reg:CC CC_REGNUM))])])
3113 (define_insn_and_split "*cmpint_sign_cc"
3114 [(set (reg CC_REGNUM)
3115 (compare (ashiftrt:DI (ashift:DI (subreg:DI
3116 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3117 UNSPEC_CCU_TO_INT) 0)
3118 (const_int 32)) (const_int 32))
3120 (set (match_operand:DI 0 "register_operand" "=d")
3121 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_CCU_TO_INT)))]
3122 "s390_match_ccmode (insn, CCSmode) && TARGET_64BIT"
3124 "&& reload_completed"
3125 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3127 [(set (match_dup 2) (match_dup 3))
3128 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
3130 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3131 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3132 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3137 ;;- Conversion instructions.
3140 (define_insn "*sethighpartsi"
3141 [(set (match_operand:SI 0 "register_operand" "=d,d")
3142 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3143 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3144 (clobber (reg:CC CC_REGNUM))]
3149 [(set_attr "op_type" "RS,RSY")
3150 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3152 (define_insn "*sethighpartdi_64"
3153 [(set (match_operand:DI 0 "register_operand" "=d")
3154 (unspec:DI [(match_operand:BLK 1 "s_operand" "QS")
3155 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
3156 (clobber (reg:CC CC_REGNUM))]
3159 [(set_attr "op_type" "RSY")
3160 (set_attr "z10prop" "z10_super")])
3162 (define_insn "*sethighpartdi_31"
3163 [(set (match_operand:DI 0 "register_operand" "=d,d")
3164 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3165 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3166 (clobber (reg:CC CC_REGNUM))]
3171 [(set_attr "op_type" "RS,RSY")
3172 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3175 (define_insn_and_split "*extzv<mode>"
3176 [(set (match_operand:GPR 0 "register_operand" "=d")
3177 (zero_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3178 (match_operand 2 "const_int_operand" "n")
3180 (clobber (reg:CC CC_REGNUM))]
3181 "INTVAL (operands[2]) > 0
3182 && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
3184 "&& reload_completed"
3186 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3187 (clobber (reg:CC CC_REGNUM))])
3188 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
3190 int bitsize = INTVAL (operands[2]);
3191 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3192 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3194 operands[1] = adjust_address (operands[1], BLKmode, 0);
3195 set_mem_size (operands[1], GEN_INT (size));
3196 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - bitsize);
3197 operands[3] = GEN_INT (mask);
3200 (define_insn_and_split "*extv<mode>"
3201 [(set (match_operand:GPR 0 "register_operand" "=d")
3202 (sign_extract:GPR (match_operand:QI 1 "s_operand" "QS")
3203 (match_operand 2 "const_int_operand" "n")
3205 (clobber (reg:CC CC_REGNUM))]
3206 "INTVAL (operands[2]) > 0
3207 && INTVAL (operands[2]) <= GET_MODE_BITSIZE (SImode)"
3209 "&& reload_completed"
3211 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3212 (clobber (reg:CC CC_REGNUM))])
3214 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3215 (clobber (reg:CC CC_REGNUM))])]
3217 int bitsize = INTVAL (operands[2]);
3218 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3219 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3221 operands[1] = adjust_address (operands[1], BLKmode, 0);
3222 set_mem_size (operands[1], GEN_INT (size));
3223 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - bitsize);
3224 operands[3] = GEN_INT (mask);
3228 ; insv instruction patterns
3231 (define_expand "insv"
3232 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3233 (match_operand 1 "const_int_operand" "")
3234 (match_operand 2 "const_int_operand" ""))
3235 (match_operand 3 "general_operand" ""))]
3238 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3243 (define_insn "*insv<mode>_z10"
3244 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
3245 (match_operand 1 "const_int_operand" "I")
3246 (match_operand 2 "const_int_operand" "I"))
3247 (match_operand:GPR 3 "nonimmediate_operand" "d"))
3248 (clobber (reg:CC CC_REGNUM))]
3250 && (INTVAL (operands[1]) + INTVAL (operands[2])) <=
3251 GET_MODE_BITSIZE (<MODE>mode)"
3253 int start = INTVAL (operands[2]);
3254 int size = INTVAL (operands[1]);
3255 int offset = 64 - GET_MODE_BITSIZE (<MODE>mode);
3257 operands[2] = GEN_INT (offset + start); /* start bit position */
3258 operands[1] = GEN_INT (offset + start + size - 1); /* end bit position */
3259 operands[4] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) -
3260 start - size); /* left shift count */
3262 return "risbg\t%0,%3,%b2,%b1,%b4";
3264 [(set_attr "op_type" "RIE")
3265 (set_attr "z10prop" "z10_super_E1")])
3267 ; and op1 with a mask being 1 for the selected bits and 0 for the rest
3268 ; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
3269 (define_insn "*insv<mode>_z10_noshift"
3270 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3271 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3272 (match_operand 2 "const_int_operand" "n"))
3273 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0")
3274 (match_operand 4 "const_int_operand" "n"))))
3275 (clobber (reg:CC CC_REGNUM))]
3277 && s390_contiguous_bitmask_p (INTVAL (operands[2]),
3278 GET_MODE_BITSIZE (<MODE>mode), NULL, NULL)
3279 && INTVAL (operands[2]) == ~(INTVAL (operands[4]))"
3285 s390_contiguous_bitmask_p (INTVAL (operands[2]),
3286 GET_MODE_BITSIZE (<MODE>mode), &start, &size);
3288 operands[5] = GEN_INT (64 - start - size); /* start bit position */
3289 operands[6] = GEN_INT (64 - 1 - start); /* end bit position */
3290 operands[7] = const0_rtx; /* left shift count */
3292 return "risbg\t%0,%1,%b5,%b6,%b7";
3294 [(set_attr "op_type" "RIE")
3295 (set_attr "z10prop" "z10_super_E1")])
3297 ; and op1 with a mask being 1 for the selected bits and 0 for the rest
3298 (define_insn "*insv<mode>_or_z10_noshift"
3299 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
3300 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
3301 (match_operand 2 "const_int_operand" "n"))
3302 (match_operand:GPR 3 "nonimmediate_operand" "0")))
3303 (clobber (reg:CC CC_REGNUM))]
3305 && s390_contiguous_bitmask_p (INTVAL (operands[2]),
3306 GET_MODE_BITSIZE (<MODE>mode), NULL, NULL)"
3311 s390_contiguous_bitmask_p (INTVAL (operands[2]),
3312 GET_MODE_BITSIZE (<MODE>mode), &start, &size);
3314 operands[4] = GEN_INT (64 - start - size); /* start bit position */
3315 operands[5] = GEN_INT (64 - 1 - start); /* end bit position */
3316 operands[6] = const0_rtx; /* left shift count */
3318 return "rosbg\t%0,%1,%b4,%b5,%b6";
3320 [(set_attr "op_type" "RIE")])
3322 (define_insn "*insv<mode>_mem_reg"
3323 [(set (zero_extract:P (match_operand:QI 0 "memory_operand" "+Q,S")
3324 (match_operand 1 "const_int_operand" "n,n")
3326 (match_operand:P 2 "register_operand" "d,d"))]
3327 "INTVAL (operands[1]) > 0
3328 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3329 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3331 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3333 operands[1] = GEN_INT ((1ul << size) - 1);
3334 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
3335 : "stcmy\t%2,%1,%S0";
3337 [(set_attr "op_type" "RS,RSY")
3338 (set_attr "z10prop" "z10_super,z10_super")])
3340 (define_insn "*insvdi_mem_reghigh"
3341 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+QS")
3342 (match_operand 1 "const_int_operand" "n")
3344 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
3347 && INTVAL (operands[1]) > 0
3348 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
3349 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
3351 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
3353 operands[1] = GEN_INT ((1ul << size) - 1);
3354 return "stcmh\t%2,%1,%S0";
3356 [(set_attr "op_type" "RSY")
3357 (set_attr "z10prop" "z10_super")])
3359 (define_insn "*insv<mode>_reg_imm"
3360 [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
3362 (match_operand 1 "const_int_operand" "n"))
3363 (match_operand:P 2 "const_int_operand" "n"))]
3365 && INTVAL (operands[1]) >= 0
3366 && INTVAL (operands[1]) < BITS_PER_WORD
3367 && INTVAL (operands[1]) % 16 == 0"
3369 switch (BITS_PER_WORD - INTVAL (operands[1]))
3371 case 64: return "iihh\t%0,%x2"; break;
3372 case 48: return "iihl\t%0,%x2"; break;
3373 case 32: return "iilh\t%0,%x2"; break;
3374 case 16: return "iill\t%0,%x2"; break;
3375 default: gcc_unreachable();
3378 [(set_attr "op_type" "RI")
3379 (set_attr "z10prop" "z10_super_E1")])
3381 ; Update the left-most 32 bit of a DI.
3382 (define_insn "*insv_h_di_reg_extimm"
3383 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3386 (match_operand:DI 1 "const_int_operand" "n"))]
3389 [(set_attr "op_type" "RIL")
3390 (set_attr "z10prop" "z10_fwd_E1")])
3392 ; Update the right-most 32 bit of a DI, or the whole of a SI.
3393 (define_insn "*insv_l<mode>_reg_extimm"
3394 [(set (zero_extract:P (match_operand:P 0 "register_operand" "+d")
3396 (match_operand 1 "const_int_operand" "n"))
3397 (match_operand:P 2 "const_int_operand" "n"))]
3399 && BITS_PER_WORD - INTVAL (operands[1]) == 32"
3401 [(set_attr "op_type" "RIL")
3402 (set_attr "z10prop" "z10_fwd_A1")])
3405 ; extendsidi2 instruction pattern(s).
3408 (define_expand "extendsidi2"
3409 [(set (match_operand:DI 0 "register_operand" "")
3410 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3415 emit_clobber (operands[0]);
3416 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
3417 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
3418 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
3423 (define_insn "*extendsidi2"
3424 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3425 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3431 [(set_attr "op_type" "RRE,RXY,RIL")
3432 (set_attr "type" "*,*,larl")
3433 (set_attr "cpu_facility" "*,*,z10")
3434 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3437 ; extend(hi|qi)(si|di)2 instruction pattern(s).
3440 (define_expand "extend<HQI:mode><DSI:mode>2"
3441 [(set (match_operand:DSI 0 "register_operand" "")
3442 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3445 if (<DSI:MODE>mode == DImode && !TARGET_64BIT)
3447 rtx tmp = gen_reg_rtx (SImode);
3448 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
3449 emit_insn (gen_extendsidi2 (operands[0], tmp));
3452 else if (!TARGET_EXTIMM)
3454 rtx bitcount = GEN_INT (GET_MODE_BITSIZE (<DSI:MODE>mode) -
3455 GET_MODE_BITSIZE (<HQI:MODE>mode));
3457 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
3458 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
3459 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
3465 ; extendhidi2 instruction pattern(s).
3468 (define_insn "*extendhidi2_extimm"
3469 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3470 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,RT,b")))]
3471 "TARGET_64BIT && TARGET_EXTIMM"
3476 [(set_attr "op_type" "RRE,RXY,RIL")
3477 (set_attr "type" "*,*,larl")
3478 (set_attr "cpu_facility" "extimm,extimm,z10")
3479 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
3481 (define_insn "*extendhidi2"
3482 [(set (match_operand:DI 0 "register_operand" "=d")
3483 (sign_extend:DI (match_operand:HI 1 "memory_operand" "RT")))]
3486 [(set_attr "op_type" "RXY")
3487 (set_attr "z10prop" "z10_super_E1")])
3490 ; extendhisi2 instruction pattern(s).
3493 (define_insn "*extendhisi2_extimm"
3494 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
3495 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
3502 [(set_attr "op_type" "RRE,RX,RXY,RIL")
3503 (set_attr "type" "*,*,*,larl")
3504 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
3505 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
3507 (define_insn "*extendhisi2"
3508 [(set (match_operand:SI 0 "register_operand" "=d,d")
3509 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
3514 [(set_attr "op_type" "RX,RXY")
3515 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3518 ; extendqi(si|di)2 instruction pattern(s).
3521 ; lbr, lgbr, lb, lgb
3522 (define_insn "*extendqi<mode>2_extimm"
3523 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3524 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,RT")))]
3529 [(set_attr "op_type" "RRE,RXY")
3530 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3533 (define_insn "*extendqi<mode>2"
3534 [(set (match_operand:GPR 0 "register_operand" "=d")
3535 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "RT")))]
3536 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
3538 [(set_attr "op_type" "RXY")
3539 (set_attr "z10prop" "z10_super_E1")])
3541 (define_insn_and_split "*extendqi<mode>2_short_displ"
3542 [(set (match_operand:GPR 0 "register_operand" "=d")
3543 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
3544 (clobber (reg:CC CC_REGNUM))]
3545 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
3547 "&& reload_completed"
3549 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
3550 (clobber (reg:CC CC_REGNUM))])
3552 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3553 (clobber (reg:CC CC_REGNUM))])]
3555 operands[1] = adjust_address (operands[1], BLKmode, 0);
3556 set_mem_size (operands[1], GEN_INT (GET_MODE_SIZE (QImode)));
3557 operands[2] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode)
3558 - GET_MODE_BITSIZE (QImode));
3562 ; zero_extendsidi2 instruction pattern(s).
3565 (define_expand "zero_extendsidi2"
3566 [(set (match_operand:DI 0 "register_operand" "")
3567 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
3572 emit_clobber (operands[0]);
3573 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
3574 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
3579 (define_insn "*zero_extendsidi2"
3580 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
3581 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,RT,b")))]
3587 [(set_attr "op_type" "RRE,RXY,RIL")
3588 (set_attr "type" "*,*,larl")
3589 (set_attr "cpu_facility" "*,*,z10")
3590 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
3593 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
3596 (define_insn "*llgt_sidi"
3597 [(set (match_operand:DI 0 "register_operand" "=d")
3598 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3599 (const_int 2147483647)))]
3602 [(set_attr "op_type" "RXE")
3603 (set_attr "z10prop" "z10_super_E1")])
3605 (define_insn_and_split "*llgt_sidi_split"
3606 [(set (match_operand:DI 0 "register_operand" "=d")
3607 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "RT") 0)
3608 (const_int 2147483647)))
3609 (clobber (reg:CC CC_REGNUM))]
3612 "&& reload_completed"
3614 (and:DI (subreg:DI (match_dup 1) 0)
3615 (const_int 2147483647)))]
3618 (define_insn "*llgt_sisi"
3619 [(set (match_operand:SI 0 "register_operand" "=d,d")
3620 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,RT")
3621 (const_int 2147483647)))]
3626 [(set_attr "op_type" "RRE,RXE")
3627 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3629 (define_insn "*llgt_didi"
3630 [(set (match_operand:DI 0 "register_operand" "=d,d")
3631 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
3632 (const_int 2147483647)))]
3637 [(set_attr "op_type" "RRE,RXE")
3638 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3641 [(set (match_operand:GPR 0 "register_operand" "")
3642 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
3643 (const_int 2147483647)))
3644 (clobber (reg:CC CC_REGNUM))]
3645 "TARGET_ZARCH && reload_completed"
3647 (and:GPR (match_dup 1)
3648 (const_int 2147483647)))]
3652 ; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
3655 (define_expand "zero_extend<mode>di2"
3656 [(set (match_operand:DI 0 "register_operand" "")
3657 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3662 rtx tmp = gen_reg_rtx (SImode);
3663 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
3664 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
3667 else if (!TARGET_EXTIMM)
3669 rtx bitcount = GEN_INT (GET_MODE_BITSIZE(DImode) -
3670 GET_MODE_BITSIZE(<MODE>mode));
3671 operands[1] = gen_lowpart (DImode, operands[1]);
3672 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
3673 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
3678 (define_expand "zero_extend<mode>si2"
3679 [(set (match_operand:SI 0 "register_operand" "")
3680 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
3685 operands[1] = gen_lowpart (SImode, operands[1]);
3686 emit_insn (gen_andsi3 (operands[0], operands[1],
3687 GEN_INT ((1 << GET_MODE_BITSIZE(<MODE>mode)) - 1)));
3693 (define_insn "*zero_extendhi<mode>2_z10"
3694 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
3695 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,RT,b")))]
3701 [(set_attr "op_type" "RXY,RRE,RIL")
3702 (set_attr "type" "*,*,larl")
3703 (set_attr "cpu_facility" "*,*,z10")
3704 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
3706 ; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
3707 (define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
3708 [(set (match_operand:GPR 0 "register_operand" "=d,d")
3709 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,RT")))]
3714 [(set_attr "op_type" "RRE,RXY")
3715 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
3718 (define_insn "*zero_extend<HQI:mode><GPR:mode>2"
3719 [(set (match_operand:GPR 0 "register_operand" "=d")
3720 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "RT")))]
3721 "TARGET_ZARCH && !TARGET_EXTIMM"
3723 [(set_attr "op_type" "RXY")
3724 (set_attr "z10prop" "z10_fwd_A3")])
3726 (define_insn_and_split "*zero_extendhisi2_31"
3727 [(set (match_operand:SI 0 "register_operand" "=&d")
3728 (zero_extend:SI (match_operand:HI 1 "s_operand" "QS")))
3729 (clobber (reg:CC CC_REGNUM))]
3732 "&& reload_completed"
3733 [(set (match_dup 0) (const_int 0))
3735 [(set (strict_low_part (match_dup 2)) (match_dup 1))
3736 (clobber (reg:CC CC_REGNUM))])]
3737 "operands[2] = gen_lowpart (HImode, operands[0]);")
3739 (define_insn_and_split "*zero_extendqisi2_31"
3740 [(set (match_operand:SI 0 "register_operand" "=&d")
3741 (zero_extend:SI (match_operand:QI 1 "memory_operand" "RT")))]
3744 "&& reload_completed"
3745 [(set (match_dup 0) (const_int 0))
3746 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3747 "operands[2] = gen_lowpart (QImode, operands[0]);")
3750 ; zero_extendqihi2 instruction pattern(s).
3753 (define_expand "zero_extendqihi2"
3754 [(set (match_operand:HI 0 "register_operand" "")
3755 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
3756 "TARGET_ZARCH && !TARGET_EXTIMM"
3758 operands[1] = gen_lowpart (HImode, operands[1]);
3759 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
3763 (define_insn "*zero_extendqihi2_64"
3764 [(set (match_operand:HI 0 "register_operand" "=d")
3765 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
3766 "TARGET_ZARCH && !TARGET_EXTIMM"
3768 [(set_attr "op_type" "RXY")
3769 (set_attr "z10prop" "z10_fwd_A3")])
3771 (define_insn_and_split "*zero_extendqihi2_31"
3772 [(set (match_operand:HI 0 "register_operand" "=&d")
3773 (zero_extend:HI (match_operand:QI 1 "memory_operand" "RT")))]
3776 "&& reload_completed"
3777 [(set (match_dup 0) (const_int 0))
3778 (set (strict_low_part (match_dup 2)) (match_dup 1))]
3779 "operands[2] = gen_lowpart (QImode, operands[0]);")
3782 ; fixuns_trunc(dd|td)di2 instruction pattern(s).
3785 (define_expand "fixuns_truncdddi2"
3787 [(set (match_operand:DI 0 "register_operand" "")
3788 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
3789 (clobber (match_scratch:TD 2 "=f"))])]
3793 rtx label1 = gen_label_rtx ();
3794 rtx label2 = gen_label_rtx ();
3795 rtx temp = gen_reg_rtx (TDmode);
3796 REAL_VALUE_TYPE cmp, sub;
3798 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
3799 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3801 /* 2^63 can't be represented as 64bit DFP number with full precision. The
3802 solution is doing the check and the subtraction in TD mode and using a
3803 TD -> DI convert afterwards. */
3804 emit_insn (gen_extendddtd2 (temp, operands[1]));
3805 temp = force_reg (TDmode, temp);
3806 emit_insn (gen_cmptd (temp,
3807 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode)));
3808 emit_jump_insn (gen_blt (label1));
3809 emit_insn (gen_subtd3 (temp, temp,
3810 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3811 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3814 emit_label (label1);
3815 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3816 emit_label (label2);
3820 (define_expand "fixuns_trunctddi2"
3821 [(set (match_operand:DI 0 "register_operand" "")
3822 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))]
3825 rtx label1 = gen_label_rtx ();
3826 rtx label2 = gen_label_rtx ();
3827 rtx temp = gen_reg_rtx (TDmode);
3828 REAL_VALUE_TYPE cmp, sub;
3830 operands[1] = force_reg (TDmode, operands[1]);
3831 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
3832 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
3834 emit_insn (gen_cmptd (operands[1],
3835 CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode)));
3836 emit_jump_insn (gen_blt (label1));
3837 emit_insn (gen_subtd3 (temp, operands[1],
3838 CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode)));
3839 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11)));
3842 emit_label (label1);
3843 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1], GEN_INT (9)));
3844 emit_label (label2);
3849 ; fixuns_trunc(sf|df)(si|di)2 and fix_trunc(sf|df)(si|di)2
3850 ; instruction pattern(s).
3853 (define_expand "fixuns_trunc<BFP:mode><GPR:mode>2"
3854 [(set (match_operand:GPR 0 "register_operand" "")
3855 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))]
3858 rtx label1 = gen_label_rtx ();
3859 rtx label2 = gen_label_rtx ();
3860 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
3861 REAL_VALUE_TYPE cmp, sub;
3863 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
3864 real_2expN (&cmp, GET_MODE_BITSIZE(<GPR:MODE>mode) - 1, <BFP:MODE>mode);
3865 real_2expN (&sub, GET_MODE_BITSIZE(<GPR:MODE>mode), <BFP:MODE>mode);
3867 emit_insn (gen_cmp<BFP:mode> (operands[1],
3868 CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode)));
3869 emit_jump_insn (gen_blt (label1));
3870 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
3871 CONST_DOUBLE_FROM_REAL_VALUE (sub, <BFP:MODE>mode)));
3872 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
3876 emit_label (label1);
3877 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
3878 operands[1], GEN_INT (5)));
3879 emit_label (label2);
3883 (define_expand "fix_trunc<DSF:mode><GPR:mode>2"
3884 [(set (match_operand:GPR 0 "register_operand" "")
3885 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
3888 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
3893 ; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
3894 (define_insn "fix_trunc<BFP:mode><GPR:mode>2_bfp"
3895 [(set (match_operand:GPR 0 "register_operand" "=d")
3896 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
3897 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
3898 (clobber (reg:CC CC_REGNUM))]
3900 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
3901 [(set_attr "op_type" "RRE")
3902 (set_attr "type" "ftoi")])
3906 ; fix_trunc(td|dd)di2 instruction pattern(s).
3909 (define_expand "fix_trunc<mode>di2"
3910 [(set (match_operand:DI 0 "register_operand" "")
3911 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
3912 "TARGET_64BIT && TARGET_HARD_DFP"
3914 operands[1] = force_reg (<MODE>mode, operands[1]);
3915 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
3921 (define_insn "fix_trunc<DFP:mode>di2_dfp"
3922 [(set (match_operand:DI 0 "register_operand" "=d")
3923 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
3924 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
3925 (clobber (reg:CC CC_REGNUM))]
3926 "TARGET_64BIT && TARGET_HARD_DFP"
3927 "cg<DFP:xde>tr\t%0,%h2,%1"
3928 [(set_attr "op_type" "RRF")
3929 (set_attr "type" "ftoidfp")])
3933 ; fix_trunctf(si|di)2 instruction pattern(s).
3936 (define_expand "fix_trunctf<mode>2"
3937 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
3938 (fix:GPR (match_operand:TF 1 "register_operand" "")))
3939 (unspec:GPR [(const_int 5)] UNSPEC_ROUND)
3940 (clobber (reg:CC CC_REGNUM))])]
3946 ; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
3949 ; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
3950 (define_insn "floatdi<mode>2"
3951 [(set (match_operand:FP 0 "register_operand" "=f")
3952 (float:FP (match_operand:DI 1 "register_operand" "d")))]
3953 "TARGET_64BIT && TARGET_HARD_FLOAT"
3954 "c<xde>g<bt>r\t%0,%1"
3955 [(set_attr "op_type" "RRE")
3956 (set_attr "type" "itof<mode>" )])
3958 ; cxfbr, cdfbr, cefbr
3959 (define_insn "floatsi<mode>2"
3960 [(set (match_operand:BFP 0 "register_operand" "=f")
3961 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
3964 [(set_attr "op_type" "RRE")
3965 (set_attr "type" "itof<mode>" )])
3969 ; truncdfsf2 instruction pattern(s).
3972 (define_insn "truncdfsf2"
3973 [(set (match_operand:SF 0 "register_operand" "=f")
3974 (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))]
3977 [(set_attr "op_type" "RRE")
3978 (set_attr "type" "ftruncdf")])
3981 ; trunctf(df|sf)2 instruction pattern(s).
3985 (define_insn "trunctf<mode>2"
3986 [(set (match_operand:DSF 0 "register_operand" "=f")
3987 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
3988 (clobber (match_scratch:TF 2 "=f"))]
3990 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
3991 [(set_attr "length" "6")
3992 (set_attr "type" "ftrunctf")])
3995 ; trunctddd2 and truncddsd2 instruction pattern(s).
3998 (define_insn "trunctddd2"
3999 [(set (match_operand:DD 0 "register_operand" "=f")
4000 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
4001 (clobber (match_scratch:TD 2 "=f"))]
4003 "ldxtr\t%2,0,%1,0\;ldr\t%0,%2"
4004 [(set_attr "length" "6")
4005 (set_attr "type" "ftruncdd")])
4007 (define_insn "truncddsd2"
4008 [(set (match_operand:SD 0 "register_operand" "=f")
4009 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
4012 [(set_attr "op_type" "RRF")
4013 (set_attr "type" "ftruncsd")])
4016 ; extend(sf|df)(df|tf)2 instruction pattern(s).
4019 ; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
4020 (define_insn "extend<DSF:mode><BFP:mode>2"
4021 [(set (match_operand:BFP 0 "register_operand" "=f,f")
4022 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
4024 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)"
4026 l<BFP:xde><DSF:xde>br\t%0,%1
4027 l<BFP:xde><DSF:xde>b\t%0,%1"
4028 [(set_attr "op_type" "RRE,RXE")
4029 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
4032 ; extendddtd2 and extendsddd2 instruction pattern(s).
4035 (define_insn "extendddtd2"
4036 [(set (match_operand:TD 0 "register_operand" "=f")
4037 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
4040 [(set_attr "op_type" "RRF")
4041 (set_attr "type" "fsimptf")])
4043 (define_insn "extendsddd2"
4044 [(set (match_operand:DD 0 "register_operand" "=f")
4045 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
4048 [(set_attr "op_type" "RRF")
4049 (set_attr "type" "fsimptf")])
4051 ; Binary <-> Decimal floating point trunc patterns
4054 (define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
4055 [(set (reg:DFP_ALL FPR0_REGNUM)
4056 (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
4057 (use (reg:SI GPR0_REGNUM))
4058 (clobber (reg:CC CC_REGNUM))]
4062 (define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
4063 [(set (reg:BFP FPR0_REGNUM)
4064 (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
4065 (use (reg:SI GPR0_REGNUM))
4066 (clobber (reg:CC CC_REGNUM))]
4070 (define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
4071 [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4072 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4074 [(set (reg:DFP_ALL FPR0_REGNUM)
4075 (float_truncate:DFP_ALL (reg:BFP FPR2_REGNUM)))
4076 (use (reg:SI GPR0_REGNUM))
4077 (clobber (reg:CC CC_REGNUM))])
4078 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4079 (reg:DFP_ALL FPR0_REGNUM))]
4081 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4083 HOST_WIDE_INT flags;
4085 flags = (PFPO_CONVERT |
4086 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4087 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4089 operands[2] = GEN_INT (flags);
4092 (define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
4093 [(set (reg:DFP_ALL FPR2_REGNUM)
4094 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4095 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4097 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR2_REGNUM)))
4098 (use (reg:SI GPR0_REGNUM))
4099 (clobber (reg:CC CC_REGNUM))])
4100 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4102 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
4104 HOST_WIDE_INT flags;
4106 flags = (PFPO_CONVERT |
4107 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4108 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4110 operands[2] = GEN_INT (flags);
4114 ; Binary <-> Decimal floating point extend patterns
4117 (define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
4118 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR2_REGNUM)))
4119 (use (reg:SI GPR0_REGNUM))
4120 (clobber (reg:CC CC_REGNUM))]
4124 (define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
4125 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR2_REGNUM)))
4126 (use (reg:SI GPR0_REGNUM))
4127 (clobber (reg:CC CC_REGNUM))]
4131 (define_expand "extend<BFP:mode><DFP_ALL:mode>2"
4132 [(set (reg:BFP FPR2_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
4133 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4135 [(set (reg:DFP_ALL FPR0_REGNUM)
4136 (float_extend:DFP_ALL (reg:BFP FPR2_REGNUM)))
4137 (use (reg:SI GPR0_REGNUM))
4138 (clobber (reg:CC CC_REGNUM))])
4139 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
4140 (reg:DFP_ALL FPR0_REGNUM))]
4142 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
4144 HOST_WIDE_INT flags;
4146 flags = (PFPO_CONVERT |
4147 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
4148 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
4150 operands[2] = GEN_INT (flags);
4153 (define_expand "extend<DFP_ALL:mode><BFP:mode>2"
4154 [(set (reg:DFP_ALL FPR2_REGNUM)
4155 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
4156 (set (reg:SI GPR0_REGNUM) (match_dup 2))
4158 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR2_REGNUM)))
4159 (use (reg:SI GPR0_REGNUM))
4160 (clobber (reg:CC CC_REGNUM))])
4161 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
4163 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
4165 HOST_WIDE_INT flags;
4167 flags = (PFPO_CONVERT |
4168 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
4169 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
4171 operands[2] = GEN_INT (flags);
4176 ;; ARITHMETIC OPERATIONS
4178 ; arithmetic operations set the ConditionCode,
4179 ; because of unpredictable Bits in Register for Halfword and Byte
4180 ; the ConditionCode can be set wrong in operations for Halfword and Byte
4183 ;;- Add instructions.
4187 ; addti3 instruction pattern(s).
4190 (define_insn_and_split "addti3"
4191 [(set (match_operand:TI 0 "register_operand" "=&d")
4192 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
4193 (match_operand:TI 2 "general_operand" "do") ) )
4194 (clobber (reg:CC CC_REGNUM))]
4197 "&& reload_completed"
4199 [(set (reg:CCL1 CC_REGNUM)
4200 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
4202 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
4204 [(set (match_dup 3) (plus:DI
4205 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
4206 (match_dup 4)) (match_dup 5)))
4207 (clobber (reg:CC CC_REGNUM))])]
4208 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4209 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4210 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4211 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4212 operands[7] = operand_subword (operands[1], 1, 0, TImode);
4213 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4216 ; adddi3 instruction pattern(s).
4219 (define_expand "adddi3"
4221 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4222 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
4223 (match_operand:DI 2 "general_operand" "")))
4224 (clobber (reg:CC CC_REGNUM))])]
4228 (define_insn "*adddi3_sign"
4229 [(set (match_operand:DI 0 "register_operand" "=d,d")
4230 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4231 (match_operand:DI 1 "register_operand" "0,0")))
4232 (clobber (reg:CC CC_REGNUM))]
4237 [(set_attr "op_type" "RRE,RXY")])
4239 (define_insn "*adddi3_zero_cc"
4240 [(set (reg CC_REGNUM)
4241 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4242 (match_operand:DI 1 "register_operand" "0,0"))
4244 (set (match_operand:DI 0 "register_operand" "=d,d")
4245 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
4246 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4250 [(set_attr "op_type" "RRE,RXY")
4251 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4253 (define_insn "*adddi3_zero_cconly"
4254 [(set (reg CC_REGNUM)
4255 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4256 (match_operand:DI 1 "register_operand" "0,0"))
4258 (clobber (match_scratch:DI 0 "=d,d"))]
4259 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4263 [(set_attr "op_type" "RRE,RXY")
4264 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4266 (define_insn "*adddi3_zero"
4267 [(set (match_operand:DI 0 "register_operand" "=d,d")
4268 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
4269 (match_operand:DI 1 "register_operand" "0,0")))
4270 (clobber (reg:CC CC_REGNUM))]
4275 [(set_attr "op_type" "RRE,RXY")
4276 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4278 (define_insn_and_split "*adddi3_31z"
4279 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4280 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4281 (match_operand:DI 2 "general_operand" "do") ) )
4282 (clobber (reg:CC CC_REGNUM))]
4283 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4285 "&& reload_completed"
4287 [(set (reg:CCL1 CC_REGNUM)
4288 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4290 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4292 [(set (match_dup 3) (plus:SI
4293 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
4294 (match_dup 4)) (match_dup 5)))
4295 (clobber (reg:CC CC_REGNUM))])]
4296 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4297 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4298 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4299 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4300 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4301 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4303 (define_insn_and_split "*adddi3_31"
4304 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
4305 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
4306 (match_operand:DI 2 "general_operand" "do") ) )
4307 (clobber (reg:CC CC_REGNUM))]
4310 "&& reload_completed"
4312 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
4313 (clobber (reg:CC CC_REGNUM))])
4315 [(set (reg:CCL1 CC_REGNUM)
4316 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
4318 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
4320 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
4322 (label_ref (match_dup 9))))
4324 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
4325 (clobber (reg:CC CC_REGNUM))])
4327 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4328 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4329 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4330 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4331 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4332 operands[8] = operand_subword (operands[2], 1, 0, DImode);
4333 operands[9] = gen_label_rtx ();")
4336 ; addsi3 instruction pattern(s).
4339 (define_expand "addsi3"
4341 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4342 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
4343 (match_operand:SI 2 "general_operand" "")))
4344 (clobber (reg:CC CC_REGNUM))])]
4348 (define_insn "*addsi3_sign"
4349 [(set (match_operand:SI 0 "register_operand" "=d,d")
4350 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
4351 (match_operand:SI 1 "register_operand" "0,0")))
4352 (clobber (reg:CC CC_REGNUM))]
4357 [(set_attr "op_type" "RX,RXY")])
4360 ; add(di|si)3 instruction pattern(s).
4363 ; ar, ahi, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
4364 (define_insn "*add<mode>3"
4365 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,QS")
4366 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0,0")
4367 (match_operand:GPR 2 "general_operand" "d,K,Op,On,R,T,C") ) )
4368 (clobber (reg:CC CC_REGNUM))]
4378 [(set_attr "op_type" "RR<E>,RI,RIL,RIL,RX<Y>,RXY,SIY")
4379 (set_attr "cpu_facility" "*,*,extimm,extimm,*,*,z10")
4380 (set_attr "z10prop" "z10_super_E1,
4388 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4389 (define_insn "*add<mode>3_carry1_cc"
4390 [(set (reg CC_REGNUM)
4391 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4392 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4394 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d")
4395 (plus:GPR (match_dup 1) (match_dup 2)))]
4396 "s390_match_ccmode (insn, CCL1mode)"
4404 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY,SIY")
4405 (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4406 (set_attr "z10prop" "z10_super_E1,
4413 ; alr, al, aly, algr, alg
4414 (define_insn "*add<mode>3_carry1_cconly"
4415 [(set (reg CC_REGNUM)
4416 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4417 (match_operand:GPR 2 "general_operand" "d,R,T"))
4419 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4420 "s390_match_ccmode (insn, CCL1mode)"
4425 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4426 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4428 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4429 (define_insn "*add<mode>3_carry2_cc"
4430 [(set (reg CC_REGNUM)
4431 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4432 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4434 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,RS")
4435 (plus:GPR (match_dup 1) (match_dup 2)))]
4436 "s390_match_ccmode (insn, CCL1mode)"
4444 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY,SIY")
4445 (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4446 (set_attr "z10prop" "z10_super_E1,
4453 ; alr, al, aly, algr, alg
4454 (define_insn "*add<mode>3_carry2_cconly"
4455 [(set (reg CC_REGNUM)
4456 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4457 (match_operand:GPR 2 "general_operand" "d,R,T"))
4459 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4460 "s390_match_ccmode (insn, CCL1mode)"
4465 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4466 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4468 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi
4469 (define_insn "*add<mode>3_cc"
4470 [(set (reg CC_REGNUM)
4471 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0,0,0,0")
4472 (match_operand:GPR 2 "general_operand" "d,Op,On,R,T,C"))
4474 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,RS")
4475 (plus:GPR (match_dup 1) (match_dup 2)))]
4476 "s390_match_ccmode (insn, CCLmode)"
4484 [(set_attr "op_type" "RR<E>,RIL,RIL,RX<Y>,RXY,SIY")
4485 (set_attr "cpu_facility" "*,extimm,extimm,*,*,z10")
4486 (set_attr "z10prop" "z10_super_E1,
4493 ; alr, al, aly, algr, alg
4494 (define_insn "*add<mode>3_cconly"
4495 [(set (reg CC_REGNUM)
4496 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4497 (match_operand:GPR 2 "general_operand" "d,R,T"))
4499 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4500 "s390_match_ccmode (insn, CCLmode)"
4505 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4506 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4508 ; alr, al, aly, algr, alg
4509 (define_insn "*add<mode>3_cconly2"
4510 [(set (reg CC_REGNUM)
4511 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,0,0")
4512 (neg:GPR (match_operand:GPR 2 "general_operand" "d,R,T"))))
4513 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4514 "s390_match_ccmode(insn, CCLmode)"
4519 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4520 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4522 ; ahi, afi, aghi, agfi, asi, agsi
4523 (define_insn "*add<mode>3_imm_cc"
4524 [(set (reg CC_REGNUM)
4525 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0,0")
4526 (match_operand:GPR 2 "const_int_operand" "K,Os,C"))
4528 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,QS")
4529 (plus:GPR (match_dup 1) (match_dup 2)))]
4530 "s390_match_ccmode (insn, CCAmode)
4531 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
4532 || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
4533 || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'C', \"C\"))
4534 && INTVAL (operands[2]) != -((HOST_WIDE_INT)1 << (GET_MODE_BITSIZE(<MODE>mode) - 1))"
4539 [(set_attr "op_type" "RI,RIL,SIY")
4540 (set_attr "cpu_facility" "*,extimm,z10")
4541 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4544 ; add(tf|df|sf|td|dd)3 instruction pattern(s).
4547 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4548 (define_insn "add<mode>3"
4549 [(set (match_operand:FP 0 "register_operand" "=f, f")
4550 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4551 (match_operand:FP 2 "general_operand" " f,<Rf>")))
4552 (clobber (reg:CC CC_REGNUM))]
4555 a<xde><bt>r\t%0,<op1>%2
4557 [(set_attr "op_type" "<RRer>,RXE")
4558 (set_attr "type" "fsimp<mode>")])
4560 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4561 (define_insn "*add<mode>3_cc"
4562 [(set (reg CC_REGNUM)
4563 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4564 (match_operand:FP 2 "general_operand" " f,<Rf>"))
4565 (match_operand:FP 3 "const0_operand" "")))
4566 (set (match_operand:FP 0 "register_operand" "=f,f")
4567 (plus:FP (match_dup 1) (match_dup 2)))]
4568 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4570 a<xde><bt>r\t%0,<op1>%2
4572 [(set_attr "op_type" "<RRer>,RXE")
4573 (set_attr "type" "fsimp<mode>")])
4575 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
4576 (define_insn "*add<mode>3_cconly"
4577 [(set (reg CC_REGNUM)
4578 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
4579 (match_operand:FP 2 "general_operand" " f,<Rf>"))
4580 (match_operand:FP 3 "const0_operand" "")))
4581 (clobber (match_scratch:FP 0 "=f,f"))]
4582 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4584 a<xde><bt>r\t%0,<op1>%2
4586 [(set_attr "op_type" "<RRer>,RXE")
4587 (set_attr "type" "fsimp<mode>")])
4591 ;;- Subtract instructions.
4595 ; subti3 instruction pattern(s).
4598 (define_insn_and_split "subti3"
4599 [(set (match_operand:TI 0 "register_operand" "=&d")
4600 (minus:TI (match_operand:TI 1 "register_operand" "0")
4601 (match_operand:TI 2 "general_operand" "do") ) )
4602 (clobber (reg:CC CC_REGNUM))]
4605 "&& reload_completed"
4607 [(set (reg:CCL2 CC_REGNUM)
4608 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
4610 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
4612 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
4613 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
4614 (clobber (reg:CC CC_REGNUM))])]
4615 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
4616 operands[4] = operand_subword (operands[1], 0, 0, TImode);
4617 operands[5] = operand_subword (operands[2], 0, 0, TImode);
4618 operands[6] = operand_subword (operands[0], 1, 0, TImode);
4619 operands[7] = operand_subword (operands[1], 1, 0, TImode);
4620 operands[8] = operand_subword (operands[2], 1, 0, TImode);")
4623 ; subdi3 instruction pattern(s).
4626 (define_expand "subdi3"
4628 [(set (match_operand:DI 0 "register_operand" "")
4629 (minus:DI (match_operand:DI 1 "register_operand" "")
4630 (match_operand:DI 2 "general_operand" "")))
4631 (clobber (reg:CC CC_REGNUM))])]
4635 (define_insn "*subdi3_sign"
4636 [(set (match_operand:DI 0 "register_operand" "=d,d")
4637 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4638 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
4639 (clobber (reg:CC CC_REGNUM))]
4644 [(set_attr "op_type" "RRE,RXY")
4645 (set_attr "z10prop" "z10_c,*")])
4647 (define_insn "*subdi3_zero_cc"
4648 [(set (reg CC_REGNUM)
4649 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4650 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
4652 (set (match_operand:DI 0 "register_operand" "=d,d")
4653 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
4654 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4658 [(set_attr "op_type" "RRE,RXY")
4659 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4661 (define_insn "*subdi3_zero_cconly"
4662 [(set (reg CC_REGNUM)
4663 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4664 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT")))
4666 (clobber (match_scratch:DI 0 "=d,d"))]
4667 "s390_match_ccmode (insn, CCLmode) && TARGET_64BIT"
4671 [(set_attr "op_type" "RRE,RXY")
4672 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4674 (define_insn "*subdi3_zero"
4675 [(set (match_operand:DI 0 "register_operand" "=d,d")
4676 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
4677 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))))
4678 (clobber (reg:CC CC_REGNUM))]
4683 [(set_attr "op_type" "RRE,RXY")
4684 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
4686 (define_insn_and_split "*subdi3_31z"
4687 [(set (match_operand:DI 0 "register_operand" "=&d")
4688 (minus:DI (match_operand:DI 1 "register_operand" "0")
4689 (match_operand:DI 2 "general_operand" "do") ) )
4690 (clobber (reg:CC CC_REGNUM))]
4691 "!TARGET_64BIT && TARGET_CPU_ZARCH"
4693 "&& reload_completed"
4695 [(set (reg:CCL2 CC_REGNUM)
4696 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4698 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4700 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
4701 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
4702 (clobber (reg:CC CC_REGNUM))])]
4703 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4704 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4705 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4706 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4707 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4708 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
4710 (define_insn_and_split "*subdi3_31"
4711 [(set (match_operand:DI 0 "register_operand" "=&d")
4712 (minus:DI (match_operand:DI 1 "register_operand" "0")
4713 (match_operand:DI 2 "general_operand" "do") ) )
4714 (clobber (reg:CC CC_REGNUM))]
4717 "&& reload_completed"
4719 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
4720 (clobber (reg:CC CC_REGNUM))])
4722 [(set (reg:CCL2 CC_REGNUM)
4723 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
4725 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
4727 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
4729 (label_ref (match_dup 9))))
4731 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
4732 (clobber (reg:CC CC_REGNUM))])
4734 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
4735 operands[4] = operand_subword (operands[1], 0, 0, DImode);
4736 operands[5] = operand_subword (operands[2], 0, 0, DImode);
4737 operands[6] = operand_subword (operands[0], 1, 0, DImode);
4738 operands[7] = operand_subword (operands[1], 1, 0, DImode);
4739 operands[8] = operand_subword (operands[2], 1, 0, DImode);
4740 operands[9] = gen_label_rtx ();")
4743 ; subsi3 instruction pattern(s).
4746 (define_expand "subsi3"
4748 [(set (match_operand:SI 0 "register_operand" "")
4749 (minus:SI (match_operand:SI 1 "register_operand" "")
4750 (match_operand:SI 2 "general_operand" "")))
4751 (clobber (reg:CC CC_REGNUM))])]
4755 (define_insn "*subsi3_sign"
4756 [(set (match_operand:SI 0 "register_operand" "=d,d")
4757 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
4758 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
4759 (clobber (reg:CC CC_REGNUM))]
4764 [(set_attr "op_type" "RX,RXY")])
4767 ; sub(di|si)3 instruction pattern(s).
4770 ; sr, s, sy, sgr, sg
4771 (define_insn "*sub<mode>3"
4772 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
4773 (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4774 (match_operand:GPR 2 "general_operand" "d,R,T") ) )
4775 (clobber (reg:CC CC_REGNUM))]
4781 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4782 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4784 ; slr, sl, sly, slgr, slg
4785 (define_insn "*sub<mode>3_borrow_cc"
4786 [(set (reg CC_REGNUM)
4787 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4788 (match_operand:GPR 2 "general_operand" "d,R,T"))
4790 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4791 (minus:GPR (match_dup 1) (match_dup 2)))]
4792 "s390_match_ccmode (insn, CCL2mode)"
4797 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4798 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4800 ; slr, sl, sly, slgr, slg
4801 (define_insn "*sub<mode>3_borrow_cconly"
4802 [(set (reg CC_REGNUM)
4803 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4804 (match_operand:GPR 2 "general_operand" "d,R,T"))
4806 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4807 "s390_match_ccmode (insn, CCL2mode)"
4812 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4813 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4815 ; slr, sl, sly, slgr, slg
4816 (define_insn "*sub<mode>3_cc"
4817 [(set (reg CC_REGNUM)
4818 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4819 (match_operand:GPR 2 "general_operand" "d,R,T"))
4821 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4822 (minus:GPR (match_dup 1) (match_dup 2)))]
4823 "s390_match_ccmode (insn, CCLmode)"
4828 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4829 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4831 ; slr, sl, sly, slgr, slg
4832 (define_insn "*sub<mode>3_cc2"
4833 [(set (reg CC_REGNUM)
4834 (compare (match_operand:GPR 1 "register_operand" "0,0,0")
4835 (match_operand:GPR 2 "general_operand" "d,R,T")))
4836 (set (match_operand:GPR 0 "register_operand" "=d,d,d")
4837 (minus:GPR (match_dup 1) (match_dup 2)))]
4838 "s390_match_ccmode (insn, CCL3mode)"
4843 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4844 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4846 ; slr, sl, sly, slgr, slg
4847 (define_insn "*sub<mode>3_cconly"
4848 [(set (reg CC_REGNUM)
4849 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,0,0")
4850 (match_operand:GPR 2 "general_operand" "d,R,T"))
4852 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4853 "s390_match_ccmode (insn, CCLmode)"
4858 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4859 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4862 ; slr, sl, sly, slgr, slg
4863 (define_insn "*sub<mode>3_cconly2"
4864 [(set (reg CC_REGNUM)
4865 (compare (match_operand:GPR 1 "register_operand" "0,0,0")
4866 (match_operand:GPR 2 "general_operand" "d,R,T")))
4867 (clobber (match_scratch:GPR 0 "=d,d,d"))]
4868 "s390_match_ccmode (insn, CCL3mode)"
4873 [(set_attr "op_type" "RR<E>,RX<Y>,RXY")
4874 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1,z10_super_E1")])
4878 ; sub(tf|df|sf|td|dd)3 instruction pattern(s).
4881 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4882 (define_insn "sub<mode>3"
4883 [(set (match_operand:FP 0 "register_operand" "=f, f")
4884 (minus:FP (match_operand:FP 1 "register_operand" "<f0>,0")
4885 (match_operand:FP 2 "general_operand" "f,<Rf>")))
4886 (clobber (reg:CC CC_REGNUM))]
4889 s<xde><bt>r\t%0,<op1>%2
4891 [(set_attr "op_type" "<RRer>,RXE")
4892 (set_attr "type" "fsimp<mode>")])
4894 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4895 (define_insn "*sub<mode>3_cc"
4896 [(set (reg CC_REGNUM)
4897 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
4898 (match_operand:FP 2 "general_operand" "f,<Rf>"))
4899 (match_operand:FP 3 "const0_operand" "")))
4900 (set (match_operand:FP 0 "register_operand" "=f,f")
4901 (minus:FP (match_dup 1) (match_dup 2)))]
4902 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4904 s<xde><bt>r\t%0,<op1>%2
4906 [(set_attr "op_type" "<RRer>,RXE")
4907 (set_attr "type" "fsimp<mode>")])
4909 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
4910 (define_insn "*sub<mode>3_cconly"
4911 [(set (reg CC_REGNUM)
4912 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "<f0>,0")
4913 (match_operand:FP 2 "general_operand" "f,<Rf>"))
4914 (match_operand:FP 3 "const0_operand" "")))
4915 (clobber (match_scratch:FP 0 "=f,f"))]
4916 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
4918 s<xde><bt>r\t%0,<op1>%2
4920 [(set_attr "op_type" "<RRer>,RXE")
4921 (set_attr "type" "fsimp<mode>")])
4925 ;;- Conditional add/subtract instructions.
4929 ; add(di|si)cc instruction pattern(s).
4932 ; the following 4 patterns are used when the result of an add with
4933 ; carry is checked for an overflow condition
4935 ; op1 + op2 + c < op1
4937 ; alcr, alc, alcgr, alcg
4938 (define_insn "*add<mode>3_alc_carry1_cc"
4939 [(set (reg CC_REGNUM)
4941 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4942 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4943 (match_operand:GPR 2 "general_operand" "d,RT"))
4945 (set (match_operand:GPR 0 "register_operand" "=d,d")
4946 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
4947 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4951 [(set_attr "op_type" "RRE,RXY")])
4953 ; alcr, alc, alcgr, alcg
4954 (define_insn "*add<mode>3_alc_carry1_cconly"
4955 [(set (reg CC_REGNUM)
4957 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4958 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4959 (match_operand:GPR 2 "general_operand" "d,RT"))
4961 (clobber (match_scratch:GPR 0 "=d,d"))]
4962 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4966 [(set_attr "op_type" "RRE,RXY")])
4968 ; op1 + op2 + c < op2
4970 ; alcr, alc, alcgr, alcg
4971 (define_insn "*add<mode>3_alc_carry2_cc"
4972 [(set (reg CC_REGNUM)
4974 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4975 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4976 (match_operand:GPR 2 "general_operand" "d,RT"))
4978 (set (match_operand:GPR 0 "register_operand" "=d,d")
4979 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
4980 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4984 [(set_attr "op_type" "RRE,RXY")])
4986 ; alcr, alc, alcgr, alcg
4987 (define_insn "*add<mode>3_alc_carry2_cconly"
4988 [(set (reg CC_REGNUM)
4990 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
4991 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
4992 (match_operand:GPR 2 "general_operand" "d,RT"))
4994 (clobber (match_scratch:GPR 0 "=d,d"))]
4995 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
4999 [(set_attr "op_type" "RRE,RXY")])
5001 ; alcr, alc, alcgr, alcg
5002 (define_insn "*add<mode>3_alc_cc"
5003 [(set (reg CC_REGNUM)
5005 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5006 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5007 (match_operand:GPR 2 "general_operand" "d,RT"))
5009 (set (match_operand:GPR 0 "register_operand" "=d,d")
5010 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
5011 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5015 [(set_attr "op_type" "RRE,RXY")])
5017 ; alcr, alc, alcgr, alcg
5018 (define_insn "*add<mode>3_alc"
5019 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5020 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
5021 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
5022 (match_operand:GPR 2 "general_operand" "d,RT")))
5023 (clobber (reg:CC CC_REGNUM))]
5028 [(set_attr "op_type" "RRE,RXY")])
5030 ; slbr, slb, slbgr, slbg
5031 (define_insn "*sub<mode>3_slb_cc"
5032 [(set (reg CC_REGNUM)
5034 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5035 (match_operand:GPR 2 "general_operand" "d,RT"))
5036 (match_operand:GPR 3 "s390_slb_comparison" ""))
5038 (set (match_operand:GPR 0 "register_operand" "=d,d")
5039 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
5040 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
5044 [(set_attr "op_type" "RRE,RXY")
5045 (set_attr "z10prop" "z10_c,*")])
5047 ; slbr, slb, slbgr, slbg
5048 (define_insn "*sub<mode>3_slb"
5049 [(set (match_operand:GPR 0 "register_operand" "=d,d")
5050 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
5051 (match_operand:GPR 2 "general_operand" "d,RT"))
5052 (match_operand:GPR 3 "s390_slb_comparison" "")))
5053 (clobber (reg:CC CC_REGNUM))]
5058 [(set_attr "op_type" "RRE,RXY")
5059 (set_attr "z10prop" "z10_c,*")])
5061 (define_expand "add<mode>cc"
5062 [(match_operand:GPR 0 "register_operand" "")
5063 (match_operand 1 "comparison_operator" "")
5064 (match_operand:GPR 2 "register_operand" "")
5065 (match_operand:GPR 3 "const_int_operand" "")]
5067 "if (!s390_expand_addcc (GET_CODE (operands[1]),
5068 s390_compare_op0, s390_compare_op1,
5069 operands[0], operands[2],
5070 operands[3])) FAIL; DONE;")
5073 ; scond instruction pattern(s).
5076 (define_insn_and_split "*scond<mode>"
5077 [(set (match_operand:GPR 0 "register_operand" "=&d")
5078 (match_operand:GPR 1 "s390_alc_comparison" ""))
5079 (clobber (reg:CC CC_REGNUM))]
5082 "&& reload_completed"
5083 [(set (match_dup 0) (const_int 0))
5085 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
5087 (clobber (reg:CC CC_REGNUM))])]
5090 (define_insn_and_split "*scond<mode>_neg"
5091 [(set (match_operand:GPR 0 "register_operand" "=&d")
5092 (match_operand:GPR 1 "s390_slb_comparison" ""))
5093 (clobber (reg:CC CC_REGNUM))]
5096 "&& reload_completed"
5097 [(set (match_dup 0) (const_int 0))
5099 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
5101 (clobber (reg:CC CC_REGNUM))])
5103 [(set (match_dup 0) (neg:GPR (match_dup 0)))
5104 (clobber (reg:CC CC_REGNUM))])]
5108 (define_expand "s<code>"
5109 [(set (match_operand:SI 0 "register_operand" "")
5110 (SCOND (match_dup 0)
5113 "if (!s390_expand_addcc (<CODE>, s390_compare_op0, s390_compare_op1,
5114 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
5116 (define_expand "seq"
5118 [(set (match_operand:SI 0 "register_operand" "=d")
5120 (clobber (reg:CC CC_REGNUM))])
5122 [(set (match_dup 0) (xor:SI (match_dup 0) (const_int 1)))
5123 (clobber (reg:CC CC_REGNUM))])]
5126 if (!s390_compare_emitted || GET_MODE (s390_compare_emitted) != CCZ1mode)
5128 operands[1] = s390_emit_compare (NE, s390_compare_op0, s390_compare_op1);
5129 PUT_MODE (operands[1], SImode);
5132 (define_insn_and_split "*sne"
5133 [(set (match_operand:SI 0 "register_operand" "=d")
5134 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
5136 (clobber (reg:CC CC_REGNUM))]
5141 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
5142 (clobber (reg:CC CC_REGNUM))])])
5146 ;;- Multiply instructions.
5150 ; muldi3 instruction pattern(s).
5153 (define_insn "*muldi3_sign"
5154 [(set (match_operand:DI 0 "register_operand" "=d,d")
5155 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,RT"))
5156 (match_operand:DI 1 "register_operand" "0,0")))]
5161 [(set_attr "op_type" "RRE,RXY")
5162 (set_attr "type" "imuldi")])
5164 (define_insn "muldi3"
5165 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
5166 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
5167 (match_operand:DI 2 "general_operand" "d,K,RT,Os")))]
5174 [(set_attr "op_type" "RRE,RI,RXY,RIL")
5175 (set_attr "type" "imuldi")
5176 (set_attr "cpu_facility" "*,*,*,z10")])
5179 ; mulsi3 instruction pattern(s).
5182 (define_insn "*mulsi3_sign"
5183 [(set (match_operand:SI 0 "register_operand" "=d,d")
5184 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5185 (match_operand:SI 1 "register_operand" "0,0")))]
5190 [(set_attr "op_type" "RX,RXY")
5191 (set_attr "type" "imulhi")
5192 (set_attr "cpu_facility" "*,z10")])
5194 (define_insn "mulsi3"
5195 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
5196 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
5197 (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
5205 [(set_attr "op_type" "RRE,RI,RX,RXY,RIL")
5206 (set_attr "type" "imulsi,imulhi,imulsi,imulsi,imulsi")
5207 (set_attr "cpu_facility" "*,*,*,*,z10")])
5210 ; mulsidi3 instruction pattern(s).
5213 (define_insn "mulsidi3"
5214 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
5215 (mult:DI (sign_extend:DI
5216 (match_operand:SI 1 "register_operand" "%0,0,0"))
5218 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
5224 [(set_attr "op_type" "RR,RX,RXY")
5225 (set_attr "type" "imulsi")
5226 (set_attr "cpu_facility" "*,*,z10")])
5229 ; umulsidi3 instruction pattern(s).
5232 (define_insn "umulsidi3"
5233 [(set (match_operand:DI 0 "register_operand" "=d,d")
5234 (mult:DI (zero_extend:DI
5235 (match_operand:SI 1 "register_operand" "%0,0"))
5237 (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))]
5238 "!TARGET_64BIT && TARGET_CPU_ZARCH"
5242 [(set_attr "op_type" "RRE,RXY")
5243 (set_attr "type" "imulsi")])
5246 ; mul(tf|df|sf|td|dd)3 instruction pattern(s).
5249 ; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
5250 (define_insn "mul<mode>3"
5251 [(set (match_operand:FP 0 "register_operand" "=f,f")
5252 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%<f0>,0")
5253 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
5256 m<xdee><bt>r\t%0,<op1>%2
5258 [(set_attr "op_type" "<RRer>,RXE")
5259 (set_attr "type" "fmul<mode>")])
5261 ; madbr, maebr, maxb, madb, maeb
5262 (define_insn "*fmadd<mode>"
5263 [(set (match_operand:DSF 0 "register_operand" "=f,f")
5264 (plus:DSF (mult:DSF (match_operand:DSF 1 "register_operand" "%f,f")
5265 (match_operand:DSF 2 "nonimmediate_operand" "f,R"))
5266 (match_operand:DSF 3 "register_operand" "0,0")))]
5267 "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5271 [(set_attr "op_type" "RRE,RXE")
5272 (set_attr "type" "fmul<mode>")])
5274 ; msxbr, msdbr, msebr, msxb, msdb, mseb
5275 (define_insn "*fmsub<mode>"
5276 [(set (match_operand:DSF 0 "register_operand" "=f,f")
5277 (minus:DSF (mult:DSF (match_operand:DSF 1 "register_operand" "f,f")
5278 (match_operand:DSF 2 "nonimmediate_operand" "f,R"))
5279 (match_operand:DSF 3 "register_operand" "0,0")))]
5280 "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5284 [(set_attr "op_type" "RRE,RXE")
5285 (set_attr "type" "fmul<mode>")])
5288 ;;- Divide and modulo instructions.
5292 ; divmoddi4 instruction pattern(s).
5295 (define_expand "divmoddi4"
5296 [(parallel [(set (match_operand:DI 0 "general_operand" "")
5297 (div:DI (match_operand:DI 1 "register_operand" "")
5298 (match_operand:DI 2 "general_operand" "")))
5299 (set (match_operand:DI 3 "general_operand" "")
5300 (mod:DI (match_dup 1) (match_dup 2)))])
5301 (clobber (match_dup 4))]
5304 rtx insn, div_equal, mod_equal;
5306 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
5307 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
5309 operands[4] = gen_reg_rtx(TImode);
5310 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
5312 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5313 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5315 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5316 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5321 (define_insn "divmodtidi3"
5322 [(set (match_operand:TI 0 "register_operand" "=d,d")
5326 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5327 (match_operand:DI 2 "general_operand" "d,RT")))
5329 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
5334 [(set_attr "op_type" "RRE,RXY")
5335 (set_attr "type" "idiv")])
5337 (define_insn "divmodtisi3"
5338 [(set (match_operand:TI 0 "register_operand" "=d,d")
5342 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5344 (match_operand:SI 2 "nonimmediate_operand" "d,RT"))))
5347 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
5352 [(set_attr "op_type" "RRE,RXY")
5353 (set_attr "type" "idiv")])
5356 ; udivmoddi4 instruction pattern(s).
5359 (define_expand "udivmoddi4"
5360 [(parallel [(set (match_operand:DI 0 "general_operand" "")
5361 (udiv:DI (match_operand:DI 1 "general_operand" "")
5362 (match_operand:DI 2 "nonimmediate_operand" "")))
5363 (set (match_operand:DI 3 "general_operand" "")
5364 (umod:DI (match_dup 1) (match_dup 2)))])
5365 (clobber (match_dup 4))]
5368 rtx insn, div_equal, mod_equal, equal;
5370 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
5371 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
5372 equal = gen_rtx_IOR (TImode,
5373 gen_rtx_ASHIFT (TImode,
5374 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
5376 gen_rtx_ZERO_EXTEND (TImode, div_equal));
5378 operands[4] = gen_reg_rtx(TImode);
5379 emit_clobber (operands[4]);
5380 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
5381 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
5383 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
5384 set_unique_reg_note (insn, REG_EQUAL, equal);
5386 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
5387 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5389 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
5390 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5395 (define_insn "udivmodtidi3"
5396 [(set (match_operand:TI 0 "register_operand" "=d,d")
5401 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
5403 (match_operand:DI 2 "nonimmediate_operand" "d,RT")))))
5407 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
5412 [(set_attr "op_type" "RRE,RXY")
5413 (set_attr "type" "idiv")])
5416 ; divmodsi4 instruction pattern(s).
5419 (define_expand "divmodsi4"
5420 [(parallel [(set (match_operand:SI 0 "general_operand" "")
5421 (div:SI (match_operand:SI 1 "general_operand" "")
5422 (match_operand:SI 2 "nonimmediate_operand" "")))
5423 (set (match_operand:SI 3 "general_operand" "")
5424 (mod:SI (match_dup 1) (match_dup 2)))])
5425 (clobber (match_dup 4))]
5428 rtx insn, div_equal, mod_equal, equal;
5430 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
5431 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
5432 equal = gen_rtx_IOR (DImode,
5433 gen_rtx_ASHIFT (DImode,
5434 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5436 gen_rtx_ZERO_EXTEND (DImode, div_equal));
5438 operands[4] = gen_reg_rtx(DImode);
5439 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
5441 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
5442 set_unique_reg_note (insn, REG_EQUAL, equal);
5444 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5445 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5447 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5448 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5453 (define_insn "divmoddisi3"
5454 [(set (match_operand:DI 0 "register_operand" "=d,d")
5459 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
5461 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
5465 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
5470 [(set_attr "op_type" "RR,RX")
5471 (set_attr "type" "idiv")])
5474 ; udivsi3 and umodsi3 instruction pattern(s).
5477 (define_expand "udivmodsi4"
5478 [(parallel [(set (match_operand:SI 0 "general_operand" "")
5479 (udiv:SI (match_operand:SI 1 "general_operand" "")
5480 (match_operand:SI 2 "nonimmediate_operand" "")))
5481 (set (match_operand:SI 3 "general_operand" "")
5482 (umod:SI (match_dup 1) (match_dup 2)))])
5483 (clobber (match_dup 4))]
5484 "!TARGET_64BIT && TARGET_CPU_ZARCH"
5486 rtx insn, div_equal, mod_equal, equal;
5488 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5489 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5490 equal = gen_rtx_IOR (DImode,
5491 gen_rtx_ASHIFT (DImode,
5492 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
5494 gen_rtx_ZERO_EXTEND (DImode, div_equal));
5496 operands[4] = gen_reg_rtx(DImode);
5497 emit_clobber (operands[4]);
5498 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
5499 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
5501 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
5502 set_unique_reg_note (insn, REG_EQUAL, equal);
5504 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
5505 set_unique_reg_note (insn, REG_EQUAL, div_equal);
5507 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
5508 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
5513 (define_insn "udivmoddisi3"
5514 [(set (match_operand:DI 0 "register_operand" "=d,d")
5519 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
5521 (match_operand:SI 2 "nonimmediate_operand" "d,RT")))))
5525 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
5526 "!TARGET_64BIT && TARGET_CPU_ZARCH"
5530 [(set_attr "op_type" "RRE,RXY")
5531 (set_attr "type" "idiv")])
5533 (define_expand "udivsi3"
5534 [(set (match_operand:SI 0 "register_operand" "=d")
5535 (udiv:SI (match_operand:SI 1 "general_operand" "")
5536 (match_operand:SI 2 "general_operand" "")))
5537 (clobber (match_dup 3))]
5538 "!TARGET_64BIT && !TARGET_CPU_ZARCH"
5540 rtx insn, udiv_equal, umod_equal, equal;
5542 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5543 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5544 equal = gen_rtx_IOR (DImode,
5545 gen_rtx_ASHIFT (DImode,
5546 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5548 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5550 operands[3] = gen_reg_rtx (DImode);
5552 if (CONSTANT_P (operands[2]))
5554 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
5556 rtx label1 = gen_label_rtx ();
5558 operands[1] = make_safe_from (operands[1], operands[0]);
5559 emit_move_insn (operands[0], const0_rtx);
5560 emit_insn (gen_cmpsi (operands[1], operands[2]));
5561 emit_jump_insn (gen_bltu (label1));
5562 emit_move_insn (operands[0], const1_rtx);
5563 emit_label (label1);
5567 operands[2] = force_reg (SImode, operands[2]);
5568 operands[2] = make_safe_from (operands[2], operands[0]);
5570 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5571 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5573 set_unique_reg_note (insn, REG_EQUAL, equal);
5575 insn = emit_move_insn (operands[0],
5576 gen_lowpart (SImode, operands[3]));
5577 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5582 rtx label1 = gen_label_rtx ();
5583 rtx label2 = gen_label_rtx ();
5584 rtx label3 = gen_label_rtx ();
5586 operands[1] = force_reg (SImode, operands[1]);
5587 operands[1] = make_safe_from (operands[1], operands[0]);
5588 operands[2] = force_reg (SImode, operands[2]);
5589 operands[2] = make_safe_from (operands[2], operands[0]);
5591 emit_move_insn (operands[0], const0_rtx);
5592 emit_insn (gen_cmpsi (operands[2], operands[1]));
5593 emit_jump_insn (gen_bgtu (label3));
5594 emit_insn (gen_cmpsi (operands[2], const0_rtx));
5595 emit_jump_insn (gen_blt (label2));
5596 emit_insn (gen_cmpsi (operands[2], const1_rtx));
5597 emit_jump_insn (gen_beq (label1));
5598 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5599 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5601 set_unique_reg_note (insn, REG_EQUAL, equal);
5603 insn = emit_move_insn (operands[0],
5604 gen_lowpart (SImode, operands[3]));
5605 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
5608 emit_label (label1);
5609 emit_move_insn (operands[0], operands[1]);
5611 emit_label (label2);
5612 emit_move_insn (operands[0], const1_rtx);
5613 emit_label (label3);
5615 emit_move_insn (operands[0], operands[0]);
5619 (define_expand "umodsi3"
5620 [(set (match_operand:SI 0 "register_operand" "=d")
5621 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
5622 (match_operand:SI 2 "nonimmediate_operand" "")))
5623 (clobber (match_dup 3))]
5624 "!TARGET_64BIT && !TARGET_CPU_ZARCH"
5626 rtx insn, udiv_equal, umod_equal, equal;
5628 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
5629 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
5630 equal = gen_rtx_IOR (DImode,
5631 gen_rtx_ASHIFT (DImode,
5632 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
5634 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
5636 operands[3] = gen_reg_rtx (DImode);
5638 if (CONSTANT_P (operands[2]))
5640 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
5642 rtx label1 = gen_label_rtx ();
5644 operands[1] = make_safe_from (operands[1], operands[0]);
5645 emit_move_insn (operands[0], operands[1]);
5646 emit_insn (gen_cmpsi (operands[0], operands[2]));
5647 emit_jump_insn (gen_bltu (label1));
5648 emit_insn (gen_abssi2 (operands[0], operands[2]));
5649 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
5650 emit_label (label1);
5654 operands[2] = force_reg (SImode, operands[2]);
5655 operands[2] = make_safe_from (operands[2], operands[0]);
5657 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5658 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5660 set_unique_reg_note (insn, REG_EQUAL, equal);
5662 insn = emit_move_insn (operands[0],
5663 gen_highpart (SImode, operands[3]));
5664 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
5669 rtx label1 = gen_label_rtx ();
5670 rtx label2 = gen_label_rtx ();
5671 rtx label3 = gen_label_rtx ();
5673 operands[1] = force_reg (SImode, operands[1]);
5674 operands[1] = make_safe_from (operands[1], operands[0]);
5675 operands[2] = force_reg (SImode, operands[2]);
5676 operands[2] = make_safe_from (operands[2], operands[0]);
5678 emit_move_insn(operands[0], operands[1]);
5679 emit_insn (gen_cmpsi (operands[2], operands[1]));
5680 emit_jump_insn (gen_bgtu (label3));
5681 emit_insn (gen_cmpsi (operands[2], const0_rtx));
5682 emit_jump_insn (gen_blt (label2));
5683 emit_insn (gen_cmpsi (operands[2], const1_rtx));
5684 emit_jump_insn (gen_beq (label1));
5685 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
5686 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
5688 set_unique_reg_note (insn, REG_EQUAL, equal);
5690 insn = emit_move_insn (operands[0],
5691 gen_highpart (SImode, operands[3]));
5692 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
5695 emit_label (label1);
5696 emit_move_insn (operands[0], const0_rtx);
5698 emit_label (label2);
5699 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
5700 emit_label (label3);
5706 ; div(df|sf)3 instruction pattern(s).
5709 ; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
5710 (define_insn "div<mode>3"
5711 [(set (match_operand:FP 0 "register_operand" "=f,f")
5712 (div:FP (match_operand:FP 1 "register_operand" "<f0>,0")
5713 (match_operand:FP 2 "general_operand" "f,<Rf>")))]
5716 d<xde><bt>r\t%0,<op1>%2
5718 [(set_attr "op_type" "<RRer>,RXE")
5719 (set_attr "type" "fdiv<mode>")])
5723 ;;- And instructions.
5726 (define_expand "and<mode>3"
5727 [(set (match_operand:INT 0 "nonimmediate_operand" "")
5728 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
5729 (match_operand:INT 2 "general_operand" "")))
5730 (clobber (reg:CC CC_REGNUM))]
5732 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
5735 ; anddi3 instruction pattern(s).
5738 (define_insn "*anddi3_cc"
5739 [(set (reg CC_REGNUM)
5740 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5741 (match_operand:DI 2 "general_operand" "d,RT"))
5743 (set (match_operand:DI 0 "register_operand" "=d,d")
5744 (and:DI (match_dup 1) (match_dup 2)))]
5745 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
5749 [(set_attr "op_type" "RRE,RXY")
5750 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5752 (define_insn "*anddi3_cconly"
5753 [(set (reg CC_REGNUM)
5754 (compare (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
5755 (match_operand:DI 2 "general_operand" "d,RT"))
5757 (clobber (match_scratch:DI 0 "=d,d"))]
5758 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT
5759 /* Do not steal TM patterns. */
5760 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
5764 [(set_attr "op_type" "RRE,RXY")
5765 (set_attr "z10prop" "z10_super_E1, z10_super_E1")])
5767 (define_insn "*anddi3"
5768 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,d,d,AQ,Q")
5769 (and:DI (match_operand:DI 1 "nonimmediate_operand"
5770 "%d,o,0,0,0,0,0,0,0,0,0,0")
5771 (match_operand:DI 2 "general_operand"
5772 "M,M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,RT,NxQDF,Q")))
5773 (clobber (reg:CC CC_REGNUM))]
5774 "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
5788 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")
5789 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,*,*,*")
5790 (set_attr "z10prop" "*,
5804 [(set (match_operand:DI 0 "s_operand" "")
5805 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
5806 (clobber (reg:CC CC_REGNUM))]
5809 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5810 (clobber (reg:CC CC_REGNUM))])]
5811 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5815 ; andsi3 instruction pattern(s).
5818 (define_insn "*andsi3_cc"
5819 [(set (reg CC_REGNUM)
5820 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5821 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5823 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
5824 (and:SI (match_dup 1) (match_dup 2)))]
5825 "s390_match_ccmode(insn, CCTmode)"
5831 [(set_attr "op_type" "RIL,RR,RX,RXY")
5832 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
5834 (define_insn "*andsi3_cconly"
5835 [(set (reg CC_REGNUM)
5836 (compare (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5837 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
5839 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
5840 "s390_match_ccmode(insn, CCTmode)
5841 /* Do not steal TM patterns. */
5842 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
5848 [(set_attr "op_type" "RIL,RR,RX,RXY")
5849 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
5851 (define_insn "*andsi3_zarch"
5852 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
5853 (and:SI (match_operand:SI 1 "nonimmediate_operand"
5854 "%d,o,0,0,0,0,0,0,0,0")
5855 (match_operand:SI 2 "general_operand"
5856 "M,M,N0HSF,N1HSF,Os,d,R,T,NxQSF,Q")))
5857 (clobber (reg:CC CC_REGNUM))]
5858 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5870 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RX,RXY,SI,SS")
5871 (set_attr "z10prop" "*,
5882 (define_insn "*andsi3_esa"
5883 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5884 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
5885 (match_operand:SI 2 "general_operand" "d,R,NxQSF,Q")))
5886 (clobber (reg:CC CC_REGNUM))]
5887 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5893 [(set_attr "op_type" "RR,RX,SI,SS")
5894 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
5898 [(set (match_operand:SI 0 "s_operand" "")
5899 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
5900 (clobber (reg:CC CC_REGNUM))]
5903 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5904 (clobber (reg:CC CC_REGNUM))])]
5905 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5908 ; andhi3 instruction pattern(s).
5911 (define_insn "*andhi3_zarch"
5912 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
5913 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
5914 (match_operand:HI 2 "general_operand" "d,n,NxQHF,Q")))
5915 (clobber (reg:CC CC_REGNUM))]
5916 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5922 [(set_attr "op_type" "RR,RI,SI,SS")
5923 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")
5926 (define_insn "*andhi3_esa"
5927 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
5928 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
5929 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
5930 (clobber (reg:CC CC_REGNUM))]
5931 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5936 [(set_attr "op_type" "RR,SI,SS")
5937 (set_attr "z10prop" "z10_super_E1,*,*")
5941 [(set (match_operand:HI 0 "s_operand" "")
5942 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
5943 (clobber (reg:CC CC_REGNUM))]
5946 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
5947 (clobber (reg:CC CC_REGNUM))])]
5948 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
5951 ; andqi3 instruction pattern(s).
5954 (define_insn "*andqi3_zarch"
5955 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
5956 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
5957 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
5958 (clobber (reg:CC CC_REGNUM))]
5959 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5966 [(set_attr "op_type" "RR,RI,SI,SIY,SS")
5967 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
5969 (define_insn "*andqi3_esa"
5970 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
5971 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
5972 (match_operand:QI 2 "general_operand" "d,n,Q")))
5973 (clobber (reg:CC CC_REGNUM))]
5974 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
5979 [(set_attr "op_type" "RR,SI,SS")
5980 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
5983 ; Block and (NC) patterns.
5987 [(set (match_operand:BLK 0 "memory_operand" "=Q")
5988 (and:BLK (match_dup 0)
5989 (match_operand:BLK 1 "memory_operand" "Q")))
5990 (use (match_operand 2 "const_int_operand" "n"))
5991 (clobber (reg:CC CC_REGNUM))]
5992 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
5993 "nc\t%O0(%2,%R0),%S1"
5994 [(set_attr "op_type" "SS")])
5997 [(set (match_operand 0 "memory_operand" "")
5999 (match_operand 1 "memory_operand" "")))
6000 (clobber (reg:CC CC_REGNUM))]
6002 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6003 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6005 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
6007 (clobber (reg:CC CC_REGNUM))])]
6009 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6010 operands[0] = adjust_address (operands[0], BLKmode, 0);
6011 operands[1] = adjust_address (operands[1], BLKmode, 0);
6016 [(set (match_operand:BLK 0 "memory_operand" "")
6017 (and:BLK (match_dup 0)
6018 (match_operand:BLK 1 "memory_operand" "")))
6019 (use (match_operand 2 "const_int_operand" ""))
6020 (clobber (reg:CC CC_REGNUM))])
6022 [(set (match_operand:BLK 3 "memory_operand" "")
6023 (and:BLK (match_dup 3)
6024 (match_operand:BLK 4 "memory_operand" "")))
6025 (use (match_operand 5 "const_int_operand" ""))
6026 (clobber (reg:CC CC_REGNUM))])]
6027 "s390_offset_p (operands[0], operands[3], operands[2])
6028 && s390_offset_p (operands[1], operands[4], operands[2])
6029 && !s390_overlap_p (operands[0], operands[1],
6030 INTVAL (operands[2]) + INTVAL (operands[5]))
6031 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6033 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
6035 (clobber (reg:CC CC_REGNUM))])]
6036 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6037 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6038 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6042 ;;- Bit set (inclusive or) instructions.
6045 (define_expand "ior<mode>3"
6046 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6047 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
6048 (match_operand:INT 2 "general_operand" "")))
6049 (clobber (reg:CC CC_REGNUM))]
6051 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
6054 ; iordi3 instruction pattern(s).
6057 (define_insn "*iordi3_cc"
6058 [(set (reg CC_REGNUM)
6059 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6060 (match_operand:DI 2 "general_operand" "d,RT"))
6062 (set (match_operand:DI 0 "register_operand" "=d,d")
6063 (ior:DI (match_dup 1) (match_dup 2)))]
6064 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6068 [(set_attr "op_type" "RRE,RXY")
6069 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6071 (define_insn "*iordi3_cconly"
6072 [(set (reg CC_REGNUM)
6073 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6074 (match_operand:DI 2 "general_operand" "d,RT"))
6076 (clobber (match_scratch:DI 0 "=d,d"))]
6077 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6081 [(set_attr "op_type" "RRE,RXY")
6082 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6084 (define_insn "*iordi3"
6085 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,d,d,d,AQ,Q")
6086 (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0,0,0")
6087 (match_operand:DI 2 "general_operand"
6088 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,RT,NxQD0,Q")))
6089 (clobber (reg:CC CC_REGNUM))]
6090 "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
6102 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RXY,SI,SS")
6103 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,*,*,*")
6104 (set_attr "z10prop" "z10_super_E1,
6116 [(set (match_operand:DI 0 "s_operand" "")
6117 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6118 (clobber (reg:CC CC_REGNUM))]
6121 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6122 (clobber (reg:CC CC_REGNUM))])]
6123 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6126 ; iorsi3 instruction pattern(s).
6129 (define_insn "*iorsi3_cc"
6130 [(set (reg CC_REGNUM)
6131 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6132 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6134 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
6135 (ior:SI (match_dup 1) (match_dup 2)))]
6136 "s390_match_ccmode(insn, CCTmode)"
6142 [(set_attr "op_type" "RIL,RR,RX,RXY")
6143 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6145 (define_insn "*iorsi3_cconly"
6146 [(set (reg CC_REGNUM)
6147 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6148 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6150 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
6151 "s390_match_ccmode(insn, CCTmode)"
6157 [(set_attr "op_type" "RIL,RR,RX,RXY")
6158 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6160 (define_insn "*iorsi3_zarch"
6161 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d,d,AQ,Q")
6162 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0,0,0")
6163 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,R,T,NxQS0,Q")))
6164 (clobber (reg:CC CC_REGNUM))]
6165 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6175 [(set_attr "op_type" "RI,RI,RIL,RR,RX,RXY,SI,SS")
6176 (set_attr "z10prop" "z10_super_E1,
6185 (define_insn "*iorsi3_esa"
6186 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6187 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6188 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
6189 (clobber (reg:CC CC_REGNUM))]
6190 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6196 [(set_attr "op_type" "RR,RX,SI,SS")
6197 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6200 [(set (match_operand:SI 0 "s_operand" "")
6201 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6202 (clobber (reg:CC CC_REGNUM))]
6205 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6206 (clobber (reg:CC CC_REGNUM))])]
6207 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6210 ; iorhi3 instruction pattern(s).
6213 (define_insn "*iorhi3_zarch"
6214 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6215 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
6216 (match_operand:HI 2 "general_operand" "d,n,NxQH0,Q")))
6217 (clobber (reg:CC CC_REGNUM))]
6218 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6224 [(set_attr "op_type" "RR,RI,SI,SS")
6225 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6227 (define_insn "*iorhi3_esa"
6228 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
6229 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
6230 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
6231 (clobber (reg:CC CC_REGNUM))]
6232 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6237 [(set_attr "op_type" "RR,SI,SS")
6238 (set_attr "z10prop" "z10_super_E1,*,*")])
6241 [(set (match_operand:HI 0 "s_operand" "")
6242 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6243 (clobber (reg:CC CC_REGNUM))]
6246 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
6247 (clobber (reg:CC CC_REGNUM))])]
6248 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
6251 ; iorqi3 instruction pattern(s).
6254 (define_insn "*iorqi3_zarch"
6255 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
6256 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
6257 (match_operand:QI 2 "general_operand" "d,n,n,n,Q")))
6258 (clobber (reg:CC CC_REGNUM))]
6259 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6266 [(set_attr "op_type" "RR,RI,SI,SIY,SS")
6267 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
6269 (define_insn "*iorqi3_esa"
6270 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
6271 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
6272 (match_operand:QI 2 "general_operand" "d,n,Q")))
6273 (clobber (reg:CC CC_REGNUM))]
6274 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
6279 [(set_attr "op_type" "RR,SI,SS")
6280 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
6283 ; Block inclusive or (OC) patterns.
6287 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6288 (ior:BLK (match_dup 0)
6289 (match_operand:BLK 1 "memory_operand" "Q")))
6290 (use (match_operand 2 "const_int_operand" "n"))
6291 (clobber (reg:CC CC_REGNUM))]
6292 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6293 "oc\t%O0(%2,%R0),%S1"
6294 [(set_attr "op_type" "SS")])
6297 [(set (match_operand 0 "memory_operand" "")
6299 (match_operand 1 "memory_operand" "")))
6300 (clobber (reg:CC CC_REGNUM))]
6302 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6303 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6305 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
6307 (clobber (reg:CC CC_REGNUM))])]
6309 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6310 operands[0] = adjust_address (operands[0], BLKmode, 0);
6311 operands[1] = adjust_address (operands[1], BLKmode, 0);
6316 [(set (match_operand:BLK 0 "memory_operand" "")
6317 (ior:BLK (match_dup 0)
6318 (match_operand:BLK 1 "memory_operand" "")))
6319 (use (match_operand 2 "const_int_operand" ""))
6320 (clobber (reg:CC CC_REGNUM))])
6322 [(set (match_operand:BLK 3 "memory_operand" "")
6323 (ior:BLK (match_dup 3)
6324 (match_operand:BLK 4 "memory_operand" "")))
6325 (use (match_operand 5 "const_int_operand" ""))
6326 (clobber (reg:CC CC_REGNUM))])]
6327 "s390_offset_p (operands[0], operands[3], operands[2])
6328 && s390_offset_p (operands[1], operands[4], operands[2])
6329 && !s390_overlap_p (operands[0], operands[1],
6330 INTVAL (operands[2]) + INTVAL (operands[5]))
6331 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6333 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
6335 (clobber (reg:CC CC_REGNUM))])]
6336 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6337 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6338 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6342 ;;- Xor instructions.
6345 (define_expand "xor<mode>3"
6346 [(set (match_operand:INT 0 "nonimmediate_operand" "")
6347 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
6348 (match_operand:INT 2 "general_operand" "")))
6349 (clobber (reg:CC CC_REGNUM))]
6351 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
6354 ; xordi3 instruction pattern(s).
6357 (define_insn "*xordi3_cc"
6358 [(set (reg CC_REGNUM)
6359 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6360 (match_operand:DI 2 "general_operand" "d,RT"))
6362 (set (match_operand:DI 0 "register_operand" "=d,d")
6363 (xor:DI (match_dup 1) (match_dup 2)))]
6364 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6368 [(set_attr "op_type" "RRE,RXY")
6369 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6371 (define_insn "*xordi3_cconly"
6372 [(set (reg CC_REGNUM)
6373 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0")
6374 (match_operand:DI 2 "general_operand" "d,RT"))
6376 (clobber (match_scratch:DI 0 "=d,d"))]
6377 "s390_match_ccmode(insn, CCTmode) && TARGET_64BIT"
6381 [(set_attr "op_type" "RRE,RXY")
6382 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
6384 (define_insn "*xordi3"
6385 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
6386 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
6387 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,RT,NxQD0,Q")))
6388 (clobber (reg:CC CC_REGNUM))]
6389 "TARGET_64BIT && s390_logical_operator_ok_p (operands)"
6397 [(set_attr "op_type" "RIL,RIL,RRE,RXY,SI,SS")
6398 (set_attr "cpu_facility" "extimm,extimm,*,*,*,*")
6399 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1,*,*")])
6402 [(set (match_operand:DI 0 "s_operand" "")
6403 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
6404 (clobber (reg:CC CC_REGNUM))]
6407 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6408 (clobber (reg:CC CC_REGNUM))])]
6409 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6412 ; xorsi3 instruction pattern(s).
6415 (define_insn "*xorsi3_cc"
6416 [(set (reg CC_REGNUM)
6417 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6418 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6420 (set (match_operand:SI 0 "register_operand" "=d,d,d,d")
6421 (xor:SI (match_dup 1) (match_dup 2)))]
6422 "s390_match_ccmode(insn, CCTmode)"
6428 [(set_attr "op_type" "RIL,RR,RX,RXY")
6429 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6431 (define_insn "*xorsi3_cconly"
6432 [(set (reg CC_REGNUM)
6433 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
6434 (match_operand:SI 2 "general_operand" "Os,d,R,T"))
6436 (clobber (match_scratch:SI 0 "=d,d,d,d"))]
6437 "s390_match_ccmode(insn, CCTmode)"
6443 [(set_attr "op_type" "RIL,RR,RX,RXY")
6444 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
6446 (define_insn "*xorsi3"
6447 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,AQ,Q")
6448 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
6449 (match_operand:SI 2 "general_operand" "Os,d,R,T,NxQS0,Q")))
6450 (clobber (reg:CC CC_REGNUM))]
6451 "s390_logical_operator_ok_p (operands)"
6459 [(set_attr "op_type" "RIL,RR,RX,RXY,SI,SS")
6460 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1,*,*")])
6463 [(set (match_operand:SI 0 "s_operand" "")
6464 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
6465 (clobber (reg:CC CC_REGNUM))]
6468 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6469 (clobber (reg:CC CC_REGNUM))])]
6470 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6473 ; xorhi3 instruction pattern(s).
6476 (define_insn "*xorhi3"
6477 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,AQ,Q")
6478 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0,0")
6479 (match_operand:HI 2 "general_operand" "Os,d,NxQH0,Q")))
6480 (clobber (reg:CC CC_REGNUM))]
6481 "s390_logical_operator_ok_p (operands)"
6487 [(set_attr "op_type" "RIL,RR,SI,SS")
6488 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
6491 [(set (match_operand:HI 0 "s_operand" "")
6492 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
6493 (clobber (reg:CC CC_REGNUM))]
6496 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
6497 (clobber (reg:CC CC_REGNUM))])]
6498 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
6501 ; xorqi3 instruction pattern(s).
6504 (define_insn "*xorqi3"
6505 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,Q,S,Q")
6506 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,0,0")
6507 (match_operand:QI 2 "general_operand" "Os,d,n,n,Q")))
6508 (clobber (reg:CC CC_REGNUM))]
6509 "s390_logical_operator_ok_p (operands)"
6516 [(set_attr "op_type" "RIL,RR,SI,SIY,SS")
6517 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super,z10_super,*")])
6521 ; Block exclusive or (XC) patterns.
6525 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6526 (xor:BLK (match_dup 0)
6527 (match_operand:BLK 1 "memory_operand" "Q")))
6528 (use (match_operand 2 "const_int_operand" "n"))
6529 (clobber (reg:CC CC_REGNUM))]
6530 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
6531 "xc\t%O0(%2,%R0),%S1"
6532 [(set_attr "op_type" "SS")])
6535 [(set (match_operand 0 "memory_operand" "")
6537 (match_operand 1 "memory_operand" "")))
6538 (clobber (reg:CC CC_REGNUM))]
6540 && GET_MODE (operands[0]) == GET_MODE (operands[1])
6541 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
6543 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
6545 (clobber (reg:CC CC_REGNUM))])]
6547 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
6548 operands[0] = adjust_address (operands[0], BLKmode, 0);
6549 operands[1] = adjust_address (operands[1], BLKmode, 0);
6554 [(set (match_operand:BLK 0 "memory_operand" "")
6555 (xor:BLK (match_dup 0)
6556 (match_operand:BLK 1 "memory_operand" "")))
6557 (use (match_operand 2 "const_int_operand" ""))
6558 (clobber (reg:CC CC_REGNUM))])
6560 [(set (match_operand:BLK 3 "memory_operand" "")
6561 (xor:BLK (match_dup 3)
6562 (match_operand:BLK 4 "memory_operand" "")))
6563 (use (match_operand 5 "const_int_operand" ""))
6564 (clobber (reg:CC CC_REGNUM))])]
6565 "s390_offset_p (operands[0], operands[3], operands[2])
6566 && s390_offset_p (operands[1], operands[4], operands[2])
6567 && !s390_overlap_p (operands[0], operands[1],
6568 INTVAL (operands[2]) + INTVAL (operands[5]))
6569 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
6571 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
6573 (clobber (reg:CC CC_REGNUM))])]
6574 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6575 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
6576 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
6579 ; Block xor (XC) patterns with src == dest.
6582 (define_insn "*xc_zero"
6583 [(set (match_operand:BLK 0 "memory_operand" "=Q")
6585 (use (match_operand 1 "const_int_operand" "n"))
6586 (clobber (reg:CC CC_REGNUM))]
6587 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
6588 "xc\t%O0(%1,%R0),%S0"
6589 [(set_attr "op_type" "SS")])
6593 [(set (match_operand:BLK 0 "memory_operand" "")
6595 (use (match_operand 1 "const_int_operand" ""))
6596 (clobber (reg:CC CC_REGNUM))])
6598 [(set (match_operand:BLK 2 "memory_operand" "")
6600 (use (match_operand 3 "const_int_operand" ""))
6601 (clobber (reg:CC CC_REGNUM))])]
6602 "s390_offset_p (operands[0], operands[2], operands[1])
6603 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
6605 [(set (match_dup 4) (const_int 0))
6607 (clobber (reg:CC CC_REGNUM))])]
6608 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
6609 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
6613 ;;- Negate instructions.
6617 ; neg(di|si)2 instruction pattern(s).
6620 (define_expand "neg<mode>2"
6622 [(set (match_operand:DSI 0 "register_operand" "=d")
6623 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
6624 (clobber (reg:CC CC_REGNUM))])]
6628 (define_insn "*negdi2_sign_cc"
6629 [(set (reg CC_REGNUM)
6630 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
6631 (match_operand:SI 1 "register_operand" "d") 0)
6632 (const_int 32)) (const_int 32)))
6634 (set (match_operand:DI 0 "register_operand" "=d")
6635 (neg:DI (sign_extend:DI (match_dup 1))))]
6636 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6638 [(set_attr "op_type" "RRE")
6639 (set_attr "z10prop" "z10_c")])
6641 (define_insn "*negdi2_sign"
6642 [(set (match_operand:DI 0 "register_operand" "=d")
6643 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6644 (clobber (reg:CC CC_REGNUM))]
6647 [(set_attr "op_type" "RRE")
6648 (set_attr "z10prop" "z10_c")])
6651 (define_insn "*neg<mode>2_cc"
6652 [(set (reg CC_REGNUM)
6653 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
6655 (set (match_operand:GPR 0 "register_operand" "=d")
6656 (neg:GPR (match_dup 1)))]
6657 "s390_match_ccmode (insn, CCAmode)"
6659 [(set_attr "op_type" "RR<E>")
6660 (set_attr "z10prop" "z10_super_c_E1")])
6663 (define_insn "*neg<mode>2_cconly"
6664 [(set (reg CC_REGNUM)
6665 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
6667 (clobber (match_scratch:GPR 0 "=d"))]
6668 "s390_match_ccmode (insn, CCAmode)"
6670 [(set_attr "op_type" "RR<E>")
6671 (set_attr "z10prop" "z10_super_c_E1")])
6674 (define_insn "*neg<mode>2"
6675 [(set (match_operand:GPR 0 "register_operand" "=d")
6676 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
6677 (clobber (reg:CC CC_REGNUM))]
6680 [(set_attr "op_type" "RR<E>")
6681 (set_attr "z10prop" "z10_super_c_E1")])
6683 (define_insn_and_split "*negdi2_31"
6684 [(set (match_operand:DI 0 "register_operand" "=d")
6685 (neg:DI (match_operand:DI 1 "register_operand" "d")))
6686 (clobber (reg:CC CC_REGNUM))]
6689 "&& reload_completed"
6691 [(set (match_dup 2) (neg:SI (match_dup 3)))
6692 (clobber (reg:CC CC_REGNUM))])
6694 [(set (reg:CCAP CC_REGNUM)
6695 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
6696 (set (match_dup 4) (neg:SI (match_dup 5)))])
6698 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
6700 (label_ref (match_dup 6))))
6702 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
6703 (clobber (reg:CC CC_REGNUM))])
6705 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
6706 operands[3] = operand_subword (operands[1], 0, 0, DImode);
6707 operands[4] = operand_subword (operands[0], 1, 0, DImode);
6708 operands[5] = operand_subword (operands[1], 1, 0, DImode);
6709 operands[6] = gen_label_rtx ();")
6712 ; neg(df|sf)2 instruction pattern(s).
6715 (define_expand "neg<mode>2"
6717 [(set (match_operand:BFP 0 "register_operand" "=f")
6718 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6719 (clobber (reg:CC CC_REGNUM))])]
6723 ; lcxbr, lcdbr, lcebr
6724 (define_insn "*neg<mode>2_cc"
6725 [(set (reg CC_REGNUM)
6726 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
6727 (match_operand:BFP 2 "const0_operand" "")))
6728 (set (match_operand:BFP 0 "register_operand" "=f")
6729 (neg:BFP (match_dup 1)))]
6730 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6732 [(set_attr "op_type" "RRE")
6733 (set_attr "type" "fsimp<mode>")])
6735 ; lcxbr, lcdbr, lcebr
6736 (define_insn "*neg<mode>2_cconly"
6737 [(set (reg CC_REGNUM)
6738 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
6739 (match_operand:BFP 2 "const0_operand" "")))
6740 (clobber (match_scratch:BFP 0 "=f"))]
6741 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6743 [(set_attr "op_type" "RRE")
6744 (set_attr "type" "fsimp<mode>")])
6747 (define_insn "*neg<mode>2_nocc"
6748 [(set (match_operand:FP 0 "register_operand" "=f")
6749 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
6752 [(set_attr "op_type" "RRE")
6753 (set_attr "type" "fsimp<mode>")])
6755 ; lcxbr, lcdbr, lcebr
6756 (define_insn "*neg<mode>2"
6757 [(set (match_operand:BFP 0 "register_operand" "=f")
6758 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
6759 (clobber (reg:CC CC_REGNUM))]
6762 [(set_attr "op_type" "RRE")
6763 (set_attr "type" "fsimp<mode>")])
6767 ;;- Absolute value instructions.
6771 ; abs(di|si)2 instruction pattern(s).
6774 (define_insn "*absdi2_sign_cc"
6775 [(set (reg CC_REGNUM)
6776 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6777 (match_operand:SI 1 "register_operand" "d") 0)
6778 (const_int 32)) (const_int 32)))
6780 (set (match_operand:DI 0 "register_operand" "=d")
6781 (abs:DI (sign_extend:DI (match_dup 1))))]
6782 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6784 [(set_attr "op_type" "RRE")
6785 (set_attr "z10prop" "z10_c")])
6787 (define_insn "*absdi2_sign"
6788 [(set (match_operand:DI 0 "register_operand" "=d")
6789 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
6790 (clobber (reg:CC CC_REGNUM))]
6793 [(set_attr "op_type" "RRE")
6794 (set_attr "z10prop" "z10_c")])
6797 (define_insn "*abs<mode>2_cc"
6798 [(set (reg CC_REGNUM)
6799 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
6801 (set (match_operand:GPR 0 "register_operand" "=d")
6802 (abs:GPR (match_dup 1)))]
6803 "s390_match_ccmode (insn, CCAmode)"
6805 [(set_attr "op_type" "RR<E>")
6806 (set_attr "z10prop" "z10_c")])
6809 (define_insn "*abs<mode>2_cconly"
6810 [(set (reg CC_REGNUM)
6811 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
6813 (clobber (match_scratch:GPR 0 "=d"))]
6814 "s390_match_ccmode (insn, CCAmode)"
6816 [(set_attr "op_type" "RR<E>")
6817 (set_attr "z10prop" "z10_c")])
6820 (define_insn "abs<mode>2"
6821 [(set (match_operand:GPR 0 "register_operand" "=d")
6822 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6823 (clobber (reg:CC CC_REGNUM))]
6826 [(set_attr "op_type" "RR<E>")
6827 (set_attr "z10prop" "z10_c")])
6830 ; abs(df|sf)2 instruction pattern(s).
6833 (define_expand "abs<mode>2"
6835 [(set (match_operand:BFP 0 "register_operand" "=f")
6836 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6837 (clobber (reg:CC CC_REGNUM))])]
6841 ; lpxbr, lpdbr, lpebr
6842 (define_insn "*abs<mode>2_cc"
6843 [(set (reg CC_REGNUM)
6844 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
6845 (match_operand:BFP 2 "const0_operand" "")))
6846 (set (match_operand:BFP 0 "register_operand" "=f")
6847 (abs:BFP (match_dup 1)))]
6848 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6850 [(set_attr "op_type" "RRE")
6851 (set_attr "type" "fsimp<mode>")])
6853 ; lpxbr, lpdbr, lpebr
6854 (define_insn "*abs<mode>2_cconly"
6855 [(set (reg CC_REGNUM)
6856 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
6857 (match_operand:BFP 2 "const0_operand" "")))
6858 (clobber (match_scratch:BFP 0 "=f"))]
6859 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6861 [(set_attr "op_type" "RRE")
6862 (set_attr "type" "fsimp<mode>")])
6865 (define_insn "*abs<mode>2_nocc"
6866 [(set (match_operand:FP 0 "register_operand" "=f")
6867 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
6870 [(set_attr "op_type" "RRE")
6871 (set_attr "type" "fsimp<mode>")])
6873 ; lpxbr, lpdbr, lpebr
6874 (define_insn "*abs<mode>2"
6875 [(set (match_operand:BFP 0 "register_operand" "=f")
6876 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6877 (clobber (reg:CC CC_REGNUM))]
6880 [(set_attr "op_type" "RRE")
6881 (set_attr "type" "fsimp<mode>")])
6885 ;;- Negated absolute value instructions
6892 (define_insn "*negabsdi2_sign_cc"
6893 [(set (reg CC_REGNUM)
6894 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
6895 (match_operand:SI 1 "register_operand" "d") 0)
6896 (const_int 32)) (const_int 32))))
6898 (set (match_operand:DI 0 "register_operand" "=d")
6899 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
6900 "TARGET_64BIT && s390_match_ccmode (insn, CCAmode)"
6902 [(set_attr "op_type" "RRE")
6903 (set_attr "z10prop" "z10_c")])
6905 (define_insn "*negabsdi2_sign"
6906 [(set (match_operand:DI 0 "register_operand" "=d")
6907 (neg:DI (abs:DI (sign_extend:DI
6908 (match_operand:SI 1 "register_operand" "d")))))
6909 (clobber (reg:CC CC_REGNUM))]
6912 [(set_attr "op_type" "RRE")
6913 (set_attr "z10prop" "z10_c")])
6916 (define_insn "*negabs<mode>2_cc"
6917 [(set (reg CC_REGNUM)
6918 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6920 (set (match_operand:GPR 0 "register_operand" "=d")
6921 (neg:GPR (abs:GPR (match_dup 1))))]
6922 "s390_match_ccmode (insn, CCAmode)"
6924 [(set_attr "op_type" "RR<E>")
6925 (set_attr "z10prop" "z10_c")])
6928 (define_insn "*negabs<mode>2_cconly"
6929 [(set (reg CC_REGNUM)
6930 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
6932 (clobber (match_scratch:GPR 0 "=d"))]
6933 "s390_match_ccmode (insn, CCAmode)"
6935 [(set_attr "op_type" "RR<E>")
6936 (set_attr "z10prop" "z10_c")])
6939 (define_insn "*negabs<mode>2"
6940 [(set (match_operand:GPR 0 "register_operand" "=d")
6941 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
6942 (clobber (reg:CC CC_REGNUM))]
6945 [(set_attr "op_type" "RR<E>")
6946 (set_attr "z10prop" "z10_c")])
6952 ; lnxbr, lndbr, lnebr
6953 (define_insn "*negabs<mode>2_cc"
6954 [(set (reg CC_REGNUM)
6955 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6956 (match_operand:BFP 2 "const0_operand" "")))
6957 (set (match_operand:BFP 0 "register_operand" "=f")
6958 (neg:BFP (abs:BFP (match_dup 1))))]
6959 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6961 [(set_attr "op_type" "RRE")
6962 (set_attr "type" "fsimp<mode>")])
6964 ; lnxbr, lndbr, lnebr
6965 (define_insn "*negabs<mode>2_cconly"
6966 [(set (reg CC_REGNUM)
6967 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
6968 (match_operand:BFP 2 "const0_operand" "")))
6969 (clobber (match_scratch:BFP 0 "=f"))]
6970 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6972 [(set_attr "op_type" "RRE")
6973 (set_attr "type" "fsimp<mode>")])
6976 (define_insn "*negabs<mode>2_nocc"
6977 [(set (match_operand:FP 0 "register_operand" "=f")
6978 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
6981 [(set_attr "op_type" "RRE")
6982 (set_attr "type" "fsimp<mode>")])
6984 ; lnxbr, lndbr, lnebr
6985 (define_insn "*negabs<mode>2"
6986 [(set (match_operand:BFP 0 "register_operand" "=f")
6987 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f"))))
6988 (clobber (reg:CC CC_REGNUM))]
6991 [(set_attr "op_type" "RRE")
6992 (set_attr "type" "fsimp<mode>")])
6995 ;;- Copy sign instructions
6999 (define_insn "copysign<mode>3"
7000 [(set (match_operand:FP 0 "register_operand" "=f")
7001 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
7002 (match_operand:FP 2 "register_operand" "f")]
7006 [(set_attr "op_type" "RRF")
7007 (set_attr "type" "fsimp<mode>")])
7010 ;;- Square root instructions.
7014 ; sqrt(df|sf)2 instruction pattern(s).
7017 ; sqxbr, sqdbr, sqebr, sqdb, sqeb
7018 (define_insn "sqrt<mode>2"
7019 [(set (match_operand:BFP 0 "register_operand" "=f,f")
7020 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,<Rf>")))]
7025 [(set_attr "op_type" "RRE,RXE")
7026 (set_attr "type" "fsqrt<mode>")])
7030 ;;- One complement instructions.
7034 ; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
7037 (define_expand "one_cmpl<mode>2"
7039 [(set (match_operand:INT 0 "register_operand" "")
7040 (xor:INT (match_operand:INT 1 "register_operand" "")
7042 (clobber (reg:CC CC_REGNUM))])]
7048 ;; Find leftmost bit instructions.
7051 (define_expand "clzdi2"
7052 [(set (match_operand:DI 0 "register_operand" "=d")
7053 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
7054 "TARGET_EXTIMM && TARGET_64BIT"
7056 rtx insn, clz_equal;
7057 rtx wide_reg = gen_reg_rtx (TImode);
7058 rtx msb = gen_rtx_CONST_INT (DImode, (unsigned HOST_WIDE_INT) 1 << 63);
7060 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
7062 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
7064 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
7065 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
7070 (define_insn "clztidi2"
7071 [(set (match_operand:TI 0 "register_operand" "=d")
7075 (xor:DI (match_operand:DI 1 "register_operand" "d")
7076 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
7077 (subreg:SI (clz:DI (match_dup 1)) 4))))
7080 (zero_extend:TI (clz:DI (match_dup 1)))))
7081 (clobber (reg:CC CC_REGNUM))]
7082 "(unsigned HOST_WIDE_INT) INTVAL (operands[2])
7083 == (unsigned HOST_WIDE_INT) 1 << 63
7084 && TARGET_EXTIMM && TARGET_64BIT"
7086 [(set_attr "op_type" "RRE")])
7090 ;;- Rotate instructions.
7094 ; rotl(di|si)3 instruction pattern(s).
7098 (define_insn "rotl<mode>3"
7099 [(set (match_operand:GPR 0 "register_operand" "=d")
7100 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7101 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7104 [(set_attr "op_type" "RSE")
7105 (set_attr "atype" "reg")
7106 (set_attr "z10prop" "z10_super_E1")])
7109 (define_insn "*rotl<mode>3_and"
7110 [(set (match_operand:GPR 0 "register_operand" "=d")
7111 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
7112 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7113 (match_operand:SI 3 "const_int_operand" "n"))))]
7114 "TARGET_CPU_ZARCH && (INTVAL (operands[3]) & 63) == 63"
7116 [(set_attr "op_type" "RSE")
7117 (set_attr "atype" "reg")
7118 (set_attr "z10prop" "z10_super_E1")])
7122 ;;- Shift instructions.
7126 ; (ashl|lshr)(di|si)3 instruction pattern(s).
7129 (define_expand "<shift><mode>3"
7130 [(set (match_operand:DSI 0 "register_operand" "")
7131 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
7132 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))]
7137 (define_insn "*<shift>di3_31"
7138 [(set (match_operand:DI 0 "register_operand" "=d")
7139 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7140 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7143 [(set_attr "op_type" "RS")
7144 (set_attr "atype" "reg")])
7146 ; sll, srl, sllg, srlg
7147 (define_insn "*<shift><mode>3"
7148 [(set (match_operand:GPR 0 "register_operand" "=d")
7149 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7150 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))]
7152 "s<lr>l<g>\t%0,<1>%Y2"
7153 [(set_attr "op_type" "RS<E>")
7154 (set_attr "atype" "reg")
7155 (set_attr "z10prop" "z10_super_E1")])
7158 (define_insn "*<shift>di3_31_and"
7159 [(set (match_operand:DI 0 "register_operand" "=d")
7160 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
7161 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7162 (match_operand:SI 3 "const_int_operand" "n"))))]
7163 "!TARGET_64BIT && (INTVAL (operands[3]) & 63) == 63"
7165 [(set_attr "op_type" "RS")
7166 (set_attr "atype" "reg")])
7168 ; sll, srl, sllg, srlg
7169 (define_insn "*<shift><mode>3_and"
7170 [(set (match_operand:GPR 0 "register_operand" "=d")
7171 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7172 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7173 (match_operand:SI 3 "const_int_operand" "n"))))]
7174 "(INTVAL (operands[3]) & 63) == 63"
7175 "s<lr>l<g>\t%0,<1>%Y2"
7176 [(set_attr "op_type" "RS<E>")
7177 (set_attr "atype" "reg")
7178 (set_attr "z10prop" "z10_super_E1")])
7181 ; ashr(di|si)3 instruction pattern(s).
7184 (define_expand "ashr<mode>3"
7186 [(set (match_operand:DSI 0 "register_operand" "")
7187 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
7188 (match_operand:SI 2 "shift_count_or_setmem_operand" "")))
7189 (clobber (reg:CC CC_REGNUM))])]
7193 (define_insn "*ashrdi3_cc_31"
7194 [(set (reg CC_REGNUM)
7195 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7196 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7198 (set (match_operand:DI 0 "register_operand" "=d")
7199 (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7200 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
7202 [(set_attr "op_type" "RS")
7203 (set_attr "atype" "reg")])
7205 (define_insn "*ashrdi3_cconly_31"
7206 [(set (reg CC_REGNUM)
7207 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7208 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7210 (clobber (match_scratch:DI 0 "=d"))]
7211 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)"
7213 [(set_attr "op_type" "RS")
7214 (set_attr "atype" "reg")])
7216 (define_insn "*ashrdi3_31"
7217 [(set (match_operand:DI 0 "register_operand" "=d")
7218 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7219 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
7220 (clobber (reg:CC CC_REGNUM))]
7223 [(set_attr "op_type" "RS")
7224 (set_attr "atype" "reg")])
7227 (define_insn "*ashr<mode>3_cc"
7228 [(set (reg CC_REGNUM)
7229 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7230 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7232 (set (match_operand:GPR 0 "register_operand" "=d")
7233 (ashiftrt:GPR (match_dup 1) (match_dup 2)))]
7234 "s390_match_ccmode(insn, CCSmode)"
7236 [(set_attr "op_type" "RS<E>")
7237 (set_attr "atype" "reg")
7238 (set_attr "z10prop" "z10_super_E1")])
7241 (define_insn "*ashr<mode>3_cconly"
7242 [(set (reg CC_REGNUM)
7243 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7244 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y"))
7246 (clobber (match_scratch:GPR 0 "=d"))]
7247 "s390_match_ccmode(insn, CCSmode)"
7249 [(set_attr "op_type" "RS<E>")
7250 (set_attr "atype" "reg")
7251 (set_attr "z10prop" "z10_super_E1")])
7254 (define_insn "*ashr<mode>3"
7255 [(set (match_operand:GPR 0 "register_operand" "=d")
7256 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7257 (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")))
7258 (clobber (reg:CC CC_REGNUM))]
7261 [(set_attr "op_type" "RS<E>")
7262 (set_attr "atype" "reg")
7263 (set_attr "z10prop" "z10_super_E1")])
7266 ; shift pattern with implicit ANDs
7268 (define_insn "*ashrdi3_cc_31_and"
7269 [(set (reg CC_REGNUM)
7270 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7271 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7272 (match_operand:SI 3 "const_int_operand" "n")))
7274 (set (match_operand:DI 0 "register_operand" "=d")
7275 (ashiftrt:DI (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7276 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)
7277 && (INTVAL (operands[3]) & 63) == 63"
7279 [(set_attr "op_type" "RS")
7280 (set_attr "atype" "reg")])
7282 (define_insn "*ashrdi3_cconly_31_and"
7283 [(set (reg CC_REGNUM)
7284 (compare (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7285 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7286 (match_operand:SI 3 "const_int_operand" "n")))
7288 (clobber (match_scratch:DI 0 "=d"))]
7289 "!TARGET_64BIT && s390_match_ccmode(insn, CCSmode)
7290 && (INTVAL (operands[3]) & 63) == 63"
7292 [(set_attr "op_type" "RS")
7293 (set_attr "atype" "reg")])
7295 (define_insn "*ashrdi3_31_and"
7296 [(set (match_operand:DI 0 "register_operand" "=d")
7297 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
7298 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7299 (match_operand:SI 3 "const_int_operand" "n"))))
7300 (clobber (reg:CC CC_REGNUM))]
7301 "!TARGET_64BIT && (INTVAL (operands[3]) & 63) == 63"
7303 [(set_attr "op_type" "RS")
7304 (set_attr "atype" "reg")])
7307 (define_insn "*ashr<mode>3_cc_and"
7308 [(set (reg CC_REGNUM)
7309 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7310 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7311 (match_operand:SI 3 "const_int_operand" "n")))
7313 (set (match_operand:GPR 0 "register_operand" "=d")
7314 (ashiftrt:GPR (match_dup 1) (and:SI (match_dup 2) (match_dup 3))))]
7315 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7317 [(set_attr "op_type" "RS<E>")
7318 (set_attr "atype" "reg")
7319 (set_attr "z10prop" "z10_super_E1")])
7322 (define_insn "*ashr<mode>3_cconly_and"
7323 [(set (reg CC_REGNUM)
7324 (compare (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7325 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7326 (match_operand:SI 3 "const_int_operand" "n")))
7328 (clobber (match_scratch:GPR 0 "=d"))]
7329 "s390_match_ccmode(insn, CCSmode) && (INTVAL (operands[3]) & 63) == 63"
7331 [(set_attr "op_type" "RS<E>")
7332 (set_attr "atype" "reg")
7333 (set_attr "z10prop" "z10_super_E1")])
7336 (define_insn "*ashr<mode>3_and"
7337 [(set (match_operand:GPR 0 "register_operand" "=d")
7338 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>")
7339 (and:SI (match_operand:SI 2 "shift_count_or_setmem_operand" "Y")
7340 (match_operand:SI 3 "const_int_operand" "n"))))
7341 (clobber (reg:CC CC_REGNUM))]
7342 "(INTVAL (operands[3]) & 63) == 63"
7344 [(set_attr "op_type" "RS<E>")
7345 (set_attr "atype" "reg")
7346 (set_attr "z10prop" "z10_super_E1")])
7350 ;; Branch instruction patterns.
7353 (define_expand "b<code>"
7355 (if_then_else (COMPARE (match_operand 0 "" "")
7360 "s390_emit_jump (operands[0],
7361 s390_emit_compare (<CODE>, s390_compare_op0, s390_compare_op1)); DONE;")
7365 ;;- Conditional jump instructions.
7368 (define_insn "*cjump_64"
7371 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7372 (label_ref (match_operand 0 "" ""))
7376 if (get_attr_length (insn) == 4)
7379 return "jg%C1\t%l0";
7381 [(set_attr "op_type" "RI")
7382 (set_attr "type" "branch")
7383 (set (attr "length")
7384 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7385 (const_int 4) (const_int 6)))])
7387 (define_insn "*cjump_31"
7390 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7391 (label_ref (match_operand 0 "" ""))
7395 gcc_assert (get_attr_length (insn) == 4);
7398 [(set_attr "op_type" "RI")
7399 (set_attr "type" "branch")
7400 (set (attr "length")
7401 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7402 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7403 (const_int 4) (const_int 6))
7404 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7405 (const_int 4) (const_int 8))))])
7407 (define_insn "*cjump_long"
7410 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7411 (match_operand 0 "address_operand" "U")
7415 if (get_attr_op_type (insn) == OP_TYPE_RR)
7420 [(set (attr "op_type")
7421 (if_then_else (match_operand 0 "register_operand" "")
7422 (const_string "RR") (const_string "RX")))
7423 (set_attr "type" "branch")
7424 (set_attr "atype" "agen")])
7428 ;;- Negated conditional jump instructions.
7431 (define_insn "*icjump_64"
7434 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7436 (label_ref (match_operand 0 "" ""))))]
7439 if (get_attr_length (insn) == 4)
7442 return "jg%D1\t%l0";
7444 [(set_attr "op_type" "RI")
7445 (set_attr "type" "branch")
7446 (set (attr "length")
7447 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7448 (const_int 4) (const_int 6)))])
7450 (define_insn "*icjump_31"
7453 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7455 (label_ref (match_operand 0 "" ""))))]
7458 gcc_assert (get_attr_length (insn) == 4);
7461 [(set_attr "op_type" "RI")
7462 (set_attr "type" "branch")
7463 (set (attr "length")
7464 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7465 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7466 (const_int 4) (const_int 6))
7467 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7468 (const_int 4) (const_int 8))))])
7470 (define_insn "*icjump_long"
7473 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7475 (match_operand 0 "address_operand" "U")))]
7478 if (get_attr_op_type (insn) == OP_TYPE_RR)
7483 [(set (attr "op_type")
7484 (if_then_else (match_operand 0 "register_operand" "")
7485 (const_string "RR") (const_string "RX")))
7486 (set_attr "type" "branch")
7487 (set_attr "atype" "agen")])
7490 ;;- Trap instructions.
7494 [(trap_if (const_int 1) (const_int 0))]
7497 [(set_attr "op_type" "RI")
7498 (set_attr "type" "branch")])
7500 (define_expand "conditional_trap"
7501 [(trap_if (match_operand 0 "comparison_operator" "")
7502 (match_operand 1 "general_operand" ""))]
7505 if (operands[1] != const0_rtx) FAIL;
7506 operands[0] = s390_emit_compare (GET_CODE (operands[0]),
7507 s390_compare_op0, s390_compare_op1);
7510 (define_insn "*trap"
7511 [(trap_if (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
7515 [(set_attr "op_type" "RI")
7516 (set_attr "type" "branch")])
7518 ; crt, cgrt, cit, cgit
7519 (define_insn "*cmp_and_trap_signed_int<mode>"
7520 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
7521 [(match_operand:GPR 1 "register_operand" "d,d")
7522 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
7528 [(set_attr "op_type" "RRF,RIE")
7529 (set_attr "type" "branch")
7530 (set_attr "z10prop" "z10_super_c,z10_super")])
7532 ; clrt, clgrt, clfit, clgit
7533 (define_insn "*cmp_and_trap_unsigned_int<mode>"
7534 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
7535 [(match_operand:GPR 1 "register_operand" "d,d")
7536 (match_operand:GPR 2 "nonmemory_operand" "d,D")])
7541 cl<gf>it%C0\t%1,%x2"
7542 [(set_attr "op_type" "RRF,RIE")
7543 (set_attr "type" "branch")
7544 (set_attr "z10prop" "z10_super_c,z10_super")])
7547 ;;- Loop instructions.
7549 ;; This is all complicated by the fact that since this is a jump insn
7550 ;; we must handle our own output reloads.
7552 (define_expand "doloop_end"
7553 [(use (match_operand 0 "" "")) ; loop pseudo
7554 (use (match_operand 1 "" "")) ; iterations; zero if unknown
7555 (use (match_operand 2 "" "")) ; max iterations
7556 (use (match_operand 3 "" "")) ; loop level
7557 (use (match_operand 4 "" ""))] ; label
7560 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
7561 emit_jump_insn (gen_doloop_si31 (operands[4], operands[0], operands[0]));
7562 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
7563 emit_jump_insn (gen_doloop_si64 (operands[4], operands[0], operands[0]));
7564 else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
7565 emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
7572 (define_insn_and_split "doloop_si64"
7575 (ne (match_operand:SI 1 "register_operand" "d,d,d")
7577 (label_ref (match_operand 0 "" ""))
7579 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
7580 (plus:SI (match_dup 1) (const_int -1)))
7581 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
7582 (clobber (reg:CC CC_REGNUM))]
7585 if (which_alternative != 0)
7587 else if (get_attr_length (insn) == 4)
7588 return "brct\t%1,%l0";
7590 return "ahi\t%1,-1\;jgne\t%l0";
7592 "&& reload_completed
7593 && (! REG_P (operands[2])
7594 || ! rtx_equal_p (operands[1], operands[2]))"
7595 [(set (match_dup 3) (match_dup 1))
7596 (parallel [(set (reg:CCAN CC_REGNUM)
7597 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7599 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7600 (set (match_dup 2) (match_dup 3))
7601 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7602 (label_ref (match_dup 0))
7605 [(set_attr "op_type" "RI")
7606 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7607 ; hurt us in the (rare) case of ahi.
7608 (set_attr "z10prop" "z10_super_E1")
7609 (set_attr "type" "branch")
7610 (set (attr "length")
7611 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7612 (const_int 4) (const_int 10)))])
7614 (define_insn_and_split "doloop_si31"
7617 (ne (match_operand:SI 1 "register_operand" "d,d,d")
7619 (label_ref (match_operand 0 "" ""))
7621 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
7622 (plus:SI (match_dup 1) (const_int -1)))
7623 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
7624 (clobber (reg:CC CC_REGNUM))]
7627 if (which_alternative != 0)
7629 else if (get_attr_length (insn) == 4)
7630 return "brct\t%1,%l0";
7634 "&& reload_completed
7635 && (! REG_P (operands[2])
7636 || ! rtx_equal_p (operands[1], operands[2]))"
7637 [(set (match_dup 3) (match_dup 1))
7638 (parallel [(set (reg:CCAN CC_REGNUM)
7639 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
7641 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
7642 (set (match_dup 2) (match_dup 3))
7643 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7644 (label_ref (match_dup 0))
7647 [(set_attr "op_type" "RI")
7648 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7649 ; hurt us in the (rare) case of ahi.
7650 (set_attr "z10prop" "z10_super_E1")
7651 (set_attr "type" "branch")
7652 (set (attr "length")
7653 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7654 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7655 (const_int 4) (const_int 6))
7656 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7657 (const_int 4) (const_int 8))))])
7659 (define_insn "*doloop_si_long"
7662 (ne (match_operand:SI 1 "register_operand" "d")
7664 (match_operand 0 "address_operand" "U")
7666 (set (match_operand:SI 2 "register_operand" "=1")
7667 (plus:SI (match_dup 1) (const_int -1)))
7668 (clobber (match_scratch:SI 3 "=X"))
7669 (clobber (reg:CC CC_REGNUM))]
7672 if (get_attr_op_type (insn) == OP_TYPE_RR)
7673 return "bctr\t%1,%0";
7675 return "bct\t%1,%a0";
7677 [(set (attr "op_type")
7678 (if_then_else (match_operand 0 "register_operand" "")
7679 (const_string "RR") (const_string "RX")))
7680 (set_attr "type" "branch")
7681 (set_attr "atype" "agen")
7682 (set_attr "z10prop" "z10_cobra")])
7684 (define_insn_and_split "doloop_di"
7687 (ne (match_operand:DI 1 "register_operand" "d,d,d")
7689 (label_ref (match_operand 0 "" ""))
7691 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
7692 (plus:DI (match_dup 1) (const_int -1)))
7693 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
7694 (clobber (reg:CC CC_REGNUM))]
7697 if (which_alternative != 0)
7699 else if (get_attr_length (insn) == 4)
7700 return "brctg\t%1,%l0";
7702 return "aghi\t%1,-1\;jgne\t%l0";
7704 "&& reload_completed
7705 && (! REG_P (operands[2])
7706 || ! rtx_equal_p (operands[1], operands[2]))"
7707 [(set (match_dup 3) (match_dup 1))
7708 (parallel [(set (reg:CCAN CC_REGNUM)
7709 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
7711 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
7712 (set (match_dup 2) (match_dup 3))
7713 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
7714 (label_ref (match_dup 0))
7717 [(set_attr "op_type" "RI")
7718 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
7719 ; hurt us in the (rare) case of ahi.
7720 (set_attr "z10prop" "z10_super_E1")
7721 (set_attr "type" "branch")
7722 (set (attr "length")
7723 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7724 (const_int 4) (const_int 10)))])
7727 ;;- Unconditional jump instructions.
7731 ; jump instruction pattern(s).
7734 (define_expand "jump"
7735 [(match_operand 0 "" "")]
7737 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
7739 (define_insn "*jump64"
7740 [(set (pc) (label_ref (match_operand 0 "" "")))]
7743 if (get_attr_length (insn) == 4)
7748 [(set_attr "op_type" "RI")
7749 (set_attr "type" "branch")
7750 (set (attr "length")
7751 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7752 (const_int 4) (const_int 6)))])
7754 (define_insn "*jump31"
7755 [(set (pc) (label_ref (match_operand 0 "" "")))]
7758 gcc_assert (get_attr_length (insn) == 4);
7761 [(set_attr "op_type" "RI")
7762 (set_attr "type" "branch")
7763 (set (attr "length")
7764 (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
7765 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7766 (const_int 4) (const_int 6))
7767 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
7768 (const_int 4) (const_int 8))))])
7771 ; indirect-jump instruction pattern(s).
7774 (define_insn "indirect_jump"
7775 [(set (pc) (match_operand 0 "address_operand" "U"))]
7778 if (get_attr_op_type (insn) == OP_TYPE_RR)
7783 [(set (attr "op_type")
7784 (if_then_else (match_operand 0 "register_operand" "")
7785 (const_string "RR") (const_string "RX")))
7786 (set_attr "type" "branch")
7787 (set_attr "atype" "agen")])
7790 ; casesi instruction pattern(s).
7793 (define_insn "casesi_jump"
7794 [(set (pc) (match_operand 0 "address_operand" "U"))
7795 (use (label_ref (match_operand 1 "" "")))]
7798 if (get_attr_op_type (insn) == OP_TYPE_RR)
7803 [(set (attr "op_type")
7804 (if_then_else (match_operand 0 "register_operand" "")
7805 (const_string "RR") (const_string "RX")))
7806 (set_attr "type" "branch")
7807 (set_attr "atype" "agen")])
7809 (define_expand "casesi"
7810 [(match_operand:SI 0 "general_operand" "")
7811 (match_operand:SI 1 "general_operand" "")
7812 (match_operand:SI 2 "general_operand" "")
7813 (label_ref (match_operand 3 "" ""))
7814 (label_ref (match_operand 4 "" ""))]
7817 rtx index = gen_reg_rtx (SImode);
7818 rtx base = gen_reg_rtx (Pmode);
7819 rtx target = gen_reg_rtx (Pmode);
7821 emit_move_insn (index, operands[0]);
7822 emit_insn (gen_subsi3 (index, index, operands[1]));
7823 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
7826 if (Pmode != SImode)
7827 index = convert_to_mode (Pmode, index, 1);
7828 if (GET_CODE (index) != REG)
7829 index = copy_to_mode_reg (Pmode, index);
7832 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
7834 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
7836 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
7838 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
7839 emit_move_insn (target, index);
7842 target = gen_rtx_PLUS (Pmode, base, target);
7843 emit_jump_insn (gen_casesi_jump (target, operands[3]));
7850 ;;- Jump to subroutine.
7855 ; untyped call instruction pattern(s).
7858 ;; Call subroutine returning any type.
7859 (define_expand "untyped_call"
7860 [(parallel [(call (match_operand 0 "" "")
7862 (match_operand 1 "" "")
7863 (match_operand 2 "" "")])]
7868 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
7870 for (i = 0; i < XVECLEN (operands[2], 0); i++)
7872 rtx set = XVECEXP (operands[2], 0, i);
7873 emit_move_insn (SET_DEST (set), SET_SRC (set));
7876 /* The optimizer does not know that the call sets the function value
7877 registers we stored in the result block. We avoid problems by
7878 claiming that all hard registers are used and clobbered at this
7880 emit_insn (gen_blockage ());
7885 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7886 ;; all of memory. This blocks insns from being moved across this point.
7888 (define_insn "blockage"
7889 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
7892 [(set_attr "type" "none")
7893 (set_attr "length" "0")])
7899 (define_expand "sibcall"
7900 [(call (match_operand 0 "" "")
7901 (match_operand 1 "" ""))]
7904 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
7908 (define_insn "*sibcall_br"
7909 [(call (mem:QI (reg SIBCALL_REGNUM))
7910 (match_operand 0 "const_int_operand" "n"))]
7911 "SIBLING_CALL_P (insn)
7912 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
7914 [(set_attr "op_type" "RR")
7915 (set_attr "type" "branch")
7916 (set_attr "atype" "agen")])
7918 (define_insn "*sibcall_brc"
7919 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7920 (match_operand 1 "const_int_operand" "n"))]
7921 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7923 [(set_attr "op_type" "RI")
7924 (set_attr "type" "branch")])
7926 (define_insn "*sibcall_brcl"
7927 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7928 (match_operand 1 "const_int_operand" "n"))]
7929 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7931 [(set_attr "op_type" "RIL")
7932 (set_attr "type" "branch")])
7935 ; sibcall_value patterns
7938 (define_expand "sibcall_value"
7939 [(set (match_operand 0 "" "")
7940 (call (match_operand 1 "" "")
7941 (match_operand 2 "" "")))]
7944 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
7948 (define_insn "*sibcall_value_br"
7949 [(set (match_operand 0 "" "")
7950 (call (mem:QI (reg SIBCALL_REGNUM))
7951 (match_operand 1 "const_int_operand" "n")))]
7952 "SIBLING_CALL_P (insn)
7953 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
7955 [(set_attr "op_type" "RR")
7956 (set_attr "type" "branch")
7957 (set_attr "atype" "agen")])
7959 (define_insn "*sibcall_value_brc"
7960 [(set (match_operand 0 "" "")
7961 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7962 (match_operand 2 "const_int_operand" "n")))]
7963 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
7965 [(set_attr "op_type" "RI")
7966 (set_attr "type" "branch")])
7968 (define_insn "*sibcall_value_brcl"
7969 [(set (match_operand 0 "" "")
7970 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
7971 (match_operand 2 "const_int_operand" "n")))]
7972 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
7974 [(set_attr "op_type" "RIL")
7975 (set_attr "type" "branch")])
7979 ; call instruction pattern(s).
7982 (define_expand "call"
7983 [(call (match_operand 0 "" "")
7984 (match_operand 1 "" ""))
7985 (use (match_operand 2 "" ""))]
7988 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
7989 gen_rtx_REG (Pmode, RETURN_REGNUM));
7993 (define_insn "*bras"
7994 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
7995 (match_operand 1 "const_int_operand" "n"))
7996 (clobber (match_operand 2 "register_operand" "=r"))]
7997 "!SIBLING_CALL_P (insn)
7998 && TARGET_SMALL_EXEC
7999 && GET_MODE (operands[2]) == Pmode"
8001 [(set_attr "op_type" "RI")
8002 (set_attr "type" "jsr")])
8004 (define_insn "*brasl"
8005 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
8006 (match_operand 1 "const_int_operand" "n"))
8007 (clobber (match_operand 2 "register_operand" "=r"))]
8008 "!SIBLING_CALL_P (insn)
8010 && GET_MODE (operands[2]) == Pmode"
8012 [(set_attr "op_type" "RIL")
8013 (set_attr "type" "jsr")])
8015 (define_insn "*basr"
8016 [(call (mem:QI (match_operand 0 "address_operand" "U"))
8017 (match_operand 1 "const_int_operand" "n"))
8018 (clobber (match_operand 2 "register_operand" "=r"))]
8019 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
8021 if (get_attr_op_type (insn) == OP_TYPE_RR)
8022 return "basr\t%2,%0";
8024 return "bas\t%2,%a0";
8026 [(set (attr "op_type")
8027 (if_then_else (match_operand 0 "register_operand" "")
8028 (const_string "RR") (const_string "RX")))
8029 (set_attr "type" "jsr")
8030 (set_attr "atype" "agen")])
8033 ; call_value instruction pattern(s).
8036 (define_expand "call_value"
8037 [(set (match_operand 0 "" "")
8038 (call (match_operand 1 "" "")
8039 (match_operand 2 "" "")))
8040 (use (match_operand 3 "" ""))]
8043 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
8044 gen_rtx_REG (Pmode, RETURN_REGNUM));
8048 (define_insn "*bras_r"
8049 [(set (match_operand 0 "" "")
8050 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8051 (match_operand:SI 2 "const_int_operand" "n")))
8052 (clobber (match_operand 3 "register_operand" "=r"))]
8053 "!SIBLING_CALL_P (insn)
8054 && TARGET_SMALL_EXEC
8055 && GET_MODE (operands[3]) == Pmode"
8057 [(set_attr "op_type" "RI")
8058 (set_attr "type" "jsr")])
8060 (define_insn "*brasl_r"
8061 [(set (match_operand 0 "" "")
8062 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8063 (match_operand 2 "const_int_operand" "n")))
8064 (clobber (match_operand 3 "register_operand" "=r"))]
8065 "!SIBLING_CALL_P (insn)
8067 && GET_MODE (operands[3]) == Pmode"
8069 [(set_attr "op_type" "RIL")
8070 (set_attr "type" "jsr")])
8072 (define_insn "*basr_r"
8073 [(set (match_operand 0 "" "")
8074 (call (mem:QI (match_operand 1 "address_operand" "U"))
8075 (match_operand 2 "const_int_operand" "n")))
8076 (clobber (match_operand 3 "register_operand" "=r"))]
8077 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8079 if (get_attr_op_type (insn) == OP_TYPE_RR)
8080 return "basr\t%3,%1";
8082 return "bas\t%3,%a1";
8084 [(set (attr "op_type")
8085 (if_then_else (match_operand 1 "register_operand" "")
8086 (const_string "RR") (const_string "RX")))
8087 (set_attr "type" "jsr")
8088 (set_attr "atype" "agen")])
8091 ;;- Thread-local storage support.
8094 (define_expand "get_tp_64"
8095 [(set (match_operand:DI 0 "nonimmediate_operand" "") (reg:DI TP_REGNUM))]
8099 (define_expand "get_tp_31"
8100 [(set (match_operand:SI 0 "nonimmediate_operand" "") (reg:SI TP_REGNUM))]
8104 (define_expand "set_tp_64"
8105 [(set (reg:DI TP_REGNUM) (match_operand:DI 0 "nonimmediate_operand" ""))
8106 (set (reg:DI TP_REGNUM) (unspec_volatile:DI [(reg:DI TP_REGNUM)] UNSPECV_SET_TP))]
8110 (define_expand "set_tp_31"
8111 [(set (reg:SI TP_REGNUM) (match_operand:SI 0 "nonimmediate_operand" ""))
8112 (set (reg:SI TP_REGNUM) (unspec_volatile:SI [(reg:SI TP_REGNUM)] UNSPECV_SET_TP))]
8116 (define_insn "*set_tp"
8117 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
8120 [(set_attr "type" "none")
8121 (set_attr "length" "0")])
8123 (define_insn "*tls_load_64"
8124 [(set (match_operand:DI 0 "register_operand" "=d")
8125 (unspec:DI [(match_operand:DI 1 "memory_operand" "RT")
8126 (match_operand:DI 2 "" "")]
8130 [(set_attr "op_type" "RXE")
8131 (set_attr "z10prop" "z10_fwd_A3")])
8133 (define_insn "*tls_load_31"
8134 [(set (match_operand:SI 0 "register_operand" "=d,d")
8135 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
8136 (match_operand:SI 2 "" "")]
8142 [(set_attr "op_type" "RX,RXY")
8143 (set_attr "type" "load")
8144 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
8146 (define_insn "*bras_tls"
8147 [(set (match_operand 0 "" "")
8148 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8149 (match_operand 2 "const_int_operand" "n")))
8150 (clobber (match_operand 3 "register_operand" "=r"))
8151 (use (match_operand 4 "" ""))]
8152 "!SIBLING_CALL_P (insn)
8153 && TARGET_SMALL_EXEC
8154 && GET_MODE (operands[3]) == Pmode"
8156 [(set_attr "op_type" "RI")
8157 (set_attr "type" "jsr")])
8159 (define_insn "*brasl_tls"
8160 [(set (match_operand 0 "" "")
8161 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
8162 (match_operand 2 "const_int_operand" "n")))
8163 (clobber (match_operand 3 "register_operand" "=r"))
8164 (use (match_operand 4 "" ""))]
8165 "!SIBLING_CALL_P (insn)
8167 && GET_MODE (operands[3]) == Pmode"
8169 [(set_attr "op_type" "RIL")
8170 (set_attr "type" "jsr")])
8172 (define_insn "*basr_tls"
8173 [(set (match_operand 0 "" "")
8174 (call (mem:QI (match_operand 1 "address_operand" "U"))
8175 (match_operand 2 "const_int_operand" "n")))
8176 (clobber (match_operand 3 "register_operand" "=r"))
8177 (use (match_operand 4 "" ""))]
8178 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
8180 if (get_attr_op_type (insn) == OP_TYPE_RR)
8181 return "basr\t%3,%1%J4";
8183 return "bas\t%3,%a1%J4";
8185 [(set (attr "op_type")
8186 (if_then_else (match_operand 1 "register_operand" "")
8187 (const_string "RR") (const_string "RX")))
8188 (set_attr "type" "jsr")
8189 (set_attr "atype" "agen")])
8192 ;;- Atomic operations
8196 ; memory barrier pattern.
8199 (define_expand "memory_barrier"
8201 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
8204 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
8205 MEM_VOLATILE_P (operands[0]) = 1;
8208 (define_insn "*memory_barrier"
8209 [(set (match_operand:BLK 0 "" "")
8210 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
8213 [(set_attr "op_type" "RR")])
8215 ; Although bcr is superscalar on Z10, this variant will never become part of
8216 ; an execution group.
8219 ; compare and swap patterns.
8222 (define_expand "sync_compare_and_swap<mode>"
8224 [(set (match_operand:TDSI 0 "register_operand" "")
8225 (match_operand:TDSI 1 "memory_operand" ""))
8227 (unspec_volatile:TDSI
8229 (match_operand:TDSI 2 "register_operand" "")
8230 (match_operand:TDSI 3 "register_operand" "")]
8232 (set (reg:CCZ1 CC_REGNUM)
8233 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
8236 (define_expand "sync_compare_and_swap<mode>"
8238 [(set (match_operand:HQI 0 "register_operand" "")
8239 (match_operand:HQI 1 "memory_operand" ""))
8241 (unspec_volatile:HQI
8243 (match_operand:HQI 2 "general_operand" "")
8244 (match_operand:HQI 3 "general_operand" "")]
8246 (set (reg:CCZ1 CC_REGNUM)
8247 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
8249 "s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1],
8250 operands[2], operands[3]); DONE;")
8252 (define_expand "sync_compare_and_swap_cc<mode>"
8254 [(set (match_operand:TDSI 0 "register_operand" "")
8255 (match_operand:TDSI 1 "memory_operand" ""))
8257 (unspec_volatile:TDSI
8259 (match_operand:TDSI 2 "register_operand" "")
8260 (match_operand:TDSI 3 "register_operand" "")]
8263 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
8266 /* Emulate compare. */
8267 operands[4] = gen_rtx_REG (CCZ1mode, CC_REGNUM);
8268 s390_compare_op0 = operands[1];
8269 s390_compare_op1 = operands[2];
8270 s390_compare_emitted = operands[4];
8274 (define_insn "*sync_compare_and_swap<mode>"
8275 [(set (match_operand:DP 0 "register_operand" "=r")
8276 (match_operand:DP 1 "memory_operand" "+Q"))
8280 (match_operand:DP 2 "register_operand" "0")
8281 (match_operand:DP 3 "register_operand" "r")]
8283 (set (reg:CCZ1 CC_REGNUM)
8284 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
8286 "cds<tg>\t%0,%3,%S1"
8287 [(set_attr "op_type" "RS<TE>")
8288 (set_attr "type" "sem")])
8291 (define_insn "*sync_compare_and_swap<mode>"
8292 [(set (match_operand:GPR 0 "register_operand" "=r")
8293 (match_operand:GPR 1 "memory_operand" "+Q"))
8295 (unspec_volatile:GPR
8297 (match_operand:GPR 2 "register_operand" "0")
8298 (match_operand:GPR 3 "register_operand" "r")]
8300 (set (reg:CCZ1 CC_REGNUM)
8301 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
8304 [(set_attr "op_type" "RS<E>")
8305 (set_attr "type" "sem")])
8309 ; Other atomic instruction patterns.
8312 (define_expand "sync_lock_test_and_set<mode>"
8313 [(match_operand:HQI 0 "register_operand")
8314 (match_operand:HQI 1 "memory_operand")
8315 (match_operand:HQI 2 "general_operand")]
8317 "s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
8318 operands[2], false); DONE;")
8320 (define_expand "sync_<atomic><mode>"
8321 [(set (match_operand:HQI 0 "memory_operand")
8322 (ATOMIC:HQI (match_dup 0)
8323 (match_operand:HQI 1 "general_operand")))]
8325 "s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
8326 operands[1], false); DONE;")
8328 (define_expand "sync_old_<atomic><mode>"
8329 [(set (match_operand:HQI 0 "register_operand")
8330 (match_operand:HQI 1 "memory_operand"))
8332 (ATOMIC:HQI (match_dup 1)
8333 (match_operand:HQI 2 "general_operand")))]
8335 "s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
8336 operands[2], false); DONE;")
8338 (define_expand "sync_new_<atomic><mode>"
8339 [(set (match_operand:HQI 0 "register_operand")
8340 (ATOMIC:HQI (match_operand:HQI 1 "memory_operand")
8341 (match_operand:HQI 2 "general_operand")))
8342 (set (match_dup 1) (ATOMIC:HQI (match_dup 1) (match_dup 2)))]
8344 "s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
8345 operands[2], true); DONE;")
8348 ;;- Miscellaneous instructions.
8352 ; allocate stack instruction pattern(s).
8355 (define_expand "allocate_stack"
8356 [(match_operand 0 "general_operand" "")
8357 (match_operand 1 "general_operand" "")]
8360 rtx temp = gen_reg_rtx (Pmode);
8362 emit_move_insn (temp, s390_back_chain_rtx ());
8363 anti_adjust_stack (operands[1]);
8364 emit_move_insn (s390_back_chain_rtx (), temp);
8366 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
8372 ; setjmp instruction pattern.
8375 (define_expand "builtin_setjmp_receiver"
8376 [(match_operand 0 "" "")]
8379 emit_insn (s390_load_got ());
8380 emit_use (pic_offset_table_rtx);
8384 ;; These patterns say how to save and restore the stack pointer. We need not
8385 ;; save the stack pointer at function level since we are careful to
8386 ;; preserve the backchain. At block level, we have to restore the backchain
8387 ;; when we restore the stack pointer.
8389 ;; For nonlocal gotos, we must save both the stack pointer and its
8390 ;; backchain and restore both. Note that in the nonlocal case, the
8391 ;; save area is a memory location.
8393 (define_expand "save_stack_function"
8394 [(match_operand 0 "general_operand" "")
8395 (match_operand 1 "general_operand" "")]
8399 (define_expand "restore_stack_function"
8400 [(match_operand 0 "general_operand" "")
8401 (match_operand 1 "general_operand" "")]
8405 (define_expand "restore_stack_block"
8406 [(match_operand 0 "register_operand" "")
8407 (match_operand 1 "register_operand" "")]
8410 rtx temp = gen_reg_rtx (Pmode);
8412 emit_move_insn (temp, s390_back_chain_rtx ());
8413 emit_move_insn (operands[0], operands[1]);
8414 emit_move_insn (s390_back_chain_rtx (), temp);
8419 (define_expand "save_stack_nonlocal"
8420 [(match_operand 0 "memory_operand" "")
8421 (match_operand 1 "register_operand" "")]
8424 enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
8425 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
8427 /* Copy the backchain to the first word, sp to the second and the
8428 literal pool base to the third. */
8430 if (TARGET_BACKCHAIN)
8432 rtx temp = force_reg (Pmode, s390_back_chain_rtx ());
8433 emit_move_insn (operand_subword (operands[0], 0, 0, mode), temp);
8436 emit_move_insn (operand_subword (operands[0], 1, 0, mode), operands[1]);
8437 emit_move_insn (operand_subword (operands[0], 2, 0, mode), base);
8442 (define_expand "restore_stack_nonlocal"
8443 [(match_operand 0 "register_operand" "")
8444 (match_operand 1 "memory_operand" "")]
8447 enum machine_mode mode = TARGET_64BIT ? OImode : TImode;
8448 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
8449 rtx temp = NULL_RTX;
8451 /* Restore the backchain from the first word, sp from the second and the
8452 literal pool base from the third. */
8454 if (TARGET_BACKCHAIN)
8455 temp = force_reg (Pmode, operand_subword (operands[1], 0, 0, mode));
8457 emit_move_insn (base, operand_subword (operands[1], 2, 0, mode));
8458 emit_move_insn (operands[0], operand_subword (operands[1], 1, 0, mode));
8461 emit_move_insn (s390_back_chain_rtx (), temp);
8467 (define_expand "exception_receiver"
8471 s390_set_has_landing_pad_p (true);
8476 ; nop instruction pattern(s).
8483 [(set_attr "op_type" "RR")
8484 (set_attr "z10prop" "z10_fr_E1")])
8490 [(set_attr "op_type" "RR")])
8494 ; Special literal pool access instruction pattern(s).
8497 (define_insn "*pool_entry"
8498 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
8499 UNSPECV_POOL_ENTRY)]
8502 enum machine_mode mode = GET_MODE (PATTERN (insn));
8503 unsigned int align = GET_MODE_BITSIZE (mode);
8504 s390_output_pool_entry (operands[0], mode, align);
8507 [(set (attr "length")
8508 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
8510 (define_insn "pool_align"
8511 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
8512 UNSPECV_POOL_ALIGN)]
8515 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
8517 (define_insn "pool_section_start"
8518 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
8521 [(set_attr "length" "0")])
8523 (define_insn "pool_section_end"
8524 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
8527 [(set_attr "length" "0")])
8529 (define_insn "main_base_31_small"
8530 [(set (match_operand 0 "register_operand" "=a")
8531 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
8532 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8534 [(set_attr "op_type" "RR")
8535 (set_attr "type" "la")])
8537 (define_insn "main_base_31_large"
8538 [(set (match_operand 0 "register_operand" "=a")
8539 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
8540 (set (pc) (label_ref (match_operand 2 "" "")))]
8541 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8543 [(set_attr "op_type" "RI")])
8545 (define_insn "main_base_64"
8546 [(set (match_operand 0 "register_operand" "=a")
8547 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
8548 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8550 [(set_attr "op_type" "RIL")
8551 (set_attr "type" "larl")
8552 (set_attr "z10prop" "z10_fwd_A1")])
8554 (define_insn "main_pool"
8555 [(set (match_operand 0 "register_operand" "=a")
8556 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
8557 "GET_MODE (operands[0]) == Pmode"
8562 (if_then_else (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
8563 (const_string "larl") (const_string "la")))])
8565 (define_insn "reload_base_31"
8566 [(set (match_operand 0 "register_operand" "=a")
8567 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
8568 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8569 "basr\t%0,0\;la\t%0,%1-.(%0)"
8570 [(set_attr "length" "6")
8571 (set_attr "type" "la")])
8573 (define_insn "reload_base_64"
8574 [(set (match_operand 0 "register_operand" "=a")
8575 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
8576 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
8578 [(set_attr "op_type" "RIL")
8579 (set_attr "type" "larl")
8580 (set_attr "z10prop" "z10_fwd_A1")])
8583 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
8588 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
8591 ;; Insns related to generating the function prologue and epilogue.
8595 (define_expand "prologue"
8596 [(use (const_int 0))]
8598 "s390_emit_prologue (); DONE;")
8600 (define_expand "epilogue"
8601 [(use (const_int 1))]
8603 "s390_emit_epilogue (false); DONE;")
8605 (define_expand "sibcall_epilogue"
8606 [(use (const_int 0))]
8608 "s390_emit_epilogue (true); DONE;")
8610 (define_insn "*return"
8612 (use (match_operand 0 "register_operand" "a"))]
8613 "GET_MODE (operands[0]) == Pmode"
8615 [(set_attr "op_type" "RR")
8616 (set_attr "type" "jsr")
8617 (set_attr "atype" "agen")])
8620 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
8621 ;; pointer. This is used for compatibility.
8623 (define_expand "ptr_extend"
8624 [(set (match_operand:DI 0 "register_operand" "=r")
8625 (match_operand:SI 1 "register_operand" "r"))]
8628 emit_insn (gen_anddi3 (operands[0],
8629 gen_lowpart (DImode, operands[1]),
8630 GEN_INT (0x7fffffff)));
8634 ;; Instruction definition to expand eh_return macro to support
8635 ;; swapping in special linkage return addresses.
8637 (define_expand "eh_return"
8638 [(use (match_operand 0 "register_operand" ""))]
8641 s390_emit_tpf_eh_return (operands[0]);
8646 ; Stack Protector Patterns
8649 (define_expand "stack_protect_set"
8650 [(set (match_operand 0 "memory_operand" "")
8651 (match_operand 1 "memory_operand" ""))]
8654 #ifdef TARGET_THREAD_SSP_OFFSET
8656 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
8657 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
8660 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
8662 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
8667 (define_insn "stack_protect_set<mode>"
8668 [(set (match_operand:DSI 0 "memory_operand" "=Q")
8669 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
8671 "mvc\t%O0(%G0,%R0),%S1"
8672 [(set_attr "op_type" "SS")])
8674 (define_expand "stack_protect_test"
8675 [(set (reg:CC CC_REGNUM)
8676 (compare (match_operand 0 "memory_operand" "")
8677 (match_operand 1 "memory_operand" "")))
8678 (match_operand 2 "" "")]
8681 #ifdef TARGET_THREAD_SSP_OFFSET
8683 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
8684 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
8686 s390_compare_op0 = operands[0];
8687 s390_compare_op1 = operands[1];
8688 s390_compare_emitted = gen_rtx_REG (CCZmode, CC_REGNUM);
8691 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
8693 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
8695 emit_jump_insn (gen_beq (operands[2]));
8700 (define_insn "stack_protect_test<mode>"
8701 [(set (reg:CCZ CC_REGNUM)
8702 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
8703 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
8705 "clc\t%O0(%G0,%R0),%S1"
8706 [(set_attr "op_type" "SS")])
8708 ; This is used in s390_emit_prologue in order to prevent insns
8709 ; adjusting the stack pointer to be moved over insns writing stack
8710 ; slots using a copy of the stack pointer in a different register.
8711 (define_insn "stack_tie"
8712 [(set (match_operand:BLK 0 "memory_operand" "+m")
8713 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
8716 [(set_attr "length" "0")])
8720 ; Data prefetch patterns
8723 (define_insn "prefetch"
8724 [(prefetch (match_operand 0 "address_operand" "UW,X")
8725 (match_operand:SI 1 "const_int_operand" "n,n")
8726 (match_operand:SI 2 "const_int_operand" "n,n"))]
8729 if (larl_operand (operands[0], Pmode))
8730 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
8732 if (s390_mem_constraint ("W", operands[0])
8733 || s390_mem_constraint ("U", operands[0]))
8734 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
8736 /* This point might be reached if op0 is a larl operand with an
8737 uneven addend. In this case we simply omit issuing a prefetch
8742 [(set_attr "type" "load,larl")
8743 (set_attr "op_type" "RXY,RIL")
8744 (set_attr "z10prop" "z10_super")])
8748 ; Byte swap instructions
8751 (define_insn "bswap<mode>2"
8752 [(set (match_operand:GPR 0 "register_operand" "=d, d")
8753 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,RT")))]
8758 [(set_attr "type" "*,load")
8759 (set_attr "op_type" "RRE,RXY")
8760 (set_attr "z10prop" "z10_super")])