[named-address-spaces-branch][Patch,committed] TYPE_PRECISION changes for named-address-spaces

Michael Meissner meissner@linux.vnet.ibm.com
Wed Dec 3 22:22:00 GMT 2008


I checked in the following to get TYPE_PRECISION correct for OFFSET_TYPE:

2008-12-03  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* stor-layout.c (layout_type): Initialize TYPE_PRECISION for
	OFFSET_TYPE.

	* tree.c (signed_or_unsigned_type_for): Add support for pointers
	to named address spaces.
	(int_or_pointer_precision): Add asserts to make sure
	TYPE_PRECISION is correct for POINTER_TYPE, OFFSET_TYPE, and
	REFERENCE_TYPE.

Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 142410)
+++ gcc/tree.c	(working copy)
@@ -8334,7 +8334,19 @@ signed_or_unsigned_type_for (int unsigne
 {
   tree t = type;
   if (POINTER_TYPE_P (type))
-    t = size_type_node;
+    {
+      /* If the pointer points to the normal address space, use the
+	 size_type_node.  Otherwise use an appropriate size for the pointer
+	 based on the named address space it points to.  */
+      if (!TYPE_ADDR_SPACE (TREE_TYPE (t)))
+	t = size_type_node;
+
+      else
+	{
+	  int prec = int_or_pointer_precision (t);
+	  return lang_hooks.types.type_for_size (prec, unsignedp);
+	}
+    }
 
   if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
     return t;
@@ -9232,9 +9244,14 @@ int_or_pointer_precision (const_tree typ
 	prec = POINTER_SIZE;
       else
 	prec = GET_MODE_BITSIZE (targetm.addr_space.pointer_mode (as));
+
+      gcc_assert (prec == TYPE_PRECISION (type));
     }
   else if (TREE_CODE (type) == OFFSET_TYPE)
-    prec = POINTER_SIZE;
+    {
+      prec = POINTER_SIZE;
+      gcc_assert (prec == POINTER_SIZE);
+    }
   else
     prec = TYPE_PRECISION (type);
 
Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c	(revision 142410)
+++ gcc/stor-layout.c	(working copy)
@@ -1681,6 +1681,7 @@ layout_type (tree type)
       /* A pointer might be MODE_PARTIAL_INT,
 	 but ptrdiff_t must be integral.  */
       TYPE_MODE (type) = mode_for_size (POINTER_SIZE, MODE_INT, 0);
+      TYPE_PRECISION (type) = POINTER_SIZE;
       break;
 
     case FUNCTION_TYPE:

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com



More information about the Gcc-patches mailing list