Commit 94105f5c by Segher Boessenkool Committed by Segher Boessenkool

Add targetm.insn_cost hook

This adds a new hook that the insn_cost function uses if a target has
implemented it (it uses the old pattern_cost nee insn_rtx_cost if not).


	* target.def (insn_cost): New hook.
	* doc/tm.texi.in (TARGET_INSN_COST): New hook.
	* doc/tm.texi: Regenerate.
	* rtlanal.c (insn_cost): Use the new hook.

From-SVN: r253562
parent a6f9eb8d
2017-10-09 Segher Boessenkool <segher@kernel.crashing.org> 2017-10-09 Segher Boessenkool <segher@kernel.crashing.org>
* target.def (insn_cost): New hook.
* doc/tm.texi.in (TARGET_INSN_COST): New hook.
* doc/tm.texi: Regenerate.
* rtlanal.c (insn_cost): Use the new hook.
2017-10-09 Segher Boessenkool <segher@kernel.crashing.org>
* combine.c (combine_validate_cost): Compute the new insn_cost, * combine.c (combine_validate_cost): Compute the new insn_cost,
not just pattern_cost. not just pattern_cost.
(try_combine): Adjust comment. (try_combine): Adjust comment.
...@@ -6652,6 +6652,18 @@ should probably only be given to addresses with different numbers of ...@@ -6652,6 +6652,18 @@ should probably only be given to addresses with different numbers of
registers on machines with lots of registers. registers on machines with lots of registers.
@end deftypefn @end deftypefn
@deftypefn {Target Hook} int TARGET_INSN_COST (rtx_insn *@var{insn}, bool @var{speed})
This target hook describes the relative costs of RTL instructions.
In implementing this hook, you can use the construct
@code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast
instructions.
When optimizing for code size, i.e.@: when @code{speed} is
false, this target hook should be used to estimate the relative
size cost of an expression, again relative to @code{COSTS_N_INSNS}.
@end deftypefn
@deftypefn {Target Hook} {unsigned int} TARGET_MAX_NOCE_IFCVT_SEQ_COST (edge @var{e}) @deftypefn {Target Hook} {unsigned int} TARGET_MAX_NOCE_IFCVT_SEQ_COST (edge @var{e})
This hook returns a value in the same units as @code{TARGET_RTX_COSTS}, This hook returns a value in the same units as @code{TARGET_RTX_COSTS},
giving the maximum acceptable cost for a sequence generated by the RTL giving the maximum acceptable cost for a sequence generated by the RTL
......
...@@ -4600,6 +4600,8 @@ Define this macro if a non-short-circuit operation produced by ...@@ -4600,6 +4600,8 @@ Define this macro if a non-short-circuit operation produced by
@hook TARGET_ADDRESS_COST @hook TARGET_ADDRESS_COST
@hook TARGET_INSN_COST
@hook TARGET_MAX_NOCE_IFCVT_SEQ_COST @hook TARGET_MAX_NOCE_IFCVT_SEQ_COST
@hook TARGET_NOCE_CONVERSION_PROFITABLE_P @hook TARGET_NOCE_CONVERSION_PROFITABLE_P
......
...@@ -5329,6 +5329,9 @@ pattern_cost (rtx pat, bool speed) ...@@ -5329,6 +5329,9 @@ pattern_cost (rtx pat, bool speed)
int int
insn_cost (rtx_insn *insn, bool speed) insn_cost (rtx_insn *insn, bool speed)
{ {
if (targetm.insn_cost)
return targetm.insn_cost (insn, speed);
return pattern_cost (PATTERN (insn), speed); return pattern_cost (PATTERN (insn), speed);
} }
......
...@@ -3715,6 +3715,20 @@ registers on machines with lots of registers.", ...@@ -3715,6 +3715,20 @@ registers on machines with lots of registers.",
int, (rtx address, machine_mode mode, addr_space_t as, bool speed), int, (rtx address, machine_mode mode, addr_space_t as, bool speed),
default_address_cost) default_address_cost)
/* Compute a cost for INSN. */
DEFHOOK
(insn_cost,
"This target hook describes the relative costs of RTL instructions.\n\
\n\
In implementing this hook, you can use the construct\n\
@code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast\n\
instructions.\n\
\n\
When optimizing for code size, i.e.@: when @code{speed} is\n\
false, this target hook should be used to estimate the relative\n\
size cost of an expression, again relative to @code{COSTS_N_INSNS}.",
int, (rtx_insn *insn, bool speed), NULL)
/* Give a cost, in RTX Costs units, for an edge. Like BRANCH_COST, but with /* Give a cost, in RTX Costs units, for an edge. Like BRANCH_COST, but with
well defined units. */ well defined units. */
DEFHOOK DEFHOOK
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment