+2015-07-05 Richard Sandiford <richard.sandiford@arm.com>
+
+ * target-insns.def (doloop_begin, doloop_end): New targetm
+ instruction patterns.
+ * loop-init.c: Include target.h.
+ (pass_loop2::gate): Use the new targetm patterns instead of
+ HAVE_*/gen_* interface.
+ (pass_rtl_doloop::gate): Likewise.
+ (pass_rtl_doloop::execute): Remove preprocessor condition.
+ * hw-doloop.c: Build unconditionally.
+ * loop-doloop.c: Likewise.
+ (doloop_optimize): Use the new targetm patterns instead of
+ HAVE_*/gen_* interface.
+ (doloop_modify): Likewise. Change type of doloop_seq to rtx_insn *.
+ * modulo-sched.c (doloop_register_get): Likewise.
+
2015-07-05 Richard Sandiford <richard.sandiford@arm.com>
* target-insns.def (clear_cache): New targetm instruction pattern.
register cannot be used for anything else but doloop -- ??? detect these
cases). */
-#ifdef HAVE_doloop_end
-
/* Return the loop termination condition for PATTERN or zero
if it is not a decrement and branch jump insn. */
static void
doloop_modify (struct loop *loop, struct niter_desc *desc,
- rtx doloop_seq, rtx condition, rtx count)
+ rtx_insn *doloop_seq, rtx condition, rtx count)
{
rtx counter_reg;
rtx tmp, noloop = NULL_RTX;
/* Some targets (eg, C4x) need to initialize special looping
registers. */
-#ifdef HAVE_doloop_begin
- {
- rtx init;
-
- init = gen_doloop_begin (counter_reg, doloop_seq);
- if (init)
- {
- start_sequence ();
- emit_insn (init);
- sequence = get_insns ();
- end_sequence ();
- emit_insn_after (sequence, BB_END (loop_preheader_edge (loop)->src));
- }
- }
-#endif
+ if (targetm.have_doloop_begin ())
+ if (rtx_insn *seq = targetm.gen_doloop_begin (counter_reg, doloop_seq))
+ emit_insn_after (seq, BB_END (loop_preheader_edge (loop)->src));
/* Insert the new low-overhead looping insn. */
emit_jump_insn_after (doloop_seq, BB_END (loop_end));
doloop_optimize (struct loop *loop)
{
machine_mode mode;
- rtx doloop_seq, doloop_pat, doloop_reg;
+ rtx doloop_reg;
rtx count;
widest_int iterations, iterations_max;
rtx_code_label *start_label;
count = copy_rtx (desc->niter_expr);
start_label = block_label (desc->in_edge->dest);
doloop_reg = gen_reg_rtx (mode);
- doloop_seq = gen_doloop_end (doloop_reg, start_label);
+ rtx_insn *doloop_seq = targetm.gen_doloop_end (doloop_reg, start_label);
word_mode_size = GET_MODE_PRECISION (word_mode);
word_mode_max
else
count = lowpart_subreg (word_mode, count, mode);
PUT_MODE (doloop_reg, word_mode);
- doloop_seq = gen_doloop_end (doloop_reg, start_label);
+ doloop_seq = targetm.gen_doloop_end (doloop_reg, start_label);
}
if (! doloop_seq)
{
}
/* If multiple instructions were created, the last must be the
- jump instruction. Also, a raw define_insn may yield a plain
- pattern. */
- doloop_pat = doloop_seq;
- if (INSN_P (doloop_pat))
- {
- rtx_insn *doloop_insn = as_a <rtx_insn *> (doloop_pat);
- while (NEXT_INSN (doloop_insn) != NULL_RTX)
- doloop_insn = NEXT_INSN (doloop_insn);
- if (!JUMP_P (doloop_insn))
- doloop_insn = NULL;
- doloop_pat = doloop_insn;
- }
-
- if (! doloop_pat
- || ! (condition = doloop_condition_get (doloop_pat)))
+ jump instruction. */
+ rtx_insn *doloop_insn = doloop_seq;
+ while (NEXT_INSN (doloop_insn) != NULL_RTX)
+ doloop_insn = NEXT_INSN (doloop_insn);
+ if (!JUMP_P (doloop_insn)
+ || !(condition = doloop_condition_get (doloop_insn)))
{
if (dump_file)
fprintf (dump_file, "Doloop: Unrecognizable doloop pattern!\n");
verify_loop_structure ();
#endif
}
-#endif /* HAVE_doloop_end */
-
#include "tree-ssa-loop-niter.h"
#include "loop-unroll.h"
#include "tree-scalar-evolution.h"
+#include "target.h"
\f
/* Apply FLAGS to the loop state. */
&& (flag_move_loop_invariants
|| flag_unswitch_loops
|| flag_unroll_loops
-#ifdef HAVE_doloop_end
- || (flag_branch_on_count_reg && HAVE_doloop_end)
-#endif
- ))
+ || (flag_branch_on_count_reg
+ && targetm.have_doloop_end ())))
return true;
else
{
bool
pass_rtl_doloop::gate (function *)
{
-#ifdef HAVE_doloop_end
- return (flag_branch_on_count_reg && HAVE_doloop_end);
-#else
- return false;
-#endif
+ return (flag_branch_on_count_reg && targetm.have_doloop_end ());
}
unsigned int
-pass_rtl_doloop::execute (function *fun ATTRIBUTE_UNUSED)
+pass_rtl_doloop::execute (function *fun)
{
-#ifdef HAVE_doloop_end
if (number_of_loops (fun) > 1)
doloop_optimize_loops ();
-#endif
return 0;
}
more than one occurrence in the loop besides the control part or the
do-loop pattern is not of the form we expect. */
static rtx
-doloop_register_get (rtx_insn *head ATTRIBUTE_UNUSED, rtx_insn *tail ATTRIBUTE_UNUSED)
+doloop_register_get (rtx_insn *head, rtx_insn *tail)
{
-#ifdef HAVE_doloop_end
rtx reg, condition;
rtx_insn *insn, *first_insn_not_to_check;
if (!JUMP_P (tail))
return NULL_RTX;
+ if (!targetm.code_for_doloop_end)
+ return NULL_RTX;
+
/* TODO: Free SMS's dependence on doloop_condition_get. */
condition = doloop_condition_get (tail);
if (! condition)
}
return reg;
-#else
- return NULL_RTX;
-#endif
}
/* Check if COUNT_REG is set to a constant in the PRE_HEADER block, so
DEF_TARGET_INSN (casesi, (rtx x0, rtx x1, rtx x2, rtx x3, rtx x4))
DEF_TARGET_INSN (check_stack, (rtx x0))
DEF_TARGET_INSN (clear_cache, (rtx x0, rtx x1))
+DEF_TARGET_INSN (doloop_begin, (rtx x0, rtx x1))
+DEF_TARGET_INSN (doloop_end, (rtx x0, rtx x1))
DEF_TARGET_INSN (epilogue, (void))
DEF_TARGET_INSN (exception_receiver, (void))
DEF_TARGET_INSN (jump, (rtx x0))