diff options
author | Paolo Bonzini <bonzini@gnu.org> | 2009-05-12 09:43:48 +0000 |
---|---|---|
committer | Paolo Bonzini <bonzini@gcc.gnu.org> | 2009-05-12 09:43:48 +0000 |
commit | f90b7a5a7913cc7239cce42f6ca328b9a741b387 (patch) | |
tree | 06c940a96a184a178bfadd53e04213225655a68d /gcc/config/s390 | |
parent | b7a0af68063c79655c561750e9863799bf846cae (diff) | |
download | gcc-f90b7a5a7913cc7239cce42f6ca328b9a741b387.zip gcc-f90b7a5a7913cc7239cce42f6ca328b9a741b387.tar.gz gcc-f90b7a5a7913cc7239cce42f6ca328b9a741b387.tar.bz2 |
Merge cond-optab branch.
From-SVN: r147425
Diffstat (limited to 'gcc/config/s390')
-rw-r--r-- | gcc/config/s390/predicates.md | 8 | ||||
-rw-r--r-- | gcc/config/s390/s390.c | 17 | ||||
-rw-r--r-- | gcc/config/s390/s390.h | 6 | ||||
-rw-r--r-- | gcc/config/s390/s390.md | 208 |
4 files changed, 118 insertions, 121 deletions
diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md index bb8fdf2..d09c9b3 100644 --- a/gcc/config/s390/predicates.md +++ b/gcc/config/s390/predicates.md @@ -189,6 +189,14 @@ return (s390_compare_and_branch_condition_mask (op) >= 0); }) +;; Return nonzero if OP is a valid comparison operator for the +;; cstore expanders -- respectively cstorecc4 and integer cstore. +(define_predicate "s390_eqne_operator" + (match_code "eq, ne")) + +(define_predicate "s390_scond_operator" + (match_code "ltu, gtu, leu, geu")) + ;; Return nonzero if OP is a valid comparison operator ;; for an ALC condition. diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index e2ed4a0..17891c6 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -223,11 +223,6 @@ struct processor_costs z10_cost = extern int reload_completed; -/* Save information from a "cmpxx" operation until the branch or scc is - emitted. A pair of a MODE_CC register and a const0_rtx if a compare - has been emitted already. */ -rtx s390_compare_op0, s390_compare_op1; - /* Structure used to hold the components of a S/390 memory address. A legitimate address on S/390 is of the general form @@ -7747,15 +7742,11 @@ s390_emit_prologue (void) rtx t = gen_rtx_AND (Pmode, stack_pointer_rtx, GEN_INT (stack_check_mask)); if (TARGET_64BIT) - gen_cmpdi (t, const0_rtx); + emit_insn (gen_ctrapdi4 (gen_rtx_EQ (VOIDmode, t, const0_rtx), + t, const0_rtx, const0_rtx)); else - gen_cmpsi (t, const0_rtx); - - emit_insn (gen_conditional_trap (gen_rtx_EQ (CCmode, - gen_rtx_REG (CCmode, - CC_REGNUM), - const0_rtx), - const0_rtx)); + emit_insn (gen_ctrapsi4 (gen_rtx_EQ (VOIDmode, t, const0_rtx), + t, const0_rtx, const0_rtx)); } } diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index 2b4d7ce..b254185 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -803,12 +803,6 @@ do { \ #define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \ s390_canonicalize_comparison (&(CODE), &(OP0), &(OP1)) -/* Define the information needed to generate branch and scc insns. This is - stored from the compare operation. Note that we can't use "rtx" here - since it hasn't been defined! */ -extern struct rtx_def *s390_compare_op0, *s390_compare_op1; - - /* Relative costs of operations. */ /* On s390, copy between fprs and gprs is expensive. */ diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index c3d181f..7c9a2b2 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -354,13 +354,6 @@ (define_mode_iterator INT [(DI "TARGET_64BIT") SI HI QI]) (define_mode_iterator INTALL [TI DI SI HI QI]) -;; This iterator allows to unify all 'bCOND' expander patterns. -(define_code_iterator COMPARE [eq ne gt gtu lt ltu ge geu le leu unordered - ordered uneq unlt ungt unle unge ltgt]) - -;; This iterator allows to unify all 'sCOND' patterns. -(define_code_iterator SCOND [ltu gtu leu geu]) - ;; This iterator allows some 'ashift' and 'lshiftrt' pattern to be defined from ;; the same template. (define_code_iterator SHIFT [ashift lshiftrt]) @@ -493,39 +486,6 @@ ;;- Compare instructions. ;; -(define_expand "cmp<mode>" - [(set (reg:CC CC_REGNUM) - (compare:CC (match_operand:GPR 0 "register_operand" "") - (match_operand:GPR 1 "general_operand" "")))] - "" -{ - s390_compare_op0 = operands[0]; - s390_compare_op1 = operands[1]; - DONE; -}) - -(define_expand "cmp<mode>" - [(set (reg:CC CC_REGNUM) - (compare:CC (match_operand:FP 0 "register_operand" "") - (match_operand:FP 1 "general_operand" "")))] - "TARGET_HARD_FLOAT" -{ - s390_compare_op0 = operands[0]; - s390_compare_op1 = operands[1]; - DONE; -}) - -(define_expand "cmpcc" - [(set (reg:CC CC_REGNUM) - (compare:CC (match_operand 0 "cc_reg_operand" "") - (match_operand 1 "general_operand" "")))] - "" -{ - s390_compare_op0 = operands[0]; - s390_compare_op1 = operands[1]; - DONE; -}) - ; Test-under-Mask instructions (define_insn "*tmqi_mem" @@ -3812,9 +3772,9 @@ TD -> DI convert afterwards. */ emit_insn (gen_extendddtd2 (temp, operands[1])); temp = force_reg (TDmode, temp); - emit_insn (gen_cmptd (temp, - CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode))); - emit_jump_insn (gen_blt (label1)); + emit_cmp_and_jump_insns (temp, + CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode), + LT, NULL_RTX, VOIDmode, 0, label1); emit_insn (gen_subtd3 (temp, temp, CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode))); emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11))); @@ -3840,9 +3800,9 @@ decimal_real_from_string (&cmp, "9223372036854775808.0"); /* 2^63 */ decimal_real_from_string (&sub, "18446744073709551616.0"); /* 2^64 */ - emit_insn (gen_cmptd (operands[1], - CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode))); - emit_jump_insn (gen_blt (label1)); + emit_cmp_and_jump_insns (operands[1], + CONST_DOUBLE_FROM_REAL_VALUE (cmp, TDmode), + LT, NULL_RTX, VOIDmode, 0, label1); emit_insn (gen_subtd3 (temp, operands[1], CONST_DOUBLE_FROM_REAL_VALUE (sub, TDmode))); emit_insn (gen_fix_trunctddi2_dfp (operands[0], temp, GEN_INT (11))); @@ -3873,9 +3833,9 @@ real_2expN (&cmp, GET_MODE_BITSIZE(<GPR:MODE>mode) - 1, <BFP:MODE>mode); real_2expN (&sub, GET_MODE_BITSIZE(<GPR:MODE>mode), <BFP:MODE>mode); - emit_insn (gen_cmp<BFP:mode> (operands[1], - CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode))); - emit_jump_insn (gen_blt (label1)); + emit_cmp_and_jump_insns (operands[1], + CONST_DOUBLE_FROM_REAL_VALUE (cmp, <BFP:MODE>mode), + LT, NULL_RTX, VOIDmode, 0, label1); emit_insn (gen_sub<BFP:mode>3 (temp, operands[1], CONST_DOUBLE_FROM_REAL_VALUE (sub, <BFP:MODE>mode))); emit_insn (gen_fix_trunc<BFP:mode><GPR:mode>2_bfp (operands[0], temp, @@ -5074,7 +5034,7 @@ (match_operand:GPR 3 "const_int_operand" "")] "TARGET_CPU_ZARCH" "if (!s390_expand_addcc (GET_CODE (operands[1]), - s390_compare_op0, s390_compare_op1, + XEXP (operands[1], 0), XEXP (operands[1], 1), operands[0], operands[2], operands[3])) FAIL; DONE;") @@ -5114,31 +5074,29 @@ "") -(define_expand "s<code>" +(define_expand "cstore<mode>4" [(set (match_operand:SI 0 "register_operand" "") - (SCOND (match_dup 0) - (match_dup 0)))] + (match_operator:SI 1 "s390_scond_operator" + [(match_operand:GPR 2 "register_operand" "") + (match_operand:GPR 3 "general_operand" "")]))] "TARGET_CPU_ZARCH" - "if (!s390_expand_addcc (<CODE>, s390_compare_op0, s390_compare_op1, + "if (!s390_expand_addcc (GET_CODE (operands[1]), operands[2], operands[3], operands[0], const0_rtx, const1_rtx)) FAIL; DONE;") -(define_expand "seq" +(define_expand "cstorecc4" [(parallel - [(set (match_operand:SI 0 "register_operand" "=d") - (match_dup 1)) - (clobber (reg:CC CC_REGNUM))]) - (parallel - [(set (match_dup 0) (xor:SI (match_dup 0) (const_int 1))) + [(set (match_operand:SI 0 "register_operand" "") + (match_operator:SI 1 "s390_eqne_operator" + [(match_operand:CCZ1 2 "register_operand") + (match_operand 3 "const0_operand")])) (clobber (reg:CC CC_REGNUM))])] "" -{ - if (GET_MODE (s390_compare_op0) != CCZ1mode) - FAIL; - operands[1] = s390_emit_compare (NE, s390_compare_op0, s390_compare_op1); - PUT_MODE (operands[1], SImode); -}) + "emit_insn (gen_sne (operands[0], operands[2])); + if (GET_CODE (operands[1]) == EQ) + emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx)); + DONE;") -(define_insn_and_split "*sne" +(define_insn_and_split "sne" [(set (match_operand:SI 0 "register_operand" "=d") (ne:SI (match_operand:CCZ1 1 "register_operand" "0") (const_int 0))) @@ -5566,8 +5524,8 @@ operands[1] = make_safe_from (operands[1], operands[0]); emit_move_insn (operands[0], const0_rtx); - emit_insn (gen_cmpsi (operands[1], operands[2])); - emit_jump_insn (gen_bltu (label1)); + emit_cmp_and_jump_insns (operands[1], operands[2], LT, NULL_RTX, + SImode, 1, label1); emit_move_insn (operands[0], const1_rtx); emit_label (label1); } @@ -5598,12 +5556,12 @@ operands[2] = make_safe_from (operands[2], operands[0]); emit_move_insn (operands[0], const0_rtx); - emit_insn (gen_cmpsi (operands[2], operands[1])); - emit_jump_insn (gen_bgtu (label3)); - emit_insn (gen_cmpsi (operands[2], const0_rtx)); - emit_jump_insn (gen_blt (label2)); - emit_insn (gen_cmpsi (operands[2], const1_rtx)); - emit_jump_insn (gen_beq (label1)); + emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX, + SImode, 1, label3); + emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX, + SImode, 0, label2); + emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX, + SImode, 0, label1); emit_insn (gen_zero_extendsidi2 (operands[3], operands[1])); insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3], operands[2])); @@ -5652,8 +5610,8 @@ operands[1] = make_safe_from (operands[1], operands[0]); emit_move_insn (operands[0], operands[1]); - emit_insn (gen_cmpsi (operands[0], operands[2])); - emit_jump_insn (gen_bltu (label1)); + emit_cmp_and_jump_insns (operands[0], operands[2], LT, NULL_RTX, + SImode, 1, label1); emit_insn (gen_abssi2 (operands[0], operands[2])); emit_insn (gen_addsi3 (operands[0], operands[0], operands[1])); emit_label (label1); @@ -5685,12 +5643,12 @@ operands[2] = make_safe_from (operands[2], operands[0]); emit_move_insn(operands[0], operands[1]); - emit_insn (gen_cmpsi (operands[2], operands[1])); - emit_jump_insn (gen_bgtu (label3)); - emit_insn (gen_cmpsi (operands[2], const0_rtx)); - emit_jump_insn (gen_blt (label2)); - emit_insn (gen_cmpsi (operands[2], const1_rtx)); - emit_jump_insn (gen_beq (label1)); + emit_cmp_and_jump_insns (operands[2], operands[1], GT, NULL_RTX, + SImode, 1, label3); + emit_cmp_and_jump_insns (operands[2], const0_rtx, LT, NULL_RTX, + SImode, 0, label2); + emit_cmp_and_jump_insns (operands[2], const1_rtx, EQ, NULL_RTX, + SImode, 0, label1); emit_insn (gen_zero_extendsidi2 (operands[3], operands[1])); insn = emit_insn (gen_divmoddisi3 (operands[3], operands[3], operands[2])); @@ -7359,15 +7317,42 @@ ;; Branch instruction patterns. ;; -(define_expand "b<code>" +(define_expand "cbranch<mode>4" [(set (pc) - (if_then_else (COMPARE (match_operand 0 "" "") - (const_int 0)) - (match_dup 0) + (if_then_else (match_operator 0 "comparison_operator" + [(match_operand:GPR 1 "register_operand" "") + (match_operand:GPR 2 "general_operand" "")]) + (label_ref (match_operand 3 "" "")) (pc)))] "" - "s390_emit_jump (operands[0], - s390_emit_compare (<CODE>, s390_compare_op0, s390_compare_op1)); DONE;") + "s390_emit_jump (operands[3], + s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2])); + DONE;") + +(define_expand "cbranch<mode>4" + [(set (pc) + (if_then_else (match_operator 0 "comparison_operator" + [(match_operand:FP 1 "register_operand" "") + (match_operand:FP 2 "general_operand" "")]) + (label_ref (match_operand 3 "" "")) + (pc)))] + "TARGET_HARD_FLOAT" + "s390_emit_jump (operands[3], + s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2])); + DONE;") + +(define_expand "cbranchcc4" + [(set (pc) + (if_then_else (match_operator 0 "s390_eqne_operator" + [(match_operand 1 "cc_reg_operand" "") + (match_operand 2 "const0_operand" "")]) + (label_ref (match_operand 3 "" "")) + (pc)))] + "TARGET_HARD_FLOAT" + "s390_emit_jump (operands[3], + s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2])); + DONE;") + ;; @@ -7506,18 +7491,36 @@ [(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" ""))] +(define_expand "ctrap<mode>4" + [(trap_if (match_operator 0 "comparison_operator" + [(match_operand:GPR 1 "register_operand" "") + (match_operand:GPR 2 "general_operand" "")]) + (match_operand 3 "const0_operand" ""))] "" -{ - if (operands[1] != const0_rtx) FAIL; - operands[0] = s390_emit_compare (GET_CODE (operands[0]), - s390_compare_op0, s390_compare_op1); -}) + { + rtx cond = s390_emit_compare (GET_CODE (operands[0]), + operands[1], operands[2]); + emit_insn (gen_condtrap (cond, XEXP (cond, 0))); + DONE; + }) + +(define_expand "ctrap<mode>4" + [(trap_if (match_operator 0 "comparison_operator" + [(match_operand:FP 1 "register_operand" "") + (match_operand:FP 2 "general_operand" "")]) + (match_operand 3 "const0_operand" ""))] + "" + { + rtx cond = s390_emit_compare (GET_CODE (operands[0]), + operands[1], operands[2]); + emit_insn (gen_condtrap (cond, XEXP (cond, 0))); + DONE; + }) -(define_insn "*trap" - [(trap_if (match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 0)]) +(define_insn "condtrap" + [(trap_if (match_operator 0 "s390_comparison" + [(match_operand 1 "cc_reg_operand" "c") + (const_int 0)]) (const_int 0))] "" "j%C0\t.+2"; @@ -8665,6 +8668,7 @@ (match_operand 2 "" "")] "" { + rtx cc_reg, test; #ifdef TARGET_THREAD_SSP_OFFSET operands[1] = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, s390_get_thread_pointer (), @@ -8675,9 +8679,9 @@ else emit_insn (gen_stack_protect_testsi (operands[0], operands[1])); - s390_compare_op0 = gen_rtx_REG (CCZmode, CC_REGNUM); - s390_compare_op1 = const0_rtx; - emit_jump_insn (gen_beq (operands[2])); + cc_reg = gen_rtx_REG (CCZmode, CC_REGNUM); + test = gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx); + emit_jump_insn (gen_cbranchcc4 (test, cc_reg, const0_rtx, operands[2])); DONE; }) |