From 5074a1f86a57764f8fb5048e6008aab3e7064b7d Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Thu, 14 May 2015 20:40:44 +0000 Subject: [PATCH] re PR rtl-optimization/65862 ([MIPS] IRA/LRA issue: integers spilled to floating-point registers) 2015-05-14 Vladimir Makarov PR rtl-optimization/65862 * target.def (ira_change_pseudo_allocno_class): New hook. * targhooks.c (default_ira_change_pseudo_allocno_class): Default value of the hook. * targhooks.h (default_ira_change_pseudo_allocno_class): New extern * doc/tm.texi.in (TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS): Add the hook. * ira-costs.c (find_costs_and_classes): Call the hook and change classes when it is necessary. * doc/tm.texi: Update. From-SVN: r223202 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/doc/tm.texi | 7 +++++++ gcc/doc/tm.texi.in | 2 ++ gcc/ira-costs.c | 14 +++++++++++++- gcc/target.def | 10 ++++++++++ gcc/targhooks.c | 7 +++++++ gcc/targhooks.h | 1 + 7 files changed, 54 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 97aa0ebe341..bf28867ac4d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2015-05-14 Vladimir Makarov + + PR rtl-optimization/65862 + * target.def (ira_change_pseudo_allocno_class): New hook. + * targhooks.c (default_ira_change_pseudo_allocno_class): Default + value of the hook. + * targhooks.h (default_ira_change_pseudo_allocno_class): New + extern + * doc/tm.texi.in (TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS): Add the + hook. + * ira-costs.c (find_costs_and_classes): Call the hook and change + classes when it is necessary. + * doc/tm.texi: Update. + 2015-05-14 Alexander Monakov * config/i386/i386.md (sibcall_memory): Check that register with diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 9886f4ad2a9..3a89eee7933 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -2837,6 +2837,13 @@ as below: @end smallexample @end defmac +@deftypefn {Target Hook} reg_class_t TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS (int, @var{reg_class_t}) +A target hook which can change allocno class for given pseudo from + allocno class calculated by IRA. + + The default version of this target hook always returns given class. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_LRA_P (void) A target hook which returns true if we use LRA instead of reload pass. It means that LRA was ported to the target. The default version of this target hook returns always false. @end deftypefn diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 707d6104284..e76b8a05e90 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -2475,6 +2475,8 @@ as below: @end smallexample @end defmac +@hook TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS + @hook TARGET_LRA_P @hook TARGET_REGISTER_PRIORITY diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c index fa6aec44db0..b5c9bdd17c7 100644 --- a/gcc/ira-costs.c +++ b/gcc/ira-costs.c @@ -1636,7 +1636,7 @@ find_costs_and_classes (FILE *dump_file) int i, k, start, max_cost_classes_num; int pass; basic_block bb; - enum reg_class *regno_best_class; + enum reg_class *regno_best_class, new_class; init_recog (); regno_best_class @@ -1878,6 +1878,18 @@ find_costs_and_classes (FILE *dump_file) ira_assert (regno_aclass[i] != NO_REGS && ira_reg_allocno_class_p[regno_aclass[i]]); } + if ((new_class + = (reg_class) (targetm.ira_change_pseudo_allocno_class + (i, regno_aclass[i]))) != regno_aclass[i]) + { + regno_aclass[i] = new_class; + if (hard_reg_set_subset_p (reg_class_contents[new_class], + reg_class_contents[best])) + best = new_class; + if (hard_reg_set_subset_p (reg_class_contents[new_class], + reg_class_contents[alt_class])) + alt_class = new_class; + } if (pass == flag_expensive_optimizations) { if (best_cost > i_mem_cost) diff --git a/gcc/target.def b/gcc/target.def index eba992102aa..f2cb81dff05 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4763,6 +4763,16 @@ This is currently used only by the C and C++ front ends.", tree, (tree type, tree expr), hook_tree_tree_tree_null) +/* Change pseudo allocno class calculated by IRA. */ +DEFHOOK +(ira_change_pseudo_allocno_class, + "A target hook which can change allocno class for given pseudo from\n\ + allocno class calculated by IRA.\n\ + \n\ + The default version of this target hook always returns given class.", + reg_class_t, (int, reg_class_t), + default_ira_change_pseudo_allocno_class) + /* Return true if we use LRA instead of reload. */ DEFHOOK (lra_p, diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 806ff8cd512..44fcd9b6a12 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -914,6 +914,13 @@ default_branch_target_register_class (void) return NO_REGS; } +reg_class_t +default_ira_change_pseudo_allocno_class (int regno ATTRIBUTE_UNUSED, + reg_class_t cl) +{ + return cl; +} + extern bool default_lra_p (void) { diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 12a44ee8e72..5ae991d1250 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -140,6 +140,7 @@ extern rtx default_static_chain (const_tree, bool); extern void default_trampoline_init (rtx, tree, rtx); extern int default_return_pops_args (tree, tree, int); extern reg_class_t default_branch_target_register_class (void); +extern reg_class_t default_ira_change_pseudo_allocno_class (int, reg_class_t); extern bool default_lra_p (void); extern int default_register_priority (int); extern bool default_register_usage_leveling_p (void); -- 2.30.2