public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] remove the unsigned_type language hook
@ 2007-05-03  9:42 Rafael Espindola
  2007-05-08 10:30 ` Eric Botcazou
                   ` (3 more replies)
  0 siblings, 4 replies; 36+ messages in thread
From: Rafael Espindola @ 2007-05-03  9:42 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2380 bytes --]

The attached patch removes the remaining parts of the unsigned_type
language hook. It depends on my previous patch that adds a default
implementation.

Compiled and regression tested with all languages (including ada).

OK for trunk?

gcc/ada/ChangeLog
 * gcc/ada/gigi.h (gnat_unsigned_type): Remove.
 * gcc/ada/misc.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.
 * gcc/ada/trans.c (gnat_to_gnu): Use get_unsigned_type instead of
gnat_unsigned_type.
                           (convert_with_check): Likewise.
 * gcc/ada/utils.c (gnat_unsigned_type): Remove.

gcc/ChangeLog
 * gcc/c-common.c (warnings_for_convert_and_check): Use
get_unsigned_type instead of c_common_unsigned_type
                            (c_common_unsigned_type): Remove.
                            (shorten_compare): Use
c_common_signed_or_unsigned_type instead of c_common_unsigned_type.
                           (c_common_nodes_and_builtins): Use
get_unsigned_type instead of c_common_unsigned_type.
 * gcc/c-common.h (c_common_unsigned_type): Remove.
 * gcc/c-decl.c (grokdeclarator): Use c_common_unsigned_type instead
of get_unsigned_type.
 * gcc/c-format.c (check_format_types): Likewise.
 * gcc/c-objc-common.h (LANG_HOOKS_UNSIGNED_TYPE): Remove.
 * gcc/c-typeck.c (convert_for_assignment): Use get_unsigned_type
instead of c_common_unsigned_type.
 * gcc/convert.c (convert_to_integer): Likewise.
 * gcc/expmed.c (make_tree): Use get_unsigned_type instead of
lang_hooks.types.unsigned_type.
 * gcc/fold-const.c (fold_negate_expr): Likewise.
                           (build_range_check): Likewise.
                           (fold_unary): Likewise.
                           (fold_binary): Likewise.
                           (fold_ternary): Likewise.
 * gcc/langhooks-def.h (LANG_HOOKS_UNSIGNED_TYPE): Remove.
                                 (LANG_HOOKS_FOR_TYPES_INITIALIZER):
Remove LANG_HOOKS_UNSIGNED_TYPE.
 * gcc/langhooks.h (lang_hooks_for_types): Remove unsigned_type
 * gcc/tree.c (unsigned_type_for): Use get_unsigned_type instead of
lang_hooks.types.unsigned_type

gcc/cp/ChangeLog
 * gcc/cp/cp-objcp-common.h (LANG_HOOKS_UNSIGNED_TYPE): Remove.
 * gcc/cp/decl.c (grokdeclarator): Replace c_common_unsigned_type with
get_unsigned_type.

-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

[-- Attachment #2: gcc-unsigned-type.patch --]
[-- Type: text/x-patch, Size: 15105 bytes --]

=== gcc/ada/gigi.h
==================================================================
--- gcc/ada/gigi.h	(revision 124112)
+++ gcc/ada/gigi.h	(local)
@@ -448,9 +448,6 @@
 /* Emit debug info for all global variable declarations.  */
 extern void gnat_write_global_declarations (void);
 
-/* Return the unsigned version of a TYPE_NODE, a scalar type.  */
-extern tree gnat_unsigned_type (tree type_node);
-
 /* Return the signed version of a TYPE_NODE, a scalar type.  */
 extern tree gnat_signed_type (tree type_node);
 
=== gcc/ada/misc.c
==================================================================
--- gcc/ada/misc.c	(revision 124112)
+++ gcc/ada/misc.c	(local)
@@ -159,8 +159,6 @@
 #define LANG_HOOKS_TYPE_FOR_SIZE	gnat_type_for_size
 #undef  LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE		gnat_signed_type
-#undef  LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE	gnat_unsigned_type
 #undef  LANG_HOOKS_ATTRIBUTE_TABLE
 #define LANG_HOOKS_ATTRIBUTE_TABLE	gnat_internal_attribute_table
 #undef  LANG_HOOKS_BUILTIN_FUNCTION
=== gcc/ada/trans.c
==================================================================
--- gcc/ada/trans.c	(revision 124112)
+++ gcc/ada/trans.c	(local)
@@ -3484,7 +3484,7 @@
 	if (Nkind (gnat_node) == N_Op_Shift_Right
 	    && !TYPE_UNSIGNED (gnu_type))
 	  {
-	    gnu_type = gnat_unsigned_type (gnu_type);
+	    gnu_type = get_unsigned_type (gnu_type);
 	    ignore_lhs_overflow = true;
 	  }
 	else if (Nkind (gnat_node) == N_Op_Shift_Right_Arithmetic
@@ -5538,13 +5538,13 @@
 
       if (INTEGRAL_TYPE_P (gnu_in_basetype)
 	  && !TYPE_UNSIGNED (gnu_in_basetype))
-	gnu_in_ub = convert (gnat_unsigned_type (gnu_in_basetype), gnu_in_ub);
+	gnu_in_ub = convert (get_unsigned_type (gnu_in_basetype), gnu_in_ub);
 
       if (INTEGRAL_TYPE_P (gnu_base_type) && TYPE_UNSIGNED (gnu_base_type))
 	gnu_out_lb = convert (gnat_signed_type (gnu_base_type), gnu_out_lb);
 
       if (INTEGRAL_TYPE_P (gnu_base_type) && !TYPE_UNSIGNED (gnu_base_type))
-	gnu_out_ub = convert (gnat_unsigned_type (gnu_base_type), gnu_out_ub);
+	gnu_out_ub = convert (get_unsigned_type (gnu_base_type), gnu_out_ub);
 
       /* Check each bound separately and only if the result bound
 	 is tighter than the bound on the input type.  Note that all the
=== gcc/ada/utils.c
==================================================================
--- gcc/ada/utils.c	(revision 124112)
+++ gcc/ada/utils.c	(local)
@@ -2290,29 +2290,6 @@
     return NULL_TREE;
 }
 
-/* Return the unsigned version of a TYPE_NODE, a scalar type.  */
-
-tree
-gnat_unsigned_type (tree type_node)
-{
-  tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 1);
-
-  if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node))
-    {
-      type = copy_node (type);
-      TREE_TYPE (type) = type_node;
-    }
-  else if (TREE_TYPE (type_node)
-	   && TREE_CODE (TREE_TYPE (type_node)) == INTEGER_TYPE
-	   && TYPE_MODULAR_P (TREE_TYPE (type_node)))
-    {
-      type = copy_node (type);
-      TREE_TYPE (type) = TREE_TYPE (type_node);
-    }
-
-  return type;
-}
-
 /* Return the signed version of a TYPE_NODE, a scalar type.  */
 
 tree
=== gcc/c-common.c
==================================================================
--- gcc/c-common.c	(revision 124112)
+++ gcc/c-common.c	(local)
@@ -1303,7 +1303,7 @@
           else if (warn_conversion)
             conversion_warning (type, expr);
         }
-      else if (!int_fits_type_p (expr, c_common_unsigned_type (type))) 
+      else if (!int_fits_type_p (expr, get_unsigned_type (type))) 
 	warning (OPT_Woverflow,
 		 "overflow in implicit constant conversion");
       /* No warning for converting 0x80000000 to int.  */
@@ -1998,39 +1998,6 @@
   return 0;
 }
 
-/* Return an unsigned type the same as TYPE in other respects.  */
-tree
-c_common_unsigned_type (tree type)
-{
-  tree type1 = TYPE_MAIN_VARIANT (type);
-  if (type1 == signed_char_type_node || type1 == char_type_node)
-    return unsigned_char_type_node;
-  if (type1 == integer_type_node)
-    return unsigned_type_node;
-  if (type1 == short_integer_type_node)
-    return short_unsigned_type_node;
-  if (type1 == long_integer_type_node)
-    return long_unsigned_type_node;
-  if (type1 == long_long_integer_type_node)
-    return long_long_unsigned_type_node;
-  if (type1 == widest_integer_literal_type_node)
-    return widest_unsigned_literal_type_node;
-#if HOST_BITS_PER_WIDE_INT >= 64
-  if (type1 == intTI_type_node)
-    return unsigned_intTI_type_node;
-#endif
-  if (type1 == intDI_type_node)
-    return unsigned_intDI_type_node;
-  if (type1 == intSI_type_node)
-    return unsigned_intSI_type_node;
-  if (type1 == intHI_type_node)
-    return unsigned_intHI_type_node;
-  if (type1 == intQI_type_node)
-    return unsigned_intQI_type_node;
-
-  return c_common_signed_or_unsigned_type (1, type);
-}
-
 /* Return a signed type the same as TYPE in other respects.  */
 
 tree
@@ -2473,7 +2440,8 @@
 	      default:
 		break;
 	      }
-	  type = c_common_unsigned_type (type);
+	  /* get_unsigned_type doesn't support C bit fields */
+	  type = c_common_signed_or_unsigned_type (1, type);
 	}
 
       if (TREE_CODE (primop0) != INTEGER_CST)
@@ -3640,7 +3608,7 @@
   else
     {
       signed_wchar_type_node = c_common_signed_type (wchar_type_node);
-      unsigned_wchar_type_node = c_common_unsigned_type (wchar_type_node);
+      unsigned_wchar_type_node = get_unsigned_type (wchar_type_node);
     }
 
   /* This is for wide string constants.  */
@@ -3658,7 +3626,7 @@
   default_function_type = build_function_type (integer_type_node, NULL_TREE);
   ptrdiff_type_node
     = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE)));
-  unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
+  unsigned_ptrdiff_type_node = get_unsigned_type (ptrdiff_type_node);
 
   lang_hooks.decls.pushdecl
     (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
=== gcc/c-common.h
==================================================================
--- gcc/c-common.h	(revision 124112)
+++ gcc/c-common.h	(local)
@@ -665,7 +665,6 @@
 extern bool c_common_missing_argument (const char *opt, size_t code);
 extern tree c_common_type_for_mode (enum machine_mode, int);
 extern tree c_common_type_for_size (unsigned int, int);
-extern tree c_common_unsigned_type (tree);
 extern tree c_common_signed_type (tree);
 extern tree c_common_signed_or_unsigned_type (int, tree);
 extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
=== gcc/c-decl.c
==================================================================
--- gcc/c-decl.c	(revision 124112)
+++ gcc/c-decl.c	(local)
@@ -4086,7 +4086,7 @@
      "signed".  */
   if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
       && TREE_CODE (type) == INTEGER_TYPE)
-    type = c_common_unsigned_type (type);
+    type = get_unsigned_type (type);
 
   /* Figure out the type qualifiers for the declaration.  There are
      two ways a declaration can become qualified.  One is something
=== gcc/c-format.c
==================================================================
--- gcc/c-format.c	(revision 124112)
+++ gcc/c-format.c	(local)
@@ -2249,7 +2249,7 @@
 	  && TREE_CODE (cur_type) == INTEGER_TYPE
 	  && (!pedantic || i == 0 || (i == 1 && char_type_flag))
 	  && (TYPE_UNSIGNED (wanted_type)
-	      ? wanted_type == c_common_unsigned_type (cur_type)
+	      ? wanted_type == get_unsigned_type (cur_type)
 	      : wanted_type == c_common_signed_type (cur_type)))
 	continue;
       /* Likewise, "signed char", "unsigned char" and "char" are
=== gcc/c-objc-common.h
==================================================================
--- gcc/c-objc-common.h	(revision 124112)
+++ gcc/c-objc-common.h	(local)
@@ -104,8 +104,6 @@
 #define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
 #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
=== gcc/c-typeck.c
==================================================================
--- gcc/c-typeck.c	(revision 124112)
+++ gcc/c-typeck.c	(local)
@@ -4080,8 +4080,8 @@
       if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
 	  || (target_cmp = comp_target_types (type, rhstype))
 	  || is_opaque_pointer
-	  || (c_common_unsigned_type (mvl)
-	      == c_common_unsigned_type (mvr)))
+	  || (get_unsigned_type (mvl)
+	      == get_unsigned_type (mvr)))
 	{
 	  if (pedantic
 	      && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
=== gcc/convert.c
==================================================================
--- gcc/convert.c	(revision 124112)
+++ gcc/convert.c	(local)
@@ -656,7 +656,7 @@
 			     || !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1)))
 			    && (ex_form == PLUS_EXPR
 				|| ex_form == MINUS_EXPR)))
-		      typex = lang_hooks.types.unsigned_type (typex);
+		      typex = get_unsigned_type (typex);
 		    else
 		      typex = lang_hooks.types.signed_type (typex);
 		    return convert (type,
@@ -678,7 +678,7 @@
 	    /* Don't do unsigned arithmetic where signed was wanted,
 	       or vice versa.  */
 	    if (TYPE_UNSIGNED (TREE_TYPE (expr)))
-	      typex = lang_hooks.types.unsigned_type (type);
+	      typex = get_unsigned_type (type);
 	    else
 	      typex = lang_hooks.types.signed_type (type);
 	    return convert (type,
=== gcc/cp/cp-objcp-common.h
==================================================================
--- gcc/cp/cp-objcp-common.h	(revision 124112)
+++ gcc/cp/cp-objcp-common.h	(local)
@@ -136,8 +136,6 @@
 #define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
 #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
=== gcc/cp/decl.c
==================================================================
--- gcc/cp/decl.c	(revision 124112)
+++ gcc/cp/decl.c	(local)
@@ -7371,7 +7371,7 @@
       else if (type == char_type_node)
 	type = unsigned_char_type_node;
       else if (typedef_decl)
-	type = c_common_unsigned_type (type);
+	type = get_unsigned_type (type);
       else
 	type = unsigned_type_node;
     }
=== gcc/expmed.c
==================================================================
--- gcc/expmed.c	(revision 124112)
+++ gcc/expmed.c	(local)
@@ -5044,7 +5044,7 @@
 			  make_tree (type, XEXP (x, 1)));
 
     case LSHIFTRT:
-      t = lang_hooks.types.unsigned_type (type);
+      t = get_unsigned_type (type);
       return fold_convert (type, build2 (RSHIFT_EXPR, t,
 			    		 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (type, XEXP (x, 1))));
@@ -5065,7 +5065,7 @@
 				    	 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (t, XEXP (x, 1))));
     case UDIV:
-      t = lang_hooks.types.unsigned_type (type);
+      t = get_unsigned_type (type);
       return fold_convert (type, build2 (TRUNC_DIV_EXPR, t,
 				    	 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (t, XEXP (x, 1))));
=== gcc/fold-const.c
==================================================================
--- gcc/fold-const.c	(revision 124112)
+++ gcc/fold-const.c	(local)
@@ -1411,7 +1411,7 @@
 	    {
 	      tree ntype = TYPE_UNSIGNED (type)
 			   ? lang_hooks.types.signed_type (type)
-			   : lang_hooks.types.unsigned_type (type);
+			   : get_unsigned_type (type);
 	      tree temp = fold_convert (ntype, TREE_OPERAND (t, 0));
 	      temp = fold_build2 (RSHIFT_EXPR, ntype, temp, op1);
 	      return fold_convert (type, temp);
@@ -4352,7 +4352,7 @@
     {
       if (! TYPE_UNSIGNED (etype))
 	{
-	  etype = lang_hooks.types.unsigned_type (etype);
+	  etype = get_unsigned_type (etype);
 	  high = fold_convert (etype, high);
 	  exp = fold_convert (etype, exp);
 	}
@@ -4420,7 +4420,7 @@
 
       /* Check if (unsigned) INT_MAX + 1 == (unsigned) INT_MIN
 	 for the type in question, as we rely on this here.  */
-      utype = lang_hooks.types.unsigned_type (etype);
+      utype = get_unsigned_type (etype);
       maxv = fold_convert (utype, TYPE_MAX_VALUE (etype));
       maxv = range_binop (PLUS_EXPR, NULL_TREE, maxv, 1,
 			  integer_one_node, 1);
@@ -7805,7 +7805,7 @@
 		  && (LOAD_EXTEND_OP (TYPE_MODE (TREE_TYPE (and0)))
 		      == ZERO_EXTEND))
 		{
-		  tree uns = lang_hooks.types.unsigned_type (TREE_TYPE (and0));
+		  tree uns = get_unsigned_type (TREE_TYPE (and0));
 		  and0 = fold_convert (uns, and0);
 		  and1 = fold_convert (uns, and1);
 		}
@@ -11294,7 +11294,7 @@
 	      || TREE_CODE (arg0) == ROUND_MOD_EXPR)
 	  && integer_pow2p (TREE_OPERAND (arg0, 1)))
 	{
-	  tree newtype = lang_hooks.types.unsigned_type (TREE_TYPE (arg0));
+	  tree newtype = get_unsigned_type (TREE_TYPE (arg0));
 	  tree newmod = fold_build2 (TREE_CODE (arg0), newtype,
 				     fold_convert (newtype,
 						   TREE_OPERAND (arg0, 0)),
@@ -12403,7 +12403,7 @@
 	      else if ((TREE_INT_CST_HIGH (arg1) & mask_hi) == 0
 		       && (TREE_INT_CST_LOW (arg1) & mask_lo) == 0)
 		{
-		  tem_type = lang_hooks.types.unsigned_type (TREE_TYPE (tem));
+		  tem_type = get_unsigned_type (TREE_TYPE (tem));
 		  tem = fold_convert (tem_type, tem);
 		}
 	      else
=== gcc/langhooks-def.h
==================================================================
--- gcc/langhooks-def.h	(revision 124112)
+++ gcc/langhooks-def.h	(local)
@@ -207,13 +207,11 @@
   lhd_omp_firstprivatize_type_sizes
 #define LANG_HOOKS_HASH_TYPES		true
 
-#define LANG_HOOKS_UNSIGNED_TYPE get_unsigned_type
 
 #define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
   LANG_HOOKS_MAKE_TYPE, \
   LANG_HOOKS_TYPE_FOR_MODE, \
   LANG_HOOKS_TYPE_FOR_SIZE, \
-  LANG_HOOKS_UNSIGNED_TYPE, \
   LANG_HOOKS_SIGNED_TYPE, \
   LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \
   LANG_HOOKS_GENERIC_TYPE_P, \
=== gcc/langhooks.h
==================================================================
--- gcc/langhooks.h	(revision 124112)
+++ gcc/langhooks.h	(local)
@@ -103,10 +103,6 @@
      integer type with at least that precision.  */
   tree (*type_for_size) (unsigned, int);
 
-  /* Given an integer type T, return a type like T but unsigned.
-     If T is unsigned, the value is T.  */
-  tree (*unsigned_type) (tree);
-
   /* Given an integer type T, return a type like T but signed.
      If T is signed, the value is T.  */
   tree (*signed_type) (tree);
=== gcc/tree.c
==================================================================
--- gcc/tree.c	(revision 124112)
+++ gcc/tree.c	(local)
@@ -7676,8 +7676,8 @@
 unsigned_type_for (tree type)
 {
   if (POINTER_TYPE_P (type))
-    return lang_hooks.types.unsigned_type (size_type_node);
-  return lang_hooks.types.unsigned_type (type);
+    return get_unsigned_type (size_type_node);
+  return get_unsigned_type (type);
 }
 
 /* Returns signed variant of TYPE.  */

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-03  9:42 [PATCH] remove the unsigned_type language hook Rafael Espindola
@ 2007-05-08 10:30 ` Eric Botcazou
  2007-05-08 12:45   ` Rafael Espindola
  2007-05-08 17:37 ` Eric Botcazou
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 36+ messages in thread
From: Eric Botcazou @ 2007-05-08 10:30 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: gcc-patches

> The attached patch removes the remaining parts of the unsigned_type
> language hook. It depends on my previous patch that adds a default
> implementation.

Could you explain what the plan is exactly?  Which one among the related lang 
hooks are you going to keep?

>  * gcc/ada/utils.c (gnat_unsigned_type): Remove.
 
-/* Return the unsigned version of a TYPE_NODE, a scalar type.  */
-
-tree
-gnat_unsigned_type (tree type_node)
-{
-  tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 1);
-
-  if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node))
-    {
-      type = copy_node (type);
-      TREE_TYPE (type) = type_node;
-    }
-  else if (TREE_TYPE (type_node)
-	   && TREE_CODE (TREE_TYPE (type_node)) == INTEGER_TYPE
-	   && TYPE_MODULAR_P (TREE_TYPE (type_node)))
-    {
-      type = copy_node (type);
-      TREE_TYPE (type) = TREE_TYPE (type_node);
-    }
-
-  return type;
-}


How is that supposed to be accounted for in the new implementation?

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 10:30 ` Eric Botcazou
@ 2007-05-08 12:45   ` Rafael Espindola
  2007-05-08 13:23     ` Richard Guenther
  2007-05-08 13:29     ` Richard Kenner
  0 siblings, 2 replies; 36+ messages in thread
From: Rafael Espindola @ 2007-05-08 12:45 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

> Could you explain what the plan is exactly?  Which one among the related lang
> hooks are you going to keep?

The plan is to process any language specific type in the front end
itself. I am trying to remove as many hooks as possible.

> >  * gcc/ada/utils.c (gnat_unsigned_type): Remove.
>
> -/* Return the unsigned version of a TYPE_NODE, a scalar type.  */
> -
> -tree
> -gnat_unsigned_type (tree type_node)
> -{
> -  tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 1);
> -
> -  if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node))
> -    {
> -      type = copy_node (type);
> -      TREE_TYPE (type) = type_node;
> -    }
> -  else if (TREE_TYPE (type_node)
> -          && TREE_CODE (TREE_TYPE (type_node)) == INTEGER_TYPE
> -          && TYPE_MODULAR_P (TREE_TYPE (type_node)))
> -    {
> -      type = copy_node (type);
> -      TREE_TYPE (type) = TREE_TYPE (type_node);
> -    }
> -
> -  return type;
> -}
>
>
> How is that supposed to be accounted for in the new implementation?

Ada was the only front end that was coping nodes. Note sure why. I was
unable to find any cases were this makes a difference. I don't know
ada or the workings of the ada front end, so I might have missed
something.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 12:45   ` Rafael Espindola
@ 2007-05-08 13:23     ` Richard Guenther
  2007-05-08 13:29     ` Richard Kenner
  1 sibling, 0 replies; 36+ messages in thread
From: Richard Guenther @ 2007-05-08 13:23 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: Eric Botcazou, gcc-patches

On 5/8/07, Rafael Espindola <espindola@google.com> wrote:
> > Could you explain what the plan is exactly?  Which one among the related lang
> > hooks are you going to keep?
>
> The plan is to process any language specific type in the front end
> itself. I am trying to remove as many hooks as possible.
>
> > >  * gcc/ada/utils.c (gnat_unsigned_type): Remove.
> >
> > -/* Return the unsigned version of a TYPE_NODE, a scalar type.  */
> > -
> > -tree
> > -gnat_unsigned_type (tree type_node)
> > -{
> > -  tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 1);
> > -
> > -  if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node))
> > -    {
> > -      type = copy_node (type);
> > -      TREE_TYPE (type) = type_node;
> > -    }
> > -  else if (TREE_TYPE (type_node)
> > -          && TREE_CODE (TREE_TYPE (type_node)) == INTEGER_TYPE
> > -          && TYPE_MODULAR_P (TREE_TYPE (type_node)))
> > -    {
> > -      type = copy_node (type);
> > -      TREE_TYPE (type) = TREE_TYPE (type_node);
> > -    }
> > -
> > -  return type;
> > -}
> >
> >
> > How is that supposed to be accounted for in the new implementation?
>
> Ada was the only front end that was coping nodes. Note sure why. I was
> unable to find any cases were this makes a difference. I don't know
> ada or the workings of the ada front end, so I might have missed
> something.

It is appearantly to make the new unsigned type (being a generic unsigned type
for its size) a sub-type of the former type.

This doesn't look correct anyway - at least from the langhook
perspective.  But maybe
an Ada maintainer can comment.  So fwiw the patch looks good.

Richard.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 12:45   ` Rafael Espindola
  2007-05-08 13:23     ` Richard Guenther
@ 2007-05-08 13:29     ` Richard Kenner
  2007-05-08 14:19       ` Eric Botcazou
  1 sibling, 1 reply; 36+ messages in thread
From: Richard Kenner @ 2007-05-08 13:29 UTC (permalink / raw)
  To: espindola; +Cc: ebotcazou, gcc-patches

> Ada was the only front end that was coping nodes. Note sure why. I
> was unable to find any cases were this makes a difference. I don't
> know ada or the workings of the ada front end, so I might have
> missed something.

I'm not convinced this is required either and are, in general, in favor
of removing this sort of lang hook because the middle-end shouldn't be
doing this sort of thing, but this definitely requires testing.  I'd
think acats should be sufficient since modular types of this sort aren't
often used elsewhere.

Eric: I know that somebody recently did a gcov run of gnat1 over the entire
AdaCore test suite and acats.  Can you check if the copy_nodes in the
code in question are ever executed?

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 13:29     ` Richard Kenner
@ 2007-05-08 14:19       ` Eric Botcazou
  2007-05-08 14:25         ` Richard Guenther
  2007-05-08 14:32         ` Richard Kenner
  0 siblings, 2 replies; 36+ messages in thread
From: Eric Botcazou @ 2007-05-08 14:19 UTC (permalink / raw)
  To: Richard Kenner; +Cc: espindola, gcc-patches

> Eric: I know that somebody recently did a gcov run of gnat1 over the entire
> AdaCore test suite and acats.  Can you check if the copy_nodes in the
> code in question are ever executed?

I don't trust this stuff too much. :-)  Instead I put 4 gcc_unreachable () in 
the hot spots of gnat_unsigned_type/gnat_signed_type.  It didn't go very far:

../../xgcc -B../../ -B/usr/gnat/i686-pc-linux-gnu/bin/ 
-isystem /usr/gnat/i686-pc-linux-gnu/include 
-isystem /usr/gnat/i686-pc-linux-gnu/sys-include 
-L/cardiff.a/gnatmail/gcc-head/build-cardiff/obj/gcc/../ld -c -O2 -fPIC      
-gnatpgn  g-alleve.adb -o g-alleve.o
+===========================GNAT BUG DETECTED==============================+
| Pro 6.1.0w (20070507-head) (i686-pc-linux-gnu) GCC error:                |
| in gnat_unsigned_type, at ada/utils.c:2321                               |
| Error detected at g-alleve.adb:1884:59                    

   function To_Pixel (Source : unsigned_short) return Pixel_16 is

      --  This conversion should not depend on the host endianess;
      --  therefore, we cannot use an unchecked conversion.

      Target : Pixel_16;

   begin
      Target.T := Unsigned_1 (Bits (Source, 0, 0)   mod 2 ** 1);
      Target.R := Unsigned_5 (Bits (Source, 1, 5)   mod 2 ** 5);
      Target.G := Unsigned_5 (Bits (Source, 6, 10)  mod 2 ** 5);
      Target.B := Unsigned_5 (Bits (Source, 11, 15) mod 2 ** 5);
      return Target;
   end To_Pixel;


Without rebuilding the runtime, ACATS is hurt too:

FAIL:   c354002
FAIL:   c360002
FAIL:   c420001
FAIL:   c450001
FAIL:   c460008
FAIL:   c460011
FAIL:   cxf2a01
FAIL:   cxf2a02


However, like Richard G, I don't fully understand the purpose of the code.  Do 
you have any recollections?

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 14:19       ` Eric Botcazou
@ 2007-05-08 14:25         ` Richard Guenther
  2007-05-08 14:36           ` Richard Kenner
  2007-05-08 14:32         ` Richard Kenner
  1 sibling, 1 reply; 36+ messages in thread
From: Richard Guenther @ 2007-05-08 14:25 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: Richard Kenner, espindola, gcc-patches

On 5/8/07, Eric Botcazou <ebotcazou@adacore.com> wrote:
> > Eric: I know that somebody recently did a gcov run of gnat1 over the entire
> > AdaCore test suite and acats.  Can you check if the copy_nodes in the
> > code in question are ever executed?
>
> I don't trust this stuff too much. :-)  Instead I put 4 gcc_unreachable () in
> the hot spots of gnat_unsigned_type/gnat_signed_type.  It didn't go very far:
>
> ../../xgcc -B../../ -B/usr/gnat/i686-pc-linux-gnu/bin/
> -isystem /usr/gnat/i686-pc-linux-gnu/include
> -isystem /usr/gnat/i686-pc-linux-gnu/sys-include
> -L/cardiff.a/gnatmail/gcc-head/build-cardiff/obj/gcc/../ld -c -O2 -fPIC
> -gnatpgn  g-alleve.adb -o g-alleve.o
> +===========================GNAT BUG DETECTED==============================+
> | Pro 6.1.0w (20070507-head) (i686-pc-linux-gnu) GCC error:                |
> | in gnat_unsigned_type, at ada/utils.c:2321                               |
> | Error detected at g-alleve.adb:1884:59
>
>    function To_Pixel (Source : unsigned_short) return Pixel_16 is
>
>       --  This conversion should not depend on the host endianess;
>       --  therefore, we cannot use an unchecked conversion.
>
>       Target : Pixel_16;
>
>    begin
>       Target.T := Unsigned_1 (Bits (Source, 0, 0)   mod 2 ** 1);
>       Target.R := Unsigned_5 (Bits (Source, 1, 5)   mod 2 ** 5);
>       Target.G := Unsigned_5 (Bits (Source, 6, 10)  mod 2 ** 5);
>       Target.B := Unsigned_5 (Bits (Source, 11, 15) mod 2 ** 5);
>       return Target;
>    end To_Pixel;
>
>
> Without rebuilding the runtime, ACATS is hurt too:
>
> FAIL:   c354002
> FAIL:   c360002
> FAIL:   c420001
> FAIL:   c450001
> FAIL:   c460008
> FAIL:   c460011
> FAIL:   cxf2a01
> FAIL:   cxf2a02
>
>
> However, like Richard G, I don't fully understand the purpose of the code.  Do
> you have any recollections?

Something that would make more "sense" would be that the generic code
substituted
for this langhook has to handle the case that we ask for an unsigned
variant of a
subtype by making sure to make the unsigned subtype a subtype of the unsigned
variant of the original basetype.  So (pseudocode)

  if (TREE_TYPE (type))
    TREE_TYPE (new_type) = unsigned_type_for (TREE_TYPE(type));

Richard.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 14:19       ` Eric Botcazou
  2007-05-08 14:25         ` Richard Guenther
@ 2007-05-08 14:32         ` Richard Kenner
  2007-05-08 17:33           ` Eric Botcazou
  1 sibling, 1 reply; 36+ messages in thread
From: Richard Kenner @ 2007-05-08 14:32 UTC (permalink / raw)
  To: ebotcazou; +Cc: espindola, gcc-patches

> However, like Richard G, I don't fully understand the purpose of the
> code.  Do you have any recollections?

Nothing specific enough, but I'm fairly sure that it only occurs in
calls from elsewhere in Gigi, not via the lang hooks.  I think this
was needed for such calls and just ended up being in the lang hooks because
that was the simplest way to convert the code.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 14:25         ` Richard Guenther
@ 2007-05-08 14:36           ` Richard Kenner
  0 siblings, 0 replies; 36+ messages in thread
From: Richard Kenner @ 2007-05-08 14:36 UTC (permalink / raw)
  To: richard.guenther; +Cc: ebotcazou, espindola, gcc-patches

> Something that would make more "sense" would be that the generic
> code substituted for this langhook has to handle the case that we
> ask for an unsigned variant of a subtype by making sure to make the
> unsigned subtype a subtype of the unsigned variant of the original
> basetype.  So (pseudocode)
>
>   if (TREE_TYPE (type))
>     TREE_TYPE (new_type) = unsigned_type_for (TREE_TYPE(type));

No, I can't believe that matters.  The issue is specific to the
modular type handling, not subtypes in general.  It would be odd for
these functions to ever return things that are subtypes at all.  But
modular types are an exception because that's a case where an Ada base
type is represented as a subtype due to the way modular types are encoded
for Ada.  But the middle-end shouldn't have to know about this, which is
why I think this code is only relevant for usage inside Gigi, not via the
lang hook.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 14:32         ` Richard Kenner
@ 2007-05-08 17:33           ` Eric Botcazou
  0 siblings, 0 replies; 36+ messages in thread
From: Eric Botcazou @ 2007-05-08 17:33 UTC (permalink / raw)
  To: Richard Kenner; +Cc: espindola, gcc-patches

> Nothing specific enough, but I'm fairly sure that it only occurs in
> calls from elsewhere in Gigi, not via the lang hooks.  I think this
> was needed for such calls and just ended up being in the lang hooks
> because that was the simplest way to convert the code.

Yes, that makes a lot of sense to me.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-03  9:42 [PATCH] remove the unsigned_type language hook Rafael Espindola
  2007-05-08 10:30 ` Eric Botcazou
@ 2007-05-08 17:37 ` Eric Botcazou
  2007-05-09 17:57   ` Rafael Espindola
  2007-05-14 19:45 ` Mike Stump
  2007-05-14 20:24 ` Regressions from " Hans-Peter Nilsson
  3 siblings, 1 reply; 36+ messages in thread
From: Eric Botcazou @ 2007-05-08 17:37 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: gcc-patches

> gcc/ada/ChangeLog
>  * gcc/ada/gigi.h (gnat_unsigned_type): Remove.
>  * gcc/ada/misc.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.
>  * gcc/ada/trans.c (gnat_to_gnu): Use get_unsigned_type instead of
> gnat_unsigned_type.
>                            (convert_with_check): Likewise.
>  * gcc/ada/utils.c (gnat_unsigned_type): Remove.

Not OK.  Please leave the Gigi code untouched and only delete in misc.c 
LANG_HOOKS_UNSIGNED_TYPE (and LANG_HOOKS_SIGNED_TYPE).

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-08 17:37 ` Eric Botcazou
@ 2007-05-09 17:57   ` Rafael Espindola
  2007-05-09 20:42     ` Eric Botcazou
  0 siblings, 1 reply; 36+ messages in thread
From: Rafael Espindola @ 2007-05-09 17:57 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]

> Not OK.  Please leave the Gigi code untouched and only delete in misc.c
> LANG_HOOKS_UNSIGNED_TYPE (and LANG_HOOKS_SIGNED_TYPE).

A new version that includes the implementation, has been ported to a
new revision and does the least possible changes to ada is attached.

OK for trunk?

* gcc/ada/misc.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.

* gcc/c-common.c (warnings_for_convert_and_check): Use
get_unsigned_type instead of c_common_unsigned_type.
                 (c_common_unsigned_type): Remove.
                 (shorten_compare): Use
c_common_signed_or_unsigned_type instead of c_common_unsigned_type.
                 (c_common_nodes_and_builtins): Use get_unsigned_type
instead of c_common_unsigned_type.
* gcc/c-format.c (check_format_types): Likewise.
* gcc/c-decl.c (grokdeclarator): Likewise.
* gcc/c-typeck.c (convert_for_assignment): Likewise.
* gcc/c-common.h (c_common_unsigned_type): Remove.
* gcc/c-objc-common.h (LANG_HOOKS_UNSIGNED_TYPE): Remove.
* gcc/convert.c (convert_to_integer): Use get_unsigned_type instead of
lang_hooks.types.unsigned_type.
* gcc/fold-const.c (fold_negate_expr): Likewise.
                   (build_range_check): Likewise.
                   (fold_unary): Likewise.
                   (fold_binary): Likewise.
                   (fold_ternary): Likewise.
* gcc/expmed.c (make_tree): Likewise.
* gcc/tree.c (unsigned_type_for): Likewise.
* gcc/langhooks-def.h (LANG_HOOKS_FOR_TYPES_INITIALIZER): Remove
LANG_HOOKS_UNSIGNED_TYPE
* gcc/langhooks.c (get_unsigned_type): New.
* gcc/langhooks.h (lang_hooks_for_types): Remove unsigned_type.
* gcc/tree.h (get_unsigned_type): New.

* gcc/cp/cp-objcp-common.h (LANG_HOOKS_UNSIGNED_TYPE): Remove.
* gcc/cp/decl.c (grokdeclarator): Use get_unsigned_type instead of
c_common_unsigned_type.

* gcc/fortran/f95-lang.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.
* gcc/fortran/trans-intrinsic.c (gfc_conv_intrinsic_ishft): Use
get_unsigned_type instead of gfc_unsigned_type.
* gcc/fortran/trans-stmt.c (gfc_trans_do): Likewise.
* gcc/fortran/trans-types.c (gfc_unsigned_type): Remove.
* gcc/fortran/trans-types.h (gfc_unsigned_type): Remove.

* gcc/java/expr.c (build_java_binop): Use get_unsigned_type instead of
java_unsigned_type.
* gcc/java/java-tree.h (java_unsigned_type): Remove.
* gcc/java/lang.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.
* gcc/java/typeck.c (java_unsigned_type): Remove.

[-- Attachment #2: gcc-unsigned-type-new.patch --]
[-- Type: text/x-patch, Size: 18716 bytes --]

--- gcc/ada/misc.c	(revision 124568)
+++ gcc/ada/misc.c	(local)
@@ -159,8 +159,6 @@ static tree gnat_type_max_size		(tree);
 #define LANG_HOOKS_TYPE_FOR_SIZE	gnat_type_for_size
 #undef  LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE		gnat_signed_type
-#undef  LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE	gnat_unsigned_type
 #undef  LANG_HOOKS_ATTRIBUTE_TABLE
 #define LANG_HOOKS_ATTRIBUTE_TABLE	gnat_internal_attribute_table
 #undef  LANG_HOOKS_BUILTIN_FUNCTION
--- gcc/c-common.c	(revision 124568)
+++ gcc/c-common.c	(local)
@@ -1303,7 +1303,7 @@ warnings_for_convert_and_check (tree typ
           else if (warn_conversion)
             conversion_warning (type, expr);
         }
-      else if (!int_fits_type_p (expr, c_common_unsigned_type (type))) 
+      else if (!int_fits_type_p (expr, get_unsigned_type (type))) 
 	warning (OPT_Woverflow,
 		 "overflow in implicit constant conversion");
       /* No warning for converting 0x80000000 to int.  */
@@ -1998,39 +1998,6 @@ c_common_type_for_mode (enum machine_mod
   return 0;
 }
 
-/* Return an unsigned type the same as TYPE in other respects.  */
-tree
-c_common_unsigned_type (tree type)
-{
-  tree type1 = TYPE_MAIN_VARIANT (type);
-  if (type1 == signed_char_type_node || type1 == char_type_node)
-    return unsigned_char_type_node;
-  if (type1 == integer_type_node)
-    return unsigned_type_node;
-  if (type1 == short_integer_type_node)
-    return short_unsigned_type_node;
-  if (type1 == long_integer_type_node)
-    return long_unsigned_type_node;
-  if (type1 == long_long_integer_type_node)
-    return long_long_unsigned_type_node;
-  if (type1 == widest_integer_literal_type_node)
-    return widest_unsigned_literal_type_node;
-#if HOST_BITS_PER_WIDE_INT >= 64
-  if (type1 == intTI_type_node)
-    return unsigned_intTI_type_node;
-#endif
-  if (type1 == intDI_type_node)
-    return unsigned_intDI_type_node;
-  if (type1 == intSI_type_node)
-    return unsigned_intSI_type_node;
-  if (type1 == intHI_type_node)
-    return unsigned_intHI_type_node;
-  if (type1 == intQI_type_node)
-    return unsigned_intQI_type_node;
-
-  return c_common_signed_or_unsigned_type (1, type);
-}
-
 /* Return a signed type the same as TYPE in other respects.  */
 
 tree
@@ -2473,7 +2440,8 @@ shorten_compare (tree *op0_ptr, tree *op
 	      default:
 		break;
 	      }
-	  type = c_common_unsigned_type (type);
+	  /* get_unsigned_type doesn't support C bit fields */
+	  type = c_common_signed_or_unsigned_type (1, type);
 	}
 
       if (TREE_CODE (primop0) != INTEGER_CST)
@@ -3640,7 +3608,7 @@ c_common_nodes_and_builtins (void)
   else
     {
       signed_wchar_type_node = c_common_signed_type (wchar_type_node);
-      unsigned_wchar_type_node = c_common_unsigned_type (wchar_type_node);
+      unsigned_wchar_type_node = get_unsigned_type (wchar_type_node);
     }
 
   /* This is for wide string constants.  */
@@ -3658,7 +3626,7 @@ c_common_nodes_and_builtins (void)
   default_function_type = build_function_type (integer_type_node, NULL_TREE);
   ptrdiff_type_node
     = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE)));
-  unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
+  unsigned_ptrdiff_type_node = get_unsigned_type (ptrdiff_type_node);
 
   lang_hooks.decls.pushdecl
     (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
--- gcc/c-common.h	(revision 124568)
+++ gcc/c-common.h	(local)
@@ -667,7 +667,6 @@ extern int c_common_handle_option (size_
 extern bool c_common_missing_argument (const char *opt, size_t code);
 extern tree c_common_type_for_mode (enum machine_mode, int);
 extern tree c_common_type_for_size (unsigned int, int);
-extern tree c_common_unsigned_type (tree);
 extern tree c_common_signed_type (tree);
 extern tree c_common_signed_or_unsigned_type (int, tree);
 extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
--- gcc/c-decl.c	(revision 124568)
+++ gcc/c-decl.c	(local)
@@ -4086,7 +4086,7 @@ grokdeclarator (const struct c_declarato
      "signed".  */
   if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
       && TREE_CODE (type) == INTEGER_TYPE)
-    type = c_common_unsigned_type (type);
+    type = get_unsigned_type (type);
 
   /* Figure out the type qualifiers for the declaration.  There are
      two ways a declaration can become qualified.  One is something
--- gcc/c-format.c	(revision 124568)
+++ gcc/c-format.c	(local)
@@ -2249,7 +2249,7 @@ check_format_types (format_wanted_type *
 	  && TREE_CODE (cur_type) == INTEGER_TYPE
 	  && (!pedantic || i == 0 || (i == 1 && char_type_flag))
 	  && (TYPE_UNSIGNED (wanted_type)
-	      ? wanted_type == c_common_unsigned_type (cur_type)
+	      ? wanted_type == get_unsigned_type (cur_type)
 	      : wanted_type == c_common_signed_type (cur_type)))
 	continue;
       /* Likewise, "signed char", "unsigned char" and "char" are
--- gcc/c-objc-common.h	(revision 124568)
+++ gcc/c-objc-common.h	(local)
@@ -104,8 +104,6 @@ extern void c_initialize_diagnostics (di
 #define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
 #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
--- gcc/c-typeck.c	(revision 124568)
+++ gcc/c-typeck.c	(local)
@@ -4081,8 +4081,8 @@ convert_for_assignment (tree type, tree 
       if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
 	  || (target_cmp = comp_target_types (type, rhstype))
 	  || is_opaque_pointer
-	  || (c_common_unsigned_type (mvl)
-	      == c_common_unsigned_type (mvr)))
+	  || (get_unsigned_type (mvl)
+	      == get_unsigned_type (mvr)))
 	{
 	  if (pedantic
 	      && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
--- gcc/convert.c	(revision 124568)
+++ gcc/convert.c	(local)
@@ -656,7 +656,7 @@ convert_to_integer (tree type, tree expr
 			     || !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1)))
 			    && (ex_form == PLUS_EXPR
 				|| ex_form == MINUS_EXPR)))
-		      typex = lang_hooks.types.unsigned_type (typex);
+		      typex = get_unsigned_type (typex);
 		    else
 		      typex = lang_hooks.types.signed_type (typex);
 		    return convert (type,
@@ -678,7 +678,7 @@ convert_to_integer (tree type, tree expr
 	    /* Don't do unsigned arithmetic where signed was wanted,
 	       or vice versa.  */
 	    if (TYPE_UNSIGNED (TREE_TYPE (expr)))
-	      typex = lang_hooks.types.unsigned_type (type);
+	      typex = get_unsigned_type (type);
 	    else
 	      typex = lang_hooks.types.signed_type (type);
 	    return convert (type,
--- gcc/cp/cp-objcp-common.h	(revision 124568)
+++ gcc/cp/cp-objcp-common.h	(local)
@@ -136,8 +136,6 @@ extern tree objcp_tsubst_copy_and_build 
 #define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
 #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
--- gcc/cp/decl.c	(revision 124568)
+++ gcc/cp/decl.c	(local)
@@ -7376,7 +7376,7 @@ grokdeclarator (const cp_declarator *dec
       else if (type == char_type_node)
 	type = unsigned_char_type_node;
       else if (typedef_decl)
-	type = c_common_unsigned_type (type);
+	type = get_unsigned_type (type);
       else
 	type = unsigned_type_node;
     }
--- gcc/expmed.c	(revision 124568)
+++ gcc/expmed.c	(local)
@@ -5044,7 +5044,7 @@ make_tree (tree type, rtx x)
 			  make_tree (type, XEXP (x, 1)));
 
     case LSHIFTRT:
-      t = lang_hooks.types.unsigned_type (type);
+      t = get_unsigned_type (type);
       return fold_convert (type, build2 (RSHIFT_EXPR, t,
 			    		 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (type, XEXP (x, 1))));
@@ -5065,7 +5065,7 @@ make_tree (tree type, rtx x)
 				    	 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (t, XEXP (x, 1))));
     case UDIV:
-      t = lang_hooks.types.unsigned_type (type);
+      t = get_unsigned_type (type);
       return fold_convert (type, build2 (TRUNC_DIV_EXPR, t,
 				    	 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (t, XEXP (x, 1))));
--- gcc/fold-const.c	(revision 124568)
+++ gcc/fold-const.c	(local)
@@ -1411,7 +1411,7 @@ fold_negate_expr (tree t)
 	    {
 	      tree ntype = TYPE_UNSIGNED (type)
 			   ? lang_hooks.types.signed_type (type)
-			   : lang_hooks.types.unsigned_type (type);
+			   : get_unsigned_type (type);
 	      tree temp = fold_convert (ntype, TREE_OPERAND (t, 0));
 	      temp = fold_build2 (RSHIFT_EXPR, ntype, temp, op1);
 	      return fold_convert (type, temp);
@@ -4352,7 +4352,7 @@ build_range_check (tree type, tree exp, 
     {
       if (! TYPE_UNSIGNED (etype))
 	{
-	  etype = lang_hooks.types.unsigned_type (etype);
+	  etype = get_unsigned_type (etype);
 	  high = fold_convert (etype, high);
 	  exp = fold_convert (etype, exp);
 	}
@@ -4420,7 +4420,7 @@ build_range_check (tree type, tree exp, 
 
       /* Check if (unsigned) INT_MAX + 1 == (unsigned) INT_MIN
 	 for the type in question, as we rely on this here.  */
-      utype = lang_hooks.types.unsigned_type (etype);
+      utype = get_unsigned_type (etype);
       maxv = fold_convert (utype, TYPE_MAX_VALUE (etype));
       maxv = range_binop (PLUS_EXPR, NULL_TREE, maxv, 1,
 			  integer_one_node, 1);
@@ -7798,7 +7798,7 @@ fold_unary (enum tree_code code, tree ty
 		  && (LOAD_EXTEND_OP (TYPE_MODE (TREE_TYPE (and0)))
 		      == ZERO_EXTEND))
 		{
-		  tree uns = lang_hooks.types.unsigned_type (TREE_TYPE (and0));
+		  tree uns = get_unsigned_type (TREE_TYPE (and0));
 		  and0 = fold_convert (uns, and0);
 		  and1 = fold_convert (uns, and1);
 		}
@@ -11220,7 +11220,7 @@ fold_binary (enum tree_code code, tree t
 	      || TREE_CODE (arg0) == ROUND_MOD_EXPR)
 	  && integer_pow2p (TREE_OPERAND (arg0, 1)))
 	{
-	  tree newtype = lang_hooks.types.unsigned_type (TREE_TYPE (arg0));
+	  tree newtype = get_unsigned_type (TREE_TYPE (arg0));
 	  tree newmod = fold_build2 (TREE_CODE (arg0), newtype,
 				     fold_convert (newtype,
 						   TREE_OPERAND (arg0, 0)),
@@ -12329,7 +12329,7 @@ fold_ternary (enum tree_code code, tree 
 	      else if ((TREE_INT_CST_HIGH (arg1) & mask_hi) == 0
 		       && (TREE_INT_CST_LOW (arg1) & mask_lo) == 0)
 		{
-		  tem_type = lang_hooks.types.unsigned_type (TREE_TYPE (tem));
+		  tem_type = get_unsigned_type (TREE_TYPE (tem));
 		  tem = fold_convert (tem_type, tem);
 		}
 	      else
--- gcc/fortran/f95-lang.c	(revision 124568)
+++ gcc/fortran/f95-lang.c	(local)
@@ -113,7 +113,6 @@ static HOST_WIDE_INT gfc_get_alias_set (
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #undef LANG_HOOKS_TYPE_FOR_SIZE
-#undef LANG_HOOKS_UNSIGNED_TYPE
 #undef LANG_HOOKS_SIGNED_TYPE
 #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
 #undef LANG_HOOKS_CLEAR_BINDING_STACK
@@ -138,7 +137,6 @@ static HOST_WIDE_INT gfc_get_alias_set (
 #define LANG_HOOKS_MARK_ADDRESSABLE        gfc_mark_addressable
 #define LANG_HOOKS_TYPE_FOR_MODE           gfc_type_for_mode
 #define LANG_HOOKS_TYPE_FOR_SIZE           gfc_type_for_size
-#define LANG_HOOKS_UNSIGNED_TYPE           gfc_unsigned_type
 #define LANG_HOOKS_SIGNED_TYPE             gfc_signed_type
 #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function
 #define LANG_HOOKS_CLEAR_BINDING_STACK     gfc_clear_binding_stack
--- gcc/fortran/trans-intrinsic.c	(revision 124568)
+++ gcc/fortran/trans-intrinsic.c	(local)
@@ -2400,7 +2400,7 @@ gfc_conv_intrinsic_ishft (gfc_se * se, g
   arg2 = TREE_VALUE (TREE_CHAIN (arg));
   arg = TREE_VALUE (arg);
   type = TREE_TYPE (arg);
-  utype = gfc_unsigned_type (type);
+  utype = get_unsigned_type (type);
 
   width = fold_build1 (ABS_EXPR, TREE_TYPE (arg2), arg2);
 
--- gcc/fortran/trans-stmt.c	(revision 124568)
+++ gcc/fortran/trans-stmt.c	(local)
@@ -890,7 +890,7 @@ gfc_trans_do (gfc_code * code)
     {
       tree ustep;
 
-      utype = gfc_unsigned_type (type);
+      utype = get_unsigned_type (type);
 
       /* tmp = abs(to - from) / abs(step) */
       ustep = fold_convert (utype, fold_build1 (ABS_EXPR, type, step));
@@ -905,7 +905,7 @@ gfc_trans_do (gfc_code * code)
       /* TODO: We could use the same width as the real type.
 	 This would probably cause more problems that it solves
 	 when we implement "long double" types.  */
-      utype = gfc_unsigned_type (gfc_array_index_type);
+      utype = get_unsigned_type (gfc_array_index_type);
       tmp = fold_build2 (MINUS_EXPR, type, to, from);
       tmp = fold_build2 (RDIV_EXPR, type, tmp, step);
       tmp = fold_build1 (FIX_TRUNC_EXPR, utype, tmp);
--- gcc/fortran/trans-types.c	(revision 124568)
+++ gcc/fortran/trans-types.c	(local)
@@ -1839,14 +1839,6 @@ gfc_type_for_mode (enum machine_mode mod
   return NULL_TREE;
 }
 
-/* Return an unsigned type the same as TYPE in other respects.  */
-
-tree
-gfc_unsigned_type (tree type)
-{
-  return get_signed_or_unsigned_type (1, type);
-}
-
 /* Return a signed type the same as TYPE in other respects.  */
 
 tree
--- gcc/fortran/trans-types.h	(revision 124568)
+++ gcc/fortran/trans-types.h	(local)
@@ -82,7 +82,6 @@ tree gfc_get_function_type (gfc_symbol *
 
 tree gfc_type_for_size (unsigned, int);
 tree gfc_type_for_mode (enum machine_mode, int);
-tree gfc_unsigned_type (tree);
 tree gfc_signed_type (tree);
 
 tree gfc_get_element_type (tree);
--- gcc/java/expr.c	(revision 124568)
+++ gcc/java/expr.c	(local)
@@ -1523,7 +1523,7 @@ build_java_binop (enum tree_code op, tre
     {
     case URSHIFT_EXPR:
       {
-	tree u_type = java_unsigned_type (type);
+	tree u_type = get_unsigned_type (type);
 	arg1 = convert (u_type, arg1);
 	arg1 = build_java_binop (RSHIFT_EXPR, u_type, arg1, arg2);
 	return convert (type, arg1);
--- gcc/java/java-tree.h	(revision 124568)
+++ gcc/java/java-tree.h	(local)
@@ -1099,7 +1099,6 @@ extern void java_parse_file (int);
 extern bool java_mark_addressable (tree);
 extern tree java_type_for_mode (enum machine_mode, int);
 extern tree java_type_for_size (unsigned int, int);
-extern tree java_unsigned_type (tree);
 extern tree java_signed_type (tree);
 extern tree java_truthvalue_conversion (tree);
 extern void add_assume_compiled (const char *, int);
--- gcc/java/lang.c	(revision 124568)
+++ gcc/java/lang.c	(local)
@@ -184,8 +184,6 @@ struct language_function GTY(())
 #define LANG_HOOKS_TYPE_FOR_SIZE java_type_for_size
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE java_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE java_unsigned_type
 
 #undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
 #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree
--- gcc/java/typeck.c	(revision 124568)
+++ gcc/java/typeck.c	(local)
@@ -203,14 +203,6 @@ java_signed_type (tree type)
   return get_signed_or_unsigned_type (0, type);
 }
 
-/* Return an unsigned type the same as TYPE in other respects.  */
-
-tree
-java_unsigned_type (tree type)
-{
-  return get_signed_or_unsigned_type (1, type);
-}
-
 /* Mark EXP saying that we need to be able to take the
    address of it; it should not be allocated in a register.
    Value is true if successful.  */
--- gcc/langhooks-def.h	(revision 124568)
+++ gcc/langhooks-def.h	(local)
@@ -211,7 +211,6 @@ extern tree lhd_make_node (enum tree_cod
   LANG_HOOKS_MAKE_TYPE, \
   LANG_HOOKS_TYPE_FOR_MODE, \
   LANG_HOOKS_TYPE_FOR_SIZE, \
-  LANG_HOOKS_UNSIGNED_TYPE, \
   LANG_HOOKS_SIGNED_TYPE, \
   LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \
   LANG_HOOKS_GENERIC_TYPE_P, \
--- gcc/langhooks.c	(revision 124568)
+++ gcc/langhooks.c	(local)
@@ -592,3 +592,11 @@ lhd_signed_or_unsigned_type (int unsigne
 {
   return lang_hooks.types.type_for_size (TYPE_PRECISION (type), unsignedp);
 }
+
+/* Return an unsigned type the same as TYPE in other respects.  */
+
+tree
+get_unsigned_type (tree type)
+{
+  return get_signed_or_unsigned_type (1, type);
+}
--- gcc/langhooks.h	(revision 124568)
+++ gcc/langhooks.h	(local)
@@ -103,10 +103,6 @@ struct lang_hooks_for_types
      integer type with at least that precision.  */
   tree (*type_for_size) (unsigned, int);
 
-  /* Given an integer type T, return a type like T but unsigned.
-     If T is unsigned, the value is T.  */
-  tree (*unsigned_type) (tree);
-
   /* Given an integer type T, return a type like T but signed.
      If T is signed, the value is T.  */
   tree (*signed_type) (tree);
--- gcc/tree.c	(revision 124568)
+++ gcc/tree.c	(local)
@@ -7737,8 +7737,8 @@ tree
 unsigned_type_for (tree type)
 {
   if (POINTER_TYPE_P (type))
-    return lang_hooks.types.unsigned_type (size_type_node);
-  return lang_hooks.types.unsigned_type (type);
+    return get_unsigned_type (size_type_node);
+  return get_unsigned_type (type);
 }
 
 /* Returns signed variant of TYPE.  */
--- gcc/tree.h	(revision 124568)
+++ gcc/tree.h	(local)
@@ -3814,6 +3814,7 @@ extern bool may_negate_without_overflow_
 extern tree get_inner_array_type (tree);
 
 extern tree get_signed_or_unsigned_type (int unsignedp, tree type);
+extern tree get_unsigned_type (tree type);
 
 /* From expmed.c.  Since rtl.h is included after tree.h, we can't
    put the prototype here.  Rtl.h does declare the prototype if
--- gcc/treelang/treetree.c	(revision 124568)
+++ gcc/treelang/treetree.c	(local)
@@ -127,7 +127,6 @@ struct language_function GTY(())
 static bool tree_mark_addressable (tree exp);
 static tree tree_lang_type_for_size (unsigned precision, int unsignedp);
 static tree tree_lang_type_for_mode (enum machine_mode mode, int unsignedp);
-static tree tree_lang_unsigned_type (tree type_node);
 static tree tree_lang_signed_type (tree type_node);
 
 /* Functions to keep track of the current scope.  */
@@ -153,8 +152,6 @@ static void treelang_expand_function (tr
 #define LANG_HOOKS_MARK_ADDRESSABLE tree_mark_addressable
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE tree_lang_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE tree_lang_unsigned_type
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #define LANG_HOOKS_TYPE_FOR_MODE tree_lang_type_for_mode
 #undef LANG_HOOKS_TYPE_FOR_SIZE
@@ -865,14 +862,6 @@ tree_lang_type_for_mode (enum machine_mo
     return NULL_TREE;
 }
 
-/* Return the unsigned version of a TYPE_NODE, a scalar type.  */
-
-static tree
-tree_lang_unsigned_type (tree type_node)
-{
-  return tree_lang_type_for_size (TYPE_PRECISION (type_node), 1);
-}
-
 /* Return the signed version of a TYPE_NODE, a scalar type.  */
 
 static tree

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-09 17:57   ` Rafael Espindola
@ 2007-05-09 20:42     ` Eric Botcazou
  2007-05-09 20:54       ` Rafael Espindola
  0 siblings, 1 reply; 36+ messages in thread
From: Eric Botcazou @ 2007-05-09 20:42 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: gcc-patches

> * gcc/ada/misc.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.

This part is OK, thanks.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-09 20:42     ` Eric Botcazou
@ 2007-05-09 20:54       ` Rafael Espindola
  2007-05-09 21:03         ` Richard Guenther
  0 siblings, 1 reply; 36+ messages in thread
From: Rafael Espindola @ 2007-05-09 20:54 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

On 5/9/07, Eric Botcazou <ebotcazou@adacore.com> wrote:
> > * gcc/ada/misc.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.
>
> This part is OK, thanks.

Thanks.

Can someone review the patch that adds a default implementation
(http://gcc.gnu.org/ml/gcc-patches/2007-04/msg01681.html)? This will
get it started and make the rest of the patch easier to review. If
someone can approve the full patch it would be even better :-)

Cheers,
Rafael

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-09 20:54       ` Rafael Espindola
@ 2007-05-09 21:03         ` Richard Guenther
  2007-05-10 16:37           ` Rafael Espindola
  0 siblings, 1 reply; 36+ messages in thread
From: Richard Guenther @ 2007-05-09 21:03 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: Eric Botcazou, gcc-patches

On 5/9/07, Rafael Espindola <espindola@google.com> wrote:
> On 5/9/07, Eric Botcazou <ebotcazou@adacore.com> wrote:
> > > * gcc/ada/misc.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.
> >
> > This part is OK, thanks.
>
> Thanks.
>
> Can someone review the patch that adds a default implementation
> (http://gcc.gnu.org/ml/gcc-patches/2007-04/msg01681.html)? This will
> get it started and make the rest of the patch easier to review. If
> someone can approve the full patch it would be even better :-)

I think the frontends should use unsigned_type_for (), not the default
implementation for the langhook directly.  So the final transition would
be simply to make the default implementation inside unsigned_type_for ().

I wonder why we ended up with this langhook duplication anyway...:

  /* Given an integer type T, return a type like T but unsigned.
     If T is unsigned, the value is T.  */
  tree (*unsigned_type) (tree);

  /* Given an integer type T, return a type like T but signed.
     If T is signed, the value is T.  */
  tree (*signed_type) (tree);

  /* Return a type the same as TYPE except unsigned or signed
     according to UNSIGNEDP.  */
  tree (*signed_or_unsigned_type) (int, tree);

!?

Richard.

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-09 21:03         ` Richard Guenther
@ 2007-05-10 16:37           ` Rafael Espindola
  2007-05-11  8:34             ` Rafael Espindola
  0 siblings, 1 reply; 36+ messages in thread
From: Rafael Espindola @ 2007-05-10 16:37 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Eric Botcazou, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]

> I think the frontends should use unsigned_type_for (), not the default
> implementation for the langhook directly.  So the final transition would
> be simply to make the default implementation inside unsigned_type_for ().
>
> I wonder why we ended up with this langhook duplication anyway...:
>
>   /* Given an integer type T, return a type like T but unsigned.
>      If T is unsigned, the value is T.  */
>   tree (*unsigned_type) (tree);
>
>   /* Given an integer type T, return a type like T but signed.
>      If T is signed, the value is T.  */
>   tree (*signed_type) (tree);
>
>   /* Return a type the same as TYPE except unsigned or signed
>      according to UNSIGNEDP.  */
>   tree (*signed_or_unsigned_type) (int, tree);
>
> !?

I like the idea. I am currently bootstraping with the attached file.
OK for trunk if the regression tests are OK?

> Richard.
>


-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

[-- Attachment #2: gcc-unsigned-type-new2.patch --]
[-- Type: text/x-patch, Size: 18179 bytes --]

--- gcc/ada/misc.c	(revision 124568)
+++ gcc/ada/misc.c	(local)
@@ -159,8 +159,6 @@ static tree gnat_type_max_size		(tree);
 #define LANG_HOOKS_TYPE_FOR_SIZE	gnat_type_for_size
 #undef  LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE		gnat_signed_type
-#undef  LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE	gnat_unsigned_type
 #undef  LANG_HOOKS_ATTRIBUTE_TABLE
 #define LANG_HOOKS_ATTRIBUTE_TABLE	gnat_internal_attribute_table
 #undef  LANG_HOOKS_BUILTIN_FUNCTION
--- gcc/c-common.c	(revision 124568)
+++ gcc/c-common.c	(local)
@@ -1303,7 +1303,7 @@ warnings_for_convert_and_check (tree typ
           else if (warn_conversion)
             conversion_warning (type, expr);
         }
-      else if (!int_fits_type_p (expr, c_common_unsigned_type (type))) 
+      else if (!int_fits_type_p (expr, unsigned_type_for (type))) 
 	warning (OPT_Woverflow,
 		 "overflow in implicit constant conversion");
       /* No warning for converting 0x80000000 to int.  */
@@ -1998,39 +1998,6 @@ c_common_type_for_mode (enum machine_mod
   return 0;
 }
 
-/* Return an unsigned type the same as TYPE in other respects.  */
-tree
-c_common_unsigned_type (tree type)
-{
-  tree type1 = TYPE_MAIN_VARIANT (type);
-  if (type1 == signed_char_type_node || type1 == char_type_node)
-    return unsigned_char_type_node;
-  if (type1 == integer_type_node)
-    return unsigned_type_node;
-  if (type1 == short_integer_type_node)
-    return short_unsigned_type_node;
-  if (type1 == long_integer_type_node)
-    return long_unsigned_type_node;
-  if (type1 == long_long_integer_type_node)
-    return long_long_unsigned_type_node;
-  if (type1 == widest_integer_literal_type_node)
-    return widest_unsigned_literal_type_node;
-#if HOST_BITS_PER_WIDE_INT >= 64
-  if (type1 == intTI_type_node)
-    return unsigned_intTI_type_node;
-#endif
-  if (type1 == intDI_type_node)
-    return unsigned_intDI_type_node;
-  if (type1 == intSI_type_node)
-    return unsigned_intSI_type_node;
-  if (type1 == intHI_type_node)
-    return unsigned_intHI_type_node;
-  if (type1 == intQI_type_node)
-    return unsigned_intQI_type_node;
-
-  return c_common_signed_or_unsigned_type (1, type);
-}
-
 /* Return a signed type the same as TYPE in other respects.  */
 
 tree
@@ -2473,7 +2440,8 @@ shorten_compare (tree *op0_ptr, tree *op
 	      default:
 		break;
 	      }
-	  type = c_common_unsigned_type (type);
+	  /* unsigned_type_for doesn't support C bit fields */
+	  type = c_common_signed_or_unsigned_type (1, type);
 	}
 
       if (TREE_CODE (primop0) != INTEGER_CST)
@@ -3640,7 +3608,7 @@ c_common_nodes_and_builtins (void)
   else
     {
       signed_wchar_type_node = c_common_signed_type (wchar_type_node);
-      unsigned_wchar_type_node = c_common_unsigned_type (wchar_type_node);
+      unsigned_wchar_type_node = unsigned_type_for (wchar_type_node);
     }
 
   /* This is for wide string constants.  */
@@ -3658,7 +3626,7 @@ c_common_nodes_and_builtins (void)
   default_function_type = build_function_type (integer_type_node, NULL_TREE);
   ptrdiff_type_node
     = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE)));
-  unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
+  unsigned_ptrdiff_type_node = unsigned_type_for (ptrdiff_type_node);
 
   lang_hooks.decls.pushdecl
     (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
--- gcc/c-common.h	(revision 124568)
+++ gcc/c-common.h	(local)
@@ -667,7 +667,6 @@ extern int c_common_handle_option (size_
 extern bool c_common_missing_argument (const char *opt, size_t code);
 extern tree c_common_type_for_mode (enum machine_mode, int);
 extern tree c_common_type_for_size (unsigned int, int);
-extern tree c_common_unsigned_type (tree);
 extern tree c_common_signed_type (tree);
 extern tree c_common_signed_or_unsigned_type (int, tree);
 extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
--- gcc/c-decl.c	(revision 124568)
+++ gcc/c-decl.c	(local)
@@ -4086,7 +4086,7 @@ grokdeclarator (const struct c_declarato
      "signed".  */
   if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
       && TREE_CODE (type) == INTEGER_TYPE)
-    type = c_common_unsigned_type (type);
+    type = unsigned_type_for (type);
 
   /* Figure out the type qualifiers for the declaration.  There are
      two ways a declaration can become qualified.  One is something
--- gcc/c-format.c	(revision 124568)
+++ gcc/c-format.c	(local)
@@ -2249,7 +2249,7 @@ check_format_types (format_wanted_type *
 	  && TREE_CODE (cur_type) == INTEGER_TYPE
 	  && (!pedantic || i == 0 || (i == 1 && char_type_flag))
 	  && (TYPE_UNSIGNED (wanted_type)
-	      ? wanted_type == c_common_unsigned_type (cur_type)
+	      ? wanted_type == unsigned_type_for (cur_type)
 	      : wanted_type == c_common_signed_type (cur_type)))
 	continue;
       /* Likewise, "signed char", "unsigned char" and "char" are
--- gcc/c-objc-common.h	(revision 124568)
+++ gcc/c-objc-common.h	(local)
@@ -104,8 +104,6 @@ extern void c_initialize_diagnostics (di
 #define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
 #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
--- gcc/c-typeck.c	(revision 124568)
+++ gcc/c-typeck.c	(local)
@@ -4081,8 +4081,8 @@ convert_for_assignment (tree type, tree 
       if (VOID_TYPE_P (ttl) || VOID_TYPE_P (ttr)
 	  || (target_cmp = comp_target_types (type, rhstype))
 	  || is_opaque_pointer
-	  || (c_common_unsigned_type (mvl)
-	      == c_common_unsigned_type (mvr)))
+	  || (unsigned_type_for (mvl)
+	      == unsigned_type_for (mvr)))
 	{
 	  if (pedantic
 	      && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
--- gcc/convert.c	(revision 124568)
+++ gcc/convert.c	(local)
@@ -656,7 +656,7 @@ convert_to_integer (tree type, tree expr
 			     || !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1)))
 			    && (ex_form == PLUS_EXPR
 				|| ex_form == MINUS_EXPR)))
-		      typex = lang_hooks.types.unsigned_type (typex);
+		      typex = unsigned_type_for (typex);
 		    else
 		      typex = lang_hooks.types.signed_type (typex);
 		    return convert (type,
@@ -678,7 +678,7 @@ convert_to_integer (tree type, tree expr
 	    /* Don't do unsigned arithmetic where signed was wanted,
 	       or vice versa.  */
 	    if (TYPE_UNSIGNED (TREE_TYPE (expr)))
-	      typex = lang_hooks.types.unsigned_type (type);
+	      typex = unsigned_type_for (type);
 	    else
 	      typex = lang_hooks.types.signed_type (type);
 	    return convert (type,
--- gcc/cp/cp-objcp-common.h	(revision 124568)
+++ gcc/cp/cp-objcp-common.h	(local)
@@ -136,8 +136,6 @@ extern tree objcp_tsubst_copy_and_build 
 #define LANG_HOOKS_TYPE_FOR_SIZE c_common_type_for_size
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE c_common_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE c_common_unsigned_type
 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
 #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
--- gcc/cp/decl.c	(revision 124568)
+++ gcc/cp/decl.c	(local)
@@ -7376,7 +7376,7 @@ grokdeclarator (const cp_declarator *dec
       else if (type == char_type_node)
 	type = unsigned_char_type_node;
       else if (typedef_decl)
-	type = c_common_unsigned_type (type);
+	type = unsigned_type_for (type);
       else
 	type = unsigned_type_node;
     }
--- gcc/expmed.c	(revision 124568)
+++ gcc/expmed.c	(local)
@@ -5044,7 +5044,7 @@ make_tree (tree type, rtx x)
 			  make_tree (type, XEXP (x, 1)));
 
     case LSHIFTRT:
-      t = lang_hooks.types.unsigned_type (type);
+      t = unsigned_type_for (type);
       return fold_convert (type, build2 (RSHIFT_EXPR, t,
 			    		 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (type, XEXP (x, 1))));
@@ -5065,7 +5065,7 @@ make_tree (tree type, rtx x)
 				    	 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (t, XEXP (x, 1))));
     case UDIV:
-      t = lang_hooks.types.unsigned_type (type);
+      t = unsigned_type_for (type);
       return fold_convert (type, build2 (TRUNC_DIV_EXPR, t,
 				    	 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (t, XEXP (x, 1))));
--- gcc/fold-const.c	(revision 124568)
+++ gcc/fold-const.c	(local)
@@ -1411,7 +1411,7 @@ fold_negate_expr (tree t)
 	    {
 	      tree ntype = TYPE_UNSIGNED (type)
 			   ? lang_hooks.types.signed_type (type)
-			   : lang_hooks.types.unsigned_type (type);
+			   : unsigned_type_for (type);
 	      tree temp = fold_convert (ntype, TREE_OPERAND (t, 0));
 	      temp = fold_build2 (RSHIFT_EXPR, ntype, temp, op1);
 	      return fold_convert (type, temp);
@@ -4352,7 +4352,7 @@ build_range_check (tree type, tree exp, 
     {
       if (! TYPE_UNSIGNED (etype))
 	{
-	  etype = lang_hooks.types.unsigned_type (etype);
+	  etype = unsigned_type_for (etype);
 	  high = fold_convert (etype, high);
 	  exp = fold_convert (etype, exp);
 	}
@@ -4420,7 +4420,7 @@ build_range_check (tree type, tree exp, 
 
       /* Check if (unsigned) INT_MAX + 1 == (unsigned) INT_MIN
 	 for the type in question, as we rely on this here.  */
-      utype = lang_hooks.types.unsigned_type (etype);
+      utype = unsigned_type_for (etype);
       maxv = fold_convert (utype, TYPE_MAX_VALUE (etype));
       maxv = range_binop (PLUS_EXPR, NULL_TREE, maxv, 1,
 			  integer_one_node, 1);
@@ -7798,7 +7798,7 @@ fold_unary (enum tree_code code, tree ty
 		  && (LOAD_EXTEND_OP (TYPE_MODE (TREE_TYPE (and0)))
 		      == ZERO_EXTEND))
 		{
-		  tree uns = lang_hooks.types.unsigned_type (TREE_TYPE (and0));
+		  tree uns = unsigned_type_for (TREE_TYPE (and0));
 		  and0 = fold_convert (uns, and0);
 		  and1 = fold_convert (uns, and1);
 		}
@@ -11220,7 +11220,7 @@ fold_binary (enum tree_code code, tree t
 	      || TREE_CODE (arg0) == ROUND_MOD_EXPR)
 	  && integer_pow2p (TREE_OPERAND (arg0, 1)))
 	{
-	  tree newtype = lang_hooks.types.unsigned_type (TREE_TYPE (arg0));
+	  tree newtype = unsigned_type_for (TREE_TYPE (arg0));
 	  tree newmod = fold_build2 (TREE_CODE (arg0), newtype,
 				     fold_convert (newtype,
 						   TREE_OPERAND (arg0, 0)),
@@ -12329,7 +12329,7 @@ fold_ternary (enum tree_code code, tree 
 	      else if ((TREE_INT_CST_HIGH (arg1) & mask_hi) == 0
 		       && (TREE_INT_CST_LOW (arg1) & mask_lo) == 0)
 		{
-		  tem_type = lang_hooks.types.unsigned_type (TREE_TYPE (tem));
+		  tem_type = unsigned_type_for (TREE_TYPE (tem));
 		  tem = fold_convert (tem_type, tem);
 		}
 	      else
--- gcc/fortran/f95-lang.c	(revision 124568)
+++ gcc/fortran/f95-lang.c	(local)
@@ -113,7 +113,6 @@ static HOST_WIDE_INT gfc_get_alias_set (
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #undef LANG_HOOKS_TYPE_FOR_SIZE
-#undef LANG_HOOKS_UNSIGNED_TYPE
 #undef LANG_HOOKS_SIGNED_TYPE
 #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
 #undef LANG_HOOKS_CLEAR_BINDING_STACK
@@ -138,7 +137,6 @@ static HOST_WIDE_INT gfc_get_alias_set (
 #define LANG_HOOKS_MARK_ADDRESSABLE        gfc_mark_addressable
 #define LANG_HOOKS_TYPE_FOR_MODE           gfc_type_for_mode
 #define LANG_HOOKS_TYPE_FOR_SIZE           gfc_type_for_size
-#define LANG_HOOKS_UNSIGNED_TYPE           gfc_unsigned_type
 #define LANG_HOOKS_SIGNED_TYPE             gfc_signed_type
 #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function
 #define LANG_HOOKS_CLEAR_BINDING_STACK     gfc_clear_binding_stack
--- gcc/fortran/trans-intrinsic.c	(revision 124568)
+++ gcc/fortran/trans-intrinsic.c	(local)
@@ -2400,7 +2400,7 @@ gfc_conv_intrinsic_ishft (gfc_se * se, g
   arg2 = TREE_VALUE (TREE_CHAIN (arg));
   arg = TREE_VALUE (arg);
   type = TREE_TYPE (arg);
-  utype = gfc_unsigned_type (type);
+  utype = unsigned_type_for (type);
 
   width = fold_build1 (ABS_EXPR, TREE_TYPE (arg2), arg2);
 
--- gcc/fortran/trans-stmt.c	(revision 124568)
+++ gcc/fortran/trans-stmt.c	(local)
@@ -890,7 +890,7 @@ gfc_trans_do (gfc_code * code)
     {
       tree ustep;
 
-      utype = gfc_unsigned_type (type);
+      utype = unsigned_type_for (type);
 
       /* tmp = abs(to - from) / abs(step) */
       ustep = fold_convert (utype, fold_build1 (ABS_EXPR, type, step));
@@ -905,7 +905,7 @@ gfc_trans_do (gfc_code * code)
       /* TODO: We could use the same width as the real type.
 	 This would probably cause more problems that it solves
 	 when we implement "long double" types.  */
-      utype = gfc_unsigned_type (gfc_array_index_type);
+      utype = unsigned_type_for (gfc_array_index_type);
       tmp = fold_build2 (MINUS_EXPR, type, to, from);
       tmp = fold_build2 (RDIV_EXPR, type, tmp, step);
       tmp = fold_build1 (FIX_TRUNC_EXPR, utype, tmp);
--- gcc/fortran/trans-types.c	(revision 124568)
+++ gcc/fortran/trans-types.c	(local)
@@ -1839,14 +1839,6 @@ gfc_type_for_mode (enum machine_mode mod
   return NULL_TREE;
 }
 
-/* Return an unsigned type the same as TYPE in other respects.  */
-
-tree
-gfc_unsigned_type (tree type)
-{
-  return get_signed_or_unsigned_type (1, type);
-}
-
 /* Return a signed type the same as TYPE in other respects.  */
 
 tree
--- gcc/fortran/trans-types.h	(revision 124568)
+++ gcc/fortran/trans-types.h	(local)
@@ -82,7 +82,6 @@ tree gfc_get_function_type (gfc_symbol *
 
 tree gfc_type_for_size (unsigned, int);
 tree gfc_type_for_mode (enum machine_mode, int);
-tree gfc_unsigned_type (tree);
 tree gfc_signed_type (tree);
 
 tree gfc_get_element_type (tree);
--- gcc/java/expr.c	(revision 124568)
+++ gcc/java/expr.c	(local)
@@ -1523,7 +1523,7 @@ build_java_binop (enum tree_code op, tre
     {
     case URSHIFT_EXPR:
       {
-	tree u_type = java_unsigned_type (type);
+	tree u_type = unsigned_type_for (type);
 	arg1 = convert (u_type, arg1);
 	arg1 = build_java_binop (RSHIFT_EXPR, u_type, arg1, arg2);
 	return convert (type, arg1);
--- gcc/java/java-tree.h	(revision 124568)
+++ gcc/java/java-tree.h	(local)
@@ -1099,7 +1099,6 @@ extern void java_parse_file (int);
 extern bool java_mark_addressable (tree);
 extern tree java_type_for_mode (enum machine_mode, int);
 extern tree java_type_for_size (unsigned int, int);
-extern tree java_unsigned_type (tree);
 extern tree java_signed_type (tree);
 extern tree java_truthvalue_conversion (tree);
 extern void add_assume_compiled (const char *, int);
--- gcc/java/lang.c	(revision 124568)
+++ gcc/java/lang.c	(local)
@@ -184,8 +184,6 @@ struct language_function GTY(())
 #define LANG_HOOKS_TYPE_FOR_SIZE java_type_for_size
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE java_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE java_unsigned_type
 
 #undef LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN
 #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree
--- gcc/java/typeck.c	(revision 124568)
+++ gcc/java/typeck.c	(local)
@@ -203,14 +203,6 @@ java_signed_type (tree type)
   return get_signed_or_unsigned_type (0, type);
 }
 
-/* Return an unsigned type the same as TYPE in other respects.  */
-
-tree
-java_unsigned_type (tree type)
-{
-  return get_signed_or_unsigned_type (1, type);
-}
-
 /* Mark EXP saying that we need to be able to take the
    address of it; it should not be allocated in a register.
    Value is true if successful.  */
--- gcc/langhooks-def.h	(revision 124568)
+++ gcc/langhooks-def.h	(local)
@@ -211,7 +211,6 @@ extern tree lhd_make_node (enum tree_cod
   LANG_HOOKS_MAKE_TYPE, \
   LANG_HOOKS_TYPE_FOR_MODE, \
   LANG_HOOKS_TYPE_FOR_SIZE, \
-  LANG_HOOKS_UNSIGNED_TYPE, \
   LANG_HOOKS_SIGNED_TYPE, \
   LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \
   LANG_HOOKS_GENERIC_TYPE_P, \
--- gcc/langhooks.h	(revision 124568)
+++ gcc/langhooks.h	(local)
@@ -103,10 +103,6 @@ struct lang_hooks_for_types
      integer type with at least that precision.  */
   tree (*type_for_size) (unsigned, int);
 
-  /* Given an integer type T, return a type like T but unsigned.
-     If T is unsigned, the value is T.  */
-  tree (*unsigned_type) (tree);
-
   /* Given an integer type T, return a type like T but signed.
      If T is signed, the value is T.  */
   tree (*signed_type) (tree);
--- gcc/tree.c	(revision 124568)
+++ gcc/tree.c	(local)
@@ -7731,14 +7731,22 @@ int_cst_value (tree x)
 }
 
 
+/* Return an unsigned type the same as TYPE in other respects.  */
+
+static tree
+get_unsigned_type (tree type)
+{
+  return get_signed_or_unsigned_type (1, type);
+}
+
 /* Returns unsigned variant of TYPE.  */
 
 tree
 unsigned_type_for (tree type)
 {
   if (POINTER_TYPE_P (type))
-    return lang_hooks.types.unsigned_type (size_type_node);
-  return lang_hooks.types.unsigned_type (type);
+    return get_unsigned_type (size_type_node);
+  return get_unsigned_type (type);
 }
 
 /* Returns signed variant of TYPE.  */
--- gcc/treelang/treetree.c	(revision 124568)
+++ gcc/treelang/treetree.c	(local)
@@ -127,7 +127,6 @@ struct language_function GTY(())
 static bool tree_mark_addressable (tree exp);
 static tree tree_lang_type_for_size (unsigned precision, int unsignedp);
 static tree tree_lang_type_for_mode (enum machine_mode mode, int unsignedp);
-static tree tree_lang_unsigned_type (tree type_node);
 static tree tree_lang_signed_type (tree type_node);
 
 /* Functions to keep track of the current scope.  */
@@ -153,8 +152,6 @@ static void treelang_expand_function (tr
 #define LANG_HOOKS_MARK_ADDRESSABLE tree_mark_addressable
 #undef LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE tree_lang_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
-#define LANG_HOOKS_UNSIGNED_TYPE tree_lang_unsigned_type
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #define LANG_HOOKS_TYPE_FOR_MODE tree_lang_type_for_mode
 #undef LANG_HOOKS_TYPE_FOR_SIZE
@@ -865,14 +862,6 @@ tree_lang_type_for_mode (enum machine_mo
     return NULL_TREE;
 }
 
-/* Return the unsigned version of a TYPE_NODE, a scalar type.  */
-
-static tree
-tree_lang_unsigned_type (tree type_node)
-{
-  return tree_lang_type_for_size (TYPE_PRECISION (type_node), 1);
-}
-
 /* Return the signed version of a TYPE_NODE, a scalar type.  */
 
 static tree

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-10 16:37           ` Rafael Espindola
@ 2007-05-11  8:34             ` Rafael Espindola
  2007-05-11 19:25               ` Mark Mitchell
  0 siblings, 1 reply; 36+ messages in thread
From: Rafael Espindola @ 2007-05-11  8:34 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Eric Botcazou, gcc-patches

> I like the idea. I am currently bootstraping with the attached file.
> OK for trunk if the regression tests are OK?

Compiled with all languages enabled. No regressions found. OK for trunk?

Cheers,
-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-11  8:34             ` Rafael Espindola
@ 2007-05-11 19:25               ` Mark Mitchell
  2007-05-14 19:11                 ` Andrew Pinski
  0 siblings, 1 reply; 36+ messages in thread
From: Mark Mitchell @ 2007-05-11 19:25 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: Richard Guenther, Eric Botcazou, gcc-patches

Rafael Espindola wrote:
>> I like the idea. I am currently bootstraping with the attached file.
>> OK for trunk if the regression tests are OK?
> 
> Compiled with all languages enabled. No regressions found. OK for trunk?

OK.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-11 19:25               ` Mark Mitchell
@ 2007-05-14 19:11                 ` Andrew Pinski
  2007-05-15  8:59                   ` Rafael Espindola
  2007-05-17  6:10                   ` Andrew Pinski
  0 siblings, 2 replies; 36+ messages in thread
From: Andrew Pinski @ 2007-05-14 19:11 UTC (permalink / raw)
  To: Mark Mitchell
  Cc: Rafael Espindola, Richard Guenther, Eric Botcazou, gcc-patches

On 5/11/07, Mark Mitchell <mark@codesourcery.com> wrote:
> Rafael Espindola wrote:
> >> I like the idea. I am currently bootstraping with the attached file.
> >> OK for trunk if the regression tests are OK?
> >
> > Compiled with all languages enabled. No regressions found. OK for trunk?
>
> OK.

And this breaks bootstrap as noted in:
http://gcc.gnu.org/ml/gcc/2007-05/msg00354.html

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-03  9:42 [PATCH] remove the unsigned_type language hook Rafael Espindola
  2007-05-08 10:30 ` Eric Botcazou
  2007-05-08 17:37 ` Eric Botcazou
@ 2007-05-14 19:45 ` Mike Stump
  2007-05-14 20:24 ` Regressions from " Hans-Peter Nilsson
  3 siblings, 0 replies; 36+ messages in thread
From: Mike Stump @ 2007-05-14 19:45 UTC (permalink / raw)
  To: Rafael Espindola; +Cc: gcc-patches

On May 3, 2007, at 2:42 AM, Rafael Espindola wrote:
> Compiled and regression tested with all languages (including ada).

Was this bootstrapped?  Andrew thinks the current failure to bootstrap  
might be caused by a recent c-format.c change...  I'm wondering if  
this one is it?

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Regressions from Re: [PATCH] remove the unsigned_type language hook
  2007-05-03  9:42 [PATCH] remove the unsigned_type language hook Rafael Espindola
                   ` (2 preceding siblings ...)
  2007-05-14 19:45 ` Mike Stump
@ 2007-05-14 20:24 ` Hans-Peter Nilsson
  2007-05-15  9:09   ` Rafael Espindola
  3 siblings, 1 reply; 36+ messages in thread
From: Hans-Peter Nilsson @ 2007-05-14 20:24 UTC (permalink / raw)
  To: espindola; +Cc: gcc-patches

> Date: Thu, 3 May 2007 10:42:17 +0100
> From: "Rafael Espindola" <espindola@google.com>

> The attached patch removes the remaining parts of the unsigned_type
> language hook. It depends on my previous patch that adds a default
> implementation.
> 
> Compiled and regression tested with all languages (including ada).

I guess something was flawed in your regression testing,
comparing old logs or something.

> OK for trunk?
> 
> gcc/ada/ChangeLog
>  * gcc/ada/gigi.h (gnat_unsigned_type): Remove.
>  * gcc/ada/misc.c (LANG_HOOKS_UNSIGNED_TYPE): Remove.
>  * gcc/ada/trans.c (gnat_to_gnu): Use get_unsigned_type instead of
> gnat_unsigned_type.
>                            (convert_with_check): Likewise.
>  * gcc/ada/utils.c (gnat_unsigned_type): Remove.
> 
> gcc/ChangeLog
>  * gcc/c-common.c (warnings_for_convert_and_check): Use
> get_unsigned_type instead of c_common_unsigned_type
>                             (c_common_unsigned_type): Remove.
>                             (shorten_compare): Use
> c_common_signed_or_unsigned_type instead of c_common_unsigned_type.
>                            (c_common_nodes_and_builtins): Use
> get_unsigned_type instead of c_common_unsigned_type.
>  * gcc/c-common.h (c_common_unsigned_type): Remove.
>  * gcc/c-decl.c (grokdeclarator): Use c_common_unsigned_type instead
> of get_unsigned_type.
>  * gcc/c-format.c (check_format_types): Likewise.
>  * gcc/c-objc-common.h (LANG_HOOKS_UNSIGNED_TYPE): Remove.
>  * gcc/c-typeck.c (convert_for_assignment): Use get_unsigned_type
> instead of c_common_unsigned_type.
>  * gcc/convert.c (convert_to_integer): Likewise.
>  * gcc/expmed.c (make_tree): Use get_unsigned_type instead of
> lang_hooks.types.unsigned_type.
>  * gcc/fold-const.c (fold_negate_expr): Likewise.
>                            (build_range_check): Likewise.
>                            (fold_unary): Likewise.
>                            (fold_binary): Likewise.
>                            (fold_ternary): Likewise.
>  * gcc/langhooks-def.h (LANG_HOOKS_UNSIGNED_TYPE): Remove.
>                                  (LANG_HOOKS_FOR_TYPES_INITIALIZER):
> Remove LANG_HOOKS_UNSIGNED_TYPE.
>  * gcc/langhooks.h (lang_hooks_for_types): Remove unsigned_type
>  * gcc/tree.c (unsigned_type_for): Use get_unsigned_type instead of
> lang_hooks.types.unsigned_type
> 
> gcc/cp/ChangeLog
>  * gcc/cp/cp-objcp-common.h (LANG_HOOKS_UNSIGNED_TYPE): Remove.
>  * gcc/cp/decl.c (grokdeclarator): Replace c_common_unsigned_type with
> get_unsigned_type.

I see people have already pointed a regressy finger in the
direction of this patch, but anyway this change causes the
following regressions for cris-elf (only suspect in the range
124713:124716) and I'd be surprised to see all pass for any
target:

Running /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/dg.exp ...
FAIL: gcc.dg/Wno-pointer-sign.c (test for excess errors)
FAIL: gcc.dg/Wpointer-sign-Wall-no.c (test for excess errors)
FAIL: gcc.dg/Wpointer-sign-Wall.c  (test for warnings, line 8)
FAIL: gcc.dg/Wpointer-sign-Wall.c (test for excess errors)
FAIL: gcc.dg/Wpointer-sign-pedantic-no.c (test for excess errors)
FAIL: gcc.dg/Wpointer-sign-pedantic.c  (test for warnings, line 8)
FAIL: gcc.dg/Wpointer-sign-pedantic.c (test for excess errors)
FAIL: gcc.dg/Wpointer-sign.c (test for excess errors)
...
XPASS: gcc.dg/c90-const-expr-2.c bogus null pointer constant (test for bogus messages, line 37)
XPASS: gcc.dg/c90-const-expr-2.c bogus null pointer constant (test for bogus messages, line 38)
XPASS: gcc.dg/c90-const-expr-2.c bogus null pointer constant (test for bogus messages, line 40)
XPASS: gcc.dg/c90-const-expr-2.c bogus null pointer constant (test for bogus messages, line 42)
XPASS: gcc.dg/c90-const-expr-3.c bogus null pointer constant (test for bogus messages, line 31)
XPASS: gcc.dg/c90-const-expr-3.c bogus null pointer constant (test for bogus messages, line 32)
XPASS: gcc.dg/c90-const-expr-3.c bogus null pointer constant (test for bogus messages, line 34)
XPASS: gcc.dg/c90-const-expr-3.c bogus null pointer constant (test for bogus messages, line 36)
XPASS: gcc.dg/c90-const-expr-3.c bogus null pointer constant (test for bogus messages, line 43)
XPASS: gcc.dg/c90-const-expr-3.c bogus null pointer constant (test for bogus messages, line 44)
XPASS: gcc.dg/c90-const-expr-3.c bogus null pointer constant (test for bogus messages, line 45)
FAIL: gcc.dg/c90-const-expr-5.c  (test for errors, line 18)
FAIL: gcc.dg/c90-const-expr-5.c  (test for errors, line 19)
FAIL: gcc.dg/c90-const-expr-5.c (test for excess errors)
XPASS: gcc.dg/c99-const-expr-2.c bogus null pointer constant (test for bogus messages, line 37)
XPASS: gcc.dg/c99-const-expr-2.c bogus null pointer constant (test for bogus messages, line 38)
XPASS: gcc.dg/c99-const-expr-2.c bogus null pointer constant (test for bogus messages, line 40)
XPASS: gcc.dg/c99-const-expr-3.c bogus null pointer constant (test for bogus messages, line 30)
XPASS: gcc.dg/c99-const-expr-3.c bogus null pointer constant (test for bogus messages, line 31)
XPASS: gcc.dg/c99-const-expr-3.c bogus null pointer constant (test for bogus messages, line 33)
XPASS: gcc.dg/c99-const-expr-3.c bogus null pointer constant (test for bogus messages, line 35)
XPASS: gcc.dg/c99-const-expr-3.c bogus null pointer constant (test for bogus messages, line 42)
XPASS: gcc.dg/c99-const-expr-3.c bogus null pointer constant (test for bogus messages, line 43)
XPASS: gcc.dg/c99-const-expr-3.c bogus null pointer constant (test for bogus messages, line 44)
FAIL: gcc.dg/c99-const-expr-5.c  (test for errors, line 18)
FAIL: gcc.dg/c99-const-expr-5.c  (test for errors, line 19)
FAIL: gcc.dg/c99-const-expr-5.c (test for excess errors)
FAIL: gcc.dg/conv-2.c  (test for warnings, line 15)
FAIL: gcc.dg/conv-2.c  (test for warnings, line 16)
FAIL: gcc.dg/conv-2.c  (test for warnings, line 17)
FAIL: gcc.dg/conv-2.c  (test for warnings, line 18)
FAIL: gcc.dg/conv-2.c (test for excess errors)
...
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 55)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 57)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 59)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 61)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 63)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 65)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 67)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 69)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 71)
FAIL: gcc.dg/transparent-union-1.c  (test for warnings, line 73)
...
Running /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/format/format.exp ...
FAIL: gcc.dg/format/bitfld-1.c   (test for excess errors)
FAIL: gcc.dg/format/bitfld-1.c  -DWIDE  (test for excess errors)
FAIL: gcc.dg/format/c99-scanf-1.c   (test for excess errors)
FAIL: gcc.dg/format/c99-scanf-1.c  -DWIDE  (test for excess errors)

With gcc.log saying for example:

FAIL: gcc.dg/Wno-pointer-sign.c (test for excess errors)
Excess errors:
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/Wno-pointer-sign.c:15: warning: assignment from incompatible pointer type
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/Wno-pointer-sign.c:16: warning: assignment from incompatible pointer type
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/Wno-pointer-sign.c:17: warning: passing argument 1 of 'f1' from incompatible pointer type
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/Wno-pointer-sign.c:18: warning: passing argument 1 of 'f2' from incompatible pointer type
...
FAIL: gcc.dg/Wpointer-sign-Wall-no.c (test for excess errors)
Excess errors:
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/Wpointer-sign-Wall-no.c:8: warning: passing argument 1 of 'foo' from incompatible pointer type
...
FAIL: gcc.dg/c90-const-expr-5.c  (test for errors, line 18)
FAIL: gcc.dg/c90-const-expr-5.c  (test for errors, line 19)
PASS: gcc.dg/c90-const-expr-5.c  (test for errors, line 25)
PASS: gcc.dg/c90-const-expr-5.c  (test for errors, line 35)
PASS: gcc.dg/c90-const-expr-5.c  (test for errors, line 36)
PASS: gcc.dg/c90-const-expr-5.c  (test for errors, line 37)
PASS: gcc.dg/c90-const-expr-5.c  (test for errors, line 38)
FAIL: gcc.dg/c90-const-expr-5.c (test for excess errors)
Excess errors:
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/c90-const-expr-5.c:18: error: pointer targets in assignment differ in signedness
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/c90-const-expr-5.c:19: error: pointer targets in assignment differ in signedness

brgds, H-P

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-14 19:11                 ` Andrew Pinski
@ 2007-05-15  8:59                   ` Rafael Espindola
  2007-05-17  6:10                   ` Andrew Pinski
  1 sibling, 0 replies; 36+ messages in thread
From: Rafael Espindola @ 2007-05-15  8:59 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

> And this breaks bootstrap as noted in:
> http://gcc.gnu.org/ml/gcc/2007-05/msg00354.html

I have just bootstrap trunk just after my patch was committed. I am
using a linux x86-64 machine. In which architecture is it failing?


> Thanks,
> Andrew Pinski
>


-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Regressions from Re: [PATCH] remove the unsigned_type language hook
  2007-05-14 20:24 ` Regressions from " Hans-Peter Nilsson
@ 2007-05-15  9:09   ` Rafael Espindola
  2007-05-15 10:13     ` Hans-Peter Nilsson
  0 siblings, 1 reply; 36+ messages in thread
From: Rafael Espindola @ 2007-05-15  9:09 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: gcc-patches

> I guess something was flawed in your regression testing,
> comparing old logs or something.

I have just bootstraped and tested gcc trunk r124715 and I don't see
any of these:

> Running /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/dg.exp ...
> FAIL: gcc.dg/Wno-pointer-sign.c (test for excess errors)
> FAIL: gcc.dg/Wpointer-sign-Wall-no.c (test for excess errors)
> FAIL: gcc.dg/Wpointer-sign-Wall.c  (test for warnings, line 8)
> FAIL: gcc.dg/Wpointer-sign-Wall.c (test for excess errors)
> FAIL: gcc.dg/Wpointer-sign-pedantic-no.c (test for excess errors)
> FAIL: gcc.dg/Wpointer-sign-pedantic.c  (test for warnings, line 8)
....

What architecture are you running the tests on?

>
> brgds, H-P
>


-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: Regressions from Re: [PATCH] remove the unsigned_type language hook
  2007-05-15  9:09   ` Rafael Espindola
@ 2007-05-15 10:13     ` Hans-Peter Nilsson
  0 siblings, 0 replies; 36+ messages in thread
From: Hans-Peter Nilsson @ 2007-05-15 10:13 UTC (permalink / raw)
  To: espindola; +Cc: hans-peter.nilsson, gcc-patches

> Date: Tue, 15 May 2007 10:09:23 +0100
> From: "Rafael Espindola" <espindola@google.com>

> > I guess something was flawed in your regression testing,
> > comparing old logs or something.
> 
> I have just bootstraped and tested gcc trunk r124715 and I don't see
> any of these:
> 
> > Running /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.dg/dg.exp ...
> > FAIL: gcc.dg/Wno-pointer-sign.c (test for excess errors)
> > FAIL: gcc.dg/Wpointer-sign-Wall-no.c (test for excess errors)
> > FAIL: gcc.dg/Wpointer-sign-Wall.c  (test for warnings, line 8)
> > FAIL: gcc.dg/Wpointer-sign-Wall.c (test for excess errors)
> > FAIL: gcc.dg/Wpointer-sign-pedantic-no.c (test for excess errors)
> > FAIL: gcc.dg/Wpointer-sign-pedantic.c  (test for warnings, line 8)
> ....
> 
> What architecture are you running the tests on?

As I said: "this change causes the following regressions for
cris-elf (only suspect in the range 124713:124716) and I'd be
surprised to see all pass for any target".  The cris-elf is my
usual cross-test target, see instructions in simtest-howto.html
(though dejagnu-1.4.4 lacks the baseboard, instructions in
<http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01571.html>).

If you don't like that target, pick another one.  Hm, perhaps
you won't see this on a target where char is default unsigned?
What target did *you* test on?  I don't see you mentioned the
target, but perhaps I missed it just like you did.

brgds, H-P

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-14 19:11                 ` Andrew Pinski
  2007-05-15  8:59                   ` Rafael Espindola
@ 2007-05-17  6:10                   ` Andrew Pinski
  2007-05-17 10:33                     ` Rafael Espindola
  2007-05-17 12:14                     ` Rafael Espindola
  1 sibling, 2 replies; 36+ messages in thread
From: Andrew Pinski @ 2007-05-17  6:10 UTC (permalink / raw)
  To: Mark Mitchell
  Cc: Rafael Espindola, Richard Guenther, Eric Botcazou, gcc-patches

On 5/14/07, Andrew Pinski <pinskia@gmail.com> wrote:
> On 5/11/07, Mark Mitchell <mark@codesourcery.com> wrote:
> > Rafael Espindola wrote:
> > >> I like the idea. I am currently bootstraping with the attached file.
> > >> OK for trunk if the regression tests are OK?
> > >
> > > Compiled with all languages enabled. No regressions found. OK for trunk?
> >
> > OK.
>
> And this breaks bootstrap as noted in:
> http://gcc.gnu.org/ml/gcc/2007-05/msg00354.html

And this still causes some regressions on spu-elf:
FAIL: gcc.dg/assign-warn-2.c  (test for errors, line 64)
FAIL: gcc.dg/assign-warn-2.c  (test for errors, line 65)
FAIL: gcc.dg/assign-warn-2.c  (test for errors, line 66)
etc.

We have now:
/home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/assign-warn-1.c:64:
warning: passing argument 1 of 'cubFp.x' from incompatible pointer
type
/home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/assign-warn-1.c:65:
warning: assignment from incompatible pointer type

While we are expecting:
64: warning: pointer targets in passing argument 1 of 'cubFp.x' differ
in signedness
65: warning: pointer targets in assignment differ in signedness

The code is doing an assignment from char* to unsigned char*.  And
char is unsigned by default on spu-elf.

gcc.dg/Wno-pointer-sign.c also fails the same way.

Likewise for some of the tests of gcc.dg/conv-2.c.

gcc.dg/pr28726.c now fails also with a warning.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-17  6:10                   ` Andrew Pinski
@ 2007-05-17 10:33                     ` Rafael Espindola
  2007-05-17 12:14                     ` Rafael Espindola
  1 sibling, 0 replies; 36+ messages in thread
From: Rafael Espindola @ 2007-05-17 10:33 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

> And this still causes some regressions on spu-elf:
> FAIL: gcc.dg/assign-warn-2.c  (test for errors, line 64)
> FAIL: gcc.dg/assign-warn-2.c  (test for errors, line 65)
> FAIL: gcc.dg/assign-warn-2.c  (test for errors, line 66)
> etc.

I am trying to create a cross compiler.  What options and versions do
you use to compile binutils, glibc and gcc?

> Thanks,
> Andrew Pinski
>


-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-17  6:10                   ` Andrew Pinski
  2007-05-17 10:33                     ` Rafael Espindola
@ 2007-05-17 12:14                     ` Rafael Espindola
  2007-05-17 22:05                       ` Andrew Pinski
  1 sibling, 1 reply; 36+ messages in thread
From: Rafael Espindola @ 2007-05-17 12:14 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 810 bytes --]

> We have now:
> /home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/assign-warn-1.c:64:
> warning: passing argument 1 of 'cubFp.x' from incompatible pointer
> type
> /home/apinski/src/local/gcc/gcc/testsuite/gcc.dg/assign-warn-1.c:65:
> warning: assignment from incompatible pointer type
>
> While we are expecting:
> 64: warning: pointer targets in passing argument 1 of 'cubFp.x' differ
> in signedness
> 65: warning: pointer targets in assignment differ in signedness
>
> The code is doing an assignment from char* to unsigned char*.  And
> char is unsigned by default on spu-elf.

From the description of the problem I would guess that the problem is
that we are returning char_type_node instead of
unsigned_char_type_node. Could you test the attached patch?

I am currently bootstraping it.

Cheers,
Rafael

[-- Attachment #2: fix.patch --]
[-- Type: text/x-patch, Size: 945 bytes --]

Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c	(revision 124790)
+++ gcc/c-common.c	(working copy)
@@ -2066,9 +2066,6 @@
 c_common_signed_or_unsigned_type (int unsignedp, tree type)
 {
   tree type1;
-  if (!INTEGRAL_TYPE_P (type)
-      || TYPE_UNSIGNED (type) == unsignedp)
-    return type;
 
   /* This block of code emulates the behavior of the old
      c_common_unsigned_type. In particular, it returns
@@ -2102,6 +2099,10 @@
   if (type1 == intQI_type_node || type1 == unsigned_intQI_type_node)
     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
 
+  if (!INTEGRAL_TYPE_P (type)
+      || TYPE_UNSIGNED (type) == unsignedp)
+    return type;
+
   /* For ENUMERAL_TYPEs in C++, must check the mode of the types, not
      the precision; they have precision set to match their range, but
      may use a wider mode to match an ABI.  If we change modes, we may

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-17 12:14                     ` Rafael Espindola
@ 2007-05-17 22:05                       ` Andrew Pinski
  2007-05-18 18:33                         ` Andrew Pinski
  0 siblings, 1 reply; 36+ messages in thread
From: Andrew Pinski @ 2007-05-17 22:05 UTC (permalink / raw)
  To: Rafael Espindola
  Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

On 5/17/07, Rafael Espindola <espindola@google.com> wrote:
> From the description of the problem I would guess that the problem is
> that we are returning char_type_node instead of
> unsigned_char_type_node. Could you test the attached patch?

I am testing this right on powerpc64-linux-gnu where the testcases also fail.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-17 22:05                       ` Andrew Pinski
@ 2007-05-18 18:33                         ` Andrew Pinski
  2007-05-18 23:59                           ` Rafael Espindola
  0 siblings, 1 reply; 36+ messages in thread
From: Andrew Pinski @ 2007-05-18 18:33 UTC (permalink / raw)
  To: Rafael Espindola
  Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

On 5/17/07, Andrew Pinski <pinskia@gmail.com> wrote:
> On 5/17/07, Rafael Espindola <espindola@google.com> wrote:
> > From the description of the problem I would guess that the problem is
> > that we are returning char_type_node instead of
> > unsigned_char_type_node. Could you test the attached patch?
>
> I am testing this right on powerpc64-linux-gnu where the testcases also fail.

Nope, these testcases still fail even after the patch you just sent.
I bet if you try doing -funsigned-char when compiling this testcase,
they will fail on i686-linux-gnu.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-18 18:33                         ` Andrew Pinski
@ 2007-05-18 23:59                           ` Rafael Espindola
  2007-05-19 18:05                             ` Andrew Pinski
  0 siblings, 1 reply; 36+ messages in thread
From: Rafael Espindola @ 2007-05-18 23:59 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

> Nope, these testcases still fail even after the patch you just sent.
> I bet if you try doing -funsigned-char when compiling this testcase,
> they will fail on i686-linux-gnu.

They did, and now I think I have the complete fix. The problem was
that with my patch, get_unsigned_type would return the wrong char
type. So tests like

unsigned_type_for(x) == unsigned_type_for(y)

would fail, because one call would return a "unsigned char" and the
other one a "char".

The attached patch fixed the problem on x86_64 + -funsigned_char.
Could you please give it a try?

> Thanks,
> Andrew Pinski
>

Thanks,
-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

[-- Attachment #2: fix.patch --]
[-- Type: text/x-patch, Size: 1467 bytes --]

--- gcc/c-common.c	(revision 124811)
+++ gcc/c-common.c	(local)
@@ -2066,9 +2066,6 @@ tree
 c_common_signed_or_unsigned_type (int unsignedp, tree type)
 {
   tree type1;
-  if (!INTEGRAL_TYPE_P (type)
-      || TYPE_UNSIGNED (type) == unsignedp)
-    return type;
 
   /* This block of code emulates the behavior of the old
      c_common_unsigned_type. In particular, it returns
@@ -2111,6 +2108,10 @@ c_common_signed_or_unsigned_type (int un
      types, and producing a signed or unsigned variant of an
      ENUMERAL_TYPE may cause other problems as well.  */
 
+  if (!INTEGRAL_TYPE_P (type)
+      || TYPE_UNSIGNED (type) == unsignedp)
+    return type;
+
 #define TYPE_OK(node)							    \
   (TYPE_MODE (type) == TYPE_MODE (node)					    \
    && (c_dialect_cxx () || TYPE_PRECISION (type) == TYPE_PRECISION (node)))
--- gcc/langhooks.c	(revision 124811)
+++ gcc/langhooks.c	(local)
@@ -579,9 +579,6 @@ lhd_builtin_function (tree decl)
 tree
 get_signed_or_unsigned_type (int unsignedp, tree type)
 {
-  if (!INTEGRAL_TYPE_P (type) || TYPE_UNSIGNED (type) == unsignedp)
-    return type;
-
   return lang_hooks.types.signed_or_unsigned_type(unsignedp, type);
 }
 
@@ -590,5 +587,8 @@ get_signed_or_unsigned_type (int unsigne
 tree
 lhd_signed_or_unsigned_type (int unsignedp, tree type)
 {
+  if (!INTEGRAL_TYPE_P (type) || TYPE_UNSIGNED (type) == unsignedp)
+    return type;
+
   return lang_hooks.types.type_for_size (TYPE_PRECISION (type), unsignedp);
 }

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-18 23:59                           ` Rafael Espindola
@ 2007-05-19 18:05                             ` Andrew Pinski
  2007-05-24  1:12                               ` Rafael Espindola
  0 siblings, 1 reply; 36+ messages in thread
From: Andrew Pinski @ 2007-05-19 18:05 UTC (permalink / raw)
  To: Rafael Espindola
  Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

On 5/18/07, Rafael Espindola <espindola@google.com> wrote:
> The attached patch fixed the problem on x86_64 + -funsigned_char.
> Could you please give it a try?

I cannot test this until Monday as the power is out in the office
today and tomorrow.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-19 18:05                             ` Andrew Pinski
@ 2007-05-24  1:12                               ` Rafael Espindola
  2007-05-24  1:14                                 ` Andrew Pinski
  0 siblings, 1 reply; 36+ messages in thread
From: Rafael Espindola @ 2007-05-24  1:12 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

> I cannot test this until Monday as the power is out in the office
> today and tomorrow.
Hi, did you managed to give it a try? Sorry to ping you, but I really
want to fix the problems my patch introduced.

I forgot to add a changelog entry. It is:

* c-common.c (c_common_signed_or_unsigned_type): Delay the check for
INTEGRAL_TYPE_P and TYPE_UNSIGNED.
* langhooks.c (get_signed_or_unsigned_type): Don't check for
INTEGRAL_TYPE_P or TYPE_UNSIGNED.
  (lhd_signed_or_unsigned_type): Check for INTEGRAL_TYPE_P and TYPE_UNSIGNED.

OK for trunk if it fixes the regressions on powerpc64?

> Thanks,
> Andrew Pinski
>

Thanks,
-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-24  1:12                               ` Rafael Espindola
@ 2007-05-24  1:14                                 ` Andrew Pinski
  2007-05-24  5:28                                   ` Rafael Espindola
  0 siblings, 1 reply; 36+ messages in thread
From: Andrew Pinski @ 2007-05-24  1:14 UTC (permalink / raw)
  To: Rafael Espindola
  Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

On 5/23/07, Rafael Espindola <espindola@google.com> wrote:
> > I cannot test this until Monday as the power is out in the office
> > today and tomorrow.
> Hi, did you managed to give it a try? Sorry to ping you, but I really
> want to fix the problems my patch introduced.

Sorry about not replying sooner but yes this fixes the testcases for me.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-24  1:14                                 ` Andrew Pinski
@ 2007-05-24  5:28                                   ` Rafael Espindola
  0 siblings, 0 replies; 36+ messages in thread
From: Rafael Espindola @ 2007-05-24  5:28 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Mark Mitchell, Richard Guenther, Eric Botcazou, gcc-patches

> Sorry about not replying sooner but yes this fixes the testcases for me.

I have committed the patch then. It bootstraps without regressions on
x86, x86-64 and fix a regression on powerpc.

> Thanks,
> Andrew Pinski
>

Thanks,
-- 
Rafael Avila de Espindonala

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
  2007-05-15  9:49 Uros Bizjak
@ 2007-05-15  9:54 ` Rafael Espindola
  0 siblings, 0 replies; 36+ messages in thread
From: Rafael Espindola @ 2007-05-15  9:54 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

> Bootstrap and testsuites fail on i686-pc-linux-gnu, but everything
> works on x86_64-pc-linux-gnu.

I am working on a partial revert + debug patch (calling both functions
on c-format and printing the debug_tree).

> Uros.
>


-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH] remove the unsigned_type language hook
@ 2007-05-15  9:49 Uros Bizjak
  2007-05-15  9:54 ` Rafael Espindola
  0 siblings, 1 reply; 36+ messages in thread
From: Uros Bizjak @ 2007-05-15  9:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Rafael Espindola

Hello!

>>    And this breaks bootstrap as noted in:
>>    http://gcc.gnu.org/ml/gcc/2007-05/msg00354.html

> I have just bootstrap trunk just after my patch was committed. I am
> using a linux x86-64 machine. In which architecture is it failing?

Bootstrap and testsuites fail on i686-pc-linux-gnu, but everything
works on x86_64-pc-linux-gnu.

Uros.

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2007-05-24  5:28 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-03  9:42 [PATCH] remove the unsigned_type language hook Rafael Espindola
2007-05-08 10:30 ` Eric Botcazou
2007-05-08 12:45   ` Rafael Espindola
2007-05-08 13:23     ` Richard Guenther
2007-05-08 13:29     ` Richard Kenner
2007-05-08 14:19       ` Eric Botcazou
2007-05-08 14:25         ` Richard Guenther
2007-05-08 14:36           ` Richard Kenner
2007-05-08 14:32         ` Richard Kenner
2007-05-08 17:33           ` Eric Botcazou
2007-05-08 17:37 ` Eric Botcazou
2007-05-09 17:57   ` Rafael Espindola
2007-05-09 20:42     ` Eric Botcazou
2007-05-09 20:54       ` Rafael Espindola
2007-05-09 21:03         ` Richard Guenther
2007-05-10 16:37           ` Rafael Espindola
2007-05-11  8:34             ` Rafael Espindola
2007-05-11 19:25               ` Mark Mitchell
2007-05-14 19:11                 ` Andrew Pinski
2007-05-15  8:59                   ` Rafael Espindola
2007-05-17  6:10                   ` Andrew Pinski
2007-05-17 10:33                     ` Rafael Espindola
2007-05-17 12:14                     ` Rafael Espindola
2007-05-17 22:05                       ` Andrew Pinski
2007-05-18 18:33                         ` Andrew Pinski
2007-05-18 23:59                           ` Rafael Espindola
2007-05-19 18:05                             ` Andrew Pinski
2007-05-24  1:12                               ` Rafael Espindola
2007-05-24  1:14                                 ` Andrew Pinski
2007-05-24  5:28                                   ` Rafael Espindola
2007-05-14 19:45 ` Mike Stump
2007-05-14 20:24 ` Regressions from " Hans-Peter Nilsson
2007-05-15  9:09   ` Rafael Espindola
2007-05-15 10:13     ` Hans-Peter Nilsson
2007-05-15  9:49 Uros Bizjak
2007-05-15  9:54 ` Rafael Espindola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).