[PATCH] Remove TYPE_NONCOPIED_PARTS

Nathan Sidwell nathan@codesourcery.com
Thu Sep 6 01:45:00 GMT 2001


[this is a resend to the list only, my home ISP is on a bad
mailer list]

Mark,
this patch removes the no longer used TYPE_NONCOPIED_PARTS.
Whilst the removal of that is mechanical, the noncopied_parts slot
of struct tree_type had other uses. I remapped them as follows,
1) TYPE_ACTUAL_ARG_TYPES becomes TYPE_BINFO
2) TYPE_RAISES_EXCEPTIONS becomes TYPE_BINFO
3) CLASSTYPE_INLINE_FRIENDS becomes CLASSTYPE_PURE_VIRTUALS

1 is a C only use an applies to (non prototypes) FUNCTION_TYPE
2 is C++ and applies to FUNCTION_TYPE and METHOD_TYPE
3 is C++ and holds inline friend info during parsing a class. It is
then unneeded.

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

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-09-05  Nathan Sidwell  <nathan@codesourcery.com>

	Remove TYPE_NONCOPIED_PARTS.
	* tree.h (TYPE_NONCOPIED_PARTS): Remove.
	(struct tree_type): Remove noncopied_parts.
	* c-tree.h (TYPE_ACTUAL_ARG_TYPES): Map onto TYPE_BINFO.
	* expr.c (save_noncopied_parts, init_noncopied_parts): Remove.
	(fixed_type_p): Remove.
	(expand_expr, INIT_EXPR): Don't deal with noncopied parts.
	(expand_expr, MODIFY_EXPR): Likewise.
	* ggc-common.c (ggc_mark_trees): Remove TYPE_NONCOPIED_PARTS.
	* doc/c-tree.texi: Remove TYPE_NONCOPIED_PARTS FIXME.

cp:
2001-09-05  Nathan Sidwell  <nathan@codesourcery.com>

	* cp-tree.h (CLASSTYPE_INLINE_FRIENDS): Map onto
	CLASSTYPE_PURE_VIRTUALS.
	(TYPE_RAISES_EXCEPTIONS): Map onto TYPE_BINFO.
	* class.c (duplicate_tag_error): Remove TYPE_NONCOPIED_PARTS.
	(layout_class_type): Don't call fixup_inlin_methods here ...
	(finish_struct_1): ... call it here.

Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.263
diff -c -3 -p -r1.263 tree.h
*** tree.h	2001/08/31 22:22:02	1.263
--- tree.h	2001/09/05 18:43:12
*************** struct tree_block
*** 918,924 ****
  #define TYPE_NAME(NODE) (TYPE_CHECK (NODE)->type.name)
  #define TYPE_NEXT_VARIANT(NODE) (TYPE_CHECK (NODE)->type.next_variant)
  #define TYPE_MAIN_VARIANT(NODE) (TYPE_CHECK (NODE)->type.main_variant)
- #define TYPE_NONCOPIED_PARTS(NODE) (TYPE_CHECK (NODE)->type.noncopied_parts)
  #define TYPE_CONTEXT(NODE) (TYPE_CHECK (NODE)->type.context)
  #define TYPE_LANG_SPECIFIC(NODE) (TYPE_CHECK (NODE)->type.lang_specific)
  
--- 918,923 ----
*************** struct tree_type
*** 1191,1197 ****
    tree next_variant;
    tree main_variant;
    tree binfo;
-   tree noncopied_parts;
    tree context;
    HOST_WIDE_INT alias_set;
    /* Points to a structure whose details depend on the language in use.  */
--- 1190,1195 ----
Index: c-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v
retrieving revision 1.67
diff -c -3 -p -r1.67 c-tree.h
*** c-tree.h	2001/08/27 17:07:48	1.67
--- c-tree.h	2001/09/05 18:43:30
*************** struct lang_type
*** 135,141 ****
  /* For FUNCTION_TYPE, a hidden list of types of arguments.  The same as
     TYPE_ARG_TYPES for functions with prototypes, but created for functions
     without prototypes.  */
! #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_NONCOPIED_PARTS (NODE)
  
  
  /* in c-lang.c and objc-act.c */
--- 135,141 ----
  /* For FUNCTION_TYPE, a hidden list of types of arguments.  The same as
     TYPE_ARG_TYPES for functions with prototypes, but created for functions
     without prototypes.  */
! #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_BINFO (NODE)
  
  
  /* in c-lang.c and objc-act.c */
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.350
diff -c -3 -p -r1.350 expr.c
*** expr.c	2001/09/02 01:14:45	1.350
--- expr.c	2001/09/05 18:46:18
*************** static rtx store_field		PARAMS ((rtx, HO
*** 163,171 ****
  					 unsigned int, HOST_WIDE_INT, int));
  static enum memory_use_mode
    get_memory_usage_from_modifier PARAMS ((enum expand_modifier));
- static tree save_noncopied_parts PARAMS ((tree, tree));
- static tree init_noncopied_parts PARAMS ((tree, tree));
- static int fixed_type_p		PARAMS ((tree));
  static rtx var_rtx		PARAMS ((tree));
  static rtx expand_expr_unaligned PARAMS ((tree, unsigned int *));
  static rtx expand_increment	PARAMS ((tree, int, int));
--- 163,168 ----
*************** force_operand (value, target)
*** 5659,5726 ****
    return value;
  }
  
- /* Subroutine of expand_expr:
-    save the non-copied parts (LIST) of an expr (LHS), and return a list
-    which can restore these values to their previous values,
-    should something modify their storage.  */
- 
- static tree
- save_noncopied_parts (lhs, list)
-      tree lhs;
-      tree list;
- {
-   tree tail;
-   tree parts = 0;
- 
-   for (tail = list; tail; tail = TREE_CHAIN (tail))
-     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
-       parts = chainon (parts, save_noncopied_parts (lhs, TREE_VALUE (tail)));
-     else
-       {
- 	tree part = TREE_VALUE (tail);
- 	tree part_type = TREE_TYPE (part);
- 	tree to_be_saved = build (COMPONENT_REF, part_type, lhs, part);
- 	rtx target
- 	  = assign_temp (build_qualified_type (part_type,
- 					       (TYPE_QUALS (part_type)
- 						| TYPE_QUAL_CONST)),
- 			 0, 1, 1);
- 
- 	parts = tree_cons (to_be_saved,
- 			   build (RTL_EXPR, part_type, NULL_TREE,
- 				  (tree) validize_mem (target)),
- 			   parts);
- 	store_expr (TREE_PURPOSE (parts),
- 		    RTL_EXPR_RTL (TREE_VALUE (parts)), 0);
-       }
-   return parts;
- }
- 
- /* Subroutine of expand_expr:
-    record the non-copied parts (LIST) of an expr (LHS), and return a list
-    which specifies the initial values of these parts.  */
- 
- static tree
- init_noncopied_parts (lhs, list)
-      tree lhs;
-      tree list;
- {
-   tree tail;
-   tree parts = 0;
- 
-   for (tail = list; tail; tail = TREE_CHAIN (tail))
-     if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
-       parts = chainon (parts, init_noncopied_parts (lhs, TREE_VALUE (tail)));
-     else if (TREE_PURPOSE (tail))
-       {
- 	tree part = TREE_VALUE (tail);
- 	tree part_type = TREE_TYPE (part);
- 	tree to_be_initialized = build (COMPONENT_REF, part_type, lhs, part);
- 	parts = tree_cons (TREE_PURPOSE (tail), to_be_initialized, parts);
-       }
-   return parts;
- }
- 
  /* Subroutine of expand_expr: return nonzero iff there is no way that
     EXP can reference X, which is being modified.  TOP_P is nonzero if this
     call is going to be used to determine whether we need a temporary
--- 5656,5661 ----
*************** safe_from_p (x, exp, top_p)
*** 5945,5966 ****
    return 1;
  }
  
- /* Subroutine of expand_expr: return nonzero iff EXP is an
-    expression whose type is statically determinable.  */
- 
- static int
- fixed_type_p (exp)
-      tree exp;
- {
-   if (TREE_CODE (exp) == PARM_DECL
-       || TREE_CODE (exp) == VAR_DECL
-       || TREE_CODE (exp) == CALL_EXPR || TREE_CODE (exp) == TARGET_EXPR
-       || TREE_CODE (exp) == COMPONENT_REF
-       || TREE_CODE (exp) == ARRAY_REF)
-     return 1;
-   return 0;
- }
- 
  /* Subroutine of expand_expr: return rtx if EXP is a
     variable or parameter; else return 0.  */
  
--- 5880,5885 ----
*************** expand_expr (exp, target, tmode, modifie
*** 8505,8541 ****
        {
  	tree lhs = TREE_OPERAND (exp, 0);
  	tree rhs = TREE_OPERAND (exp, 1);
- 	tree noncopied_parts = 0;
- 	tree lhs_type = TREE_TYPE (lhs);
  
  	temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
- 	if (TYPE_NONCOPIED_PARTS (lhs_type) != 0 && !fixed_type_p (rhs))
- 	  noncopied_parts
- 	    = init_noncopied_parts (stabilize_reference (lhs),
- 				    TYPE_NONCOPIED_PARTS (lhs_type));
- 
- 	while (noncopied_parts != 0)
- 	  {
- 	    expand_assignment (TREE_VALUE (noncopied_parts),
- 			       TREE_PURPOSE (noncopied_parts), 0, 0);
- 	    noncopied_parts = TREE_CHAIN (noncopied_parts);
- 	  }
  	return temp;
        }
  
      case MODIFY_EXPR:
        {
  	/* If lhs is complex, expand calls in rhs before computing it.
! 	   That's so we don't compute a pointer and save it over a call.
! 	   If lhs is simple, compute it first so we can give it as a
! 	   target if the rhs is just a call.  This avoids an extra temp and copy
! 	   and that prevents a partial-subsumption which makes bad code.
! 	   Actually we could treat component_ref's of vars like vars.  */
  
  	tree lhs = TREE_OPERAND (exp, 0);
  	tree rhs = TREE_OPERAND (exp, 1);
- 	tree noncopied_parts = 0;
- 	tree lhs_type = TREE_TYPE (lhs);
  
  	temp = 0;
  
--- 8424,8446 ----
        {
  	tree lhs = TREE_OPERAND (exp, 0);
  	tree rhs = TREE_OPERAND (exp, 1);
  
  	temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
  	return temp;
        }
  
      case MODIFY_EXPR:
        {
  	/* If lhs is complex, expand calls in rhs before computing it.
! 	   That's so we don't compute a pointer and save it over a
! 	   call.  If lhs is simple, compute it first so we can give it
! 	   as a target if the rhs is just a call.  This avoids an
! 	   extra temp and copy and that prevents a partial-subsumption
! 	   which makes bad code.  Actually we could treat
! 	   component_ref's of vars like vars.  */
  
  	tree lhs = TREE_OPERAND (exp, 0);
  	tree rhs = TREE_OPERAND (exp, 1);
  
  	temp = 0;
  
*************** expand_expr (exp, target, tmode, modifie
*** 8571,8589 ****
  	    return const0_rtx;
  	  }
  
- 	if (TYPE_NONCOPIED_PARTS (lhs_type) != 0
- 	    && ! (fixed_type_p (lhs) && fixed_type_p (rhs)))
- 	  noncopied_parts
- 	    = save_noncopied_parts (stabilize_reference (lhs),
- 				    TYPE_NONCOPIED_PARTS (lhs_type));
- 
  	temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
! 	while (noncopied_parts != 0)
! 	  {
! 	    expand_assignment (TREE_PURPOSE (noncopied_parts),
! 			       TREE_VALUE (noncopied_parts), 0, 0);
! 	    noncopied_parts = TREE_CHAIN (noncopied_parts);
! 	  }
  	return temp;
        }
  
--- 8476,8483 ----
  	    return const0_rtx;
  	  }
  
  	temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
! 	
  	return temp;
        }
  
Index: ggc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-common.c,v
retrieving revision 1.40
diff -c -3 -p -r1.40 ggc-common.c
*** ggc-common.c	2001/08/31 22:22:01	1.40
--- ggc-common.c	2001/09/05 18:46:22
*************** ggc_mark_trees ()
*** 399,405 ****
  	  ggc_mark_tree (TYPE_NEXT_VARIANT (t));
  	  ggc_mark_tree (TYPE_MAIN_VARIANT (t));
  	  ggc_mark_tree (TYPE_BINFO (t));
- 	  ggc_mark_tree (TYPE_NONCOPIED_PARTS (t));
  	  ggc_mark_tree (TYPE_CONTEXT (t));
  	  lang_mark_tree (t);
  	  break;
--- 399,404 ----
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.639
diff -c -3 -p -r1.639 cp-tree.h
*** cp-tree.h	2001/08/24 12:07:43	1.639
--- cp-tree.h	2001/09/05 18:47:59
*************** Boston, MA 02111-1307, USA.  */
*** 117,122 ****
--- 117,123 ----
       For a TYPENAME_TYPE, this is TYPENAME_TYPE_FULLNAME.
       For a TEMPLATE_TEMPLATE_PARM or BOUND_TEMPLATE_TEMPLATE_PARM,
       this is TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO.
+      For a FUNCTION_TYPE or METHOD_TYPE, this is TYPE_RAISES_EXCEPTIONS
  
    BINFO_VIRTUALS
       For a binfo, this is a TREE_LIST.  The BV_DELTA of each node
*************** struct lang_type
*** 1266,1272 ****
     After the class is defined, these fields hold other information.  */
  
  /* List of friends which were defined inline in this class definition.  */
! #define CLASSTYPE_INLINE_FRIENDS(NODE) (TYPE_NONCOPIED_PARTS (NODE))
  
  /* Nonzero for _CLASSTYPE means that operator delete is defined.  */
  #define TYPE_GETS_DELETE(NODE) (TYPE_LANG_SPECIFIC(NODE)->gets_delete)
--- 1267,1273 ----
     After the class is defined, these fields hold other information.  */
  
  /* List of friends which were defined inline in this class definition.  */
! #define CLASSTYPE_INLINE_FRIENDS(NODE) (CLASSTYPE_PURE_VIRTUALS (NODE))
  
  /* Nonzero for _CLASSTYPE means that operator delete is defined.  */
  #define TYPE_GETS_DELETE(NODE) (TYPE_LANG_SPECIFIC(NODE)->gets_delete)
*************** struct lang_type
*** 1660,1666 ****
     this type can raise.  Each TREE_VALUE is a _TYPE.  The TREE_VALUE
     will be NULL_TREE to indicate a throw specification of `()', or
     no exceptions allowed.  */
! #define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_NONCOPIED_PARTS (NODE)
  
  /* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'.  */
  #define TYPE_NOTHROW_P(NODE) \
--- 1661,1667 ----
     this type can raise.  Each TREE_VALUE is a _TYPE.  The TREE_VALUE
     will be NULL_TREE to indicate a throw specification of `()', or
     no exceptions allowed.  */
! #define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_BINFO (NODE)
  
  /* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'.  */
  #define TYPE_NOTHROW_P(NODE) \
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.406
diff -c -3 -p -r1.406 class.c
*** class.c	2001/08/30 12:44:22	1.406
--- class.c	2001/09/05 18:50:05
*************** duplicate_tag_error (t)
*** 2189,2195 ****
    TYPE_METHODS (t) = NULL_TREE;
    TYPE_VFIELD (t) = NULL_TREE;
    TYPE_CONTEXT (t) = NULL_TREE;
-   TYPE_NONCOPIED_PARTS (t) = NULL_TREE;
    
    /* Clear TYPE_LANG_FLAGS -- those in TYPE_LANG_SPECIFIC are cleared above.  */
    TYPE_LANG_FLAG_0 (t) = 0;
--- 2189,2194 ----
*************** layout_class_type (t, empty_p, vfuns_p, 
*** 4866,4875 ****
    if (build_base_fields (rli, empty_p, empty_base_offsets, t))
      CLASSTYPE_NEARLY_EMPTY_P (t) = 0;
    
-   /* CLASSTYPE_INLINE_FRIENDS is really TYPE_NONCOPIED_PARTS.  Thus,
-      we have to save this before we zap TYPE_NONCOPIED_PARTS.  */
-   fixup_inline_methods (t);
- 
    /* Layout the non-static data members.  */
    for (field = non_static_data_members; field; field = TREE_CHAIN (field))
      {
--- 4865,4870 ----
*************** finish_struct_1 (t)
*** 5077,5082 ****
--- 5072,5079 ----
    vfuns = 0;
    CLASSTYPE_RTTI (t) = NULL_TREE;
  
+   fixup_inline_methods (t);
+   
    /* Do end-of-class semantic processing: checking the validity of the
       bases and members and add implicitly generated methods.  */
    check_bases_and_members (t, &empty);
Index: doc/c-tree.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/c-tree.texi,v
retrieving revision 1.15
diff -c -3 -p -r1.15 c-tree.texi
*** c-tree.texi	2001/08/02 10:51:16	1.15
--- c-tree.texi	2001/09/05 18:51:04
*************** indicated kind of inheritance was used. 
*** 758,765 ****
  holds of a binfo, then its @code{BINFO_TYPE} was inherited from
  virtually.
  
- FIXME: Talk about @code{TYPE_NONCOPIED_PARTS}.
- 
  The following macros can be used on a tree node representing a class-type.
  
  @ftable @code
--- 758,763 ----



More information about the Gcc-patches mailing list