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]

Re: [PATCH] Remove DUP_PASS macro


On Fri, 2004-07-23 at 16:40, Richard Henderson wrote:
> On Fri, Jul 23, 2004 at 01:32:22PM -0400, Brian Booth wrote:
> > 	* tree-pass.h (tree_opt_pass): Add in_pass_list flag.
> 
> Hmm.  I would think that you could use static_pass_number to
> tell whether or not this pass has been added before.  That
> means adjusting the arithmetic inside dup_pass_1, but should
> be simple enough.  Something like
> 
> 	0	not added
> 	-1	added, no duplicates
> 	-2	added, one duplicate
> 	...
> 	1	n/a
> 	2	added, is second instance of the pass (dup number 1)
> 	3	added, is third instance
> 	...

You mean like this?

Bootstrapped and tested on i686-pc-linux-gnu.

Brian
---

2004-07-27  Brian Booth  <bbooth@redhat.com>

	* tree-optimize.c (register_one_dump_file): Update condition 	that uses
static_pass_number.
	(dup_pass_1): Replace with...
	(next_pass_1): This.
	(NEXT_PASS): Call next_pass_1.
	(DUP_PASS): Remove.
	(init_tree_optimization_passes): Remove uses of DUP_PASS.
	(execute_one_pass): Update condition that uses
	static_pass_number.
	* tree-pass.h (tree_opt_pass): Declare static_pass_number as 	a signed
integer.
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.32
diff -u -p -c -p -r2.32 tree-optimize.c
*** tree-optimize.c	22 Jul 2004 08:20:38 -0000	2.32
--- tree-optimize.c	27 Jul 2004 13:34:01 -0000
*************** register_one_dump_file (struct tree_opt_
*** 213,221 ****
    if (!pass->name)
      return;
  
!   /* See below in dup_pass_1.  */
    num[0] = '\0';
!   if (pass->static_pass_number)
      sprintf (num, "%d", ((int) pass->static_pass_number < 0
  			 ? 1 : pass->static_pass_number));
  
--- 213,221 ----
    if (!pass->name)
      return;
  
!   /* See below in next_pass_1.  */
    num[0] = '\0';
!   if (pass->static_pass_number != -1)
      sprintf (num, "%d", ((int) pass->static_pass_number < 0
  			 ? 1 : pass->static_pass_number));
  
*************** register_dump_files (struct tree_opt_pas
*** 252,285 ****
    return properties;
  }
  
! /* Duplicate a pass that's to be run more than once.  */
  
! static struct tree_opt_pass *
! dup_pass_1 (struct tree_opt_pass *pass)
  {
-   struct tree_opt_pass *new;
- 
-   new = xmalloc (sizeof (*new));
-   memcpy (new, pass, sizeof (*new));
  
!   /* Indicate to register_dump_files that this pass has duplicates,
!      and so it should rename the dump file.  The first instance will
!      be < 0, and be number of duplicates = -static_pass_number + 1.
!      Subsequent instances will be > 0 and just the duplicate number.  */
!   if (pass->name)
      {
!       int n, p = pass->static_pass_number;
! 	
!       if (p)
! 	n = -(--p) + 1;
!       else
! 	n = 2, p = -1;
  
!       pass->static_pass_number = p;
!       new->static_pass_number = n;
!     }
  
!   return new;
  }
  
  /* Construct the pass tree.  */
--- 252,293 ----
    return properties;
  }
  
! /* Add a pass to the pass list. Duplicate the pass if it's already
!    in the list.  */
  
! static struct tree_opt_pass **
! next_pass_1 (struct tree_opt_pass **list, struct tree_opt_pass *pass)
  {
  
!   /* A non-zero static_pass_number indicates that the
!      pass is already in the list. */
!   if (pass->static_pass_number)
      {
!       struct tree_opt_pass *new;
  
!       new = xmalloc (sizeof (*new));
!       memcpy (new, pass, sizeof (*new));
  
!       /* Indicate to register_dump_files that this pass has duplicates,
!          and so it should rename the dump file.  The first instance will
!          be -1, and be number of duplicates = -static_pass_number - 1.
!          Subsequent instances will be > 0 and just the duplicate number.  */
!       if (pass->name)
!         {
!           pass->static_pass_number -= 1;
!           new->static_pass_number = -pass->static_pass_number;
! 	}
!       
!       *list = new;
!     }
!   else
!     {
!       pass->static_pass_number = -1;
!       *list = pass;
!     }  
!   
!   return &(*list)->next;
!           
  }
  
  /* Construct the pass tree.  */
*************** init_tree_optimization_passes (void)
*** 289,296 ****
  {
    struct tree_opt_pass **p;
  
! #define NEXT_PASS(PASS) (*p = &PASS, p = &(*p)->next)
! #define DUP_PASS(PASS)  (*dup_pass_1 (&PASS))
  
    p = &all_passes;
    NEXT_PASS (pass_gimple);
--- 297,303 ----
  {
    struct tree_opt_pass **p;
  
! #define NEXT_PASS(PASS)  (p = next_pass_1 (p, &PASS))
  
    p = &all_passes;
    NEXT_PASS (pass_gimple);
*************** init_tree_optimization_passes (void)
*** 319,325 ****
    NEXT_PASS (pass_dce);
    NEXT_PASS (pass_dominator);
    NEXT_PASS (pass_redundant_phi);
!   NEXT_PASS (DUP_PASS (pass_dce));
    NEXT_PASS (pass_forwprop);
    NEXT_PASS (pass_phiopt);
    NEXT_PASS (pass_may_alias);
--- 326,332 ----
    NEXT_PASS (pass_dce);
    NEXT_PASS (pass_dominator);
    NEXT_PASS (pass_redundant_phi);
!   NEXT_PASS (pass_dce);
    NEXT_PASS (pass_forwprop);
    NEXT_PASS (pass_phiopt);
    NEXT_PASS (pass_may_alias);
*************** init_tree_optimization_passes (void)
*** 327,352 ****
    NEXT_PASS (pass_ch);
    NEXT_PASS (pass_profile);
    NEXT_PASS (pass_sra);
!   NEXT_PASS (DUP_PASS (pass_rename_ssa_copies));
!   NEXT_PASS (DUP_PASS (pass_dominator));
!   NEXT_PASS (DUP_PASS (pass_redundant_phi));
!   NEXT_PASS (DUP_PASS (pass_dce));
    NEXT_PASS (pass_dse);
!   NEXT_PASS (DUP_PASS (pass_may_alias));
!   NEXT_PASS (DUP_PASS (pass_forwprop));
!   NEXT_PASS (DUP_PASS (pass_phiopt));
    NEXT_PASS (pass_ccp);
!   NEXT_PASS (DUP_PASS (pass_redundant_phi));
    NEXT_PASS (pass_fold_builtins);
    NEXT_PASS (pass_split_crit_edges);
    NEXT_PASS (pass_pre);
    NEXT_PASS (pass_loop);
!   NEXT_PASS (DUP_PASS (pass_dominator));
!   NEXT_PASS (DUP_PASS (pass_redundant_phi));
    NEXT_PASS (pass_cd_dce);
!   NEXT_PASS (DUP_PASS (pass_dse));
!   NEXT_PASS (DUP_PASS (pass_forwprop));
!   NEXT_PASS (DUP_PASS (pass_phiopt));
    NEXT_PASS (pass_tail_calls);
    NEXT_PASS (pass_late_warn_uninitialized);
    NEXT_PASS (pass_del_pta);
--- 334,359 ----
    NEXT_PASS (pass_ch);
    NEXT_PASS (pass_profile);
    NEXT_PASS (pass_sra);
!   NEXT_PASS (pass_rename_ssa_copies);
!   NEXT_PASS (pass_dominator);
!   NEXT_PASS (pass_redundant_phi);
!   NEXT_PASS (pass_dce);
    NEXT_PASS (pass_dse);
!   NEXT_PASS (pass_may_alias);
!   NEXT_PASS (pass_forwprop);
!   NEXT_PASS (pass_phiopt);
    NEXT_PASS (pass_ccp);
!   NEXT_PASS (pass_redundant_phi);
    NEXT_PASS (pass_fold_builtins);
    NEXT_PASS (pass_split_crit_edges);
    NEXT_PASS (pass_pre);
    NEXT_PASS (pass_loop);
!   NEXT_PASS (pass_dominator);
!   NEXT_PASS (pass_redundant_phi);
    NEXT_PASS (pass_cd_dce);
!   NEXT_PASS (pass_dse);
!   NEXT_PASS (pass_forwprop);
!   NEXT_PASS (pass_phiopt);
    NEXT_PASS (pass_tail_calls);
    NEXT_PASS (pass_late_warn_uninitialized);
    NEXT_PASS (pass_del_pta);
*************** init_tree_optimization_passes (void)
*** 363,369 ****
    *p = NULL;
  
  #undef NEXT_PASS
- #undef DUP_PASS
  
    /* Register the passes with the tree dump code.  */
    register_dump_files (all_passes, 0);
--- 370,375 ----
*************** execute_one_pass (struct tree_opt_pass *
*** 424,430 ****
      execute_todo (todo);
  
    /* If a dump file name is present, open it if enabled.  */
!   if (pass->static_pass_number)
      {
        dump_file = dump_begin (pass->static_pass_number, &dump_flags);
        if (dump_file)
--- 430,436 ----
      execute_todo (todo);
  
    /* If a dump file name is present, open it if enabled.  */
!   if (pass->static_pass_number != -1)
      {
        dump_file = dump_begin (pass->static_pass_number, &dump_flags);
        if (dump_file)
Index: tree-pass.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pass.h,v
retrieving revision 2.6
diff -u -p -c -p -r2.6 tree-pass.h
*** tree-pass.h	22 Jul 2004 08:20:39 -0000	2.6
--- tree-pass.h	27 Jul 2004 13:34:01 -0000
*************** struct tree_opt_pass
*** 50,56 ****
    struct tree_opt_pass *next;
  
    /* Static pass number, used as a fragment of the dump file name.  */
!   unsigned int static_pass_number;
  
    /* The timevar id associated with this pass.  */
    /* ??? Ideally would be dynamically assigned.  */
--- 50,56 ----
    struct tree_opt_pass *next;
  
    /* Static pass number, used as a fragment of the dump file name.  */
!   int static_pass_number;
  
    /* The timevar id associated with this pass.  */
    /* ??? Ideally would be dynamically assigned.  */

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