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]

[csl-hpuc-branch] vestigial destructor parameter


Hi,
I've installed this patch on the csl-hpux-branch. It uses the targetm hook
structure for the vestigial in-charge parameter needed on HPUX.

built and tested with an ia64-hp-hpux11.23 cross compiler and an
i686-pc-linux-gnu native compiler, approved by Mark.

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
         The voices in my head said this was stupid too
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2003-12-05  Nathan Sidwell  <nathan@codesourcery.com>

	* target.h (gcc_target.abi): Add cxx_dtor_in_charge_parm.
	* target-def.h (TARGET_ABI_CXX_DTOR_IN_CHARGE_PARM): New.
	(TARGET_ABI): Add new initializer.
	* config/ia64/ia64.c (TARGET_ABI_CXX_DTOR_IN_CHARGE_PARM):
	Override on HPUX.
	* doc/tm.texi (TARGET_ABI_CXX_DTOR_IN_CHARGE_PARM): Document

	* cp/class.c (build_clone): Use cxx_dtor_in_charge_parm_ to
	determine whether a vestigial in_charge parameter is needed.
	* cp/call.c (build_new_method_call): Prepend vestigial in-charge only
	if there is one.

Index: target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.62.2.2
diff -c -3 -p -r1.62.2.2 target-def.h
*** target-def.h	30 Nov 2003 16:26:58 -0000	1.62.2.2
--- target-def.h	5 Dec 2003 12:44:55 -0000
*************** Foundation, 59 Temple Place - Suite 330,
*** 351,360 ****
--- 351,362 ----
  
  #define TARGET_ABI_CXX_VIRTUAL_DTORS_POSITION abi_cxx_vdp_default
  #define TARGET_ABI_CXX_EXPR_DECL_MANGLING abi_cxx_edm_default
+ #define TARGET_ABI_CXX_DTOR_IN_CHARGE_PARM abi_cxx_dicp_default
  
  #define TARGET_ABI {						\
     TARGET_ABI_CXX_VIRTUAL_DTORS_POSITION,			\
     TARGET_ABI_CXX_EXPR_DECL_MANGLING,				\
+    TARGET_ABI_CXX_DTOR_IN_CHARGE_PARM,				\
     }
  
  /* The whole shebang.  */
Index: target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.70.2.2
diff -c -3 -p -r1.70.2.2 target.h
*** target.h	30 Nov 2003 16:26:58 -0000	1.70.2.2
--- target.h	5 Dec 2003 12:44:56 -0000
*************** struct gcc_target
*** 448,453 ****
--- 448,454 ----
        abi_cxx_vdp_last_in_vtable,  /* Placed last in vtable. */
        abi_cxx_vdp_declared_last    /* As if they are declared last. */
      } cxx_virtual_dtors_position;
+     
      /* How _DECL nodes are mangled in expressions. */
      enum abi_cxx_expr_decl_mangling {
        abi_cxx_edm_default,
*************** struct gcc_target
*** 455,460 ****
--- 456,471 ----
  					    symbol, encoded as a
  					    source_name */
      } cxx_expr_decl_mangling;
+     
+     /* Whether there are any vestigial in_charge destructor
+        parameters.  */
+     enum abi_cxx_dtor_in_charge_parm {
+       abi_cxx_dicp_default,
+       abi_cxx_dicp_with_vbases,   /* Only on destructors with virtual
+ 				     bases. */
+       abi_cxx_dicp_always	  /* On every destructor.  */
+     } cxx_dtor_in_charge_parm;
+     
    } abi;
  };
  
Index: config/ia64/ia64.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.c,v
retrieving revision 1.259.2.2
diff -c -3 -p -r1.259.2.2 ia64.c
*** config/ia64/ia64.c	30 Nov 2003 16:27:21 -0000	1.259.2.2
--- config/ia64/ia64.c	5 Dec 2003 12:45:23 -0000
*************** static const struct attribute_spec ia64_
*** 372,384 ****
--- 372,391 ----
  #define TARGET_ENCODE_SECTION_INFO ia64_encode_section_info
  
  #if TARGET_HPUX
+ 
  /* On HPUX, virtual destructors behave as if they are declared last. */
  #undef TARGET_ABI_CXX_VIRTUAL_DTORS_POSITION
  #define TARGET_ABI_CXX_VIRTUAL_DTORS_POSITION abi_cxx_vdp_declared_last
+ 
  /* On HPUX DECL nodes are mangled independently and then encoded as a
     source_name.  */
  #undef TARGET_ABI_CXX_EXPR_DECL_MANGLING
  #define TARGET_ABI_CXX_EXPR_DECL_MANGLING abi_cxx_edm_as_nested_source_name
+ 
+ /* On HPUX all dtors have a vestigial destructor parameter.  */
+ #undef TARGET_ABI_CXX_DTOR_IN_CHARGE_PARM
+ #define TARGET_ABI_CXX_DTOR_IN_CHARGE_PARM abi_cxx_dicp_always
+ 
  #endif
  
  struct gcc_target targetm = TARGET_INITIALIZER;
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.441.2.1
diff -c -3 -p -r1.441.2.1 call.c
*** cp/call.c	24 Nov 2003 16:41:25 -0000	1.441.2.1
--- cp/call.c	5 Dec 2003 12:45:38 -0000
*************** build_new_method_call (tree instance, tr
*** 5006,5013 ****
        tree type = build_pointer_type (basetype);
        if (!same_type_p (type, TREE_TYPE (instance_ptr)))
  	instance_ptr = build_nop (type, instance_ptr);
!       /* Prepend the dummy in-charge argument.  */
!       args = tree_cons (NULL_TREE, integer_zero_node, args);
      }
  
    class_type = (conversion_path ? BINFO_TYPE (conversion_path) : NULL_TREE);
--- 5006,5014 ----
        tree type = build_pointer_type (basetype);
        if (!same_type_p (type, TREE_TYPE (instance_ptr)))
  	instance_ptr = build_nop (type, instance_ptr);
!       if (DECL_HAS_IN_CHARGE_PARM_P (fn))
!         /* Prepend a vestigial in-charge argument.  */
! 	args = tree_cons (NULL_TREE, integer_zero_node, args);
      }
  
    class_type = (conversion_path ? BINFO_TYPE (conversion_path) : NULL_TREE);
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.582.2.2
diff -c -3 -p -r1.582.2.2 class.c
*** cp/class.c	30 Nov 2003 15:52:13 -0000	1.582.2.2
--- cp/class.c	5 Dec 2003 12:45:55 -0000
*************** check_methods (tree t)
*** 3812,3818 ****
     We add it here to every clone.  A better fix, which would fit with
     the mainline more cleanly, might well be to add in-charge parms to
     all abstract ctors and dtors, and then remove them (or not) in the
!    clones. All call sites would prepend a dummty in-charge arg, that
     gets dropped if the selected cdtor doesn't need it.  Also, we could
     add the VTT parm to the abstract ctor/dtor too, and do the same
     with that.  Then MAYBE_IN_CHARGE_X can go away.  */
--- 3812,3818 ----
     We add it here to every clone.  A better fix, which would fit with
     the mainline more cleanly, might well be to add in-charge parms to
     all abstract ctors and dtors, and then remove them (or not) in the
!    clones. All call sites would prepend a dummy in-charge arg, that
     gets dropped if the selected cdtor doesn't need it.  Also, we could
     add the VTT parm to the abstract ctor/dtor too, and do the same
     with that.  Then MAYBE_IN_CHARGE_X can go away.  */
*************** build_clone (tree fn, tree name)
*** 3822,3828 ****
  {
    tree parms;
    tree clone;
!   bool needs_dummy_inchg = DECL_DESTRUCTOR_P (fn);
  
    /* Copy the function.  */
    clone = copy_decl (fn);
--- 3822,3828 ----
  {
    tree parms;
    tree clone;
!   bool needs_dummy_inchg = false;
  
    /* Copy the function.  */
    clone = copy_decl (fn);
*************** build_clone (tree fn, tree name)
*** 3838,3843 ****
--- 3838,3858 ----
    /* And it hasn't yet been deferred.  */
    DECL_DEFERRED_FN (clone) = 0;
  
+   if (DECL_DESTRUCTOR_P (fn))
+     {
+       switch (targetm.abi.cxx_dtor_in_charge_parm)
+ 	{
+ 	case abi_cxx_dicp_default:
+ 	  break;
+ 	case abi_cxx_dicp_with_vbases:
+ 	  needs_dummy_inchg = DECL_HAS_IN_CHARGE_PARM_P (fn);
+ 	  break;
+ 	case abi_cxx_dicp_always:
+ 	  needs_dummy_inchg = true;
+ 	  break;
+ 	}
+     }
+  
    /* The base-class destructor is not virtual.  */
    if (name == base_dtor_identifier)
      {
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.266.2.2
diff -c -3 -p -r1.266.2.2 tm.texi
*** doc/tm.texi	30 Nov 2003 16:27:25 -0000	1.266.2.2
--- doc/tm.texi	5 Dec 2003 12:46:31 -0000
*************** independently and then encoded as a @cod
*** 4529,4534 ****
--- 4529,4547 ----
  @code{abi_cxx_edm_as_nested_source_name}.
  @end deftypevr
  
+ @findex abi_cxx_dicp_default
+ @findex abi_cxx_dicp_with_vbases
+ @findex abi_cxx_dicp_always
+ @deftypevr {Target Hook} {enum cxx_dtor_in_charge_parm} TARGET_ABI_CXX_DTOR_IN_CHARGE_PARM
+ Set this hook if destructors have a vestigial in charge parameter.
+ The default is @code{abi_cxx_dicp_default}, which means there is no such
+ parameter.  If instead there is one for classes with virtual bases, set
+ it to @code{abi_cxx_dicp_with_vbases}. If every destructor has such a
+ pareter, set it to @code{abi_cxx_dicp_always}.  When present the
+ parameter is passed immediately after the this parameter, and the value
+ zero is passed.
+ @end deftypevr
+ 
  @node Trampolines
  @section Trampolines for Nested Functions
  @cindex trampolines for nested functions

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