Patchwork [2/27] Use target structures for init_alignments

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

Comments

Richard Sandiford - July 4, 2010, 9:58 p.m.
The next set of patches walk through backend_init_target and put the
variables initialised by each line into target structures.  First up
it's init_alignments:

    static void
    backend_init_target (void)
    {
      /* Initialize alignment variables.  */
==>   init_alignments ();

      /* This reinitializes hard_frame_pointer, and calls init_reg_modes_target()
         to initialize reg_raw_mode[].  */
      init_emit_regs ();

Richard


gcc/
	* Makefile.in (target-globals.o): Depend on $(FLAGS_H).
	* flags.h (target_flag_state): New structure.
	(default_target_flag_state): Declare.
	(this_target_flag_state): Declare as a variable or define as a macro.
	(align_loops_log): Redefine as a macro.
	(align_loops_max_skip, align_jumps_log): Likewise.
	(align_jumps_max_skip, align_labels_log): Likewise.
	(align_labels_max_skip, align_functions_log): Likewise.
	* toplev.c (default_target_flag_state): New variable.
	(this_target_flag_state): New conditional variable.
	(align_loops_log): Delete.
	(align_loops_max_skip, align_jumps_log): Likewise.
	(align_jumps_max_skip, align_labels_log): Likewise.
	(align_labels_max_skip, align_functions_log): Likewise.
	* target-globals.h (this_target_flag_state): Declare.
	(target_globals): Add a flag_state field.
	(restore_target_globals): Copy the flag_state field to
	this_target_flag_state.
	* target-globals.c: Include flags.h.
	(default_target_globals): Initialize the flag_state field.
	(save_target_globals): Likewise.

Patch

Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	2010-07-04 22:55:48.000000000 +0100
+++ gcc/Makefile.in	2010-07-04 22:55:49.000000000 +0100
@@ -3476,7 +3476,8 @@  lower-subreg.o : lower-subreg.c $(CONFIG
    insn-config.h $(BASIC_BLOCK_H) $(RECOG_H) $(OBSTACK_H) $(BITMAP_H) \
    $(EXPR_H) $(EXCEPT_H) $(REGS_H) $(TREE_PASS_H) $(DF_H)
 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
+   $(TM_H) insn-config.h $(MACHMODE_H) $(GGC_H) $(TOPLEV_H) target-globals.h \
+   $(FLAGS_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/flags.h
===================================================================
--- gcc/flags.h	2010-07-04 22:48:32.000000000 +0100
+++ gcc/flags.h	2010-07-04 22:56:17.000000000 +0100
@@ -239,6 +239,43 @@  enum excess_precision
 
 /* Other basic status info about current function.  */
 
+/* Target-dependent global state.  */
+struct target_flag_state {
+  /* Values of the -falign-* flags: how much to align labels in code.
+     0 means `use default', 1 means `don't align'.
+     For each variable, there is an _log variant which is the power
+     of two not less than the variable, for .align output.  */
+  int x_align_loops_log;
+  int x_align_loops_max_skip;
+  int x_align_jumps_log;
+  int x_align_jumps_max_skip;
+  int x_align_labels_log;
+  int x_align_labels_max_skip;
+  int x_align_functions_log;
+};
+
+extern struct target_flag_state default_target_flag_state;
+#if SWITCHABLE_TARGET
+extern struct target_flag_state *this_target_flag_state;
+#else
+#define this_target_flag_state (&default_target_flag_state)
+#endif
+
+#define align_loops_log \
+  (this_target_flag_state->x_align_loops_log)
+#define align_loops_max_skip \
+  (this_target_flag_state->x_align_loops_max_skip)
+#define align_jumps_log \
+  (this_target_flag_state->x_align_jumps_log)
+#define align_jumps_max_skip \
+  (this_target_flag_state->x_align_jumps_max_skip)
+#define align_labels_log \
+  (this_target_flag_state->x_align_labels_log)
+#define align_labels_max_skip \
+  (this_target_flag_state->x_align_labels_max_skip)
+#define align_functions_log \
+  (this_target_flag_state->x_align_functions_log)
+
 /* Nonzero if subexpressions must be evaluated from left-to-right.  */
 extern int flag_evaluation_order;
 
@@ -252,19 +289,6 @@  enum excess_precision
 /* Whether to run the warn_unused_result attribute pass.  */
 extern bool flag_warn_unused_result;
 
-/* Values of the -falign-* flags: how much to align labels in code.
-   0 means `use default', 1 means `don't align'.
-   For each variable, there is an _log variant which is the power
-   of two not less than the variable, for .align output.  */
-
-extern int align_loops_log;
-extern int align_loops_max_skip;
-extern int align_jumps_log;
-extern int align_jumps_max_skip;
-extern int align_labels_log;
-extern int align_labels_max_skip;
-extern int align_functions_log;
-
 /* Nonzero if we dump in VCG format, not plain text.  */
 extern int dump_for_graph;
 
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c	2010-07-04 22:48:32.000000000 +0100
+++ gcc/toplev.c	2010-07-04 22:55:49.000000000 +0100
@@ -317,18 +317,12 @@  enum stack_check_type flag_stack_check =
 
 bool user_defined_section_attribute = false;
 
-/* Values of the -falign-* flags: how much to align labels in code.
-   0 means `use default', 1 means `don't align'.
-   For each variable, there is an _log variant which is the power
-   of two not less than the variable, for .align output.  */
-
-int align_loops_log;
-int align_loops_max_skip;
-int align_jumps_log;
-int align_jumps_max_skip;
-int align_labels_log;
-int align_labels_max_skip;
-int align_functions_log;
+struct target_flag_state default_target_flag_state;
+#if SWITCHABLE_TARGET
+struct target_flag_state *this_target_flag_state = &default_target_flag_state;
+#else
+#define this_target_flag_state (&default_target_flag_state)
+#endif
 
 typedef struct
 {
Index: gcc/target-globals.h
===================================================================
--- gcc/target-globals.h	2010-07-04 22:55:48.000000000 +0100
+++ gcc/target-globals.h	2010-07-04 22:55:49.000000000 +0100
@@ -21,7 +21,10 @@  Software Foundation; either version 3, o
 #define TARGET_GLOBALS_H 1
 
 #if SWITCHABLE_TARGET
+extern struct target_flag_state *this_target_flag_state;
+
 struct GTY(()) target_globals {
+  struct target_flag_state *GTY((skip)) flag_state;
 };
 
 extern struct target_globals default_target_globals;
@@ -31,6 +34,7 @@  extern struct target_globals *save_targe
 static inline void
 restore_target_globals (struct target_globals *g)
 {
+  this_target_flag_state = g->flag_state;
 }
 #endif
 
Index: gcc/target-globals.c
===================================================================
--- gcc/target-globals.c	2010-07-04 22:55:48.000000000 +0100
+++ gcc/target-globals.c	2010-07-04 22:55:49.000000000 +0100
@@ -26,9 +26,11 @@  Software Foundation; either version 3, o
 #include "ggc.h"
 #include "toplev.h"
 #include "target-globals.h"
+#include "flags.h"
 
 #if SWITCHABLE_TARGET
 struct target_globals default_target_globals = {
+  &default_target_flag_state
 };
 
 struct target_globals *
@@ -37,6 +39,7 @@  save_target_globals (void)
   struct target_globals *g;
 
   g = ggc_alloc_target_globals ();
+  g->flag_state = XCNEW (struct target_flag_state);
   restore_target_globals (g);
   target_reinit ();
   return g;