From: Segher Boessenkool Date: Mon, 28 Sep 2020 23:57:52 +0000 (+0000) Subject: rs6000: Use parameterized names for tablejump X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=58614b10edc9a66fa3ef23dd0fee034e3a2cbc2d;p=gcc.git rs6000: Use parameterized names for tablejump We have too many tablejump patterns. Using parameterized names simplifies the code a bit. 2020-09-29 Segher Boessenkool * config/rs6000/rs6000.md (tablejump): Simplify. (tablejumpsi): Merge this ... (tablejumpdi): ... and this ... (@tablejump_normal): ... into this. (tablejumpsi_nospec): Merge this ... (tablejumpdi_nospec): ... and this ... (@tablejump_nospec): ... into this. (*tablejump_internal1): Delete, rename to ... (@tablejump_insn_normal): ... this. (*tablejump_internal1_nospec): Delete, rename to ... (@tablejump_insn_nospec): ... this. --- diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 694ff70635e..24ad80993ad 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -12697,12 +12697,7 @@ "" { if (rs6000_speculate_indirect_jumps) - { - if (TARGET_32BIT) - emit_jump_insn (gen_tablejumpsi (operands[0], operands[1])); - else - emit_jump_insn (gen_tablejumpdi (operands[0], operands[1])); - } + emit_jump_insn (gen_tablejump_normal (Pmode, operands[0], operands[1])); else { rtx ccreg = gen_reg_rtx (CCmode); @@ -12716,69 +12711,55 @@ DONE; }) -(define_expand "tablejumpsi" - [(set (match_dup 3) - (plus:SI (match_operand:SI 0) - (match_dup 2))) - (parallel [(set (pc) - (match_dup 3)) - (use (label_ref (match_operand 1)))])] - "TARGET_32BIT && rs6000_speculate_indirect_jumps" +(define_expand "@tablejump_normal" + [(use (match_operand:SI 0)) + (use (match_operand:P 1))] + "rs6000_speculate_indirect_jumps" { operands[0] = force_reg (SImode, operands[0]); - operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1])); - operands[3] = gen_reg_rtx (SImode); + if (mode == SImode) + operands[4] = operands[0]; + else + { + operands[4] = gen_reg_rtx (Pmode); + rtx src = gen_rtx_fmt_e (SIGN_EXTEND, Pmode, operands[0]); + emit_move_insn (operands[4], src); + } + + operands[2] = force_reg (Pmode, gen_rtx_LABEL_REF (Pmode, operands[1])); + operands[3] = gen_reg_rtx (Pmode); + + emit_insn (gen_add3 (operands[3], operands[4], operands[2])); + emit_jump_insn (gen_tablejump_insn_normal (Pmode, operands[3], operands[1])); + DONE; }) -(define_expand "tablejumpsi_nospec" - [(set (match_dup 4) - (plus:SI (match_operand:SI 0) - (match_dup 3))) - (parallel [(set (pc) - (match_dup 4)) - (use (label_ref (match_operand 1))) - (clobber (match_operand 2))])] - "TARGET_32BIT && !rs6000_speculate_indirect_jumps" +(define_expand "@tablejump_nospec" + [(use (match_operand:SI 0)) + (use (match_operand:P 1)) + (use (match_operand:CC 2))] + "!rs6000_speculate_indirect_jumps" { operands[0] = force_reg (SImode, operands[0]); - operands[3] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1])); - operands[4] = gen_reg_rtx (SImode); -}) + if (mode == SImode) + operands[4] = operands[0]; + else + { + operands[4] = gen_reg_rtx (Pmode); + rtx src = gen_rtx_fmt_e (SIGN_EXTEND, Pmode, operands[0]); + emit_move_insn (operands[4], src); + } -(define_expand "tablejumpdi" - [(set (match_dup 4) - (sign_extend:DI (match_operand:SI 0 "lwa_operand"))) - (set (match_dup 3) - (plus:DI (match_dup 4) - (match_dup 2))) - (parallel [(set (pc) - (match_dup 3)) - (use (label_ref (match_operand 1)))])] - "TARGET_64BIT && rs6000_speculate_indirect_jumps" -{ - operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1])); - operands[3] = gen_reg_rtx (DImode); - operands[4] = gen_reg_rtx (DImode); -}) + operands[5] = force_reg (Pmode, gen_rtx_LABEL_REF (Pmode, operands[1])); + operands[3] = gen_reg_rtx (Pmode); -(define_expand "tablejumpdi_nospec" - [(set (match_dup 5) - (sign_extend:DI (match_operand:SI 0 "lwa_operand"))) - (set (match_dup 4) - (plus:DI (match_dup 5) - (match_dup 3))) - (parallel [(set (pc) - (match_dup 4)) - (use (label_ref (match_operand 1))) - (clobber (match_operand 2))])] - "TARGET_64BIT && !rs6000_speculate_indirect_jumps" -{ - operands[3] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1])); - operands[4] = gen_reg_rtx (DImode); - operands[5] = gen_reg_rtx (DImode); + emit_insn (gen_add3 (operands[3], operands[4], operands[5])); + emit_jump_insn (gen_tablejump_insn_nospec (Pmode, operands[3], operands[1], + operands[2])); + DONE; }) -(define_insn "*tablejump_internal1" +(define_insn "@tablejump_insn_normal" [(set (pc) (match_operand:P 0 "register_operand" "c,*l")) (use (label_ref (match_operand 1)))] @@ -12786,7 +12767,7 @@ "b%T0" [(set_attr "type" "jmpreg")]) -(define_insn "*tablejump_internal1_nospec" +(define_insn "@tablejump_insn_nospec" [(set (pc) (match_operand:P 0 "register_operand" "c,*l")) (use (label_ref (match_operand 1)))