1 ;;- Machine description for GNU compiler -- S/390 / zSeries version.
2 ;; Copyright (C) 1999-2017 Free Software Foundation, Inc.
3 ;; Contributed by Hartmut Penner (hpenner@de.ibm.com) and
4 ;; Ulrich Weigand (uweigand@de.ibm.com) and
5 ;; Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify it under
10 ;; the terms of the GNU General Public License as published by the Free
11 ;; Software Foundation; either version 3, or (at your option) any later
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
24 ;; See constraints.md for a description of constraints specific to s390.
27 ;; Special formats used for outputting 390 instructions.
29 ;; %C: print opcode suffix for branch condition.
30 ;; %D: print opcode suffix for inverse branch condition.
31 ;; %J: print tls_load/tls_gdcall/tls_ldcall suffix
32 ;; %G: print the size of the operand in bytes.
33 ;; %O: print only the displacement of a memory reference.
34 ;; %R: print only the base register of a memory reference.
35 ;; %S: print S-type memory reference (base+displacement).
36 ;; %N: print the second word of a DImode operand.
37 ;; %M: print the second word of a TImode operand.
38 ;; %Y: print shift count operand.
40 ;; %b: print integer X as if it's an unsigned byte.
41 ;; %c: print integer X as if it's an signed byte.
42 ;; %x: print integer X as if it's an unsigned halfword.
43 ;; %h: print integer X as if it's a signed halfword.
44 ;; %i: print the first nonzero HImode part of X.
45 ;; %j: print the first HImode part unequal to -1 of X.
46 ;; %k: print the first nonzero SImode part of X.
47 ;; %m: print the first SImode part unequal to -1 of X.
48 ;; %o: print integer X as if it's an unsigned 32bit word.
50 ;; We have a special constraint for pattern matching.
52 ;; s_operand -- Matches a valid S operand in a RS, SI or SS type instruction.
59 (define_c_enum "unspec" [
65 ; Convert CC into a str comparison result and copy it into an
67 ; cc0->0, cc1->1, cc2->-1, (cc3->-1)
68 UNSPEC_STRCMPCC_TO_INT
70 ; Copy CC as is into the lower 2 bits of an integer register
73 ; The right hand side of an setmem
76 ; GOT/PLT and lt-relative accesses
97 ; TLS relocation specifiers
113 ; Stack Smashing Protector
117 ; Split stack support
120 ; Test Data Class (TDC)
132 UNSPEC_FPINT_NEARBYINT
141 UNSPEC_VEC_SMULT_EVEN
142 UNSPEC_VEC_UMULT_EVEN
156 UNSPEC_VEC_INSERT_AND_ZERO
157 UNSPEC_VEC_LOAD_BNDRY
162 UNSPEC_VEC_PACK_SATURATE
163 UNSPEC_VEC_PACK_SATURATE_CC
164 UNSPEC_VEC_PACK_SATURATE_GENCC
165 UNSPEC_VEC_PACK_UNSIGNED_SATURATE
166 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_CC
167 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_GENCC
178 UNSPEC_VEC_ADDEC_U128
183 UNSPEC_VEC_GFMSUM_128
184 UNSPEC_VEC_GFMSUM_ACCUM
185 UNSPEC_VEC_GFMSUM_ACCUM_128
202 UNSPEC_VEC_SUBEC_U128
236 ;; UNSPEC_VOLATILE usage
239 (define_c_enum "unspecv" [
261 ; Hotpatching (unremovable NOPs)
266 ; Transactional Execution support
276 ; Set and get floating point control register
280 ; Split stack support
281 UNSPECV_SPLIT_STACK_CALL
282 UNSPECV_SPLIT_STACK_DATA
291 ; Registers with special meaning
295 ; Sibling call register.
297 ; Literal pool base register.
299 ; Return address register.
301 ; Stack pointer register.
303 ; Condition code register.
305 ; Thread local storage pointer register.
309 ; Hardware register names
313 ; General purpose registers
318 ; Floating point registers.
342 ; Rounding modes for binary floating point numbers
345 (BFP_RND_NEAREST_TIE_AWAY_FROM_0 1)
346 (BFP_RND_PREP_FOR_SHORT_PREC 3)
347 (BFP_RND_NEAREST_TIE_TO_EVEN 4)
349 (BFP_RND_TOWARD_INF 6)
350 (BFP_RND_TOWARD_MINF 7)])
352 ; Rounding modes for decimal floating point numbers
353 ; 1-7 were introduced with the floating point extension facility
354 ; available with z196
355 ; With these rounding modes (1-7) a quantum exception might occur
356 ; which is suppressed for the other modes.
359 (DFP_RND_NEAREST_TIE_AWAY_FROM_0_QUANTEXC 1)
360 (DFP_RND_CURRENT_QUANTEXC 2)
361 (DFP_RND_PREP_FOR_SHORT_PREC_QUANTEXC 3)
362 (DFP_RND_NEAREST_TIE_TO_EVEN_QUANTEXC 4)
363 (DFP_RND_TOWARD_0_QUANTEXC 5)
364 (DFP_RND_TOWARD_INF_QUANTEXC 6)
365 (DFP_RND_TOWARD_MINF_QUANTEXC 7)
366 (DFP_RND_NEAREST_TIE_TO_EVEN 8)
368 (DFP_RND_TOWARD_INF 10)
369 (DFP_RND_TOWARD_MINF 11)
370 (DFP_RND_NEAREST_TIE_AWAY_FROM_0 12)
371 (DFP_RND_NEAREST_TIE_TO_0 13)
372 (DFP_RND_AWAY_FROM_0 14)
373 (DFP_RND_PREP_FOR_SHORT_PREC 15)])
376 ;; PFPO GPR0 argument format
381 ; PFPO operation type
382 (PFPO_CONVERT 0x1000000)
384 (PFPO_OP_TYPE_SF 0x5)
385 (PFPO_OP_TYPE_DF 0x6)
386 (PFPO_OP_TYPE_TF 0x7)
387 (PFPO_OP_TYPE_SD 0x8)
388 (PFPO_OP_TYPE_DD 0x9)
389 (PFPO_OP_TYPE_TD 0xa)
390 ; Bitposition of operand types
391 (PFPO_OP0_TYPE_SHIFT 16)
392 (PFPO_OP1_TYPE_SHIFT 8)
395 ; Immediate operands for tbegin and tbeginc
396 (define_constants [(TBEGIN_MASK 65292)]) ; 0xff0c
397 (define_constants [(TBEGINC_MASK 65288)]) ; 0xff08
399 ;; Instruction operand type as used in the Principles of Operation.
400 ;; Used to determine defaults for length and other attribute values.
402 (define_attr "op_type"
403 "NN,E,RR,RRE,RX,RS,RSI,RI,SI,S,SS,SSE,RXE,RSE,RIL,RIE,RXY,RSY,SIY,RRF,SIL,RRS,RIS,VRI,VRR,VRS,VRV,VRX"
406 ;; Instruction type attribute used for scheduling.
408 (define_attr "type" "none,integer,load,lr,la,larl,lm,stm,
409 cs,vs,store,sem,idiv,
410 imulhi,imulsi,imuldi,
411 branch,jsr,fsimptf,fsimpdf,fsimpsf,fhex,
412 floadtf,floaddf,floadsf,fstoredf,fstoresf,
413 fmultf,fmuldf,fmulsf,fdivtf,fdivdf,fdivsf,
414 ftoi,fsqrttf,fsqrtdf,fsqrtsf,
416 ftrunctf,ftruncdf, ftruncsd, ftruncdd,
417 itoftf, itofdf, itofsf, itofdd, itoftd,
418 fdivdd, fdivtd, floaddd, floadsd, fmuldd, fmultd,
419 fsimpdd, fsimpsd, fsimptd, fstoredd, fstoresd,
421 (cond [(eq_attr "op_type" "NN") (const_string "other")
422 (eq_attr "op_type" "SS") (const_string "cs")]
423 (const_string "integer")))
425 ;; Another attribute used for scheduling purposes:
426 ;; agen: Instruction uses the address generation unit
427 ;; reg: Instruction does not use the agen unit
429 (define_attr "atype" "agen,reg"
430 (if_then_else (eq_attr "op_type" "E,RR,RI,RRE,RSI,RIL,RIE,RRF")
432 (const_string "agen")))
434 ;; Properties concerning Z10 execution grouping and value forwarding.
435 ;; z10_super: instruction is superscalar.
436 ;; z10_super_c: instruction is superscalar and meets the condition of z10_c.
437 ;; z10_fwd: The instruction reads the value of an operand and stores it into a
438 ;; target register. It can forward this value to a second instruction that reads
439 ;; the same register if that second instruction is issued in the same group.
440 ;; z10_rec: The instruction is in the T pipeline and reads a register. If the
441 ;; instruction in the S pipe writes to the register, then the T instruction
442 ;; can immediately read the new value.
443 ;; z10_fr: union of Z10_fwd and z10_rec.
444 ;; z10_c: second operand of instruction is a register and read with complemented bits.
446 ;; An additional suffix A1, A3, or E1 indicates the respective AGI bypass.
449 (define_attr "z10prop" "none,
450 z10_super, z10_super_E1, z10_super_A1, z10_super_c, z10_super_c_E1,
451 z10_fwd, z10_fwd_A1, z10_fwd_A3, z10_fwd_E1,
453 z10_fr, z10_fr_A3, z10_fr_E1,
455 (const_string "none"))
457 ;; Properties concerning Z196 decoding
458 ;; z196_alone: must group alone
459 ;; z196_end: ends a group
460 ;; z196_cracked: instruction is cracked or expanded
461 (define_attr "z196prop" "none,
462 z196_alone, z196_ends,
464 (const_string "none"))
466 (define_attr "mnemonic" "bcr_flush,unknown" (const_string "unknown"))
470 (define_attr "length" ""
471 (cond [(eq_attr "op_type" "E,RR") (const_int 2)
472 (eq_attr "op_type" "RX,RI,RRE,RS,RSI,S,SI,RRF") (const_int 4)]
476 ;; Processor type. This attribute must exactly match the processor_type
477 ;; enumeration in s390.h. The current machine description does not
478 ;; distinguish between g5 and g6, but there are differences between the two
479 ;; CPUs could in theory be modeled.
481 (define_attr "cpu" "g5,g6,z900,z990,z9_109,z9_ec,z10,z196,zEC12,z13,arch12"
482 (const (symbol_ref "s390_tune_attr")))
484 (define_attr "cpu_facility"
485 "standard,ieee,zarch,cpu_zarch,longdisp,extimm,dfp,z10,z196,zEC12,vx,z13,arch12,vxe"
486 (const_string "standard"))
488 (define_attr "enabled" ""
489 (cond [(eq_attr "cpu_facility" "standard")
492 (and (eq_attr "cpu_facility" "ieee")
493 (match_test "TARGET_CPU_IEEE_FLOAT"))
496 (and (eq_attr "cpu_facility" "zarch")
497 (match_test "TARGET_ZARCH"))
500 (and (eq_attr "cpu_facility" "longdisp")
501 (match_test "TARGET_LONG_DISPLACEMENT"))
504 (and (eq_attr "cpu_facility" "extimm")
505 (match_test "TARGET_EXTIMM"))
508 (and (eq_attr "cpu_facility" "dfp")
509 (match_test "TARGET_DFP"))
512 (and (eq_attr "cpu_facility" "cpu_zarch")
513 (match_test "TARGET_CPU_ZARCH"))
516 (and (eq_attr "cpu_facility" "z10")
517 (match_test "TARGET_Z10"))
520 (and (eq_attr "cpu_facility" "z196")
521 (match_test "TARGET_Z196"))
524 (and (eq_attr "cpu_facility" "zEC12")
525 (match_test "TARGET_ZEC12"))
528 (and (eq_attr "cpu_facility" "vx")
529 (match_test "TARGET_VX"))
532 (and (eq_attr "cpu_facility" "z13")
533 (match_test "TARGET_Z13"))
536 (and (eq_attr "cpu_facility" "arch12")
537 (match_test "TARGET_ARCH12"))
540 (and (eq_attr "cpu_facility" "vxe")
541 (match_test "TARGET_VXE"))
546 ;; Pipeline description for z900. For lack of anything better,
547 ;; this description is also used for the g5 and g6.
550 ;; Pipeline description for z990, z9-109 and z9-ec.
553 ;; Pipeline description for z10
556 ;; Pipeline description for z196
559 ;; Pipeline description for zEC12
562 ;; Pipeline description for z13
566 (include "predicates.md")
568 ;; Constraint definitions
569 (include "constraints.md")
576 (define_mode_iterator ALL [TI DI SI HI QI TF DF SF TD DD SD V1QI V2QI V4QI V8QI V16QI V1HI V2HI V4HI V8HI V1SI V2SI V4SI V1DI V2DI V1SF V2SF V4SF V1TI V1DF V2DF V1TF])
578 ;; These mode iterators allow floating point patterns to be generated from the
580 (define_mode_iterator FP_ALL [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")
581 (SD "TARGET_HARD_DFP")])
582 (define_mode_iterator FP [TF DF SF (TD "TARGET_HARD_DFP") (DD "TARGET_HARD_DFP")])
583 (define_mode_iterator BFP [TF DF SF])
584 (define_mode_iterator DFP [TD DD])
585 (define_mode_iterator DFP_ALL [TD DD SD])
586 (define_mode_iterator DSF [DF SF])
587 (define_mode_iterator SD_SF [SF SD])
588 (define_mode_iterator DD_DF [DF DD])
589 (define_mode_iterator TD_TF [TF TD])
591 ;; These mode iterators allow 31-bit and 64-bit GPR patterns to be generated
592 ;; from the same template.
593 (define_mode_iterator GPR [(DI "TARGET_ZARCH") SI])
594 (define_mode_iterator DGPR [(TI "TARGET_ZARCH") DI SI])
595 (define_mode_iterator DSI [DI SI])
596 (define_mode_iterator TDI [TI DI])
598 ;; These mode iterators allow :P to be used for patterns that operate on
599 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
600 (define_mode_iterator P [(DI "TARGET_64BIT") (SI "!TARGET_64BIT")])
602 ;; These macros refer to the actual word_mode of the configuration.
603 ;; This is equal to Pmode except on 31-bit machines in zarch mode.
604 (define_mode_iterator DW [(TI "TARGET_ZARCH") (DI "!TARGET_ZARCH")])
605 (define_mode_iterator W [(DI "TARGET_ZARCH") (SI "!TARGET_ZARCH")])
607 ;; Used by the umul pattern to express modes having half the size.
608 (define_mode_attr DWH [(TI "DI") (DI "SI")])
609 (define_mode_attr dwh [(TI "di") (DI "si")])
611 ;; This mode iterator allows the QI and HI patterns to be defined from
612 ;; the same template.
613 (define_mode_iterator HQI [HI QI])
615 ;; This mode iterator allows the integer patterns to be defined from the
617 (define_mode_iterator INT [(DI "TARGET_ZARCH") SI HI QI])
618 (define_mode_iterator DINT [(TI "TARGET_ZARCH") DI SI HI QI])
619 (define_mode_iterator SINT [SI HI QI])
621 ;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from
622 ;; the same template.
623 (define_code_iterator SHIFT [ashift lshiftrt])
625 ;; This iterator allows r[ox]sbg to be defined with the same template
626 (define_code_iterator IXOR [ior xor])
628 ;; This iterator is used to expand the patterns for the nearest
629 ;; integer functions.
630 (define_int_iterator FPINT [UNSPEC_FPINT_FLOOR UNSPEC_FPINT_BTRUNC
631 UNSPEC_FPINT_ROUND UNSPEC_FPINT_CEIL
632 UNSPEC_FPINT_NEARBYINT])
633 (define_int_attr fpint_name [(UNSPEC_FPINT_FLOOR "floor")
634 (UNSPEC_FPINT_BTRUNC "btrunc")
635 (UNSPEC_FPINT_ROUND "round")
636 (UNSPEC_FPINT_CEIL "ceil")
637 (UNSPEC_FPINT_NEARBYINT "nearbyint")])
638 (define_int_attr fpint_roundingmode [(UNSPEC_FPINT_FLOOR "7")
639 (UNSPEC_FPINT_BTRUNC "5")
640 (UNSPEC_FPINT_ROUND "1")
641 (UNSPEC_FPINT_CEIL "6")
642 (UNSPEC_FPINT_NEARBYINT "0")])
644 ;; This iterator and attribute allow to combine most atomic operations.
645 (define_code_iterator ATOMIC [and ior xor plus minus mult])
646 (define_code_iterator ATOMIC_Z196 [and ior xor plus])
647 (define_code_attr atomic [(and "and") (ior "or") (xor "xor")
648 (plus "add") (minus "sub") (mult "nand")])
649 (define_code_attr noxa [(and "n") (ior "o") (xor "x") (plus "a")])
651 ;; In FP templates, a string like "lt<de>br" will expand to "ltxbr" in
652 ;; TF/TDmode, "ltdbr" in DF/DDmode, and "ltebr" in SF/SDmode.
653 (define_mode_attr xde [(TF "x") (DF "d") (SF "e") (TD "x") (DD "d") (SD "e")])
655 ;; In FP templates, a <dee> in "m<dee><bt>r" will expand to "mx<bt>r" in
656 ;; TF/TDmode, "md<bt>r" in DF/DDmode, "mee<bt>r" in SFmode and "me<bt>r in
658 (define_mode_attr xdee [(TF "x") (DF "d") (SF "ee") (TD "x") (DD "d") (SD "e")])
660 ;; In FP templates, "<RRe>" will expand to "RRE" in TFmode and "RR" otherwise.
661 ;; Likewise for "<RXe>".
662 (define_mode_attr RRe [(TF "RRE") (DF "RR") (SF "RR")])
663 (define_mode_attr RXe [(TF "RXE") (DF "RX") (SF "RX")])
665 ;; The decimal floating point variants of add, sub, div and mul support 3
666 ;; fp register operands. The following attributes allow to merge the bfp and
667 ;; dfp variants in a single insn definition.
669 ;; These mode attributes are supposed to be used in the `enabled' insn
670 ;; attribute to disable certain alternatives for certain modes.
671 (define_mode_attr nBFP [(TF "0") (DF "0") (SF "0") (TD "*") (DD "*") (DD "*")])
672 (define_mode_attr nDFP [(TF "*") (DF "*") (SF "*") (TD "0") (DD "0") (DD "0")])
673 (define_mode_attr DSF [(TF "0") (DF "*") (SF "*") (TD "0") (DD "0") (SD "0")])
674 (define_mode_attr DFDI [(TF "0") (DF "*") (SF "0")
675 (TD "0") (DD "0") (DD "0")
676 (TI "0") (DI "*") (SI "0")])
678 ;; This attribute is used in the operand constraint list
679 ;; for instructions dealing with the sign bit of 32 or 64bit fp values.
680 ;; TFmode values are represented by a fp register pair. Since the
681 ;; sign bit instructions only handle single source and target fp registers
682 ;; these instructions can only be used for TFmode values if the source and
683 ;; target operand uses the same fp register.
684 (define_mode_attr fT0 [(TF "0") (DF "f") (SF "f")])
686 ;; This attribute adds b for bfp instructions and t for dfp instructions and is used
687 ;; within instruction mnemonics.
688 (define_mode_attr bt [(TF "b") (DF "b") (SF "b") (TD "t") (DD "t") (SD "t")])
690 ;; This attribute is used within instruction mnemonics. It evaluates to d for dfp
691 ;; modes and to an empty string for bfp modes.
692 (define_mode_attr _d [(TF "") (DF "") (SF "") (TD "d") (DD "d") (SD "d")])
694 ;; In GPR and P templates, a constraint like "<d0>" will expand to "d" in DImode
695 ;; and "0" in SImode. This allows to combine instructions of which the 31bit
696 ;; version only operates on one register.
697 (define_mode_attr d0 [(DI "d") (SI "0")])
699 ;; In combination with d0 this allows to combine instructions of which the 31bit
700 ;; version only operates on one register. The DImode version needs an additional
701 ;; register for the assembler output.
702 (define_mode_attr 1 [(DI "%1,") (SI "")])
704 ;; In SHIFT templates, a string like "s<lr>dl" will expand to "sldl" in
705 ;; 'ashift' and "srdl" in 'lshiftrt'.
706 (define_code_attr lr [(ashift "l") (lshiftrt "r")])
708 ;; In SHIFT templates, this attribute holds the correct standard name for the
709 ;; pattern itself and the corresponding function calls.
710 (define_code_attr shift [(ashift "ashl") (lshiftrt "lshr")])
712 ;; This attribute handles differences in the instruction 'type' and will result
713 ;; in "RRE" for DImode and "RR" for SImode.
714 (define_mode_attr E [(DI "E") (SI "")])
716 ;; This attribute handles differences in the instruction 'type' and makes RX<Y>
717 ;; to result in "RXY" for DImode and "RX" for SImode.
718 (define_mode_attr Y [(DI "Y") (SI "")])
720 ;; This attribute handles differences in the instruction 'type' and will result
721 ;; in "RSE" for TImode and "RS" for DImode.
722 (define_mode_attr TE [(TI "E") (DI "")])
724 ;; In GPR templates, a string like "lc<g>r" will expand to "lcgr" in DImode
725 ;; and "lcr" in SImode.
726 (define_mode_attr g [(DI "g") (SI "")])
728 ;; In GPR templates, a string like "sl<y>" will expand to "slg" in DImode
729 ;; and "sly" in SImode. This is useful because on 64bit the ..g instructions
730 ;; were enhanced with long displacements whereas 31bit instructions got a ..y
731 ;; variant for long displacements.
732 (define_mode_attr y [(DI "g") (SI "y")])
734 ;; In DW templates, a string like "cds<g>" will expand to "cdsg" in TImode
735 ;; and "cds" in DImode.
736 (define_mode_attr tg [(TI "g") (DI "")])
738 ;; In TDI templates, a string like "c<d>sg".
739 (define_mode_attr td [(TI "d") (DI "")])
741 ;; In GPR templates, a string like "c<gf>dbr" will expand to "cgdbr" in DImode
742 ;; and "cfdbr" in SImode.
743 (define_mode_attr gf [(DI "g") (SI "f")])
745 ;; In GPR templates, a string like sll<gk> will expand to sllg for DI
746 ;; and sllk for SI. This way it is possible to merge the new z196 SI
747 ;; 3 operands shift instructions into the existing patterns.
748 (define_mode_attr gk [(DI "g") (SI "k")])
750 ;; ICM mask required to load MODE value into the lowest subreg
751 ;; of a SImode register.
752 (define_mode_attr icm_lo [(HI "3") (QI "1")])
754 ;; In HQI templates, a string like "llg<hc>" will expand to "llgh" in
755 ;; HImode and "llgc" in QImode.
756 (define_mode_attr hc [(HI "h") (QI "c")])
758 ;; In P templates, the mode <DBL> will expand to "TI" in DImode and "DI"
760 (define_mode_attr DBL [(DI "TI") (SI "DI")])
762 ;; This attribute expands to DF for TFmode and to DD for TDmode . It is
763 ;; used for Txmode splitters splitting a Txmode copy into 2 Dxmode copies.
764 (define_mode_attr HALF_TMODE [(TF "DF") (TD "DD")])
766 ;; Maximum unsigned integer that fits in MODE.
767 (define_mode_attr max_uint [(HI "65535") (QI "255")])
769 ;; Start and end field computations for RISBG et al.
770 (define_mode_attr bfstart [(DI "s") (SI "t")])
771 (define_mode_attr bfend [(DI "e") (SI "f")])
773 ;; In place of GET_MODE_BITSIZE (<MODE>mode)
774 (define_mode_attr bitsize [(DI "64") (SI "32") (HI "16") (QI "8")])
776 (define_mode_attr bitoff [(DI "0") (SI "32") (HI "48") (QI "56")])
777 (define_mode_attr bitoff_plus [(DI "") (SI "32+") (HI "48+") (QI "56+")])
779 ;; In place of GET_MODE_SIZE (<MODE>mode)
780 (define_mode_attr modesize [(DI "8") (SI "4")])
782 ;; Allow return and simple_return to be defined from a single template.
783 (define_code_iterator ANY_RETURN [return simple_return])
787 ; Condition code modes generated by vector fp comparisons. These will
788 ; be used also in single element mode.
789 (define_mode_iterator VFCMP [CCVEQ CCVFH CCVFHE])
790 ; Used with VFCMP to expand part of the mnemonic
791 ; For fp we have a mismatch: eq in the insn name - e in asm
792 (define_mode_attr asm_fcmp [(CCVEQ "e") (CCVFH "h") (CCVFHE "he")])
793 (define_mode_attr insn_cmp [(CCVEQ "eq") (CCVIH "h") (CCVIHU "hl") (CCVFH "h") (CCVFHE "he")])
795 ;; Subst pattern definitions
798 (include "vector.md")
801 ;;- Compare instructions.
804 ; Test-under-Mask instructions
806 (define_insn "*tmqi_mem"
807 [(set (reg CC_REGNUM)
808 (compare (and:QI (match_operand:QI 0 "memory_operand" "Q,S")
809 (match_operand:QI 1 "immediate_operand" "n,n"))
810 (match_operand:QI 2 "immediate_operand" "n,n")))]
811 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], false))"
815 [(set_attr "op_type" "SI,SIY")
816 (set_attr "cpu_facility" "*,longdisp")
817 (set_attr "z10prop" "z10_super,z10_super")])
819 (define_insn "*tmdi_reg"
820 [(set (reg CC_REGNUM)
821 (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "d,d,d,d")
822 (match_operand:DI 1 "immediate_operand"
823 "N0HD0,N1HD0,N2HD0,N3HD0"))
824 (match_operand:DI 2 "immediate_operand" "n,n,n,n")))]
826 && s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
827 && s390_single_part (operands[1], DImode, HImode, 0) >= 0"
833 [(set_attr "op_type" "RI")
834 (set_attr "z10prop" "z10_super,z10_super,z10_super,z10_super")])
836 (define_insn "*tmsi_reg"
837 [(set (reg CC_REGNUM)
838 (compare (and:SI (match_operand:SI 0 "nonimmediate_operand" "d,d")
839 (match_operand:SI 1 "immediate_operand" "N0HS0,N1HS0"))
840 (match_operand:SI 2 "immediate_operand" "n,n")))]
841 "s390_match_ccmode (insn, s390_tm_ccmode (operands[1], operands[2], true))
842 && s390_single_part (operands[1], SImode, HImode, 0) >= 0"
846 [(set_attr "op_type" "RI")
847 (set_attr "z10prop" "z10_super,z10_super")])
849 (define_insn "*tm<mode>_full"
850 [(set (reg CC_REGNUM)
851 (compare (match_operand:HQI 0 "register_operand" "d")
852 (match_operand:HQI 1 "immediate_operand" "n")))]
853 "s390_match_ccmode (insn, s390_tm_ccmode (constm1_rtx, operands[1], true))"
855 [(set_attr "op_type" "RI")
856 (set_attr "z10prop" "z10_super")])
860 ; Load-and-Test instructions
863 ; tst(di|si) instruction pattern(s).
865 (define_insn "*tstdi_sign"
866 [(set (reg CC_REGNUM)
870 (subreg:DI (match_operand:SI 0 "nonimmediate_operand" "d,T") 0)
871 (const_int 32)) (const_int 32))
872 (match_operand:DI 1 "const0_operand" "")))
873 (set (match_operand:DI 2 "register_operand" "=d,d")
874 (sign_extend:DI (match_dup 0)))]
875 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH"
878 [(set_attr "op_type" "RRE,RXY")
879 (set_attr "cpu_facility" "*,z10")
880 (set_attr "z10prop" "z10_super_E1,z10_super_E1") ])
883 (define_insn "*tst<mode>_extimm"
884 [(set (reg CC_REGNUM)
885 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,T")
886 (match_operand:GPR 1 "const0_operand" "")))
887 (set (match_operand:GPR 2 "register_operand" "=d,d")
889 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
893 [(set_attr "op_type" "RR<E>,RXY")
894 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3") ])
897 (define_insn "*tst<mode>_cconly_extimm"
898 [(set (reg CC_REGNUM)
899 (compare (match_operand:GPR 0 "nonimmediate_operand" "d,T")
900 (match_operand:GPR 1 "const0_operand" "")))
901 (clobber (match_scratch:GPR 2 "=X,d"))]
902 "s390_match_ccmode(insn, CCSmode) && TARGET_EXTIMM"
906 [(set_attr "op_type" "RR<E>,RXY")
907 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3")])
909 (define_insn "*tstdi"
910 [(set (reg CC_REGNUM)
911 (compare (match_operand:DI 0 "register_operand" "d")
912 (match_operand:DI 1 "const0_operand" "")))
913 (set (match_operand:DI 2 "register_operand" "=d")
915 "s390_match_ccmode(insn, CCSmode) && TARGET_ZARCH && !TARGET_EXTIMM"
917 [(set_attr "op_type" "RRE")
918 (set_attr "z10prop" "z10_fr_E1")])
920 (define_insn "*tstsi"
921 [(set (reg CC_REGNUM)
922 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
923 (match_operand:SI 1 "const0_operand" "")))
924 (set (match_operand:SI 2 "register_operand" "=d,d,d")
926 "s390_match_ccmode(insn, CCSmode) && !TARGET_EXTIMM"
931 [(set_attr "op_type" "RR,RS,RSY")
932 (set_attr "cpu_facility" "*,*,longdisp")
933 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
935 (define_insn "*tstsi_cconly"
936 [(set (reg CC_REGNUM)
937 (compare (match_operand:SI 0 "nonimmediate_operand" "d,Q,S")
938 (match_operand:SI 1 "const0_operand" "")))
939 (clobber (match_scratch:SI 2 "=X,d,d"))]
940 "s390_match_ccmode(insn, CCSmode)"
945 [(set_attr "op_type" "RR,RS,RSY")
946 (set_attr "cpu_facility" "*,*,longdisp")
947 (set_attr "z10prop" "z10_fr_E1,z10_super_E1,z10_super_E1")])
949 (define_insn "*tstdi_cconly_31"
950 [(set (reg CC_REGNUM)
951 (compare (match_operand:DI 0 "register_operand" "d")
952 (match_operand:DI 1 "const0_operand" "")))]
953 "s390_match_ccmode(insn, CCSmode) && !TARGET_ZARCH"
955 [(set_attr "op_type" "RS")
956 (set_attr "atype" "reg")])
959 (define_insn "*tst<mode>_cconly2"
960 [(set (reg CC_REGNUM)
961 (compare (match_operand:GPR 0 "register_operand" "d")
962 (match_operand:GPR 1 "const0_operand" "")))]
963 "s390_match_ccmode(insn, CCSmode)"
965 [(set_attr "op_type" "RR<E>")
966 (set_attr "z10prop" "z10_fr_E1")])
968 ; tst(hi|qi) instruction pattern(s).
970 (define_insn "*tst<mode>CCT"
971 [(set (reg CC_REGNUM)
972 (compare (match_operand:HQI 0 "nonimmediate_operand" "?Q,?S,d")
973 (match_operand:HQI 1 "const0_operand" "")))
974 (set (match_operand:HQI 2 "register_operand" "=d,d,0")
976 "s390_match_ccmode(insn, CCTmode)"
979 icmy\t%2,<icm_lo>,%S0
981 [(set_attr "op_type" "RS,RSY,RI")
982 (set_attr "cpu_facility" "*,longdisp,*")
983 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
985 (define_insn "*tsthiCCT_cconly"
986 [(set (reg CC_REGNUM)
987 (compare (match_operand:HI 0 "nonimmediate_operand" "Q,S,d")
988 (match_operand:HI 1 "const0_operand" "")))
989 (clobber (match_scratch:HI 2 "=d,d,X"))]
990 "s390_match_ccmode(insn, CCTmode)"
995 [(set_attr "op_type" "RS,RSY,RI")
996 (set_attr "cpu_facility" "*,longdisp,*")
997 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super")])
999 (define_insn "*tstqiCCT_cconly"
1000 [(set (reg CC_REGNUM)
1001 (compare (match_operand:QI 0 "nonimmediate_operand" "?Q,?S,d")
1002 (match_operand:QI 1 "const0_operand" "")))]
1003 "s390_match_ccmode(insn, CCTmode)"
1008 [(set_attr "op_type" "SI,SIY,RI")
1009 (set_attr "cpu_facility" "*,longdisp,*")
1010 (set_attr "z10prop" "z10_super,z10_super,z10_super")])
1012 (define_insn "*tst<mode>"
1013 [(set (reg CC_REGNUM)
1014 (compare (match_operand:HQI 0 "s_operand" "Q,S")
1015 (match_operand:HQI 1 "const0_operand" "")))
1016 (set (match_operand:HQI 2 "register_operand" "=d,d")
1018 "s390_match_ccmode(insn, CCSmode)"
1020 icm\t%2,<icm_lo>,%S0
1021 icmy\t%2,<icm_lo>,%S0"
1022 [(set_attr "op_type" "RS,RSY")
1023 (set_attr "cpu_facility" "*,longdisp")
1024 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1026 (define_insn "*tst<mode>_cconly"
1027 [(set (reg CC_REGNUM)
1028 (compare (match_operand:HQI 0 "s_operand" "Q,S")
1029 (match_operand:HQI 1 "const0_operand" "")))
1030 (clobber (match_scratch:HQI 2 "=d,d"))]
1031 "s390_match_ccmode(insn, CCSmode)"
1033 icm\t%2,<icm_lo>,%S0
1034 icmy\t%2,<icm_lo>,%S0"
1035 [(set_attr "op_type" "RS,RSY")
1036 (set_attr "cpu_facility" "*,longdisp")
1037 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
1040 ; Compare (equality) instructions
1042 (define_insn "*cmpdi_cct"
1043 [(set (reg CC_REGNUM)
1044 (compare (match_operand:DI 0 "nonimmediate_operand" "%d,d,d,d,Q")
1045 (match_operand:DI 1 "general_operand" "d,K,Os,T,BQ")))]
1046 "s390_match_ccmode (insn, CCTmode) && TARGET_ZARCH"
1053 [(set_attr "op_type" "RRE,RI,RIL,RXY,SS")
1054 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,*")])
1056 (define_insn "*cmpsi_cct"
1057 [(set (reg CC_REGNUM)
1058 (compare (match_operand:SI 0 "nonimmediate_operand" "%d,d,d,d,d,Q")
1059 (match_operand:SI 1 "general_operand" "d,K,Os,R,T,BQ")))]
1060 "s390_match_ccmode (insn, CCTmode)"
1068 [(set_attr "op_type" "RR,RI,RIL,RX,RXY,SS")
1069 (set_attr "cpu_facility" "*,*,*,*,longdisp,*")
1070 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*")])
1072 ; Compare (signed) instructions
1074 (define_insn "*cmpdi_ccs_sign"
1075 [(set (reg CC_REGNUM)
1076 (compare (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand"
1078 (match_operand:DI 0 "register_operand" "d, d,d")))]
1079 "s390_match_ccmode(insn, CCSRmode) && TARGET_ZARCH"
1084 [(set_attr "op_type" "RRE,RXY,RIL")
1085 (set_attr "z10prop" "z10_c,*,*")
1086 (set_attr "type" "*,*,larl")])
1090 (define_insn "*cmpsi_ccs_sign"
1091 [(set (reg CC_REGNUM)
1092 (compare (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T,b"))
1093 (match_operand:SI 0 "register_operand" "d,d,d")))]
1094 "s390_match_ccmode(insn, CCSRmode)"
1099 [(set_attr "op_type" "RX,RXY,RIL")
1100 (set_attr "cpu_facility" "*,longdisp,z10")
1101 (set_attr "type" "*,*,larl")
1102 (set_attr "z196prop" "z196_cracked,z196_cracked,z196_cracked")])
1104 (define_insn "*cmphi_ccs_z10"
1105 [(set (reg CC_REGNUM)
1106 (compare (match_operand:HI 0 "s_operand" "Q")
1107 (match_operand:HI 1 "immediate_operand" "K")))]
1108 "s390_match_ccmode(insn, CCSmode) && TARGET_Z10"
1110 [(set_attr "op_type" "SIL")
1111 (set_attr "z196prop" "z196_cracked")])
1113 (define_insn "*cmpdi_ccs_signhi_rl"
1114 [(set (reg CC_REGNUM)
1115 (compare (sign_extend:DI (match_operand:HI 1 "memory_operand" "T,b"))
1116 (match_operand:GPR 0 "register_operand" "d,d")))]
1117 "s390_match_ccmode(insn, CCSRmode) && TARGET_Z10"
1121 [(set_attr "op_type" "RXY,RIL")
1122 (set_attr "type" "*,larl")])
1124 ; cr, chi, cfi, c, cy, cgr, cghi, cgfi, cg, chsi, cghsi, crl, cgrl
1125 (define_insn "*cmp<mode>_ccs"
1126 [(set (reg CC_REGNUM)
1127 (compare (match_operand:GPR 0 "nonimmediate_operand"
1129 (match_operand:GPR 1 "general_operand"
1130 "d,K,K,Os,R,T,b")))]
1131 "s390_match_ccmode(insn, CCSmode)"
1140 [(set_attr "op_type" "RR<E>,RI,SIL,RIL,RX<Y>,RXY,RIL")
1141 (set_attr "cpu_facility" "*,*,z10,extimm,*,longdisp,z10")
1142 (set_attr "type" "*,*,*,*,*,*,larl")
1143 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,z10_super")])
1146 ; Compare (unsigned) instructions
1148 (define_insn "*cmpsi_ccu_zerohi_rlsi"
1149 [(set (reg CC_REGNUM)
1150 (compare (zero_extend:SI (mem:HI (match_operand:SI 1
1151 "larl_operand" "X")))
1152 (match_operand:SI 0 "register_operand" "d")))]
1153 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
1155 [(set_attr "op_type" "RIL")
1156 (set_attr "type" "larl")
1157 (set_attr "z10prop" "z10_super")])
1160 (define_insn "*cmp<GPR:mode>_ccu_zerohi_rldi"
1161 [(set (reg CC_REGNUM)
1162 (compare (zero_extend:GPR (mem:HI (match_operand:DI 1
1163 "larl_operand" "X")))
1164 (match_operand:GPR 0 "register_operand" "d")))]
1165 "s390_match_ccmode(insn, CCURmode) && TARGET_Z10"
1167 [(set_attr "op_type" "RIL")
1168 (set_attr "type" "larl")
1169 (set_attr "z10prop" "z10_super")])
1171 (define_insn "*cmpdi_ccu_zero"
1172 [(set (reg CC_REGNUM)
1173 (compare (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand"
1175 (match_operand:DI 0 "register_operand" "d,d,d")))]
1176 "s390_match_ccmode (insn, CCURmode) && TARGET_ZARCH"
1181 [(set_attr "op_type" "RRE,RXY,RIL")
1182 (set_attr "cpu_facility" "*,*,z10")
1183 (set_attr "type" "*,*,larl")
1184 (set_attr "z10prop" "z10_super_c,z10_super_E1,z10_super")])
1186 (define_insn "*cmpdi_ccu"
1187 [(set (reg CC_REGNUM)
1188 (compare (match_operand:DI 0 "nonimmediate_operand"
1190 (match_operand:DI 1 "general_operand"
1191 "d,Op,b,D,T,BQ,Q")))]
1192 "s390_match_ccmode (insn, CCUmode) && TARGET_ZARCH"
1201 [(set_attr "op_type" "RRE,RIL,RIL,SIL,RXY,SS,SS")
1202 (set_attr "cpu_facility" "*,extimm,z10,z10,*,*,*")
1203 (set_attr "type" "*,*,larl,*,*,*,*")
1204 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,*,*")])
1206 (define_insn "*cmpsi_ccu"
1207 [(set (reg CC_REGNUM)
1208 (compare (match_operand:SI 0 "nonimmediate_operand" "d, d,d,Q,d,d, Q,BQ")
1209 (match_operand:SI 1 "general_operand" "d,Os,b,D,R,T,BQ, Q")))]
1210 "s390_match_ccmode (insn, CCUmode)"
1220 [(set_attr "op_type" "RR,RIL,RIL,SIL,RX,RXY,SS,SS")
1221 (set_attr "cpu_facility" "*,extimm,z10,z10,*,longdisp,*,*")
1222 (set_attr "type" "*,*,larl,*,*,*,*,*")
1223 (set_attr "z10prop" "z10_super_c,z10_super,z10_super,z10_super,z10_super,z10_super,*,*")])
1225 (define_insn "*cmphi_ccu"
1226 [(set (reg CC_REGNUM)
1227 (compare (match_operand:HI 0 "nonimmediate_operand" "d,d,Q,Q,BQ")
1228 (match_operand:HI 1 "general_operand" "Q,S,D,BQ,Q")))]
1229 "s390_match_ccmode (insn, CCUmode)
1230 && !register_operand (operands[1], HImode)"
1237 [(set_attr "op_type" "RS,RSY,SIL,SS,SS")
1238 (set_attr "cpu_facility" "*,longdisp,z10,*,*")
1239 (set_attr "z10prop" "*,*,z10_super,*,*")])
1241 (define_insn "*cmpqi_ccu"
1242 [(set (reg CC_REGNUM)
1243 (compare (match_operand:QI 0 "nonimmediate_operand" "d,d,Q,S,Q,BQ")
1244 (match_operand:QI 1 "general_operand" "Q,S,n,n,BQ,Q")))]
1245 "s390_match_ccmode (insn, CCUmode)
1246 && !register_operand (operands[1], QImode)"
1254 [(set_attr "op_type" "RS,RSY,SI,SIY,SS,SS")
1255 (set_attr "cpu_facility" "*,longdisp,*,longdisp,*,*")
1256 (set_attr "z10prop" "*,*,z10_super,z10_super,*,*")])
1259 ; Block compare (CLC) instruction patterns.
1262 [(set (reg CC_REGNUM)
1263 (compare (match_operand:BLK 0 "memory_operand" "Q")
1264 (match_operand:BLK 1 "memory_operand" "Q")))
1265 (use (match_operand 2 "const_int_operand" "n"))]
1266 "s390_match_ccmode (insn, CCUmode)
1267 && INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
1268 "clc\t%O0(%2,%R0),%S1"
1269 [(set_attr "op_type" "SS")])
1272 [(set (reg CC_REGNUM)
1273 (compare (match_operand 0 "memory_operand" "")
1274 (match_operand 1 "memory_operand" "")))]
1276 && s390_match_ccmode (insn, CCUmode)
1277 && GET_MODE (operands[0]) == GET_MODE (operands[1])
1278 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
1280 [(set (match_dup 0) (match_dup 1))
1281 (use (match_dup 2))])]
1283 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
1284 operands[0] = adjust_address (operands[0], BLKmode, 0);
1285 operands[1] = adjust_address (operands[1], BLKmode, 0);
1287 operands[1] = gen_rtx_COMPARE (GET_MODE (SET_DEST (PATTERN (curr_insn))),
1288 operands[0], operands[1]);
1289 operands[0] = SET_DEST (PATTERN (curr_insn));
1293 ; (TF|DF|SF|TD|DD|SD) instructions
1296 ; load and test instructions turn SNaN into QNaN what is not
1297 ; acceptable if the target will be used afterwards. On the other hand
1298 ; they are quite convenient for implementing comparisons with 0.0. So
1299 ; try to enable them via splitter if the value isn't needed anymore.
1301 ; ltxbr, ltdbr, ltebr, ltxtr, ltdtr
1302 (define_insn "*cmp<mode>_ccs_0"
1303 [(set (reg CC_REGNUM)
1304 (compare (match_operand:FP 0 "register_operand" "f")
1305 (match_operand:FP 1 "const0_operand" "")))
1306 (clobber (match_operand:FP 2 "register_operand" "=0"))]
1307 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1308 "lt<xde><bt>r\t%0,%0"
1309 [(set_attr "op_type" "RRE")
1310 (set_attr "type" "fsimp<mode>")])
1313 [(set (match_operand 0 "cc_reg_operand")
1314 (compare (match_operand:FP 1 "register_operand")
1315 (match_operand:FP 2 "const0_operand")))]
1316 "TARGET_HARD_FLOAT && REG_P (operands[1]) && dead_or_set_p (insn, operands[1])"
1318 [(set (match_dup 0) (match_dup 3))
1319 (clobber (match_dup 1))])]
1321 /* s390_match_ccmode requires the compare to have the same CC mode
1322 as the CC destination register. */
1323 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[0]),
1324 operands[1], operands[2]);
1328 ; cxtr, cdtr, cxbr, cdbr, cebr, cdb, ceb, wfcdb
1329 (define_insn "*cmp<mode>_ccs"
1330 [(set (reg CC_REGNUM)
1331 (compare (match_operand:FP 0 "register_operand" "f,f,v")
1332 (match_operand:FP 1 "general_operand" "f,R,v")))]
1333 "s390_match_ccmode(insn, CCSmode) && TARGET_HARD_FLOAT"
1338 [(set_attr "op_type" "RRE,RXE,VRR")
1339 (set_attr "cpu_facility" "*,*,vx")
1340 (set_attr "enabled" "*,<DSF>,<DFDI>")])
1343 ; Compare and Branch instructions
1345 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1346 ; The following instructions do a complementary access of their second
1347 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1348 (define_insn "*cmp_and_br_signed_<mode>"
1350 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1351 [(match_operand:GPR 1 "register_operand" "d,d")
1352 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1353 (label_ref (match_operand 3 "" ""))
1355 (clobber (reg:CC CC_REGNUM))]
1356 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1358 if (get_attr_length (insn) == 6)
1359 return which_alternative ?
1360 "c<g>ij%C0\t%1,%c2,%l3" : "c<g>rj%C0\t%1,%2,%l3";
1362 return which_alternative ?
1363 "c<g>fi\t%1,%c2\;jg%C0\t%l3" : "c<g>r\t%1,%2\;jg%C0\t%l3";
1365 [(set_attr "op_type" "RIE")
1366 (set_attr "type" "branch")
1367 (set_attr "z10prop" "z10_super_c,z10_super")
1368 (set (attr "length")
1369 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1370 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1371 ; 10 byte for cgr/jg
1373 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1374 ; The following instructions do a complementary access of their second
1375 ; operand (z10 only): clrj, clgrj, clr, clgr
1376 (define_insn "*cmp_and_br_unsigned_<mode>"
1378 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1379 [(match_operand:GPR 1 "register_operand" "d,d")
1380 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1381 (label_ref (match_operand 3 "" ""))
1383 (clobber (reg:CC CC_REGNUM))]
1384 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1386 if (get_attr_length (insn) == 6)
1387 return which_alternative ?
1388 "cl<g>ij%C0\t%1,%b2,%l3" : "cl<g>rj%C0\t%1,%2,%l3";
1390 return which_alternative ?
1391 "cl<g>fi\t%1,%b2\;jg%C0\t%l3" : "cl<g>r\t%1,%2\;jg%C0\t%l3";
1393 [(set_attr "op_type" "RIE")
1394 (set_attr "type" "branch")
1395 (set_attr "z10prop" "z10_super_c,z10_super")
1396 (set (attr "length")
1397 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1398 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1399 ; 10 byte for clgr/jg
1401 ; And now the same two patterns as above but with a negated CC mask.
1403 ; cij, cgij, crj, cgrj, cfi, cgfi, cr, cgr
1404 ; The following instructions do a complementary access of their second
1405 ; operand (z01 only): crj_c, cgrjc, cr, cgr
1406 (define_insn "*icmp_and_br_signed_<mode>"
1408 (if_then_else (match_operator 0 "s390_signed_integer_comparison"
1409 [(match_operand:GPR 1 "register_operand" "d,d")
1410 (match_operand:GPR 2 "nonmemory_operand" "d,C")])
1412 (label_ref (match_operand 3 "" ""))))
1413 (clobber (reg:CC CC_REGNUM))]
1414 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1416 if (get_attr_length (insn) == 6)
1417 return which_alternative ?
1418 "c<g>ij%D0\t%1,%c2,%l3" : "c<g>rj%D0\t%1,%2,%l3";
1420 return which_alternative ?
1421 "c<g>fi\t%1,%c2\;jg%D0\t%l3" : "c<g>r\t%1,%2\;jg%D0\t%l3";
1423 [(set_attr "op_type" "RIE")
1424 (set_attr "type" "branch")
1425 (set_attr "z10prop" "z10_super_c,z10_super")
1426 (set (attr "length")
1427 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1428 (const_int 6) (const_int 12)))]) ; 8 byte for cr/jg
1429 ; 10 byte for cgr/jg
1431 ; clij, clgij, clrj, clgrj, clfi, clgfi, clr, clgr
1432 ; The following instructions do a complementary access of their second
1433 ; operand (z10 only): clrj, clgrj, clr, clgr
1434 (define_insn "*icmp_and_br_unsigned_<mode>"
1436 (if_then_else (match_operator 0 "s390_unsigned_integer_comparison"
1437 [(match_operand:GPR 1 "register_operand" "d,d")
1438 (match_operand:GPR 2 "nonmemory_operand" "d,I")])
1440 (label_ref (match_operand 3 "" ""))))
1441 (clobber (reg:CC CC_REGNUM))]
1442 "TARGET_Z10 && !TARGET_AVOID_CMP_AND_BRANCH"
1444 if (get_attr_length (insn) == 6)
1445 return which_alternative ?
1446 "cl<g>ij%D0\t%1,%b2,%l3" : "cl<g>rj%D0\t%1,%2,%l3";
1448 return which_alternative ?
1449 "cl<g>fi\t%1,%b2\;jg%D0\t%l3" : "cl<g>r\t%1,%2\;jg%D0\t%l3";
1451 [(set_attr "op_type" "RIE")
1452 (set_attr "type" "branch")
1453 (set_attr "z10prop" "z10_super_c,z10_super")
1454 (set (attr "length")
1455 (if_then_else (lt (abs (minus (pc) (match_dup 3))) (const_int 60000))
1456 (const_int 6) (const_int 12)))]) ; 8 byte for clr/jg
1457 ; 10 byte for clgr/jg
1460 ;;- Move instructions.
1464 ; movti instruction pattern(s).
1467 ; FIXME: More constants are possible by enabling jxx, jyy constraints
1468 ; for TImode (use double-int for the calculations)
1469 (define_insn "movti"
1470 [(set (match_operand:TI 0 "nonimmediate_operand" "=d,S,v, v, v,v,d,v,R, d,o")
1471 (match_operand:TI 1 "general_operand" " S,d,v,j00,jm1,d,v,R,v,dPT,d"))]
1485 [(set_attr "op_type" "RSY,RSY,VRR,VRI,VRI,VRR,*,VRX,VRX,*,*")
1486 (set_attr "type" "lm,stm,*,*,*,*,*,*,*,*,*")
1487 (set_attr "cpu_facility" "*,*,vx,vx,vx,vx,vx,vx,vx,*,*")])
1490 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1491 (match_operand:TI 1 "general_operand" ""))]
1492 "TARGET_ZARCH && reload_completed
1493 && !s_operand (operands[0], TImode)
1494 && !s_operand (operands[1], TImode)
1495 && s390_split_ok_p (operands[0], operands[1], TImode, 0)"
1496 [(set (match_dup 2) (match_dup 4))
1497 (set (match_dup 3) (match_dup 5))]
1499 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1500 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1501 operands[4] = operand_subword (operands[1], 0, 0, TImode);
1502 operands[5] = operand_subword (operands[1], 1, 0, TImode);
1506 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1507 (match_operand:TI 1 "general_operand" ""))]
1508 "TARGET_ZARCH && reload_completed
1509 && !s_operand (operands[0], TImode)
1510 && !s_operand (operands[1], TImode)
1511 && s390_split_ok_p (operands[0], operands[1], TImode, 1)"
1512 [(set (match_dup 2) (match_dup 4))
1513 (set (match_dup 3) (match_dup 5))]
1515 operands[2] = operand_subword (operands[0], 1, 0, TImode);
1516 operands[3] = operand_subword (operands[0], 0, 0, TImode);
1517 operands[4] = operand_subword (operands[1], 1, 0, TImode);
1518 operands[5] = operand_subword (operands[1], 0, 0, TImode);
1521 ; Use part of the TImode target reg to perform the address
1522 ; calculation. If the TImode value is supposed to be copied into a VR
1523 ; this splitter is not necessary.
1525 [(set (match_operand:TI 0 "register_operand" "")
1526 (match_operand:TI 1 "memory_operand" ""))]
1527 "TARGET_ZARCH && reload_completed
1528 && !VECTOR_REG_P (operands[0])
1529 && !s_operand (operands[1], VOIDmode)"
1530 [(set (match_dup 0) (match_dup 1))]
1532 rtx addr = operand_subword (operands[0], 1, 0, TImode);
1533 addr = gen_lowpart (Pmode, addr);
1534 s390_load_address (addr, XEXP (operands[1], 0));
1535 operands[1] = replace_equiv_address (operands[1], addr);
1539 ; Split a VR -> GPR TImode move into 2 vector load GR from VR element.
1540 ; For the higher order bits we do simply a DImode move while the
1541 ; second part is done via vec extract. Both will end up as vlgvg.
1543 [(set (match_operand:TI 0 "register_operand" "")
1544 (match_operand:TI 1 "register_operand" ""))]
1545 "TARGET_VX && reload_completed
1546 && GENERAL_REG_P (operands[0])
1547 && VECTOR_REG_P (operands[1])"
1548 [(set (match_dup 2) (match_dup 4))
1549 (set (match_dup 3) (unspec:DI [(match_dup 5) (const_int 1)]
1550 UNSPEC_VEC_EXTRACT))]
1552 operands[2] = operand_subword (operands[0], 0, 0, TImode);
1553 operands[3] = operand_subword (operands[0], 1, 0, TImode);
1554 operands[4] = gen_rtx_REG (DImode, REGNO (operands[1]));
1555 operands[5] = gen_rtx_REG (V2DImode, REGNO (operands[1]));
1559 ; Patterns used for secondary reloads
1562 ; z10 provides move instructions accepting larl memory operands.
1563 ; Unfortunately there is no such variant for QI, TI and FP mode moves.
1564 ; These patterns are also used for unaligned SI and DI accesses.
1566 (define_expand "reload<ALL:mode><P:mode>_tomem_z10"
1567 [(parallel [(match_operand:ALL 0 "memory_operand" "")
1568 (match_operand:ALL 1 "register_operand" "=d")
1569 (match_operand:P 2 "register_operand" "=&a")])]
1572 s390_reload_symref_address (operands[1], operands[0], operands[2], 1);
1576 (define_expand "reload<ALL:mode><P:mode>_toreg_z10"
1577 [(parallel [(match_operand:ALL 0 "register_operand" "=d")
1578 (match_operand:ALL 1 "memory_operand" "")
1579 (match_operand:P 2 "register_operand" "=a")])]
1582 s390_reload_symref_address (operands[0], operands[1], operands[2], 0);
1586 (define_expand "reload<P:mode>_larl_odd_addend_z10"
1587 [(parallel [(match_operand:P 0 "register_operand" "=d")
1588 (match_operand:P 1 "larl_operand" "")
1589 (match_operand:P 2 "register_operand" "=a")])]
1592 s390_reload_larl_operand (operands[0], operands[1], operands[2]);
1596 ; Handles loading a PLUS (load address) expression
1598 (define_expand "reload<mode>_plus"
1599 [(parallel [(match_operand:P 0 "register_operand" "=a")
1600 (match_operand:P 1 "s390_plus_operand" "")
1601 (match_operand:P 2 "register_operand" "=&a")])]
1604 s390_expand_plus_operand (operands[0], operands[1], operands[2]);
1608 ; Not all the indirect memory access instructions support the full
1609 ; format (long disp + index + base). So whenever a move from/to such
1610 ; an address is required and the instruction cannot deal with it we do
1611 ; a load address into a scratch register first and use this as the new
1613 ; This in particular is used for:
1614 ; - non-offsetable memory accesses for multiword moves
1615 ; - full vector reg moves with long displacements
1617 (define_expand "reload<mode>_la_in"
1618 [(parallel [(match_operand 0 "register_operand" "")
1619 (match_operand 1 "" "")
1620 (match_operand:P 2 "register_operand" "=&a")])]
1623 gcc_assert (MEM_P (operands[1]));
1624 s390_load_address (operands[2], find_replacement (&XEXP (operands[1], 0)));
1625 operands[1] = replace_equiv_address (operands[1], operands[2]);
1626 emit_move_insn (operands[0], operands[1]);
1630 (define_expand "reload<mode>_la_out"
1631 [(parallel [(match_operand 0 "" "")
1632 (match_operand 1 "register_operand" "")
1633 (match_operand:P 2 "register_operand" "=&a")])]
1636 gcc_assert (MEM_P (operands[0]));
1637 s390_load_address (operands[2], find_replacement (&XEXP (operands[0], 0)));
1638 operands[0] = replace_equiv_address (operands[0], operands[2]);
1639 emit_move_insn (operands[0], operands[1]);
1643 (define_expand "reload<mode>_PIC_addr"
1644 [(parallel [(match_operand 0 "register_operand" "=d")
1645 (match_operand 1 "larl_operand" "")
1646 (match_operand:P 2 "register_operand" "=a")])]
1649 rtx new_rtx = legitimize_pic_address (operands[1], operands[2]);
1650 emit_move_insn (operands[0], new_rtx);
1654 ; movdi instruction pattern(s).
1657 (define_expand "movdi"
1658 [(set (match_operand:DI 0 "general_operand" "")
1659 (match_operand:DI 1 "general_operand" ""))]
1662 /* Handle symbolic constants. */
1664 && (SYMBOLIC_CONST (operands[1])
1665 || (GET_CODE (operands[1]) == PLUS
1666 && XEXP (operands[1], 0) == pic_offset_table_rtx
1667 && SYMBOLIC_CONST (XEXP (operands[1], 1)))))
1668 emit_symbolic_move (operands);
1671 (define_insn "*movdi_larl"
1672 [(set (match_operand:DI 0 "register_operand" "=d")
1673 (match_operand:DI 1 "larl_operand" "X"))]
1675 && !FP_REG_P (operands[0])"
1677 [(set_attr "op_type" "RIL")
1678 (set_attr "type" "larl")
1679 (set_attr "z10prop" "z10_super_A1")])
1681 (define_insn "*movdi_64"
1682 [(set (match_operand:DI 0 "nonimmediate_operand"
1683 "=d, d, d, d, d, d, d, d,f,d,d,d,d,d,T,!*f,!*f,!*f,!R,!T,b,Q,d,t,Q,t,v,v,v,d,v,R")
1684 (match_operand:DI 1 "general_operand"
1685 " K,N0HD0,N1HD0,N2HD0,N3HD0,Os,N0SD0,N1SD0,d,f,L,b,d,T,d, *f, R, T,*f,*f,d,K,t,d,t,Q,K,v,d,v,R,v"))]
1720 [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RXY,RIL,RRE,RXY,
1721 RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS,VRX,VRX")
1722 (set_attr "type" "*,*,*,*,*,*,*,*,floaddf,floaddf,la,larl,lr,load,store,
1723 floaddf,floaddf,floaddf,fstoredf,fstoredf,larl,*,*,*,*,
1725 (set_attr "cpu_facility" "*,*,*,*,*,extimm,extimm,extimm,dfp,dfp,longdisp,
1726 z10,*,*,*,*,*,longdisp,*,longdisp,
1727 z10,z10,*,*,*,*,vx,vx,vx,vx,vx,vx")
1728 (set_attr "z10prop" "z10_fwd_A1,
1757 [(set (match_operand:DI 0 "register_operand" "")
1758 (match_operand:DI 1 "register_operand" ""))]
1759 "TARGET_ZARCH && ACCESS_REG_P (operands[1])"
1760 [(set (match_dup 2) (match_dup 3))
1761 (set (match_dup 0) (ashift:DI (match_dup 0) (const_int 32)))
1762 (set (strict_low_part (match_dup 2)) (match_dup 4))]
1763 "operands[2] = gen_lowpart (SImode, operands[0]);
1764 s390_split_access_reg (operands[1], &operands[4], &operands[3]);")
1767 [(set (match_operand:DI 0 "register_operand" "")
1768 (match_operand:DI 1 "register_operand" ""))]
1769 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
1770 && dead_or_set_p (insn, operands[1])"
1771 [(set (match_dup 3) (match_dup 2))
1772 (set (match_dup 1) (lshiftrt:DI (match_dup 1) (const_int 32)))
1773 (set (match_dup 4) (match_dup 2))]
1774 "operands[2] = gen_lowpart (SImode, operands[1]);
1775 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1778 [(set (match_operand:DI 0 "register_operand" "")
1779 (match_operand:DI 1 "register_operand" ""))]
1780 "TARGET_ZARCH && ACCESS_REG_P (operands[0])
1781 && !dead_or_set_p (insn, operands[1])"
1782 [(set (match_dup 3) (match_dup 2))
1783 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))
1784 (set (match_dup 4) (match_dup 2))
1785 (set (match_dup 1) (rotate:DI (match_dup 1) (const_int 32)))]
1786 "operands[2] = gen_lowpart (SImode, operands[1]);
1787 s390_split_access_reg (operands[0], &operands[3], &operands[4]);")
1789 (define_insn "*movdi_31"
1790 [(set (match_operand:DI 0 "nonimmediate_operand"
1791 "=d,d,Q,S,d ,o,!*f,!*f,!*f,!R,!T,d")
1792 (match_operand:DI 1 "general_operand"
1793 " Q,S,d,d,dPT,d, *f, R, T,*f,*f,b"))]
1808 [(set_attr "op_type" "RS,RSY,RS,RSY,*,*,RR,RX,RXY,RX,RXY,*")
1809 (set_attr "type" "lm,lm,stm,stm,*,*,floaddf,floaddf,floaddf,fstoredf,fstoredf,*")
1810 (set_attr "cpu_facility" "*,longdisp,*,longdisp,*,*,*,*,longdisp,*,longdisp,z10")])
1812 ; For a load from a symbol ref we can use one of the target registers
1813 ; together with larl to load the address.
1815 [(set (match_operand:DI 0 "register_operand" "")
1816 (match_operand:DI 1 "memory_operand" ""))]
1817 "!TARGET_ZARCH && reload_completed && TARGET_Z10
1818 && larl_operand (XEXP (operands[1], 0), SImode)"
1819 [(set (match_dup 2) (match_dup 3))
1820 (set (match_dup 0) (match_dup 1))]
1822 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1823 operands[3] = XEXP (operands[1], 0);
1824 operands[1] = replace_equiv_address (operands[1], operands[2]);
1828 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1829 (match_operand:DI 1 "general_operand" ""))]
1830 "!TARGET_ZARCH && reload_completed
1831 && !s_operand (operands[0], DImode)
1832 && !s_operand (operands[1], DImode)
1833 && s390_split_ok_p (operands[0], operands[1], DImode, 0)"
1834 [(set (match_dup 2) (match_dup 4))
1835 (set (match_dup 3) (match_dup 5))]
1837 operands[2] = operand_subword (operands[0], 0, 0, DImode);
1838 operands[3] = operand_subword (operands[0], 1, 0, DImode);
1839 operands[4] = operand_subword (operands[1], 0, 0, DImode);
1840 operands[5] = operand_subword (operands[1], 1, 0, DImode);
1844 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1845 (match_operand:DI 1 "general_operand" ""))]
1846 "!TARGET_ZARCH && reload_completed
1847 && !s_operand (operands[0], DImode)
1848 && !s_operand (operands[1], DImode)
1849 && s390_split_ok_p (operands[0], operands[1], DImode, 1)"
1850 [(set (match_dup 2) (match_dup 4))
1851 (set (match_dup 3) (match_dup 5))]
1853 operands[2] = operand_subword (operands[0], 1, 0, DImode);
1854 operands[3] = operand_subword (operands[0], 0, 0, DImode);
1855 operands[4] = operand_subword (operands[1], 1, 0, DImode);
1856 operands[5] = operand_subword (operands[1], 0, 0, DImode);
1860 [(set (match_operand:DI 0 "register_operand" "")
1861 (match_operand:DI 1 "memory_operand" ""))]
1862 "!TARGET_ZARCH && reload_completed
1863 && !FP_REG_P (operands[0])
1864 && !s_operand (operands[1], VOIDmode)"
1865 [(set (match_dup 0) (match_dup 1))]
1867 rtx addr = operand_subword (operands[0], 1, 0, DImode);
1868 s390_load_address (addr, XEXP (operands[1], 0));
1869 operands[1] = replace_equiv_address (operands[1], addr);
1873 [(set (match_operand:DI 0 "register_operand" "")
1874 (mem:DI (match_operand 1 "address_operand" "")))]
1876 && !FP_REG_P (operands[0])
1877 && GET_CODE (operands[1]) == SYMBOL_REF
1878 && CONSTANT_POOL_ADDRESS_P (operands[1])
1879 && get_pool_mode (operands[1]) == DImode
1880 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
1881 [(set (match_dup 0) (match_dup 2))]
1882 "operands[2] = get_pool_constant (operands[1]);")
1884 (define_insn "*la_64"
1885 [(set (match_operand:DI 0 "register_operand" "=d,d")
1886 (match_operand:QI 1 "address_operand" "ZR,ZT"))]
1891 [(set_attr "op_type" "RX,RXY")
1892 (set_attr "type" "la")
1893 (set_attr "cpu_facility" "*,longdisp")
1894 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
1898 [(set (match_operand:DI 0 "register_operand" "")
1899 (match_operand:QI 1 "address_operand" ""))
1900 (clobber (reg:CC CC_REGNUM))])]
1902 && preferred_la_operand_p (operands[1], const0_rtx)"
1903 [(set (match_dup 0) (match_dup 1))]
1907 [(set (match_operand:DI 0 "register_operand" "")
1908 (match_operand:DI 1 "register_operand" ""))
1911 (plus:DI (match_dup 0)
1912 (match_operand:DI 2 "nonmemory_operand" "")))
1913 (clobber (reg:CC CC_REGNUM))])]
1915 && !reg_overlap_mentioned_p (operands[0], operands[2])
1916 && preferred_la_operand_p (operands[1], operands[2])"
1917 [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 2)))]
1921 ; movsi instruction pattern(s).
1924 (define_expand "movsi"
1925 [(set (match_operand:SI 0 "general_operand" "")
1926 (match_operand:SI 1 "general_operand" ""))]
1929 /* Handle symbolic constants. */
1931 && (SYMBOLIC_CONST (operands[1])
1932 || (GET_CODE (operands[1]) == PLUS
1933 && XEXP (operands[1], 0) == pic_offset_table_rtx
1934 && SYMBOLIC_CONST (XEXP(operands[1], 1)))))
1935 emit_symbolic_move (operands);
1938 (define_insn "*movsi_larl"
1939 [(set (match_operand:SI 0 "register_operand" "=d")
1940 (match_operand:SI 1 "larl_operand" "X"))]
1941 "!TARGET_64BIT && TARGET_CPU_ZARCH
1942 && !FP_REG_P (operands[0])"
1944 [(set_attr "op_type" "RIL")
1945 (set_attr "type" "larl")
1946 (set_attr "z10prop" "z10_fwd_A1")])
1948 (define_insn "*movsi_zarch"
1949 [(set (match_operand:SI 0 "nonimmediate_operand"
1950 "=d, d, d, d,d,d,d,d,d,R,T,!*f,!*f,!*f,!*f,!*f,!R,!T,d,t,Q,b,Q,t,v,v,v,d,v,R")
1951 (match_operand:SI 1 "general_operand"
1952 " K,N0HS0,N1HS0,Os,L,b,d,R,T,d,d, *f, *f, R, R, T,*f,*f,t,d,t,d,K,Q,K,v,d,v,R,v"))]
1985 [(set_attr "op_type" "RI,RI,RI,RIL,RXY,RIL,RR,RX,RXY,RX,RXY,
1986 RR,RR,RXE,RX,RXY,RX,RXY,RRE,RRE,RS,RIL,SIL,RS,VRI,VRR,VRS,VRS,VRX,VRX")
1987 (set_attr "type" "*,
2011 (set_attr "cpu_facility" "*,*,*,extimm,longdisp,z10,*,*,longdisp,*,longdisp,
2012 vx,*,vx,*,longdisp,*,longdisp,*,*,*,z10,z10,*,vx,vx,vx,vx,vx,vx")
2013 (set_attr "z10prop" "z10_fwd_A1,
2038 (define_insn "*movsi_esa"
2039 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,R,!*f,!*f,!*f,!*f,!R,d,t,Q,t")
2040 (match_operand:SI 1 "general_operand" "K,d,R,d, *f, *f, R, R,*f,t,d,t,Q"))]
2056 [(set_attr "op_type" "RI,RR,RX,RX,RR,RR,RXE,RX,RX,RRE,RRE,RS,RS")
2057 (set_attr "type" "*,lr,load,store,floadsf,floadsf,floadsf,floadsf,fstoresf,*,*,*,*")
2058 (set_attr "z10prop" "z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_rec,*,*,*,*,*,z10_super_E1,
2060 (set_attr "cpu_facility" "*,*,*,*,vx,*,vx,*,*,*,*,*,*")
2064 [(set (match_operand:SI 0 "register_operand" "")
2065 (mem:SI (match_operand 1 "address_operand" "")))]
2066 "!FP_REG_P (operands[0])
2067 && GET_CODE (operands[1]) == SYMBOL_REF
2068 && CONSTANT_POOL_ADDRESS_P (operands[1])
2069 && get_pool_mode (operands[1]) == SImode
2070 && legitimate_reload_constant_p (get_pool_constant (operands[1]))"
2071 [(set (match_dup 0) (match_dup 2))]
2072 "operands[2] = get_pool_constant (operands[1]);")
2074 (define_insn "*la_31"
2075 [(set (match_operand:SI 0 "register_operand" "=d,d")
2076 (match_operand:QI 1 "address_operand" "ZR,ZT"))]
2077 "!TARGET_64BIT && legitimate_la_operand_p (operands[1])"
2081 [(set_attr "op_type" "RX,RXY")
2082 (set_attr "type" "la")
2083 (set_attr "cpu_facility" "*,longdisp")
2084 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
2088 [(set (match_operand:SI 0 "register_operand" "")
2089 (match_operand:QI 1 "address_operand" ""))
2090 (clobber (reg:CC CC_REGNUM))])]
2092 && preferred_la_operand_p (operands[1], const0_rtx)"
2093 [(set (match_dup 0) (match_dup 1))]
2097 [(set (match_operand:SI 0 "register_operand" "")
2098 (match_operand:SI 1 "register_operand" ""))
2101 (plus:SI (match_dup 0)
2102 (match_operand:SI 2 "nonmemory_operand" "")))
2103 (clobber (reg:CC CC_REGNUM))])]
2105 && !reg_overlap_mentioned_p (operands[0], operands[2])
2106 && preferred_la_operand_p (operands[1], operands[2])"
2107 [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 2)))]
2110 (define_insn "*la_31_and"
2111 [(set (match_operand:SI 0 "register_operand" "=d,d")
2112 (and:SI (match_operand:QI 1 "address_operand" "ZR,ZT")
2113 (const_int 2147483647)))]
2118 [(set_attr "op_type" "RX,RXY")
2119 (set_attr "type" "la")
2120 (set_attr "cpu_facility" "*,longdisp")
2121 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
2123 (define_insn_and_split "*la_31_and_cc"
2124 [(set (match_operand:SI 0 "register_operand" "=d")
2125 (and:SI (match_operand:QI 1 "address_operand" "p")
2126 (const_int 2147483647)))
2127 (clobber (reg:CC CC_REGNUM))]
2130 "&& reload_completed"
2132 (and:SI (match_dup 1) (const_int 2147483647)))]
2134 [(set_attr "op_type" "RX")
2135 (set_attr "type" "la")])
2137 (define_insn "force_la_31"
2138 [(set (match_operand:SI 0 "register_operand" "=d,d")
2139 (match_operand:QI 1 "address_operand" "ZR,ZT"))
2140 (use (const_int 0))]
2145 [(set_attr "op_type" "RX")
2146 (set_attr "type" "la")
2147 (set_attr "cpu_facility" "*,longdisp")
2148 (set_attr "z10prop" "z10_fwd_A1,z10_fwd_A1")])
2151 ; movhi instruction pattern(s).
2154 (define_expand "movhi"
2155 [(set (match_operand:HI 0 "nonimmediate_operand" "")
2156 (match_operand:HI 1 "general_operand" ""))]
2159 /* Make it explicit that loading a register from memory
2160 always sign-extends (at least) to SImode. */
2161 if (optimize && can_create_pseudo_p ()
2162 && register_operand (operands[0], VOIDmode)
2163 && GET_CODE (operands[1]) == MEM)
2165 rtx tmp = gen_reg_rtx (SImode);
2166 rtx ext = gen_rtx_SIGN_EXTEND (SImode, operands[1]);
2167 emit_insn (gen_rtx_SET (tmp, ext));
2168 operands[1] = gen_lowpart (HImode, tmp);
2172 (define_insn "*movhi"
2173 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d,d,d,R,T,b,Q,v,v,v,d,v,R")
2174 (match_operand:HI 1 "general_operand" " d,n,R,T,b,d,d,d,K,K,v,d,v,R,v"))]
2192 [(set_attr "op_type" "RR,RI,RX,RXY,RIL,RX,RXY,RIL,SIL,VRI,VRR,VRS,VRS,VRX,VRX")
2193 (set_attr "type" "lr,*,*,*,larl,store,store,store,*,*,*,*,*,*,*")
2194 (set_attr "cpu_facility" "*,*,*,longdisp,z10,*,longdisp,z10,z10,vx,vx,vx,vx,vx,vx")
2195 (set_attr "z10prop" "z10_fr_E1,
2203 z10_super,*,*,*,*,*,*")])
2206 [(set (match_operand:HI 0 "register_operand" "")
2207 (mem:HI (match_operand 1 "address_operand" "")))]
2208 "GET_CODE (operands[1]) == SYMBOL_REF
2209 && CONSTANT_POOL_ADDRESS_P (operands[1])
2210 && get_pool_mode (operands[1]) == HImode
2211 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2212 [(set (match_dup 0) (match_dup 2))]
2213 "operands[2] = get_pool_constant (operands[1]);")
2216 ; movqi instruction pattern(s).
2219 (define_expand "movqi"
2220 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2221 (match_operand:QI 1 "general_operand" ""))]
2224 /* On z/Architecture, zero-extending from memory to register
2225 is just as fast as a QImode load. */
2226 if (TARGET_ZARCH && optimize && can_create_pseudo_p ()
2227 && register_operand (operands[0], VOIDmode)
2228 && GET_CODE (operands[1]) == MEM)
2230 rtx tmp = gen_reg_rtx (DImode);
2231 rtx ext = gen_rtx_ZERO_EXTEND (DImode, operands[1]);
2232 emit_insn (gen_rtx_SET (tmp, ext));
2233 operands[1] = gen_lowpart (QImode, tmp);
2237 (define_insn "*movqi"
2238 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,d,R,T,Q,S,?Q,v,v,v,d,v,R")
2239 (match_operand:QI 1 "general_operand" " d,n,R,T,d,d,n,n,?Q,K,v,d,v,R,v"))]
2257 [(set_attr "op_type" "RR,RI,RX,RXY,RX,RXY,SI,SIY,SS,VRI,VRR,VRS,VRS,VRX,VRX")
2258 (set_attr "type" "lr,*,*,*,store,store,store,store,*,*,*,*,*,*,*")
2259 (set_attr "cpu_facility" "*,*,*,longdisp,*,longdisp,*,longdisp,*,vx,vx,vx,vx,vx,vx")
2260 (set_attr "z10prop" "z10_fr_E1,
2271 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2272 (mem:QI (match_operand 1 "address_operand" "")))]
2273 "GET_CODE (operands[1]) == SYMBOL_REF
2274 && CONSTANT_POOL_ADDRESS_P (operands[1])
2275 && get_pool_mode (operands[1]) == QImode
2276 && GET_CODE (get_pool_constant (operands[1])) == CONST_INT"
2277 [(set (match_dup 0) (match_dup 2))]
2278 "operands[2] = get_pool_constant (operands[1]);")
2281 ; movstrictqi instruction pattern(s).
2284 (define_insn "*movstrictqi"
2285 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d,d"))
2286 (match_operand:QI 1 "memory_operand" "R,T"))]
2291 [(set_attr "op_type" "RX,RXY")
2292 (set_attr "cpu_facility" "*,longdisp")
2293 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
2296 ; movstricthi instruction pattern(s).
2299 (define_insn "*movstricthi"
2300 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d,d"))
2301 (match_operand:HI 1 "memory_operand" "Q,S"))
2302 (clobber (reg:CC CC_REGNUM))]
2307 [(set_attr "op_type" "RS,RSY")
2308 (set_attr "cpu_facility" "*,longdisp")
2309 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
2312 ; movstrictsi instruction pattern(s).
2315 (define_insn "movstrictsi"
2316 [(set (strict_low_part (match_operand:SI 0 "register_operand" "+d,d,d,d"))
2317 (match_operand:SI 1 "general_operand" "d,R,T,t"))]
2324 [(set_attr "op_type" "RR,RX,RXY,RRE")
2325 (set_attr "type" "lr,load,load,*")
2326 (set_attr "cpu_facility" "*,*,longdisp,*")
2327 (set_attr "z10prop" "z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_super_E1")])
2330 ; mov(tf|td) instruction pattern(s).
2333 (define_expand "mov<mode>"
2334 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2335 (match_operand:TD_TF 1 "general_operand" ""))]
2339 (define_insn "*mov<mode>_64"
2340 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o,d,S, d,o")
2341 (match_operand:TD_TF 1 "general_operand" " G,f,o,f,S,d,dT,d"))]
2352 [(set_attr "op_type" "RRE,RRE,*,*,RSY,RSY,*,*")
2353 (set_attr "type" "fsimptf,fsimptf,*,*,lm,stm,*,*")
2354 (set_attr "cpu_facility" "z196,*,*,*,*,*,*,*")])
2356 (define_insn "*mov<mode>_31"
2357 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "=f,f,f,o")
2358 (match_operand:TD_TF 1 "general_operand" " G,f,o,f"))]
2365 [(set_attr "op_type" "RRE,RRE,*,*")
2366 (set_attr "type" "fsimptf,fsimptf,*,*")
2367 (set_attr "cpu_facility" "z196,*,*,*")])
2369 ; TFmode in GPRs splitters
2372 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2373 (match_operand:TD_TF 1 "general_operand" ""))]
2374 "TARGET_ZARCH && reload_completed
2375 && !s_operand (operands[0], <MODE>mode)
2376 && !s_operand (operands[1], <MODE>mode)
2377 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2378 [(set (match_dup 2) (match_dup 4))
2379 (set (match_dup 3) (match_dup 5))]
2381 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2382 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2383 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2384 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2388 [(set (match_operand:TD_TF 0 "nonimmediate_operand" "")
2389 (match_operand:TD_TF 1 "general_operand" ""))]
2390 "TARGET_ZARCH && reload_completed
2391 && !s_operand (operands[0], <MODE>mode)
2392 && !s_operand (operands[1], <MODE>mode)
2393 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2394 [(set (match_dup 2) (match_dup 4))
2395 (set (match_dup 3) (match_dup 5))]
2397 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2398 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2399 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2400 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2404 [(set (match_operand:TD_TF 0 "register_operand" "")
2405 (match_operand:TD_TF 1 "memory_operand" ""))]
2406 "TARGET_ZARCH && reload_completed
2407 && GENERAL_REG_P (operands[0])
2408 && !s_operand (operands[1], VOIDmode)"
2409 [(set (match_dup 0) (match_dup 1))]
2411 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2412 addr = gen_lowpart (Pmode, addr);
2413 s390_load_address (addr, XEXP (operands[1], 0));
2414 operands[1] = replace_equiv_address (operands[1], addr);
2417 ; TFmode in BFPs splitters
2420 [(set (match_operand:TD_TF 0 "register_operand" "")
2421 (match_operand:TD_TF 1 "memory_operand" ""))]
2422 "reload_completed && offsettable_memref_p (operands[1])
2423 && FP_REG_P (operands[0])"
2424 [(set (match_dup 2) (match_dup 4))
2425 (set (match_dup 3) (match_dup 5))]
2427 operands[2] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2429 operands[3] = simplify_gen_subreg (<HALF_TMODE>mode, operands[0],
2431 operands[4] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 0);
2432 operands[5] = adjust_address_nv (operands[1], <HALF_TMODE>mode, 8);
2436 [(set (match_operand:TD_TF 0 "memory_operand" "")
2437 (match_operand:TD_TF 1 "register_operand" ""))]
2438 "reload_completed && offsettable_memref_p (operands[0])
2439 && FP_REG_P (operands[1])"
2440 [(set (match_dup 2) (match_dup 4))
2441 (set (match_dup 3) (match_dup 5))]
2443 operands[2] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 0);
2444 operands[3] = adjust_address_nv (operands[0], <HALF_TMODE>mode, 8);
2445 operands[4] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2447 operands[5] = simplify_gen_subreg (<HALF_TMODE>mode, operands[1],
2452 ; mov(df|dd) instruction pattern(s).
2455 (define_expand "mov<mode>"
2456 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2457 (match_operand:DD_DF 1 "general_operand" ""))]
2461 (define_insn "*mov<mode>_64dfp"
2462 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2463 "=f,f,f,d,f,f,R,T,d,d,d,d,b,T,v,v,v,d,v,R")
2464 (match_operand:DD_DF 1 "general_operand"
2465 " G,f,d,f,R,T,f,f,G,d,b,T,d,d,v,G,d,v,R,v"))]
2488 [(set_attr "op_type" "RRE,RR,RRE,RRE,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY,VRR,VRI,VRS,VRS,VRX,VRX")
2489 (set_attr "type" "fsimpdf,floaddf,floaddf,floaddf,floaddf,floaddf,
2490 fstoredf,fstoredf,*,lr,load,load,store,store,*,*,*,*,load,store")
2491 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,*,*,*,*,*,*")
2492 (set_attr "cpu_facility" "z196,*,*,*,*,longdisp,*,longdisp,*,*,z10,*,z10,*,vx,vx,vx,vx,vx,vx")])
2494 (define_insn "*mov<mode>_64"
2495 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "=f,f,f,f,R,T,d,d,d,d,b,T")
2496 (match_operand:DD_DF 1 "general_operand" " G,f,R,T,f,f,G,d,b,T,d,d"))]
2511 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RI,RRE,RIL,RXY,RIL,RXY")
2512 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2513 fstore<mode>,fstore<mode>,*,lr,load,load,store,store")
2514 (set_attr "z10prop" "*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
2515 (set_attr "cpu_facility" "z196,*,*,longdisp,*,longdisp,*,*,z10,*,z10,*")])
2517 (define_insn "*mov<mode>_31"
2518 [(set (match_operand:DD_DF 0 "nonimmediate_operand"
2519 "=f,f,f,f,R,T,d,d,Q,S, d,o")
2520 (match_operand:DD_DF 1 "general_operand"
2521 " G,f,R,T,f,f,Q,S,d,d,dPT,d"))]
2536 [(set_attr "op_type" "RRE,RR,RX,RXY,RX,RXY,RS,RSY,RS,RSY,*,*")
2537 (set_attr "type" "fsimpdf,fload<mode>,fload<mode>,fload<mode>,
2538 fstore<mode>,fstore<mode>,lm,lm,stm,stm,*,*")
2539 (set_attr "cpu_facility" "z196,*,*,longdisp,*,longdisp,*,longdisp,*,longdisp,*,*")])
2542 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2543 (match_operand:DD_DF 1 "general_operand" ""))]
2544 "!TARGET_ZARCH && reload_completed
2545 && !s_operand (operands[0], <MODE>mode)
2546 && !s_operand (operands[1], <MODE>mode)
2547 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 0)"
2548 [(set (match_dup 2) (match_dup 4))
2549 (set (match_dup 3) (match_dup 5))]
2551 operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
2552 operands[3] = operand_subword (operands[0], 1, 0, <MODE>mode);
2553 operands[4] = operand_subword (operands[1], 0, 0, <MODE>mode);
2554 operands[5] = operand_subword (operands[1], 1, 0, <MODE>mode);
2558 [(set (match_operand:DD_DF 0 "nonimmediate_operand" "")
2559 (match_operand:DD_DF 1 "general_operand" ""))]
2560 "!TARGET_ZARCH && reload_completed
2561 && !s_operand (operands[0], <MODE>mode)
2562 && !s_operand (operands[1], <MODE>mode)
2563 && s390_split_ok_p (operands[0], operands[1], <MODE>mode, 1)"
2564 [(set (match_dup 2) (match_dup 4))
2565 (set (match_dup 3) (match_dup 5))]
2567 operands[2] = operand_subword (operands[0], 1, 0, <MODE>mode);
2568 operands[3] = operand_subword (operands[0], 0, 0, <MODE>mode);
2569 operands[4] = operand_subword (operands[1], 1, 0, <MODE>mode);
2570 operands[5] = operand_subword (operands[1], 0, 0, <MODE>mode);
2574 [(set (match_operand:DD_DF 0 "register_operand" "")
2575 (match_operand:DD_DF 1 "memory_operand" ""))]
2576 "!TARGET_ZARCH && reload_completed
2577 && !FP_REG_P (operands[0])
2578 && !s_operand (operands[1], VOIDmode)"
2579 [(set (match_dup 0) (match_dup 1))]
2581 rtx addr = operand_subword (operands[0], 1, 0, <MODE>mode);
2582 s390_load_address (addr, XEXP (operands[1], 0));
2583 operands[1] = replace_equiv_address (operands[1], addr);
2587 ; mov(sf|sd) instruction pattern(s).
2590 (define_insn "mov<mode>"
2591 [(set (match_operand:SD_SF 0 "nonimmediate_operand"
2592 "=f,f,f,f,f,f,R,T,d,d,d,d,d,b,R,T,v,v,v,d,v,R")
2593 (match_operand:SD_SF 1 "general_operand"
2594 " G,f,f,R,R,T,f,f,G,d,b,R,T,d,d,d,v,G,d,v,R,v"))]
2619 [(set_attr "op_type" "RRE,RR,RR,RXE,RX,RXY,RX,RXY,RI,RR,RIL,RX,RXY,RIL,RX,RXY,VRR,VRI,VRS,VRS,VRX,VRX")
2620 (set_attr "type" "fsimpsf,fsimpsf,fload<mode>,fload<mode>,fload<mode>,fload<mode>,
2621 fstore<mode>,fstore<mode>,*,lr,load,load,load,store,store,store,*,*,*,*,load,store")
2622 (set_attr "z10prop" "*,*,*,*,*,*,*,*,z10_fwd_A1,z10_fr_E1,z10_fr_E1,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec,z10_rec,*,*,*,*,*,*")
2623 (set_attr "cpu_facility" "z196,vx,*,vx,*,longdisp,*,longdisp,*,*,z10,*,longdisp,z10,*,longdisp,vx,vx,vx,vx,vx,vx")])
2626 ; movcc instruction pattern
2629 (define_insn "movcc"
2630 [(set (match_operand:CC 0 "nonimmediate_operand" "=d,c,d,d,d,R,T")
2631 (match_operand:CC 1 "nonimmediate_operand" " d,d,c,R,T,d,d"))]
2641 [(set_attr "op_type" "RR,RI,RRE,RX,RXY,RX,RXY")
2642 (set_attr "type" "lr,*,*,load,load,store,store")
2643 (set_attr "cpu_facility" "*,*,*,*,longdisp,*,longdisp")
2644 (set_attr "z10prop" "z10_fr_E1,z10_super,*,z10_fwd_A3,z10_fwd_A3,z10_rec,z10_rec")
2645 (set_attr "z196prop" "*,*,z196_ends,*,*,*,*")])
2648 ; Block move (MVC) patterns.
2652 [(set (match_operand:BLK 0 "memory_operand" "=Q")
2653 (match_operand:BLK 1 "memory_operand" "Q"))
2654 (use (match_operand 2 "const_int_operand" "n"))]
2655 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
2656 "mvc\t%O0(%2,%R0),%S1"
2657 [(set_attr "op_type" "SS")])
2659 ; This splitter converts a QI to QI mode copy into a BLK mode copy in
2660 ; order to have it implemented with mvc.
2663 [(set (match_operand:QI 0 "memory_operand" "")
2664 (match_operand:QI 1 "memory_operand" ""))]
2667 [(set (match_dup 0) (match_dup 1))
2668 (use (const_int 1))])]
2670 operands[0] = adjust_address (operands[0], BLKmode, 0);
2671 operands[1] = adjust_address (operands[1], BLKmode, 0);
2677 [(set (match_operand:BLK 0 "memory_operand" "")
2678 (match_operand:BLK 1 "memory_operand" ""))
2679 (use (match_operand 2 "const_int_operand" ""))])
2681 [(set (match_operand:BLK 3 "memory_operand" "")
2682 (match_operand:BLK 4 "memory_operand" ""))
2683 (use (match_operand 5 "const_int_operand" ""))])]
2684 "s390_offset_p (operands[0], operands[3], operands[2])
2685 && s390_offset_p (operands[1], operands[4], operands[2])
2686 && !s390_overlap_p (operands[0], operands[1],
2687 INTVAL (operands[2]) + INTVAL (operands[5]))
2688 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
2690 [(set (match_dup 6) (match_dup 7))
2691 (use (match_dup 8))])]
2692 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
2693 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
2694 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
2698 ; load_multiple pattern(s).
2700 ; ??? Due to reload problems with replacing registers inside match_parallel
2701 ; we currently support load_multiple/store_multiple only after reload.
2704 (define_expand "load_multiple"
2705 [(match_par_dup 3 [(set (match_operand 0 "" "")
2706 (match_operand 1 "" ""))
2707 (use (match_operand 2 "" ""))])]
2716 /* Support only loading a constant number of fixed-point registers from
2717 memory and only bother with this if more than two */
2718 if (GET_CODE (operands[2]) != CONST_INT
2719 || INTVAL (operands[2]) < 2
2720 || INTVAL (operands[2]) > 16
2721 || GET_CODE (operands[1]) != MEM
2722 || GET_CODE (operands[0]) != REG
2723 || REGNO (operands[0]) >= 16)
2726 count = INTVAL (operands[2]);
2727 regno = REGNO (operands[0]);
2728 mode = GET_MODE (operands[0]);
2729 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
2732 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2733 if (!can_create_pseudo_p ())
2735 if (GET_CODE (XEXP (operands[1], 0)) == REG)
2737 from = XEXP (operands[1], 0);
2740 else if (GET_CODE (XEXP (operands[1], 0)) == PLUS
2741 && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == REG
2742 && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT)
2744 from = XEXP (XEXP (operands[1], 0), 0);
2745 off = INTVAL (XEXP (XEXP (operands[1], 0), 1));
2752 from = force_reg (Pmode, XEXP (operands[1], 0));
2756 for (i = 0; i < count; i++)
2757 XVECEXP (operands[3], 0, i)
2758 = gen_rtx_SET (gen_rtx_REG (mode, regno + i),
2759 change_address (operands[1], mode,
2760 plus_constant (Pmode, from,
2761 off + i * GET_MODE_SIZE (mode))));
2764 (define_insn "*load_multiple_di"
2765 [(match_parallel 0 "load_multiple_operation"
2766 [(set (match_operand:DI 1 "register_operand" "=r")
2767 (match_operand:DI 2 "s_operand" "S"))])]
2768 "reload_completed && TARGET_ZARCH"
2770 int words = XVECLEN (operands[0], 0);
2771 operands[0] = gen_rtx_REG (DImode, REGNO (operands[1]) + words - 1);
2772 return "lmg\t%1,%0,%S2";
2774 [(set_attr "op_type" "RSY")
2775 (set_attr "type" "lm")])
2777 (define_insn "*load_multiple_si"
2778 [(match_parallel 0 "load_multiple_operation"
2779 [(set (match_operand:SI 1 "register_operand" "=r,r")
2780 (match_operand:SI 2 "s_operand" "Q,S"))])]
2783 int words = XVECLEN (operands[0], 0);
2784 operands[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + words - 1);
2785 return which_alternative == 0 ? "lm\t%1,%0,%S2" : "lmy\t%1,%0,%S2";
2787 [(set_attr "op_type" "RS,RSY")
2788 (set_attr "cpu_facility" "*,longdisp")
2789 (set_attr "type" "lm")])
2792 ; store multiple pattern(s).
2795 (define_expand "store_multiple"
2796 [(match_par_dup 3 [(set (match_operand 0 "" "")
2797 (match_operand 1 "" ""))
2798 (use (match_operand 2 "" ""))])]
2807 /* Support only storing a constant number of fixed-point registers to
2808 memory and only bother with this if more than two. */
2809 if (GET_CODE (operands[2]) != CONST_INT
2810 || INTVAL (operands[2]) < 2
2811 || INTVAL (operands[2]) > 16
2812 || GET_CODE (operands[0]) != MEM
2813 || GET_CODE (operands[1]) != REG
2814 || REGNO (operands[1]) >= 16)
2817 count = INTVAL (operands[2]);
2818 regno = REGNO (operands[1]);
2819 mode = GET_MODE (operands[1]);
2820 if (mode != SImode && (!TARGET_ZARCH || mode != DImode))
2823 operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
2825 if (!can_create_pseudo_p ())
2827 if (GET_CODE (XEXP (operands[0], 0)) == REG)
2829 to = XEXP (operands[0], 0);
2832 else if (GET_CODE (XEXP (operands[0], 0)) == PLUS
2833 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
2834 && GET_CODE (XEXP (XEXP (operands[0], 0), 1)) == CONST_INT)
2836 to = XEXP (XEXP (operands[0], 0), 0);
2837 off = INTVAL (XEXP (XEXP (operands[0], 0), 1));
2844 to = force_reg (Pmode, XEXP (operands[0], 0));
2848 for (i = 0; i < count; i++)
2849 XVECEXP (operands[3], 0, i)
2850 = gen_rtx_SET (change_address (operands[0], mode,
2851 plus_constant (Pmode, to,
2852 off + i * GET_MODE_SIZE (mode))),
2853 gen_rtx_REG (mode, regno + i));
2856 (define_insn "*store_multiple_di"
2857 [(match_parallel 0 "store_multiple_operation"
2858 [(set (match_operand:DI 1 "s_operand" "=S")
2859 (match_operand:DI 2 "register_operand" "r"))])]
2860 "reload_completed && TARGET_ZARCH"
2862 int words = XVECLEN (operands[0], 0);
2863 operands[0] = gen_rtx_REG (DImode, REGNO (operands[2]) + words - 1);
2864 return "stmg\t%2,%0,%S1";
2866 [(set_attr "op_type" "RSY")
2867 (set_attr "type" "stm")])
2870 (define_insn "*store_multiple_si"
2871 [(match_parallel 0 "store_multiple_operation"
2872 [(set (match_operand:SI 1 "s_operand" "=Q,S")
2873 (match_operand:SI 2 "register_operand" "r,r"))])]
2876 int words = XVECLEN (operands[0], 0);
2877 operands[0] = gen_rtx_REG (SImode, REGNO (operands[2]) + words - 1);
2878 return which_alternative == 0 ? "stm\t%2,%0,%S1" : "stmy\t%2,%0,%S1";
2880 [(set_attr "op_type" "RS,RSY")
2881 (set_attr "cpu_facility" "*,longdisp")
2882 (set_attr "type" "stm")])
2885 ;; String instructions.
2888 (define_insn "*execute_rl"
2889 [(match_parallel 0 "execute_operation"
2890 [(unspec [(match_operand 1 "register_operand" "a")
2891 (match_operand 2 "" "")
2892 (match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
2893 "TARGET_Z10 && GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2894 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2896 [(set_attr "op_type" "RIL")
2897 (set_attr "type" "cs")])
2899 (define_insn "*execute"
2900 [(match_parallel 0 "execute_operation"
2901 [(unspec [(match_operand 1 "register_operand" "a")
2902 (match_operand:BLK 2 "memory_operand" "R")
2903 (match_operand 3 "" "")] UNSPEC_EXECUTE)])]
2904 "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT
2905 && GET_MODE_SIZE (GET_MODE (operands[1])) <= UNITS_PER_WORD"
2907 [(set_attr "op_type" "RX")
2908 (set_attr "type" "cs")])
2912 ; strlenM instruction pattern(s).
2915 (define_expand "strlen<mode>"
2916 [(match_operand:P 0 "register_operand" "") ; result
2917 (match_operand:BLK 1 "memory_operand" "") ; input string
2918 (match_operand:SI 2 "immediate_operand" "") ; search character
2919 (match_operand:SI 3 "immediate_operand" "")] ; known alignment
2922 if (!TARGET_VX || operands[2] != const0_rtx)
2923 emit_insn (gen_strlen_srst<mode> (operands[0], operands[1],
2924 operands[2], operands[3]));
2926 s390_expand_vec_strlen (operands[0], operands[1], operands[3]);
2931 (define_expand "strlen_srst<mode>"
2932 [(set (reg:SI 0) (match_operand:SI 2 "immediate_operand" ""))
2935 (unspec:P [(const_int 0)
2936 (match_operand:BLK 1 "memory_operand" "")
2938 (match_operand 3 "immediate_operand" "")] UNSPEC_SRST))
2939 (clobber (scratch:P))
2940 (clobber (reg:CC CC_REGNUM))])
2942 [(set (match_operand:P 0 "register_operand" "")
2943 (minus:P (match_dup 4) (match_dup 5)))
2944 (clobber (reg:CC CC_REGNUM))])]
2947 operands[4] = gen_reg_rtx (Pmode);
2948 operands[5] = gen_reg_rtx (Pmode);
2949 emit_move_insn (operands[5], force_operand (XEXP (operands[1], 0), NULL_RTX));
2950 operands[1] = replace_equiv_address (operands[1], operands[5]);
2953 (define_insn "*strlen<mode>"
2954 [(set (match_operand:P 0 "register_operand" "=a")
2955 (unspec:P [(match_operand:P 2 "general_operand" "0")
2956 (mem:BLK (match_operand:P 3 "register_operand" "1"))
2958 (match_operand 4 "immediate_operand" "")] UNSPEC_SRST))
2959 (clobber (match_scratch:P 1 "=a"))
2960 (clobber (reg:CC CC_REGNUM))]
2962 "srst\t%0,%1\;jo\t.-4"
2963 [(set_attr "length" "8")
2964 (set_attr "type" "vs")])
2967 ; cmpstrM instruction pattern(s).
2970 (define_expand "cmpstrsi"
2971 [(set (reg:SI 0) (const_int 0))
2973 [(clobber (match_operand 3 "" ""))
2974 (clobber (match_dup 4))
2975 (set (reg:CCU CC_REGNUM)
2976 (compare:CCU (match_operand:BLK 1 "memory_operand" "")
2977 (match_operand:BLK 2 "memory_operand" "")))
2980 [(set (match_operand:SI 0 "register_operand" "=d")
2981 (unspec:SI [(reg:CCU CC_REGNUM)] UNSPEC_STRCMPCC_TO_INT))
2982 (clobber (reg:CC CC_REGNUM))])]
2985 /* As the result of CMPINT is inverted compared to what we need,
2986 we have to swap the operands. */
2987 rtx op1 = operands[2];
2988 rtx op2 = operands[1];
2989 rtx addr1 = gen_reg_rtx (Pmode);
2990 rtx addr2 = gen_reg_rtx (Pmode);
2992 emit_move_insn (addr1, force_operand (XEXP (op1, 0), NULL_RTX));
2993 emit_move_insn (addr2, force_operand (XEXP (op2, 0), NULL_RTX));
2994 operands[1] = replace_equiv_address_nv (op1, addr1);
2995 operands[2] = replace_equiv_address_nv (op2, addr2);
2996 operands[3] = addr1;
2997 operands[4] = addr2;
3000 (define_insn "*cmpstr<mode>"
3001 [(clobber (match_operand:P 0 "register_operand" "=d"))
3002 (clobber (match_operand:P 1 "register_operand" "=d"))
3003 (set (reg:CCU CC_REGNUM)
3004 (compare:CCU (mem:BLK (match_operand:P 2 "register_operand" "0"))
3005 (mem:BLK (match_operand:P 3 "register_operand" "1"))))
3008 "clst\t%0,%1\;jo\t.-4"
3009 [(set_attr "length" "8")
3010 (set_attr "type" "vs")])
3013 ; movstr instruction pattern.
3016 (define_expand "movstr"
3017 [(match_operand 0 "register_operand" "")
3018 (match_operand 1 "memory_operand" "")
3019 (match_operand 2 "memory_operand" "")]
3023 emit_insn (gen_movstrdi (operands[0], operands[1], operands[2]));
3025 emit_insn (gen_movstrsi (operands[0], operands[1], operands[2]));
3029 (define_expand "movstr<P:mode>"
3030 [(set (reg:SI 0) (const_int 0))
3032 [(clobber (match_dup 3))
3033 (set (match_operand:BLK 1 "memory_operand" "")
3034 (match_operand:BLK 2 "memory_operand" ""))
3035 (set (match_operand:P 0 "register_operand" "")
3036 (unspec:P [(match_dup 1)
3038 (reg:SI 0)] UNSPEC_MVST))
3039 (clobber (reg:CC CC_REGNUM))])]
3044 if (TARGET_VX && optimize_function_for_speed_p (cfun))
3046 s390_expand_vec_movstr (operands[0], operands[1], operands[2]);
3050 addr1 = gen_reg_rtx (Pmode);
3051 addr2 = gen_reg_rtx (Pmode);
3053 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3054 emit_move_insn (addr2, force_operand (XEXP (operands[2], 0), NULL_RTX));
3055 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3056 operands[2] = replace_equiv_address_nv (operands[2], addr2);
3057 operands[3] = addr2;
3060 (define_insn "*movstr"
3061 [(clobber (match_operand:P 2 "register_operand" "=d"))
3062 (set (mem:BLK (match_operand:P 1 "register_operand" "0"))
3063 (mem:BLK (match_operand:P 3 "register_operand" "2")))
3064 (set (match_operand:P 0 "register_operand" "=d")
3065 (unspec:P [(mem:BLK (match_dup 1))
3066 (mem:BLK (match_dup 3))
3067 (reg:SI 0)] UNSPEC_MVST))
3068 (clobber (reg:CC CC_REGNUM))]
3070 "mvst\t%1,%2\;jo\t.-4"
3071 [(set_attr "length" "8")
3072 (set_attr "type" "vs")])
3076 ; movmemM instruction pattern(s).
3079 (define_expand "movmem<mode>"
3080 [(set (match_operand:BLK 0 "memory_operand" "") ; destination
3081 (match_operand:BLK 1 "memory_operand" "")) ; source
3082 (use (match_operand:GPR 2 "general_operand" "")) ; count
3083 (match_operand 3 "" "")]
3086 if (s390_expand_movmem (operands[0], operands[1], operands[2]))
3092 ; Move a block that is up to 256 bytes in length.
3093 ; The block length is taken as (operands[2] % 256) + 1.
3095 (define_expand "movmem_short"
3097 [(set (match_operand:BLK 0 "memory_operand" "")
3098 (match_operand:BLK 1 "memory_operand" ""))
3099 (use (match_operand 2 "nonmemory_operand" ""))
3100 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3101 (clobber (match_dup 3))])]
3103 "operands[3] = gen_rtx_SCRATCH (Pmode);")
3105 (define_insn "*movmem_short"
3106 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
3107 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q"))
3108 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3109 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
3110 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3111 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
3113 [(set_attr "type" "cs")
3114 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
3117 [(set (match_operand:BLK 0 "memory_operand" "")
3118 (match_operand:BLK 1 "memory_operand" ""))
3119 (use (match_operand 2 "const_int_operand" ""))
3120 (use (match_operand 3 "immediate_operand" ""))
3121 (clobber (scratch))]
3124 [(set (match_dup 0) (match_dup 1))
3125 (use (match_dup 2))])]
3126 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
3129 [(set (match_operand:BLK 0 "memory_operand" "")
3130 (match_operand:BLK 1 "memory_operand" ""))
3131 (use (match_operand 2 "register_operand" ""))
3132 (use (match_operand 3 "memory_operand" ""))
3133 (clobber (scratch))]
3136 [(unspec [(match_dup 2) (match_dup 3)
3137 (const_int 0)] UNSPEC_EXECUTE)
3138 (set (match_dup 0) (match_dup 1))
3139 (use (const_int 1))])]
3143 [(set (match_operand:BLK 0 "memory_operand" "")
3144 (match_operand:BLK 1 "memory_operand" ""))
3145 (use (match_operand 2 "register_operand" ""))
3146 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3147 (clobber (scratch))]
3148 "TARGET_Z10 && reload_completed"
3150 [(unspec [(match_dup 2) (const_int 0)
3151 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3152 (set (match_dup 0) (match_dup 1))
3153 (use (const_int 1))])]
3154 "operands[3] = gen_label_rtx ();")
3157 [(set (match_operand:BLK 0 "memory_operand" "")
3158 (match_operand:BLK 1 "memory_operand" ""))
3159 (use (match_operand 2 "register_operand" ""))
3160 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3161 (clobber (match_operand 3 "register_operand" ""))]
3162 "reload_completed && TARGET_CPU_ZARCH"
3163 [(set (match_dup 3) (label_ref (match_dup 4)))
3165 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
3166 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3167 (set (match_dup 0) (match_dup 1))
3168 (use (const_int 1))])]
3169 "operands[4] = gen_label_rtx ();")
3171 ; Move a block of arbitrary length.
3173 (define_expand "movmem_long"
3175 [(clobber (match_dup 2))
3176 (clobber (match_dup 3))
3177 (set (match_operand:BLK 0 "memory_operand" "")
3178 (match_operand:BLK 1 "memory_operand" ""))
3179 (use (match_operand 2 "general_operand" ""))
3181 (clobber (reg:CC CC_REGNUM))])]
3184 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3185 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
3186 rtx reg0 = gen_reg_rtx (dreg_mode);
3187 rtx reg1 = gen_reg_rtx (dreg_mode);
3188 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3189 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
3190 rtx len0 = gen_lowpart (Pmode, reg0);
3191 rtx len1 = gen_lowpart (Pmode, reg1);
3193 emit_clobber (reg0);
3194 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3195 emit_move_insn (len0, operands[2]);
3197 emit_clobber (reg1);
3198 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3199 emit_move_insn (len1, operands[2]);
3201 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3202 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3207 (define_insn "*movmem_long"
3208 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3209 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3210 (set (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3211 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0)))
3214 (clobber (reg:CC CC_REGNUM))]
3215 "TARGET_64BIT || !TARGET_ZARCH"
3216 "mvcle\t%0,%1,0\;jo\t.-4"
3217 [(set_attr "length" "8")
3218 (set_attr "type" "vs")])
3220 (define_insn "*movmem_long_31z"
3221 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3222 (clobber (match_operand:TI 1 "register_operand" "=d"))
3223 (set (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3224 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4)))
3227 (clobber (reg:CC CC_REGNUM))]
3228 "!TARGET_64BIT && TARGET_ZARCH"
3229 "mvcle\t%0,%1,0\;jo\t.-4"
3230 [(set_attr "length" "8")
3231 (set_attr "type" "vs")])
3238 (define_expand "signbit<mode>2"
3239 [(set (reg:CCZ CC_REGNUM)
3240 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3243 (set (match_operand:SI 0 "register_operand" "=d")
3244 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
3247 operands[2] = GEN_INT (S390_TDC_SIGNBIT_SET);
3250 (define_expand "isinf<mode>2"
3251 [(set (reg:CCZ CC_REGNUM)
3252 (unspec:CCZ [(match_operand:FP_ALL 1 "register_operand" "f")
3255 (set (match_operand:SI 0 "register_operand" "=d")
3256 (unspec:SI [(reg:CCZ CC_REGNUM)] UNSPEC_CC_TO_INT))]
3259 operands[2] = GEN_INT (S390_TDC_INFINITY);
3262 ; This extracts CC into a GPR properly shifted. The actual IPM
3263 ; instruction will be issued by reload. The constraint of operand 1
3264 ; forces reload to use a GPR. So reload will issue a movcc insn for
3265 ; copying CC into a GPR first.
3266 (define_insn_and_split "*cc_to_int"
3267 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3268 (unspec:SI [(match_operand 1 "register_operand" "0")]
3273 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 28)))])
3275 ; This insn is used to generate all variants of the Test Data Class
3276 ; instruction, namely tcxb, tcdb, and tceb. The insn's first operand
3277 ; is the register to be tested and the second one is the bit mask
3278 ; specifying the required test(s).
3280 ; tcxb, tcdb, tceb, tdcxt, tdcdt, tdcet
3281 (define_insn "*TDC_insn_<mode>"
3282 [(set (reg:CCZ CC_REGNUM)
3283 (unspec:CCZ [(match_operand:FP_ALL 0 "register_operand" "f")
3284 (match_operand:SI 1 "const_int_operand")] UNSPEC_TDC_INSN))]
3286 "t<_d>c<xde><bt>\t%0,%1"
3287 [(set_attr "op_type" "RXE")
3288 (set_attr "type" "fsimp<mode>")])
3293 ; setmemM instruction pattern(s).
3296 (define_expand "setmem<mode>"
3297 [(set (match_operand:BLK 0 "memory_operand" "")
3298 (match_operand:QI 2 "general_operand" ""))
3299 (use (match_operand:GPR 1 "general_operand" ""))
3300 (match_operand 3 "" "")]
3302 "s390_expand_setmem (operands[0], operands[1], operands[2]); DONE;")
3304 ; Clear a block that is up to 256 bytes in length.
3305 ; The block length is taken as (operands[1] % 256) + 1.
3307 (define_expand "clrmem_short"
3309 [(set (match_operand:BLK 0 "memory_operand" "")
3311 (use (match_operand 1 "nonmemory_operand" ""))
3312 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3313 (clobber (match_dup 2))
3314 (clobber (reg:CC CC_REGNUM))])]
3316 "operands[2] = gen_rtx_SCRATCH (Pmode);")
3318 (define_insn "*clrmem_short"
3319 [(set (match_operand:BLK 0 "memory_operand" "=Q,Q,Q,Q")
3321 (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
3322 (use (match_operand 2 "immediate_operand" "X,R,X,X"))
3323 (clobber (match_scratch:P 3 "=X,X,X,&a"))
3324 (clobber (reg:CC CC_REGNUM))]
3325 "(GET_MODE (operands[1]) == Pmode || GET_MODE (operands[1]) == VOIDmode)"
3327 [(set_attr "type" "cs")
3328 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
3331 [(set (match_operand:BLK 0 "memory_operand" "")
3333 (use (match_operand 1 "const_int_operand" ""))
3334 (use (match_operand 2 "immediate_operand" ""))
3336 (clobber (reg:CC CC_REGNUM))]
3339 [(set (match_dup 0) (const_int 0))
3341 (clobber (reg:CC CC_REGNUM))])]
3342 "operands[1] = GEN_INT ((INTVAL (operands[1]) & 0xff) + 1);")
3345 [(set (match_operand:BLK 0 "memory_operand" "")
3347 (use (match_operand 1 "register_operand" ""))
3348 (use (match_operand 2 "memory_operand" ""))
3350 (clobber (reg:CC CC_REGNUM))]
3353 [(unspec [(match_dup 1) (match_dup 2)
3354 (const_int 0)] UNSPEC_EXECUTE)
3355 (set (match_dup 0) (const_int 0))
3357 (clobber (reg:CC CC_REGNUM))])]
3361 [(set (match_operand:BLK 0 "memory_operand" "")
3363 (use (match_operand 1 "register_operand" ""))
3364 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3366 (clobber (reg:CC CC_REGNUM))]
3367 "TARGET_Z10 && reload_completed"
3369 [(unspec [(match_dup 1) (const_int 0)
3370 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3371 (set (match_dup 0) (const_int 0))
3373 (clobber (reg:CC CC_REGNUM))])]
3374 "operands[3] = gen_label_rtx ();")
3377 [(set (match_operand:BLK 0 "memory_operand" "")
3379 (use (match_operand 1 "register_operand" ""))
3380 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3381 (clobber (match_operand 2 "register_operand" ""))
3382 (clobber (reg:CC CC_REGNUM))]
3383 "reload_completed && TARGET_CPU_ZARCH"
3384 [(set (match_dup 2) (label_ref (match_dup 3)))
3386 [(unspec [(match_dup 1) (mem:BLK (match_dup 2))
3387 (label_ref (match_dup 3))] UNSPEC_EXECUTE)
3388 (set (match_dup 0) (const_int 0))
3390 (clobber (reg:CC CC_REGNUM))])]
3391 "operands[3] = gen_label_rtx ();")
3393 ; Initialize a block of arbitrary length with (operands[2] % 256).
3395 (define_expand "setmem_long_<P:mode>"
3397 [(clobber (match_dup 1))
3398 (set (match_operand:BLK 0 "memory_operand" "")
3399 (unspec:BLK [(match_operand:P 2 "setmem_operand" "")
3400 (match_dup 4)] UNSPEC_REPLICATE_BYTE))
3402 (clobber (reg:CC CC_REGNUM))])]
3405 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3406 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
3407 rtx reg0 = gen_reg_rtx (dreg_mode);
3408 rtx reg1 = gen_reg_rtx (dreg_mode);
3409 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3410 rtx len0 = gen_lowpart (Pmode, reg0);
3412 emit_clobber (reg0);
3413 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3414 emit_move_insn (len0, operands[1]);
3416 emit_move_insn (reg1, const0_rtx);
3418 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3421 operands[4] = gen_lowpart (Pmode, operands[1]);
3424 ; Patterns for 31 bit + Esa and 64 bit + Zarch.
3426 (define_insn "*setmem_long"
3427 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3428 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3429 (unspec:BLK [(match_operand:P 2 "setmem_operand" "Y")
3430 (subreg:P (match_dup 3) <modesize>)]
3431 UNSPEC_REPLICATE_BYTE))
3432 (use (match_operand:<DBL> 1 "register_operand" "d"))
3433 (clobber (reg:CC CC_REGNUM))]
3434 "TARGET_64BIT || !TARGET_ZARCH"
3435 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3436 [(set_attr "length" "8")
3437 (set_attr "type" "vs")])
3439 (define_insn "*setmem_long_and"
3440 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3441 (set (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "0") 0))
3442 (unspec:BLK [(zero_extend:P (match_operand:QI 2 "setmem_operand" "Y"))
3443 (subreg:P (match_dup 3) <modesize>)]
3444 UNSPEC_REPLICATE_BYTE))
3445 (use (match_operand:<DBL> 1 "register_operand" "d"))
3446 (clobber (reg:CC CC_REGNUM))]
3447 "(TARGET_64BIT || !TARGET_ZARCH)"
3448 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3449 [(set_attr "length" "8")
3450 (set_attr "type" "vs")])
3452 ; Variants for 31 bit + Zarch, necessary because of the odd in-register offsets
3453 ; of the SImode subregs.
3455 (define_insn "*setmem_long_31z"
3456 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3457 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
3458 (unspec:BLK [(match_operand:SI 2 "setmem_operand" "Y")
3459 (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
3460 (use (match_operand:TI 1 "register_operand" "d"))
3461 (clobber (reg:CC CC_REGNUM))]
3462 "!TARGET_64BIT && TARGET_ZARCH"
3463 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3464 [(set_attr "length" "8")
3465 (set_attr "type" "vs")])
3467 (define_insn "*setmem_long_and_31z"
3468 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3469 (set (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "0") 4))
3470 (unspec:BLK [(zero_extend:SI (match_operand:QI 2 "setmem_operand" "Y"))
3471 (subreg:SI (match_dup 3) 12)] UNSPEC_REPLICATE_BYTE))
3472 (use (match_operand:TI 1 "register_operand" "d"))
3473 (clobber (reg:CC CC_REGNUM))]
3474 "(!TARGET_64BIT && TARGET_ZARCH)"
3475 "mvcle\t%0,%1,%Y2\;jo\t.-4"
3476 [(set_attr "length" "8")
3477 (set_attr "type" "vs")])
3480 ; cmpmemM instruction pattern(s).
3483 (define_expand "cmpmemsi"
3484 [(set (match_operand:SI 0 "register_operand" "")
3485 (compare:SI (match_operand:BLK 1 "memory_operand" "")
3486 (match_operand:BLK 2 "memory_operand" "") ) )
3487 (use (match_operand:SI 3 "general_operand" ""))
3488 (use (match_operand:SI 4 "" ""))]
3491 if (s390_expand_cmpmem (operands[0], operands[1],
3492 operands[2], operands[3]))
3498 ; Compare a block that is up to 256 bytes in length.
3499 ; The block length is taken as (operands[2] % 256) + 1.
3501 (define_expand "cmpmem_short"
3503 [(set (reg:CCU CC_REGNUM)
3504 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3505 (match_operand:BLK 1 "memory_operand" "")))
3506 (use (match_operand 2 "nonmemory_operand" ""))
3507 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3508 (clobber (match_dup 3))])]
3510 "operands[3] = gen_rtx_SCRATCH (Pmode);")
3512 (define_insn "*cmpmem_short"
3513 [(set (reg:CCU CC_REGNUM)
3514 (compare:CCU (match_operand:BLK 0 "memory_operand" "Q,Q,Q,Q")
3515 (match_operand:BLK 1 "memory_operand" "Q,Q,Q,Q")))
3516 (use (match_operand 2 "nonmemory_operand" "n,a,a,a"))
3517 (use (match_operand 3 "immediate_operand" "X,R,X,X"))
3518 (clobber (match_scratch:P 4 "=X,X,X,&a"))]
3519 "(GET_MODE (operands[2]) == Pmode || GET_MODE (operands[2]) == VOIDmode)"
3521 [(set_attr "type" "cs")
3522 (set_attr "cpu_facility" "*,*,z10,cpu_zarch")])
3525 [(set (reg:CCU CC_REGNUM)
3526 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3527 (match_operand:BLK 1 "memory_operand" "")))
3528 (use (match_operand 2 "const_int_operand" ""))
3529 (use (match_operand 3 "immediate_operand" ""))
3530 (clobber (scratch))]
3533 [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3534 (use (match_dup 2))])]
3535 "operands[2] = GEN_INT ((INTVAL (operands[2]) & 0xff) + 1);")
3538 [(set (reg:CCU CC_REGNUM)
3539 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3540 (match_operand:BLK 1 "memory_operand" "")))
3541 (use (match_operand 2 "register_operand" ""))
3542 (use (match_operand 3 "memory_operand" ""))
3543 (clobber (scratch))]
3546 [(unspec [(match_dup 2) (match_dup 3)
3547 (const_int 0)] UNSPEC_EXECUTE)
3548 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3549 (use (const_int 1))])]
3553 [(set (reg:CCU CC_REGNUM)
3554 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3555 (match_operand:BLK 1 "memory_operand" "")))
3556 (use (match_operand 2 "register_operand" ""))
3557 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3558 (clobber (scratch))]
3559 "TARGET_Z10 && reload_completed"
3561 [(unspec [(match_dup 2) (const_int 0)
3562 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3563 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3564 (use (const_int 1))])]
3565 "operands[4] = gen_label_rtx ();")
3568 [(set (reg:CCU CC_REGNUM)
3569 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3570 (match_operand:BLK 1 "memory_operand" "")))
3571 (use (match_operand 2 "register_operand" ""))
3572 (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
3573 (clobber (match_operand 3 "register_operand" ""))]
3574 "reload_completed && TARGET_CPU_ZARCH"
3575 [(set (match_dup 3) (label_ref (match_dup 4)))
3577 [(unspec [(match_dup 2) (mem:BLK (match_dup 3))
3578 (label_ref (match_dup 4))] UNSPEC_EXECUTE)
3579 (set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
3580 (use (const_int 1))])]
3581 "operands[4] = gen_label_rtx ();")
3583 ; Compare a block of arbitrary length.
3585 (define_expand "cmpmem_long"
3587 [(clobber (match_dup 2))
3588 (clobber (match_dup 3))
3589 (set (reg:CCU CC_REGNUM)
3590 (compare:CCU (match_operand:BLK 0 "memory_operand" "")
3591 (match_operand:BLK 1 "memory_operand" "")))
3592 (use (match_operand 2 "general_operand" ""))
3593 (use (match_dup 3))])]
3596 machine_mode sreg_mode = TARGET_ZARCH ? DImode : SImode;
3597 machine_mode dreg_mode = TARGET_ZARCH ? TImode : DImode;
3598 rtx reg0 = gen_reg_rtx (dreg_mode);
3599 rtx reg1 = gen_reg_rtx (dreg_mode);
3600 rtx addr0 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg0));
3601 rtx addr1 = gen_lowpart (Pmode, gen_highpart (sreg_mode, reg1));
3602 rtx len0 = gen_lowpart (Pmode, reg0);
3603 rtx len1 = gen_lowpart (Pmode, reg1);
3605 emit_clobber (reg0);
3606 emit_move_insn (addr0, force_operand (XEXP (operands[0], 0), NULL_RTX));
3607 emit_move_insn (len0, operands[2]);
3609 emit_clobber (reg1);
3610 emit_move_insn (addr1, force_operand (XEXP (operands[1], 0), NULL_RTX));
3611 emit_move_insn (len1, operands[2]);
3613 operands[0] = replace_equiv_address_nv (operands[0], addr0);
3614 operands[1] = replace_equiv_address_nv (operands[1], addr1);
3619 (define_insn "*cmpmem_long"
3620 [(clobber (match_operand:<DBL> 0 "register_operand" "=d"))
3621 (clobber (match_operand:<DBL> 1 "register_operand" "=d"))
3622 (set (reg:CCU CC_REGNUM)
3623 (compare:CCU (mem:BLK (subreg:P (match_operand:<DBL> 2 "register_operand" "0") 0))
3624 (mem:BLK (subreg:P (match_operand:<DBL> 3 "register_operand" "1") 0))))
3626 (use (match_dup 3))]
3627 "TARGET_64BIT || !TARGET_ZARCH"
3628 "clcle\t%0,%1,0\;jo\t.-4"
3629 [(set_attr "length" "8")
3630 (set_attr "type" "vs")])
3632 (define_insn "*cmpmem_long_31z"
3633 [(clobber (match_operand:TI 0 "register_operand" "=d"))
3634 (clobber (match_operand:TI 1 "register_operand" "=d"))
3635 (set (reg:CCU CC_REGNUM)
3636 (compare:CCU (mem:BLK (subreg:SI (match_operand:TI 2 "register_operand" "0") 4))
3637 (mem:BLK (subreg:SI (match_operand:TI 3 "register_operand" "1") 4))))
3639 (use (match_dup 3))]
3640 "!TARGET_64BIT && TARGET_ZARCH"
3641 "clcle\t%0,%1,0\;jo\t.-4"
3642 [(set_attr "op_type" "NN")
3643 (set_attr "type" "vs")
3644 (set_attr "length" "8")])
3646 ; Convert CCUmode condition code to integer.
3647 ; Result is zero if EQ, positive if LTU, negative if GTU.
3649 (define_insn_and_split "cmpint"
3650 [(set (match_operand:SI 0 "register_operand" "=d")
3651 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3652 UNSPEC_STRCMPCC_TO_INT))
3653 (clobber (reg:CC CC_REGNUM))]
3657 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3659 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))
3660 (clobber (reg:CC CC_REGNUM))])])
3662 (define_insn_and_split "*cmpint_cc"
3663 [(set (reg CC_REGNUM)
3664 (compare (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3665 UNSPEC_STRCMPCC_TO_INT)
3667 (set (match_operand:SI 0 "register_operand" "=d")
3668 (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT))]
3669 "s390_match_ccmode (insn, CCSmode)"
3671 "&& reload_completed"
3672 [(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 2)))
3674 [(set (match_dup 2) (match_dup 3))
3675 (set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 30)))])]
3677 rtx result = gen_rtx_ASHIFTRT (SImode, operands[0], GEN_INT (30));
3678 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3679 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3682 (define_insn_and_split "*cmpint_sign"
3683 [(set (match_operand:DI 0 "register_operand" "=d")
3684 (sign_extend:DI (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3685 UNSPEC_STRCMPCC_TO_INT)))
3686 (clobber (reg:CC CC_REGNUM))]
3689 "&& reload_completed"
3690 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3692 [(set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))
3693 (clobber (reg:CC CC_REGNUM))])])
3695 (define_insn_and_split "*cmpint_sign_cc"
3696 [(set (reg CC_REGNUM)
3697 (compare (ashiftrt:DI (ashift:DI (subreg:DI
3698 (unspec:SI [(match_operand:CCU 1 "register_operand" "0")]
3699 UNSPEC_STRCMPCC_TO_INT) 0)
3700 (const_int 32)) (const_int 32))
3702 (set (match_operand:DI 0 "register_operand" "=d")
3703 (sign_extend:DI (unspec:SI [(match_dup 1)] UNSPEC_STRCMPCC_TO_INT)))]
3704 "s390_match_ccmode (insn, CCSmode) && TARGET_ZARCH"
3706 "&& reload_completed"
3707 [(set (match_dup 0) (ashift:DI (match_dup 0) (const_int 34)))
3709 [(set (match_dup 2) (match_dup 3))
3710 (set (match_dup 0) (ashiftrt:DI (match_dup 0) (const_int 62)))])]
3712 rtx result = gen_rtx_ASHIFTRT (DImode, operands[0], GEN_INT (62));
3713 operands[2] = SET_DEST (XVECEXP (PATTERN (curr_insn), 0, 0));
3714 operands[3] = gen_rtx_COMPARE (GET_MODE (operands[2]), result, const0_rtx);
3719 ;;- Conversion instructions.
3722 (define_insn "*sethighpartsi"
3723 [(set (match_operand:SI 0 "register_operand" "=d,d")
3724 (unspec:SI [(match_operand:BLK 1 "s_operand" "Q,S")
3725 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3726 (clobber (reg:CC CC_REGNUM))]
3731 [(set_attr "op_type" "RS,RSY")
3732 (set_attr "cpu_facility" "*,longdisp")
3733 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3735 (define_insn "*sethighpartdi_64"
3736 [(set (match_operand:DI 0 "register_operand" "=d")
3737 (unspec:DI [(match_operand:BLK 1 "s_operand" "S")
3738 (match_operand 2 "const_int_operand" "n")] UNSPEC_ICM))
3739 (clobber (reg:CC CC_REGNUM))]
3742 [(set_attr "op_type" "RSY")
3743 (set_attr "z10prop" "z10_super")])
3745 (define_insn "*sethighpartdi_31"
3746 [(set (match_operand:DI 0 "register_operand" "=d,d")
3747 (unspec:DI [(match_operand:BLK 1 "s_operand" "Q,S")
3748 (match_operand 2 "const_int_operand" "n,n")] UNSPEC_ICM))
3749 (clobber (reg:CC CC_REGNUM))]
3754 [(set_attr "op_type" "RS,RSY")
3755 (set_attr "cpu_facility" "*,longdisp")
3756 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
3759 ; extv instruction patterns
3762 ; FIXME: This expander needs to be converted from DI to GPR as well
3763 ; after resolving some issues with it.
3765 (define_expand "extzv"
3767 [(set (match_operand:DI 0 "register_operand" "=d")
3769 (match_operand:DI 1 "register_operand" "d")
3770 (match_operand 2 "const_int_operand" "") ; size
3771 (match_operand 3 "const_int_operand" ""))) ; start
3772 (clobber (reg:CC CC_REGNUM))])]
3775 if (! EXTRACT_ARGS_IN_RANGE (INTVAL (operands[2]), INTVAL (operands[3]), 64))
3777 /* Starting with zEC12 there is risbgn not clobbering CC. */
3780 emit_move_insn (operands[0],
3781 gen_rtx_ZERO_EXTRACT (DImode,
3789 (define_insn "*extzv<mode><clobbercc_or_nocc>"
3790 [(set (match_operand:GPR 0 "register_operand" "=d")
3792 (match_operand:GPR 1 "register_operand" "d")
3793 (match_operand 2 "const_int_operand" "") ; size
3794 (match_operand 3 "const_int_operand" ""))) ; start
3796 "<z10_or_zEC12_cond>
3797 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[2]), INTVAL (operands[3]),
3798 GET_MODE_BITSIZE (<MODE>mode))"
3799 "<risbg_n>\t%0,%1,64-%2,128+63,<bitoff_plus>%3+%2" ; dst, src, start, end, shift
3800 [(set_attr "op_type" "RIE")
3801 (set_attr "z10prop" "z10_super_E1")])
3803 ; 64 bit: (a & -16) | ((b >> 8) & 15)
3804 (define_insn "*extzvdi<clobbercc_or_nocc>_lshiftrt"
3805 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
3806 (match_operand 1 "const_int_operand" "") ; size
3807 (match_operand 2 "const_int_operand" "")) ; start
3808 (lshiftrt:DI (match_operand:DI 3 "register_operand" "d")
3809 (match_operand:DI 4 "nonzero_shift_count_operand" "")))]
3810 "<z10_or_zEC12_cond>
3811 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
3812 && 64 - UINTVAL (operands[4]) >= UINTVAL (operands[1])"
3813 "<risbg_n>\t%0,%3,%2,%2+%1-1,128-%2-%1-%4"
3814 [(set_attr "op_type" "RIE")
3815 (set_attr "z10prop" "z10_super_E1")])
3817 ; 32 bit: (a & -16) | ((b >> 8) & 15)
3818 (define_insn "*<risbg_n>_ior_and_sr_ze"
3819 [(set (match_operand:SI 0 "register_operand" "=d")
3821 (match_operand:SI 1 "register_operand" "0")
3822 (match_operand:SI 2 "const_int_operand" ""))
3825 (match_operand:DI 3 "register_operand" "d")
3826 (match_operand 4 "const_int_operand" "") ; size
3827 (match_operand 5 "const_int_operand" "")) ; start
3829 "<z10_or_zEC12_cond>
3830 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[4]), INTVAL (operands[5]), 64)
3831 && UINTVAL (operands[2]) == (~(0ULL) << UINTVAL (operands[4]))"
3832 "<risbg_n>\t%0,%3,64-%4,63,%4+%5"
3833 [(set_attr "op_type" "RIE")
3834 (set_attr "z10prop" "z10_super_E1")])
3836 ; ((int)foo >> 10) & 1;
3837 (define_insn "*extract1bitdi<clobbercc_or_nocc>"
3838 [(set (match_operand:DI 0 "register_operand" "=d")
3839 (ne:DI (zero_extract:DI
3840 (match_operand:DI 1 "register_operand" "d")
3841 (const_int 1) ; size
3842 (match_operand 2 "const_int_operand" "")) ; start
3844 "<z10_or_zEC12_cond>
3845 && EXTRACT_ARGS_IN_RANGE (1, INTVAL (operands[2]), 64)"
3846 "<risbg_n>\t%0,%1,64-1,128+63,%2+1" ; dst, src, start, end, shift
3847 [(set_attr "op_type" "RIE")
3848 (set_attr "z10prop" "z10_super_E1")])
3850 (define_insn "*<risbg_n>_and_subregdi_rotr"
3851 [(set (match_operand:DI 0 "register_operand" "=d")
3853 (rotate:SINT (match_operand:SINT 1 "register_operand" "d")
3854 (match_operand:SINT 2 "const_int_operand" "")) 0)
3855 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3856 "<z10_or_zEC12_cond>
3857 && UINTVAL (operands[3]) < (1ULL << (UINTVAL (operands[2]) & 0x3f))"
3858 "<risbg_n>\t%0,%1,%s3,128+%e3,<bitoff_plus>%2" ; dst, src, start, end, shift
3859 [(set_attr "op_type" "RIE")
3860 (set_attr "z10prop" "z10_super_E1")])
3862 (define_insn "*<risbg_n>_and_subregdi_rotl"
3863 [(set (match_operand:DI 0 "register_operand" "=d")
3865 (rotate:SINT (match_operand:SINT 1 "register_operand" "d")
3866 (match_operand:SINT 2 "const_int_operand" "")) 0)
3867 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3868 "<z10_or_zEC12_cond>
3869 && !(UINTVAL (operands[3]) & ((1ULL << (UINTVAL (operands[2]) & 0x3f)) - 1))"
3870 "<risbg_n>\t%0,%1,%s3,128+%e3,%2" ; dst, src, start, end, shift
3871 [(set_attr "op_type" "RIE")
3872 (set_attr "z10prop" "z10_super_E1")])
3874 (define_insn "*<risbg_n>_di_and_rot"
3875 [(set (match_operand:DI 0 "register_operand" "=d")
3876 (and:DI (rotate:DI (match_operand:DI 1 "register_operand" "d")
3877 (match_operand:DI 2 "const_int_operand" ""))
3878 (match_operand:DI 3 "contiguous_bitmask_operand" "")))]
3879 "<z10_or_zEC12_cond>"
3880 "<risbg_n>\t%0,%1,%s3,128+%e3,%2" ; dst, src, start, end, shift
3881 [(set_attr "op_type" "RIE")
3882 (set_attr "z10prop" "z10_super_E1")])
3884 (define_insn_and_split "*pre_z10_extzv<mode>"
3885 [(set (match_operand:GPR 0 "register_operand" "=d")
3886 (zero_extract:GPR (match_operand:QI 1 "s_operand" "S")
3887 (match_operand 2 "nonzero_shift_count_operand" "")
3889 (clobber (reg:CC CC_REGNUM))]
3892 "&& reload_completed"
3894 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3895 (clobber (reg:CC CC_REGNUM))])
3896 (set (match_dup 0) (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
3898 int bitsize = INTVAL (operands[2]);
3899 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3900 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3902 operands[1] = adjust_address (operands[1], BLKmode, 0);
3903 set_mem_size (operands[1], size);
3904 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
3905 operands[3] = GEN_INT (mask);
3908 (define_insn_and_split "*pre_z10_extv<mode>"
3909 [(set (match_operand:GPR 0 "register_operand" "=d")
3910 (sign_extract:GPR (match_operand:QI 1 "s_operand" "S")
3911 (match_operand 2 "nonzero_shift_count_operand" "")
3913 (clobber (reg:CC CC_REGNUM))]
3916 "&& reload_completed"
3918 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (match_dup 3)] UNSPEC_ICM))
3919 (clobber (reg:CC CC_REGNUM))])
3921 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
3922 (clobber (reg:CC CC_REGNUM))])]
3924 int bitsize = INTVAL (operands[2]);
3925 int size = (bitsize - 1) / BITS_PER_UNIT + 1; /* round up */
3926 int mask = ((1ul << size) - 1) << (GET_MODE_SIZE (SImode) - size);
3928 operands[1] = adjust_address (operands[1], BLKmode, 0);
3929 set_mem_size (operands[1], size);
3930 operands[2] = GEN_INT (<GPR:bitsize> - bitsize);
3931 operands[3] = GEN_INT (mask);
3935 ; insv instruction patterns
3938 (define_expand "insv"
3939 [(set (zero_extract (match_operand 0 "nonimmediate_operand" "")
3940 (match_operand 1 "const_int_operand" "")
3941 (match_operand 2 "const_int_operand" ""))
3942 (match_operand 3 "general_operand" ""))]
3945 if (s390_expand_insv (operands[0], operands[1], operands[2], operands[3]))
3951 ; The normal RTL expansion will never generate a zero_extract where
3952 ; the location operand isn't word mode. However, we do this in the
3953 ; back-end when generating atomic operations. See s390_two_part_insv.
3954 (define_insn "*insv<mode><clobbercc_or_nocc>"
3955 [(set (zero_extract:GPR (match_operand:GPR 0 "nonimmediate_operand" "+d")
3956 (match_operand 1 "const_int_operand" "I") ; size
3957 (match_operand 2 "const_int_operand" "I")) ; pos
3958 (match_operand:GPR 3 "nonimmediate_operand" "d"))]
3959 "<z10_or_zEC12_cond>
3960 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]),
3961 GET_MODE_BITSIZE (<MODE>mode))
3962 && (INTVAL (operands[1]) + INTVAL (operands[2])) <= <bitsize>"
3963 "<risbg_n>\t%0,%3,<bitoff_plus>%2,<bitoff_plus>%2+%1-1,<bitsize>-%2-%1"
3964 [(set_attr "op_type" "RIE")
3965 (set_attr "z10prop" "z10_super_E1")])
3967 ; and op1 with a mask being 1 for the selected bits and 0 for the rest
3968 ; and op3=op0 with a mask being 0 for the selected bits and 1 for the rest
3969 (define_insn "*insv<mode><clobbercc_or_nocc>_noshift"
3970 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d")
3971 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d,0")
3972 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
3973 (and:GPR (match_operand:GPR 3 "nonimmediate_operand" "0,d")
3974 (match_operand:GPR 4 "const_int_operand" ""))))]
3975 "<z10_or_zEC12_cond> && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3977 <risbg_n>\t%0,%1,%<bfstart>2,%<bfend>2,0
3978 <risbg_n>\t%0,%3,%<bfstart>4,%<bfend>4,0"
3979 [(set_attr "op_type" "RIE")
3980 (set_attr "z10prop" "z10_super_E1")])
3982 (define_insn "*insv_z10_noshift_cc"
3983 [(set (reg CC_REGNUM)
3986 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,0")
3987 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
3988 (and:DI (match_operand:DI 3 "nonimmediate_operand" "0,d")
3989 (match_operand:DI 4 "const_int_operand" "")))
3991 (set (match_operand:DI 0 "nonimmediate_operand" "=d,d")
3992 (ior:DI (and:DI (match_dup 1) (match_dup 2))
3993 (and:DI (match_dup 3) (match_dup 4))))]
3994 "TARGET_Z10 && s390_match_ccmode (insn, CCSmode)
3995 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
3997 risbg\t%0,%1,%s2,%e2,0
3998 risbg\t%0,%3,%s4,%e4,0"
3999 [(set_attr "op_type" "RIE")
4000 (set_attr "z10prop" "z10_super_E1")])
4002 (define_insn "*insv_z10_noshift_cconly"
4007 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,0")
4008 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
4009 (and:DI (match_operand:DI 3 "nonimmediate_operand" "0,d")
4010 (match_operand:DI 4 "const_int_operand" "")))
4012 (clobber (match_scratch:DI 0 "=d,d"))]
4013 "TARGET_Z10 && s390_match_ccmode (insn, CCSmode)
4014 && INTVAL (operands[2]) == ~INTVAL (operands[4])"
4016 risbg\t%0,%1,%s2,%e2,0
4017 risbg\t%0,%3,%s4,%e4,0"
4018 [(set_attr "op_type" "RIE")
4019 (set_attr "z10prop" "z10_super_E1")])
4021 ; Implement appending Y on the left of S bits of X
4022 ; x = (y << s) | (x & ((1 << s) - 1))
4023 (define_insn "*insv<mode><clobbercc_or_nocc>_appendbitsleft"
4024 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4025 (ior:GPR (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "0")
4026 (match_operand:GPR 2 "immediate_operand" ""))
4027 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "d")
4028 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4029 "<z10_or_zEC12_cond>
4030 && UINTVAL (operands[2]) == (1UL << UINTVAL (operands[4])) - 1"
4031 "<risbg_n>\t%0,%3,<bitoff>,64-%4-1,%4"
4032 [(set_attr "op_type" "RIE")
4033 (set_attr "z10prop" "z10_super_E1")])
4035 ; a = ((i32)a & -16777216) | (((ui32)b) >> 8)
4036 (define_insn "*<risbg_n>_<mode>_ior_and_lshiftrt"
4037 [(set (match_operand:GPR 0 "register_operand" "=d")
4039 (match_operand:GPR 1 "register_operand" "0")
4040 (match_operand:GPR 2 "const_int_operand" ""))
4042 (match_operand:GPR 3 "register_operand" "d")
4043 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4044 "<z10_or_zEC12_cond> && UINTVAL (operands[2])
4045 == (~(0ULL) << (GET_MODE_BITSIZE (<MODE>mode) - UINTVAL (operands[4])))"
4046 "<risbg_n>\t%0,%3,<bitoff_plus>%4,63,64-%4"
4047 [(set_attr "op_type" "RIE")
4048 (set_attr "z10prop" "z10_super_E1")])
4050 ; (ui32)(((ui64)x) >> 48) | ((i32)y & -65536);
4051 (define_insn "*<risbg_n>_sidi_ior_and_lshiftrt"
4052 [(set (match_operand:SI 0 "register_operand" "=d")
4054 (match_operand:SI 1 "register_operand" "0")
4055 (match_operand:SI 2 "const_int_operand" ""))
4058 (match_operand:DI 3 "register_operand" "d")
4059 (match_operand:DI 4 "nonzero_shift_count_operand" "")) 4)))]
4060 "<z10_or_zEC12_cond>
4061 && UINTVAL (operands[2]) == ~(~(0ULL) >> UINTVAL (operands[4]))"
4062 "<risbg_n>\t%0,%3,%4,63,64-%4"
4063 [(set_attr "op_type" "RIE")
4064 (set_attr "z10prop" "z10_super_E1")])
4066 ; (ui32)(((ui64)x) >> 12) & -4
4067 (define_insn "*trunc_sidi_and_subreg_lshrt<clobbercc_or_nocc>"
4068 [(set (match_operand:SI 0 "register_operand" "=d")
4070 (subreg:SI (lshiftrt:DI
4071 (match_operand:DI 1 "register_operand" "d")
4072 (match_operand:DI 2 "nonzero_shift_count_operand" "")) 4)
4073 (match_operand:SI 3 "contiguous_bitmask_nowrap_operand" "")))]
4074 "<z10_or_zEC12_cond>"
4075 "<risbg_n>\t%0,%1,%t3,128+%f3,64-%2"
4076 [(set_attr "op_type" "RIE")
4077 (set_attr "z10prop" "z10_super_E1")])
4079 ; z = (x << c) | (y >> d) with (x << c) and (y >> d) not overlapping after shifting
4080 ; -> z = y >> d; z = (x << c) | (z & ((1 << c) - 1))
4081 ; -> z = y >> d; z = risbg;
4084 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
4085 (ior:GPR (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
4086 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4087 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "")
4088 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))]
4089 "TARGET_ZEC12 && UINTVAL (operands[2]) + UINTVAL (operands[4]) >= <bitsize>"
4091 (lshiftrt:GPR (match_dup 1) (match_dup 2)))
4093 (ior:GPR (and:GPR (match_dup 6) (match_dup 5))
4094 (ashift:GPR (match_dup 3) (match_dup 4))))]
4096 operands[5] = GEN_INT ((1UL << UINTVAL (operands[4])) - 1);
4097 if (reg_overlap_mentioned_p (operands[0], operands[3]))
4099 if (!can_create_pseudo_p ())
4101 operands[6] = gen_reg_rtx (<MODE>mode);
4104 operands[6] = operands[0];
4109 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
4110 (ior:GPR (lshiftrt:GPR (match_operand:GPR 1 "nonimmediate_operand" "")
4111 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4112 (ashift:GPR (match_operand:GPR 3 "nonimmediate_operand" "")
4113 (match_operand:GPR 4 "nonzero_shift_count_operand" ""))))
4114 (clobber (reg:CC CC_REGNUM))])]
4115 "TARGET_Z10 && !TARGET_ZEC12 && UINTVAL (operands[2]) + UINTVAL (operands[4]) >= <bitsize>"
4117 (lshiftrt:GPR (match_dup 1) (match_dup 2)))
4120 (ior:GPR (and:GPR (match_dup 6) (match_dup 5))
4121 (ashift:GPR (match_dup 3) (match_dup 4))))
4122 (clobber (reg:CC CC_REGNUM))])]
4124 operands[5] = GEN_INT ((1UL << UINTVAL (operands[4])) - 1);
4125 if (reg_overlap_mentioned_p (operands[0], operands[3]))
4127 if (!can_create_pseudo_p ())
4129 operands[6] = gen_reg_rtx (<MODE>mode);
4132 operands[6] = operands[0];
4136 (define_insn "*r<noxa>sbg_<mode>_noshift"
4137 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4139 (and:GPR (match_operand:GPR 1 "nonimmediate_operand" "d")
4140 (match_operand:GPR 2 "contiguous_bitmask_operand" ""))
4141 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4142 (clobber (reg:CC CC_REGNUM))]
4144 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,0"
4145 [(set_attr "op_type" "RIE")])
4148 (define_insn "*r<noxa>sbg_di_rotl"
4149 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4153 (match_operand:DI 1 "nonimmediate_operand" "d")
4154 (match_operand:DI 3 "const_int_operand" ""))
4155 (match_operand:DI 2 "contiguous_bitmask_operand" ""))
4156 (match_operand:DI 4 "nonimmediate_operand" "0")))
4157 (clobber (reg:CC CC_REGNUM))]
4159 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%b3"
4160 [(set_attr "op_type" "RIE")])
4163 (define_insn "*r<noxa>sbg_<mode>_srl_bitmask"
4164 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4168 (match_operand:GPR 1 "nonimmediate_operand" "d")
4169 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
4170 (match_operand:GPR 2 "contiguous_bitmask_nowrap_operand" ""))
4171 (match_operand:GPR 4 "nonimmediate_operand" "0")))
4172 (clobber (reg:CC CC_REGNUM))]
4174 && s390_extzv_shift_ok (<bitsize>, 64 - INTVAL (operands[3]),
4175 INTVAL (operands[2]))"
4176 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,64-%3"
4177 [(set_attr "op_type" "RIE")])
4180 (define_insn "*r<noxa>sbg_<mode>_sll_bitmask"
4181 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4185 (match_operand:GPR 1 "nonimmediate_operand" "d")
4186 (match_operand:GPR 3 "nonzero_shift_count_operand" ""))
4187 (match_operand:GPR 2 "contiguous_bitmask_nowrap_operand" ""))
4188 (match_operand:GPR 4 "nonimmediate_operand" "0")))
4189 (clobber (reg:CC CC_REGNUM))]
4191 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[3]),
4192 INTVAL (operands[2]))"
4193 "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%3"
4194 [(set_attr "op_type" "RIE")])
4196 ;; unsigned {int,long} a, b
4197 ;; a = a | (b << const_int)
4198 ;; a = a ^ (b << const_int)
4200 (define_insn "*r<noxa>sbg_<mode>_sll"
4201 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4204 (match_operand:GPR 1 "nonimmediate_operand" "d")
4205 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4206 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4207 (clobber (reg:CC CC_REGNUM))]
4209 "r<noxa>sbg\t%0,%1,<bitoff>,63-%2,%2"
4210 [(set_attr "op_type" "RIE")])
4212 ;; unsigned {int,long} a, b
4213 ;; a = a | (b >> const_int)
4214 ;; a = a ^ (b >> const_int)
4216 (define_insn "*r<noxa>sbg_<mode>_srl"
4217 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d")
4220 (match_operand:GPR 1 "nonimmediate_operand" "d")
4221 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
4222 (match_operand:GPR 3 "nonimmediate_operand" "0")))
4223 (clobber (reg:CC CC_REGNUM))]
4225 "r<noxa>sbg\t%0,%1,<bitoff_plus>%2,63,64-%2"
4226 [(set_attr "op_type" "RIE")])
4228 ;; These two are generated by combine for s.bf &= val.
4229 ;; ??? For bitfields smaller than 32-bits, we wind up with SImode
4230 ;; shifts and ands, which results in some truly awful patterns
4231 ;; including subregs of operations. Rather unnecessisarily, IMO.
4234 ;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
4235 ;; (const_int 24 [0x18])
4236 ;; (const_int 0 [0]))
4237 ;; (subreg:DI (and:SI (subreg:SI (lshiftrt:DI (reg/v:DI 50 [ s ])
4238 ;; (const_int 40 [0x28])) 4)
4239 ;; (reg:SI 4 %r4 [ y+4 ])) 0))
4241 ;; we should instead generate
4243 ;; (set (zero_extract:DI (reg/v:DI 50 [ s ])
4244 ;; (const_int 24 [0x18])
4245 ;; (const_int 0 [0]))
4246 ;; (and:DI (lshiftrt:DI (reg/v:DI 50 [ s ])
4247 ;; (const_int 40 [0x28]))
4248 ;; (subreg:DI (reg:SI 4 %r4 [ y+4 ]) 0)))
4250 ;; by noticing that we can push down the outer paradoxical subreg
4251 ;; into the operation.
4253 (define_insn "*insv_rnsbg_noshift"
4254 [(set (zero_extract:DI
4255 (match_operand:DI 0 "nonimmediate_operand" "+d")
4256 (match_operand 1 "const_int_operand" "")
4257 (match_operand 2 "const_int_operand" ""))
4260 (match_operand:DI 3 "nonimmediate_operand" "d")))
4261 (clobber (reg:CC CC_REGNUM))]
4263 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
4264 && INTVAL (operands[1]) + INTVAL (operands[2]) == 64"
4265 "rnsbg\t%0,%3,%2,63,0"
4266 [(set_attr "op_type" "RIE")])
4268 (define_insn "*insv_rnsbg_srl"
4269 [(set (zero_extract:DI
4270 (match_operand:DI 0 "nonimmediate_operand" "+d")
4271 (match_operand 1 "const_int_operand" "")
4272 (match_operand 2 "const_int_operand" ""))
4276 (match_operand 3 "const_int_operand" ""))
4277 (match_operand:DI 4 "nonimmediate_operand" "d")))
4278 (clobber (reg:CC CC_REGNUM))]
4280 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64)
4281 && INTVAL (operands[3]) == 64 - INTVAL (operands[1]) - INTVAL (operands[2])"
4282 "rnsbg\t%0,%4,%2,%2+%1-1,%3"
4283 [(set_attr "op_type" "RIE")])
4285 (define_insn "*insv<mode>_mem_reg"
4286 [(set (zero_extract:W (match_operand:QI 0 "memory_operand" "+Q,S")
4287 (match_operand 1 "const_int_operand" "n,n")
4289 (match_operand:W 2 "register_operand" "d,d"))]
4290 "EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), 0, 64)
4291 && INTVAL (operands[1]) > 0
4292 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
4293 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
4295 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
4297 operands[1] = GEN_INT ((1ul << size) - 1);
4298 return (which_alternative == 0) ? "stcm\t%2,%1,%S0"
4299 : "stcmy\t%2,%1,%S0";
4301 [(set_attr "op_type" "RS,RSY")
4302 (set_attr "cpu_facility" "*,longdisp")
4303 (set_attr "z10prop" "z10_super,z10_super")])
4305 (define_insn "*insvdi_mem_reghigh"
4306 [(set (zero_extract:DI (match_operand:QI 0 "memory_operand" "+S")
4307 (match_operand 1 "const_int_operand" "n")
4309 (lshiftrt:DI (match_operand:DI 2 "register_operand" "d")
4312 && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), 0, 64)
4313 && INTVAL (operands[1]) > 0
4314 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode)
4315 && INTVAL (operands[1]) % BITS_PER_UNIT == 0"
4317 int size = INTVAL (operands[1]) / BITS_PER_UNIT;
4319 operands[1] = GEN_INT ((1ul << size) - 1);
4320 return "stcmh\t%2,%1,%S0";
4322 [(set_attr "op_type" "RSY")
4323 (set_attr "z10prop" "z10_super")])
4325 (define_insn "*insvdi_reg_imm"
4326 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4328 (match_operand 1 "const_int_operand" "n"))
4329 (match_operand:DI 2 "const_int_operand" "n"))]
4331 && EXTRACT_ARGS_IN_RANGE (16, INTVAL (operands[1]), 64)
4332 && INTVAL (operands[1]) >= 0
4333 && INTVAL (operands[1]) < BITS_PER_WORD
4334 && INTVAL (operands[1]) % 16 == 0"
4336 switch (BITS_PER_WORD - INTVAL (operands[1]))
4338 case 64: return "iihh\t%0,%x2"; break;
4339 case 48: return "iihl\t%0,%x2"; break;
4340 case 32: return "iilh\t%0,%x2"; break;
4341 case 16: return "iill\t%0,%x2"; break;
4342 default: gcc_unreachable();
4345 [(set_attr "op_type" "RI")
4346 (set_attr "z10prop" "z10_super_E1")])
4348 ; Update the left-most 32 bit of a DI.
4349 (define_insn "*insv_h_di_reg_extimm"
4350 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4353 (match_operand:DI 1 "const_int_operand" "n"))]
4356 [(set_attr "op_type" "RIL")
4357 (set_attr "z10prop" "z10_fwd_E1")])
4359 ; Update the right-most 32 bit of a DI.
4360 (define_insn "*insv_l_di_reg_extimm"
4361 [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+d")
4364 (match_operand:DI 1 "const_int_operand" "n"))]
4367 [(set_attr "op_type" "RIL")
4368 (set_attr "z10prop" "z10_fwd_A1")])
4371 ; extendsidi2 instruction pattern(s).
4374 (define_expand "extendsidi2"
4375 [(set (match_operand:DI 0 "register_operand" "")
4376 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
4381 emit_clobber (operands[0]);
4382 emit_move_insn (gen_highpart (SImode, operands[0]), operands[1]);
4383 emit_move_insn (gen_lowpart (SImode, operands[0]), const0_rtx);
4384 emit_insn (gen_ashrdi3 (operands[0], operands[0], GEN_INT (32)));
4389 (define_insn "*extendsidi2"
4390 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4391 (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,T,b")))]
4397 [(set_attr "op_type" "RRE,RXY,RIL")
4398 (set_attr "type" "*,*,larl")
4399 (set_attr "cpu_facility" "*,*,z10")
4400 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4403 ; extend(hi|qi)(si|di)2 instruction pattern(s).
4406 (define_expand "extend<HQI:mode><DSI:mode>2"
4407 [(set (match_operand:DSI 0 "register_operand" "")
4408 (sign_extend:DSI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4411 if (<DSI:MODE>mode == DImode && !TARGET_ZARCH)
4413 rtx tmp = gen_reg_rtx (SImode);
4414 emit_insn (gen_extend<HQI:mode>si2 (tmp, operands[1]));
4415 emit_insn (gen_extendsidi2 (operands[0], tmp));
4418 else if (!TARGET_EXTIMM)
4420 rtx bitcount = GEN_INT (<DSI:bitsize> - <HQI:bitsize>);
4422 operands[1] = gen_lowpart (<DSI:MODE>mode, operands[1]);
4423 emit_insn (gen_ashl<DSI:mode>3 (operands[0], operands[1], bitcount));
4424 emit_insn (gen_ashr<DSI:mode>3 (operands[0], operands[0], bitcount));
4430 ; extendhidi2 instruction pattern(s).
4433 (define_insn "*extendhidi2_extimm"
4434 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4435 (sign_extend:DI (match_operand:HI 1 "general_operand" "d,T,b")))]
4436 "TARGET_ZARCH && TARGET_EXTIMM"
4441 [(set_attr "op_type" "RRE,RXY,RIL")
4442 (set_attr "type" "*,*,larl")
4443 (set_attr "cpu_facility" "extimm,extimm,z10")
4444 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1")])
4446 (define_insn "*extendhidi2"
4447 [(set (match_operand:DI 0 "register_operand" "=d")
4448 (sign_extend:DI (match_operand:HI 1 "memory_operand" "T")))]
4451 [(set_attr "op_type" "RXY")
4452 (set_attr "z10prop" "z10_super_E1")])
4455 ; extendhisi2 instruction pattern(s).
4458 (define_insn "*extendhisi2_extimm"
4459 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d")
4460 (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" " d,R,T,b")))]
4467 [(set_attr "op_type" "RRE,RX,RXY,RIL")
4468 (set_attr "type" "*,*,*,larl")
4469 (set_attr "cpu_facility" "extimm,extimm,extimm,z10")
4470 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,z10_super_E1")])
4472 (define_insn "*extendhisi2"
4473 [(set (match_operand:SI 0 "register_operand" "=d,d")
4474 (sign_extend:SI (match_operand:HI 1 "memory_operand" "R,T")))]
4479 [(set_attr "op_type" "RX,RXY")
4480 (set_attr "cpu_facility" "*,longdisp")
4481 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4484 ; extendqi(si|di)2 instruction pattern(s).
4487 ; lbr, lgbr, lb, lgb
4488 (define_insn "*extendqi<mode>2_extimm"
4489 [(set (match_operand:GPR 0 "register_operand" "=d,d")
4490 (sign_extend:GPR (match_operand:QI 1 "nonimmediate_operand" "d,T")))]
4495 [(set_attr "op_type" "RRE,RXY")
4496 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4499 (define_insn "*extendqi<mode>2"
4500 [(set (match_operand:GPR 0 "register_operand" "=d")
4501 (sign_extend:GPR (match_operand:QI 1 "memory_operand" "T")))]
4502 "!TARGET_EXTIMM && TARGET_LONG_DISPLACEMENT"
4504 [(set_attr "op_type" "RXY")
4505 (set_attr "z10prop" "z10_super_E1")])
4507 (define_insn_and_split "*extendqi<mode>2_short_displ"
4508 [(set (match_operand:GPR 0 "register_operand" "=d")
4509 (sign_extend:GPR (match_operand:QI 1 "s_operand" "Q")))
4510 (clobber (reg:CC CC_REGNUM))]
4511 "!TARGET_EXTIMM && !TARGET_LONG_DISPLACEMENT"
4513 "&& reload_completed"
4515 [(set (match_dup 0) (unspec:GPR [(match_dup 1) (const_int 8)] UNSPEC_ICM))
4516 (clobber (reg:CC CC_REGNUM))])
4518 [(set (match_dup 0) (ashiftrt:GPR (match_dup 0) (match_dup 2)))
4519 (clobber (reg:CC CC_REGNUM))])]
4521 operands[1] = adjust_address (operands[1], BLKmode, 0);
4522 set_mem_size (operands[1], GET_MODE_SIZE (QImode));
4523 operands[2] = GEN_INT (<GPR:bitsize> - BITS_PER_UNIT);
4527 ; zero_extendsidi2 instruction pattern(s).
4530 (define_expand "zero_extendsidi2"
4531 [(set (match_operand:DI 0 "register_operand" "")
4532 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "")))]
4537 emit_clobber (operands[0]);
4538 emit_move_insn (gen_lowpart (SImode, operands[0]), operands[1]);
4539 emit_move_insn (gen_highpart (SImode, operands[0]), const0_rtx);
4544 (define_insn "*zero_extendsidi2"
4545 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
4546 (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "d,T,b")))]
4552 [(set_attr "op_type" "RRE,RXY,RIL")
4553 (set_attr "type" "*,*,larl")
4554 (set_attr "cpu_facility" "*,*,z10")
4555 (set_attr "z10prop" "z10_fwd_E1,z10_fwd_A3,z10_fwd_A3")])
4558 ; LLGT-type instructions (zero-extend from 31 bit to 64 bit).
4561 (define_insn "*llgt_sidi"
4562 [(set (match_operand:DI 0 "register_operand" "=d")
4563 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "T") 0)
4564 (const_int 2147483647)))]
4567 [(set_attr "op_type" "RXE")
4568 (set_attr "z10prop" "z10_super_E1")])
4570 (define_insn_and_split "*llgt_sidi_split"
4571 [(set (match_operand:DI 0 "register_operand" "=d")
4572 (and:DI (subreg:DI (match_operand:SI 1 "memory_operand" "T") 0)
4573 (const_int 2147483647)))
4574 (clobber (reg:CC CC_REGNUM))]
4577 "&& reload_completed"
4579 (and:DI (subreg:DI (match_dup 1) 0)
4580 (const_int 2147483647)))]
4583 (define_insn "*llgt_sisi"
4584 [(set (match_operand:SI 0 "register_operand" "=d,d")
4585 (and:SI (match_operand:SI 1 "nonimmediate_operand" "d,T")
4586 (const_int 2147483647)))]
4591 [(set_attr "op_type" "RRE,RXE")
4592 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4594 (define_insn "*llgt_didi"
4595 [(set (match_operand:DI 0 "register_operand" "=d,d")
4596 (and:DI (match_operand:DI 1 "nonimmediate_operand" "d,o")
4597 (const_int 2147483647)))]
4602 [(set_attr "op_type" "RRE,RXE")
4603 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
4606 [(set (match_operand:DSI 0 "register_operand" "")
4607 (and:DSI (match_operand:DSI 1 "nonimmediate_operand" "")
4608 (const_int 2147483647)))
4609 (clobber (reg:CC CC_REGNUM))]
4610 "TARGET_ZARCH && reload_completed"
4612 (and:DSI (match_dup 1)
4613 (const_int 2147483647)))]
4617 ; zero_extend(hi|qi)(si|di)2 instruction pattern(s).
4620 (define_expand "zero_extend<mode>di2"
4621 [(set (match_operand:DI 0 "register_operand" "")
4622 (zero_extend:DI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4627 rtx tmp = gen_reg_rtx (SImode);
4628 emit_insn (gen_zero_extend<mode>si2 (tmp, operands[1]));
4629 emit_insn (gen_zero_extendsidi2 (operands[0], tmp));
4632 else if (!TARGET_EXTIMM)
4634 rtx bitcount = GEN_INT (64 - <HQI:bitsize>);
4635 operands[1] = gen_lowpart (DImode, operands[1]);
4636 emit_insn (gen_ashldi3 (operands[0], operands[1], bitcount));
4637 emit_insn (gen_lshrdi3 (operands[0], operands[0], bitcount));
4642 (define_expand "zero_extend<mode>si2"
4643 [(set (match_operand:SI 0 "register_operand" "")
4644 (zero_extend:SI (match_operand:HQI 1 "nonimmediate_operand" "")))]
4649 operands[1] = gen_lowpart (SImode, operands[1]);
4650 emit_insn (gen_andsi3 (operands[0], operands[1],
4651 GEN_INT ((1 << <HQI:bitsize>) - 1)));
4657 (define_insn "*zero_extendhi<mode>2_z10"
4658 [(set (match_operand:GPR 0 "register_operand" "=d,d,d")
4659 (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "d,T,b")))]
4665 [(set_attr "op_type" "RXY,RRE,RIL")
4666 (set_attr "type" "*,*,larl")
4667 (set_attr "cpu_facility" "*,*,z10")
4668 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3,z10_fwd_A3")])
4670 ; llhr, llcr, llghr, llgcr, llh, llc, llgh, llgc
4671 (define_insn "*zero_extend<HQI:mode><GPR:mode>2_extimm"
4672 [(set (match_operand:GPR 0 "register_operand" "=d,d")
4673 (zero_extend:GPR (match_operand:HQI 1 "nonimmediate_operand" "d,T")))]
4678 [(set_attr "op_type" "RRE,RXY")
4679 (set_attr "z10prop" "z10_super_E1,z10_fwd_A3")])
4682 (define_insn "*zero_extend<HQI:mode><GPR:mode>2"
4683 [(set (match_operand:GPR 0 "register_operand" "=d")
4684 (zero_extend:GPR (match_operand:HQI 1 "memory_operand" "T")))]
4685 "TARGET_ZARCH && !TARGET_EXTIMM"
4687 [(set_attr "op_type" "RXY")
4688 (set_attr "z10prop" "z10_fwd_A3")])
4690 (define_insn_and_split "*zero_extendhisi2_31"
4691 [(set (match_operand:SI 0 "register_operand" "=&d")
4692 (zero_extend:SI (match_operand:HI 1 "s_operand" "S")))
4693 (clobber (reg:CC CC_REGNUM))]
4696 "&& reload_completed"
4697 [(set (match_dup 0) (const_int 0))
4699 [(set (strict_low_part (match_dup 2)) (match_dup 1))
4700 (clobber (reg:CC CC_REGNUM))])]
4701 "operands[2] = gen_lowpart (HImode, operands[0]);")
4703 (define_insn_and_split "*zero_extendqisi2_31"
4704 [(set (match_operand:SI 0 "register_operand" "=&d")
4705 (zero_extend:SI (match_operand:QI 1 "memory_operand" "T")))]
4708 "&& reload_completed"
4709 [(set (match_dup 0) (const_int 0))
4710 (set (strict_low_part (match_dup 2)) (match_dup 1))]
4711 "operands[2] = gen_lowpart (QImode, operands[0]);")
4714 ; zero_extendqihi2 instruction pattern(s).
4717 (define_expand "zero_extendqihi2"
4718 [(set (match_operand:HI 0 "register_operand" "")
4719 (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
4720 "TARGET_ZARCH && !TARGET_EXTIMM"
4722 operands[1] = gen_lowpart (HImode, operands[1]);
4723 emit_insn (gen_andhi3 (operands[0], operands[1], GEN_INT (0xff)));
4727 (define_insn "*zero_extendqihi2_64"
4728 [(set (match_operand:HI 0 "register_operand" "=d")
4729 (zero_extend:HI (match_operand:QI 1 "memory_operand" "T")))]
4730 "TARGET_ZARCH && !TARGET_EXTIMM"
4732 [(set_attr "op_type" "RXY")
4733 (set_attr "z10prop" "z10_fwd_A3")])
4735 (define_insn_and_split "*zero_extendqihi2_31"
4736 [(set (match_operand:HI 0 "register_operand" "=&d")
4737 (zero_extend:HI (match_operand:QI 1 "memory_operand" "T")))]
4740 "&& reload_completed"
4741 [(set (match_dup 0) (const_int 0))
4742 (set (strict_low_part (match_dup 2)) (match_dup 1))]
4743 "operands[2] = gen_lowpart (QImode, operands[0]);")
4746 ; fixuns_trunc(dd|td|sf|df|tf)(si|di)2 expander
4749 ; This is the only entry point for fixuns_trunc. It multiplexes the
4750 ; expansion to either the *_emu expanders below for pre z196 machines
4751 ; or emits the default pattern otherwise.
4752 (define_expand "fixuns_trunc<FP:mode><GPR:mode>2"
4754 [(set (match_operand:GPR 0 "register_operand" "")
4755 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "")))
4756 (unspec:GPR [(match_dup 2)] UNSPEC_ROUND)
4757 (clobber (reg:CC CC_REGNUM))])]
4762 /* We don't provide emulation for TD|DD->SI. */
4763 if (GET_MODE_CLASS (<FP:MODE>mode) == MODE_DECIMAL_FLOAT
4764 && <GPR:MODE>mode == SImode)
4766 emit_insn (gen_fixuns_trunc<FP:mode><GPR:mode>2_emu (operands[0],
4771 if (GET_MODE_CLASS (<FP:MODE>mode) == MODE_DECIMAL_FLOAT)
4772 operands[2] = GEN_INT (DFP_RND_TOWARD_0);
4774 operands[2] = GEN_INT (BFP_RND_TOWARD_0);
4777 ; (sf|df|tf)->unsigned (si|di)
4779 ; Emulate the unsigned conversion with the signed version for pre z196
4781 (define_expand "fixuns_trunc<BFP:mode><GPR:mode>2_emu"
4783 [(set (match_operand:GPR 0 "register_operand" "")
4784 (unsigned_fix:GPR (match_operand:BFP 1 "register_operand" "")))
4785 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
4786 (clobber (reg:CC CC_REGNUM))])]
4787 "!TARGET_Z196 && TARGET_HARD_FLOAT"
4789 rtx_code_label *label1 = gen_label_rtx ();
4790 rtx_code_label *label2 = gen_label_rtx ();
4791 rtx temp = gen_reg_rtx (<BFP:MODE>mode);
4792 REAL_VALUE_TYPE cmp, sub;
4794 operands[1] = force_reg (<BFP:MODE>mode, operands[1]);
4795 real_2expN (&cmp, <GPR:bitsize> - 1, <BFP:MODE>mode);
4796 real_2expN (&sub, <GPR:bitsize>, <BFP:MODE>mode);
4798 emit_cmp_and_jump_insns (operands[1],
4799 const_double_from_real_value (cmp, <BFP:MODE>mode),
4800 LT, NULL_RTX, VOIDmode, 0, label1);
4801 emit_insn (gen_sub<BFP:mode>3 (temp, operands[1],
4802 const_double_from_real_value (sub, <BFP:MODE>mode)));
4803 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp,
4804 GEN_INT (BFP_RND_TOWARD_MINF)));
4807 emit_label (label1);
4808 emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0],
4810 GEN_INT (BFP_RND_TOWARD_0)));
4811 emit_label (label2);
4817 ; Emulate the unsigned conversion with the signed version for pre z196
4819 (define_expand "fixuns_truncdddi2_emu"
4821 [(set (match_operand:DI 0 "register_operand" "")
4822 (unsigned_fix:DI (match_operand:DD 1 "register_operand" "")))
4823 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
4824 (clobber (reg:CC CC_REGNUM))])]
4826 "!TARGET_Z196 && TARGET_HARD_DFP"
4828 rtx_code_label *label1 = gen_label_rtx ();
4829 rtx_code_label *label2 = gen_label_rtx ();
4830 rtx temp = gen_reg_rtx (TDmode);
4831 REAL_VALUE_TYPE cmp, sub;
4833 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4834 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4836 /* 2^63 can't be represented as 64bit DFP number with full precision. The
4837 solution is doing the check and the subtraction in TD mode and using a
4838 TD -> DI convert afterwards. */
4839 emit_insn (gen_extendddtd2 (temp, operands[1]));
4840 temp = force_reg (TDmode, temp);
4841 emit_cmp_and_jump_insns (temp,
4842 const_double_from_real_value (cmp, TDmode),
4843 LT, NULL_RTX, VOIDmode, 0, label1);
4844 emit_insn (gen_subtd3 (temp, temp,
4845 const_double_from_real_value (sub, TDmode)));
4846 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp,
4847 GEN_INT (DFP_RND_TOWARD_MINF)));
4850 emit_label (label1);
4851 emit_insn (gen_fix_truncdddi2_dfp (operands[0], operands[1],
4852 GEN_INT (DFP_RND_TOWARD_0)));
4853 emit_label (label2);
4859 ; Emulate the unsigned conversion with the signed version for pre z196
4861 (define_expand "fixuns_trunctddi2_emu"
4863 [(set (match_operand:DI 0 "register_operand" "")
4864 (unsigned_fix:DI (match_operand:TD 1 "register_operand" "")))
4865 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
4866 (clobber (reg:CC CC_REGNUM))])]
4868 "!TARGET_Z196 && TARGET_HARD_DFP"
4870 rtx_code_label *label1 = gen_label_rtx ();
4871 rtx_code_label *label2 = gen_label_rtx ();
4872 rtx temp = gen_reg_rtx (TDmode);
4873 REAL_VALUE_TYPE cmp, sub;
4875 operands[1] = force_reg (TDmode, operands[1]);
4876 decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */
4877 decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */
4879 emit_cmp_and_jump_insns (operands[1],
4880 const_double_from_real_value (cmp, TDmode),
4881 LT, NULL_RTX, VOIDmode, 0, label1);
4882 emit_insn (gen_subtd3 (temp, operands[1],
4883 const_double_from_real_value (sub, TDmode)));
4884 emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp,
4885 GEN_INT (DFP_RND_TOWARD_MINF)));
4888 emit_label (label1);
4889 emit_insn (gen_fix_trunctddi2_dfp (operands[0], operands[1],
4890 GEN_INT (DFP_RND_TOWARD_0)));
4891 emit_label (label2);
4895 ; Just a dummy to make the code in the first expander a bit easier.
4896 (define_expand "fixuns_trunc<mode>si2_emu"
4898 [(set (match_operand:SI 0 "register_operand" "")
4899 (unsigned_fix:SI (match_operand:DFP 1 "register_operand" "")))
4900 (unspec:DI [(const_int DFP_RND_TOWARD_0)] UNSPEC_ROUND)
4901 (clobber (reg:CC CC_REGNUM))])]
4903 "!TARGET_Z196 && TARGET_HARD_DFP"
4909 ; fixuns_trunc(tf|df|sf|td|dd)(di|si)2 instruction patterns.
4912 (define_insn "*fixuns_truncdfdi2_vx"
4913 [(set (match_operand:DI 0 "register_operand" "=d,v")
4914 (unsigned_fix:DI (match_operand:DF 1 "register_operand" "f,v")))
4915 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K,K")] UNSPEC_ROUND)
4916 (clobber (reg:CC CC_REGNUM))]
4917 "TARGET_VX && TARGET_HARD_FLOAT"
4920 wclgdb\t%v0,%v1,0,%h2"
4921 [(set_attr "op_type" "RRF,VRR")
4922 (set_attr "type" "ftoi")])
4924 ; (dd|td|sf|df|tf)->unsigned (di|si)
4925 ; clfebr, clfdbr, clfxbr, clgebr, clgdbr, clgxbr
4926 ; clfdtr, clfxtr, clgdtr, clgxtr
4927 (define_insn "*fixuns_trunc<FP:mode><GPR:mode>2_z196"
4928 [(set (match_operand:GPR 0 "register_operand" "=d")
4929 (unsigned_fix:GPR (match_operand:FP 1 "register_operand" "f")))
4930 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4931 (clobber (reg:CC CC_REGNUM))]
4932 "TARGET_Z196 && TARGET_HARD_FLOAT
4933 && (!TARGET_VX || <GPR:MODE>mode != DImode || <FP:MODE>mode != DFmode)"
4934 "cl<GPR:gf><FP:xde><FP:bt>r\t%0,%h2,%1,0"
4935 [(set_attr "op_type" "RRF")
4936 (set_attr "type" "ftoi")])
4938 (define_expand "fix_trunc<DSF:mode><GPR:mode>2"
4939 [(set (match_operand:GPR 0 "register_operand" "")
4940 (fix:GPR (match_operand:DSF 1 "register_operand" "")))]
4943 emit_insn (gen_fix_trunc<DSF:mode><GPR:mode>2_bfp (operands[0], operands[1],
4944 GEN_INT (BFP_RND_TOWARD_0)));
4948 (define_insn "*fix_truncdfdi2_bfp_z13"
4949 [(set (match_operand:DI 0 "register_operand" "=d,v")
4950 (fix:DI (match_operand:DF 1 "register_operand" "f,v")))
4951 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K,K")] UNSPEC_ROUND)
4952 (clobber (reg:CC CC_REGNUM))]
4953 "TARGET_VX && TARGET_HARD_FLOAT"
4956 wcgdb\t%v0,%v1,0,%h2"
4957 [(set_attr "op_type" "RRE,VRR")
4958 (set_attr "type" "ftoi")])
4960 ; cgxbr, cgdbr, cgebr, cfxbr, cfdbr, cfebr
4961 (define_insn "*fix_trunc<BFP:mode><GPR:mode>2_bfp"
4962 [(set (match_operand:GPR 0 "register_operand" "=d")
4963 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
4964 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4965 (clobber (reg:CC CC_REGNUM))]
4967 && (!TARGET_VX || <GPR:MODE>mode != DImode || <BFP:MODE>mode != DFmode)"
4968 "c<GPR:gf><BFP:xde>br\t%0,%h2,%1"
4969 [(set_attr "op_type" "RRE")
4970 (set_attr "type" "ftoi")])
4972 (define_expand "fix_trunc<BFP:mode><GPR:mode>2_bfp"
4974 [(set (match_operand:GPR 0 "register_operand" "=d")
4975 (fix:GPR (match_operand:BFP 1 "register_operand" "f")))
4976 (unspec:GPR [(match_operand:GPR 2 "immediate_operand" "K")] UNSPEC_ROUND)
4977 (clobber (reg:CC CC_REGNUM))])]
4978 "TARGET_HARD_FLOAT")
4980 ; fix_trunc(td|dd)di2 instruction pattern(s).
4983 (define_expand "fix_trunc<mode>di2"
4984 [(set (match_operand:DI 0 "register_operand" "")
4985 (fix:DI (match_operand:DFP 1 "nonimmediate_operand" "")))]
4986 "TARGET_ZARCH && TARGET_HARD_DFP"
4988 operands[1] = force_reg (<MODE>mode, operands[1]);
4989 emit_insn (gen_fix_trunc<mode>di2_dfp (operands[0], operands[1],
4990 GEN_INT (DFP_RND_TOWARD_0)));
4995 (define_insn "fix_trunc<DFP:mode>di2_dfp"
4996 [(set (match_operand:DI 0 "register_operand" "=d")
4997 (fix:DI (match_operand:DFP 1 "register_operand" "f")))
4998 (unspec:DI [(match_operand:DI 2 "immediate_operand" "K")] UNSPEC_ROUND)
4999 (clobber (reg:CC CC_REGNUM))]
5000 "TARGET_ZARCH && TARGET_HARD_DFP"
5001 "cg<DFP:xde>tr\t%0,%h2,%1"
5002 [(set_attr "op_type" "RRF")
5003 (set_attr "type" "ftoidfp")])
5007 ; fix_trunctf(si|di)2 instruction pattern(s).
5010 (define_expand "fix_trunctf<mode>2"
5011 [(parallel [(set (match_operand:GPR 0 "register_operand" "")
5012 (fix:GPR (match_operand:TF 1 "register_operand" "")))
5013 (unspec:GPR [(const_int BFP_RND_TOWARD_0)] UNSPEC_ROUND)
5014 (clobber (reg:CC CC_REGNUM))])]
5020 ; float(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
5023 ; cxgbr, cdgbr, cegbr, cxgtr, cdgtr
5024 (define_insn "floatdi<mode>2"
5025 [(set (match_operand:FP 0 "register_operand" "=f,v")
5026 (float:FP (match_operand:DI 1 "register_operand" "d,v")))]
5027 "TARGET_ZARCH && TARGET_HARD_FLOAT"
5031 [(set_attr "op_type" "RRE,VRR")
5032 (set_attr "type" "itof<mode>" )
5033 (set_attr "cpu_facility" "*,vx")
5034 (set_attr "enabled" "*,<DFDI>")])
5036 ; cxfbr, cdfbr, cefbr
5037 (define_insn "floatsi<mode>2"
5038 [(set (match_operand:BFP 0 "register_operand" "=f")
5039 (float:BFP (match_operand:SI 1 "register_operand" "d")))]
5042 [(set_attr "op_type" "RRE")
5043 (set_attr "type" "itof<mode>" )])
5046 (define_insn "floatsi<mode>2"
5047 [(set (match_operand:DFP 0 "register_operand" "=f")
5048 (float:DFP (match_operand:SI 1 "register_operand" "d")))]
5049 "TARGET_Z196 && TARGET_HARD_FLOAT"
5050 "c<xde>ftr\t%0,0,%1,0"
5051 [(set_attr "op_type" "RRE")
5052 (set_attr "type" "itof<mode>" )])
5055 ; floatuns(si|di)(tf|df|sf|td|dd)2 instruction pattern(s).
5058 (define_insn "*floatunsdidf2_z13"
5059 [(set (match_operand:DF 0 "register_operand" "=f,v")
5060 (unsigned_float:DF (match_operand:DI 1 "register_operand" "d,v")))]
5061 "TARGET_VX && TARGET_HARD_FLOAT"
5064 wcdlgb\t%v0,%v1,0,0"
5065 [(set_attr "op_type" "RRE,VRR")
5066 (set_attr "type" "itofdf")])
5068 ; cxlgbr, cdlgbr, celgbr, cxlgtr, cdlgtr
5069 ; cxlfbr, cdlfbr, celfbr, cxlftr, cdlftr
5070 (define_insn "*floatuns<GPR:mode><FP:mode>2"
5071 [(set (match_operand:FP 0 "register_operand" "=f")
5072 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "d")))]
5073 "TARGET_Z196 && TARGET_HARD_FLOAT
5074 && (!TARGET_VX || <FP:MODE>mode != DFmode || <GPR:MODE>mode != DImode)"
5075 "c<FP:xde>l<GPR:gf><FP:bt>r\t%0,0,%1,0"
5076 [(set_attr "op_type" "RRE")
5077 (set_attr "type" "itof<FP:mode>")])
5079 (define_expand "floatuns<GPR:mode><FP:mode>2"
5080 [(set (match_operand:FP 0 "register_operand" "")
5081 (unsigned_float:FP (match_operand:GPR 1 "register_operand" "")))]
5082 "TARGET_Z196 && TARGET_HARD_FLOAT")
5085 ; truncdfsf2 instruction pattern(s).
5088 (define_insn "truncdfsf2"
5089 [(set (match_operand:SF 0 "register_operand" "=f,v")
5090 (float_truncate:SF (match_operand:DF 1 "register_operand" "f,v")))]
5094 wledb\t%v0,%v1,0,0" ; IEEE inexact exception not suppressed
5095 ; According to BFP rounding mode
5096 [(set_attr "op_type" "RRE,VRR")
5097 (set_attr "type" "ftruncdf")
5098 (set_attr "cpu_facility" "*,vx")])
5101 ; trunctf(df|sf)2 instruction pattern(s).
5105 (define_insn "trunctf<mode>2"
5106 [(set (match_operand:DSF 0 "register_operand" "=f")
5107 (float_truncate:DSF (match_operand:TF 1 "register_operand" "f")))
5108 (clobber (match_scratch:TF 2 "=f"))]
5110 "l<xde>xbr\t%2,%1\;l<xde>r\t%0,%2"
5111 [(set_attr "length" "6")
5112 (set_attr "type" "ftrunctf")])
5115 ; trunctddd2 and truncddsd2 instruction pattern(s).
5119 (define_expand "trunctddd2"
5121 [(set (match_operand:DD 0 "register_operand" "")
5122 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
5123 (unspec:DI [(const_int DFP_RND_CURRENT)] UNSPEC_ROUND)
5124 (clobber (scratch:TD))])]
5127 (define_insn "*trunctddd2"
5128 [(set (match_operand:DD 0 "register_operand" "=f")
5129 (float_truncate:DD (match_operand:TD 1 "register_operand" "f")))
5130 (unspec:DI [(match_operand:DI 2 "const_mask_operand" "I")] UNSPEC_ROUND)
5131 (clobber (match_scratch:TD 3 "=f"))]
5133 "ldxtr\t%3,%2,%1,0\;ldr\t%0,%3"
5134 [(set_attr "length" "6")
5135 (set_attr "type" "ftruncdd")])
5137 (define_insn "truncddsd2"
5138 [(set (match_operand:SD 0 "register_operand" "=f")
5139 (float_truncate:SD (match_operand:DD 1 "register_operand" "f")))]
5142 [(set_attr "op_type" "RRF")
5143 (set_attr "type" "ftruncsd")])
5145 (define_expand "trunctdsd2"
5148 (float_truncate:DD (match_operand:TD 1 "register_operand" "")))
5149 (unspec:DI [(const_int DFP_RND_PREP_FOR_SHORT_PREC)] UNSPEC_ROUND)
5150 (clobber (match_scratch:TD 3 ""))])
5151 (set (match_operand:SD 0 "register_operand" "")
5152 (float_truncate:SD (match_dup 2)))]
5155 operands[2] = gen_reg_rtx (DDmode);
5159 ; extend(sf|df)(df|tf)2 instruction pattern(s).
5162 (define_insn "*extendsfdf2_z13"
5163 [(set (match_operand:DF 0 "register_operand" "=f,f,v")
5164 (float_extend:DF (match_operand:SF 1 "nonimmediate_operand" "f,R,v")))]
5165 "TARGET_VX && TARGET_HARD_FLOAT"
5170 [(set_attr "op_type" "RRE,RXE,VRR")
5171 (set_attr "type" "fsimpdf, floaddf,fsimpdf")])
5173 ; ldebr, ldeb, lxdbr, lxdb, lxebr, lxeb
5174 (define_insn "*extend<DSF:mode><BFP:mode>2"
5175 [(set (match_operand:BFP 0 "register_operand" "=f,f")
5176 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "f,R")))]
5178 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)
5179 && (!TARGET_VX || <BFP:MODE>mode != DFmode || <DSF:MODE>mode != SFmode)"
5181 l<BFP:xde><DSF:xde>br\t%0,%1
5182 l<BFP:xde><DSF:xde>b\t%0,%1"
5183 [(set_attr "op_type" "RRE,RXE")
5184 (set_attr "type" "fsimp<BFP:mode>, fload<BFP:mode>")])
5186 (define_expand "extend<DSF:mode><BFP:mode>2"
5187 [(set (match_operand:BFP 0 "register_operand" "")
5188 (float_extend:BFP (match_operand:DSF 1 "nonimmediate_operand" "")))]
5190 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DSF:MODE>mode)")
5193 ; extendddtd2 and extendsddd2 instruction pattern(s).
5196 (define_insn "extendddtd2"
5197 [(set (match_operand:TD 0 "register_operand" "=f")
5198 (float_extend:TD (match_operand:DD 1 "register_operand" "f")))]
5201 [(set_attr "op_type" "RRF")
5202 (set_attr "type" "fsimptf")])
5204 (define_insn "extendsddd2"
5205 [(set (match_operand:DD 0 "register_operand" "=f")
5206 (float_extend:DD (match_operand:SD 1 "register_operand" "f")))]
5209 [(set_attr "op_type" "RRF")
5210 (set_attr "type" "fsimptf")])
5212 (define_expand "extendsdtd2"
5214 (float_extend:DD (match_operand:SD 1 "register_operand" "")))
5215 (set (match_operand:TD 0 "register_operand" "")
5216 (float_extend:TD (match_dup 2)))]
5219 operands[2] = gen_reg_rtx (DDmode);
5222 ; Binary Floating Point - load fp integer
5224 ; Expanders for: floor, btrunc, round, ceil, and nearbyint
5225 ; For all of them the inexact exceptions are suppressed.
5227 ; fiebra, fidbra, fixbra
5228 (define_insn "<FPINT:fpint_name><BFP:mode>2"
5229 [(set (match_operand:BFP 0 "register_operand" "=f")
5230 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
5233 "fi<BFP:xde>bra\t%0,<FPINT:fpint_roundingmode>,%1,4"
5234 [(set_attr "op_type" "RRF")
5235 (set_attr "type" "fsimp<BFP:mode>")])
5237 ; rint is supposed to raise an inexact exception so we can use the
5238 ; older instructions.
5240 ; fiebr, fidbr, fixbr
5241 (define_insn "rint<BFP:mode>2"
5242 [(set (match_operand:BFP 0 "register_operand" "=f")
5243 (unspec:BFP [(match_operand:BFP 1 "register_operand" "f")]
5244 UNSPEC_FPINT_RINT))]
5246 "fi<BFP:xde>br\t%0,0,%1"
5247 [(set_attr "op_type" "RRF")
5248 (set_attr "type" "fsimp<BFP:mode>")])
5251 ; Decimal Floating Point - load fp integer
5254 (define_insn "<FPINT:fpint_name><DFP:mode>2"
5255 [(set (match_operand:DFP 0 "register_operand" "=f")
5256 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
5259 "fi<DFP:xde>tr\t%0,<FPINT:fpint_roundingmode>,%1,4"
5260 [(set_attr "op_type" "RRF")
5261 (set_attr "type" "fsimp<DFP:mode>")])
5264 (define_insn "rint<DFP:mode>2"
5265 [(set (match_operand:DFP 0 "register_operand" "=f")
5266 (unspec:DFP [(match_operand:DFP 1 "register_operand" "f")]
5267 UNSPEC_FPINT_RINT))]
5269 "fi<DFP:xde>tr\t%0,0,%1,0"
5270 [(set_attr "op_type" "RRF")
5271 (set_attr "type" "fsimp<DFP:mode>")])
5274 ; Binary <-> Decimal floating point trunc patterns
5277 (define_insn "*trunc<BFP:mode><DFP_ALL:mode>2"
5278 [(set (reg:DFP_ALL FPR0_REGNUM)
5279 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
5280 (use (reg:SI GPR0_REGNUM))
5281 (clobber (reg:CC CC_REGNUM))
5282 (clobber (reg:SI GPR1_REGNUM))]
5286 (define_insn "*trunc<DFP_ALL:mode><BFP:mode>2"
5287 [(set (reg:BFP FPR0_REGNUM)
5288 (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
5289 (use (reg:SI GPR0_REGNUM))
5290 (clobber (reg:CC CC_REGNUM))
5291 (clobber (reg:SI GPR1_REGNUM))]
5295 (define_expand "trunc<BFP:mode><DFP_ALL:mode>2"
5296 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
5297 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5299 [(set (reg:DFP_ALL FPR0_REGNUM)
5300 (float_truncate:DFP_ALL (reg:BFP FPR4_REGNUM)))
5301 (use (reg:SI GPR0_REGNUM))
5302 (clobber (reg:CC CC_REGNUM))
5303 (clobber (reg:SI GPR1_REGNUM))])
5304 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
5305 (reg:DFP_ALL FPR0_REGNUM))]
5307 && GET_MODE_SIZE (<BFP:MODE>mode) > GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
5309 HOST_WIDE_INT flags;
5311 flags = (PFPO_CONVERT |
5312 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
5313 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
5315 operands[2] = GEN_INT (flags);
5318 (define_expand "trunc<DFP_ALL:mode><BFP:mode>2"
5319 [(set (reg:DFP_ALL FPR4_REGNUM)
5320 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
5321 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5323 [(set (reg:BFP FPR0_REGNUM) (float_truncate:BFP (reg:DFP_ALL FPR4_REGNUM)))
5324 (use (reg:SI GPR0_REGNUM))
5325 (clobber (reg:CC CC_REGNUM))
5326 (clobber (reg:SI GPR1_REGNUM))])
5327 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
5329 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) >= GET_MODE_SIZE (<BFP:MODE>mode)"
5331 HOST_WIDE_INT flags;
5333 flags = (PFPO_CONVERT |
5334 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
5335 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
5337 operands[2] = GEN_INT (flags);
5341 ; Binary <-> Decimal floating point extend patterns
5344 (define_insn "*extend<BFP:mode><DFP_ALL:mode>2"
5345 [(set (reg:DFP_ALL FPR0_REGNUM) (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
5346 (use (reg:SI GPR0_REGNUM))
5347 (clobber (reg:CC CC_REGNUM))
5348 (clobber (reg:SI GPR1_REGNUM))]
5352 (define_insn "*extend<DFP_ALL:mode><BFP:mode>2"
5353 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
5354 (use (reg:SI GPR0_REGNUM))
5355 (clobber (reg:CC CC_REGNUM))
5356 (clobber (reg:SI GPR1_REGNUM))]
5360 (define_expand "extend<BFP:mode><DFP_ALL:mode>2"
5361 [(set (reg:BFP FPR4_REGNUM) (match_operand:BFP 1 "nonimmediate_operand" ""))
5362 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5364 [(set (reg:DFP_ALL FPR0_REGNUM)
5365 (float_extend:DFP_ALL (reg:BFP FPR4_REGNUM)))
5366 (use (reg:SI GPR0_REGNUM))
5367 (clobber (reg:CC CC_REGNUM))
5368 (clobber (reg:SI GPR1_REGNUM))])
5369 (set (match_operand:DFP_ALL 0 "nonimmediate_operand" "")
5370 (reg:DFP_ALL FPR0_REGNUM))]
5372 && GET_MODE_SIZE (<BFP:MODE>mode) <= GET_MODE_SIZE (<DFP_ALL:MODE>mode)"
5374 HOST_WIDE_INT flags;
5376 flags = (PFPO_CONVERT |
5377 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP0_TYPE_SHIFT |
5378 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP1_TYPE_SHIFT);
5380 operands[2] = GEN_INT (flags);
5383 (define_expand "extend<DFP_ALL:mode><BFP:mode>2"
5384 [(set (reg:DFP_ALL FPR4_REGNUM)
5385 (match_operand:DFP_ALL 1 "nonimmediate_operand" ""))
5386 (set (reg:SI GPR0_REGNUM) (match_dup 2))
5388 [(set (reg:BFP FPR0_REGNUM) (float_extend:BFP (reg:DFP_ALL FPR4_REGNUM)))
5389 (use (reg:SI GPR0_REGNUM))
5390 (clobber (reg:CC CC_REGNUM))
5391 (clobber (reg:SI GPR1_REGNUM))])
5392 (set (match_operand:BFP 0 "nonimmediate_operand" "") (reg:BFP FPR0_REGNUM))]
5394 && GET_MODE_SIZE (<DFP_ALL:MODE>mode) < GET_MODE_SIZE (<BFP:MODE>mode)"
5396 HOST_WIDE_INT flags;
5398 flags = (PFPO_CONVERT |
5399 PFPO_OP_TYPE_<BFP:MODE> << PFPO_OP0_TYPE_SHIFT |
5400 PFPO_OP_TYPE_<DFP_ALL:MODE> << PFPO_OP1_TYPE_SHIFT);
5402 operands[2] = GEN_INT (flags);
5407 ;; ARITHMETIC OPERATIONS
5409 ; arithmetic operations set the ConditionCode,
5410 ; because of unpredictable Bits in Register for Halfword and Byte
5411 ; the ConditionCode can be set wrong in operations for Halfword and Byte
5414 ;;- Add instructions.
5418 ; addti3 instruction pattern(s).
5421 (define_expand "addti3"
5423 [(set (match_operand:TI 0 "register_operand" "")
5424 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "")
5425 (match_operand:TI 2 "general_operand" "") ) )
5426 (clobber (reg:CC CC_REGNUM))])]
5429 /* For z13 we have vaq which doesn't set CC. */
5432 emit_insn (gen_rtx_SET (operands[0],
5433 gen_rtx_PLUS (TImode,
5434 copy_to_mode_reg (TImode, operands[1]),
5435 copy_to_mode_reg (TImode, operands[2]))));
5440 (define_insn_and_split "*addti3"
5441 [(set (match_operand:TI 0 "register_operand" "=&d")
5442 (plus:TI (match_operand:TI 1 "nonimmediate_operand" "%0")
5443 (match_operand:TI 2 "general_operand" "do") ) )
5444 (clobber (reg:CC CC_REGNUM))]
5447 "&& reload_completed"
5449 [(set (reg:CCL1 CC_REGNUM)
5450 (compare:CCL1 (plus:DI (match_dup 7) (match_dup 8))
5452 (set (match_dup 6) (plus:DI (match_dup 7) (match_dup 8)))])
5454 [(set (match_dup 3) (plus:DI
5455 (plus:DI (ltu:DI (reg:CCL1 CC_REGNUM) (const_int 0))
5456 (match_dup 4)) (match_dup 5)))
5457 (clobber (reg:CC CC_REGNUM))])]
5458 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
5459 operands[4] = operand_subword (operands[1], 0, 0, TImode);
5460 operands[5] = operand_subword (operands[2], 0, 0, TImode);
5461 operands[6] = operand_subword (operands[0], 1, 0, TImode);
5462 operands[7] = operand_subword (operands[1], 1, 0, TImode);
5463 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
5464 [(set_attr "op_type" "*")
5465 (set_attr "cpu_facility" "*")])
5468 ; adddi3 instruction pattern(s).
5471 (define_expand "adddi3"
5473 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5474 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
5475 (match_operand:DI 2 "general_operand" "")))
5476 (clobber (reg:CC CC_REGNUM))])]
5480 (define_insn "*adddi3_sign"
5481 [(set (match_operand:DI 0 "register_operand" "=d,d")
5482 (plus:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
5483 (match_operand:DI 1 "register_operand" "0,0")))
5484 (clobber (reg:CC CC_REGNUM))]
5489 [(set_attr "op_type" "RRE,RXY")
5490 (set_attr "z196prop" "z196_cracked,z196_cracked")])
5492 (define_insn "*adddi3_zero_cc"
5493 [(set (reg CC_REGNUM)
5494 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
5495 (match_operand:DI 1 "register_operand" "0,0"))
5497 (set (match_operand:DI 0 "register_operand" "=d,d")
5498 (plus:DI (zero_extend:DI (match_dup 2)) (match_dup 1)))]
5499 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
5503 [(set_attr "op_type" "RRE,RXY")
5504 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5506 (define_insn "*adddi3_zero_cconly"
5507 [(set (reg CC_REGNUM)
5508 (compare (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
5509 (match_operand:DI 1 "register_operand" "0,0"))
5511 (clobber (match_scratch:DI 0 "=d,d"))]
5512 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
5516 [(set_attr "op_type" "RRE,RXY")
5517 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5519 (define_insn "*adddi3_zero"
5520 [(set (match_operand:DI 0 "register_operand" "=d,d")
5521 (plus:DI (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
5522 (match_operand:DI 1 "register_operand" "0,0")))
5523 (clobber (reg:CC CC_REGNUM))]
5528 [(set_attr "op_type" "RRE,RXY")
5529 (set_attr "z10prop" "z10_super_E1,z10_super_E1")])
5531 (define_insn_and_split "*adddi3_31z"
5532 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
5533 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5534 (match_operand:DI 2 "general_operand" "do") ) )
5535 (clobber (reg:CC CC_REGNUM))]
5536 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
5538 "&& reload_completed"
5540 [(set (reg:CCL1 CC_REGNUM)
5541 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
5543 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
5545 [(set (match_dup 3) (plus:SI
5546 (plus:SI (ltu:SI (reg:CCL1 CC_REGNUM) (const_int 0))
5547 (match_dup 4)) (match_dup 5)))
5548 (clobber (reg:CC CC_REGNUM))])]
5549 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5550 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5551 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5552 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5553 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5554 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
5556 (define_insn_and_split "*adddi3_31"
5557 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
5558 (plus:DI (match_operand:DI 1 "nonimmediate_operand" "%0")
5559 (match_operand:DI 2 "general_operand" "do") ) )
5560 (clobber (reg:CC CC_REGNUM))]
5563 "&& reload_completed"
5565 [(set (match_dup 3) (plus:SI (match_dup 4) (match_dup 5)))
5566 (clobber (reg:CC CC_REGNUM))])
5568 [(set (reg:CCL1 CC_REGNUM)
5569 (compare:CCL1 (plus:SI (match_dup 7) (match_dup 8))
5571 (set (match_dup 6) (plus:SI (match_dup 7) (match_dup 8)))])
5573 (if_then_else (ltu (reg:CCL1 CC_REGNUM) (const_int 0))
5575 (label_ref (match_dup 9))))
5577 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int 1)))
5578 (clobber (reg:CC CC_REGNUM))])
5580 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
5581 operands[4] = operand_subword (operands[1], 0, 0, DImode);
5582 operands[5] = operand_subword (operands[2], 0, 0, DImode);
5583 operands[6] = operand_subword (operands[0], 1, 0, DImode);
5584 operands[7] = operand_subword (operands[1], 1, 0, DImode);
5585 operands[8] = operand_subword (operands[2], 1, 0, DImode);
5586 operands[9] = gen_label_rtx ();")
5589 ; addsi3 instruction pattern(s).
5592 (define_expand "addsi3"
5594 [(set (match_operand:SI 0 "nonimmediate_operand" "")
5595 (plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
5596 (match_operand:SI 2 "general_operand" "")))
5597 (clobber (reg:CC CC_REGNUM))])]
5601 (define_insn "*addsi3_sign"
5602 [(set (match_operand:SI 0 "register_operand" "=d,d")
5603 (plus:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
5604 (match_operand:SI 1 "register_operand" "0,0")))
5605 (clobber (reg:CC CC_REGNUM))]
5610 [(set_attr "op_type" "RX,RXY")
5611 (set_attr "cpu_facility" "*,longdisp")
5612 (set_attr "z196prop" "z196_cracked,z196_cracked")])
5615 ; add(di|si)3 instruction pattern(s).
5618 ; ark, agrk, ar, ahi, ahik, aghik, alfi, slfi, a, ay, agr, aghi, algfi, slgfi, ag, asi, agsi
5619 (define_insn "*add<mode>3"
5620 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d, d, d,d,d,S")
5621 (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,d, 0, 0,0,0,0")
5622 (match_operand:GPR 2 "general_operand" " d,d,K,K,Op,On,R,T,C") ) )
5623 (clobber (reg:CC CC_REGNUM))]
5635 [(set_attr "op_type" "RR<E>,RRF,RI,RIE,RIL,RIL,RX<Y>,RXY,SIY")
5636 (set_attr "cpu_facility" "*,z196,*,z196,extimm,extimm,*,longdisp,z10")
5637 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,z10_super_E1,z10_super_E1,
5638 z10_super_E1,z10_super_E1,z10_super_E1")])
5640 ; alr, alfi, slfi, al, aly, alrk, alhsik, algr, algfi, slgfi, alg, alsi, algsi, algrk, alghsik
5641 (define_insn "*add<mode>3_carry1_cc"
5642 [(set (reg CC_REGNUM)
5643 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5644 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
5646 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,d")
5647 (plus:GPR (match_dup 1) (match_dup 2)))]
5648 "s390_match_ccmode (insn, CCL1mode)"
5654 al<g>hsik\t%0,%1,%h2
5658 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
5659 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
5660 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
5661 z10_super_E1,z10_super_E1,z10_super_E1")])
5663 ; alr, al, aly, algr, alg, alrk, algrk
5664 (define_insn "*add<mode>3_carry1_cconly"
5665 [(set (reg CC_REGNUM)
5666 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5667 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5669 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5670 "s390_match_ccmode (insn, CCL1mode)"
5676 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5677 (set_attr "cpu_facility" "*,z196,*,longdisp")
5678 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
5680 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
5681 (define_insn "*add<mode>3_carry2_cc"
5682 [(set (reg CC_REGNUM)
5683 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5684 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
5686 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,S")
5687 (plus:GPR (match_dup 1) (match_dup 2)))]
5688 "s390_match_ccmode (insn, CCL1mode)"
5694 al<g>hsik\t%0,%1,%h2
5698 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
5699 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
5700 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,*,
5701 z10_super_E1,z10_super_E1,z10_super_E1")])
5703 ; alr, al, aly, algr, alg, alrk, algrk
5704 (define_insn "*add<mode>3_carry2_cconly"
5705 [(set (reg CC_REGNUM)
5706 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5707 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5709 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5710 "s390_match_ccmode (insn, CCL1mode)"
5716 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5717 (set_attr "cpu_facility" "*,z196,*,longdisp")
5718 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
5720 ; alr, alfi, slfi, al, aly, algr, algfi, slgfi, alg, alsi, algsi, alrk, algrk, alhsik, alghsik
5721 (define_insn "*add<mode>3_cc"
5722 [(set (reg CC_REGNUM)
5723 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d, 0, 0,d,0,0,0")
5724 (match_operand:GPR 2 "general_operand" " d,d,Op,On,K,R,T,C"))
5726 (set (match_operand:GPR 0 "nonimmediate_operand" "=d,d, d, d,d,d,d,S")
5727 (plus:GPR (match_dup 1) (match_dup 2)))]
5728 "s390_match_ccmode (insn, CCLmode)"
5734 al<g>hsik\t%0,%1,%h2
5738 [(set_attr "op_type" "RR<E>,RRF,RIL,RIL,RIE,RX<Y>,RXY,SIY")
5739 (set_attr "cpu_facility" "*,z196,extimm,extimm,z196,*,longdisp,z10")
5740 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1,
5741 *,z10_super_E1,z10_super_E1,z10_super_E1")])
5743 ; alr, al, aly, algr, alg, alrk, algrk
5744 (define_insn "*add<mode>3_cconly"
5745 [(set (reg CC_REGNUM)
5746 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5747 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
5749 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5750 "s390_match_ccmode (insn, CCLmode)"
5756 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5757 (set_attr "cpu_facility" "*,z196,*,longdisp")
5758 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
5760 ; alr, al, aly, algr, alg, alrk, algrk
5761 (define_insn "*add<mode>3_cconly2"
5762 [(set (reg CC_REGNUM)
5763 (compare (match_operand:GPR 1 "nonimmediate_operand" "%0,d,0,0")
5764 (neg:GPR (match_operand:GPR 2 "general_operand" "d,d,R,T"))))
5765 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
5766 "s390_match_ccmode(insn, CCLmode)"
5772 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
5773 (set_attr "cpu_facility" "*,z196,*,longdisp")
5774 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
5776 ; ahi, afi, aghi, agfi, asi, agsi
5777 (define_insn "*add<mode>3_imm_cc"
5778 [(set (reg CC_REGNUM)
5779 (compare (plus:GPR (match_operand:GPR 1 "nonimmediate_operand" " 0, d,0, 0")
5780 (match_operand:GPR 2 "const_int_operand" " K, K,Os,C"))
5782 (set (match_operand:GPR 0 "nonimmediate_operand" "=d, d,d, S")
5783 (plus:GPR (match_dup 1) (match_dup 2)))]
5784 "s390_match_ccmode (insn, CCAmode)
5785 && (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'K', \"K\")
5786 || (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'O', \"Os\")
5787 /* Avoid INT32_MIN on 32 bit. */
5788 && (!TARGET_ZARCH || INTVAL (operands[2]) != -0x7fffffff - 1)))"
5794 [(set_attr "op_type" "RI,RIE,RIL,SIY")
5795 (set_attr "cpu_facility" "*,z196,extimm,z10")
5796 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
5799 ; add(tf|df|sf|td|dd)3 instruction pattern(s).
5802 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
5803 ; FIXME: wfadb does not clobber cc
5804 (define_insn "add<mode>3"
5805 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
5806 (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0,v")
5807 (match_operand:FP 2 "general_operand" "f,f,R,v")))
5808 (clobber (reg:CC CC_REGNUM))]
5815 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
5816 (set_attr "type" "fsimp<mode>")
5817 (set_attr "cpu_facility" "*,*,*,vx")
5818 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
5820 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
5821 (define_insn "*add<mode>3_cc"
5822 [(set (reg CC_REGNUM)
5823 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0")
5824 (match_operand:FP 2 "general_operand" "f,f,R"))
5825 (match_operand:FP 3 "const0_operand" "")))
5826 (set (match_operand:FP 0 "register_operand" "=f,f,f")
5827 (plus:FP (match_dup 1) (match_dup 2)))]
5828 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
5833 [(set_attr "op_type" "RRF,RRE,RXE")
5834 (set_attr "type" "fsimp<mode>")
5835 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
5837 ; axbr, adbr, aebr, axb, adb, aeb, adtr, axtr
5838 (define_insn "*add<mode>3_cconly"
5839 [(set (reg CC_REGNUM)
5840 (compare (plus:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0")
5841 (match_operand:FP 2 "general_operand" "f,f,R"))
5842 (match_operand:FP 3 "const0_operand" "")))
5843 (clobber (match_scratch:FP 0 "=f,f,f"))]
5844 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
5849 [(set_attr "op_type" "RRF,RRE,RXE")
5850 (set_attr "type" "fsimp<mode>")
5851 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
5854 ; Pointer add instruction patterns
5857 ; This will match "*la_64"
5858 (define_expand "addptrdi3"
5859 [(set (match_operand:DI 0 "register_operand" "")
5860 (plus:DI (match_operand:DI 1 "register_operand" "")
5861 (match_operand:DI 2 "nonmemory_operand" "")))]
5864 if (GET_CODE (operands[2]) == CONST_INT)
5866 HOST_WIDE_INT c = INTVAL (operands[2]);
5868 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
5869 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
5871 operands[2] = force_const_mem (DImode, operands[2]);
5872 operands[2] = force_reg (DImode, operands[2]);
5874 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
5875 operands[2] = force_reg (DImode, operands[2]);
5879 ; For 31 bit we have to prevent the generated pattern from matching
5880 ; normal ADDs since la only does a 31 bit add. This is supposed to
5881 ; match "force_la_31".
5882 (define_expand "addptrsi3"
5884 [(set (match_operand:SI 0 "register_operand" "")
5885 (plus:SI (match_operand:SI 1 "register_operand" "")
5886 (match_operand:SI 2 "nonmemory_operand" "")))
5887 (use (const_int 0))])]
5890 if (GET_CODE (operands[2]) == CONST_INT)
5892 HOST_WIDE_INT c = INTVAL (operands[2]);
5894 if (!CONST_OK_FOR_CONSTRAINT_P (c, 'K', "K")
5895 && !CONST_OK_FOR_CONSTRAINT_P (c, 'O', "Os"))
5897 operands[2] = force_const_mem (SImode, operands[2]);
5898 operands[2] = force_reg (SImode, operands[2]);
5900 else if (!DISP_IN_RANGE (INTVAL (operands[2])))
5901 operands[2] = force_reg (SImode, operands[2]);
5906 ;;- Subtract instructions.
5910 ; subti3 instruction pattern(s).
5913 (define_expand "subti3"
5915 [(set (match_operand:TI 0 "register_operand" "")
5916 (minus:TI (match_operand:TI 1 "register_operand" "")
5917 (match_operand:TI 2 "general_operand" "") ) )
5918 (clobber (reg:CC CC_REGNUM))])]
5921 /* For z13 we have vsq which doesn't set CC. */
5924 emit_insn (gen_rtx_SET (operands[0],
5925 gen_rtx_MINUS (TImode,
5927 copy_to_mode_reg (TImode, operands[2]))));
5932 (define_insn_and_split "*subti3"
5933 [(set (match_operand:TI 0 "register_operand" "=&d")
5934 (minus:TI (match_operand:TI 1 "register_operand" "0")
5935 (match_operand:TI 2 "general_operand" "do") ) )
5936 (clobber (reg:CC CC_REGNUM))]
5939 "&& reload_completed"
5941 [(set (reg:CCL2 CC_REGNUM)
5942 (compare:CCL2 (minus:DI (match_dup 7) (match_dup 8))
5944 (set (match_dup 6) (minus:DI (match_dup 7) (match_dup 8)))])
5946 [(set (match_dup 3) (minus:DI (minus:DI (match_dup 4) (match_dup 5))
5947 (gtu:DI (reg:CCL2 CC_REGNUM) (const_int 0))))
5948 (clobber (reg:CC CC_REGNUM))])]
5949 "operands[3] = operand_subword (operands[0], 0, 0, TImode);
5950 operands[4] = operand_subword (operands[1], 0, 0, TImode);
5951 operands[5] = operand_subword (operands[2], 0, 0, TImode);
5952 operands[6] = operand_subword (operands[0], 1, 0, TImode);
5953 operands[7] = operand_subword (operands[1], 1, 0, TImode);
5954 operands[8] = operand_subword (operands[2], 1, 0, TImode);"
5955 [(set_attr "op_type" "*")
5956 (set_attr "cpu_facility" "*")])
5959 ; subdi3 instruction pattern(s).
5962 (define_expand "subdi3"
5964 [(set (match_operand:DI 0 "register_operand" "")
5965 (minus:DI (match_operand:DI 1 "register_operand" "")
5966 (match_operand:DI 2 "general_operand" "")))
5967 (clobber (reg:CC CC_REGNUM))])]
5971 (define_insn "*subdi3_sign"
5972 [(set (match_operand:DI 0 "register_operand" "=d,d")
5973 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
5974 (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))))
5975 (clobber (reg:CC CC_REGNUM))]
5980 [(set_attr "op_type" "RRE,RXY")
5981 (set_attr "z10prop" "z10_c,*")
5982 (set_attr "z196prop" "z196_cracked")])
5984 (define_insn "*subdi3_zero_cc"
5985 [(set (reg CC_REGNUM)
5986 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
5987 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T")))
5989 (set (match_operand:DI 0 "register_operand" "=d,d")
5990 (minus:DI (match_dup 1) (zero_extend:DI (match_dup 2))))]
5991 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
5995 [(set_attr "op_type" "RRE,RXY")
5996 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
5998 (define_insn "*subdi3_zero_cconly"
5999 [(set (reg CC_REGNUM)
6000 (compare (minus:DI (match_operand:DI 1 "register_operand" "0,0")
6001 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T")))
6003 (clobber (match_scratch:DI 0 "=d,d"))]
6004 "s390_match_ccmode (insn, CCLmode) && TARGET_ZARCH"
6008 [(set_attr "op_type" "RRE,RXY")
6009 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
6011 (define_insn "*subdi3_zero"
6012 [(set (match_operand:DI 0 "register_operand" "=d,d")
6013 (minus:DI (match_operand:DI 1 "register_operand" "0,0")
6014 (zero_extend:DI (match_operand:SI 2 "general_operand" "d,T"))))
6015 (clobber (reg:CC CC_REGNUM))]
6020 [(set_attr "op_type" "RRE,RXY")
6021 (set_attr "z10prop" "z10_super_c_E1,z10_super_E1")])
6023 (define_insn_and_split "*subdi3_31z"
6024 [(set (match_operand:DI 0 "register_operand" "=&d")
6025 (minus:DI (match_operand:DI 1 "register_operand" "0")
6026 (match_operand:DI 2 "general_operand" "do") ) )
6027 (clobber (reg:CC CC_REGNUM))]
6028 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
6030 "&& reload_completed"
6032 [(set (reg:CCL2 CC_REGNUM)
6033 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
6035 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
6037 [(set (match_dup 3) (minus:SI (minus:SI (match_dup 4) (match_dup 5))
6038 (gtu:SI (reg:CCL2 CC_REGNUM) (const_int 0))))
6039 (clobber (reg:CC CC_REGNUM))])]
6040 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
6041 operands[4] = operand_subword (operands[1], 0, 0, DImode);
6042 operands[5] = operand_subword (operands[2], 0, 0, DImode);
6043 operands[6] = operand_subword (operands[0], 1, 0, DImode);
6044 operands[7] = operand_subword (operands[1], 1, 0, DImode);
6045 operands[8] = operand_subword (operands[2], 1, 0, DImode);")
6047 (define_insn_and_split "*subdi3_31"
6048 [(set (match_operand:DI 0 "register_operand" "=&d")
6049 (minus:DI (match_operand:DI 1 "register_operand" "0")
6050 (match_operand:DI 2 "general_operand" "do") ) )
6051 (clobber (reg:CC CC_REGNUM))]
6054 "&& reload_completed"
6056 [(set (match_dup 3) (minus:SI (match_dup 4) (match_dup 5)))
6057 (clobber (reg:CC CC_REGNUM))])
6059 [(set (reg:CCL2 CC_REGNUM)
6060 (compare:CCL2 (minus:SI (match_dup 7) (match_dup 8))
6062 (set (match_dup 6) (minus:SI (match_dup 7) (match_dup 8)))])
6064 (if_then_else (gtu (reg:CCL2 CC_REGNUM) (const_int 0))
6066 (label_ref (match_dup 9))))
6068 [(set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))
6069 (clobber (reg:CC CC_REGNUM))])
6071 "operands[3] = operand_subword (operands[0], 0, 0, DImode);
6072 operands[4] = operand_subword (operands[1], 0, 0, DImode);
6073 operands[5] = operand_subword (operands[2], 0, 0, DImode);
6074 operands[6] = operand_subword (operands[0], 1, 0, DImode);
6075 operands[7] = operand_subword (operands[1], 1, 0, DImode);
6076 operands[8] = operand_subword (operands[2], 1, 0, DImode);
6077 operands[9] = gen_label_rtx ();")
6080 ; subsi3 instruction pattern(s).
6083 (define_expand "subsi3"
6085 [(set (match_operand:SI 0 "register_operand" "")
6086 (minus:SI (match_operand:SI 1 "register_operand" "")
6087 (match_operand:SI 2 "general_operand" "")))
6088 (clobber (reg:CC CC_REGNUM))])]
6092 (define_insn "*subsi3_sign"
6093 [(set (match_operand:SI 0 "register_operand" "=d,d")
6094 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
6095 (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))))
6096 (clobber (reg:CC CC_REGNUM))]
6101 [(set_attr "op_type" "RX,RXY")
6102 (set_attr "cpu_facility" "*,longdisp")
6103 (set_attr "z196prop" "z196_cracked,z196_cracked")])
6106 ; sub(di|si)3 instruction pattern(s).
6109 ; sr, s, sy, sgr, sg, srk, sgrk
6110 (define_insn "*sub<mode>3"
6111 [(set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6112 (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6113 (match_operand:GPR 2 "general_operand" "d,d,R,T") ) )
6114 (clobber (reg:CC CC_REGNUM))]
6121 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6122 (set_attr "cpu_facility" "*,z196,*,longdisp")
6123 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6125 ; slr, sl, sly, slgr, slg, slrk, slgrk
6126 (define_insn "*sub<mode>3_borrow_cc"
6127 [(set (reg CC_REGNUM)
6128 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6129 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6131 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6132 (minus:GPR (match_dup 1) (match_dup 2)))]
6133 "s390_match_ccmode (insn, CCL2mode)"
6139 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6140 (set_attr "cpu_facility" "*,z196,*,longdisp")
6141 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6143 ; slr, sl, sly, slgr, slg, slrk, slgrk
6144 (define_insn "*sub<mode>3_borrow_cconly"
6145 [(set (reg CC_REGNUM)
6146 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6147 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6149 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6150 "s390_match_ccmode (insn, CCL2mode)"
6156 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6157 (set_attr "cpu_facility" "*,z196,*,longdisp")
6158 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6160 ; slr, sl, sly, slgr, slg, slrk, slgrk
6161 (define_insn "*sub<mode>3_cc"
6162 [(set (reg CC_REGNUM)
6163 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6164 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6166 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6167 (minus:GPR (match_dup 1) (match_dup 2)))]
6168 "s390_match_ccmode (insn, CCLmode)"
6174 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6175 (set_attr "cpu_facility" "*,z196,*,longdisp")
6176 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6178 ; slr, sl, sly, slgr, slg, slrk, slgrk
6179 (define_insn "*sub<mode>3_cc2"
6180 [(set (reg CC_REGNUM)
6181 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
6182 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
6183 (set (match_operand:GPR 0 "register_operand" "=d,d,d,d")
6184 (minus:GPR (match_dup 1) (match_dup 2)))]
6185 "s390_match_ccmode (insn, CCL3mode)"
6191 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6192 (set_attr "cpu_facility" "*,z196,*,longdisp")
6193 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6195 ; slr, sl, sly, slgr, slg, slrk, slgrk
6196 (define_insn "*sub<mode>3_cconly"
6197 [(set (reg CC_REGNUM)
6198 (compare (minus:GPR (match_operand:GPR 1 "register_operand" "0,d,0,0")
6199 (match_operand:GPR 2 "general_operand" "d,d,R,T"))
6201 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6202 "s390_match_ccmode (insn, CCLmode)"
6208 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6209 (set_attr "cpu_facility" "*,z196,*,longdisp")
6210 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6213 ; slr, sl, sly, slgr, slg, slrk, slgrk
6214 (define_insn "*sub<mode>3_cconly2"
6215 [(set (reg CC_REGNUM)
6216 (compare (match_operand:GPR 1 "register_operand" "0,d,0,0")
6217 (match_operand:GPR 2 "general_operand" "d,d,R,T")))
6218 (clobber (match_scratch:GPR 0 "=d,d,d,d"))]
6219 "s390_match_ccmode (insn, CCL3mode)"
6225 [(set_attr "op_type" "RR<E>,RRF,RX<Y>,RXY")
6226 (set_attr "cpu_facility" "*,z196,*,longdisp")
6227 (set_attr "z10prop" "z10_super_c_E1,*,z10_super_E1,z10_super_E1")])
6231 ; sub(tf|df|sf|td|dd)3 instruction pattern(s).
6234 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
6235 (define_insn "sub<mode>3"
6236 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
6237 (minus:FP (match_operand:FP 1 "register_operand" "f,0,0,v")
6238 (match_operand:FP 2 "general_operand" "f,f,R,v")))
6239 (clobber (reg:CC CC_REGNUM))]
6246 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6247 (set_attr "type" "fsimp<mode>")
6248 (set_attr "cpu_facility" "*,*,*,vx")
6249 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
6251 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
6252 (define_insn "*sub<mode>3_cc"
6253 [(set (reg CC_REGNUM)
6254 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "f,0,0")
6255 (match_operand:FP 2 "general_operand" "f,f,R"))
6256 (match_operand:FP 3 "const0_operand" "")))
6257 (set (match_operand:FP 0 "register_operand" "=f,f,f")
6258 (minus:FP (match_dup 1) (match_dup 2)))]
6259 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6264 [(set_attr "op_type" "RRF,RRE,RXE")
6265 (set_attr "type" "fsimp<mode>")
6266 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
6268 ; sxbr, sdbr, sebr, sdb, seb, sxtr, sdtr
6269 (define_insn "*sub<mode>3_cconly"
6270 [(set (reg CC_REGNUM)
6271 (compare (minus:FP (match_operand:FP 1 "nonimmediate_operand" "f,0,0")
6272 (match_operand:FP 2 "general_operand" "f,f,R"))
6273 (match_operand:FP 3 "const0_operand" "")))
6274 (clobber (match_scratch:FP 0 "=f,f,f"))]
6275 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
6280 [(set_attr "op_type" "RRF,RRE,RXE")
6281 (set_attr "type" "fsimp<mode>")
6282 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>")])
6286 ;;- Conditional add/subtract instructions.
6290 ; add(di|si)cc instruction pattern(s).
6293 ; the following 4 patterns are used when the result of an add with
6294 ; carry is checked for an overflow condition
6296 ; op1 + op2 + c < op1
6298 ; alcr, alc, alcgr, alcg
6299 (define_insn "*add<mode>3_alc_carry1_cc"
6300 [(set (reg CC_REGNUM)
6302 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6303 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
6304 (match_operand:GPR 2 "general_operand" "d,T"))
6306 (set (match_operand:GPR 0 "register_operand" "=d,d")
6307 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
6308 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6312 [(set_attr "op_type" "RRE,RXY")
6313 (set_attr "z196prop" "z196_alone,z196_alone")])
6315 ; alcr, alc, alcgr, alcg
6316 (define_insn "*add<mode>3_alc_carry1_cconly"
6317 [(set (reg CC_REGNUM)
6319 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6320 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
6321 (match_operand:GPR 2 "general_operand" "d,T"))
6323 (clobber (match_scratch:GPR 0 "=d,d"))]
6324 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6328 [(set_attr "op_type" "RRE,RXY")
6329 (set_attr "z196prop" "z196_alone,z196_alone")])
6331 ; op1 + op2 + c < op2
6333 ; alcr, alc, alcgr, alcg
6334 (define_insn "*add<mode>3_alc_carry2_cc"
6335 [(set (reg CC_REGNUM)
6337 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6338 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
6339 (match_operand:GPR 2 "general_operand" "d,T"))
6341 (set (match_operand:GPR 0 "register_operand" "=d,d")
6342 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
6343 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6347 [(set_attr "op_type" "RRE,RXY")])
6349 ; alcr, alc, alcgr, alcg
6350 (define_insn "*add<mode>3_alc_carry2_cconly"
6351 [(set (reg CC_REGNUM)
6353 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6354 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
6355 (match_operand:GPR 2 "general_operand" "d,T"))
6357 (clobber (match_scratch:GPR 0 "=d,d"))]
6358 "s390_match_ccmode (insn, CCL1mode) && TARGET_CPU_ZARCH"
6362 [(set_attr "op_type" "RRE,RXY")])
6364 ; alcr, alc, alcgr, alcg
6365 (define_insn "*add<mode>3_alc_cc"
6366 [(set (reg CC_REGNUM)
6368 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6369 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
6370 (match_operand:GPR 2 "general_operand" "d,T"))
6372 (set (match_operand:GPR 0 "register_operand" "=d,d")
6373 (plus:GPR (plus:GPR (match_dup 3) (match_dup 1)) (match_dup 2)))]
6374 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
6378 [(set_attr "op_type" "RRE,RXY")])
6380 ; alcr, alc, alcgr, alcg
6381 (define_insn "*add<mode>3_alc"
6382 [(set (match_operand:GPR 0 "register_operand" "=d,d")
6383 (plus:GPR (plus:GPR (match_operand:GPR 3 "s390_alc_comparison" "")
6384 (match_operand:GPR 1 "nonimmediate_operand" "%0,0"))
6385 (match_operand:GPR 2 "general_operand" "d,T")))
6386 (clobber (reg:CC CC_REGNUM))]
6391 [(set_attr "op_type" "RRE,RXY")])
6393 ; slbr, slb, slbgr, slbg
6394 (define_insn "*sub<mode>3_slb_cc"
6395 [(set (reg CC_REGNUM)
6397 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
6398 (match_operand:GPR 2 "general_operand" "d,T"))
6399 (match_operand:GPR 3 "s390_slb_comparison" ""))
6401 (set (match_operand:GPR 0 "register_operand" "=d,d")
6402 (minus:GPR (minus:GPR (match_dup 1) (match_dup 2)) (match_dup 3)))]
6403 "s390_match_ccmode (insn, CCLmode) && TARGET_CPU_ZARCH"
6407 [(set_attr "op_type" "RRE,RXY")
6408 (set_attr "z10prop" "z10_c,*")])
6410 ; slbr, slb, slbgr, slbg
6411 (define_insn "*sub<mode>3_slb"
6412 [(set (match_operand:GPR 0 "register_operand" "=d,d")
6413 (minus:GPR (minus:GPR (match_operand:GPR 1 "nonimmediate_operand" "0,0")
6414 (match_operand:GPR 2 "general_operand" "d,T"))
6415 (match_operand:GPR 3 "s390_slb_comparison" "")))
6416 (clobber (reg:CC CC_REGNUM))]
6421 [(set_attr "op_type" "RRE,RXY")
6422 (set_attr "z10prop" "z10_c,*")])
6424 (define_expand "add<mode>cc"
6425 [(match_operand:GPR 0 "register_operand" "")
6426 (match_operand 1 "comparison_operator" "")
6427 (match_operand:GPR 2 "register_operand" "")
6428 (match_operand:GPR 3 "const_int_operand" "")]
6430 "if (!s390_expand_addcc (GET_CODE (operands[1]),
6431 XEXP (operands[1], 0), XEXP (operands[1], 1),
6432 operands[0], operands[2],
6433 operands[3])) FAIL; DONE;")
6436 ; scond instruction pattern(s).
6439 (define_insn_and_split "*scond<mode>"
6440 [(set (match_operand:GPR 0 "register_operand" "=&d")
6441 (match_operand:GPR 1 "s390_alc_comparison" ""))
6442 (clobber (reg:CC CC_REGNUM))]
6445 "&& reload_completed"
6446 [(set (match_dup 0) (const_int 0))
6448 [(set (match_dup 0) (plus:GPR (plus:GPR (match_dup 1) (match_dup 0))
6450 (clobber (reg:CC CC_REGNUM))])]
6453 (define_insn_and_split "*scond<mode>_neg"
6454 [(set (match_operand:GPR 0 "register_operand" "=&d")
6455 (match_operand:GPR 1 "s390_slb_comparison" ""))
6456 (clobber (reg:CC CC_REGNUM))]
6459 "&& reload_completed"
6460 [(set (match_dup 0) (const_int 0))
6462 [(set (match_dup 0) (minus:GPR (minus:GPR (match_dup 0) (match_dup 0))
6464 (clobber (reg:CC CC_REGNUM))])
6466 [(set (match_dup 0) (neg:GPR (match_dup 0)))
6467 (clobber (reg:CC CC_REGNUM))])]
6471 (define_expand "cstore<mode>4"
6472 [(set (match_operand:SI 0 "register_operand" "")
6473 (match_operator:SI 1 "s390_scond_operator"
6474 [(match_operand:GPR 2 "register_operand" "")
6475 (match_operand:GPR 3 "general_operand" "")]))]
6477 "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3],
6478 operands[0], const0_rtx, const1_rtx)) FAIL; DONE;")
6480 (define_expand "cstorecc4"
6482 [(set (match_operand:SI 0 "register_operand" "")
6483 (match_operator:SI 1 "s390_eqne_operator"
6484 [(match_operand:CCZ1 2 "register_operand")
6485 (match_operand 3 "const0_operand")]))
6486 (clobber (reg:CC CC_REGNUM))])]
6488 "emit_insn (gen_sne (operands[0], operands[2]));
6489 if (GET_CODE (operands[1]) == EQ)
6490 emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx));
6493 (define_insn_and_split "sne"
6494 [(set (match_operand:SI 0 "register_operand" "=d")
6495 (ne:SI (match_operand:CCZ1 1 "register_operand" "0")
6497 (clobber (reg:CC CC_REGNUM))]
6502 [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28)))
6503 (clobber (reg:CC CC_REGNUM))])])
6507 ;; - Conditional move instructions (introduced with z196)
6510 (define_expand "mov<mode>cc"
6511 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
6512 (if_then_else:GPR (match_operand 1 "comparison_operator" "")
6513 (match_operand:GPR 2 "nonimmediate_operand" "")
6514 (match_operand:GPR 3 "nonimmediate_operand" "")))]
6517 /* Emit the comparison insn in case we do not already have a comparison result. */
6518 if (!s390_comparison (operands[1], VOIDmode))
6519 operands[1] = s390_emit_compare (GET_CODE (operands[1]),
6520 XEXP (operands[1], 0),
6521 XEXP (operands[1], 1));
6524 ; locr, loc, stoc, locgr, locg, stocg, lochi, locghi
6525 (define_insn_and_split "*mov<mode>cc"
6526 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,S,S,&d")
6528 (match_operator 1 "s390_comparison"
6529 [(match_operand 2 "cc_reg_operand" " c,c,c,c,c,c,c,c,c")
6530 (match_operand 5 "const_int_operand" "")])
6531 (match_operand:GPR 3 "loc_operand" " d,0,S,0,K,0,d,0,S")
6532 (match_operand:GPR 4 "loc_operand" " 0,d,0,S,0,K,0,d,S")))]
6544 "&& reload_completed
6545 && MEM_P (operands[3]) && MEM_P (operands[4])"
6548 (match_op_dup 1 [(match_dup 2) (const_int 0)])
6553 (match_op_dup 1 [(match_dup 2) (const_int 0)])
6557 [(set_attr "op_type" "RRF,RRF,RSY,RSY,RIE,RIE,RSY,RSY,*")
6558 (set_attr "cpu_facility" "*,*,*,*,z13,z13,*,*,*")])
6561 ;;- Multiply instructions.
6565 ; muldi3 instruction pattern(s).
6568 (define_insn "*muldi3_sign"
6569 [(set (match_operand:DI 0 "register_operand" "=d,d")
6570 (mult:DI (sign_extend:DI (match_operand:SI 2 "general_operand" "d,T"))
6571 (match_operand:DI 1 "register_operand" "0,0")))]
6576 [(set_attr "op_type" "RRE,RXY")
6577 (set_attr "type" "imuldi")])
6579 (define_insn "muldi3"
6580 [(set (match_operand:DI 0 "register_operand" "=d,d,d,d")
6581 (mult:DI (match_operand:DI 1 "nonimmediate_operand" "%0,0,0,0")
6582 (match_operand:DI 2 "general_operand" "d,K,T,Os")))]
6589 [(set_attr "op_type" "RRE,RI,RXY,RIL")
6590 (set_attr "type" "imuldi")
6591 (set_attr "cpu_facility" "*,*,*,z10")])
6594 ; mulsi3 instruction pattern(s).
6597 (define_insn "*mulsi3_sign"
6598 [(set (match_operand:SI 0 "register_operand" "=d,d")
6599 (mult:SI (sign_extend:SI (match_operand:HI 2 "memory_operand" "R,T"))
6600 (match_operand:SI 1 "register_operand" "0,0")))]
6605 [(set_attr "op_type" "RX,RXY")
6606 (set_attr "type" "imulhi")
6607 (set_attr "cpu_facility" "*,z10")])
6609 (define_insn "mulsi3"
6610 [(set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
6611 (mult:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0")
6612 (match_operand:SI 2 "general_operand" "d,K,R,T,Os")))]
6620 [(set_attr "op_type" "RRE,RI,RX,RXY,RIL")
6621 (set_attr "type" "imulsi,imulhi,imulsi,imulsi,imulsi")
6622 (set_attr "cpu_facility" "*,*,*,longdisp,z10")])
6625 ; mulsidi3 instruction pattern(s).
6628 (define_insn "mulsidi3"
6629 [(set (match_operand:DI 0 "register_operand" "=d,d,d")
6630 (mult:DI (sign_extend:DI
6631 (match_operand:SI 1 "register_operand" "%0,0,0"))
6633 (match_operand:SI 2 "nonimmediate_operand" "d,R,T"))))]
6639 [(set_attr "op_type" "RR,RX,RXY")
6640 (set_attr "type" "imulsi")
6641 (set_attr "cpu_facility" "*,*,z10")])
6644 ; umul instruction pattern(s).
6647 ; mlr, ml, mlgr, mlg
6648 (define_insn "umul<dwh><mode>3"
6649 [(set (match_operand:DW 0 "register_operand" "=d,d")
6650 (mult:DW (zero_extend:DW
6651 (match_operand:<DWH> 1 "register_operand" "%0,0"))
6653 (match_operand:<DWH> 2 "nonimmediate_operand" " d,T"))))]
6658 [(set_attr "op_type" "RRE,RXY")
6659 (set_attr "type" "imul<dwh>")])
6662 ; mul(tf|df|sf|td|dd)3 instruction pattern(s).
6665 ; mxbr, mdbr, meebr, mxb, mxb, meeb, mdtr, mxtr
6666 (define_insn "mul<mode>3"
6667 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
6668 (mult:FP (match_operand:FP 1 "nonimmediate_operand" "%f,0,0,v")
6669 (match_operand:FP 2 "general_operand" "f,f,R,v")))]
6676 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
6677 (set_attr "type" "fmul<mode>")
6678 (set_attr "cpu_facility" "*,*,*,vx")
6679 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
6681 ; madbr, maebr, maxb, madb, maeb
6682 (define_insn "fma<mode>4"
6683 [(set (match_operand:DSF 0 "register_operand" "=f,f,v")
6684 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f,v")
6685 (match_operand:DSF 2 "nonimmediate_operand" "f,R,v")
6686 (match_operand:DSF 3 "register_operand" "0,0,v")))]
6691 wfmadb\t%v0,%v1,%v2,%v3"
6692 [(set_attr "op_type" "RRE,RXE,VRR")
6693 (set_attr "type" "fmadd<mode>")
6694 (set_attr "cpu_facility" "*,*,vx")
6695 (set_attr "enabled" "*,*,<DFDI>")])
6697 ; msxbr, msdbr, msebr, msxb, msdb, mseb
6698 (define_insn "fms<mode>4"
6699 [(set (match_operand:DSF 0 "register_operand" "=f,f,v")
6700 (fma:DSF (match_operand:DSF 1 "nonimmediate_operand" "%f,f,v")
6701 (match_operand:DSF 2 "nonimmediate_operand" "f,R,v")
6702 (neg:DSF (match_operand:DSF 3 "register_operand" "0,0,v"))))]
6707 wfmsdb\t%v0,%v1,%v2,%v3"
6708 [(set_attr "op_type" "RRE,RXE,VRR")
6709 (set_attr "type" "fmadd<mode>")
6710 (set_attr "cpu_facility" "*,*,vx")
6711 (set_attr "enabled" "*,*,<DFDI>")])
6714 ;;- Divide and modulo instructions.
6718 ; divmoddi4 instruction pattern(s).
6721 (define_expand "divmoddi4"
6722 [(parallel [(set (match_operand:DI 0 "general_operand" "")
6723 (div:DI (match_operand:DI 1 "register_operand" "")
6724 (match_operand:DI 2 "general_operand" "")))
6725 (set (match_operand:DI 3 "general_operand" "")
6726 (mod:DI (match_dup 1) (match_dup 2)))])
6727 (clobber (match_dup 4))]
6730 rtx div_equal, mod_equal;
6733 div_equal = gen_rtx_DIV (DImode, operands[1], operands[2]);
6734 mod_equal = gen_rtx_MOD (DImode, operands[1], operands[2]);
6736 operands[4] = gen_reg_rtx(TImode);
6737 emit_insn (gen_divmodtidi3 (operands[4], operands[1], operands[2]));
6739 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
6740 set_unique_reg_note (insn, REG_EQUAL, div_equal);
6742 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
6743 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
6748 (define_insn "divmodtidi3"
6749 [(set (match_operand:TI 0 "register_operand" "=d,d")
6753 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
6754 (match_operand:DI 2 "general_operand" "d,T")))
6756 (zero_extend:TI (div:DI (match_dup 1) (match_dup 2)))))]
6761 [(set_attr "op_type" "RRE,RXY")
6762 (set_attr "type" "idiv")])
6764 (define_insn "divmodtisi3"
6765 [(set (match_operand:TI 0 "register_operand" "=d,d")
6769 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
6771 (match_operand:SI 2 "nonimmediate_operand" "d,T"))))
6774 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2))))))]
6779 [(set_attr "op_type" "RRE,RXY")
6780 (set_attr "type" "idiv")])
6783 ; udivmoddi4 instruction pattern(s).
6786 (define_expand "udivmoddi4"
6787 [(parallel [(set (match_operand:DI 0 "general_operand" "")
6788 (udiv:DI (match_operand:DI 1 "general_operand" "")
6789 (match_operand:DI 2 "nonimmediate_operand" "")))
6790 (set (match_operand:DI 3 "general_operand" "")
6791 (umod:DI (match_dup 1) (match_dup 2)))])
6792 (clobber (match_dup 4))]
6795 rtx div_equal, mod_equal, equal;
6798 div_equal = gen_rtx_UDIV (DImode, operands[1], operands[2]);
6799 mod_equal = gen_rtx_UMOD (DImode, operands[1], operands[2]);
6800 equal = gen_rtx_IOR (TImode,
6801 gen_rtx_ASHIFT (TImode,
6802 gen_rtx_ZERO_EXTEND (TImode, mod_equal),
6804 gen_rtx_ZERO_EXTEND (TImode, div_equal));
6806 operands[4] = gen_reg_rtx(TImode);
6807 emit_clobber (operands[4]);
6808 emit_move_insn (gen_lowpart (DImode, operands[4]), operands[1]);
6809 emit_move_insn (gen_highpart (DImode, operands[4]), const0_rtx);
6811 insn = emit_insn (gen_udivmodtidi3 (operands[4], operands[4], operands[2]));
6812 set_unique_reg_note (insn, REG_EQUAL, equal);
6814 insn = emit_move_insn (operands[0], gen_lowpart (DImode, operands[4]));
6815 set_unique_reg_note (insn, REG_EQUAL, div_equal);
6817 insn = emit_move_insn (operands[3], gen_highpart (DImode, operands[4]));
6818 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
6823 (define_insn "udivmodtidi3"
6824 [(set (match_operand:TI 0 "register_operand" "=d,d")
6829 (umod:TI (match_operand:TI 1 "register_operand" "0,0")
6831 (match_operand:DI 2 "nonimmediate_operand" "d,T")))))
6835 (udiv:TI (match_dup 1) (zero_extend:TI (match_dup 2)))))))]
6840 [(set_attr "op_type" "RRE,RXY")
6841 (set_attr "type" "idiv")])
6844 ; divmodsi4 instruction pattern(s).
6847 (define_expand "divmodsi4"
6848 [(parallel [(set (match_operand:SI 0 "general_operand" "")
6849 (div:SI (match_operand:SI 1 "general_operand" "")
6850 (match_operand:SI 2 "nonimmediate_operand" "")))
6851 (set (match_operand:SI 3 "general_operand" "")
6852 (mod:SI (match_dup 1) (match_dup 2)))])
6853 (clobber (match_dup 4))]
6856 rtx div_equal, mod_equal, equal;
6859 div_equal = gen_rtx_DIV (SImode, operands[1], operands[2]);
6860 mod_equal = gen_rtx_MOD (SImode, operands[1], operands[2]);
6861 equal = gen_rtx_IOR (DImode,
6862 gen_rtx_ASHIFT (DImode,
6863 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
6865 gen_rtx_ZERO_EXTEND (DImode, div_equal));
6867 operands[4] = gen_reg_rtx(DImode);
6868 emit_insn (gen_extendsidi2 (operands[4], operands[1]));
6870 insn = emit_insn (gen_divmoddisi3 (operands[4], operands[4], operands[2]));
6871 set_unique_reg_note (insn, REG_EQUAL, equal);
6873 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
6874 set_unique_reg_note (insn, REG_EQUAL, div_equal);
6876 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
6877 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
6882 (define_insn "divmoddisi3"
6883 [(set (match_operand:DI 0 "register_operand" "=d,d")
6888 (mod:DI (match_operand:DI 1 "register_operand" "0,0")
6890 (match_operand:SI 2 "nonimmediate_operand" "d,R")))))
6894 (div:DI (match_dup 1) (sign_extend:DI (match_dup 2)))))))]
6899 [(set_attr "op_type" "RR,RX")
6900 (set_attr "type" "idiv")])
6903 ; udivsi3 and umodsi3 instruction pattern(s).
6906 (define_expand "udivmodsi4"
6907 [(parallel [(set (match_operand:SI 0 "general_operand" "")
6908 (udiv:SI (match_operand:SI 1 "general_operand" "")
6909 (match_operand:SI 2 "nonimmediate_operand" "")))
6910 (set (match_operand:SI 3 "general_operand" "")
6911 (umod:SI (match_dup 1) (match_dup 2)))])
6912 (clobber (match_dup 4))]
6913 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
6915 rtx div_equal, mod_equal, equal;
6918 div_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6919 mod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6920 equal = gen_rtx_IOR (DImode,
6921 gen_rtx_ASHIFT (DImode,
6922 gen_rtx_ZERO_EXTEND (DImode, mod_equal),
6924 gen_rtx_ZERO_EXTEND (DImode, div_equal));
6926 operands[4] = gen_reg_rtx(DImode);
6927 emit_clobber (operands[4]);
6928 emit_move_insn (gen_lowpart (SImode, operands[4]), operands[1]);
6929 emit_move_insn (gen_highpart (SImode, operands[4]), const0_rtx);
6931 insn = emit_insn (gen_udivmoddisi3 (operands[4], operands[4], operands[2]));
6932 set_unique_reg_note (insn, REG_EQUAL, equal);
6934 insn = emit_move_insn (operands[0], gen_lowpart (SImode, operands[4]));
6935 set_unique_reg_note (insn, REG_EQUAL, div_equal);
6937 insn = emit_move_insn (operands[3], gen_highpart (SImode, operands[4]));
6938 set_unique_reg_note (insn, REG_EQUAL, mod_equal);
6943 (define_insn "udivmoddisi3"
6944 [(set (match_operand:DI 0 "register_operand" "=d,d")
6949 (umod:DI (match_operand:DI 1 "register_operand" "0,0")
6951 (match_operand:SI 2 "nonimmediate_operand" "d,T")))))
6955 (udiv:DI (match_dup 1) (zero_extend:DI (match_dup 2)))))))]
6956 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
6960 [(set_attr "op_type" "RRE,RXY")
6961 (set_attr "type" "idiv")])
6963 (define_expand "udivsi3"
6964 [(set (match_operand:SI 0 "register_operand" "=d")
6965 (udiv:SI (match_operand:SI 1 "general_operand" "")
6966 (match_operand:SI 2 "general_operand" "")))
6967 (clobber (match_dup 3))]
6968 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
6970 rtx udiv_equal, umod_equal, equal;
6973 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
6974 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
6975 equal = gen_rtx_IOR (DImode,
6976 gen_rtx_ASHIFT (DImode,
6977 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
6979 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
6981 operands[3] = gen_reg_rtx (DImode);
6983 if (CONSTANT_P (operands[2]))
6985 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0)
6987 rtx_code_label *label1 = gen_label_rtx ();
6989 operands[1] = make_safe_from (operands[1], operands[0]);
6990 emit_move_insn (operands[0], const0_rtx);
6991 emit_cmp_and_jump_insns (operands[1], operands[2], LT, NULL_RTX,
6993 emit_move_insn (operands[0], const1_rtx);
6994 emit_label (label1);
6998 operands[2] = force_reg (SImode, operands[2]);
6999 operands[2] = make_safe_from (operands[2], operands[0]);
7001 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
7002 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
7004 set_unique_reg_note (insn, REG_EQUAL, equal);
7006 insn = emit_move_insn (operands[0],
7007 gen_lowpart (SImode, operands[3]));
7008 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
7013 rtx_code_label *label1 = gen_label_rtx ();
7014 rtx_code_label *label2 = gen_label_rtx ();
7015 rtx_code_label *label3 = gen_label_rtx ();
7017 operands[1] = force_reg (SImode, operands[1]);
7018 operands[1] = make_safe_from (operands[1], operands[0]);
7019 operands[2] = force_reg (SImode, operands[2]);
7020 operands[2] = make_safe_from (operands[2], operands[0]);
7022 emit_move_insn (operands[0], const0_rtx);
7023 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
7025 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
7027 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
7029 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
7030 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
7032 set_unique_reg_note (insn, REG_EQUAL, equal);
7034 insn = emit_move_insn (operands[0],
7035 gen_lowpart (SImode, operands[3]));
7036 set_unique_reg_note (insn, REG_EQUAL, udiv_equal);
7039 emit_label (label1);
7040 emit_move_insn (operands[0], operands[1]);
7042 emit_label (label2);
7043 emit_move_insn (operands[0], const1_rtx);
7044 emit_label (label3);
7046 emit_move_insn (operands[0], operands[0]);
7050 (define_expand "umodsi3"
7051 [(set (match_operand:SI 0 "register_operand" "=d")
7052 (umod:SI (match_operand:SI 1 "nonimmediate_operand" "")
7053 (match_operand:SI 2 "nonimmediate_operand" "")))
7054 (clobber (match_dup 3))]
7055 "!TARGET_ZARCH && !TARGET_CPU_ZARCH"
7057 rtx udiv_equal, umod_equal, equal;
7060 udiv_equal = gen_rtx_UDIV (SImode, operands[1], operands[2]);
7061 umod_equal = gen_rtx_UMOD (SImode, operands[1], operands[2]);
7062 equal = gen_rtx_IOR (DImode,
7063 gen_rtx_ASHIFT (DImode,
7064 gen_rtx_ZERO_EXTEND (DImode, umod_equal),
7066 gen_rtx_ZERO_EXTEND (DImode, udiv_equal));
7068 operands[3] = gen_reg_rtx (DImode);
7070 if (CONSTANT_P (operands[2]))
7072 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) <= 0)
7074 rtx_code_label *label1 = gen_label_rtx ();
7076 operands[1] = make_safe_from (operands[1], operands[0]);
7077 emit_move_insn (operands[0], operands[1]);
7078 emit_cmp_and_jump_insns (operands[0], operands[2], LT, NULL_RTX,
7080 emit_insn (gen_abssi2 (operands[0], operands[2]));
7081 emit_insn (gen_addsi3 (operands[0], operands[0], operands[1]));
7082 emit_label (label1);
7086 operands[2] = force_reg (SImode, operands[2]);
7087 operands[2] = make_safe_from (operands[2], operands[0]);
7089 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
7090 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
7092 set_unique_reg_note (insn, REG_EQUAL, equal);
7094 insn = emit_move_insn (operands[0],
7095 gen_highpart (SImode, operands[3]));
7096 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
7101 rtx_code_label *label1 = gen_label_rtx ();
7102 rtx_code_label *label2 = gen_label_rtx ();
7103 rtx_code_label *label3 = gen_label_rtx ();
7105 operands[1] = force_reg (SImode, operands[1]);
7106 operands[1] = make_safe_from (operands[1], operands[0]);
7107 operands[2] = force_reg (SImode, operands[2]);
7108 operands[2] = make_safe_from (operands[2], operands[0]);
7110 emit_move_insn(operands[0], operands[1]);
7111 emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX,
7113 emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX,
7115 emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX,
7117 emit_insn (gen_zero_extendsidi2 (operands[3], operands[1]));
7118 insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3],
7120 set_unique_reg_note (insn, REG_EQUAL, equal);
7122 insn = emit_move_insn (operands[0],
7123 gen_highpart (SImode, operands[3]));
7124 set_unique_reg_note (insn, REG_EQUAL, umod_equal);
7127 emit_label (label1);
7128 emit_move_insn (operands[0], const0_rtx);
7130 emit_label (label2);
7131 emit_insn (gen_subsi3 (operands[0], operands[0], operands[2]));
7132 emit_label (label3);
7138 ; div(df|sf)3 instruction pattern(s).
7141 ; dxbr, ddbr, debr, dxb, ddb, deb, ddtr, dxtr
7142 (define_insn "div<mode>3"
7143 [(set (match_operand:FP 0 "register_operand" "=f,f,f,v")
7144 (div:FP (match_operand:FP 1 "register_operand" "f,0,0,v")
7145 (match_operand:FP 2 "general_operand" "f,f,R,v")))]
7152 [(set_attr "op_type" "RRF,RRE,RXE,VRR")
7153 (set_attr "type" "fdiv<mode>")
7154 (set_attr "cpu_facility" "*,*,*,vx")
7155 (set_attr "enabled" "<nBFP>,<nDFP>,<DSF>,<DFDI>")])
7159 ;;- And instructions.
7162 (define_expand "and<mode>3"
7163 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7164 (and:INT (match_operand:INT 1 "nonimmediate_operand" "")
7165 (match_operand:INT 2 "general_operand" "")))
7166 (clobber (reg:CC CC_REGNUM))]
7168 "s390_expand_logical_operator (AND, <MODE>mode, operands); DONE;")
7171 ; anddi3 instruction pattern(s).
7174 (define_insn "*anddi3_cc"
7175 [(set (reg CC_REGNUM)
7177 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0, d")
7178 (match_operand:DI 2 "general_operand" " d,d,T,NxxDw"))
7180 (set (match_operand:DI 0 "register_operand" "=d,d,d, d")
7181 (and:DI (match_dup 1) (match_dup 2)))]
7182 "TARGET_ZARCH && s390_match_ccmode(insn, CCTmode)"
7187 risbg\t%0,%1,%s2,128+%e2,0"
7188 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
7189 (set_attr "cpu_facility" "*,z196,*,z10")
7190 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
7192 (define_insn "*anddi3_cconly"
7193 [(set (reg CC_REGNUM)
7195 (and:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0, d")
7196 (match_operand:DI 2 "general_operand" " d,d,T,NxxDw"))
7198 (clobber (match_scratch:DI 0 "=d,d,d, d"))]
7200 && s390_match_ccmode(insn, CCTmode)
7201 /* Do not steal TM patterns. */
7202 && s390_single_part (operands[2], DImode, HImode, 0) < 0"
7207 risbg\t%0,%1,%s2,128+%e2,0"
7208 [(set_attr "op_type" "RRE,RRF,RXY,RIE")
7209 (set_attr "cpu_facility" "*,z196,*,z10")
7210 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super_E1")])
7212 (define_insn "*anddi3"
7213 [(set (match_operand:DI 0 "nonimmediate_operand"
7214 "=d,d, d, d, d, d, d, d,d,d,d, d, AQ,Q")
7216 (match_operand:DI 1 "nonimmediate_operand"
7217 "%d,o, 0, 0, 0, 0, 0, 0,0,d,0, d, 0,0")
7218 (match_operand:DI 2 "general_operand"
7219 "M, M,N0HDF,N1HDF,N2HDF,N3HDF,N0SDF,N1SDF,d,d,T,NxxDw,NxQDF,Q")))
7220 (clobber (reg:CC CC_REGNUM))]
7221 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7234 risbg\t%0,%1,%s2,128+%e2,0
7237 [(set_attr "op_type" "RRE,RXE,RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,RIE,SI,SS")
7238 (set_attr "cpu_facility" "*,*,*,*,*,*,extimm,extimm,*,z196,*,z10,*,*")
7239 (set_attr "z10prop" "*,
7255 [(set (match_operand:DI 0 "s_operand" "")
7256 (and:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
7257 (clobber (reg:CC CC_REGNUM))]
7260 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
7261 (clobber (reg:CC CC_REGNUM))])]
7262 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
7264 ;; These two are what combine generates for (ashift (zero_extract)).
7265 (define_insn "*extzv_<mode>_srl<clobbercc_or_nocc>"
7266 [(set (match_operand:GPR 0 "register_operand" "=d")
7267 (and:GPR (lshiftrt:GPR
7268 (match_operand:GPR 1 "register_operand" "d")
7269 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
7270 (match_operand:GPR 3 "contiguous_bitmask_nowrap_operand" "")))]
7271 "<z10_or_zEC12_cond>
7272 /* Note that even for the SImode pattern, the rotate is always DImode. */
7273 && s390_extzv_shift_ok (<bitsize>, -INTVAL (operands[2]),
7274 INTVAL (operands[3]))"
7275 "<risbg_n>\t%0,%1,%<bfstart>3,128+%<bfend>3,64-%2"
7276 [(set_attr "op_type" "RIE")
7277 (set_attr "z10prop" "z10_super_E1")])
7279 (define_insn "*extzv_<mode>_sll<clobbercc_or_nocc>"
7280 [(set (match_operand:GPR 0 "register_operand" "=d")
7281 (and:GPR (ashift:GPR
7282 (match_operand:GPR 1 "register_operand" "d")
7283 (match_operand:GPR 2 "nonzero_shift_count_operand" ""))
7284 (match_operand:GPR 3 "contiguous_bitmask_nowrap_operand" "")))]
7285 "<z10_or_zEC12_cond>
7286 && s390_extzv_shift_ok (<bitsize>, INTVAL (operands[2]),
7287 INTVAL (operands[3]))"
7288 "<risbg_n>\t%0,%1,%<bfstart>3,128+%<bfend>3,%2"
7289 [(set_attr "op_type" "RIE")
7290 (set_attr "z10prop" "z10_super_E1")])
7294 ; andsi3 instruction pattern(s).
7297 (define_insn "*andsi3_cc"
7298 [(set (reg CC_REGNUM)
7301 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
7302 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
7304 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d, d")
7305 (and:SI (match_dup 1) (match_dup 2)))]
7306 "s390_match_ccmode(insn, CCTmode)"
7313 risbg\t%0,%1,%t2,128+%f2,0"
7314 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
7315 (set_attr "cpu_facility" "*,*,z196,*,longdisp,z10")
7316 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7317 z10_super_E1,z10_super_E1,z10_super_E1")])
7319 (define_insn "*andsi3_cconly"
7320 [(set (reg CC_REGNUM)
7323 (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, d")
7324 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxxSq"))
7326 (clobber (match_scratch:SI 0 "=d,d,d,d,d, d"))]
7327 "s390_match_ccmode(insn, CCTmode)
7328 /* Do not steal TM patterns. */
7329 && s390_single_part (operands[2], SImode, HImode, 0) < 0"
7336 risbg\t%0,%1,%t2,128+%f2,0"
7337 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,RIE")
7338 (set_attr "cpu_facility" "*,*,z196,*,longdisp,z10")
7339 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
7340 z10_super_E1,z10_super_E1,z10_super_E1")])
7342 (define_insn "*andsi3_zarch"
7343 [(set (match_operand:SI 0 "nonimmediate_operand"
7344 "=d,d, d, d, d,d,d,d,d, d, AQ,Q")
7345 (and:SI (match_operand:SI 1 "nonimmediate_operand"
7346 "%d,o, 0, 0, 0,0,d,0,0, d, 0,0")
7347 (match_operand:SI 2 "general_operand"
7348 " M,M,N0HSF,N1HSF,Os,d,d,R,T,NxxSw,NxQSF,Q")))
7349 (clobber (reg:CC CC_REGNUM))]
7350 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7361 risbg\t%0,%1,%t2,128+%f2,0
7364 [(set_attr "op_type" "RRE,RXE,RI,RI,RIL,RR,RRF,RX,RXY,RIE,SI,SS")
7365 (set_attr "cpu_facility" "*,*,*,*,*,*,z196,*,longdisp,z10,*,*")
7366 (set_attr "z10prop" "*,
7379 (define_insn "*andsi3_esa"
7380 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d, AQ,Q")
7381 (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0, 0,0")
7382 (match_operand:SI 2 "general_operand" " d,R,NxQSF,Q")))
7383 (clobber (reg:CC CC_REGNUM))]
7384 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7390 [(set_attr "op_type" "RR,RX,SI,SS")
7391 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
7395 [(set (match_operand:SI 0 "s_operand" "")
7396 (and:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
7397 (clobber (reg:CC CC_REGNUM))]
7400 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
7401 (clobber (reg:CC CC_REGNUM))])]
7402 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
7405 ; andhi3 instruction pattern(s).
7408 (define_insn "*andhi3_zarch"
7409 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7410 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
7411 (match_operand:HI 2 "general_operand" " d,d,n,NxQHF,Q")))
7412 (clobber (reg:CC CC_REGNUM))]
7413 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7420 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
7421 (set_attr "cpu_facility" "*,z196,*,*,*")
7422 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")
7425 (define_insn "*andhi3_esa"
7426 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
7427 (and:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
7428 (match_operand:HI 2 "general_operand" "d,NxQHF,Q")))
7429 (clobber (reg:CC CC_REGNUM))]
7430 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7435 [(set_attr "op_type" "RR,SI,SS")
7436 (set_attr "z10prop" "z10_super_E1,*,*")
7440 [(set (match_operand:HI 0 "s_operand" "")
7441 (and:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
7442 (clobber (reg:CC CC_REGNUM))]
7445 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))
7446 (clobber (reg:CC CC_REGNUM))])]
7447 "s390_narrow_logical_operator (AND, &operands[0], &operands[1]);")
7450 ; andqi3 instruction pattern(s).
7453 (define_insn "*andqi3_zarch"
7454 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7455 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7456 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
7457 (clobber (reg:CC CC_REGNUM))]
7458 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7466 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
7467 (set_attr "cpu_facility" "*,z196,*,*,longdisp,*")
7468 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,z10_super,z10_super,*")])
7470 (define_insn "*andqi3_esa"
7471 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
7472 (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7473 (match_operand:QI 2 "general_operand" "d,n,Q")))
7474 (clobber (reg:CC CC_REGNUM))]
7475 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7480 [(set_attr "op_type" "RR,SI,SS")
7481 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
7484 ; And with complement
7486 ; c = ~b & a = (b & a) ^ a
7488 (define_insn_and_split "*andc_split_<mode>"
7489 [(set (match_operand:GPR 0 "nonimmediate_operand" "")
7490 (and:GPR (not:GPR (match_operand:GPR 1 "nonimmediate_operand" ""))
7491 (match_operand:GPR 2 "general_operand" "")))
7492 (clobber (reg:CC CC_REGNUM))]
7494 && (GET_CODE (operands[0]) != MEM
7495 /* Ensure that s390_logical_operator_ok_p will succeed even
7496 on the split xor if (b & a) is stored into a pseudo. */
7497 || rtx_equal_p (operands[0], operands[2]))"
7502 [(set (match_dup 3) (and:GPR (match_dup 1) (match_dup 2)))
7503 (clobber (reg:CC CC_REGNUM))])
7505 [(set (match_dup 0) (xor:GPR (match_dup 3) (match_dup 2)))
7506 (clobber (reg:CC CC_REGNUM))])]
7508 if (reg_overlap_mentioned_p (operands[0], operands[2]))
7509 operands[3] = gen_reg_rtx (<MODE>mode);
7511 operands[3] = operands[0];
7515 ; Block and (NC) patterns.
7519 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7520 (and:BLK (match_dup 0)
7521 (match_operand:BLK 1 "memory_operand" "Q")))
7522 (use (match_operand 2 "const_int_operand" "n"))
7523 (clobber (reg:CC CC_REGNUM))]
7524 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
7525 "nc\t%O0(%2,%R0),%S1"
7526 [(set_attr "op_type" "SS")
7527 (set_attr "z196prop" "z196_cracked")])
7530 [(set (match_operand 0 "memory_operand" "")
7532 (match_operand 1 "memory_operand" "")))
7533 (clobber (reg:CC CC_REGNUM))]
7535 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7536 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7538 [(set (match_dup 0) (and:BLK (match_dup 0) (match_dup 1)))
7540 (clobber (reg:CC CC_REGNUM))])]
7542 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7543 operands[0] = adjust_address (operands[0], BLKmode, 0);
7544 operands[1] = adjust_address (operands[1], BLKmode, 0);
7549 [(set (match_operand:BLK 0 "memory_operand" "")
7550 (and:BLK (match_dup 0)
7551 (match_operand:BLK 1 "memory_operand" "")))
7552 (use (match_operand 2 "const_int_operand" ""))
7553 (clobber (reg:CC CC_REGNUM))])
7555 [(set (match_operand:BLK 3 "memory_operand" "")
7556 (and:BLK (match_dup 3)
7557 (match_operand:BLK 4 "memory_operand" "")))
7558 (use (match_operand 5 "const_int_operand" ""))
7559 (clobber (reg:CC CC_REGNUM))])]
7560 "s390_offset_p (operands[0], operands[3], operands[2])
7561 && s390_offset_p (operands[1], operands[4], operands[2])
7562 && !s390_overlap_p (operands[0], operands[1],
7563 INTVAL (operands[2]) + INTVAL (operands[5]))
7564 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7566 [(set (match_dup 6) (and:BLK (match_dup 6) (match_dup 7)))
7568 (clobber (reg:CC CC_REGNUM))])]
7569 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7570 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7571 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7575 ;;- Bit set (inclusive or) instructions.
7578 (define_expand "ior<mode>3"
7579 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7580 (ior:INT (match_operand:INT 1 "nonimmediate_operand" "")
7581 (match_operand:INT 2 "general_operand" "")))
7582 (clobber (reg:CC CC_REGNUM))]
7584 "s390_expand_logical_operator (IOR, <MODE>mode, operands); DONE;")
7587 ; iordi3 instruction pattern(s).
7590 (define_insn "*iordi3_cc"
7591 [(set (reg CC_REGNUM)
7592 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7593 (match_operand:DI 2 "general_operand" " d,d,T"))
7595 (set (match_operand:DI 0 "register_operand" "=d,d,d")
7596 (ior:DI (match_dup 1) (match_dup 2)))]
7597 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
7602 [(set_attr "op_type" "RRE,RRF,RXY")
7603 (set_attr "cpu_facility" "*,z196,*")
7604 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
7606 (define_insn "*iordi3_cconly"
7607 [(set (reg CC_REGNUM)
7608 (compare (ior:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7609 (match_operand:DI 2 "general_operand" " d,d,T"))
7611 (clobber (match_scratch:DI 0 "=d,d,d"))]
7612 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
7617 [(set_attr "op_type" "RRE,RRF,RXY")
7618 (set_attr "cpu_facility" "*,z196,*")
7619 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
7621 (define_insn "*iordi3"
7622 [(set (match_operand:DI 0 "nonimmediate_operand"
7623 "=d, d, d, d, d, d,d,d,d, AQ,Q")
7624 (ior:DI (match_operand:DI 1 "nonimmediate_operand"
7625 " %0, 0, 0, 0, 0, 0,0,d,0, 0,0")
7626 (match_operand:DI 2 "general_operand"
7627 "N0HD0,N1HD0,N2HD0,N3HD0,N0SD0,N1SD0,d,d,T,NxQD0,Q")))
7628 (clobber (reg:CC CC_REGNUM))]
7629 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7642 [(set_attr "op_type" "RI,RI,RI,RI,RIL,RIL,RRE,RRF,RXY,SI,SS")
7643 (set_attr "cpu_facility" "*,*,*,*,extimm,extimm,*,z196,*,*,*")
7644 (set_attr "z10prop" "z10_super_E1,
7657 [(set (match_operand:DI 0 "s_operand" "")
7658 (ior:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
7659 (clobber (reg:CC CC_REGNUM))]
7662 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
7663 (clobber (reg:CC CC_REGNUM))])]
7664 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
7667 ; iorsi3 instruction pattern(s).
7670 (define_insn "*iorsi3_cc"
7671 [(set (reg CC_REGNUM)
7672 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7673 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
7675 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
7676 (ior:SI (match_dup 1) (match_dup 2)))]
7677 "s390_match_ccmode(insn, CCTmode)"
7684 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
7685 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
7686 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
7688 (define_insn "*iorsi3_cconly"
7689 [(set (reg CC_REGNUM)
7690 (compare (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7691 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
7693 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
7694 "s390_match_ccmode(insn, CCTmode)"
7701 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
7702 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
7703 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super_E1,z10_super_E1")])
7705 (define_insn "*iorsi3_zarch"
7706 [(set (match_operand:SI 0 "nonimmediate_operand" "=d, d, d,d,d,d,d, AQ,Q")
7707 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0, 0, 0,0,d,0,0, 0,0")
7708 (match_operand:SI 2 "general_operand" "N0HS0,N1HS0,Os,d,d,R,T,NxQS0,Q")))
7709 (clobber (reg:CC CC_REGNUM))]
7710 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7721 [(set_attr "op_type" "RI,RI,RIL,RR,RRF,RX,RXY,SI,SS")
7722 (set_attr "cpu_facility" "*,*,*,*,z196,*,longdisp,*,*")
7723 (set_attr "z10prop" "z10_super_E1,
7733 (define_insn "*iorsi3_esa"
7734 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,AQ,Q")
7735 (ior:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0")
7736 (match_operand:SI 2 "general_operand" "d,R,NxQS0,Q")))
7737 (clobber (reg:CC CC_REGNUM))]
7738 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7744 [(set_attr "op_type" "RR,RX,SI,SS")
7745 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*")])
7748 [(set (match_operand:SI 0 "s_operand" "")
7749 (ior:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
7750 (clobber (reg:CC CC_REGNUM))]
7753 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
7754 (clobber (reg:CC CC_REGNUM))])]
7755 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
7758 ; iorhi3 instruction pattern(s).
7761 (define_insn "*iorhi3_zarch"
7762 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
7763 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,d,0, 0,0")
7764 (match_operand:HI 2 "general_operand" " d,d,n,NxQH0,Q")))
7765 (clobber (reg:CC CC_REGNUM))]
7766 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7773 [(set_attr "op_type" "RR,RRF,RI,SI,SS")
7774 (set_attr "cpu_facility" "*,z196,*,*,*")
7775 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,*,*")])
7777 (define_insn "*iorhi3_esa"
7778 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,AQ,Q")
7779 (ior:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,0")
7780 (match_operand:HI 2 "general_operand" "d,NxQH0,Q")))
7781 (clobber (reg:CC CC_REGNUM))]
7782 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7787 [(set_attr "op_type" "RR,SI,SS")
7788 (set_attr "z10prop" "z10_super_E1,*,*")])
7791 [(set (match_operand:HI 0 "s_operand" "")
7792 (ior:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
7793 (clobber (reg:CC CC_REGNUM))]
7796 [(set (match_dup 0) (ior:QI (match_dup 0) (match_dup 1)))
7797 (clobber (reg:CC CC_REGNUM))])]
7798 "s390_narrow_logical_operator (IOR, &operands[0], &operands[1]);")
7801 ; iorqi3 instruction pattern(s).
7804 (define_insn "*iorqi3_zarch"
7805 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
7806 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,d,0,0,0,0")
7807 (match_operand:QI 2 "general_operand" " d,d,n,n,n,Q")))
7808 (clobber (reg:CC CC_REGNUM))]
7809 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7817 [(set_attr "op_type" "RR,RRF,RI,SI,SIY,SS")
7818 (set_attr "cpu_facility" "*,z196,*,*,longdisp,*")
7819 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1,
7820 z10_super,z10_super,*")])
7822 (define_insn "*iorqi3_esa"
7823 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,Q,Q")
7824 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
7825 (match_operand:QI 2 "general_operand" "d,n,Q")))
7826 (clobber (reg:CC CC_REGNUM))]
7827 "!TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7832 [(set_attr "op_type" "RR,SI,SS")
7833 (set_attr "z10prop" "z10_super_E1,z10_super,*")])
7836 ; Block inclusive or (OC) patterns.
7840 [(set (match_operand:BLK 0 "memory_operand" "=Q")
7841 (ior:BLK (match_dup 0)
7842 (match_operand:BLK 1 "memory_operand" "Q")))
7843 (use (match_operand 2 "const_int_operand" "n"))
7844 (clobber (reg:CC CC_REGNUM))]
7845 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
7846 "oc\t%O0(%2,%R0),%S1"
7847 [(set_attr "op_type" "SS")
7848 (set_attr "z196prop" "z196_cracked")])
7851 [(set (match_operand 0 "memory_operand" "")
7853 (match_operand 1 "memory_operand" "")))
7854 (clobber (reg:CC CC_REGNUM))]
7856 && GET_MODE (operands[0]) == GET_MODE (operands[1])
7857 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
7859 [(set (match_dup 0) (ior:BLK (match_dup 0) (match_dup 1)))
7861 (clobber (reg:CC CC_REGNUM))])]
7863 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
7864 operands[0] = adjust_address (operands[0], BLKmode, 0);
7865 operands[1] = adjust_address (operands[1], BLKmode, 0);
7870 [(set (match_operand:BLK 0 "memory_operand" "")
7871 (ior:BLK (match_dup 0)
7872 (match_operand:BLK 1 "memory_operand" "")))
7873 (use (match_operand 2 "const_int_operand" ""))
7874 (clobber (reg:CC CC_REGNUM))])
7876 [(set (match_operand:BLK 3 "memory_operand" "")
7877 (ior:BLK (match_dup 3)
7878 (match_operand:BLK 4 "memory_operand" "")))
7879 (use (match_operand 5 "const_int_operand" ""))
7880 (clobber (reg:CC CC_REGNUM))])]
7881 "s390_offset_p (operands[0], operands[3], operands[2])
7882 && s390_offset_p (operands[1], operands[4], operands[2])
7883 && !s390_overlap_p (operands[0], operands[1],
7884 INTVAL (operands[2]) + INTVAL (operands[5]))
7885 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
7887 [(set (match_dup 6) (ior:BLK (match_dup 6) (match_dup 7)))
7889 (clobber (reg:CC CC_REGNUM))])]
7890 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
7891 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
7892 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
7896 ;;- Xor instructions.
7899 (define_expand "xor<mode>3"
7900 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7901 (xor:INT (match_operand:INT 1 "nonimmediate_operand" "")
7902 (match_operand:INT 2 "general_operand" "")))
7903 (clobber (reg:CC CC_REGNUM))]
7905 "s390_expand_logical_operator (XOR, <MODE>mode, operands); DONE;")
7907 ; Combine replaces (xor (x) (const_int -1)) with (not (x)) when doing
7908 ; simplifications. So its better to have something matching.
7910 [(set (match_operand:INT 0 "nonimmediate_operand" "")
7911 (not:INT (match_operand:INT 1 "nonimmediate_operand" "")))]
7914 [(set (match_dup 0) (xor:INT (match_dup 1) (match_dup 2)))
7915 (clobber (reg:CC CC_REGNUM))])]
7917 operands[2] = constm1_rtx;
7918 if (!s390_logical_operator_ok_p (operands))
7923 ; xordi3 instruction pattern(s).
7926 (define_insn "*xordi3_cc"
7927 [(set (reg CC_REGNUM)
7928 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7929 (match_operand:DI 2 "general_operand" " d,d,T"))
7931 (set (match_operand:DI 0 "register_operand" "=d,d,d")
7932 (xor:DI (match_dup 1) (match_dup 2)))]
7933 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
7938 [(set_attr "op_type" "RRE,RRF,RXY")
7939 (set_attr "cpu_facility" "*,z196,*")
7940 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
7942 (define_insn "*xordi3_cconly"
7943 [(set (reg CC_REGNUM)
7944 (compare (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0,d,0")
7945 (match_operand:DI 2 "general_operand" " d,d,T"))
7947 (clobber (match_scratch:DI 0 "=d,d,d"))]
7948 "s390_match_ccmode(insn, CCTmode) && TARGET_ZARCH"
7953 [(set_attr "op_type" "RRE,RRF,RXY")
7954 (set_attr "cpu_facility" "*,z196,*")
7955 (set_attr "z10prop" "z10_super_E1,*,z10_super_E1")])
7957 (define_insn "*xordi3"
7958 [(set (match_operand:DI 0 "nonimmediate_operand" "=d, d,d,d,d, AQ,Q")
7959 (xor:DI (match_operand:DI 1 "nonimmediate_operand" "%0, 0,0,d,0, 0,0")
7960 (match_operand:DI 2 "general_operand" "N0SD0,N1SD0,d,d,T,NxQD0,Q")))
7961 (clobber (reg:CC CC_REGNUM))]
7962 "TARGET_ZARCH && s390_logical_operator_ok_p (operands)"
7971 [(set_attr "op_type" "RIL,RIL,RRE,RRF,RXY,SI,SS")
7972 (set_attr "cpu_facility" "extimm,extimm,*,z196,*,*,*")
7973 (set_attr "z10prop" "z10_super_E1,z10_super_E1,z10_super_E1,
7974 *,z10_super_E1,*,*")])
7977 [(set (match_operand:DI 0 "s_operand" "")
7978 (xor:DI (match_dup 0) (match_operand:DI 1 "immediate_operand" "")))
7979 (clobber (reg:CC CC_REGNUM))]
7982 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
7983 (clobber (reg:CC CC_REGNUM))])]
7984 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
7987 ; xorsi3 instruction pattern(s).
7990 (define_insn "*xorsi3_cc"
7991 [(set (reg CC_REGNUM)
7992 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
7993 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
7995 (set (match_operand:SI 0 "register_operand" "=d,d,d,d,d")
7996 (xor:SI (match_dup 1) (match_dup 2)))]
7997 "s390_match_ccmode(insn, CCTmode)"
8004 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
8005 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
8006 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
8007 z10_super_E1,z10_super_E1")])
8009 (define_insn "*xorsi3_cconly"
8010 [(set (reg CC_REGNUM)
8011 (compare (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0")
8012 (match_operand:SI 2 "general_operand" "Os,d,d,R,T"))
8014 (clobber (match_scratch:SI 0 "=d,d,d,d,d"))]
8015 "s390_match_ccmode(insn, CCTmode)"
8022 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY")
8023 (set_attr "cpu_facility" "*,*,z196,*,longdisp")
8024 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
8025 z10_super_E1,z10_super_E1")])
8027 (define_insn "*xorsi3"
8028 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d,d,d, AQ,Q")
8029 (xor:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,d,0,0, 0,0")
8030 (match_operand:SI 2 "general_operand" "Os,d,d,R,T,NxQS0,Q")))
8031 (clobber (reg:CC CC_REGNUM))]
8032 "s390_logical_operator_ok_p (operands)"
8041 [(set_attr "op_type" "RIL,RR,RRF,RX,RXY,SI,SS")
8042 (set_attr "cpu_facility" "*,*,z196,*,longdisp,*,*")
8043 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,
8044 z10_super_E1,z10_super_E1,*,*")])
8047 [(set (match_operand:SI 0 "s_operand" "")
8048 (xor:SI (match_dup 0) (match_operand:SI 1 "immediate_operand" "")))
8049 (clobber (reg:CC CC_REGNUM))]
8052 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
8053 (clobber (reg:CC CC_REGNUM))])]
8054 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
8057 ; xorhi3 instruction pattern(s).
8060 (define_insn "*xorhi3"
8061 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,d, AQ,Q")
8062 (xor:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0,d, 0,0")
8063 (match_operand:HI 2 "general_operand" "Os,d,d,NxQH0,Q")))
8064 (clobber (reg:CC CC_REGNUM))]
8065 "s390_logical_operator_ok_p (operands)"
8072 [(set_attr "op_type" "RIL,RR,RRF,SI,SS")
8073 (set_attr "cpu_facility" "*,*,z196,*,*")
8074 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,*,*")])
8077 [(set (match_operand:HI 0 "s_operand" "")
8078 (xor:HI (match_dup 0) (match_operand:HI 1 "immediate_operand" "")))
8079 (clobber (reg:CC CC_REGNUM))]
8082 [(set (match_dup 0) (xor:QI (match_dup 0) (match_dup 1)))
8083 (clobber (reg:CC CC_REGNUM))])]
8084 "s390_narrow_logical_operator (XOR, &operands[0], &operands[1]);")
8087 ; xorqi3 instruction pattern(s).
8090 (define_insn "*xorqi3"
8091 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d,d,Q,S,Q")
8092 (xor:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,d,0,0,0")
8093 (match_operand:QI 2 "general_operand" "Os,d,d,n,n,Q")))
8094 (clobber (reg:CC CC_REGNUM))]
8095 "s390_logical_operator_ok_p (operands)"
8103 [(set_attr "op_type" "RIL,RR,RRF,SI,SIY,SS")
8104 (set_attr "cpu_facility" "*,*,z196,*,longdisp,*")
8105 (set_attr "z10prop" "z10_super_E1,z10_super_E1,*,z10_super,z10_super,*")])
8109 ; Block exclusive or (XC) patterns.
8113 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8114 (xor:BLK (match_dup 0)
8115 (match_operand:BLK 1 "memory_operand" "Q")))
8116 (use (match_operand 2 "const_int_operand" "n"))
8117 (clobber (reg:CC CC_REGNUM))]
8118 "INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 256"
8119 "xc\t%O0(%2,%R0),%S1"
8120 [(set_attr "op_type" "SS")])
8123 [(set (match_operand 0 "memory_operand" "")
8125 (match_operand 1 "memory_operand" "")))
8126 (clobber (reg:CC CC_REGNUM))]
8128 && GET_MODE (operands[0]) == GET_MODE (operands[1])
8129 && GET_MODE_SIZE (GET_MODE (operands[0])) > 0"
8131 [(set (match_dup 0) (xor:BLK (match_dup 0) (match_dup 1)))
8133 (clobber (reg:CC CC_REGNUM))])]
8135 operands[2] = GEN_INT (GET_MODE_SIZE (GET_MODE (operands[0])));
8136 operands[0] = adjust_address (operands[0], BLKmode, 0);
8137 operands[1] = adjust_address (operands[1], BLKmode, 0);
8142 [(set (match_operand:BLK 0 "memory_operand" "")
8143 (xor:BLK (match_dup 0)
8144 (match_operand:BLK 1 "memory_operand" "")))
8145 (use (match_operand 2 "const_int_operand" ""))
8146 (clobber (reg:CC CC_REGNUM))])
8148 [(set (match_operand:BLK 3 "memory_operand" "")
8149 (xor:BLK (match_dup 3)
8150 (match_operand:BLK 4 "memory_operand" "")))
8151 (use (match_operand 5 "const_int_operand" ""))
8152 (clobber (reg:CC CC_REGNUM))])]
8153 "s390_offset_p (operands[0], operands[3], operands[2])
8154 && s390_offset_p (operands[1], operands[4], operands[2])
8155 && !s390_overlap_p (operands[0], operands[1],
8156 INTVAL (operands[2]) + INTVAL (operands[5]))
8157 && INTVAL (operands[2]) + INTVAL (operands[5]) <= 256"
8159 [(set (match_dup 6) (xor:BLK (match_dup 6) (match_dup 7)))
8161 (clobber (reg:CC CC_REGNUM))])]
8162 "operands[6] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8163 operands[7] = gen_rtx_MEM (BLKmode, XEXP (operands[1], 0));
8164 operands[8] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[5]));")
8167 ; Block xor (XC) patterns with src == dest.
8170 (define_insn "*xc_zero"
8171 [(set (match_operand:BLK 0 "memory_operand" "=Q")
8173 (use (match_operand 1 "const_int_operand" "n"))
8174 (clobber (reg:CC CC_REGNUM))]
8175 "INTVAL (operands[1]) >= 1 && INTVAL (operands[1]) <= 256"
8176 "xc\t%O0(%1,%R0),%S0"
8177 [(set_attr "op_type" "SS")
8178 (set_attr "z196prop" "z196_cracked")])
8182 [(set (match_operand:BLK 0 "memory_operand" "")
8184 (use (match_operand 1 "const_int_operand" ""))
8185 (clobber (reg:CC CC_REGNUM))])
8187 [(set (match_operand:BLK 2 "memory_operand" "")
8189 (use (match_operand 3 "const_int_operand" ""))
8190 (clobber (reg:CC CC_REGNUM))])]
8191 "s390_offset_p (operands[0], operands[2], operands[1])
8192 && INTVAL (operands[1]) + INTVAL (operands[3]) <= 256"
8194 [(set (match_dup 4) (const_int 0))
8196 (clobber (reg:CC CC_REGNUM))])]
8197 "operands[4] = gen_rtx_MEM (BLKmode, XEXP (operands[0], 0));
8198 operands[5] = GEN_INT (INTVAL (operands[1]) + INTVAL (operands[3]));")
8202 ;;- Negate instructions.
8206 ; neg(di|si)2 instruction pattern(s).
8209 (define_expand "neg<mode>2"
8211 [(set (match_operand:DSI 0 "register_operand" "=d")
8212 (neg:DSI (match_operand:DSI 1 "register_operand" "d")))
8213 (clobber (reg:CC CC_REGNUM))])]
8217 (define_insn "*negdi2_sign_cc"
8218 [(set (reg CC_REGNUM)
8219 (compare (neg:DI (ashiftrt:DI (ashift:DI (subreg:DI
8220 (match_operand:SI 1 "register_operand" "d") 0)
8221 (const_int 32)) (const_int 32)))
8223 (set (match_operand:DI 0 "register_operand" "=d")
8224 (neg:DI (sign_extend:DI (match_dup 1))))]
8225 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
8227 [(set_attr "op_type" "RRE")
8228 (set_attr "z10prop" "z10_c")])
8230 (define_insn "*negdi2_sign"
8231 [(set (match_operand:DI 0 "register_operand" "=d")
8232 (neg:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
8233 (clobber (reg:CC CC_REGNUM))]
8236 [(set_attr "op_type" "RRE")
8237 (set_attr "z10prop" "z10_c")])
8240 (define_insn "*neg<mode>2_cc"
8241 [(set (reg CC_REGNUM)
8242 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
8244 (set (match_operand:GPR 0 "register_operand" "=d")
8245 (neg:GPR (match_dup 1)))]
8246 "s390_match_ccmode (insn, CCAmode)"
8248 [(set_attr "op_type" "RR<E>")
8249 (set_attr "z10prop" "z10_super_c_E1")])
8252 (define_insn "*neg<mode>2_cconly"
8253 [(set (reg CC_REGNUM)
8254 (compare (neg:GPR (match_operand:GPR 1 "register_operand" "d"))
8256 (clobber (match_scratch:GPR 0 "=d"))]
8257 "s390_match_ccmode (insn, CCAmode)"
8259 [(set_attr "op_type" "RR<E>")
8260 (set_attr "z10prop" "z10_super_c_E1")])
8263 (define_insn "*neg<mode>2"
8264 [(set (match_operand:GPR 0 "register_operand" "=d")
8265 (neg:GPR (match_operand:GPR 1 "register_operand" "d")))
8266 (clobber (reg:CC CC_REGNUM))]
8269 [(set_attr "op_type" "RR<E>")
8270 (set_attr "z10prop" "z10_super_c_E1")])
8272 (define_insn "*negdi2_31"
8273 [(set (match_operand:DI 0 "register_operand" "=d")
8274 (neg:DI (match_operand:DI 1 "register_operand" "d")))
8275 (clobber (reg:CC CC_REGNUM))]
8279 ; Split a DImode NEG on 31bit into 2 SImode NEGs
8281 ; Doing the twos complement separately on the SImode parts does an
8282 ; unwanted +1 on the high part which needs to be subtracted afterwards
8283 ; ... unless the +1 on the low part created an overflow.
8286 [(set (match_operand:DI 0 "register_operand" "")
8287 (neg:DI (match_operand:DI 1 "register_operand" "")))
8288 (clobber (reg:CC CC_REGNUM))]
8290 && (REGNO (operands[0]) == REGNO (operands[1])
8291 || s390_split_ok_p (operands[0], operands[1], DImode, 0))
8292 && reload_completed"
8294 [(set (match_dup 2) (neg:SI (match_dup 3)))
8295 (clobber (reg:CC CC_REGNUM))])
8297 [(set (reg:CCAP CC_REGNUM)
8298 (compare:CCAP (neg:SI (match_dup 5)) (const_int 0)))
8299 (set (match_dup 4) (neg:SI (match_dup 5)))])
8301 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
8303 (label_ref (match_dup 6))))
8305 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
8306 (clobber (reg:CC CC_REGNUM))])
8308 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
8309 operands[3] = operand_subword (operands[1], 0, 0, DImode);
8310 operands[4] = operand_subword (operands[0], 1, 0, DImode);
8311 operands[5] = operand_subword (operands[1], 1, 0, DImode);
8312 operands[6] = gen_label_rtx ();")
8314 ; Like above but first make a copy of the low part of the src operand
8315 ; since it might overlap with the high part of the destination.
8318 [(set (match_operand:DI 0 "register_operand" "")
8319 (neg:DI (match_operand:DI 1 "register_operand" "")))
8320 (clobber (reg:CC CC_REGNUM))]
8322 && s390_split_ok_p (operands[0], operands[1], DImode, 1)
8323 && reload_completed"
8324 [; Make a backup of op5 first
8325 (set (match_dup 4) (match_dup 5))
8326 ; Setting op2 here might clobber op5
8328 [(set (match_dup 2) (neg:SI (match_dup 3)))
8329 (clobber (reg:CC CC_REGNUM))])
8331 [(set (reg:CCAP CC_REGNUM)
8332 (compare:CCAP (neg:SI (match_dup 4)) (const_int 0)))
8333 (set (match_dup 4) (neg:SI (match_dup 4)))])
8335 (if_then_else (ne (reg:CCAP CC_REGNUM) (const_int 0))
8337 (label_ref (match_dup 6))))
8339 [(set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))
8340 (clobber (reg:CC CC_REGNUM))])
8342 "operands[2] = operand_subword (operands[0], 0, 0, DImode);
8343 operands[3] = operand_subword (operands[1], 0, 0, DImode);
8344 operands[4] = operand_subword (operands[0], 1, 0, DImode);
8345 operands[5] = operand_subword (operands[1], 1, 0, DImode);
8346 operands[6] = gen_label_rtx ();")
8349 ; neg(df|sf)2 instruction pattern(s).
8352 (define_expand "neg<mode>2"
8354 [(set (match_operand:BFP 0 "register_operand" "=f")
8355 (neg:BFP (match_operand:BFP 1 "register_operand" "f")))
8356 (clobber (reg:CC CC_REGNUM))])]
8360 ; lcxbr, lcdbr, lcebr
8361 (define_insn "*neg<mode>2_cc"
8362 [(set (reg CC_REGNUM)
8363 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
8364 (match_operand:BFP 2 "const0_operand" "")))
8365 (set (match_operand:BFP 0 "register_operand" "=f")
8366 (neg:BFP (match_dup 1)))]
8367 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
8369 [(set_attr "op_type" "RRE")
8370 (set_attr "type" "fsimp<mode>")])
8372 ; lcxbr, lcdbr, lcebr
8373 (define_insn "*neg<mode>2_cconly"
8374 [(set (reg CC_REGNUM)
8375 (compare (neg:BFP (match_operand:BFP 1 "register_operand" "f"))
8376 (match_operand:BFP 2 "const0_operand" "")))
8377 (clobber (match_scratch:BFP 0 "=f"))]
8378 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
8380 [(set_attr "op_type" "RRE")
8381 (set_attr "type" "fsimp<mode>")])
8384 (define_insn "*neg<mode>2_nocc"
8385 [(set (match_operand:FP 0 "register_operand" "=f")
8386 (neg:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
8389 [(set_attr "op_type" "RRE")
8390 (set_attr "type" "fsimp<mode>")])
8392 ; lcxbr, lcdbr, lcebr
8393 ; FIXME: wflcdb does not clobber cc
8394 (define_insn "*neg<mode>2"
8395 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8396 (neg:BFP (match_operand:BFP 1 "register_operand" "f,v")))
8397 (clobber (reg:CC CC_REGNUM))]
8402 [(set_attr "op_type" "RRE,VRR")
8403 (set_attr "cpu_facility" "*,vx")
8404 (set_attr "type" "fsimp<mode>,*")
8405 (set_attr "enabled" "*,<DFDI>")])
8409 ;;- Absolute value instructions.
8413 ; abs(di|si)2 instruction pattern(s).
8416 (define_insn "*absdi2_sign_cc"
8417 [(set (reg CC_REGNUM)
8418 (compare (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
8419 (match_operand:SI 1 "register_operand" "d") 0)
8420 (const_int 32)) (const_int 32)))
8422 (set (match_operand:DI 0 "register_operand" "=d")
8423 (abs:DI (sign_extend:DI (match_dup 1))))]
8424 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
8426 [(set_attr "op_type" "RRE")
8427 (set_attr "z10prop" "z10_c")])
8429 (define_insn "*absdi2_sign"
8430 [(set (match_operand:DI 0 "register_operand" "=d")
8431 (abs:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "d"))))
8432 (clobber (reg:CC CC_REGNUM))]
8435 [(set_attr "op_type" "RRE")
8436 (set_attr "z10prop" "z10_c")])
8439 (define_insn "*abs<mode>2_cc"
8440 [(set (reg CC_REGNUM)
8441 (compare (abs:GPR (match_operand:DI 1 "register_operand" "d"))
8443 (set (match_operand:GPR 0 "register_operand" "=d")
8444 (abs:GPR (match_dup 1)))]
8445 "s390_match_ccmode (insn, CCAmode)"
8447 [(set_attr "op_type" "RR<E>")
8448 (set_attr "z10prop" "z10_c")])
8451 (define_insn "*abs<mode>2_cconly"
8452 [(set (reg CC_REGNUM)
8453 (compare (abs:GPR (match_operand:GPR 1 "register_operand" "d"))
8455 (clobber (match_scratch:GPR 0 "=d"))]
8456 "s390_match_ccmode (insn, CCAmode)"
8458 [(set_attr "op_type" "RR<E>")
8459 (set_attr "z10prop" "z10_c")])
8462 (define_insn "abs<mode>2"
8463 [(set (match_operand:GPR 0 "register_operand" "=d")
8464 (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
8465 (clobber (reg:CC CC_REGNUM))]
8468 [(set_attr "op_type" "RR<E>")
8469 (set_attr "z10prop" "z10_c")])
8472 ; abs(df|sf)2 instruction pattern(s).
8475 (define_expand "abs<mode>2"
8477 [(set (match_operand:BFP 0 "register_operand" "=f")
8478 (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
8479 (clobber (reg:CC CC_REGNUM))])]
8483 ; lpxbr, lpdbr, lpebr
8484 (define_insn "*abs<mode>2_cc"
8485 [(set (reg CC_REGNUM)
8486 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
8487 (match_operand:BFP 2 "const0_operand" "")))
8488 (set (match_operand:BFP 0 "register_operand" "=f")
8489 (abs:BFP (match_dup 1)))]
8490 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
8492 [(set_attr "op_type" "RRE")
8493 (set_attr "type" "fsimp<mode>")])
8495 ; lpxbr, lpdbr, lpebr
8496 (define_insn "*abs<mode>2_cconly"
8497 [(set (reg CC_REGNUM)
8498 (compare (abs:BFP (match_operand:BFP 1 "register_operand" "f"))
8499 (match_operand:BFP 2 "const0_operand" "")))
8500 (clobber (match_scratch:BFP 0 "=f"))]
8501 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
8503 [(set_attr "op_type" "RRE")
8504 (set_attr "type" "fsimp<mode>")])
8507 (define_insn "*abs<mode>2_nocc"
8508 [(set (match_operand:FP 0 "register_operand" "=f")
8509 (abs:FP (match_operand:FP 1 "register_operand" "<fT0>")))]
8512 [(set_attr "op_type" "RRE")
8513 (set_attr "type" "fsimp<mode>")])
8515 ; lpxbr, lpdbr, lpebr
8516 ; FIXME: wflpdb does not clobber cc
8517 (define_insn "*abs<mode>2"
8518 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8519 (abs:BFP (match_operand:BFP 1 "register_operand" "f,v")))
8520 (clobber (reg:CC CC_REGNUM))]
8525 [(set_attr "op_type" "RRE,VRR")
8526 (set_attr "cpu_facility" "*,vx")
8527 (set_attr "type" "fsimp<mode>,*")
8528 (set_attr "enabled" "*,<DFDI>")])
8532 ;;- Negated absolute value instructions
8539 (define_insn "*negabsdi2_sign_cc"
8540 [(set (reg CC_REGNUM)
8541 (compare (neg:DI (abs:DI (ashiftrt:DI (ashift:DI (subreg:DI
8542 (match_operand:SI 1 "register_operand" "d") 0)
8543 (const_int 32)) (const_int 32))))
8545 (set (match_operand:DI 0 "register_operand" "=d")
8546 (neg:DI (abs:DI (sign_extend:DI (match_dup 1)))))]
8547 "TARGET_ZARCH && s390_match_ccmode (insn, CCAmode)"
8549 [(set_attr "op_type" "RRE")
8550 (set_attr "z10prop" "z10_c")])
8552 (define_insn "*negabsdi2_sign"
8553 [(set (match_operand:DI 0 "register_operand" "=d")
8554 (neg:DI (abs:DI (sign_extend:DI
8555 (match_operand:SI 1 "register_operand" "d")))))
8556 (clobber (reg:CC CC_REGNUM))]
8559 [(set_attr "op_type" "RRE")
8560 (set_attr "z10prop" "z10_c")])
8563 (define_insn "*negabs<mode>2_cc"
8564 [(set (reg CC_REGNUM)
8565 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
8567 (set (match_operand:GPR 0 "register_operand" "=d")
8568 (neg:GPR (abs:GPR (match_dup 1))))]
8569 "s390_match_ccmode (insn, CCAmode)"
8571 [(set_attr "op_type" "RR<E>")
8572 (set_attr "z10prop" "z10_c")])
8575 (define_insn "*negabs<mode>2_cconly"
8576 [(set (reg CC_REGNUM)
8577 (compare (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d")))
8579 (clobber (match_scratch:GPR 0 "=d"))]
8580 "s390_match_ccmode (insn, CCAmode)"
8582 [(set_attr "op_type" "RR<E>")
8583 (set_attr "z10prop" "z10_c")])
8586 (define_insn "*negabs<mode>2"
8587 [(set (match_operand:GPR 0 "register_operand" "=d")
8588 (neg:GPR (abs:GPR (match_operand:GPR 1 "register_operand" "d"))))
8589 (clobber (reg:CC CC_REGNUM))]
8592 [(set_attr "op_type" "RR<E>")
8593 (set_attr "z10prop" "z10_c")])
8599 ; lnxbr, lndbr, lnebr
8600 (define_insn "*negabs<mode>2_cc"
8601 [(set (reg CC_REGNUM)
8602 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
8603 (match_operand:BFP 2 "const0_operand" "")))
8604 (set (match_operand:BFP 0 "register_operand" "=f")
8605 (neg:BFP (abs:BFP (match_dup 1))))]
8606 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
8608 [(set_attr "op_type" "RRE")
8609 (set_attr "type" "fsimp<mode>")])
8611 ; lnxbr, lndbr, lnebr
8612 (define_insn "*negabs<mode>2_cconly"
8613 [(set (reg CC_REGNUM)
8614 (compare (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f")))
8615 (match_operand:BFP 2 "const0_operand" "")))
8616 (clobber (match_scratch:BFP 0 "=f"))]
8617 "s390_match_ccmode (insn, CCSmode) && TARGET_HARD_FLOAT"
8619 [(set_attr "op_type" "RRE")
8620 (set_attr "type" "fsimp<mode>")])
8623 (define_insn "*negabs<mode>2_nocc"
8624 [(set (match_operand:FP 0 "register_operand" "=f")
8625 (neg:FP (abs:FP (match_operand:BFP 1 "register_operand" "<fT0>"))))]
8628 [(set_attr "op_type" "RRE")
8629 (set_attr "type" "fsimp<mode>")])
8631 ; lnxbr, lndbr, lnebr
8632 ; FIXME: wflndb does not clobber cc
8633 (define_insn "*negabs<mode>2"
8634 [(set (match_operand:BFP 0 "register_operand" "=f,v")
8635 (neg:BFP (abs:BFP (match_operand:BFP 1 "register_operand" "f,v"))))
8636 (clobber (reg:CC CC_REGNUM))]
8641 [(set_attr "op_type" "RRE,VRR")
8642 (set_attr "cpu_facility" "*,vx")
8643 (set_attr "type" "fsimp<mode>,*")
8644 (set_attr "enabled" "*,<DFDI>")])
8647 ;;- Square root instructions.
8651 ; sqrt(df|sf)2 instruction pattern(s).
8654 ; sqxbr, sqdbr, sqebr, sqdb, sqeb
8655 (define_insn "sqrt<mode>2"
8656 [(set (match_operand:BFP 0 "register_operand" "=f,f,v")
8657 (sqrt:BFP (match_operand:BFP 1 "general_operand" "f,R,v")))]
8663 [(set_attr "op_type" "RRE,RXE,VRR")
8664 (set_attr "type" "fsqrt<mode>")
8665 (set_attr "cpu_facility" "*,*,vx")
8666 (set_attr "enabled" "*,<DSF>,<DFDI>")])
8670 ;;- One complement instructions.
8674 ; one_cmpl(di|si|hi|qi)2 instruction pattern(s).
8677 (define_expand "one_cmpl<mode>2"
8679 [(set (match_operand:INT 0 "register_operand" "")
8680 (xor:INT (match_operand:INT 1 "register_operand" "")
8682 (clobber (reg:CC CC_REGNUM))])]
8688 ;; Find leftmost bit instructions.
8691 (define_expand "clzdi2"
8692 [(set (match_operand:DI 0 "register_operand" "=d")
8693 (clz:DI (match_operand:DI 1 "register_operand" "d")))]
8694 "TARGET_EXTIMM && TARGET_ZARCH"
8698 rtx wide_reg = gen_reg_rtx (TImode);
8699 rtx msb = gen_rtx_CONST_INT (DImode, HOST_WIDE_INT_1U << 63);
8701 clz_equal = gen_rtx_CLZ (DImode, operands[1]);
8703 emit_insn (gen_clztidi2 (wide_reg, operands[1], msb));
8705 insn = emit_move_insn (operands[0], gen_highpart (DImode, wide_reg));
8706 set_unique_reg_note (insn, REG_EQUAL, clz_equal);
8711 (define_insn "clztidi2"
8712 [(set (match_operand:TI 0 "register_operand" "=d")
8716 (xor:DI (match_operand:DI 1 "register_operand" "d")
8717 (lshiftrt (match_operand:DI 2 "const_int_operand" "")
8718 (subreg:SI (clz:DI (match_dup 1)) 4))))
8721 (zero_extend:TI (clz:DI (match_dup 1)))))
8722 (clobber (reg:CC CC_REGNUM))]
8723 "UINTVAL (operands[2]) == HOST_WIDE_INT_1U << 63
8724 && TARGET_EXTIMM && TARGET_ZARCH"
8726 [(set_attr "op_type" "RRE")])
8730 ;;- Rotate instructions.
8734 ; rotl(di|si)3 instruction pattern(s).
8737 (define_expand "rotl<mode>3"
8738 [(set (match_operand:GPR 0 "register_operand" "")
8739 (rotate:GPR (match_operand:GPR 1 "register_operand" "")
8740 (match_operand:SI 2 "nonmemory_operand" "")))]
8745 (define_insn "*rotl<mode>3<addr_style_op><masked_op>"
8746 [(set (match_operand:GPR 0 "register_operand" "=d")
8747 (rotate:GPR (match_operand:GPR 1 "register_operand" "d")
8748 (match_operand:SI 2 "nonmemory_operand" "an")))]
8750 "rll<g>\t%0,%1,<addr_style_op_ops>"
8751 [(set_attr "op_type" "RSE")
8752 (set_attr "atype" "reg")
8753 (set_attr "z10prop" "z10_super_E1")])
8757 ;;- Shift instructions.
8761 ; (ashl|lshr)(di|si)3 instruction pattern(s).
8762 ; Left shifts and logical right shifts
8764 (define_expand "<shift><mode>3"
8765 [(set (match_operand:DSI 0 "register_operand" "")
8766 (SHIFT:DSI (match_operand:DSI 1 "register_operand" "")
8767 (match_operand:SI 2 "nonmemory_operand" "")))]
8771 ; ESA 64 bit register pair shift with reg or imm shift count
8773 (define_insn "*<shift>di3_31<addr_style_op><masked_op>"
8774 [(set (match_operand:DI 0 "register_operand" "=d")
8775 (SHIFT:DI (match_operand:DI 1 "register_operand" "0")
8776 (match_operand:SI 2 "nonmemory_operand" "an")))]
8778 "s<lr>dl\t%0,<addr_style_op_ops>"
8779 [(set_attr "op_type" "RS")
8780 (set_attr "atype" "reg")
8781 (set_attr "z196prop" "z196_cracked")])
8784 ; 64 bit register shift with reg or imm shift count
8785 ; sll, srl, sllg, srlg, sllk, srlk
8786 (define_insn "*<shift><mode>3<addr_style_op><masked_op>"
8787 [(set (match_operand:GPR 0 "register_operand" "=d, d")
8788 (SHIFT:GPR (match_operand:GPR 1 "register_operand" "<d0>, d")
8789 (match_operand:SI 2 "nonmemory_operand" "an,an")))]
8792 s<lr>l<g>\t%0,<1><addr_style_op_ops>
8793 s<lr>l<gk>\t%0,%1,<addr_style_op_ops>"
8794 [(set_attr "op_type" "RS<E>,RSY")
8795 (set_attr "atype" "reg,reg")
8796 (set_attr "cpu_facility" "*,z196")
8797 (set_attr "z10prop" "z10_super_E1,*")])
8800 ; ashr(di|si)3 instruction pattern(s).
8801 ; Arithmetic right shifts
8803 (define_expand "ashr<mode>3"
8805 [(set (match_operand:DSI 0 "register_operand" "")
8806 (ashiftrt:DSI (match_operand:DSI 1 "register_operand" "")
8807 (match_operand:SI 2 "nonmemory_operand" "")))
8808 (clobber (reg:CC CC_REGNUM))])]
8812 ; FIXME: The number of alternatives is doubled here to match the fix
8813 ; number of 2 in the subst pattern for the (clobber (match_scratch...
8814 ; The right fix should be to support match_scratch in the output
8815 ; pattern of a define_subst.
8816 (define_insn "*ashrdi3_31<addr_style_op_cc><masked_op_cc><setcc><cconly>"
8817 [(set (match_operand:DI 0 "register_operand" "=d, d")
8818 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0, 0")
8819 (match_operand:SI 2 "nonmemory_operand" "an,an")))
8820 (clobber (reg:CC CC_REGNUM))]
8823 srda\t%0,<addr_style_op_cc_ops>
8824 srda\t%0,<addr_style_op_cc_ops>"
8825 [(set_attr "op_type" "RS")
8826 (set_attr "atype" "reg")])
8830 (define_insn "*ashr<mode>3<addr_style_op_cc><masked_op_cc><setcc><cconly>"
8831 [(set (match_operand:GPR 0 "register_operand" "=d, d")
8832 (ashiftrt:GPR (match_operand:GPR 1 "register_operand" "<d0>, d")
8833 (match_operand:SI 2 "nonmemory_operand" "an,an")))
8834 (clobber (reg:CC CC_REGNUM))]
8837 sra<g>\t%0,<1><addr_style_op_cc_ops>
8838 sra<gk>\t%0,%1,<addr_style_op_cc_ops>"
8839 [(set_attr "op_type" "RS<E>,RSY")
8840 (set_attr "atype" "reg")
8841 (set_attr "cpu_facility" "*,z196")
8842 (set_attr "z10prop" "z10_super_E1,*")])
8846 ;; Branch instruction patterns.
8849 (define_expand "cbranch<mode>4"
8851 (if_then_else (match_operator 0 "comparison_operator"
8852 [(match_operand:GPR 1 "register_operand" "")
8853 (match_operand:GPR 2 "general_operand" "")])
8854 (label_ref (match_operand 3 "" ""))
8857 "s390_emit_jump (operands[3],
8858 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8861 (define_expand "cbranch<mode>4"
8863 (if_then_else (match_operator 0 "comparison_operator"
8864 [(match_operand:FP 1 "register_operand" "")
8865 (match_operand:FP 2 "general_operand" "")])
8866 (label_ref (match_operand 3 "" ""))
8869 "s390_emit_jump (operands[3],
8870 s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
8873 (define_expand "cbranchcc4"
8875 (if_then_else (match_operator 0 "s390_comparison"
8876 [(match_operand 1 "cc_reg_operand" "")
8877 (match_operand 2 "const_int_operand" "")])
8878 (label_ref (match_operand 3 "" ""))
8885 ;;- Conditional jump instructions.
8888 (define_insn "*cjump_64"
8891 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8892 (match_operand 2 "const_int_operand" "")])
8893 (label_ref (match_operand 0 "" ""))
8897 if (get_attr_length (insn) == 4)
8900 return "jg%C1\t%l0";
8902 [(set_attr "op_type" "RI")
8903 (set_attr "type" "branch")
8904 (set (attr "length")
8905 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8906 (const_int 4) (const_int 6)))])
8908 (define_insn "*cjump_31"
8911 (match_operator 1 "s390_comparison" [(reg CC_REGNUM)
8912 (match_operand 2 "const_int_operand" "")])
8913 (label_ref (match_operand 0 "" ""))
8917 gcc_assert (get_attr_length (insn) == 4);
8920 [(set_attr "op_type" "RI")
8921 (set_attr "type" "branch")
8922 (set (attr "length")
8923 (if_then_else (not (match_test "flag_pic"))
8924 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8925 (const_int 4) (const_int 6))
8926 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8927 (const_int 4) (const_int 8))))])
8929 (define_insn "*cjump_long"
8932 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8933 (match_operand 0 "address_operand" "ZQZR")
8937 if (get_attr_op_type (insn) == OP_TYPE_RR)
8942 [(set (attr "op_type")
8943 (if_then_else (match_operand 0 "register_operand" "")
8944 (const_string "RR") (const_string "RX")))
8945 (set_attr "type" "branch")
8946 (set_attr "atype" "agen")])
8948 ;; A conditional return instruction.
8949 (define_insn "*c<code>"
8952 (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8955 "s390_can_use_<code>_insn ()"
8957 [(set_attr "op_type" "RR")
8958 (set_attr "type" "jsr")
8959 (set_attr "atype" "agen")])
8962 ;;- Negated conditional jump instructions.
8965 (define_insn "*icjump_64"
8968 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8970 (label_ref (match_operand 0 "" ""))))]
8973 if (get_attr_length (insn) == 4)
8976 return "jg%D1\t%l0";
8978 [(set_attr "op_type" "RI")
8979 (set_attr "type" "branch")
8980 (set (attr "length")
8981 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
8982 (const_int 4) (const_int 6)))])
8984 (define_insn "*icjump_31"
8987 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
8989 (label_ref (match_operand 0 "" ""))))]
8992 gcc_assert (get_attr_length (insn) == 4);
8995 [(set_attr "op_type" "RI")
8996 (set_attr "type" "branch")
8997 (set (attr "length")
8998 (if_then_else (not (match_test "flag_pic"))
8999 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9000 (const_int 4) (const_int 6))
9001 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9002 (const_int 4) (const_int 8))))])
9004 (define_insn "*icjump_long"
9007 (match_operator 1 "s390_comparison" [(reg CC_REGNUM) (const_int 0)])
9009 (match_operand 0 "address_operand" "ZQZR")))]
9012 if (get_attr_op_type (insn) == OP_TYPE_RR)
9017 [(set (attr "op_type")
9018 (if_then_else (match_operand 0 "register_operand" "")
9019 (const_string "RR") (const_string "RX")))
9020 (set_attr "type" "branch")
9021 (set_attr "atype" "agen")])
9024 ;;- Trap instructions.
9028 [(trap_if (const_int 1) (const_int 0))]
9031 [(set_attr "op_type" "RI")
9032 (set_attr "type" "branch")])
9034 (define_expand "ctrap<mode>4"
9035 [(trap_if (match_operator 0 "comparison_operator"
9036 [(match_operand:GPR 1 "register_operand" "")
9037 (match_operand:GPR 2 "general_operand" "")])
9038 (match_operand 3 "const0_operand" ""))]
9041 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
9042 operands[1], operands[2]);
9043 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
9047 (define_expand "ctrap<mode>4"
9048 [(trap_if (match_operator 0 "comparison_operator"
9049 [(match_operand:FP 1 "register_operand" "")
9050 (match_operand:FP 2 "general_operand" "")])
9051 (match_operand 3 "const0_operand" ""))]
9054 rtx cond = s390_emit_compare (GET_CODE (operands[0]),
9055 operands[1], operands[2]);
9056 emit_insn (gen_condtrap (cond, XEXP (cond, 0)));
9060 (define_insn "condtrap"
9061 [(trap_if (match_operator 0 "s390_comparison"
9062 [(match_operand 1 "cc_reg_operand" "c")
9067 [(set_attr "op_type" "RI")
9068 (set_attr "type" "branch")])
9070 ; crt, cgrt, cit, cgit
9071 (define_insn "*cmp_and_trap_signed_int<mode>"
9072 [(trap_if (match_operator 0 "s390_signed_integer_comparison"
9073 [(match_operand:GPR 1 "register_operand" "d,d")
9074 (match_operand:GPR 2 "nonmemory_operand" "d,K")])
9080 [(set_attr "op_type" "RRF,RIE")
9081 (set_attr "type" "branch")
9082 (set_attr "z10prop" "z10_super_c,z10_super")])
9084 ; clrt, clgrt, clfit, clgit, clt, clgt
9085 (define_insn "*cmp_and_trap_unsigned_int<mode>"
9086 [(trap_if (match_operator 0 "s390_unsigned_integer_comparison"
9087 [(match_operand:GPR 1 "register_operand" "d,d,d")
9088 (match_operand:GPR 2 "general_operand" "d,D,T")])
9095 [(set_attr "op_type" "RRF,RIE,RSY")
9096 (set_attr "type" "branch")
9097 (set_attr "z10prop" "z10_super_c,z10_super,*")
9098 (set_attr "cpu_facility" "z10,z10,zEC12")])
9101 (define_insn "*load_and_trap<mode>"
9102 [(trap_if (eq (match_operand:GPR 0 "memory_operand" "T")
9105 (set (match_operand:GPR 1 "register_operand" "=d")
9109 [(set_attr "op_type" "RXY")])
9113 ;;- Loop instructions.
9115 ;; This is all complicated by the fact that since this is a jump insn
9116 ;; we must handle our own output reloads.
9120 ; This splitter will be matched by combine and has to add the 2 moves
9121 ; necessary to load the compare and the increment values into a
9122 ; register pair as needed by brxle.
9124 (define_insn_and_split "*brx_stage1_<GPR:mode>"
9127 (match_operator 6 "s390_brx_operator"
9128 [(plus:GPR (match_operand:GPR 1 "register_operand" "")
9129 (match_operand:GPR 2 "general_operand" ""))
9130 (match_operand:GPR 3 "register_operand" "")])
9131 (label_ref (match_operand 0 "" ""))
9133 (set (match_operand:GPR 4 "nonimmediate_operand" "")
9134 (plus:GPR (match_dup 1) (match_dup 2)))
9135 (clobber (match_scratch:GPR 5 ""))]
9138 "!reload_completed && !reload_in_progress"
9139 [(set (match_dup 7) (match_dup 2)) ; the increment
9140 (set (match_dup 8) (match_dup 3)) ; the comparison value
9141 (parallel [(set (pc)
9144 [(plus:GPR (match_dup 1) (match_dup 7))
9146 (label_ref (match_dup 0))
9149 (plus:GPR (match_dup 1) (match_dup 7)))
9150 (clobber (match_dup 5))
9151 (clobber (reg:CC CC_REGNUM))])]
9153 rtx dreg = gen_reg_rtx (word_mode == DImode ? TImode : DImode);
9154 operands[7] = gen_lowpart (<GPR:MODE>mode,
9155 gen_highpart (word_mode, dreg));
9156 operands[8] = gen_lowpart (<GPR:MODE>mode,
9157 gen_lowpart (word_mode, dreg));
9162 (define_insn_and_split "*brxg_64bit"
9165 (match_operator 5 "s390_brx_operator"
9166 [(plus:DI (match_operand:DI 1 "register_operand" "d,d,d")
9167 (subreg:DI (match_operand:TI 2 "register_operand" "d,d,d") 0))
9168 (subreg:DI (match_dup 2) 8)])
9169 (label_ref (match_operand 0 "" ""))
9171 (set (match_operand:DI 3 "nonimmediate_operand" "=1,?X,?X")
9172 (plus:DI (match_dup 1)
9173 (subreg:DI (match_dup 2) 0)))
9174 (clobber (match_scratch:DI 4 "=X,&1,&?d"))
9175 (clobber (reg:CC CC_REGNUM))]
9178 if (which_alternative != 0)
9180 else if (get_attr_length (insn) == 6)
9181 return "brx%E5g\t%1,%2,%l0";
9183 return "agr\t%1,%2\;cgr\t%1,%M2\;jg%C5\t%l0";
9185 "&& reload_completed
9186 && (!REG_P (operands[3])
9187 || !rtx_equal_p (operands[1], operands[3]))"
9188 [(set (match_dup 4) (match_dup 1))
9189 (parallel [(set (match_dup 4) (plus:DI (match_dup 4) (subreg:DI (match_dup 2) 0)))
9190 (clobber (reg:CC CC_REGNUM))])
9191 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:DI (match_dup 2) 8)))
9192 (set (match_dup 3) (match_dup 4))
9193 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9194 (label_ref (match_dup 0))
9197 [(set_attr "op_type" "RIE")
9198 (set_attr "type" "branch")
9199 (set (attr "length")
9200 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9201 (const_int 6) (const_int 16)))])
9205 (define_insn_and_split "*brx_64bit"
9208 (match_operator 5 "s390_brx_operator"
9209 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
9210 (subreg:SI (match_operand:TI 2 "register_operand" "d,d,d") 4))
9211 (subreg:SI (match_dup 2) 12)])
9212 (label_ref (match_operand 0 "" ""))
9214 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
9215 (plus:SI (match_dup 1)
9216 (subreg:SI (match_dup 2) 4)))
9217 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
9218 (clobber (reg:CC CC_REGNUM))]
9221 if (which_alternative != 0)
9223 else if (get_attr_length (insn) == 6)
9224 return "brx%C5\t%1,%2,%l0";
9226 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
9228 "&& reload_completed
9229 && (!REG_P (operands[3])
9230 || !rtx_equal_p (operands[1], operands[3]))"
9231 [(set (match_dup 4) (match_dup 1))
9232 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 4)))
9233 (clobber (reg:CC CC_REGNUM))])
9234 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 12)))
9235 (set (match_dup 3) (match_dup 4))
9236 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9237 (label_ref (match_dup 0))
9240 [(set_attr "op_type" "RSI")
9241 (set_attr "type" "branch")
9242 (set (attr "length")
9243 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9244 (const_int 6) (const_int 14)))])
9248 (define_insn_and_split "*brx_31bit"
9251 (match_operator 5 "s390_brx_operator"
9252 [(plus:SI (match_operand:SI 1 "register_operand" "d,d,d")
9253 (subreg:SI (match_operand:DI 2 "register_operand" "d,d,d") 0))
9254 (subreg:SI (match_dup 2) 4)])
9255 (label_ref (match_operand 0 "" ""))
9257 (set (match_operand:SI 3 "nonimmediate_operand" "=1,?X,?X")
9258 (plus:SI (match_dup 1)
9259 (subreg:SI (match_dup 2) 0)))
9260 (clobber (match_scratch:SI 4 "=X,&1,&?d"))
9261 (clobber (reg:CC CC_REGNUM))]
9262 "!TARGET_ZARCH && TARGET_CPU_ZARCH"
9264 if (which_alternative != 0)
9266 else if (get_attr_length (insn) == 6)
9267 return "brx%C5\t%1,%2,%l0";
9269 return "ar\t%1,%2\;cr\t%1,%M2\;jg%C5\t%l0";
9271 "&& reload_completed
9272 && (!REG_P (operands[3])
9273 || !rtx_equal_p (operands[1], operands[3]))"
9274 [(set (match_dup 4) (match_dup 1))
9275 (parallel [(set (match_dup 4) (plus:SI (match_dup 4) (subreg:SI (match_dup 2) 0)))
9276 (clobber (reg:CC CC_REGNUM))])
9277 (set (reg:CCS CC_REGNUM) (compare:CCS (match_dup 4) (subreg:SI (match_dup 2) 4)))
9278 (set (match_dup 3) (match_dup 4))
9279 (set (pc) (if_then_else (match_op_dup 5 [(reg:CCS CC_REGNUM) (const_int 0)])
9280 (label_ref (match_dup 0))
9283 [(set_attr "op_type" "RSI")
9284 (set_attr "type" "branch")
9285 (set (attr "length")
9286 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9287 (const_int 6) (const_int 14)))])
9292 (define_expand "doloop_end"
9293 [(use (match_operand 0 "" "")) ; loop pseudo
9294 (use (match_operand 1 "" ""))] ; label
9297 if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
9298 emit_jump_insn (gen_doloop_si31 (operands[1], operands[0], operands[0]));
9299 else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
9300 emit_jump_insn (gen_doloop_si64 (operands[1], operands[0], operands[0]));
9301 else if (GET_MODE (operands[0]) == DImode && TARGET_ZARCH)
9302 emit_jump_insn (gen_doloop_di (operands[1], operands[0], operands[0]));
9309 (define_insn_and_split "doloop_si64"
9312 (ne (match_operand:SI 1 "register_operand" "d,d,d")
9314 (label_ref (match_operand 0 "" ""))
9316 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
9317 (plus:SI (match_dup 1) (const_int -1)))
9318 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
9319 (clobber (reg:CC CC_REGNUM))]
9322 if (which_alternative != 0)
9324 else if (get_attr_length (insn) == 4)
9325 return "brct\t%1,%l0";
9327 return "ahi\t%1,-1\;jgne\t%l0";
9329 "&& reload_completed
9330 && (! REG_P (operands[2])
9331 || ! rtx_equal_p (operands[1], operands[2]))"
9332 [(set (match_dup 3) (match_dup 1))
9333 (parallel [(set (reg:CCAN CC_REGNUM)
9334 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
9336 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
9337 (set (match_dup 2) (match_dup 3))
9338 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
9339 (label_ref (match_dup 0))
9342 [(set_attr "op_type" "RI")
9343 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9344 ; hurt us in the (rare) case of ahi.
9345 (set_attr "z10prop" "z10_super_E1")
9346 (set_attr "type" "branch")
9347 (set (attr "length")
9348 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9349 (const_int 4) (const_int 10)))])
9351 (define_insn_and_split "doloop_si31"
9354 (ne (match_operand:SI 1 "register_operand" "d,d,d")
9356 (label_ref (match_operand 0 "" ""))
9358 (set (match_operand:SI 2 "nonimmediate_operand" "=1,?X,?X")
9359 (plus:SI (match_dup 1) (const_int -1)))
9360 (clobber (match_scratch:SI 3 "=X,&1,&?d"))
9361 (clobber (reg:CC CC_REGNUM))]
9364 if (which_alternative != 0)
9366 else if (get_attr_length (insn) == 4)
9367 return "brct\t%1,%l0";
9371 "&& reload_completed
9372 && (! REG_P (operands[2])
9373 || ! rtx_equal_p (operands[1], operands[2]))"
9374 [(set (match_dup 3) (match_dup 1))
9375 (parallel [(set (reg:CCAN CC_REGNUM)
9376 (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
9378 (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
9379 (set (match_dup 2) (match_dup 3))
9380 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
9381 (label_ref (match_dup 0))
9384 [(set_attr "op_type" "RI")
9385 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9386 ; hurt us in the (rare) case of ahi.
9387 (set_attr "z10prop" "z10_super_E1")
9388 (set_attr "type" "branch")
9389 (set (attr "length")
9390 (if_then_else (not (match_test "flag_pic"))
9391 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9392 (const_int 4) (const_int 6))
9393 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9394 (const_int 4) (const_int 8))))])
9396 (define_insn "*doloop_si_long"
9399 (ne (match_operand:SI 1 "register_operand" "d")
9401 (match_operand 0 "address_operand" "ZR")
9403 (set (match_operand:SI 2 "register_operand" "=1")
9404 (plus:SI (match_dup 1) (const_int -1)))
9405 (clobber (match_scratch:SI 3 "=X"))
9406 (clobber (reg:CC CC_REGNUM))]
9409 if (get_attr_op_type (insn) == OP_TYPE_RR)
9410 return "bctr\t%1,%0";
9412 return "bct\t%1,%a0";
9414 [(set (attr "op_type")
9415 (if_then_else (match_operand 0 "register_operand" "")
9416 (const_string "RR") (const_string "RX")))
9417 (set_attr "type" "branch")
9418 (set_attr "atype" "agen")
9419 (set_attr "z10prop" "z10_c")
9420 (set_attr "z196prop" "z196_cracked")])
9422 (define_insn_and_split "doloop_di"
9425 (ne (match_operand:DI 1 "register_operand" "d,d,d")
9427 (label_ref (match_operand 0 "" ""))
9429 (set (match_operand:DI 2 "nonimmediate_operand" "=1,?X,?X")
9430 (plus:DI (match_dup 1) (const_int -1)))
9431 (clobber (match_scratch:DI 3 "=X,&1,&?d"))
9432 (clobber (reg:CC CC_REGNUM))]
9435 if (which_alternative != 0)
9437 else if (get_attr_length (insn) == 4)
9438 return "brctg\t%1,%l0";
9440 return "aghi\t%1,-1\;jgne\t%l0";
9442 "&& reload_completed
9443 && (! REG_P (operands[2])
9444 || ! rtx_equal_p (operands[1], operands[2]))"
9445 [(set (match_dup 3) (match_dup 1))
9446 (parallel [(set (reg:CCAN CC_REGNUM)
9447 (compare:CCAN (plus:DI (match_dup 3) (const_int -1))
9449 (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
9450 (set (match_dup 2) (match_dup 3))
9451 (set (pc) (if_then_else (ne (reg:CCAN CC_REGNUM) (const_int 0))
9452 (label_ref (match_dup 0))
9455 [(set_attr "op_type" "RI")
9456 ; Strictly speaking, the z10 properties are valid for brct only, however, it does not
9457 ; hurt us in the (rare) case of ahi.
9458 (set_attr "z10prop" "z10_super_E1")
9459 (set_attr "type" "branch")
9460 (set (attr "length")
9461 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9462 (const_int 4) (const_int 10)))])
9465 ;;- Unconditional jump instructions.
9469 ; jump instruction pattern(s).
9472 (define_expand "jump"
9473 [(match_operand 0 "" "")]
9475 "s390_emit_jump (operands[0], NULL_RTX); DONE;")
9477 (define_insn "*jump64"
9478 [(set (pc) (label_ref (match_operand 0 "" "")))]
9481 if (get_attr_length (insn) == 4)
9486 [(set_attr "op_type" "RI")
9487 (set_attr "type" "branch")
9488 (set (attr "length")
9489 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9490 (const_int 4) (const_int 6)))])
9492 (define_insn "*jump31"
9493 [(set (pc) (label_ref (match_operand 0 "" "")))]
9496 gcc_assert (get_attr_length (insn) == 4);
9499 [(set_attr "op_type" "RI")
9500 (set_attr "type" "branch")
9501 (set (attr "length")
9502 (if_then_else (not (match_test "flag_pic"))
9503 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9504 (const_int 4) (const_int 6))
9505 (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
9506 (const_int 4) (const_int 8))))])
9509 ; indirect-jump instruction pattern(s).
9512 (define_insn "indirect_jump"
9513 [(set (pc) (match_operand 0 "address_operand" "ZR"))]
9516 if (get_attr_op_type (insn) == OP_TYPE_RR)
9521 [(set (attr "op_type")
9522 (if_then_else (match_operand 0 "register_operand" "")
9523 (const_string "RR") (const_string "RX")))
9524 (set_attr "type" "branch")
9525 (set_attr "atype" "agen")])
9528 ; casesi instruction pattern(s).
9531 (define_insn "casesi_jump"
9532 [(set (pc) (match_operand 0 "address_operand" "ZR"))
9533 (use (label_ref (match_operand 1 "" "")))]
9536 if (get_attr_op_type (insn) == OP_TYPE_RR)
9541 [(set (attr "op_type")
9542 (if_then_else (match_operand 0 "register_operand" "")
9543 (const_string "RR") (const_string "RX")))
9544 (set_attr "type" "branch")
9545 (set_attr "atype" "agen")])
9547 (define_expand "casesi"
9548 [(match_operand:SI 0 "general_operand" "")
9549 (match_operand:SI 1 "general_operand" "")
9550 (match_operand:SI 2 "general_operand" "")
9551 (label_ref (match_operand 3 "" ""))
9552 (label_ref (match_operand 4 "" ""))]
9555 rtx index = gen_reg_rtx (SImode);
9556 rtx base = gen_reg_rtx (Pmode);
9557 rtx target = gen_reg_rtx (Pmode);
9559 emit_move_insn (index, operands[0]);
9560 emit_insn (gen_subsi3 (index, index, operands[1]));
9561 emit_cmp_and_jump_insns (index, operands[2], GTU, NULL_RTX, SImode, 1,
9564 if (Pmode != SImode)
9565 index = convert_to_mode (Pmode, index, 1);
9566 if (GET_CODE (index) != REG)
9567 index = copy_to_mode_reg (Pmode, index);
9570 emit_insn (gen_ashldi3 (index, index, GEN_INT (3)));
9572 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
9574 emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3]));
9576 index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index));
9577 emit_move_insn (target, index);
9580 target = gen_rtx_PLUS (Pmode, base, target);
9581 emit_jump_insn (gen_casesi_jump (target, operands[3]));
9588 ;;- Jump to subroutine.
9593 ; untyped call instruction pattern(s).
9596 ;; Call subroutine returning any type.
9597 (define_expand "untyped_call"
9598 [(parallel [(call (match_operand 0 "" "")
9600 (match_operand 1 "" "")
9601 (match_operand 2 "" "")])]
9606 emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx));
9608 for (i = 0; i < XVECLEN (operands[2], 0); i++)
9610 rtx set = XVECEXP (operands[2], 0, i);
9611 emit_move_insn (SET_DEST (set), SET_SRC (set));
9614 /* The optimizer does not know that the call sets the function value
9615 registers we stored in the result block. We avoid problems by
9616 claiming that all hard registers are used and clobbered at this
9618 emit_insn (gen_blockage ());
9623 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
9624 ;; all of memory. This blocks insns from being moved across this point.
9626 (define_insn "blockage"
9627 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
9630 [(set_attr "type" "none")
9631 (set_attr "length" "0")])
9637 (define_expand "sibcall"
9638 [(call (match_operand 0 "" "")
9639 (match_operand 1 "" ""))]
9642 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX, NULL_RTX);
9646 (define_insn "*sibcall_br"
9647 [(call (mem:QI (reg SIBCALL_REGNUM))
9648 (match_operand 0 "const_int_operand" "n"))]
9649 "SIBLING_CALL_P (insn)
9650 && GET_MODE (XEXP (XEXP (PATTERN (insn), 0), 0)) == Pmode"
9652 [(set_attr "op_type" "RR")
9653 (set_attr "type" "branch")
9654 (set_attr "atype" "agen")])
9656 (define_insn "*sibcall_brc"
9657 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9658 (match_operand 1 "const_int_operand" "n"))]
9659 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
9661 [(set_attr "op_type" "RI")
9662 (set_attr "type" "branch")])
9664 (define_insn "*sibcall_brcl"
9665 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9666 (match_operand 1 "const_int_operand" "n"))]
9667 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
9669 [(set_attr "op_type" "RIL")
9670 (set_attr "type" "branch")])
9673 ; sibcall_value patterns
9676 (define_expand "sibcall_value"
9677 [(set (match_operand 0 "" "")
9678 (call (match_operand 1 "" "")
9679 (match_operand 2 "" "")))]
9682 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0], NULL_RTX);
9686 (define_insn "*sibcall_value_br"
9687 [(set (match_operand 0 "" "")
9688 (call (mem:QI (reg SIBCALL_REGNUM))
9689 (match_operand 1 "const_int_operand" "n")))]
9690 "SIBLING_CALL_P (insn)
9691 && GET_MODE (XEXP (XEXP (XEXP (PATTERN (insn), 1), 0), 0)) == Pmode"
9693 [(set_attr "op_type" "RR")
9694 (set_attr "type" "branch")
9695 (set_attr "atype" "agen")])
9697 (define_insn "*sibcall_value_brc"
9698 [(set (match_operand 0 "" "")
9699 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9700 (match_operand 2 "const_int_operand" "n")))]
9701 "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC"
9703 [(set_attr "op_type" "RI")
9704 (set_attr "type" "branch")])
9706 (define_insn "*sibcall_value_brcl"
9707 [(set (match_operand 0 "" "")
9708 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9709 (match_operand 2 "const_int_operand" "n")))]
9710 "SIBLING_CALL_P (insn) && TARGET_CPU_ZARCH"
9712 [(set_attr "op_type" "RIL")
9713 (set_attr "type" "branch")])
9717 ; call instruction pattern(s).
9720 (define_expand "call"
9721 [(call (match_operand 0 "" "")
9722 (match_operand 1 "" ""))
9723 (use (match_operand 2 "" ""))]
9726 s390_emit_call (XEXP (operands[0], 0), NULL_RTX, NULL_RTX,
9727 gen_rtx_REG (Pmode, RETURN_REGNUM));
9731 (define_insn "*bras"
9732 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9733 (match_operand 1 "const_int_operand" "n"))
9734 (clobber (match_operand 2 "register_operand" "=r"))]
9735 "!SIBLING_CALL_P (insn)
9736 && TARGET_SMALL_EXEC
9737 && GET_MODE (operands[2]) == Pmode"
9739 [(set_attr "op_type" "RI")
9740 (set_attr "type" "jsr")
9741 (set_attr "z196prop" "z196_cracked")])
9743 (define_insn "*brasl"
9744 [(call (mem:QI (match_operand 0 "bras_sym_operand" "X"))
9745 (match_operand 1 "const_int_operand" "n"))
9746 (clobber (match_operand 2 "register_operand" "=r"))]
9747 "!SIBLING_CALL_P (insn)
9749 && GET_MODE (operands[2]) == Pmode"
9751 [(set_attr "op_type" "RIL")
9752 (set_attr "type" "jsr")
9753 (set_attr "z196prop" "z196_cracked")])
9755 (define_insn "*basr"
9756 [(call (mem:QI (match_operand 0 "address_operand" "ZR"))
9757 (match_operand 1 "const_int_operand" "n"))
9758 (clobber (match_operand 2 "register_operand" "=r"))]
9759 "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode"
9761 if (get_attr_op_type (insn) == OP_TYPE_RR)
9762 return "basr\t%2,%0";
9764 return "bas\t%2,%a0";
9766 [(set (attr "op_type")
9767 (if_then_else (match_operand 0 "register_operand" "")
9768 (const_string "RR") (const_string "RX")))
9769 (set_attr "type" "jsr")
9770 (set_attr "atype" "agen")
9771 (set_attr "z196prop" "z196_cracked")])
9774 ; call_value instruction pattern(s).
9777 (define_expand "call_value"
9778 [(set (match_operand 0 "" "")
9779 (call (match_operand 1 "" "")
9780 (match_operand 2 "" "")))
9781 (use (match_operand 3 "" ""))]
9784 s390_emit_call (XEXP (operands[1], 0), NULL_RTX, operands[0],
9785 gen_rtx_REG (Pmode, RETURN_REGNUM));
9789 (define_insn "*bras_r"
9790 [(set (match_operand 0 "" "")
9791 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9792 (match_operand:SI 2 "const_int_operand" "n")))
9793 (clobber (match_operand 3 "register_operand" "=r"))]
9794 "!SIBLING_CALL_P (insn)
9795 && TARGET_SMALL_EXEC
9796 && GET_MODE (operands[3]) == Pmode"
9798 [(set_attr "op_type" "RI")
9799 (set_attr "type" "jsr")
9800 (set_attr "z196prop" "z196_cracked")])
9802 (define_insn "*brasl_r"
9803 [(set (match_operand 0 "" "")
9804 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9805 (match_operand 2 "const_int_operand" "n")))
9806 (clobber (match_operand 3 "register_operand" "=r"))]
9807 "!SIBLING_CALL_P (insn)
9809 && GET_MODE (operands[3]) == Pmode"
9811 [(set_attr "op_type" "RIL")
9812 (set_attr "type" "jsr")
9813 (set_attr "z196prop" "z196_cracked")])
9815 (define_insn "*basr_r"
9816 [(set (match_operand 0 "" "")
9817 (call (mem:QI (match_operand 1 "address_operand" "ZR"))
9818 (match_operand 2 "const_int_operand" "n")))
9819 (clobber (match_operand 3 "register_operand" "=r"))]
9820 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9822 if (get_attr_op_type (insn) == OP_TYPE_RR)
9823 return "basr\t%3,%1";
9825 return "bas\t%3,%a1";
9827 [(set (attr "op_type")
9828 (if_then_else (match_operand 1 "register_operand" "")
9829 (const_string "RR") (const_string "RX")))
9830 (set_attr "type" "jsr")
9831 (set_attr "atype" "agen")
9832 (set_attr "z196prop" "z196_cracked")])
9835 ;;- Thread-local storage support.
9838 (define_expand "get_thread_pointer<mode>"
9839 [(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))]
9843 (define_expand "set_thread_pointer<mode>"
9844 [(set (reg:P TP_REGNUM) (match_operand:P 0 "nonimmediate_operand" ""))
9845 (set (reg:P TP_REGNUM) (unspec_volatile:P [(reg:P TP_REGNUM)] UNSPECV_SET_TP))]
9849 (define_insn "*set_tp"
9850 [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))]
9853 [(set_attr "type" "none")
9854 (set_attr "length" "0")])
9856 (define_insn "*tls_load_64"
9857 [(set (match_operand:DI 0 "register_operand" "=d")
9858 (unspec:DI [(match_operand:DI 1 "memory_operand" "T")
9859 (match_operand:DI 2 "" "")]
9863 [(set_attr "op_type" "RXE")
9864 (set_attr "z10prop" "z10_fwd_A3")])
9866 (define_insn "*tls_load_31"
9867 [(set (match_operand:SI 0 "register_operand" "=d,d")
9868 (unspec:SI [(match_operand:SI 1 "memory_operand" "R,T")
9869 (match_operand:SI 2 "" "")]
9875 [(set_attr "op_type" "RX,RXY")
9876 (set_attr "type" "load")
9877 (set_attr "cpu_facility" "*,longdisp")
9878 (set_attr "z10prop" "z10_fwd_A3,z10_fwd_A3")])
9880 (define_insn "*bras_tls"
9881 [(set (match_operand 0 "" "")
9882 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9883 (match_operand 2 "const_int_operand" "n")))
9884 (clobber (match_operand 3 "register_operand" "=r"))
9885 (use (match_operand 4 "" ""))]
9886 "!SIBLING_CALL_P (insn)
9887 && TARGET_SMALL_EXEC
9888 && GET_MODE (operands[3]) == Pmode"
9890 [(set_attr "op_type" "RI")
9891 (set_attr "type" "jsr")
9892 (set_attr "z196prop" "z196_cracked")])
9894 (define_insn "*brasl_tls"
9895 [(set (match_operand 0 "" "")
9896 (call (mem:QI (match_operand 1 "bras_sym_operand" "X"))
9897 (match_operand 2 "const_int_operand" "n")))
9898 (clobber (match_operand 3 "register_operand" "=r"))
9899 (use (match_operand 4 "" ""))]
9900 "!SIBLING_CALL_P (insn)
9902 && GET_MODE (operands[3]) == Pmode"
9904 [(set_attr "op_type" "RIL")
9905 (set_attr "type" "jsr")
9906 (set_attr "z196prop" "z196_cracked")])
9908 (define_insn "*basr_tls"
9909 [(set (match_operand 0 "" "")
9910 (call (mem:QI (match_operand 1 "address_operand" "ZR"))
9911 (match_operand 2 "const_int_operand" "n")))
9912 (clobber (match_operand 3 "register_operand" "=r"))
9913 (use (match_operand 4 "" ""))]
9914 "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode"
9916 if (get_attr_op_type (insn) == OP_TYPE_RR)
9917 return "basr\t%3,%1%J4";
9919 return "bas\t%3,%a1%J4";
9921 [(set (attr "op_type")
9922 (if_then_else (match_operand 1 "register_operand" "")
9923 (const_string "RR") (const_string "RX")))
9924 (set_attr "type" "jsr")
9925 (set_attr "atype" "agen")
9926 (set_attr "z196prop" "z196_cracked")])
9929 ;;- Atomic operations
9933 ; memory barrier patterns.
9936 (define_expand "mem_signal_fence"
9937 [(match_operand:SI 0 "const_int_operand")] ;; model
9940 /* The s390 memory model is strong enough not to require any
9941 barrier in order to synchronize a thread with itself. */
9945 (define_expand "mem_thread_fence"
9946 [(match_operand:SI 0 "const_int_operand")] ;; model
9949 /* Unless this is a SEQ_CST fence, the s390 memory model is strong
9950 enough not to require barriers of any kind. */
9951 if (is_mm_seq_cst (memmodel_from_int (INTVAL (operands[0]))))
9953 rtx mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
9954 MEM_VOLATILE_P (mem) = 1;
9955 emit_insn (gen_mem_thread_fence_1 (mem));
9960 ; Although bcr is superscalar on Z10, this variant will never
9961 ; become part of an execution group.
9962 ; With z196 we can make use of the fast-BCR-serialization facility.
9963 ; This allows for a slightly faster sync which is sufficient for our
9965 (define_insn "mem_thread_fence_1"
9966 [(set (match_operand:BLK 0 "" "")
9967 (unspec:BLK [(match_dup 0)] UNSPEC_MB))]
9975 [(set_attr "op_type" "RR")
9976 (set_attr "mnemonic" "bcr_flush")
9977 (set_attr "z196prop" "z196_alone")])
9980 ; atomic load/store operations
9983 ; Atomic loads need not examine the memory model at all.
9984 (define_expand "atomic_load<mode>"
9985 [(match_operand:DINT 0 "register_operand") ;; output
9986 (match_operand:DINT 1 "memory_operand") ;; memory
9987 (match_operand:SI 2 "const_int_operand")] ;; model
9990 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
9993 if (<MODE>mode == TImode)
9994 emit_insn (gen_atomic_loadti_1 (operands[0], operands[1]));
9995 else if (<MODE>mode == DImode && !TARGET_ZARCH)
9996 emit_insn (gen_atomic_loaddi_1 (operands[0], operands[1]));
9998 emit_move_insn (operands[0], operands[1]);
10002 ; Different from movdi_31 in that we want no splitters.
10003 (define_insn "atomic_loaddi_1"
10004 [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f")
10005 (unspec:DI [(match_operand:DI 1 "memory_operand" "Q,S,R,T")]
10013 [(set_attr "op_type" "RS,RSY,RS,RSY")
10014 (set_attr "cpu_facility" "*,longdisp,*,longdisp")
10015 (set_attr "type" "lm,lm,floaddf,floaddf")])
10017 (define_insn "atomic_loadti_1"
10018 [(set (match_operand:TI 0 "register_operand" "=r")
10019 (unspec:TI [(match_operand:TI 1 "memory_operand" "T")]
10023 [(set_attr "op_type" "RXY")
10024 (set_attr "type" "other")])
10026 ; Atomic stores must(?) enforce sequential consistency.
10027 (define_expand "atomic_store<mode>"
10028 [(match_operand:DINT 0 "memory_operand") ;; memory
10029 (match_operand:DINT 1 "register_operand") ;; input
10030 (match_operand:SI 2 "const_int_operand")] ;; model
10033 enum memmodel model = memmodel_from_int (INTVAL (operands[2]));
10035 if (MEM_ALIGN (operands[0]) < GET_MODE_BITSIZE (GET_MODE (operands[0])))
10038 if (<MODE>mode == TImode)
10039 emit_insn (gen_atomic_storeti_1 (operands[0], operands[1]));
10040 else if (<MODE>mode == DImode && !TARGET_ZARCH)
10041 emit_insn (gen_atomic_storedi_1 (operands[0], operands[1]));
10043 emit_move_insn (operands[0], operands[1]);
10044 if (is_mm_seq_cst (model))
10045 emit_insn (gen_mem_thread_fence (operands[2]));
10049 ; Different from movdi_31 in that we want no splitters.
10050 (define_insn "atomic_storedi_1"
10051 [(set (match_operand:DI 0 "memory_operand" "=Q,S,R,T")
10052 (unspec:DI [(match_operand:DI 1 "register_operand" "d,d,!*f,!*f")]
10060 [(set_attr "op_type" "RS,RSY,RS,RSY")
10061 (set_attr "cpu_facility" "*,longdisp,*,longdisp")
10062 (set_attr "type" "stm,stm,fstoredf,fstoredf")])
10064 (define_insn "atomic_storeti_1"
10065 [(set (match_operand:TI 0 "memory_operand" "=T")
10066 (unspec:TI [(match_operand:TI 1 "register_operand" "r")]
10070 [(set_attr "op_type" "RXY")
10071 (set_attr "type" "other")])
10074 ; compare and swap patterns.
10077 (define_expand "atomic_compare_and_swap<mode>"
10078 [(match_operand:SI 0 "register_operand") ;; bool success output
10079 (match_operand:DGPR 1 "nonimmediate_operand");; oldval output
10080 (match_operand:DGPR 2 "memory_operand") ;; memory
10081 (match_operand:DGPR 3 "register_operand") ;; expected intput
10082 (match_operand:DGPR 4 "register_operand") ;; newval intput
10083 (match_operand:SI 5 "const_int_operand") ;; is_weak
10084 (match_operand:SI 6 "const_int_operand") ;; success model
10085 (match_operand:SI 7 "const_int_operand")] ;; failure model
10088 rtx cc, cmp, output = operands[1];
10090 if (!register_operand (output, <MODE>mode))
10091 output = gen_reg_rtx (<MODE>mode);
10093 if (MEM_ALIGN (operands[2]) < GET_MODE_BITSIZE (GET_MODE (operands[2])))
10096 emit_insn (gen_atomic_compare_and_swap<mode>_internal
10097 (output, operands[2], operands[3], operands[4]));
10099 /* We deliberately accept non-register operands in the predicate
10100 to ensure the write back to the output operand happens *before*
10101 the store-flags code below. This makes it easier for combine
10102 to merge the store-flags code with a potential test-and-branch
10103 pattern following (immediately!) afterwards. */
10104 if (output != operands[1])
10105 emit_move_insn (operands[1], output);
10107 cc = gen_rtx_REG (CCZ1mode, CC_REGNUM);
10108 cmp = gen_rtx_EQ (SImode, cc, const0_rtx);
10109 emit_insn (gen_cstorecc4 (operands[0], cmp, cc, const0_rtx));
10113 (define_expand "atomic_compare_and_swap<mode>"
10114 [(match_operand:SI 0 "register_operand") ;; bool success output
10115 (match_operand:HQI 1 "nonimmediate_operand") ;; oldval output
10116 (match_operand:HQI 2 "memory_operand") ;; memory
10117 (match_operand:HQI 3 "general_operand") ;; expected intput
10118 (match_operand:HQI 4 "general_operand") ;; newval intput
10119 (match_operand:SI 5 "const_int_operand") ;; is_weak
10120 (match_operand:SI 6 "const_int_operand") ;; success model
10121 (match_operand:SI 7 "const_int_operand")] ;; failure model
10124 s390_expand_cs_hqi (<MODE>mode, operands[0], operands[1], operands[2],
10125 operands[3], operands[4], INTVAL (operands[5]));
10129 (define_expand "atomic_compare_and_swap<mode>_internal"
10131 [(set (match_operand:DGPR 0 "register_operand")
10132 (match_operand:DGPR 1 "memory_operand"))
10134 (unspec_volatile:DGPR
10136 (match_operand:DGPR 2 "register_operand")
10137 (match_operand:DGPR 3 "register_operand")]
10139 (set (reg:CCZ1 CC_REGNUM)
10140 (compare:CCZ1 (match_dup 1) (match_dup 2)))])]
10144 (define_insn "*atomic_compare_and_swap<mode>_1"
10145 [(set (match_operand:TDI 0 "register_operand" "=r")
10146 (match_operand:TDI 1 "memory_operand" "+S"))
10148 (unspec_volatile:TDI
10150 (match_operand:TDI 2 "register_operand" "0")
10151 (match_operand:TDI 3 "register_operand" "r")]
10153 (set (reg:CCZ1 CC_REGNUM)
10154 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
10156 "c<td>sg\t%0,%3,%S1"
10157 [(set_attr "op_type" "RSY")
10158 (set_attr "type" "sem")])
10161 (define_insn "*atomic_compare_and_swapdi_2"
10162 [(set (match_operand:DI 0 "register_operand" "=r,r")
10163 (match_operand:DI 1 "memory_operand" "+Q,S"))
10165 (unspec_volatile:DI
10167 (match_operand:DI 2 "register_operand" "0,0")
10168 (match_operand:DI 3 "register_operand" "r,r")]
10170 (set (reg:CCZ1 CC_REGNUM)
10171 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
10176 [(set_attr "op_type" "RS,RSY")
10177 (set_attr "cpu_facility" "*,longdisp")
10178 (set_attr "type" "sem")])
10181 (define_insn "*atomic_compare_and_swapsi_3"
10182 [(set (match_operand:SI 0 "register_operand" "=r,r")
10183 (match_operand:SI 1 "memory_operand" "+Q,S"))
10185 (unspec_volatile:SI
10187 (match_operand:SI 2 "register_operand" "0,0")
10188 (match_operand:SI 3 "register_operand" "r,r")]
10190 (set (reg:CCZ1 CC_REGNUM)
10191 (compare:CCZ1 (match_dup 1) (match_dup 2)))]
10196 [(set_attr "op_type" "RS,RSY")
10197 (set_attr "cpu_facility" "*,longdisp")
10198 (set_attr "type" "sem")])
10201 ; Other atomic instruction patterns.
10204 ; z196 load and add, xor, or and and instructions
10206 (define_expand "atomic_fetch_<atomic><mode>"
10207 [(match_operand:GPR 0 "register_operand") ;; val out
10209 (match_operand:GPR 1 "memory_operand") ;; memory
10210 (match_operand:GPR 2 "register_operand")) ;; val in
10211 (match_operand:SI 3 "const_int_operand")] ;; model
10214 if (MEM_ALIGN (operands[1]) < GET_MODE_BITSIZE (GET_MODE (operands[1])))
10217 emit_insn (gen_atomic_fetch_<atomic><mode>_iaf
10218 (operands[0], operands[1], operands[2]));
10222 ; lan, lang, lao, laog, lax, laxg, laa, laag
10223 (define_insn "atomic_fetch_<atomic><mode>_iaf"
10224 [(set (match_operand:GPR 0 "register_operand" "=d")
10225 (match_operand:GPR 1 "memory_operand" "+S"))
10227 (unspec_volatile:GPR
10228 [(ATOMIC_Z196:GPR (match_dup 1)
10229 (match_operand:GPR 2 "general_operand" "d"))]
10230 UNSPECV_ATOMIC_OP))
10231 (clobber (reg:CC CC_REGNUM))]
10233 "la<noxa><g>\t%0,%2,%1"
10234 [(set_attr "op_type" "RSY")
10235 (set_attr "type" "sem")])
10237 ;; For SImode and larger, the optabs.c code will do just fine in
10238 ;; expanding a compare-and-swap loop. For QI/HImode, we can do
10239 ;; better by expanding our own loop.
10241 (define_expand "atomic_<atomic><mode>"
10243 (match_operand:HQI 0 "memory_operand") ;; memory
10244 (match_operand:HQI 1 "general_operand")) ;; val in
10245 (match_operand:SI 2 "const_int_operand")] ;; model
10248 s390_expand_atomic (<MODE>mode, <CODE>, NULL_RTX, operands[0],
10249 operands[1], false);
10253 (define_expand "atomic_fetch_<atomic><mode>"
10254 [(match_operand:HQI 0 "register_operand") ;; val out
10256 (match_operand:HQI 1 "memory_operand") ;; memory
10257 (match_operand:HQI 2 "general_operand")) ;; val in
10258 (match_operand:SI 3 "const_int_operand")] ;; model
10261 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
10262 operands[2], false);
10266 (define_expand "atomic_<atomic>_fetch<mode>"
10267 [(match_operand:HQI 0 "register_operand") ;; val out
10269 (match_operand:HQI 1 "memory_operand") ;; memory
10270 (match_operand:HQI 2 "general_operand")) ;; val in
10271 (match_operand:SI 3 "const_int_operand")] ;; model
10274 s390_expand_atomic (<MODE>mode, <CODE>, operands[0], operands[1],
10275 operands[2], true);
10279 (define_expand "atomic_exchange<mode>"
10280 [(match_operand:HQI 0 "register_operand") ;; val out
10281 (match_operand:HQI 1 "memory_operand") ;; memory
10282 (match_operand:HQI 2 "general_operand") ;; val in
10283 (match_operand:SI 3 "const_int_operand")] ;; model
10286 s390_expand_atomic (<MODE>mode, SET, operands[0], operands[1],
10287 operands[2], false);
10292 ;;- Miscellaneous instructions.
10296 ; allocate stack instruction pattern(s).
10299 (define_expand "allocate_stack"
10300 [(match_operand 0 "general_operand" "")
10301 (match_operand 1 "general_operand" "")]
10304 rtx temp = gen_reg_rtx (Pmode);
10306 emit_move_insn (temp, s390_back_chain_rtx ());
10307 anti_adjust_stack (operands[1]);
10308 emit_move_insn (s390_back_chain_rtx (), temp);
10310 emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10316 ; setjmp instruction pattern.
10319 (define_expand "builtin_setjmp_receiver"
10320 [(match_operand 0 "" "")]
10323 emit_insn (s390_load_got ());
10324 emit_use (pic_offset_table_rtx);
10328 ;; These patterns say how to save and restore the stack pointer. We need not
10329 ;; save the stack pointer at function level since we are careful to
10330 ;; preserve the backchain. At block level, we have to restore the backchain
10331 ;; when we restore the stack pointer.
10333 ;; For nonlocal gotos, we must save both the stack pointer and its
10334 ;; backchain and restore both. Note that in the nonlocal case, the
10335 ;; save area is a memory location.
10337 (define_expand "save_stack_function"
10338 [(match_operand 0 "general_operand" "")
10339 (match_operand 1 "general_operand" "")]
10343 (define_expand "restore_stack_function"
10344 [(match_operand 0 "general_operand" "")
10345 (match_operand 1 "general_operand" "")]
10349 (define_expand "restore_stack_block"
10350 [(match_operand 0 "register_operand" "")
10351 (match_operand 1 "register_operand" "")]
10354 rtx temp = gen_reg_rtx (Pmode);
10356 emit_move_insn (temp, s390_back_chain_rtx ());
10357 emit_move_insn (operands[0], operands[1]);
10358 emit_move_insn (s390_back_chain_rtx (), temp);
10363 (define_expand "save_stack_nonlocal"
10364 [(match_operand 0 "memory_operand" "")
10365 (match_operand 1 "register_operand" "")]
10368 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
10370 /* Copy the backchain to the first word, sp to the second and the
10371 literal pool base to the third. */
10373 rtx save_bc = adjust_address (operands[0], Pmode, 0);
10374 rtx save_sp = adjust_address (operands[0], Pmode, GET_MODE_SIZE (Pmode));
10375 rtx save_bp = adjust_address (operands[0], Pmode, 2 * GET_MODE_SIZE (Pmode));
10377 if (TARGET_BACKCHAIN)
10378 emit_move_insn (save_bc, force_reg (Pmode, s390_back_chain_rtx ()));
10380 emit_move_insn (save_sp, operands[1]);
10381 emit_move_insn (save_bp, base);
10386 (define_expand "restore_stack_nonlocal"
10387 [(match_operand 0 "register_operand" "")
10388 (match_operand 1 "memory_operand" "")]
10391 rtx base = gen_rtx_REG (Pmode, BASE_REGNUM);
10392 rtx temp = NULL_RTX;
10394 /* Restore the backchain from the first word, sp from the second and the
10395 literal pool base from the third. */
10397 rtx save_bc = adjust_address (operands[1], Pmode, 0);
10398 rtx save_sp = adjust_address (operands[1], Pmode, GET_MODE_SIZE (Pmode));
10399 rtx save_bp = adjust_address (operands[1], Pmode, 2 * GET_MODE_SIZE (Pmode));
10401 if (TARGET_BACKCHAIN)
10402 temp = force_reg (Pmode, save_bc);
10404 emit_move_insn (base, save_bp);
10405 emit_move_insn (operands[0], save_sp);
10408 emit_move_insn (s390_back_chain_rtx (), temp);
10414 (define_expand "exception_receiver"
10418 s390_set_has_landing_pad_p (true);
10423 ; nop instruction pattern(s).
10430 [(set_attr "op_type" "RR")
10431 (set_attr "z10prop" "z10_fr_E1")])
10433 (define_insn "nop1"
10437 [(set_attr "op_type" "RR")])
10439 ;;- Undeletable nops (used for hotpatching)
10441 (define_insn "nop_2_byte"
10442 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_2_BYTE)]
10445 [(set_attr "op_type" "RR")])
10447 (define_insn "nop_4_byte"
10448 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_4_BYTE)]
10451 [(set_attr "op_type" "RX")])
10453 (define_insn "nop_6_byte"
10454 [(unspec_volatile [(const_int 0)] UNSPECV_NOP_6_BYTE)]
10457 [(set_attr "op_type" "RIL")])
10461 ; Special literal pool access instruction pattern(s).
10464 (define_insn "*pool_entry"
10465 [(unspec_volatile [(match_operand 0 "consttable_operand" "X")]
10466 UNSPECV_POOL_ENTRY)]
10469 machine_mode mode = GET_MODE (PATTERN (insn));
10470 unsigned int align = GET_MODE_BITSIZE (mode);
10471 s390_output_pool_entry (operands[0], mode, align);
10474 [(set (attr "length")
10475 (symbol_ref "GET_MODE_SIZE (GET_MODE (PATTERN (insn)))"))])
10477 (define_insn "pool_align"
10478 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")]
10479 UNSPECV_POOL_ALIGN)]
10482 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
10484 (define_insn "pool_section_start"
10485 [(unspec_volatile [(const_int 1)] UNSPECV_POOL_SECTION)]
10488 switch_to_section (targetm.asm_out.function_rodata_section
10489 (current_function_decl));
10492 [(set_attr "length" "0")])
10494 (define_insn "pool_section_end"
10495 [(unspec_volatile [(const_int 0)] UNSPECV_POOL_SECTION)]
10498 switch_to_section (current_function_section ());
10501 [(set_attr "length" "0")])
10503 (define_insn "main_base_31_small"
10504 [(set (match_operand 0 "register_operand" "=a")
10505 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
10506 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
10508 [(set_attr "op_type" "RR")
10509 (set_attr "type" "la")
10510 (set_attr "z196prop" "z196_cracked")])
10512 (define_insn "main_base_31_large"
10513 [(set (match_operand 0 "register_operand" "=a")
10514 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))
10515 (set (pc) (label_ref (match_operand 2 "" "")))]
10516 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
10518 [(set_attr "op_type" "RI")
10519 (set_attr "z196prop" "z196_cracked")])
10521 (define_insn "main_base_64"
10522 [(set (match_operand 0 "register_operand" "=a")
10523 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))]
10524 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
10526 [(set_attr "op_type" "RIL")
10527 (set_attr "type" "larl")
10528 (set_attr "z10prop" "z10_fwd_A1")])
10530 (define_insn "main_pool"
10531 [(set (match_operand 0 "register_operand" "=a")
10532 (unspec_volatile [(const_int 0)] UNSPECV_MAIN_POOL))]
10533 "GET_MODE (operands[0]) == Pmode"
10535 gcc_unreachable ();
10537 [(set (attr "type")
10538 (if_then_else (match_test "TARGET_CPU_ZARCH")
10539 (const_string "larl") (const_string "la")))])
10541 (define_insn "reload_base_31"
10542 [(set (match_operand 0 "register_operand" "=a")
10543 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
10544 "!TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
10545 "basr\t%0,0\;la\t%0,%1-.(%0)"
10546 [(set_attr "length" "6")
10547 (set_attr "type" "la")
10548 (set_attr "z196prop" "z196_cracked")])
10550 (define_insn "reload_base_64"
10551 [(set (match_operand 0 "register_operand" "=a")
10552 (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))]
10553 "TARGET_CPU_ZARCH && GET_MODE (operands[0]) == Pmode"
10555 [(set_attr "op_type" "RIL")
10556 (set_attr "type" "larl")
10557 (set_attr "z10prop" "z10_fwd_A1")])
10559 (define_insn "pool"
10560 [(unspec_volatile [(match_operand 0 "const_int_operand" "n")] UNSPECV_POOL)]
10563 gcc_unreachable ();
10565 [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))])
10568 ;; Insns related to generating the function prologue and epilogue.
10572 (define_expand "prologue"
10573 [(use (const_int 0))]
10575 "s390_emit_prologue (); DONE;")
10577 (define_expand "epilogue"
10578 [(use (const_int 1))]
10580 "s390_emit_epilogue (false); DONE;")
10582 (define_expand "sibcall_epilogue"
10583 [(use (const_int 0))]
10585 "s390_emit_epilogue (true); DONE;")
10587 ;; A direct return instruction, without using an epilogue.
10588 (define_insn "<code>"
10590 "s390_can_use_<code>_insn ()"
10592 [(set_attr "op_type" "RR")
10593 (set_attr "type" "jsr")
10594 (set_attr "atype" "agen")])
10596 (define_insn "*return"
10598 (use (match_operand 0 "register_operand" "a"))]
10599 "GET_MODE (operands[0]) == Pmode"
10601 [(set_attr "op_type" "RR")
10602 (set_attr "type" "jsr")
10603 (set_attr "atype" "agen")])
10606 ;; Instruction definition to extend a 31-bit pointer into a 64-bit
10607 ;; pointer. This is used for compatibility.
10609 (define_expand "ptr_extend"
10610 [(set (match_operand:DI 0 "register_operand" "=r")
10611 (match_operand:SI 1 "register_operand" "r"))]
10614 emit_insn (gen_anddi3 (operands[0],
10615 gen_lowpart (DImode, operands[1]),
10616 GEN_INT (0x7fffffff)));
10620 ;; Instruction definition to expand eh_return macro to support
10621 ;; swapping in special linkage return addresses.
10623 (define_expand "eh_return"
10624 [(use (match_operand 0 "register_operand" ""))]
10627 s390_emit_tpf_eh_return (operands[0]);
10632 ; Stack Protector Patterns
10635 (define_expand "stack_protect_set"
10636 [(set (match_operand 0 "memory_operand" "")
10637 (match_operand 1 "memory_operand" ""))]
10640 #ifdef TARGET_THREAD_SSP_OFFSET
10642 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
10643 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
10646 emit_insn (gen_stack_protect_setdi (operands[0], operands[1]));
10648 emit_insn (gen_stack_protect_setsi (operands[0], operands[1]));
10653 (define_insn "stack_protect_set<mode>"
10654 [(set (match_operand:DSI 0 "memory_operand" "=Q")
10655 (unspec:DSI [(match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_SET))]
10657 "mvc\t%O0(%G0,%R0),%S1"
10658 [(set_attr "op_type" "SS")])
10660 (define_expand "stack_protect_test"
10661 [(set (reg:CC CC_REGNUM)
10662 (compare (match_operand 0 "memory_operand" "")
10663 (match_operand 1 "memory_operand" "")))
10664 (match_operand 2 "" "")]
10668 #ifdef TARGET_THREAD_SSP_OFFSET
10670 = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (),
10671 GEN_INT (TARGET_THREAD_SSP_OFFSET)));
10674 emit_insn (gen_stack_protect_testdi (operands[0], operands[1]));
10676 emit_insn (gen_stack_protect_testsi (operands[0], operands[1]));
10678 cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM);
10679 test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx);
10680 emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2]));
10684 (define_insn "stack_protect_test<mode>"
10685 [(set (reg:CCZ CC_REGNUM)
10686 (unspec:CCZ [(match_operand:DSI 0 "memory_operand" "Q")
10687 (match_operand:DSI 1 "memory_operand" "Q")] UNSPEC_SP_TEST))]
10689 "clc\t%O0(%G0,%R0),%S1"
10690 [(set_attr "op_type" "SS")])
10692 ; This is used in s390_emit_prologue in order to prevent insns
10693 ; adjusting the stack pointer to be moved over insns writing stack
10694 ; slots using a copy of the stack pointer in a different register.
10695 (define_insn "stack_tie"
10696 [(set (match_operand:BLK 0 "memory_operand" "+m")
10697 (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
10700 [(set_attr "length" "0")])
10703 (define_insn "stack_restore_from_fpr"
10704 [(set (reg:DI STACK_REGNUM)
10705 (match_operand:DI 0 "register_operand" "f"))
10706 (clobber (mem:BLK (scratch)))]
10709 [(set_attr "op_type" "RRE")])
10712 ; Data prefetch patterns
10715 (define_insn "prefetch"
10716 [(prefetch (match_operand 0 "address_operand" "ZT,X")
10717 (match_operand:SI 1 "const_int_operand" " n,n")
10718 (match_operand:SI 2 "const_int_operand" " n,n"))]
10721 switch (which_alternative)
10724 return INTVAL (operands[1]) == 1 ? "pfd\t2,%a0" : "pfd\t1,%a0";
10726 if (larl_operand (operands[0], Pmode))
10727 return INTVAL (operands[1]) == 1 ? "pfdrl\t2,%a0" : "pfdrl\t1,%a0";
10731 /* This might be reached for symbolic operands with an odd
10732 addend. We simply omit the prefetch for such rare cases. */
10737 [(set_attr "type" "load,larl")
10738 (set_attr "op_type" "RXY,RIL")
10739 (set_attr "z10prop" "z10_super")
10740 (set_attr "z196prop" "z196_alone")])
10744 ; Byte swap instructions
10747 ; FIXME: There is also mvcin but we cannot use it since src and target
10749 ; lrvr, lrv, strv, lrvgr, lrvg, strvg
10750 (define_insn "bswap<mode>2"
10751 [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,T")
10752 (bswap:GPR (match_operand:GPR 1 "nonimmediate_operand" " d,T,d")))]
10758 [(set_attr "type" "*,load,store")
10759 (set_attr "op_type" "RRE,RXY,RXY")
10760 (set_attr "z10prop" "z10_super")])
10762 (define_insn "bswaphi2"
10763 [(set (match_operand:HI 0 "nonimmediate_operand" "=d,d,T")
10764 (bswap:HI (match_operand:HI 1 "nonimmediate_operand" " d,T,d")))]
10770 [(set_attr "type" "*,load,store")
10771 (set_attr "op_type" "RRE,RXY,RXY")
10772 (set_attr "z10prop" "z10_super")])
10775 [(set (match_operand:HI 0 "register_operand" "")
10776 (bswap:HI (match_operand:HI 1 "register_operand" "")))]
10778 [(set (match_dup 2) (bswap:SI (match_dup 3)))
10779 (set (match_dup 2) (lshiftrt:SI (match_dup 2) (const_int 16)))]
10781 operands[2] = simplify_gen_subreg (SImode, operands[0], HImode, 0);
10782 operands[3] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
10787 ; Population count instruction
10790 ; The S/390 popcount instruction counts the bits of op1 in 8 byte
10791 ; portions and stores the result in the corresponding bytes in op0.
10792 (define_insn "*popcount<mode>"
10793 [(set (match_operand:INT 0 "register_operand" "=d")
10794 (unspec:INT [(match_operand:INT 1 "register_operand" "d")] UNSPEC_POPCNT))
10795 (clobber (reg:CC CC_REGNUM))]
10798 [(set_attr "op_type" "RRE")])
10800 (define_expand "popcountdi2"
10802 (parallel [(set (match_operand:DI 0 "register_operand" "")
10803 (unspec:DI [(match_operand:DI 1 "register_operand")]
10805 (clobber (reg:CC CC_REGNUM))])
10806 ; sllg op2, op0, 32
10807 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 32)))
10809 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10810 (clobber (reg:CC CC_REGNUM))])
10811 ; sllg op2, op0, 16
10813 (ashift:DI (match_dup 0) (const_int 16)))
10815 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10816 (clobber (reg:CC CC_REGNUM))])
10818 (set (match_dup 2) (ashift:DI (match_dup 0) (const_int 8)))
10820 (parallel [(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2)))
10821 (clobber (reg:CC CC_REGNUM))])
10822 ; srlg op0, op0, 56
10823 (set (match_dup 0) (lshiftrt:DI (match_dup 0) (const_int 56)))]
10824 "TARGET_Z196 && TARGET_64BIT"
10825 "operands[2] = gen_reg_rtx (DImode);")
10827 (define_expand "popcountsi2"
10829 (parallel [(set (match_operand:SI 0 "register_operand" "")
10830 (unspec:SI [(match_operand:SI 1 "register_operand")]
10832 (clobber (reg:CC CC_REGNUM))])
10833 ; sllk op2, op0, 16
10835 (ashift:SI (match_dup 0) (const_int 16)))
10837 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10838 (clobber (reg:CC CC_REGNUM))])
10840 (set (match_dup 2) (ashift:SI (match_dup 0) (const_int 8)))
10842 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10843 (clobber (reg:CC CC_REGNUM))])
10845 (set (match_dup 0) (lshiftrt:SI (match_dup 0) (const_int 24)))]
10847 "operands[2] = gen_reg_rtx (SImode);")
10849 (define_expand "popcounthi2"
10851 (parallel [(set (match_operand:HI 0 "register_operand" "")
10852 (unspec:HI [(match_operand:HI 1 "register_operand")]
10854 (clobber (reg:CC CC_REGNUM))])
10857 (ashift:SI (match_dup 0) (const_int 8)))
10859 (parallel [(set (match_dup 0) (plus:SI (match_dup 0) (match_dup 2)))
10860 (clobber (reg:CC CC_REGNUM))])
10862 (set (match_dup 0) (lshiftrt:HI (match_dup 0) (const_int 8)))]
10864 "operands[2] = gen_reg_rtx (SImode);")
10866 (define_expand "popcountqi2"
10868 (parallel [(set (match_operand:QI 0 "register_operand" "")
10869 (unspec:QI [(match_operand:QI 1 "register_operand")]
10871 (clobber (reg:CC CC_REGNUM))])]
10876 ;;- Copy sign instructions
10879 (define_insn "copysign<mode>3"
10880 [(set (match_operand:FP 0 "register_operand" "=f")
10881 (unspec:FP [(match_operand:FP 1 "register_operand" "<fT0>")
10882 (match_operand:FP 2 "register_operand" "f")]
10886 [(set_attr "op_type" "RRF")
10887 (set_attr "type" "fsimp<mode>")])
10891 ;;- Transactional execution instructions
10894 ; This splitter helps combine to make use of CC directly when
10895 ; comparing the integer result of a tbegin builtin with a constant.
10896 ; The unspec is already removed by canonicalize_comparison. So this
10897 ; splitters only job is to turn the PARALLEL into separate insns
10898 ; again. Unfortunately this only works with the very first cc/int
10899 ; compare since combine is not able to deal with data flow across
10900 ; basic block boundaries.
10902 ; It needs to be an insn pattern as well since combine does not apply
10903 ; the splitter directly. Combine would only use it if it actually
10904 ; would reduce the number of instructions.
10905 (define_insn_and_split "*ccraw_to_int"
10908 (match_operator 0 "s390_eqne_operator"
10909 [(reg:CCRAW CC_REGNUM)
10910 (match_operand 1 "const_int_operand" "")])
10911 (label_ref (match_operand 2 "" ""))
10913 (set (match_operand:SI 3 "register_operand" "=d")
10914 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
10918 [(set (match_dup 3)
10919 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))
10921 (if_then_else (match_op_dup 0 [(reg:CCRAW CC_REGNUM) (match_dup 1)])
10922 (label_ref (match_dup 2))
10926 ; Non-constrained transaction begin
10928 (define_expand "tbegin"
10929 [(match_operand:SI 0 "register_operand" "")
10930 (match_operand:BLK 1 "memory_operand" "")]
10933 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, true);
10937 (define_expand "tbegin_nofloat"
10938 [(match_operand:SI 0 "register_operand" "")
10939 (match_operand:BLK 1 "memory_operand" "")]
10942 s390_expand_tbegin (operands[0], operands[1], NULL_RTX, false);
10946 (define_expand "tbegin_retry"
10947 [(match_operand:SI 0 "register_operand" "")
10948 (match_operand:BLK 1 "memory_operand" "")
10949 (match_operand:SI 2 "general_operand" "")]
10952 s390_expand_tbegin (operands[0], operands[1], operands[2], true);
10956 (define_expand "tbegin_retry_nofloat"
10957 [(match_operand:SI 0 "register_operand" "")
10958 (match_operand:BLK 1 "memory_operand" "")
10959 (match_operand:SI 2 "general_operand" "")]
10962 s390_expand_tbegin (operands[0], operands[1], operands[2], false);
10966 ; Clobber VRs since they don't get restored
10967 (define_insn "tbegin_1_z13"
10968 [(set (reg:CCRAW CC_REGNUM)
10969 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10971 (set (match_operand:BLK 1 "memory_operand" "=Q")
10972 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
10973 (clobber (reg:TI 16)) (clobber (reg:TI 38))
10974 (clobber (reg:TI 17)) (clobber (reg:TI 39))
10975 (clobber (reg:TI 18)) (clobber (reg:TI 40))
10976 (clobber (reg:TI 19)) (clobber (reg:TI 41))
10977 (clobber (reg:TI 20)) (clobber (reg:TI 42))
10978 (clobber (reg:TI 21)) (clobber (reg:TI 43))
10979 (clobber (reg:TI 22)) (clobber (reg:TI 44))
10980 (clobber (reg:TI 23)) (clobber (reg:TI 45))
10981 (clobber (reg:TI 24)) (clobber (reg:TI 46))
10982 (clobber (reg:TI 25)) (clobber (reg:TI 47))
10983 (clobber (reg:TI 26)) (clobber (reg:TI 48))
10984 (clobber (reg:TI 27)) (clobber (reg:TI 49))
10985 (clobber (reg:TI 28)) (clobber (reg:TI 50))
10986 (clobber (reg:TI 29)) (clobber (reg:TI 51))
10987 (clobber (reg:TI 30)) (clobber (reg:TI 52))
10988 (clobber (reg:TI 31)) (clobber (reg:TI 53))]
10989 ; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
10990 ; not supposed to be used for immediates (see genpreds.c).
10991 "TARGET_VX && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
10993 [(set_attr "op_type" "SIL")])
10995 (define_insn "tbegin_1"
10996 [(set (reg:CCRAW CC_REGNUM)
10997 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
10999 (set (match_operand:BLK 1 "memory_operand" "=Q")
11000 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))
11001 (clobber (reg:DF 16))
11002 (clobber (reg:DF 17))
11003 (clobber (reg:DF 18))
11004 (clobber (reg:DF 19))
11005 (clobber (reg:DF 20))
11006 (clobber (reg:DF 21))
11007 (clobber (reg:DF 22))
11008 (clobber (reg:DF 23))
11009 (clobber (reg:DF 24))
11010 (clobber (reg:DF 25))
11011 (clobber (reg:DF 26))
11012 (clobber (reg:DF 27))
11013 (clobber (reg:DF 28))
11014 (clobber (reg:DF 29))
11015 (clobber (reg:DF 30))
11016 (clobber (reg:DF 31))]
11017 ; CONST_OK_FOR_CONSTRAINT_P does not work with D constraint since D is
11018 ; not supposed to be used for immediates (see genpreds.c).
11019 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
11021 [(set_attr "op_type" "SIL")])
11023 ; Same as above but without the FPR clobbers
11024 (define_insn "tbegin_nofloat_1"
11025 [(set (reg:CCRAW CC_REGNUM)
11026 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" "D")]
11028 (set (match_operand:BLK 1 "memory_operand" "=Q")
11029 (unspec_volatile:BLK [(match_dup 0)] UNSPECV_TBEGIN_TDB))]
11030 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
11032 [(set_attr "op_type" "SIL")])
11035 ; Constrained transaction begin
11037 (define_expand "tbeginc"
11038 [(set (reg:CCRAW CC_REGNUM)
11039 (unspec_volatile:CCRAW [(const_int TBEGINC_MASK)]
11044 (define_insn "*tbeginc_1"
11045 [(set (reg:CCRAW CC_REGNUM)
11046 (unspec_volatile:CCRAW [(match_operand 0 "const_int_operand" " D")]
11048 "TARGET_HTM && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 0xffff"
11050 [(set_attr "op_type" "SIL")])
11054 (define_expand "tend"
11055 [(set (reg:CCRAW CC_REGNUM)
11056 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))
11057 (set (match_operand:SI 0 "register_operand" "")
11058 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
11062 (define_insn "*tend_1"
11063 [(set (reg:CCRAW CC_REGNUM)
11064 (unspec_volatile:CCRAW [(const_int 0)] UNSPECV_TEND))]
11067 [(set_attr "op_type" "S")])
11069 ; Transaction abort
11071 (define_expand "tabort"
11072 [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "")]
11074 "TARGET_HTM && operands != NULL"
11076 if (CONST_INT_P (operands[0])
11077 && INTVAL (operands[0]) >= 0 && INTVAL (operands[0]) <= 255)
11079 error ("invalid transaction abort code: " HOST_WIDE_INT_PRINT_DEC
11080 ". Values in range 0 through 255 are reserved.",
11081 INTVAL (operands[0]));
11086 (define_insn "*tabort_1"
11087 [(unspec_volatile [(match_operand:SI 0 "nonmemory_operand" "aJ")]
11089 "TARGET_HTM && operands != NULL"
11091 [(set_attr "op_type" "S")])
11093 (define_insn "*tabort_1_plus"
11094 [(unspec_volatile [(plus:SI (match_operand:SI 0 "register_operand" "a")
11095 (match_operand:SI 1 "const_int_operand" "J"))]
11097 "TARGET_HTM && operands != NULL
11098 && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'J', \"J\")"
11100 [(set_attr "op_type" "S")])
11102 ; Transaction extract nesting depth
11104 (define_insn "etnd"
11105 [(set (match_operand:SI 0 "register_operand" "=d")
11106 (unspec_volatile:SI [(const_int 0)] UNSPECV_ETND))]
11109 [(set_attr "op_type" "RRE")])
11111 ; Non-transactional store
11113 (define_insn "ntstg"
11114 [(set (match_operand:DI 0 "memory_operand" "=T")
11115 (unspec_volatile:DI [(match_operand:DI 1 "register_operand" "d")]
11119 [(set_attr "op_type" "RXY")])
11121 ; Transaction perform processor assist
11123 (define_expand "tx_assist"
11124 [(unspec_volatile [(match_operand:SI 0 "register_operand" "")
11125 (reg:SI GPR0_REGNUM)
11131 (define_insn "*ppa"
11132 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")
11133 (match_operand:SI 1 "register_operand" "d")
11134 (match_operand 2 "const_int_operand" "I")]
11136 "TARGET_HTM && INTVAL (operands[2]) < 16"
11138 [(set_attr "op_type" "RRF")])
11141 ; Set and get floating point control register
11143 (define_insn "sfpc"
11144 [(unspec_volatile [(match_operand:SI 0 "register_operand" "d")]
11146 "TARGET_HARD_FLOAT"
11149 (define_insn "efpc"
11150 [(set (match_operand:SI 0 "register_operand" "=d")
11151 (unspec_volatile:SI [(const_int 0)] UNSPECV_EFPC))]
11152 "TARGET_HARD_FLOAT"
11156 ; Load count to block boundary
11158 (define_insn "lcbb"
11159 [(set (match_operand:SI 0 "register_operand" "=d")
11160 (unspec:SI [(match_operand 1 "address_operand" "ZR")
11161 (match_operand:SI 2 "immediate_operand" "C")] UNSPEC_LCBB))
11162 (clobber (reg:CC CC_REGNUM))]
11165 [(set_attr "op_type" "VRX")])
11167 ; Handle -fsplit-stack.
11169 (define_expand "split_stack_prologue"
11173 s390_expand_split_stack_prologue ();
11177 ;; If there are operand 0 bytes available on the stack, jump to
11180 (define_expand "split_stack_space_check"
11181 [(set (pc) (if_then_else
11182 (ltu (minus (reg 15)
11183 (match_operand 0 "register_operand"))
11184 (unspec [(const_int 0)] UNSPEC_STACK_CHECK))
11185 (label_ref (match_operand 1))
11189 /* Offset from thread pointer to __private_ss. */
11190 int psso = TARGET_64BIT ? 0x38 : 0x20;
11191 rtx tp = s390_get_thread_pointer ();
11192 rtx guard = gen_rtx_MEM (Pmode, plus_constant (Pmode, tp, psso));
11193 rtx reg = gen_reg_rtx (Pmode);
11196 emit_insn (gen_subdi3 (reg, stack_pointer_rtx, operands[0]));
11198 emit_insn (gen_subsi3 (reg, stack_pointer_rtx, operands[0]));
11199 cc = s390_emit_compare (GT, reg, guard);
11200 s390_emit_jump (operands[1], cc);
11205 ;; __morestack parameter block for split stack prologue. Parameters are:
11206 ;; parameter block label, label to be called by __morestack, frame size,
11207 ;; stack parameter size.
11209 (define_insn "split_stack_data"
11210 [(unspec_volatile [(match_operand 0 "" "X")
11211 (match_operand 1 "" "X")
11212 (match_operand 2 "const_int_operand" "X")
11213 (match_operand 3 "const_int_operand" "X")]
11214 UNSPECV_SPLIT_STACK_DATA)]
11217 switch_to_section (targetm.asm_out.function_rodata_section
11218 (current_function_decl));
11221 output_asm_insn (".align\t8", operands);
11223 output_asm_insn (".align\t4", operands);
11224 (*targetm.asm_out.internal_label) (asm_out_file, "L",
11225 CODE_LABEL_NUMBER (operands[0]));
11228 output_asm_insn (".quad\t%2", operands);
11229 output_asm_insn (".quad\t%3", operands);
11230 output_asm_insn (".quad\t%1-%0", operands);
11234 output_asm_insn (".long\t%2", operands);
11235 output_asm_insn (".long\t%3", operands);
11236 output_asm_insn (".long\t%1-%0", operands);
11239 switch_to_section (current_function_section ());
11242 [(set_attr "length" "0")])
11245 ;; A jg with minimal fuss for use in split stack prologue.
11247 (define_expand "split_stack_call"
11248 [(match_operand 0 "bras_sym_operand" "X")
11249 (match_operand 1 "" "")]
11253 emit_jump_insn (gen_split_stack_call_di (operands[0], operands[1]));
11255 emit_jump_insn (gen_split_stack_call_si (operands[0], operands[1]));
11259 (define_insn "split_stack_call_<mode>"
11260 [(set (pc) (label_ref (match_operand 1 "" "")))
11261 (set (reg:P 1) (unspec_volatile [(match_operand 0 "bras_sym_operand" "X")
11263 UNSPECV_SPLIT_STACK_CALL))]
11266 [(set_attr "op_type" "RIL")
11267 (set_attr "type" "branch")])
11269 ;; Also a conditional one.
11271 (define_expand "split_stack_cond_call"
11272 [(match_operand 0 "bras_sym_operand" "X")
11273 (match_operand 1 "" "")
11274 (match_operand 2 "" "")]
11278 emit_jump_insn (gen_split_stack_cond_call_di (operands[0], operands[1], operands[2]));
11280 emit_jump_insn (gen_split_stack_cond_call_si (operands[0], operands[1], operands[2]));
11284 (define_insn "split_stack_cond_call_<mode>"
11287 (match_operand 1 "" "")
11288 (label_ref (match_operand 2 "" ""))
11290 (set (reg:P 1) (unspec_volatile [(match_operand 0 "bras_sym_operand" "X")
11292 UNSPECV_SPLIT_STACK_CALL))]
11295 [(set_attr "op_type" "RIL")
11296 (set_attr "type" "branch")])
11298 (define_insn "osc_break"
11299 [(unspec_volatile [(const_int 0)] UNSPECV_OSC_BREAK)]
11302 [(set_attr "op_type" "RR")])