This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Committed] Unify and globalize reg_class_names


Whilst debugging a recent reload PR, I made a discovery so hideous
I felt I had to clean it up before 4.0.  There are no less than eight
local static declarations of the array reg_class_names in the GCC
tree, all initialized to the target macro REG_CLASS_NAMES.  The need
to add a ninth just to debug my changes was, for me, eight too many!

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages, and regression tested with
a top-level "make -k check" with no new failures.  I've also tested
that I can still build a cc1 and cc1plus cross-compiler from
i686-pc-linux-gnu to m68hc11-elf.

Committed to mainline CVS.



2004-01-15  Roger Sayle  <roger@eyesopen.com>

	* harg-reg-set.h (reg_class_names): Prototype global array.
	* regclass.c (reg_class_names): Declare here and initialize to
	REG_CLASS_NAMES.
	(dump_regclass): Remove local declaration of reg_class_names.
	(regclass): Likewise.
	* cfg.c (dump_flow_info): Likewise.
	* ra-debug.c (reg_class_names): Likewise.
	* regrename.c (reg_class_names): Likewise.
	* reload.c (reg_class_names): Likewise.
	* reload1.c (spill_failure): Likewise.
	* config/m68hc11/m68hc11.c (reg_class_names): Likewise.


Index: hard-reg-set.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hard-reg-set.h,v
retrieving revision 1.24
diff -c -3 -p -r1.24 hard-reg-set.h
*** hard-reg-set.h	15 Oct 2004 14:47:08 -0000	1.24
--- hard-reg-set.h	15 Jan 2005 04:34:25 -0000
*************** extern int n_non_fixed_regs;
*** 490,495 ****
--- 490,499 ----

  extern const char * reg_names[FIRST_PSEUDO_REGISTER];

+ /* Vector indexed by reg class giving its name.  */
+
+ extern const char * reg_class_names[];
+
  /* Given a hard REGN a FROM mode and a TO mode, return nonzero if
     REGN cannot change modes between the specified modes.  */
  #define REG_CANNOT_CHANGE_MODE_P(REGN, FROM, TO)                          \
Index: regclass.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regclass.c,v
retrieving revision 1.201
diff -c -3 -p -r1.201 regclass.c
*** regclass.c	22 Nov 2004 12:23:54 -0000	1.201
--- regclass.c	15 Jan 2005 04:34:26 -0000
*************** enum reg_class reg_class_superunion[N_RE
*** 192,197 ****
--- 192,201 ----

  const char * reg_names[] = REGISTER_NAMES;

+ /* 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
*************** regclass_init (void)
*** 925,931 ****
  static void
  dump_regclass (FILE *dump)
  {
-   static const char *const reg_class_names[] = REG_CLASS_NAMES;
    int i;
    for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
      {
--- 929,934 ----
*************** regclass (rtx f, int nregs, FILE *dump)
*** 1348,1354 ****
  	      && (reg_pref[i].prefclass != (int) best
  		  || reg_pref[i].altclass != (int) alt))
  	    {
- 	      static const char *const reg_class_names[] = REG_CLASS_NAMES;
  	      fprintf (dump, "  Register %i", i);
  	      if (alt == ALL_REGS || best == ALL_REGS)
  		fprintf (dump, " pref %s\n", reg_class_names[(int) best]);
--- 1351,1356 ----
Index: cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.80
diff -c -3 -p -r1.80 cfg.c
*** cfg.c	13 Dec 2004 10:45:07 -0000	1.80
--- cfg.c	15 Jan 2005 04:34:26 -0000
*************** dump_flow_info (FILE *file)
*** 515,521 ****
  {
    int i;
    basic_block bb;
-   static const char * const reg_class_names[] = REG_CLASS_NAMES;

    /* There are no pseudo registers after reload.  Don't dump them.  */
    if (reg_n_info && !reload_completed)
--- 515,520 ----
Index: ra-debug.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-debug.c,v
retrieving revision 1.23
diff -c -3 -p -r1.23 ra-debug.c
*** ra-debug.c	22 Nov 2004 12:23:54 -0000	1.23
--- ra-debug.c	15 Jan 2005 04:34:26 -0000
*************** static void ra_print_rtx_2op (FILE *, rt
*** 41,49 ****
  static void ra_print_rtx_3op (FILE *, rtx);
  static void ra_print_rtx_object (FILE *, rtx);

- /* The hardregs as names, for debugging.  */
- static const char *const reg_class_names[] = REG_CLASS_NAMES;
-
  /* Print a message to the dump file, if debug_new_regalloc and LEVEL
     have any bits in common.  */

--- 41,46 ----
Index: regrename.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regrename.c,v
retrieving revision 1.93
diff -c -3 -p -r1.93 regrename.c
*** regrename.c	11 Jan 2005 21:56:01 -0000	1.93
--- regrename.c	15 Jan 2005 04:34:27 -0000
***************
*** 36,43 ****
  #include "toplev.h"
  #include "obstack.h"

- static const char *const reg_class_names[] = REG_CLASS_NAMES;
-
  struct du_chain
  {
    struct du_chain *next_chain;
--- 36,41 ----
Index: reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.264
diff -c -3 -p -r1.264 reload.c
*** reload.c	5 Jan 2005 23:19:20 -0000	1.264
--- reload.c	15 Jan 2005 04:34:28 -0000
*************** static const char *const reload_when_nee
*** 7017,7024 ****
    "RELOAD_FOR_OTHER_ADDRESS"
  };

- static const char * const reg_class_names[] = REG_CLASS_NAMES;
-
  /* These functions are used to print the variables set by 'find_reloads' */

  void
--- 7017,7022 ----
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.459
diff -c -3 -p -r1.459 reload1.c
*** reload1.c	13 Jan 2005 01:18:58 -0000	1.459
--- reload1.c	15 Jan 2005 04:34:30 -0000
*************** delete_caller_save_insns (void)
*** 1861,1867 ****
  static void
  spill_failure (rtx insn, enum reg_class class)
  {
-   static const char *const reg_class_names[] = REG_CLASS_NAMES;
    if (asm_noperands (PATTERN (insn)) >= 0)
      error_for_asm (insn, "can't find a register in class %qs while "
  		   "reloading %<asm%>",
--- 1861,1866 ----
Index: config/m68hc11/m68hc11.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.110
diff -c -3 -p -r1.110 m68hc11.c
*** config/m68hc11/m68hc11.c	9 Nov 2004 10:13:08 -0000	1.110
--- config/m68hc11/m68hc11.c	15 Jan 2005 04:34:30 -0000
*************** m68hc11_conditional_register_usage (void
*** 387,394 ****

  /* Reload and register operations.  */

- static const char *const reg_class_names[] = REG_CLASS_NAMES;
-

  void
  create_regs_rtx (void)
--- 387,392 ----

Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]