This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: New C++ target macro to allow backends to overrule thedecision to import or export a class
- From: Nick Clifton <nickc at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 30 Jun 2004 09:53:06 +0100
- Subject: RFA: New C++ target macro to allow backends to overrule thedecision to import or export a class
Hi Guys,
I would like permission to apply the patch below. It is a revised
and simplified version of the patch submitted here:
http://gcc.gnu.org/ml/gcc-patches/2004-05/msg00860.html
The patch adds a new C++ specific target macro which is used in the
import_export_class() function to allow backends to overrule the
decision about whether a class should be imported or exported. This
is needed for the Symbian OS which has complicated rules about
exporting classes depending upon the attributes that have been set
on them or their ancestors.
The bulk of the original patch has now been moved into the SH
backend and will be contributed if this patch is approved.
Cheers
Nick
gcc/ChangeLog
2004-06-30 Nick Clifton <nickc@redhat.com>
* target.h (struct gcc_target): Add new field to struct cxx:
import_export_class.
* target-def.h (TARGET_CXX): Initialise the new field.
(TARGET_CXX_IMPORT_EXPORT_CLASS): Provide a default value for
the new field.
* doc/tm.texi: Document the new target hook.
gcc/cp/ChangeLog
2004-06-30 Nick Clifton <nickc@redhat.com>
* decl2.c (import_export_class): Invoke the
import_export_class field in the gcc_target structure is not
empty.
Index: gcc/target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.95
diff -c -3 -p -r1.95 target.h
*** gcc/target.h 29 Jun 2004 14:50:26 -0000 1.95
--- gcc/target.h 30 Jun 2004 08:32:21 -0000
*************** struct gcc_target
*** 487,492 ****
--- 487,495 ----
/* Returns true if the element size should be stored in the
array cookie. */
bool (*cookie_has_size) (void);
+ /* Allows backends to perform additional processing when
+ deciding if a class should be exported or imported. */
+ void (*import_export_class) (tree, int *);
} cxx;
/* Leave the boolean fields at the end. */
Index: gcc/target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.82
diff -c -3 -p -r1.82 target-def.h
*** gcc/target-def.h 29 Jun 2004 14:50:26 -0000 1.82
--- gcc/target-def.h 30 Jun 2004 08:32:21 -0000
*************** Foundation, 59 Temple Place - Suite 330,
*** 408,419 ****
#define TARGET_CXX_COOKIE_HAS_SIZE hook_bool_void_false
#endif
#define TARGET_CXX \
{ \
TARGET_CXX_GUARD_TYPE, \
TARGET_CXX_GUARD_MASK_BIT, \
TARGET_CXX_GET_COOKIE_SIZE, \
! TARGET_CXX_COOKIE_HAS_SIZE \
}
/* The whole shebang. */
--- 408,424 ----
#define TARGET_CXX_COOKIE_HAS_SIZE hook_bool_void_false
#endif
+ #ifndef TARGET_CXX_IMPORT_EXPORT_CLASS
+ #define TARGET_CXX_IMPORT_EXPORT_CLASS NULL
+ #endif
+
#define TARGET_CXX \
{ \
TARGET_CXX_GUARD_TYPE, \
TARGET_CXX_GUARD_MASK_BIT, \
TARGET_CXX_GET_COOKIE_SIZE, \
! TARGET_CXX_COOKIE_HAS_SIZE, \
! TARGET_CXX_IMPORT_EXPORT_CLASS \
}
/* The whole shebang. */
Index: gcc/doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.332
diff -c -3 -p -r1.332 tm.texi
*** gcc/doc/tm.texi 29 Jun 2004 14:50:31 -0000 1.332
--- gcc/doc/tm.texi 30 Jun 2004 08:32:52 -0000
*************** This hook should return @code{true} if t
*** 8490,8495 ****
--- 8490,8504 ----
array cookies. The default is to return @code{false}.
@end deftypefn
+ @deftypefn {Target Hook} void TARGET_CXX_IMPORT_EXPORT_CLASS (tree @var{type}, int * @var{import_export_ptr})
+ If defined by a backend this hook allows the decision made to export
+ class @var{type} to be overruled. Upon entry @var{import_export_ptr}
+ will contain 1 if the class is going to be exported, -1 if it is going
+ to be imported and 0 otherwise. This function can change that value,
+ and perform any other actions necessary to support the backend's
+ targeted operating system.
+ @end deftypefn
+
@node Misc
@section Miscellaneous Parameters
@cindex parameters, miscellaneous
Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.723
diff -c -3 -p -r1.723 decl2.c
*** gcc/cp/decl2.c 27 Jun 2004 03:03:55 -0000 1.723
--- gcc/cp/decl2.c 30 Jun 2004 08:32:36 -0000
*************** import_export_class (tree ctype)
*** 1510,1515 ****
--- 1510,1519 ----
import_export = 0;
#endif
+ /* Allow backends the chance to overrule the decision. */
+ if (targetm.cxx.import_export_class)
+ targetm.cxx.import_export_class (ctype, & import_export);
+
if (import_export)
{
SET_CLASSTYPE_INTERFACE_KNOWN (ctype);