@@ -6499,6 +6499,16 @@ should probably only be given to addresses with different numbers of
registers on machines with lots of registers.
@end deftypefn
+@deftypefn {Target Hook} {unsigned int} TARGET_RTX_BRANCH_COST (bool @var{speed_p}, bool @var{predictable_p})
+This hook should return a cost in the same units as
+ @code{TARGET_RTX_COSTS}, giving the estimated cost of a branch.
+ @code{speed_p} is true if we are compiling for speed.
+ @code{predictable_p} is true if analysis suggests that the branch
+ will be predictable. The default implementation of this hook
+ multiplies @code{BRANCH_COST} by the cost of a cheap instruction to
+ approximate the cost of a branch in the appropriate units.
+@end deftypefn
+
@deftypefn {Target Hook} bool TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P (void)
This predicate controls the use of the eager delay slot filler to disallow
speculatively executed instructions being placed in delay slots. Targets
@@ -4748,6 +4748,8 @@ Define this macro if a non-short-circuit operation produced by
@hook TARGET_ADDRESS_COST
+@hook TARGET_RTX_BRANCH_COST
+
@hook TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P
@node Scheduling
@@ -3559,6 +3559,20 @@ registers on machines with lots of registers.",
int, (rtx address, machine_mode mode, addr_space_t as, bool speed),
default_address_cost)
+/* Give a cost, in RTX Costs units, for an edge. Like BRANCH_COST, but with
+ well defined units. */
+DEFHOOK
+(rtx_branch_cost,
+ "This hook should return a cost in the same units as\n\
+ @code{TARGET_RTX_COSTS}, giving the estimated cost of a branch.\n\
+ @code{speed_p} is true if we are compiling for speed.\n\
+ @code{predictable_p} is true if analysis suggests that the branch\n\
+ will be predictable. The default implementation of this hook\n\
+ multiplies @code{BRANCH_COST} by the cost of a cheap instruction to\n\
+ approximate the cost of a branch in the appropriate units.",
+ unsigned int, (bool speed_p, bool predictable_p),
+ default_rtx_branch_cost)
+
/* Permit speculative instructions in delay slots during delayed-branch
scheduling. */
DEFHOOK
@@ -74,6 +74,7 @@ along with GCC; see the file COPYING3. If not see
#include "intl.h"
#include "opts.h"
#include "gimplify.h"
+#include "predict.h"
bool
@@ -1965,4 +1966,13 @@ default_optab_supported_p (int, machine_mode, machine_mode, optimization_type)
return true;
}
+/* Default implementation of TARGET_RTX_BRANCH_COST. */
+
+unsigned int
+default_rtx_branch_cost (bool speed_p,
+ bool predictable_p)
+{
+ return BRANCH_COST (speed_p, predictable_p) * COSTS_N_INSNS (1);
+}
+
#include "gt-targhooks.h"
@@ -254,4 +254,6 @@ extern void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE
extern bool default_optab_supported_p (int, machine_mode, machine_mode,
optimization_type);
+extern unsigned int default_rtx_branch_cost (bool, bool);
+
#endif /* GCC_TARGHOOKS_H */