This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

S/390: Clean up jump insn patterns


Hello,

this is a clean-up of all jump-like insn patterns in the s390 backend.
Most significant changes: use s390_select_ccmode to choose optimal
CC mode right from the start; twiddle insn length attribute to get
a better representation of the default length (e.g. if !flag_pic,
not even the default length need take PIC sequences into account),
merge doloop splitters into insn_and_split.

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.
Committed to mainline.

Bye,
Ulrich

ChangeLog:

	* config/s390/s390-protos.h (s390_emit_compare): Add prototype.
	(s390_emit_jump): Likewise.
	* config/s390/s390.c (s390_emit_compare): New function.
	(s390_emit_jump): Likewise.
	* config/s390/s390.md ("beq", "bne", "bgt", "bgtu", "blt", "bltu",
	"bge", "bgeu", "ble", "bleu", "bunordered", "bordered", "buneq",
	"bungt", "bunlt", "bunge", "bunle", "bltgt"): Use s390_emit_compare
	and s390_emit_jump.
	("cjump"): Remove, replace by ...
	("*cjump_64", "*cjump_31"): ... these insns.  Improve length default.
	("icjump", "*icjump_64", "*icjump_31"): Likewise.
	("trap"): Fix type attribute.
	("conditional_trap"): Use s390_emit_compare.
	("doloop_si"): Remove, replace by ...
	("doloop_si64", "doloop_si31"): ... these new insn_and_split.
	Merge existing splitter into insn_and_split.  Improve length default.
	("doloop_di"): Merge with existing splitter into insn_and_split.
	("doloop"): Adapt.
	("jump"): Convert to expander.  Use s390_emit_jump.
	("*jump_64", "*jump_31"): New insns.  Improve length default.
	


Index: gcc/config/s390/s390-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390-protos.h,v
retrieving revision 1.48
diff -c -p -r1.48 s390-protos.h
*** gcc/config/s390/s390-protos.h	17 Jun 2004 10:32:14 -0000	1.48
--- gcc/config/s390/s390-protos.h	23 Jun 2004 22:58:03 -0000
*************** extern enum machine_mode s390_tm_ccmode 
*** 52,57 ****
--- 52,59 ----
  extern enum machine_mode s390_select_ccmode (enum rtx_code, rtx, rtx);
  extern int s390_alc_comparison (rtx op, enum machine_mode mode);
  extern int s390_slb_comparison (rtx op, enum machine_mode mode);
+ extern rtx s390_emit_compare (enum rtx_code, rtx, rtx);
+ extern void s390_emit_jump (rtx, rtx);
  extern int symbolic_reference_mentioned_p (rtx);
  extern int tls_symbolic_reference_mentioned_p (rtx);
  extern int legitimate_la_operand_p (rtx);
Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.152
diff -c -p -r1.152 s390.c
*** gcc/config/s390/s390.c	22 Jun 2004 03:06:51 -0000	1.152
--- gcc/config/s390/s390.c	23 Jun 2004 22:58:04 -0000
*************** s390_select_ccmode (enum rtx_code code, 
*** 468,473 ****
--- 468,503 ----
      }
  }
  
+ /* Emit a compare instruction suitable to implement the comparison
+    OP0 CODE OP1.  Return the correct condition RTL to be placed in
+    the IF_THEN_ELSE of the conditional branch testing the result.  */
+ 
+ rtx
+ s390_emit_compare (enum rtx_code code, rtx op0, rtx op1)
+ {
+   enum machine_mode mode = s390_select_ccmode (code, op0, op1);
+   rtx cc = gen_rtx_REG (mode, CC_REGNUM);
+ 
+   emit_insn (gen_rtx_SET (VOIDmode, cc, gen_rtx_COMPARE (mode, op0, op1)));
+   return gen_rtx_fmt_ee (code, VOIDmode, cc, const0_rtx);
+ }
+ 
+ /* Emit a jump instruction to TARGET.  If COND is NULL_RTX, emit an
+    unconditional jump, else a conditional jump under condition COND.  */
+ 
+ void
+ s390_emit_jump (rtx target, rtx cond)
+ {
+   rtx insn;
+ 
+   target = gen_rtx_LABEL_REF (VOIDmode, target);
+   if (cond)
+     target = gen_rtx_IF_THEN_ELSE (VOIDmode, cond, target, pc_rtx);
+ 
+   insn = gen_rtx_SET (VOIDmode, pc_rtx, target);
+   emit_jump_insn (insn);
+ }
+ 
  /* Return nonzero if OP is a valid comparison operator
     for an ALC condition in mode MODE.  */
  
Index: gcc/config/s390/s390.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.md,v
retrieving revision 1.112
diff -c -p -r1.112 s390.md
*** gcc/config/s390/s390.md	18 Jun 2004 14:27:25 -0000	1.112
--- gcc/config/s390/s390.md	23 Jun 2004 22:58:05 -0000
***************
*** 6439,6641 ****
  ;;
  
  (define_expand "beq"
!   [(set (reg:CCZ 33) (compare:CCZ (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (eq (reg:CCZ 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bne"
!   [(set (reg:CCZ 33) (compare:CCZ (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (ne (reg:CCZ 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bgt"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (gt (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bgtu"
!   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (gtu (reg:CCU 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "blt"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (lt (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bltu"
!   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (ltu (reg:CCU 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bge"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (ge (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bgeu"
!   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (geu (reg:CCU 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "ble"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (le (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bleu"
!   [(set (reg:CCU 33) (compare:CCU (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (leu (reg:CCU 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bunordered"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (unordered (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bordered"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (ordered (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "buneq"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (uneq (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
!   ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
! 
! (define_expand "bungt"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (ungt (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bunlt"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (unlt (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
! (define_expand "bunge"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (unge (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bunle"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (unle (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  (define_expand "bltgt"
!   [(set (reg:CCS 33) (compare:CCS (match_dup 1) (match_dup 2)))
!    (set (pc)
!         (if_then_else (ltgt (reg:CCS 33) (const_int 0))
!                       (label_ref (match_operand 0 "" ""))
!                       (pc)))]
    ""
!   "operands[1] = s390_compare_op0; operands[2] = s390_compare_op1;")
  
  
  ;;
  ;;- Conditional jump instructions.
  ;;
  
! (define_insn "cjump"
!  [(set (pc)
!        (if_then_else
!          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
! 	 (label_ref (match_operand 0 "" ""))
! 	 (pc)))]
!   ""
  {
    if (get_attr_length (insn) == 4)
      return "j%C1\t%l0";
!   else if (TARGET_CPU_ZARCH)
      return "jg%C1\t%l0";
    else
      abort ();
  }
    [(set_attr "op_type" "RI")
     (set_attr "type"    "branch")
     (set (attr "length")
!         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                 (const_int 4)
!                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
!                  (const_int 6)
!                (eq (symbol_ref "flag_pic") (const_int 0))
!                  (const_int 6)] (const_int 8)))])
  
  (define_insn "*cjump_long"
!  [(set (pc)
!        (if_then_else
!          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
! 	 (match_operand 0 "address_operand" "U")
! 	 (pc)))]
    ""
  {
    if (get_attr_op_type (insn) == OP_TYPE_RR)
--- 6439,6603 ----
  ;;
  
  (define_expand "beq"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (EQ, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bne"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (NE, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bgt"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (GT, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bgtu"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (GTU, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "blt"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (LT, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bltu"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (LTU, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bge"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (GE, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bgeu"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (GEU, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "ble"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (LE, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bleu"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (LEU, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bunordered"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (UNORDERED, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bordered"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (ORDERED, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "buneq"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (UNEQ, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bunlt"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (UNLT, s390_compare_op0, s390_compare_op1)); DONE;")
  
! (define_expand "bungt"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (UNGT, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bunle"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (UNLE, s390_compare_op0, s390_compare_op1)); DONE;")
! 
! (define_expand "bunge"
!   [(match_operand 0 "" "")]
!   ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (UNGE, s390_compare_op0, s390_compare_op1)); DONE;")
  
  (define_expand "bltgt"
!   [(match_operand 0 "" "")]
    ""
!   "s390_emit_jump (operands[0],
!     s390_emit_compare (LTGT, s390_compare_op0, s390_compare_op1)); DONE;")
  
  
  ;;
  ;;- Conditional jump instructions.
  ;;
  
! (define_insn "*cjump_64"
!   [(set (pc)
!         (if_then_else
!           (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
!           (label_ref (match_operand 0 "" ""))
!           (pc)))]
!   "TARGET_CPU_ZARCH"
  {
    if (get_attr_length (insn) == 4)
      return "j%C1\t%l0";
!   else
      return "jg%C1\t%l0";
+ }
+   [(set_attr "op_type" "RI")
+    (set_attr "type"    "branch")
+    (set (attr "length")
+         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
+                       (const_int 4) (const_int 6)))])
+ 
+ (define_insn "*cjump_31"
+   [(set (pc)
+         (if_then_else
+           (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
+           (label_ref (match_operand 0 "" ""))
+           (pc)))]
+   "!TARGET_CPU_ZARCH"
+ {
+   if (get_attr_length (insn) == 4)
+     return "j%C1\t%l0";
    else
      abort ();
  }
    [(set_attr "op_type" "RI")
     (set_attr "type"    "branch")
     (set (attr "length")
!         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
!           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                         (const_int 4) (const_int 6))
!           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                         (const_int 4) (const_int 8))))])
  
  (define_insn "*cjump_long"
!   [(set (pc)
!         (if_then_else
!           (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
!           (match_operand 0 "address_operand" "U")
!           (pc)))]
    ""
  {
    if (get_attr_op_type (insn) == OP_TYPE_RR)
***************
*** 6646,6652 ****
    [(set (attr "op_type")
          (if_then_else (match_operand 0 "register_operand" "")
                        (const_string "RR") (const_string "RX")))
!    (set_attr "type"    "branch")
     (set_attr "atype" "agen")])
  
  
--- 6608,6614 ----
    [(set (attr "op_type")
          (if_then_else (match_operand 0 "register_operand" "")
                        (const_string "RR") (const_string "RX")))
!    (set_attr "type"  "branch")
     (set_attr "atype" "agen")])
  
  
***************
*** 6654,6690 ****
  ;;- Negated conditional jump instructions.
  ;;
  
! (define_insn "icjump"
!  [(set (pc)
!        (if_then_else
!          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
!          (pc)
! 	 (label_ref (match_operand 0 "" ""))))]
!   ""
  {
    if (get_attr_length (insn) == 4)
      return "j%D1\t%l0";
!   else if (TARGET_CPU_ZARCH)
      return "jg%D1\t%l0";
    else
      abort ();
  }
    [(set_attr "op_type" "RI")
     (set_attr "type"    "branch")
     (set (attr "length")
!         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                 (const_int 4)
!                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
!                  (const_int 6)
!                (eq (symbol_ref "flag_pic") (const_int 0))
!                  (const_int 6)] (const_int 8)))])
  
  (define_insn "*icjump_long"
!  [(set (pc)
!        (if_then_else
!          (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
!          (pc)
! 	 (match_operand 0 "address_operand" "U")))]
    ""
  {
    if (get_attr_op_type (insn) == OP_TYPE_RR)
--- 6616,6668 ----
  ;;- Negated conditional jump instructions.
  ;;
  
! (define_insn "*icjump_64"
!   [(set (pc)
!         (if_then_else
!           (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
!           (pc)
!           (label_ref (match_operand 0 "" ""))))]
!   "TARGET_CPU_ZARCH"
  {
    if (get_attr_length (insn) == 4)
      return "j%D1\t%l0";
!   else
      return "jg%D1\t%l0";
+ }
+   [(set_attr "op_type" "RI")
+    (set_attr "type"    "branch")
+    (set (attr "length")
+         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
+                       (const_int 4) (const_int 6)))])
+ 
+ (define_insn "*icjump_31"
+   [(set (pc)
+         (if_then_else
+           (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
+           (pc)
+           (label_ref (match_operand 0 "" ""))))]
+   "!TARGET_CPU_ZARCH"
+ {
+   if (get_attr_length (insn) == 4)
+     return "j%D1\t%l0";
    else
      abort ();
  }
    [(set_attr "op_type" "RI")
     (set_attr "type"    "branch")
     (set (attr "length")
!         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
!           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                         (const_int 4) (const_int 6))
!           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                         (const_int 4) (const_int 8))))])
  
  (define_insn "*icjump_long"
!   [(set (pc)
!         (if_then_else
!           (match_operator 1 "comparison_operator" [(reg 33) (const_int 0)])
!           (pc)
!           (match_operand 0 "address_operand" "U")))]
    ""
  {
    if (get_attr_op_type (insn) == OP_TYPE_RR)
***************
*** 6706,6729 ****
    [(trap_if (const_int 1) (const_int 0))]
    ""
    "j\t.+2"
!   [(set_attr "op_type" "RX")
     (set_attr "type"  "branch")])
  
  (define_expand "conditional_trap"
!   [(set (match_dup 2) (match_dup 3))
!    (trap_if (match_operator 0 "comparison_operator"
! 			    [(match_dup 2) (const_int 0)])
! 	    (match_operand:SI 1 "general_operand" ""))]
    ""
  {
!    enum machine_mode ccmode;
! 
!    if (operands[1] != const0_rtx) FAIL;
! 
!    ccmode = s390_select_ccmode (GET_CODE (operands[0]),
! 			        s390_compare_op0, s390_compare_op1);
!    operands[2] = gen_rtx_REG (ccmode, 33);
!    operands[3] = gen_rtx_COMPARE (ccmode, s390_compare_op0, s390_compare_op1);
  })
  
  (define_insn "*trap"
--- 6684,6700 ----
    [(trap_if (const_int 1) (const_int 0))]
    ""
    "j\t.+2"
!   [(set_attr "op_type" "RI")
     (set_attr "type"  "branch")])
  
  (define_expand "conditional_trap"
!   [(trap_if (match_operand 0 "comparison_operator" "")
! 	    (match_operand 1 "general_operand" ""))]
    ""
  {
!   if (operands[1] != const0_rtx) FAIL;
!   operands[0] = s390_emit_compare (GET_CODE (operands[0]), 
!                                    s390_compare_op0, s390_compare_op1);
  })
  
  (define_insn "*trap"
***************
*** 6748,6755 ****
     (use (match_operand 4 "" ""))]       ; label
    ""
  {
!   if (GET_MODE (operands[0]) == SImode)
!     emit_jump_insn (gen_doloop_si (operands[4], operands[0], operands[0]));
    else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
      emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
    else
--- 6719,6728 ----
     (use (match_operand 4 "" ""))]       ; label
    ""
  {
!   if (GET_MODE (operands[0]) == SImode && !TARGET_CPU_ZARCH)
!     emit_jump_insn (gen_doloop_si31 (operands[4], operands[0], operands[0]));
!   else if (GET_MODE (operands[0]) == SImode && TARGET_CPU_ZARCH)
!     emit_jump_insn (gen_doloop_si64 (operands[4], operands[0], operands[0]));
    else if (GET_MODE (operands[0]) == DImode && TARGET_64BIT)
      emit_jump_insn (gen_doloop_di (operands[4], operands[0], operands[0]));
    else
***************
*** 6758,6764 ****
    DONE;
  })
  
! (define_insn "doloop_si"
    [(set (pc)
          (if_then_else
            (ne (match_operand:SI 1 "register_operand" "d,d")
--- 6731,6737 ----
    DONE;
  })
  
! (define_insn_and_split "doloop_si64"
    [(set (pc)
          (if_then_else
            (ne (match_operand:SI 1 "register_operand" "d,d")
***************
*** 6769,6794 ****
          (plus:SI (match_dup 1) (const_int -1)))
     (clobber (match_scratch:SI 3 "=X,&d"))
     (clobber (reg:CC 33))]
!   ""
  {
    if (which_alternative != 0)
      return "#";
    else if (get_attr_length (insn) == 4)
      return "brct\t%1,%l0";
!   else if (TARGET_CPU_ZARCH)
      return "ahi\t%1,-1\;jgne\t%l0";
    else
      abort ();
  }
    [(set_attr "op_type"  "RI")
     (set_attr "type"  "branch")
     (set (attr "length")
!         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                 (const_int 4)
!                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
!                  (const_int 10)
!                (eq (symbol_ref "flag_pic") (const_int 0))
!                  (const_int 6)] (const_int 8)))])
  
  (define_insn "*doloop_si_long"
    [(set (pc)
--- 6742,6816 ----
          (plus:SI (match_dup 1) (const_int -1)))
     (clobber (match_scratch:SI 3 "=X,&d"))
     (clobber (reg:CC 33))]
!   "TARGET_CPU_ZARCH"
  {
    if (which_alternative != 0)
      return "#";
    else if (get_attr_length (insn) == 4)
      return "brct\t%1,%l0";
!   else
      return "ahi\t%1,-1\;jgne\t%l0";
+ }
+   "&& reload_completed
+    && (! REG_P (operands[2])
+        || ! rtx_equal_p (operands[1], operands[2]))"
+   [(set (match_dup 3) (match_dup 1))
+    (parallel [(set (reg:CCAN 33)
+                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
+                                  (const_int 0)))
+               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
+    (set (match_dup 2) (match_dup 3))
+    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
+                            (label_ref (match_dup 0))
+                            (pc)))]
+   ""
+   [(set_attr "op_type"  "RI")
+    (set_attr "type"  "branch")
+    (set (attr "length")
+         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
+                       (const_int 4) (const_int 10)))])
+ 
+ (define_insn_and_split "doloop_si31"
+   [(set (pc)
+         (if_then_else
+           (ne (match_operand:SI 1 "register_operand" "d,d")
+               (const_int 1))
+           (label_ref (match_operand 0 "" ""))
+           (pc)))
+    (set (match_operand:SI 2 "nonimmediate_operand" "=1,?*m*d")
+         (plus:SI (match_dup 1) (const_int -1)))
+    (clobber (match_scratch:SI 3 "=X,&d"))
+    (clobber (reg:CC 33))]
+   "!TARGET_CPU_ZARCH"
+ {
+   if (which_alternative != 0)
+     return "#";
+   else if (get_attr_length (insn) == 4)
+     return "brct\t%1,%l0";
    else
      abort ();
  }
+   "&& reload_completed
+    && (! REG_P (operands[2])
+        || ! rtx_equal_p (operands[1], operands[2]))"
+   [(set (match_dup 3) (match_dup 1))
+    (parallel [(set (reg:CCAN 33)
+                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
+                                  (const_int 0)))
+               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
+    (set (match_dup 2) (match_dup 3))
+    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
+                            (label_ref (match_dup 0))
+                            (pc)))]
+   ""
    [(set_attr "op_type"  "RI")
     (set_attr "type"  "branch")
     (set (attr "length")
!         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
!           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                         (const_int 4) (const_int 6))
!           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                         (const_int 4) (const_int 8))))])
  
  (define_insn "*doloop_si_long"
    [(set (pc)
***************
*** 6801,6807 ****
          (plus:SI (match_dup 1) (const_int -1)))
     (clobber (match_scratch:SI 3 "=X,&d"))
     (clobber (reg:CC 33))]
!   ""
  {
    if (get_attr_op_type (insn) == OP_TYPE_RR)
      return "bctr\t%1,%0";
--- 6823,6829 ----
          (plus:SI (match_dup 1) (const_int -1)))
     (clobber (match_scratch:SI 3 "=X,&d"))
     (clobber (reg:CC 33))]
!   "!TARGET_CPU_ZARCH"
  {
    if (get_attr_op_type (insn) == OP_TYPE_RR)
      return "bctr\t%1,%0";
***************
*** 6814,6844 ****
     (set_attr "type"  "branch")
     (set_attr "atype" "agen")])
  
! (define_split
!   [(set (pc)
!         (if_then_else (ne (match_operand:SI 1 "register_operand" "")
!                           (const_int 1))
!                       (match_operand 0 "" "")
!                       (pc)))
!    (set (match_operand:SI 2 "nonimmediate_operand" "")
!         (plus:SI (match_dup 1) (const_int -1)))
!    (clobber (match_scratch:SI 3 ""))
!    (clobber (reg:CC 33))]
!   "reload_completed
!    && (! REG_P (operands[2])
!        || ! rtx_equal_p (operands[1], operands[2]))"
!   [(set (match_dup 3) (match_dup 1))
!    (parallel [(set (reg:CCAN 33)
!                    (compare:CCAN (plus:SI (match_dup 3) (const_int -1))
!                                  (const_int 0)))
!               (set (match_dup 3) (plus:SI (match_dup 3) (const_int -1)))])
!    (set (match_dup 2) (match_dup 3))
!    (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
!                            (match_dup 0)
!                            (pc)))]
!   "")
! 
! (define_insn "doloop_di"
    [(set (pc)
          (if_then_else
            (ne (match_operand:DI 1 "register_operand" "d,d")
--- 6836,6842 ----
     (set_attr "type"  "branch")
     (set_attr "atype" "agen")])
  
! (define_insn_and_split "doloop_di"
    [(set (pc)
          (if_then_else
            (ne (match_operand:DI 1 "register_operand" "d,d")
***************
*** 6858,6880 ****
    else
      return "aghi\t%1,-1\;jgne\t%l0";
  }
!   [(set_attr "op_type"  "RI")
!    (set_attr "type"  "branch")
!    (set (attr "length")
!         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                       (const_int 4) (const_int 10)))])
! 
! (define_split
!   [(set (pc)
!         (if_then_else (ne (match_operand:DI 1 "register_operand" "")
!                           (const_int 1))
!                       (match_operand 0 "" "")
!                       (pc)))
!    (set (match_operand:DI 2 "nonimmediate_operand" "")
!         (plus:DI (match_dup 1) (const_int -1)))
!    (clobber (match_scratch:DI 3 ""))
!    (clobber (reg:CC 33))]
!   "reload_completed
     && (! REG_P (operands[2])
         || ! rtx_equal_p (operands[1], operands[2]))"
    [(set (match_dup 3) (match_dup 1))
--- 6856,6862 ----
    else
      return "aghi\t%1,-1\;jgne\t%l0";
  }
!   "&& reload_completed
     && (! REG_P (operands[2])
         || ! rtx_equal_p (operands[1], operands[2]))"
    [(set (match_dup 3) (match_dup 1))
***************
*** 6884,6892 ****
                (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
     (set (match_dup 2) (match_dup 3))
     (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
!                            (match_dup 0)
                             (pc)))]
!   "")
  
  ;;
  ;;- Unconditional jump instructions.
--- 6866,6879 ----
                (set (match_dup 3) (plus:DI (match_dup 3) (const_int -1)))])
     (set (match_dup 2) (match_dup 3))
     (set (pc) (if_then_else (ne (reg:CCAN 33) (const_int 0))
!                            (label_ref (match_dup 0))
                             (pc)))]
!   ""
!   [(set_attr "op_type"  "RI")
!    (set_attr "type"  "branch")
!    (set (attr "length")
!         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                       (const_int 4) (const_int 10)))])
  
  ;;
  ;;- Unconditional jump instructions.
***************
*** 6896,6921 ****
  ; jump instruction pattern(s).
  ;
  
! (define_insn "jump"
!   [(set (pc) (label_ref (match_operand 0 "" "")))]
    ""
  {
    if (get_attr_length (insn) == 4)
      return "j\t%l0";
!   else if (TARGET_CPU_ZARCH)
      return "jg\t%l0";
    else
      abort ();
  }
    [(set_attr "op_type" "RI")
     (set_attr "type"  "branch")
     (set (attr "length")
!         (cond [(lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                 (const_int 4)
!                (ne (symbol_ref "TARGET_CPU_ZARCH") (const_int 0))
!                  (const_int 6)
!                (eq (symbol_ref "flag_pic") (const_int 0))
!                  (const_int 6)] (const_int 8)))])
  
  ;
  ; indirect-jump instruction pattern(s).
--- 6883,6925 ----
  ; jump instruction pattern(s).
  ;
  
! (define_expand "jump"
!   [(match_operand 0 "" "")]
    ""
+   "s390_emit_jump (operands[0], NULL_RTX); DONE;")
+ 
+ (define_insn "*jump64"
+   [(set (pc) (label_ref (match_operand 0 "" "")))]
+   "TARGET_CPU_ZARCH"
  {
    if (get_attr_length (insn) == 4)
      return "j\t%l0";
!   else
      return "jg\t%l0";
+ }
+   [(set_attr "op_type" "RI")
+    (set_attr "type"  "branch")
+    (set (attr "length")
+         (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
+                       (const_int 4) (const_int 6)))])
+ 
+ (define_insn "*jump31"
+   [(set (pc) (label_ref (match_operand 0 "" "")))]
+   "!TARGET_CPU_ZARCH"
+ {
+   if (get_attr_length (insn) == 4)
+     return "j\t%l0";
    else
      abort ();
  }
    [(set_attr "op_type" "RI")
     (set_attr "type"  "branch")
     (set (attr "length")
!         (if_then_else (eq (symbol_ref "flag_pic") (const_int 0))
!           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                         (const_int 4) (const_int 6))
!           (if_then_else (lt (abs (minus (pc) (match_dup 0))) (const_int 60000))
!                         (const_int 4) (const_int 8))))])
  
  ;
  ; indirect-jump instruction pattern(s).
-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]