From 9d8895c9342d2c46d7d7e9b0437879db9d60cf7c Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 26 Jun 2015 10:06:56 +0000 Subject: [PATCH] rtl.h (emit): Add an optional boolean parameter to control whether barriers are emitted. gcc/ * rtl.h (emit): Add an optional boolean parameter to control whether barriers are emitted. * emit-rtl.c (emit): Likewise. * gensupport.c (get_emit_function): Return null rather than "emit". * genemit.c (gen_emit_seq): Handle the null return value. Don't emit barriers after the final instruction in the sequence. * gentarget-def.c (main): Don't emit barriers after the instruction. From-SVN: r225000 --- gcc/ChangeLog | 10 ++++++++++ gcc/emit-rtl.c | 10 +++++++--- gcc/genemit.c | 20 +++++++++++++++----- gcc/gensupport.c | 6 ++++-- gcc/gentarget-def.c | 2 +- gcc/rtl.h | 2 +- 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ecc209fec3c..bd9abfc6702 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2015-06-26 Richard Sandiford + + * rtl.h (emit): Add an optional boolean parameter to control + whether barriers are emitted. + * emit-rtl.c (emit): Likewise. + * gensupport.c (get_emit_function): Return null rather than "emit". + * genemit.c (gen_emit_seq): Handle the null return value. + Don't emit barriers after the final instruction in the sequence. + * gentarget-def.c (main): Don't emit barriers after the instruction. + 2015-06-26 Ramana Radhakrishnan * config/arm/arm.c (arm_output_multireg_pop): Fix use of diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index e7f7eab4fe2..80c0adb1a35 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -5303,11 +5303,14 @@ set_dst_reg_note (rtx insn, enum reg_note kind, rtx datum, rtx dst) return NULL_RTX; } -/* Emit the rtl pattern X as an appropriate kind of insn. +/* Emit the rtl pattern X as an appropriate kind of insn. Also emit a + following barrier if the instruction needs one and if ALLOW_BARRIER_P + is true. + If X is a label, it is simply added into the insn chain. */ rtx_insn * -emit (rtx x) +emit (rtx x, bool allow_barrier_p) { enum rtx_code code = classify_insn (x); @@ -5320,7 +5323,8 @@ emit (rtx x) case JUMP_INSN: { rtx_insn *insn = emit_jump_insn (x); - if (any_uncondjump_p (insn) || GET_CODE (x) == RETURN) + if (allow_barrier_p + && (any_uncondjump_p (insn) || GET_CODE (x) == RETURN)) return emit_barrier (); return insn; } diff --git a/gcc/genemit.c b/gcc/genemit.c index 15ec08192ba..4ee07a0f3bc 100644 --- a/gcc/genemit.c +++ b/gcc/genemit.c @@ -277,12 +277,22 @@ gen_emit_seq (rtvec vec, char *used) { for (int i = 0, len = GET_NUM_ELEM (vec); i < len; ++i) { + bool last_p = (i == len - 1); rtx next = RTVEC_ELT (vec, i); - printf (" %s (", get_emit_function (next)); - gen_exp (next, DEFINE_EXPAND, used); - printf (");\n"); - if (needs_barrier_p (next)) - printf (" emit_barrier ();"); + if (const char *name = get_emit_function (next)) + { + printf (" %s (", name); + gen_exp (next, DEFINE_EXPAND, used); + printf (");\n"); + if (!last_p && needs_barrier_p (next)) + printf (" emit_barrier ();"); + } + else + { + printf (" emit ("); + gen_exp (next, DEFINE_EXPAND, used); + printf (", %s);\n", last_p ? "false" : "true"); + } } } diff --git a/gcc/gensupport.c b/gcc/gensupport.c index 916fbc10b92..729366c9546 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -2983,7 +2983,9 @@ get_pattern_stats (struct pattern_stats *stats, rtvec pattern) stats->max_scratch_opno)) + 1; } -/* Return the emit_* function that should be used for pattern X. */ +/* Return the emit_* function that should be used for pattern X, or NULL + if we can't pick a particular type at compile time and should instead + fall back to "emit". */ const char * get_emit_function (rtx x) @@ -3000,7 +3002,7 @@ get_emit_function (rtx x) return "emit_jump_insn"; case UNKNOWN: - return "emit"; + return NULL; default: gcc_unreachable (); diff --git a/gcc/gentarget-def.c b/gcc/gentarget-def.c index bca94804e18..c1125dde2fe 100644 --- a/gcc/gentarget-def.c +++ b/gcc/gentarget-def.c @@ -245,7 +245,7 @@ main (int argc, char **argv) printf (" if (rtx_insn *insn = dyn_cast (x))\n"); printf (" return insn;\n"); printf (" start_sequence ();\n"); - printf (" emit (x);\n"); + printf (" emit (x, false);\n"); printf (" rtx_insn *res = get_insns ();\n"); printf (" end_sequence ();\n"); printf (" return res;\n"); diff --git a/gcc/rtl.h b/gcc/rtl.h index 37ec7d4c6bf..d74c20fbed1 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3494,7 +3494,7 @@ extern void add_insn (rtx_insn *); extern void add_insn_before (rtx, rtx, basic_block); extern void add_insn_after (rtx, rtx, basic_block); extern void remove_insn (rtx); -extern rtx_insn *emit (rtx); +extern rtx_insn *emit (rtx, bool = true); extern void emit_insn_at_entry (rtx); extern rtx gen_lowpart_SUBREG (machine_mode, rtx); extern rtx gen_const_mem (machine_mode, rtx); -- 2.30.2