From 1d0216c8b79931cffcc5599b8a9a4f6eaf86d2b7 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sat, 9 Nov 2013 11:42:16 +0000 Subject: target.def (can_use_doloop_p): New hook. gcc/ * target.def (can_use_doloop_p): New hook. * doc/tm.texi.in (TARGET_CAN_USE_DOLOOP_P): Add. * doc/tm.texi: Regenerate. * doc/md.texi (doloop_begin, doloop_end): Update documentation. * hooks.h (hook_bool_dint_dint_uint_true): Declare. * hooks.c (hook_bool_dint_dint_uint_true): New function. * targhooks.h (can_use_doloop_if_innermost): Declare. * targhooks.c (can_use_doloop_if_innermost): New function. * target.h: Include double-int.h. * loop-doloop.c (doloop_optimize): Call targetm.can_use_doloop_p. Remove iteration count, maximum iteration count, loop depth and enter-at-top inputs from doloop_begin and doloop_end. * config/arc/arc.md (doloop_begin, doloop_end): Update for new interface. * config/arc/arc.c (arc_can_use_doloop_p): New function. (TARGET_CAN_USE_DOLOOP_P): Define. * config/arm/thumb2.md (doloop_end): Update for new interface. * config/arm/arm.c (TARGET_CAN_USE_DOLOOP_P): Define. * config/bfin/bfin.md (doloop_end): Update for new interface. * config/bfin/bfin.c (bfin_can_use_doloop_p): New function. (TARGET_CAN_USE_DOLOOP_P): Define. * config/c6x/c6x.md (doloop_end): Update for new interface. * config/ia64/ia64.md (doloop_end): Update for new interface. * config/ia64/ia64.c (TARGET_CAN_USE_DOLOOP_P): Define. * config/mep/mep.md (doloop_begin, doloop_end): Update for new interface. * config/mep/mep.c (mep_emit_doloop): Likewise. (TARGET_CAN_USE_DOLOOP_P): Define. * config/rs6000/rs6000.md (doloop_end): Update for new interface. * config/rs6000/rs6000.c (TARGET_CAN_USE_DOLOOP_P): Define. * config/s390/s390.md (doloop_end): Update for new interface. * config/sh/sh.md (doloop_end): Likewise. * config/spu/spu.md (doloop_end): Likewise. * config/spu/spu.c (TARGET_CAN_USE_DOLOOP_P): Define. * config/tilegx/tilegx.md (doloop_end): Update for new interface. * config/tilegx/tilegx.c (TARGET_CAN_USE_DOLOOP_P): Define. * config/tilepro/tilepro.md (doloop_end): Update for new interface. * config/tilepro/tilepro.c (TARGET_CAN_USE_DOLOOP_P): Define. * config/v850/v850.md (doloop_begin, doloop_end): Update for new interface. * config/v850/v850.c (TARGET_CAN_USE_DOLOOP_P): Define. From-SVN: r204614 --- gcc/doc/md.texi | 31 ++++++++++++------------------- gcc/doc/tm.texi | 14 ++++++++++++++ gcc/doc/tm.texi.in | 2 ++ 3 files changed, 28 insertions(+), 19 deletions(-) (limited to 'gcc/doc') diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 1e22b88..1a06e3d 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -5857,34 +5857,27 @@ reduction is enabled. @cindex @code{doloop_end} instruction pattern @item @samp{doloop_end} -Conditional branch instruction that decrements a register and jumps if -the register is nonzero. This instruction takes five operands: Operand -0 is the register to decrement and test; operand 1 is the number of loop -iterations as a @code{const_int} or @code{const0_rtx} if this cannot be -determined until run-time; operand 2 is the actual or estimated maximum -number of iterations as a @code{const_int}; operand 3 is the number of -enclosed loops as a @code{const_int} (an innermost loop has a value of -1); operand 4 is the label to jump to if the register is nonzero; -operand 5 is const1_rtx if the loop in entered at its top, const0_rtx -otherwise. +Conditional branch instruction that decrements a register and +jumps if the register is nonzero. Operand 0 is the register to +decrement and test; operand 1 is the label to jump to if the +register is nonzero. @xref{Looping Patterns}. This optional instruction pattern should be defined for machines with low-overhead looping instructions as the loop optimizer will try to -modify suitable loops to utilize it. If nested low-overhead looping is -not supported, use a @code{define_expand} (@pxref{Expander Definitions}) -and make the pattern fail if operand 3 is not @code{const1_rtx}. -Similarly, if the actual or estimated maximum number of iterations is -too large for this instruction, make it fail. +modify suitable loops to utilize it. The target hook +@code{TARGET_CAN_USE_DOLOOP_P} controls the conditions under which +low-overhead loops can be used. @cindex @code{doloop_begin} instruction pattern @item @samp{doloop_begin} Companion instruction to @code{doloop_end} required for machines that -need to perform some initialization, such as loading special registers -used by a low-overhead looping instruction. If initialization insns do -not always need to be emitted, use a @code{define_expand} -(@pxref{Expander Definitions}) and make it fail. +need to perform some initialization, such as loading a special counter +register. Operand 1 is the associated @code{doloop_end} pattern and +operand 0 is the register that it decrements. +If initialization insns do not always need to be emitted, use a +@code{define_expand} (@pxref{Expander Definitions}) and make it fail. @cindex @code{canonicalize_funcptr_for_compare} instruction pattern @item @samp{canonicalize_funcptr_for_compare} diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 5e7910b..35cfa99 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -11091,6 +11091,20 @@ function version at run-time for a given set of function versions. body must be generated. @end deftypefn +@deftypefn {Target Hook} bool TARGET_CAN_USE_DOLOOP_P (double_int @var{iterations}, double_int @var{iterations_max}, unsigned int @var{loop_depth}, bool @var{entered_at_top}) +Return true if it is possible to use low-overhead loops (@code{doloop_end} +and @code{doloop_begin}) for a particular loop. @var{iterations} gives the +exact number of iterations, or 0 if not known. @var{iterations_max} gives +the maximum number of iterations, or 0 if not known. @var{loop_depth} is +the nesting depth of the loop, with 1 for innermost loops, 2 for loops that +contain innermost loops, and so on. @var{entered_at_top} is true if the +loop is only entered from the top. + +This hook is only used if @code{doloop_end} is available. The default +implementation returns true. You can use @code{can_use_doloop_if_innermost} +if the loop must be the innermost, and if there are no other restrictions. +@end deftypefn + @deftypefn {Target Hook} {const char *} TARGET_INVALID_WITHIN_DOLOOP (const_rtx @var{insn}) Take an instruction in @var{insn} and return NULL if it is valid within a diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 4e60d48..b10ecd7 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -8212,6 +8212,8 @@ to by @var{ce_info}. @hook TARGET_GENERATE_VERSION_DISPATCHER_BODY +@hook TARGET_CAN_USE_DOLOOP_P + @hook TARGET_INVALID_WITHIN_DOLOOP @hook TARGET_LEGITIMATE_COMBINED_INSN -- cgit v1.1