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]

[PATCH]:Remove size_int cache


This patch removes the separate sizetype integer cache, and uses
the new generic integer value caching machinery.

booted & tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-08-27  Nathan Sidwell  <nathan@codesourcery.com>

	* tree.h (size_int_type): Remove.
	* fold-const.c: Do not #include gt-fold-const.h.
	(size_htab_hash, size_htab_eq): Remove.
	(size_int_kind): Use build_int_cst.
	(new_const, size_htab): Remove.
	(size_int_type): Remove.
	(round_up): Use build_int_cst.
	(round_down): Likewise. Remove spurious constant build.

	* ada/utils2.c (build_allocator): Use ssize_int.

	* cp/class.c (build_vtbl_initializer): Use ssize_int.
	* cp/decl.c (complete_array_type): Likewise.
	* cp/method.c (finish_thunk): Likewise.
	* cp/search.c (get_dynamic_base_type): Likewise.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.444
diff -c -3 -p -r1.444 fold-const.c
*** fold-const.c	25 Aug 2004 09:51:25 -0000	1.444
--- fold-const.c	27 Aug 2004 08:49:53 -0000
*************** static tree negate_expr (tree);
*** 89,96 ****
  static tree split_tree (tree, enum tree_code, tree *, tree *, tree *, int);
  static tree associate_trees (tree, tree, enum tree_code, tree);
  static tree const_binop (enum tree_code, tree, tree, int);
- static hashval_t size_htab_hash (const void *);
- static int size_htab_eq (const void *, const void *);
  static tree fold_convert_const (enum tree_code, tree, tree);
  static enum tree_code invert_tree_comparison (enum tree_code, bool);
  static enum comparison_code comparison_to_compcode (enum tree_code);
--- 89,94 ----
*************** const_binop (enum tree_code code, tree a
*** 1597,1697 ****
    return 0;
  }
  
! /* These are the hash table functions for the hash table of INTEGER_CST
!    nodes of a sizetype.  */
! 
! /* Return the hash code code X, an INTEGER_CST.  */
! 
! static hashval_t
! size_htab_hash (const void *x)
! {
!   tree t = (tree) x;
! 
!   return (TREE_INT_CST_HIGH (t) ^ TREE_INT_CST_LOW (t)
! 	  ^ htab_hash_pointer (TREE_TYPE (t))
! 	  ^ (TREE_OVERFLOW (t) << 20));
! }
! 
! /* Return nonzero if the value represented by *X (an INTEGER_CST tree node)
!    is the same as that given by *Y, which is the same.  */
! 
! static int
! size_htab_eq (const void *x, const void *y)
! {
!   tree xt = (tree) x;
!   tree yt = (tree) y;
! 
!   return (TREE_INT_CST_HIGH (xt) == TREE_INT_CST_HIGH (yt)
! 	  && TREE_INT_CST_LOW (xt) == TREE_INT_CST_LOW (yt)
! 	  && TREE_TYPE (xt) == TREE_TYPE (yt)
! 	  && TREE_OVERFLOW (xt) == TREE_OVERFLOW (yt));
! }
! 
! /* Return an INTEGER_CST with value whose low-order HOST_BITS_PER_WIDE_INT
!    bits are given by NUMBER and of the sizetype represented by KIND.  */
  
  tree
  size_int_kind (HOST_WIDE_INT number, enum size_type_kind kind)
  {
!   return size_int_type (number, sizetype_tab[(int) kind]);
  }
! 
! /* Likewise, but the desired type is specified explicitly.  */
! 
! static GTY (()) tree new_const;
! static GTY ((if_marked ("ggc_marked_p"), param_is (union tree_node)))
!      htab_t size_htab;
! 
! tree
! size_int_type (HOST_WIDE_INT number, tree type)
! {
!   void **slot;
!   unsigned int prec;
!   HOST_WIDE_INT high;
!   unsigned HOST_WIDE_INT low;
! 
!   if (size_htab == 0)
!     {
!       size_htab = htab_create_ggc (1024, size_htab_hash, size_htab_eq, NULL);
!       new_const = make_node (INTEGER_CST);
!     }
! 
!   /* Adjust NEW_CONST to be the constant we want.  If it's already in the
!      hash table, we return the value from the hash table.  Otherwise, we
!      place that in the hash table and make a new node for the next time.  */
!   prec = TYPE_PRECISION (type);
!   TREE_TYPE (new_const) = type;
!   TREE_OVERFLOW (new_const) = TREE_CONSTANT_OVERFLOW (new_const) = 0;
!   low = number;
!   if (number >= 0)
!     high = 0;
!   else
!     {
!       /* Sizetype IS sign extended.  */
!       high = -1;
!       if (prec <= HOST_BITS_PER_WIDE_INT)
! 	low |= (HOST_WIDE_INT)(-1) << (prec - 1);
!     }
!   TREE_INT_CST_LOW (new_const) = low;
!   TREE_INT_CST_HIGH (new_const) = high;
! 
!   if (low != (unsigned HOST_WIDE_INT)number
!       || high != (number < 0 ? -1 : 0))
!     TREE_OVERFLOW (new_const) = TREE_CONSTANT_OVERFLOW (new_const) = 1;
!   
!   slot = htab_find_slot (size_htab, new_const, INSERT);
!   if (*slot == 0)
!     {
!       tree t = new_const;
! 
!       *slot = new_const;
!       new_const = make_node (INTEGER_CST);
!       return t;
!     }
!   else
!     return (tree) *slot;
! }
! 
  /* Combine operands OP1 and OP2 with arithmetic operation CODE.  CODE
     is a tree code.  The type of the result is taken from the operands.
     Both must be the same type integer type and it must be a size type.
--- 1595,1609 ----
    return 0;
  }
  
! /* Create a size type INT_CST node with NUMBER sign extended.  KIND
!    indicates which particular sizetype to create.  */
  
  tree
  size_int_kind (HOST_WIDE_INT number, enum size_type_kind kind)
  {
!   return build_int_cst (sizetype_tab[(int) kind], number);
  }
! 
  /* Combine operands OP1 and OP2 with arithmetic operation CODE.  CODE
     is a tree code.  The type of the result is taken from the operands.
     Both must be the same type integer type and it must be a size type.
*************** round_up (tree value, int divisor)
*** 10649,10655 ****
       doing it. */
    if (TREE_CODE (value) != INTEGER_CST)
      {
!       div = size_int_type (divisor, TREE_TYPE (value));
  
        if (multiple_of_p (TREE_TYPE (value), value, div))
  	return value;
--- 10561,10567 ----
       doing it. */
    if (TREE_CODE (value) != INTEGER_CST)
      {
!       div = build_int_cst (TREE_TYPE (value), divisor);
  
        if (multiple_of_p (TREE_TYPE (value), value, div))
  	return value;
*************** round_up (tree value, int divisor)
*** 10668,10674 ****
    else
      {
        if (!div)
! 	div = size_int_type (divisor, TREE_TYPE (value));
        value = size_binop (CEIL_DIV_EXPR, value, div);
        value = size_binop (MULT_EXPR, value, div);
      }
--- 10580,10586 ----
    else
      {
        if (!div)
! 	div = build_int_cst (TREE_TYPE (value), divisor);
        value = size_binop (CEIL_DIV_EXPR, value, div);
        value = size_binop (MULT_EXPR, value, div);
      }
*************** round_down (tree value, int divisor)
*** 10688,10702 ****
    if (divisor == 1)
      return value;
  
-   div = size_int_type (divisor, TREE_TYPE (value));
- 
    /* See if VALUE is already a multiple of DIVISOR.  If so, we don't
       have to do anything.  Only do this when we are not given a const,
       because in that case, this check is more expensive than just
       doing it. */
    if (TREE_CODE (value) != INTEGER_CST)
      {
!       div = size_int_type (divisor, TREE_TYPE (value));
  
        if (multiple_of_p (TREE_TYPE (value), value, div))
  	return value;
--- 10600,10612 ----
    if (divisor == 1)
      return value;
  
    /* See if VALUE is already a multiple of DIVISOR.  If so, we don't
       have to do anything.  Only do this when we are not given a const,
       because in that case, this check is more expensive than just
       doing it. */
    if (TREE_CODE (value) != INTEGER_CST)
      {
!       div = build_int_cst (TREE_TYPE (value), divisor);
  
        if (multiple_of_p (TREE_TYPE (value), value, div))
  	return value;
*************** round_down (tree value, int divisor)
*** 10713,10723 ****
    else
      {
        if (!div)
! 	div = size_int_type (divisor, TREE_TYPE (value));
        value = size_binop (FLOOR_DIV_EXPR, value, div);
        value = size_binop (MULT_EXPR, value, div);
      }
  
    return value;
  }
- #include "gt-fold-const.h"
--- 10623,10632 ----
    else
      {
        if (!div)
! 	div = build_int_cst (TREE_TYPE (value), divisor);
        value = size_binop (FLOOR_DIV_EXPR, value, div);
        value = size_binop (MULT_EXPR, value, div);
      }
  
    return value;
  }
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.604
diff -c -3 -p -r1.604 tree.h
*** tree.h	25 Aug 2004 09:51:34 -0000	1.604
--- tree.h	27 Aug 2004 08:50:14 -0000
*************** extern GTY(()) tree sizetype_tab[(int) T
*** 3091,3100 ****
  #define ssizetype sizetype_tab[(int) SSIZETYPE]
  #define sbitsizetype sizetype_tab[(int) SBITSIZETYPE]
  
  extern tree size_binop (enum tree_code, tree, tree);
  extern tree size_diffop (tree, tree);
- extern tree size_int_kind (HOST_WIDE_INT, enum size_type_kind);
- extern tree size_int_type (HOST_WIDE_INT, tree);
  
  #define size_int(L) size_int_kind (L, SIZETYPE)
  #define ssize_int(L) size_int_kind (L, SSIZETYPE)
--- 3091,3099 ----
  #define ssizetype sizetype_tab[(int) SSIZETYPE]
  #define sbitsizetype sizetype_tab[(int) SBITSIZETYPE]
  
+ extern tree size_int_kind (HOST_WIDE_INT, enum size_type_kind);
  extern tree size_binop (enum tree_code, tree, tree);
  extern tree size_diffop (tree, tree);
  
  #define size_int(L) size_int_kind (L, SIZETYPE)
  #define ssize_int(L) size_int_kind (L, SSIZETYPE)
Index: ada/utils2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/utils2.c,v
retrieving revision 1.36
diff -c -3 -p -r1.36 utils2.c
*** ada/utils2.c	25 Aug 2004 09:52:05 -0000	1.36
--- ada/utils2.c	27 Aug 2004 08:50:24 -0000
*************** build_allocator (tree type, tree init, t
*** 1799,1805 ****
        /* If the size overflows, pass -1 so the allocator will raise
  	 storage error.  */
        if (TREE_CODE (size) == INTEGER_CST && TREE_OVERFLOW (size))
! 	size = build_int_cst (ssizetype, -1);
  
        storage = build_call_alloc_dealloc (NULL_TREE, size,
  					  TYPE_ALIGN (storage_type),
--- 1799,1805 ----
        /* If the size overflows, pass -1 so the allocator will raise
  	 storage error.  */
        if (TREE_CODE (size) == INTEGER_CST && TREE_OVERFLOW (size))
! 	size = ssize_int (-1);
  
        storage = build_call_alloc_dealloc (NULL_TREE, size,
  					  TYPE_ALIGN (storage_type),
*************** build_allocator (tree type, tree init, t
*** 1872,1878 ****
    /* If the size overflows, pass -1 so the allocator will raise
       storage error.  */
    if (TREE_CODE (size) == INTEGER_CST && TREE_OVERFLOW (size))
!     size = build_int_cst (ssizetype, -1);
  
    /* If this is a type whose alignment is larger than the
       biggest we support in normal alignment and this is in
--- 1872,1878 ----
    /* If the size overflows, pass -1 so the allocator will raise
       storage error.  */
    if (TREE_CODE (size) == INTEGER_CST && TREE_OVERFLOW (size))
!     size = ssize_int (-1);
  
    /* If this is a type whose alignment is larger than the
       biggest we support in normal alignment and this is in
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.658
diff -c -3 -p -r1.658 class.c
*** cp/class.c	25 Aug 2004 09:52:29 -0000	1.658
--- cp/class.c	27 Aug 2004 08:50:44 -0000
*************** build_vtbl_initializer (tree binfo,
*** 7278,7285 ****
    vid.ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
    vid.generate_vcall_entries = true;
    /* The first vbase or vcall offset is at index -3 in the vtable.  */
!   vid.index = build_int_cst (ssizetype,
! 			     -3 * TARGET_VTABLE_DATA_ENTRY_DISTANCE);
  
    /* Add entries to the vtable for RTTI.  */
    build_rtti_vtbl_entries (binfo, &vid);
--- 7278,7284 ----
    vid.ctor_vtbl_p = !same_type_p (BINFO_TYPE (rtti_binfo), t);
    vid.generate_vcall_entries = true;
    /* The first vbase or vcall offset is at index -3 in the vtable.  */
!   vid.index = ssize_int(-3 * TARGET_VTABLE_DATA_ENTRY_DISTANCE);
  
    /* Add entries to the vtable for RTTI.  */
    build_rtti_vtbl_entries (binfo, &vid);
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1279
diff -c -3 -p -r1.1279 decl.c
*** cp/decl.c	25 Aug 2004 20:50:56 -0000	1.1279
--- cp/decl.c	27 Aug 2004 08:51:06 -0000
*************** complete_array_type (tree type, tree ini
*** 5260,5266 ****
  	{
  	  tree elts = CONSTRUCTOR_ELTS (initial_value);
  
! 	  maxindex = build_int_cst (ssizetype, -1);
  	  for (; elts; elts = TREE_CHAIN (elts))
  	    {
  	      if (TREE_PURPOSE (elts))
--- 5260,5266 ----
  	{
  	  tree elts = CONSTRUCTOR_ELTS (initial_value);
  
! 	  maxindex = ssize_int (-1);
  	  for (; elts; elts = TREE_CHAIN (elts))
  	    {
  	      if (TREE_PURPOSE (elts))
Index: cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.311
diff -c -3 -p -r1.311 method.c
*** cp/method.c	25 Aug 2004 09:52:38 -0000	1.311
--- cp/method.c	27 Aug 2004 08:51:09 -0000
*************** void
*** 179,185 ****
  finish_thunk (tree thunk)
  {
    tree function, name;
!   tree fixed_offset = build_int_cst (ssizetype, THUNK_FIXED_OFFSET (thunk));
    tree virtual_offset = THUNK_VIRTUAL_OFFSET (thunk);
  
    my_friendly_assert (!DECL_NAME (thunk) && DECL_THUNK_P (thunk), 20021127);
--- 179,185 ----
  finish_thunk (tree thunk)
  {
    tree function, name;
!   tree fixed_offset = ssize_int (THUNK_FIXED_OFFSET (thunk));
    tree virtual_offset = THUNK_VIRTUAL_OFFSET (thunk);
  
    my_friendly_assert (!DECL_NAME (thunk) && DECL_THUNK_P (thunk), 20021127);
Index: cp/search.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/search.c,v
retrieving revision 1.313
diff -c -3 -p -r1.313 search.c
*** cp/search.c	25 Aug 2004 09:52:39 -0000	1.313
--- cp/search.c	27 Aug 2004 08:51:14 -0000
*************** get_dynamic_cast_base_type (tree subtype
*** 347,353 ****
    
    if (!boff)
      return offset;
!   offset = build_int_cst (ssizetype, boff);
    return offset;
  }
  
--- 347,353 ----
    
    if (!boff)
      return offset;
!   offset = ssize_int (boff);
    return offset;
  }
  

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