* defaults.h (TARGET_PTRMEMFUNC_VBIT_LOCATION): Define.
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 12 May 2001 10:41:21 +0000 (10:41 +0000)
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 12 May 2001 10:41:21 +0000 (10:41 +0000)
* tm.texi (TARGET_PRTMEMFUNC_VBIT_LOCATION): Document.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41989 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/defaults.h
gcc/tm.texi

index cd72d90..748847f 100644 (file)
@@ -1,3 +1,8 @@
+2001-05-12  Alexandre Oliva  <aoliva@redhat.com>
+
+       * defaults.h (TARGET_PTRMEMFUNC_VBIT_LOCATION): Define.
+       * tm.texi (TARGET_PRTMEMFUNC_VBIT_LOCATION): Document.
+
 2001-05-11  Richard Henderson  <rth@redhat.com>
 
        * defaults.h (ASM_PREFERRED_EH_DATA_FORMAT): New.
index 9ec2af1..45fb088 100644 (file)
@@ -325,5 +325,16 @@ do {                                                               \
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  DW_EH_PE_absptr
 #endif
 
+/* By default, the C++ compiler will use the lowest bit of the pointer
+   to function to indicate a pointer-to-member-function points to a
+   virtual member function.  However, if FUNCTION_BOUNDARY indicates
+   function addresses aren't always even, the lowest bit of the delta
+   field will be used.  */
+#ifndef TARGET_PTRMEMFUNC_VBIT_LOCATION
+#define TARGET_PTRMEMFUNC_VBIT_LOCATION \
+  (FUNCTION_BOUNDARY >= 2 * BITS_PER_UNIT \
+   ? ptrmemfunc_vbit_in_pfn : ptrmemfunc_vbit_in_delta)
+#endif
+
 #endif  /* GCC_DEFAULTS_H */
 
index 1a1ad21..8f1c314 100644 (file)
@@ -1451,6 +1451,45 @@ label.
 On certain machines, it is important to have a separate label for each
 selector because this enables the linker to eliminate duplicate selectors.
 
+@findex TARGET_PTRMEMFUNC_VBIT_LOCATION
+@item TARGET_PTRMEMFUNC_VBIT_LOCATION
+The C++ compiler represents a pointer-to-member-function with a struct
+that looks like:
+
+@example
+  struct @{
+    union @{
+      void (*fn)();
+      ptrdiff_t vtable_index;
+    @};
+    ptrdiff_t delta;
+  @};
+@end example
+
+@noindent
+The C++ compiler must use one bit to indicate whether the function that
+will be called through a pointer-to-member-function is virtual.
+Normally, we assume that the low-order bit of a function pointer must
+always be zero.  Then, by ensuring that the vtable_index is odd, we can
+distinguish which variant of the union is in use.  But, on some
+platforms function pointers can be odd, and so this doesn't work.  In
+that case, we use the low-order bit of the @code{delta} field, and shift
+the remainder of the @code{delta} field to the left.
+
+GCC will automatically make the right selection about where to store
+this bit using the @code{FUNCTION_BOUNDARY} setting for your platform.
+However, some platforms such as ARM/Thumb have @code{FUNCTION_BOUNDARY}
+set such that functions always start at even addresses, but the lowest
+bit of pointers to functions indicate whether the function at that
+address is in ARM or Thumb mode.  If this is the case of your
+architecture, you should define this macro to
+@code{ptrmemfunc_vbit_in_delta}.
+
+In general, you should not have to define this macro.  On architectures
+in which function addresses are always even, according to
+@code{FUNCTION_BOUNDARY}, GCC will automatically define this macro to
+@code{ptrmemfunc_vbit_in_pfn}.
+
 @findex TARGET_BELL
 @item TARGET_BELL
 A C constant expression for the integer value for escape sequence