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]

[rtlopt] var-tracking.c: add function parameters to OUT set of ENTRY_BLOCK


Hi,

this patch adds the function parameters to IN and OUT set of ENTRY_BLOCK
which helps with tracking the function parameters.
Parameter processing is probably still too simple, but it should work on
majority of functions.

Bootstrapped i386.

2003-02-06  Josef Zlomek  <zlomekj@suse.cz>

	* Makefile.in (var-tracking.o): Add dependency to insn-config.h
	and reload.h, remove dependency on hard-reg-set.h.
	* var-tracking.c (get_decl_and_offset): New function.
	(insert_function_parameters): New function.
	(hybrid_search): Make union with OUT set of ENTRY_BLOCK too.
	(var_tracking_initialize): Initialize the IN and OUT sets of
	ENTRY_BLOCK too, insert function parameters to IN and OUT set of
	ENTRY_BLOCK.
	(var_tracking_finalize): Destroy the IN and OUT sets of ENTRY_BLOCK. 

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.937.2.30
diff -c -3 -p -r1.937.2.30 Makefile.in
*** Makefile.in	2 Feb 2003 18:14:57 -0000	1.937.2.30
--- Makefile.in	6 Feb 2003 18:29:24 -0000
*************** df.o : df.c $(CONFIG_H) $(SYSTEM_H) core
*** 1584,1591 ****
     insn-config.h $(RECOG_H) function.h $(REGS_H) $(OBSTACK_H) hard-reg-set.h \
     $(BASIC_BLOCK_H) df.h $(FIBHEAP_H)
  var-tracking.o : var-tracking.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
!     $(RTL_H) hard-reg-set.h $(BASIC_BLOCK_H) $(TREE_H) output.h sbitmap.h \
!     alloc-pool.h $(FIBHEAP_H) $(HASHTAB_H)
  conflict.o : conflict.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(OBSTACK_H) \
     $(HASHTAB_H) $(RTL_H) hard-reg-set.h $(BASIC_BLOCK_H)
  profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
--- 1584,1591 ----
     insn-config.h $(RECOG_H) function.h $(REGS_H) $(OBSTACK_H) hard-reg-set.h \
     $(BASIC_BLOCK_H) df.h $(FIBHEAP_H)
  var-tracking.o : var-tracking.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
!     $(RTL_H) $(TREE_H) $(BASIC_BLOCK_H) output.h insn-config.h reload.h \
!     sbitmap.h alloc-pool.h $(FIBHEAP_H) $(HASHTAB_H)
  conflict.o : conflict.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(OBSTACK_H) \
     $(HASHTAB_H) $(RTL_H) hard-reg-set.h $(BASIC_BLOCK_H)
  profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
Index: var-tracking.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/var-tracking.c,v
retrieving revision 1.1.4.18
diff -c -3 -p -r1.1.4.18 var-tracking.c
*** var-tracking.c	6 Feb 2003 12:32:21 -0000	1.1.4.18
--- var-tracking.c	6 Feb 2003 18:29:24 -0000
***************
*** 97,102 ****
--- 97,104 ----
  #include "tree.h"
  #include "basic-block.h"
  #include "output.h"
+ #include "insn-config.h"
+ #include "reload.h"
  #include "sbitmap.h"
  #include "alloc-pool.h"
  #include "fibheap.h"
*************** static int mark_variables_for_deletion	P
*** 296,301 ****
--- 298,306 ----
  static int add_and_unmark_variables	PARAMS ((void **, void *));
  static void var_tracking_emit_notes	PARAMS ((void));
  
+ static bool get_decl_and_offset		PARAMS ((rtx, tree *,
+ 						 HOST_WIDE_INT *));
+ static void insert_function_parameters	PARAMS ((void));
  static void var_tracking_initialize	PARAMS ((void));
  static void var_tracking_finalize	PARAMS ((void));
  
*************** hybrid_search (bb, visited, pending)
*** 957,965 ****
  	  attrs *bb_in = VTI (bb)->in;
  	  attrs *pred_out = VTI (e->src)->out;
  
- 	  if (e->src == ENTRY_BLOCK_PTR)
- 	    continue;
- 
  	  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  	    attrs_list_union (&bb_in[i], pred_out[i]);
  	  attrs_htab_union (VTI (bb)->mem_in, VTI (e->src)->mem_out);
--- 962,967 ----
*************** var_tracking_emit_notes ()
*** 1536,1541 ****
--- 1538,1624 ----
    htab_delete (last_htab);
  }
  
+ /* If there is a declaration and offset associated with register/memory RTL
+    assign declaration to *DECLP and offset to *OFFSETP, and return true.  */
+ 
+ static bool
+ get_decl_and_offset (rtl, declp, offsetp)
+      rtx rtl;
+      tree *declp;
+      HOST_WIDE_INT *offsetp;
+ {
+   if (GET_CODE (rtl) == REG)
+     {
+       if (REG_ATTRS (rtl))
+ 	{
+ 	  *declp = REG_EXPR (rtl);
+ 	  *offsetp = REG_OFFSET (rtl);
+ 	  return true;
+ 	}
+     }
+   else if (GET_CODE (rtl) == MEM)
+     {
+       if (MEM_ATTRS (rtl))
+ 	{
+ 	  *declp = MEM_EXPR (rtl);
+ 	  *offsetp = MEM_OFFSET (rtl) ? INTVAL (MEM_OFFSET (rtl)) : 0;
+ 	  return true;
+ 	}
+     }
+   else
+     abort ();
+   return false;
+ }
+ 
+ /* Insert function parameters to IN and OUT sets of ENTRY_BLOCK.  */
+ 
+ static void
+ insert_function_parameters ()
+ {
+   tree parm;
+ 
+   for (parm = DECL_ARGUMENTS (current_function_decl);
+        parm; parm = TREE_CHAIN (parm))
+     {
+       rtx decl_rtl = DECL_RTL (parm);
+       rtx incoming = DECL_INCOMING_RTL (parm);
+       tree decl;
+       HOST_WIDE_INT offset;
+ 
+       if (!decl_rtl || !incoming)
+ 	abort ();
+ 
+       if (!get_decl_and_offset (incoming, &decl, &offset))
+ 	if (!get_decl_and_offset (decl_rtl, &decl, &offset))
+ 	  abort ();
+ 
+       if (parm != decl)
+ 	abort ();
+ 
+       incoming = eliminate_regs (incoming, 0, NULL_RTX);
+       if (GET_CODE (incoming) == REG)
+ 	{
+ 	  attrs *in = VTI (ENTRY_BLOCK_PTR)->in;
+ 	  attrs *out = VTI (ENTRY_BLOCK_PTR)->out;
+ 
+ 	  if (REGNO (incoming) >= FIRST_PSEUDO_REGISTER)
+ 	    abort ();
+ 	  attrs_list_insert (&in[REGNO (incoming)], parm, offset, incoming);
+ 	  attrs_list_insert (&out[REGNO (incoming)], parm, offset, incoming);
+ 	}
+       else if (GET_CODE (incoming) == MEM)
+ 	{
+ 	  htab_t mem_in = VTI (ENTRY_BLOCK_PTR)->mem_in;
+ 	  htab_t mem_out = VTI (ENTRY_BLOCK_PTR)->mem_out;
+ 
+ 	  attrs_htab_insert (mem_in, parm, offset, incoming);
+ 	  attrs_htab_insert (mem_out, parm, offset, incoming);
+ 	}
+       else
+ 	abort ();
+     }
+ }
+ 
  /* Allocate and initialize the data structures for variable tracking
     and parse the RTL to get the REG and MEM references.  */
  
*************** var_tracking_initialize ()
*** 1616,1623 ****
  		}
  	    }
  	}
  
!       /* Init the IN and OUT arrays.  */
        init_attrs_list_set (VTI (bb)->in);
        init_attrs_list_set (VTI (bb)->out);
        VTI (bb)->mem_in = htab_create (7, mem_htab_hash, mem_htab_eq,
--- 1699,1709 ----
  		}
  	    }
  	}
+     }
  
!   /* Init the IN and OUT sets.  */
!   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
!     {
        init_attrs_list_set (VTI (bb)->in);
        init_attrs_list_set (VTI (bb)->out);
        VTI (bb)->mem_in = htab_create (7, mem_htab_hash, mem_htab_eq,
*************** var_tracking_initialize ()
*** 1632,1638 ****
  				sizeof (struct variable_def), 64);
    variable_htab = htab_create (37, variable_htab_hash, variable_htab_eq,
  			       variable_htab_free);
! 
  }
  
  /* Free the data structures needed for variable tracking.  */
--- 1718,1724 ----
  				sizeof (struct variable_def), 64);
    variable_htab = htab_create (37, variable_htab_hash, variable_htab_eq,
  			       variable_htab_free);
!   insert_function_parameters ();
  }
  
  /* Free the data structures needed for variable tracking.  */
*************** var_tracking_finalize ()
*** 1646,1652 ****
--- 1732,1741 ----
    FOR_EACH_BB (bb)
      {
        free (VTI (bb)->locs);
+     }
  
+   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
+     {
        for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  	{
  	  attrs_list_clear (&VTI (bb)->in[i]);


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