Updated: RFA: partially hookize POINTER_SIZE
diff mbox

Message ID 20110626080845.bgietnj74scswoog-nzlynne@webmail.spamcop.net
State New
Headers show

Commit Message

Joern Rennecke June 26, 2011, 12:08 p.m. UTC
This is basically the same patch as posted before in
http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02772.html and updated in
http://gcc.gnu.org/viewcvs?view=revision&revision=168273, but with a
few merge conflicts in current mainline resolved.

Re-tested natively with a bootstrap & regtest on gcc20, and
cross-configurations with the contrib/config-list.mk makefile.
Configurations that could not be tested because they are currently broken
in mainline (PR47093) are:
arm-freebsd6 arm-wince-pe i686-interix3 --enable-obsolete i686-openbsd3.0 i686-pc-msdosdjgpp i686-wrs-vxworksae lm32-elf lm32-rtems lm32-uclinux mep-elf microblaze-elf microblaze-linux mips-openbsd powerpc-wrs-vxworksae rs6000-ibm-aix5.2.0 rs6000-ibm-aix5.3.0 rs6000-ibm-aix6.0 score-elf --enable-obsolete vax-openbsd x86_64-knetbsd-gnu

2011-06-26  Joern Rennecke  <joern.rennecke@embecosm.com>

	PR other/46677
gcc:
	* targhooks.c (pointer_size): New function.
	* cppbuiltin.c (define_builtin_macros_for_lp64): Use pointer_size.
	(define_builtin_macros_for_type_sizes): Likewise.
	* target.h (pointer_size): Declare.

	* cppbuiltin.c (define_builtin_macros_for_type_sizes):
	Use TYPE_PRECISION (char_type_node).
gcc/c-family:
	c-common.c (c_common_nodes_and_builtins): Use pointer_size.
gcc/java:
	* java-tree.h (JAVA_POINTER_SIZE): Define.
	* class.c (make_class_data): Use JAVA_POINTER_SIZE.
	(emit_register_classes): Likewise.
	* jcf-parse.c (handle_long_constant): Likewise.
	* constants.c (build_constants_constructor): Likewise.
	* builtins.c (UNMARSHAL3, UNMARSHAL4, UNMARSHAL5): Likewise.
	(compareAndSwapObject_builtin): Likewise.
	* boehm.c (get_boehm_type_descriptor): Likewise.
	(mark_reference_fields): Add log2_size parameter.  Changed all callers.
gcc/cp:
	* cvt.c (cp_convert_to_pointer): Use TYPE_PRECISION (ptr_type_node).
gcc/fortran:
	* trans-types.c (gfc_init_kinds): Use pointer_size.
gcc/lto:
	* lto-object.c (lto_obj_begin_section): Use pointer_size.
ada:
	* gcc-interface/decl.c (gnat_to_gnu_entity): Replace pointer_size
	with pointer_size_t.  Replace POINTER_SIZE with pointer_size ().
	(gnat_to_gnu_param): Use pointer_size.
	(annotate_rep, make_type_from_size): Likewise.
	* gcc-interface/utils.c (finish_fat_pointer_type): Likewise.
	* gcc-interface/utils2.c: Include target.h .
	(maybe_wrap_malloc, maybe_wrap_free): Use pointer_size.
	* gcc-interface/targtyps.c: Include target.h .
	(get_target_pointer_size): Use pointer_size.

Comments

Joseph Myers June 26, 2011, 2:47 p.m. UTC | #1
The cppbuiltin.c and c-common.c changes are OK.  I'm not sure what the 
best approach is for a proper hook conversion of POINTER_SIZE, but I don't 
think this patch makes things any worse.  (The things that need 
considering together in a hook conversion are how the modes for both Pmode 
and ptr_mode are defined, as well as the POINTER_SIZE macro - and I'm not 
sure why Pmode is a macro but ptr_mode a global variable.  I suspect it 
should be necessary to define just the two modes and not a separate 
POINTER_SIZE, but this may be one of the trickier and riskier hook 
conversions, and a wrapper pointer_size function, such as in this patch, 
probably does make sense for use in front-end code rather than front ends 
using the modes and target hooks directly.  Maybe things should be turned 
around so that the pointer_mode and address_mode hooks are what are used 
to define ptr_mode and Pmode, rather than being defined in terms of those 
modes.)
Tom Tromey June 28, 2011, 7:01 p.m. UTC | #2
>>>>> "Joern" == Joern Rennecke <amylaar@spamcop.net> writes:

Joern> This is basically the same patch as posted before in
Joern> http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02772.html and updated in
Joern> http://gcc.gnu.org/viewcvs?view=revision&revision=168273, but with a
Joern> few merge conflicts in current mainline resolved.

Joern> 	* java-tree.h (JAVA_POINTER_SIZE): Define.
Joern> 	* class.c (make_class_data): Use JAVA_POINTER_SIZE.
Joern> 	(emit_register_classes): Likewise.
Joern> 	* jcf-parse.c (handle_long_constant): Likewise.
Joern> 	* constants.c (build_constants_constructor): Likewise.
Joern> 	* builtins.c (UNMARSHAL3, UNMARSHAL4, UNMARSHAL5): Likewise.
Joern> 	(compareAndSwapObject_builtin): Likewise.
Joern> 	* boehm.c (get_boehm_type_descriptor): Likewise.
Joern> 	(mark_reference_fields): Add log2_size parameter.  Changed all callers.
Joern> gcc/cp:

One question about the Java parts...

Joern> -	  if (offset % (HOST_WIDE_INT) (POINTER_SIZE / BITS_PER_UNIT))
Joern> +	  if (offset & ((1 << log2_size) - 1))

I think this has to be '(((HOST_WIDE_INT) 1) << log2_size) - 1'.
Otherwise it seems like this could overflow.

The rest of the java parts are ok.

Tom

Patch
diff mbox

Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c	(revision 175397)
+++ gcc/targhooks.c	(working copy)
@@ -1441,4 +1441,23 @@  default_pch_valid_p (const void *data_p,
   return NULL;
 }
 
+/* Return the size of a pointer.  This function might be used when
+   ptr_type_node is not / is not known to be set up, like in the
+   preprocessor.  */
+unsigned
+pointer_size (void)
+{
+  enum machine_mode
+    mode = targetm.addr_space.pointer_mode (ADDR_SPACE_GENERIC);
+
+  /* If the hook definition uses ptr_mode, and we are called before
+     init_emit_once, e.g. from the preprocessor, we might see VOIDmode.  */
+  if (mode == VOIDmode)
+    {
+      gcc_assert (mode == ptr_mode);
+      return POINTER_SIZE;
+    }
+  return GET_MODE_BITSIZE (mode);
+}
+
 #include "gt-targhooks.h"
Index: gcc/cppbuiltin.c
===================================================================
--- gcc/cppbuiltin.c	(revision 175397)
+++ gcc/cppbuiltin.c	(working copy)
@@ -105,7 +105,7 @@  define_builtin_macros_for_compilation_fl
 define_builtin_macros_for_lp64 (cpp_reader *pfile)
 {
   if (TYPE_PRECISION (long_integer_type_node) == 64
-      && POINTER_SIZE == 64
+      && pointer_size () == 64
       && TYPE_PRECISION (integer_type_node) == 32)
     {
       cpp_define (pfile, "_LP64");
@@ -163,9 +163,13 @@  #define define_type_sizeof(NAME, TYPE)
                          : "__ORDER_LITTLE_ENDIAN__"));
 
   /* ptr_type_node can't be used here since ptr_mode is only set when
-     toplev calls backend_init which is not done with -E switch.  */
+     toplev calls backend_init which is not done with -E switch.
+     In principle we could use
+     targetm.addr_space.pointer_mode (ADDR_SPACE_GENERIC), but we don't really
+     want the prepocessor to have to know about machine modes, and most
+     definitions of the hook also use ptr_mode.  */
   cpp_define_formatted (pfile, "__SIZEOF_POINTER__=%d",
-			POINTER_SIZE / BITS_PER_UNIT);
+			pointer_size () / TYPE_PRECISION (char_type_node));
 }
 
 
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c	(revision 175397)
+++ gcc/c-family/c-common.c	(working copy)
@@ -5000,7 +5000,7 @@  c_common_nodes_and_builtins (void)
   /* Create the built-in __null node.  It is important that this is
      not shared.  */
   null_node = make_node (INTEGER_CST);
-  TREE_TYPE (null_node) = c_common_type_for_size (POINTER_SIZE, 0);
+  TREE_TYPE (null_node) = c_common_type_for_size (pointer_size (), 0);
 
   /* Since builtin_types isn't gc'ed, don't export these nodes.  */
   memset (builtin_types, 0, sizeof (builtin_types));
Index: gcc/java/class.c
===================================================================
--- gcc/java/class.c	(revision 175397)
+++ gcc/java/class.c	(working copy)
@@ -1787,7 +1787,7 @@  make_class_data (tree type)
   tree id_class = get_identifier("java.lang.Class");
   /** Offset from start of virtual function table declaration
       to where objects actually point at, following new g++ ABI. */
-  tree dtable_start_offset = size_int (2 * POINTER_SIZE / BITS_PER_UNIT);
+  tree dtable_start_offset = size_int (2 * JAVA_POINTER_SIZE / BITS_PER_UNIT);
   VEC(int, heap) *field_indexes;
   tree first_real_field;
   VEC(constructor_elt,gc) *v1 = NULL, *v2 = NULL;
@@ -2228,7 +2228,7 @@  make_class_data (tree type)
   DECL_INITIAL (decl) = cons;
   
   /* Hash synchronization requires at least 64-bit alignment. */
-  if (flag_hash_synchronization && POINTER_SIZE < 64)
+  if (flag_hash_synchronization && JAVA_POINTER_SIZE < 64)
     DECL_ALIGN (decl) = 64; 
   
   if (flag_indirect_classes)
@@ -2825,12 +2825,13 @@  emit_register_classes (tree *list_p)
 	 but doesn't have a JCR_SECTION_NAME.  */
       gcc_unreachable ();
 #endif
-      assemble_align (POINTER_SIZE);
+      assemble_align (JAVA_POINTER_SIZE);
 
       FOR_EACH_VEC_ELT (tree, registered_class, i, klass)
 	{
 	  t = build_fold_addr_expr (klass);
-	  output_constant (t, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE);
+	  output_constant (t, JAVA_POINTER_SIZE / BITS_PER_UNIT,
+			   JAVA_POINTER_SIZE);
 	}
     }
   else
Index: gcc/java/jcf-parse.c
===================================================================
--- gcc/java/jcf-parse.c	(revision 175397)
+++ gcc/java/jcf-parse.c	(working copy)
@@ -473,7 +473,7 @@  handle_long_constant (JCF *jcf, CPool *c
 {
   /* If we're on a 64-bit platform we can fit a long or double
      into the same space as a jword.  */
-  if (POINTER_SIZE >= 64)
+  if (JAVA_POINTER_SIZE >= 64)
     index = find_constant1 (cpool, kind, JPOOL_LONG (jcf, index));
 
   /* In a compiled program the constant pool is in native word
Index: gcc/java/constants.c
===================================================================
--- gcc/java/constants.c	(revision 175397)
+++ gcc/java/constants.c	(working copy)
@@ -541,7 +541,7 @@  build_constants_constructor (void)
 	     not a scalar but a union, and that's how we should
 	     represent it in the compiler.  We should fix this.  */
 	  if (BYTES_BIG_ENDIAN)
-	    temp <<= ((POINTER_SIZE > 32) ? POINTER_SIZE - 32 : 0);
+	    temp <<= ((JAVA_POINTER_SIZE > 32) ? JAVA_POINTER_SIZE - 32 : 0);
 
           CONSTRUCTOR_PREPEND_VALUE (t, get_tag_node (outgoing_cpool->tags[i]));
           CONSTRUCTOR_PREPEND_VALUE (d, build_int_cst (ptr_type_node, temp));
Index: gcc/java/builtins.c
===================================================================
--- gcc/java/builtins.c	(revision 175397)
+++ gcc/java/builtins.c	(working copy)
@@ -243,7 +243,7 @@  #define UNMARSHAL3(METHOD_CALL)					\
   tree orig_method_call = METHOD_CALL;					\
   this_arg = CALL_EXPR_ARG (orig_method_call, 0);			\
   obj_arg = CALL_EXPR_ARG (orig_method_call, 1);			\
-  offset_arg = fold_convert (java_type_for_size (POINTER_SIZE, 0),	\
+  offset_arg = fold_convert (java_type_for_size (JAVA_POINTER_SIZE, 0),	\
 			     CALL_EXPR_ARG (orig_method_call, 2));	\
 }									\
 while (0)
@@ -255,7 +255,7 @@  #define UNMARSHAL4(METHOD_CALL)					\
   tree orig_method_call = METHOD_CALL;					\
   this_arg = CALL_EXPR_ARG (orig_method_call, 0);			\
   obj_arg = CALL_EXPR_ARG (orig_method_call, 1);			\
-  offset_arg = fold_convert (java_type_for_size (POINTER_SIZE, 0),	\
+  offset_arg = fold_convert (java_type_for_size (JAVA_POINTER_SIZE, 0),	\
 			     CALL_EXPR_ARG (orig_method_call, 2));	\
   value_arg = CALL_EXPR_ARG (orig_method_call, 3);			\
   value_type = TREE_TYPE (value_arg);					\
@@ -269,7 +269,7 @@  #define UNMARSHAL5(METHOD_CALL)					\
   tree orig_method_call = METHOD_CALL;					\
   this_arg = CALL_EXPR_ARG (orig_method_call, 0);			\
   obj_arg = CALL_EXPR_ARG (orig_method_call, 1);			\
-  offset_arg = fold_convert (java_type_for_size (POINTER_SIZE, 0),	\
+  offset_arg = fold_convert (java_type_for_size (JAVA_POINTER_SIZE, 0),	\
 			     CALL_EXPR_ARG (orig_method_call, 2));	\
   expected_arg = CALL_EXPR_ARG (orig_method_call, 3);			\
   value_arg = CALL_EXPR_ARG (orig_method_call, 4);			\
@@ -379,7 +379,7 @@  compareAndSwapObject_builtin (tree metho
     int builtin;
 
     UNMARSHAL5 (orig_call);
-    builtin = (POINTER_SIZE == 32 
+    builtin = (JAVA_POINTER_SIZE == 32 
 	       ? BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_4 
 	       : BUILT_IN_SYNC_BOOL_COMPARE_AND_SWAP_8);
 
Index: gcc/java/java-tree.h
===================================================================
--- gcc/java/java-tree.h	(revision 175397)
+++ gcc/java/java-tree.h	(working copy)
@@ -1516,4 +1516,12 @@  extern int java_gimplify_expr (tree *, g
 
 extern FILE *finput;
 
+/* Frontends shouldn't use POINTER_SIZE, since that is a target macro.
+   We can't use TYPE_PRECISION (ptr_type_node), since that node isn't
+   available for java.
+   Luckily, sizetype is set with the precision of pointer_size (),
+   so we don't have to call pointer_size all the time once sizetype
+   has been set up.  */
+#define JAVA_POINTER_SIZE (TYPE_PRECISION (sizetype))
+
 #endif /* ! GCC_JAVA_TREE_H */
Index: gcc/java/boehm.c
===================================================================
--- gcc/java/boehm.c	(revision 175397)
+++ gcc/java/boehm.c	(working copy)
@@ -35,7 +35,8 @@  the Free Software Foundation; either ver
 #include "diagnostic-core.h"
 
 static void mark_reference_fields (tree, double_int *, unsigned int,
-				   int *, int *, int *, HOST_WIDE_INT *);
+				   int *, int *, int *, HOST_WIDE_INT *,
+				   unsigned int);
 
 /* A procedure-based object descriptor.  We know that our
    `kind' is 0, and `env' is likewise 0, so we have a simple
@@ -53,7 +54,8 @@  mark_reference_fields (tree field,
 		       int *pointer_after_end,
 		       int *all_bits_set,
 		       int *last_set_index,
-		       HOST_WIDE_INT *last_view_index)
+		       HOST_WIDE_INT *last_view_index,
+		       unsigned int log2_size)
 {
   /* See if we have fields from our superclass.  */
   if (DECL_NAME (field) == NULL_TREE)
@@ -61,7 +63,7 @@  mark_reference_fields (tree field,
       mark_reference_fields (TYPE_FIELDS (TREE_TYPE (field)),
 			     mask, ubit,
 			     pointer_after_end, all_bits_set,
-			     last_set_index, last_view_index);
+			     last_set_index, last_view_index, log2_size);
       field = DECL_CHAIN (field);
     }
 
@@ -89,15 +91,15 @@  mark_reference_fields (tree field,
 	     we already covered, then we are doomed.  */
 	  gcc_assert (offset > *last_view_index);
 
-	  if (offset % (HOST_WIDE_INT) (POINTER_SIZE / BITS_PER_UNIT))
+	  if (offset & ((1 << log2_size) - 1))
 	    {
 	      *all_bits_set = -1;
 	      *pointer_after_end = 1;
 	      break;
 	    }
 
-	  count = offset * BITS_PER_UNIT / POINTER_SIZE;
-	  size_words = size_bytes * BITS_PER_UNIT / POINTER_SIZE;
+	  count = offset >> log2_size;
+	  size_words = size_bytes >> log2_size;
 
 	  *last_set_index = count;
 	     
@@ -151,7 +153,7 @@  get_boehm_type_descriptor (tree type)
   if (int_size_in_bytes (type) == -1)
     goto procedure_object_descriptor;
 
-  bit = POINTER_SIZE / BITS_PER_UNIT;
+  bit = JAVA_POINTER_SIZE / BITS_PER_UNIT;
   /* The size of this node has to be known.  And, we only support 32
      and 64 bit targets, so we need to know that the log2 is one of
      our values.  */
@@ -174,7 +176,7 @@  get_boehm_type_descriptor (tree type)
   field = TYPE_FIELDS (type);
   mark_reference_fields (field, &mask, ubit,
 			 &pointer_after_end, &all_bits_set,
-			 &last_set_index, &last_view_index);
+			 &last_set_index, &last_view_index, log2_size);
 
   /* If the object is all pointers, or if the part with pointers fits
      in our bitmap, then we are ok.  Otherwise we have to allocate it
Index: gcc/target.h
===================================================================
--- gcc/target.h	(revision 175397)
+++ gcc/target.h	(working copy)
@@ -185,4 +185,8 @@  pack_cumulative_args (CUMULATIVE_ARGS *a
 }
 #endif /* GCC_TM_H */
 
+/* Functions defined in targhooks.c that use target hooks and/or target
+   macros that make these values available to frontends / tree optimizers.  */
+extern unsigned pointer_size (void);
+
 #endif /* GCC_TARGET_H */

Index: gcc/cp/cvt.c
===================================================================
--- gcc/cp/cvt.c	(revision 175397)
+++ gcc/cp/cvt.c	(working copy)
@@ -220,9 +220,12 @@  cp_convert_to_pointer (tree type, tree e
 
   if (INTEGRAL_CODE_P (form))
     {
-      if (TYPE_PRECISION (intype) == POINTER_SIZE)
+      if (TYPE_PRECISION (intype) == TYPE_PRECISION (ptr_type_node))
 	return build1 (CONVERT_EXPR, type, expr);
-      expr = cp_convert (c_common_type_for_size (POINTER_SIZE, 0), expr);
+      expr
+	= cp_convert (c_common_type_for_size (TYPE_PRECISION (ptr_type_node),
+							      0),
+		      expr);
       /* Modes may be different but sizes should be the same.  There
 	 is supposed to be some integral type that is the same width
 	 as a pointer.  */
Index: gcc/ada/gcc-interface/utils.c
===================================================================
--- gcc/ada/gcc-interface/utils.c	(revision 175397)
+++ gcc/ada/gcc-interface/utils.c	(working copy)
@@ -627,7 +627,7 @@  record_builtin_type (const char *name, t
 finish_fat_pointer_type (tree record_type, tree field_list)
 {
   /* Make sure we can put it into a register.  */
-  TYPE_ALIGN (record_type) = MIN (BIGGEST_ALIGNMENT, 2 * POINTER_SIZE);
+  TYPE_ALIGN (record_type) = MIN (BIGGEST_ALIGNMENT, 2 * pointer_size ());
 
   /* Show what it really is.  */
   TYPE_FAT_POINTER_P (record_type) = 1;
Index: gcc/ada/gcc-interface/decl.c
===================================================================
--- gcc/ada/gcc-interface/decl.c	(revision 175397)
+++ gcc/ada/gcc-interface/decl.c	(working copy)
@@ -399,7 +399,7 @@  gnat_to_gnu_entity (Entity_Id gnat_entit
 	  if (IN (kind, Float_Kind))
 	    max_esize = fp_prec_to_size (LONG_DOUBLE_TYPE_SIZE);
 	  else if (IN (kind, Access_Kind))
-	    max_esize = POINTER_SIZE * 2;
+	    max_esize = pointer_size () * 2;
 	  else
 	    max_esize = LONG_LONG_TYPE_SIZE;
 
@@ -3742,7 +3742,7 @@  gnat_to_gnu_entity (Entity_Id gnat_entit
 	    if (TYPE_IS_FAT_POINTER_P (gnu_type))
 	      {
 		gnu_old_desig_type = TYPE_UNCONSTRAINED_ARRAY (gnu_type);
-		if (esize == POINTER_SIZE)
+		if (esize == pointer_size ())
 		  gnu_type = build_pointer_type
 			     (TYPE_OBJECT_RECORD_TYPE (gnu_old_desig_type));
 	      }
@@ -4897,7 +4897,7 @@  gnat_to_gnu_entity (Entity_Id gnat_entit
 	    {
 	      /* In this mode, the tag and the parent components are not
 		 generated by the front-end so the sizes must be adjusted.  */
-	      tree pointer_size = bitsize_int (POINTER_SIZE), offset;
+	      tree pointer_size_t = bitsize_int (pointer_size ()), offset;
 	      Uint uint_size;
 
 	      if (Is_Derived_Type (gnat_entity))
@@ -4908,13 +4908,13 @@  gnat_to_gnu_entity (Entity_Id gnat_entit
 				 Alignment (Etype (Base_Type (gnat_entity))));
 		}
 	      else
-		offset = pointer_size;
+		offset = pointer_size_t;
 
 	      gnu_size = size_binop (PLUS_EXPR, gnu_size, offset);
-	      gnu_size = size_binop (MULT_EXPR, pointer_size,
+	      gnu_size = size_binop (MULT_EXPR, pointer_size_t,
 						size_binop (CEIL_DIV_EXPR,
 							    gnu_size,
-							    pointer_size));
+							    pointer_size_t));
 	      uint_size = annotate_value (gnu_size);
 	      Set_Esize (gnat_entity, uint_size);
 	      Set_RM_Size (gnat_entity, uint_size);
@@ -5425,7 +5425,7 @@  gnat_to_gnu_param (Entity_Id gnat_param,
   /* Fat pointers are passed as thin pointers for foreign conventions.  */
   else if (foreign && TYPE_IS_FAT_POINTER_P (gnu_param_type))
     gnu_param_type
-      = make_type_from_size (gnu_param_type, size_int (POINTER_SIZE), 0);
+      = make_type_from_size (gnu_param_type, size_int (pointer_size ()), 0);
 
   /* If we must pass or were requested to pass by reference, do so.
      If we were requested to pass by copy, do so.
@@ -7644,7 +7644,7 @@  annotate_rep (Entity_Id gnat_entity, tre
 		    = UI_To_gnu (Esize (Etype (Base_Type (gnat_entity))),
 				 bitsizetype);
 		else
-		  parent_offset = bitsize_int (POINTER_SIZE);
+		  parent_offset = bitsize_int (pointer_size ());
 	      }
 	    else
 	      parent_offset = bitsize_zero_node;
@@ -8082,7 +8082,7 @@  make_type_from_size (tree type, tree siz
     case RECORD_TYPE:
       /* Do something if this is a fat pointer, in which case we
 	 may need to return the thin pointer.  */
-      if (TYPE_FAT_POINTER_P (type) && size < POINTER_SIZE * 2)
+      if (TYPE_FAT_POINTER_P (type) && size < pointer_size () * 2)
 	{
 	  enum machine_mode p_mode = mode_for_size (size, MODE_INT, 0);
 	  if (!targetm.valid_pointer_mode (p_mode))
@@ -8097,7 +8097,7 @@  make_type_from_size (tree type, tree siz
     case POINTER_TYPE:
       /* Only do something if this is a thin pointer, in which case we
 	 may need to return the fat pointer.  */
-      if (TYPE_IS_THIN_POINTER_P (type) && size >= POINTER_SIZE * 2)
+      if (TYPE_IS_THIN_POINTER_P (type) && size >= pointer_size () * 2)
 	return
 	  build_pointer_type (TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type)));
       break;
Index: gcc/ada/gcc-interface/targtyps.c
===================================================================
--- gcc/ada/gcc-interface/targtyps.c	(revision 175397)
+++ gcc/ada/gcc-interface/targtyps.c	(working copy)
@@ -31,6 +31,7 @@ 
 #include "tree.h"
 #include "tm.h"
 #include "tm_p.h"
+#include "target.h"
 
 #include "ada.h"
 #include "types.h"
@@ -131,7 +132,7 @@  get_target_long_double_size (void)
 Pos
 get_target_pointer_size (void)
 {
-  return POINTER_SIZE;
+  return pointer_size ();
 }
 
 /* Alignment related values, mapped to attributes for functional and
Index: gcc/ada/gcc-interface/utils2.c
===================================================================
--- gcc/ada/gcc-interface/utils2.c	(revision 175397)
+++ gcc/ada/gcc-interface/utils2.c	(working copy)
@@ -32,6 +32,7 @@ 
 #include "ggc.h"
 #include "output.h"
 #include "tree-inline.h"
+#include "target.h"
 
 #include "ada.h"
 #include "types.h"
@@ -1956,7 +1957,7 @@  maybe_wrap_malloc (tree data_size, tree
     = ((data_align > default_allocator_alignment)
        ? make_aligning_type (data_type, data_align, data_size,
 			     default_allocator_alignment,
-			     POINTER_SIZE / BITS_PER_UNIT)
+			     pointer_size () / BITS_PER_UNIT)
        : NULL_TREE);
 
   tree size_to_malloc
@@ -1967,7 +1968,7 @@  maybe_wrap_malloc (tree data_size, tree
   /* On VMS, if pointers are 64-bit and the allocator size is 32-bit or
      Convention C, allocate 32-bit memory.  */
   if (TARGET_ABI_OPEN_VMS
-      && POINTER_SIZE == 64
+      && pointer_size () == 64
       && Nkind (gnat_node) == N_Allocator
       && (UI_To_Int (Esize (Etype (gnat_node))) == 32
           || Convention (Etype (gnat_node)) == Convention_C))
@@ -1999,7 +2000,7 @@  maybe_wrap_malloc (tree data_size, tree
       tree storage_ptr_slot_addr
 	= build_binary_op (POINTER_PLUS_EXPR, ptr_void_type_node,
 			   convert (ptr_void_type_node, aligning_field_addr),
-			   size_int (-(HOST_WIDE_INT) POINTER_SIZE
+			   size_int (-(HOST_WIDE_INT) pointer_size ()
 				     / BITS_PER_UNIT));
 
       tree storage_ptr_slot
@@ -2041,7 +2042,7 @@  maybe_wrap_free (tree data_ptr, tree dat
 	= build_binary_op
 	  (POINTER_PLUS_EXPR, ptr_void_type_node,
 	   convert (ptr_void_type_node, data_ptr),
-	   size_int (-(HOST_WIDE_INT) POINTER_SIZE / BITS_PER_UNIT));
+	   size_int (-(HOST_WIDE_INT) pointer_size () / BITS_PER_UNIT));
 
       /* FREE_PTR (void *) = *(void **)DATA_FRONT_PTR  */
       free_ptr
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c	(revision 175397)
+++ gcc/fortran/trans-types.c	(working copy)
@@ -576,7 +576,7 @@  gfc_init_kinds (void)
   gfc_character_storage_size = gfc_default_character_kind * 8;
 
   /* Choose the integer kind the same size as "void*" for our index kind.  */
-  gfc_index_integer_kind = POINTER_SIZE / 8;
+  gfc_index_integer_kind = pointer_size () / 8;
   /* Pick a kind the same size as the C "int" type.  */
   gfc_c_int_kind = INT_TYPE_SIZE / 8;
 
Index: gcc/lto/lto-object.c
===================================================================
--- gcc/lto/lto-object.c	(revision 175397)
+++ gcc/lto/lto-object.c	(working copy)
@@ -317,7 +317,7 @@  lto_obj_begin_section (const char *name)
 	      && lo->sobj_w != NULL
 	      && lo->section == NULL);
 
-  align = exact_log2 (POINTER_SIZE / BITS_PER_UNIT);
+  align = exact_log2 (pointer_size () / BITS_PER_UNIT);
   lo->section = simple_object_write_create_section (lo->sobj_w, name, align,
 						    &errmsg, &err);
   if (lo->section == NULL)