Patchwork [25/27] Put bb-reorder.c's uncond_jump_length into target structures

login
register
mail settings
Submitter Richard Sandiford
Date July 7, 2010, 9:32 p.m.
Message ID <8739vvrn9y.fsf@firetop.home>
Download mbox | patch
Permalink /patch/58192/
State New
Headers show

Comments

Richard Sandiford - July 7, 2010, 9:32 p.m.
Another case where a pass (bb-reorder) is caching target-dependent data.

Richard


gcc/
	* Makefile.in (bb-reorder.o, target-globals.o): Depend on bb-reorder.h
	* bb-reorder.h: New file.
	* bb-reorder.c (default_target_bb_reorder): New variable.
	(this_target_bb_reorder): New conditional variable.
	(uncond_jump_length): Redefine as a macro.
	* target-globals.h (this_target_bb_reorder): Declare.
	(target_globals): Add a bb_reorder field.
	(restore_target_globals): Copy the bb_reorder field to
	this_target_bb-reorder.
	* target-globals.c: Include bb-reorder.h.
	(default_target_globals): Initialize the bb_reorder field.
	(save_target_globals): Likewise.

Patch

Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	2010-07-07 22:29:12.000000000 +0100
+++ gcc/Makefile.in	2010-07-07 22:30:59.000000000 +0100
@@ -3430,7 +3430,7 @@  lists.o: lists.c $(CONFIG_H) $(SYSTEM_H)
 bb-reorder.o : bb-reorder.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(RTL_H) $(FLAGS_H) $(TIMEVAR_H) output.h $(CFGLAYOUT_H) $(FIBHEAP_H) \
    $(TARGET_H) $(FUNCTION_H) $(TM_P_H) $(OBSTACK_H) $(EXPR_H) $(REGS_H) \
-   $(PARAMS_H) $(TOPLEV_H) $(TREE_PASS_H) $(DF_H)
+   $(PARAMS_H) $(TOPLEV_H) $(TREE_PASS_H) $(DF_H) bb-reorder.h
 tracer.o : tracer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
    $(TREE_H) $(BASIC_BLOCK_H) hard-reg-set.h output.h $(CFGLAYOUT_H) \
    $(FLAGS_H) $(TIMEVAR_H) $(PARAMS_H) $(COVERAGE_H) $(FIBHEAP_H) \
@@ -3479,7 +3479,7 @@  lower-subreg.o : lower-subreg.c $(CONFIG
 target-globals.o : target-globals.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    $(TM_H) insn-config.h $(MACHMODE_H) $(GGC_H) $(TOPLEV_H) target-globals.h \
    $(FLAGS_H) $(REGS_H) $(RTL_H) reload.h expmed.h $(EXPR_H) $(OPTABS_H) \
-   $(LIBFUNCS_H) $(CFGLOOP_H) $(IRA_INT_H) builtins.h gcse.h
+   $(LIBFUNCS_H) $(CFGLOOP_H) $(IRA_INT_H) builtins.h gcse.h bb-reorder.h
 
 $(out_object_file): $(out_file) $(CONFIG_H) coretypes.h $(TM_H) $(TREE_H) \
    $(RTL_H) $(REGS_H) hard-reg-set.h insn-config.h conditions.h \
Index: gcc/bb-reorder.h
===================================================================
--- /dev/null	2010-07-07 22:25:18.139280603 +0100
+++ gcc/bb-reorder.h	2010-07-07 22:30:59.000000000 +0100
@@ -0,0 +1,37 @@ 
+/* Basic block reordering routines for the GNU compiler.
+   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
+   Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_BB_REORDER
+#define GCC_BB_REORDER
+
+/* Target-specific globals.  */
+struct target_bb_reorder {
+  /* Length of unconditional jump instruction.  */
+  int x_uncond_jump_length;
+};
+
+extern GTY(()) struct target_bb_reorder default_target_bb_reorder;
+#if SWITCHABLE_TARGET
+extern struct target_bb_reorder *this_target_bb_reorder;
+#else
+#define this_target_bb_reorder (&default_target_bb_reorder)
+#endif
+
+#endif
Index: gcc/bb-reorder.c
===================================================================
--- gcc/bb-reorder.c	2010-07-04 22:48:27.000000000 +0100
+++ gcc/bb-reorder.c	2010-07-07 22:30:59.000000000 +0100
@@ -85,6 +85,7 @@ 
 #include "toplev.h"
 #include "tree-pass.h"
 #include "df.h"
+#include "bb-reorder.h"
 
 /* The number of rounds.  In most cases there will only be 4 rounds, but
    when partitioning hot and cold basic blocks into separate sections of
@@ -100,6 +101,14 @@  #define gen_return() NULL_RTX
 #endif
 
 
+struct target_bb_reorder default_target_bb_reorder;
+#if SWITCHABLE_TARGET
+struct target_bb_reorder *this_target_bb_reorder = &default_target_bb_reorder;
+#endif
+
+#define uncond_jump_length \
+  (this_target_bb_reorder->x_uncond_jump_length)
+
 /* Branch thresholds in thousandths (per mille) of the REG_BR_PROB_BASE.  */
 static int branch_threshold[N_ROUNDS] = {400, 200, 100, 0, 0};
 
@@ -110,9 +119,6 @@  static int exec_threshold[N_ROUNDS] = {5
    block the edge destination is not duplicated while connecting traces.  */
 #define DUPLICATION_THRESHOLD 100
 
-/* Length of unconditional jump instruction.  */
-static int uncond_jump_length;
-
 /* Structure to hold needed information for each basic block.  */
 typedef struct bbro_basic_block_data_def
 {
Index: gcc/target-globals.h
===================================================================
--- gcc/target-globals.h	2010-07-07 22:29:12.000000000 +0100
+++ gcc/target-globals.h	2010-07-07 22:30:59.000000000 +0100
@@ -34,6 +34,7 @@  #define TARGET_GLOBALS_H 1
 extern struct target_ira_int *this_target_ira_int;
 extern struct target_builtins *this_target_builtins;
 extern struct target_gcse *this_target_gcse;
+extern struct target_bb_reorder *this_target_bb_reorder;
 
 struct GTY(()) target_globals {
   struct target_flag_state *GTY((skip)) flag_state;
@@ -49,6 +50,7 @@  struct GTY(()) target_globals {
   struct target_ira_int *GTY((skip)) ira_int;
   struct target_builtins *GTY((skip)) builtins;
   struct target_gcse *GTY((skip)) gcse;
+  struct target_bb_reorder *GTY((skip)) bb_reorder;
 };
 
 extern struct target_globals default_target_globals;
@@ -71,6 +73,7 @@  restore_target_globals (struct target_gl
   this_target_ira_int = g->ira_int;
   this_target_builtins = g->builtins;
   this_target_gcse = g->gcse;
+  this_target_bb_reorder = g->bb_reorder;
 }
 #endif
 
Index: gcc/target-globals.c
===================================================================
--- gcc/target-globals.c	2010-07-07 22:29:12.000000000 +0100
+++ gcc/target-globals.c	2010-07-07 22:30:59.000000000 +0100
@@ -39,6 +39,7 @@  Software Foundation; either version 3, o
 #include "ira-int.h"
 #include "builtins.h"
 #include "gcse.h"
+#include "bb-reorder.h"
 
 #if SWITCHABLE_TARGET
 struct target_globals default_target_globals = {
@@ -54,7 +55,8 @@  struct target_globals default_target_glo
   &default_target_ira,
   &default_target_ira_int,
   &default_target_builtins,
-  &default_target_gcse
+  &default_target_gcse,
+  &default_target_bb_reorder
 };
 
 struct target_globals *
@@ -76,6 +78,7 @@  save_target_globals (void)
   g->ira_int = XCNEW (struct target_ira_int);
   g->builtins = XCNEW (struct target_builtins);
   g->gcse = XCNEW (struct target_gcse);
+  g->bb_reorder = XCNEW (struct target_bb_reorder);
   restore_target_globals (g);
   target_reinit ();
   return g;