[3/27] Use target structures for init_reg_modes_target
Richard Sandiford
rdsandiford@googlemail.com
Sun Jul 4 22:05:00 GMT 2010
Now the init_emit_regs line in backend_init_target:
/* Initialize alignment variables. */
init_alignments ();
/* This reinitializes hard_frame_pointer, and calls init_reg_modes_target()
to initialize reg_raw_mode[]. */
==> init_emit_regs ();
/* This invokes target hooks to set fixed_reg[] etc, which is
mode-dependent. */
init_regs ();
init_emit_regs starts:
/* Reset register attributes */
htab_empty (reg_attrs_htab);
/* We need reg_raw_mode, so initialize the modes now. */
init_reg_modes_target ();
and I can't see any reason why we need to clear reg_attrs_htab.
The table gives a unique structure for (decl, offset) pair,
which doesn't seem target-specific. So the patch starts
with the call to init_reg_modes_target.
Richard
gcc/
* Makefile.in (target-globals.o): Depend on $(REGS_H).
* regs.h (target_reg_modes): New structure.
(default_target_reg_modes): Declare.
(this_target_reg_modes): Declare as a variable or define as a macro.
(hard_regno_nregs, reg_raw_mode): Redefine as macros.
* reginfo.c (default_target_reg_modes): New variable.
(this_target_reg_modes): New conditional variable.
(hard_regno_nregs, reg_raw_mode): Delete.
* target-globals.h (this_target_regs): Declare.
(target_globals): Add a regs field.
(restore_target_globals): Copy the regs field to this_target_regs.
* target-globals.c: Include regs.h.
(default_target_globals): Initialize the regs field.
(save_target_globals): Likewise.
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in 2010-07-04 14:15:13.000000000 +0100
+++ gcc/Makefile.in 2010-07-04 14:15:27.000000000 +0100
@@ -3479,7 +3479,7 @@ lower-subreg.o : lower-subreg.c $(CONFIG
$(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 \
- $(FLAGS_H)
+ $(FLAGS_H) $(REGS_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/regs.h
===================================================================
--- gcc/regs.h 2010-07-04 14:15:03.000000000 +0100
+++ gcc/regs.h 2010-07-04 14:15:19.000000000 +0100
@@ -218,13 +218,6 @@ #define REG_BASIC_BLOCK(N) (reg_info_p[N
extern bool have_regs_of_mode [MAX_MACHINE_MODE];
-/* For each hard register, the widest mode object that it can contain.
- This will be a MODE_INT mode if the register can hold integers. Otherwise
- it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the
- register. */
-
-extern enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER];
-
/* Flag set by local-alloc or global-alloc if they decide to allocate
something in a call-clobbered register. */
@@ -266,9 +259,6 @@ typedef unsigned short move_table[N_REG_
in another class. */
extern move_table *move_cost[MAX_MACHINE_MODE];
-/* Specify number of hard registers given machine mode occupy. */
-extern unsigned char hard_regno_nregs[FIRST_PSEUDO_REGISTER][MAX_MACHINE_MODE];
-
/* Similar, but here we don't have to move if the first index is a
subset of the second so in that case the cost is zero. */
extern move_table *may_move_in_cost[MAX_MACHINE_MODE];
@@ -277,6 +267,31 @@ typedef unsigned short move_table[N_REG_
superset of the second so in that case the cost is zero. */
extern move_table *may_move_out_cost[MAX_MACHINE_MODE];
+/* Target-dependent globals. */
+struct target_regs {
+ /* For each starting hard register, the number of consecutive hard
+ registers that a given machine mode occupies. */
+ unsigned char x_hard_regno_nregs[FIRST_PSEUDO_REGISTER][MAX_MACHINE_MODE];
+
+ /* For each hard register, the widest mode object that it can contain.
+ This will be a MODE_INT mode if the register can hold integers. Otherwise
+ it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the
+ register. */
+ enum machine_mode x_reg_raw_mode[FIRST_PSEUDO_REGISTER];
+};
+
+extern struct target_regs default_target_regs;
+#if SWITCHABLE_TARGET
+extern struct target_regs *this_target_regs;
+#else
+#define this_target_regs (&default_target_regs)
+#endif
+
+#define hard_regno_nregs \
+ (this_target_regs->x_hard_regno_nregs)
+#define reg_raw_mode \
+ (this_target_regs->x_reg_raw_mode)
+
/* Return an exclusive upper bound on the registers occupied by hard
register (reg:MODE REGNO). */
Index: gcc/reginfo.c
===================================================================
--- gcc/reginfo.c 2010-07-04 14:15:03.000000000 +0100
+++ gcc/reginfo.c 2010-07-04 14:15:19.000000000 +0100
@@ -58,6 +58,11 @@ Software Foundation; either version 3, o
int max_regno;
+struct target_regs default_target_regs;
+#if SWITCHABLE_TARGET
+struct target_regs *this_target_regs = &default_target_regs;
+#endif
+
/* Register tables used by many passes. */
/* Indexed by hard register number, contains 1 for registers
@@ -170,12 +175,6 @@ const char * reg_names[] = REGISTER_NAME
/* Array containing all of the register class names. */
const char * reg_class_names[] = REG_CLASS_NAMES;
-/* For each hard register, the widest mode object that it can contain.
- This will be a MODE_INT mode if the register can hold integers. Otherwise
- it will be a MODE_FLOAT or a MODE_CC mode, whichever is valid for the
- register. */
-enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER];
-
/* 1 if there is a register of given mode. */
bool have_regs_of_mode [MAX_MACHINE_MODE];
@@ -204,9 +203,6 @@ static GTY(()) rtx top_of_stack[MAX_MACH
reginfo has been initialized. */
static int no_global_reg_vars = 0;
-/* Specify number of hard registers given machine mode occupy. */
-unsigned char hard_regno_nregs[FIRST_PSEUDO_REGISTER][MAX_MACHINE_MODE];
-
/* Given a register bitmap, turn on the bits in a HARD_REG_SET that
correspond to the hard registers, if any, set in that map. This
could be done far more efficiently by having all sorts of special-cases
Index: gcc/target-globals.h
===================================================================
--- gcc/target-globals.h 2010-07-04 14:15:06.000000000 +0100
+++ gcc/target-globals.h 2010-07-04 14:15:19.000000000 +0100
@@ -22,9 +22,11 @@ #define TARGET_GLOBALS_H 1
#if SWITCHABLE_TARGET
extern struct target_flag_state *this_target_flag_state;
+extern struct target_regs *this_target_regs;
struct GTY(()) target_globals {
struct target_flag_state *GTY((skip)) flag_state;
+ struct target_regs *GTY((skip)) regs;
};
extern struct target_globals default_target_globals;
@@ -35,6 +37,7 @@ extern struct target_globals *save_targe
restore_target_globals (struct target_globals *g)
{
this_target_flag_state = g->flag_state;
+ this_target_regs = g->regs;
}
#endif
Index: gcc/target-globals.c
===================================================================
--- gcc/target-globals.c 2010-07-04 14:15:06.000000000 +0100
+++ gcc/target-globals.c 2010-07-04 14:15:19.000000000 +0100
@@ -27,10 +27,12 @@ Software Foundation; either version 3, o
#include "toplev.h"
#include "target-globals.h"
#include "flags.h"
+#include "regs.h"
#if SWITCHABLE_TARGET
struct target_globals default_target_globals = {
- &default_target_flag_state
+ &default_target_flag_state,
+ &default_target_regs
};
struct target_globals *
@@ -40,6 +42,7 @@ save_target_globals (void)
g = ggc_alloc_target_globals ();
g->flag_state = XCNEW (struct target_flag_state);
+ g->regs = XCNEW (struct target_regs);
restore_target_globals (g);
target_reinit ();
return g;
More information about the Gcc-patches
mailing list