This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] remove signed(_or_unsigned)?_type langhooks


I did some additional testing on i686, and found more places were the
C front end needs to distinguish between types with the same size and
sign. Instead of trying to find one by one, I just edited the patch so
that all "c-*" files call the C specific implementation.

I also added a small code factoring in the implementation of the
c_common_(signed|unsigned)?_type. They just call
c_common_signed_or_unsigned now.

This patch was bootstrapped and tested on i686 and x86_64. All
languages enabled. No regressions were found.

The new ChangeLog entries are:

* gcc/c-format.c (check_format_types): Use c_common_unsigned_type
instead of unsigned_type_for.
* gcc/c-decl.c (groakdeclarator): Likewise.
* gcc/c-typeck.c (convert_for_assignment): Likewise.
* gcc/c-common.c (c_common_unsigned_type): New.
(c_common_signed_type): Just call c_common_signed_or_unsigned_type.
(shorten_compare): Use c_common_unsigned_type instead of
c_common_signed_or_unsigned_type.
(c_common_nodes_and_builtins): Use c_common_unsigned_type instead of
unsigned_type_for.
* gcc/c-common.h (c_common_unsigned_type): New.


Cheers, Rafael
--- gcc/java/typeck.c	(/gcc/trunk)	(revision 125384)
+++ gcc/java/typeck.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -195,14 +195,6 @@ java_type_for_size (unsigned bits, int u
   return 0;
 }
 
-/* Return a signed type the same as TYPE in other respects.  */
-
-tree
-java_signed_type (tree type)
-{
-  return get_signed_or_unsigned_type (0, 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/java/lang.c	(/gcc/trunk)	(revision 125384)
+++ gcc/java/lang.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -182,8 +182,6 @@ struct language_function GTY(())
 #define LANG_HOOKS_TYPE_FOR_MODE java_type_for_mode
 #undef LANG_HOOKS_TYPE_FOR_SIZE
 #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_TREE_DUMP_DUMP_TREE_FN
 #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN java_dump_tree
--- gcc/java/java-tree.h	(/gcc/trunk)	(revision 125384)
+++ gcc/java/java-tree.h	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -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_signed_type (tree);
 extern tree java_truthvalue_conversion (tree);
 extern void add_assume_compiled (const char *, int);
 extern void add_enable_assert (const char *, int);
--- gcc/tree.c	(/gcc/trunk)	(revision 125384)
+++ gcc/tree.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -7730,13 +7730,21 @@ int_cst_value (tree x)
   return val;
 }
 
+/* If TYPE is an integral type, return an equivalent type which is
+    unsigned iff UNSIGNEDP is true.  If TYPE is not an integral type,
+    return TYPE itself.  */
 
-/* Return an unsigned type the same as TYPE in other respects.  */
-
-static tree
-get_unsigned_type (tree type)
+tree
+signed_or_unsigned_type_for (int unsignedp, tree type)
 {
-  return get_signed_or_unsigned_type (1, type);
+  tree t = type;
+  if (POINTER_TYPE_P (type))
+    t = size_type_node;
+
+  if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
+    return t;
+  
+  return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
 }
 
 /* Returns unsigned variant of TYPE.  */
@@ -7744,9 +7752,7 @@ get_unsigned_type (tree type)
 tree
 unsigned_type_for (tree type)
 {
-  if (POINTER_TYPE_P (type))
-    return get_unsigned_type (size_type_node);
-  return get_unsigned_type (type);
+  return signed_or_unsigned_type_for (1, type);
 }
 
 /* Returns signed variant of TYPE.  */
@@ -7754,9 +7760,7 @@ unsigned_type_for (tree type)
 tree
 signed_type_for (tree type)
 {
-  if (POINTER_TYPE_P (type))
-    return lang_hooks.types.signed_type (size_type_node);
-  return lang_hooks.types.signed_type (type);
+  return signed_or_unsigned_type_for (0, type);
 }
 
 /* Returns the largest value obtainable by casting something in INNER type to
--- gcc/tree.h	(/gcc/trunk)	(revision 125384)
+++ gcc/tree.h	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -3770,6 +3770,7 @@ extern tree build_call_array (tree, tree
 
 extern tree make_signed_type (int);
 extern tree make_unsigned_type (int);
+extern tree signed_or_unsigned_type_for (int, tree);
 extern tree signed_type_for (tree);
 extern tree unsigned_type_for (tree);
 extern void initialize_sizetypes (bool);
@@ -3814,8 +3815,6 @@ extern bool tree_expr_nonnegative_warnv_
 extern bool may_negate_without_overflow_p (tree);
 extern tree get_inner_array_type (tree);
 
-extern tree get_signed_or_unsigned_type (int unsignedp, 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
    tree.h had been included.  */
--- gcc/fold-const.c	(/gcc/trunk)	(revision 125384)
+++ gcc/fold-const.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -1410,7 +1410,7 @@ fold_negate_expr (tree t)
 		 == TREE_INT_CST_LOW (op1))
 	    {
 	      tree ntype = TYPE_UNSIGNED (type)
-			   ? lang_hooks.types.signed_type (type)
+			   ? signed_type_for (type)
 			   : unsigned_type_for (type);
 	      tree temp = fold_convert (ntype, TREE_OPERAND (t, 0));
 	      temp = fold_build2 (RSHIFT_EXPR, ntype, temp, op1);
@@ -2028,7 +2028,7 @@ size_diffop (tree arg0, tree arg1)
   else if (type == bitsizetype)
     ctype = sbitsizetype;
   else
-    ctype = lang_hooks.types.signed_type (type);
+    ctype = signed_type_for (type);
 
   /* If either operand is not a constant, do the conversions to the signed
      type and subtract.  The hardware will do the right thing with any
@@ -3045,7 +3045,7 @@ operand_equal_for_comparison_p (tree arg
 
       /* Make sure shorter operand is extended the right way
 	 to match the longer operand.  */
-      primarg1 = fold_convert (get_signed_or_unsigned_type
+      primarg1 = fold_convert (signed_or_unsigned_type_for
 			       (unsignedp1, TREE_TYPE (primarg1)), primarg1);
 
       if (operand_equal_p (arg0, fold_convert (type, primarg1), 0))
@@ -3828,7 +3828,7 @@ all_ones_mask_p (tree mask, int size)
   unsigned int precision = TYPE_PRECISION (type);
   tree tmask;
 
-  tmask = build_int_cst_type (lang_hooks.types.signed_type (type), -1);
+  tmask = build_int_cst_type (signed_type_for (type), -1);
 
   return
     tree_int_cst_equal (mask,
@@ -4382,7 +4382,7 @@ build_range_check (tree type, tree exp, 
 	{
 	  if (TYPE_UNSIGNED (etype))
 	    {
-	      etype = lang_hooks.types.signed_type (etype);
+	      etype = signed_type_for (etype);
 	      exp = fold_convert (etype, exp);
 	    }
 	  return fold_build2 (GT_EXPR, type, exp,
@@ -4740,7 +4740,7 @@ fold_cond_expr_with_comparison (tree typ
       case GE_EXPR:
       case GT_EXPR:
 	if (TYPE_UNSIGNED (TREE_TYPE (arg1)))
-	  arg1 = fold_convert (lang_hooks.types.signed_type
+	  arg1 = fold_convert (signed_type_for
 			       (TREE_TYPE (arg1)), arg1);
 	tem = fold_build1 (ABS_EXPR, TREE_TYPE (arg1), arg1);
 	return pedantic_non_lvalue (fold_convert (type, tem));
@@ -4751,7 +4751,7 @@ fold_cond_expr_with_comparison (tree typ
       case LE_EXPR:
       case LT_EXPR:
 	if (TYPE_UNSIGNED (TREE_TYPE (arg1)))
-	  arg1 = fold_convert (lang_hooks.types.signed_type
+	  arg1 = fold_convert (signed_type_for
 			       (TREE_TYPE (arg1)), arg1);
 	tem = fold_build1 (ABS_EXPR, TREE_TYPE (arg1), arg1);
 	return negate_expr (fold_convert (type, tem));
@@ -5059,7 +5059,7 @@ unextend (tree c, int p, int unsignedp, 
      zero or one, and the conversion to a signed type can never overflow.
      We could get an overflow if this conversion is done anywhere else.  */
   if (TYPE_UNSIGNED (type))
-    temp = fold_convert (lang_hooks.types.signed_type (type), temp);
+    temp = fold_convert (signed_type_for (type), temp);
 
   temp = const_binop (LSHIFT_EXPR, temp, size_int (modesize - 1), 0);
   temp = const_binop (RSHIFT_EXPR, temp, size_int (modesize - p - 1), 0);
@@ -5731,7 +5731,7 @@ extract_muldiv_1 (tree t, tree c, enum t
          must avoid building ABS_EXPR itself as unsigned.  */
       if (TYPE_UNSIGNED (ctype) && !TYPE_UNSIGNED (type))
         {
-          tree cstype = (*lang_hooks.types.signed_type) (ctype);
+          tree cstype = (*signed_type_for) (ctype);
           if ((t1 = extract_muldiv (op0, c, code, cstype, strict_overflow_p))
 	      != 0)
             {
@@ -6542,7 +6542,7 @@ fold_single_bit_test_into_sign_test (enu
 	  && TYPE_PRECISION (TREE_TYPE (arg00))
 	     == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (arg00))))
 	{
-	  tree stype = lang_hooks.types.signed_type (TREE_TYPE (arg00));
+	  tree stype = signed_type_for (TREE_TYPE (arg00));
 	  return fold_build2 (code == EQ_EXPR ? GE_EXPR : LT_EXPR,
 			      result_type, fold_convert (stype, arg00),
 			      build_int_cst (stype, 0));
@@ -11380,7 +11380,7 @@ fold_binary (enum tree_code code, tree t
 	    {
 	      if (TYPE_UNSIGNED (itype))
 		{
-		  itype = lang_hooks.types.signed_type (itype);
+		  itype = signed_type_for (itype);
 		  arg00 = fold_convert (itype, arg00);
 		}
 	      return fold_build2 (code == EQ_EXPR ? GE_EXPR : LT_EXPR,
@@ -11933,7 +11933,7 @@ fold_binary (enum tree_code code, tree t
 		if (code == LE_EXPR || code == GT_EXPR)
 		  {
 		    tree st;
-		    st = lang_hooks.types.signed_type (TREE_TYPE (arg1));
+		    st = signed_type_for (TREE_TYPE (arg1));
 		    return fold_build2 (code == LE_EXPR ? GE_EXPR : LT_EXPR,
 					type, fold_convert (st, arg0),
 					build_int_cst (st, 0));
@@ -12323,7 +12323,7 @@ fold_ternary (enum tree_code code, tree 
 	      if ((TREE_INT_CST_HIGH (arg1) & mask_hi) == mask_hi
 		  && (TREE_INT_CST_LOW (arg1) & mask_lo) == mask_lo)
 		{
-		  tem_type = lang_hooks.types.signed_type (TREE_TYPE (tem));
+		  tem_type = signed_type_for (TREE_TYPE (tem));
 		  tem = fold_convert (tem_type, tem);
 		}
 	      else if ((TREE_INT_CST_HIGH (arg1) & mask_hi) == 0
--- gcc/cp/cp-objcp-common.h	(/gcc/trunk)	(revision 125384)
+++ gcc/cp/cp-objcp-common.h	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -134,10 +134,6 @@ extern tree objcp_tsubst_copy_and_build 
 #define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode
 #undef LANG_HOOKS_TYPE_FOR_SIZE
 #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_SIGNED_OR_UNSIGNED_TYPE
-#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
 #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
 #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR cxx_incomplete_type_error
 #undef LANG_HOOKS_TYPE_PROMOTES_TO
--- gcc/c-objc-common.h	(/gcc/trunk)	(revision 125384)
+++ gcc/c-objc-common.h	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -102,10 +102,6 @@ extern void c_initialize_diagnostics (di
 #define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode
 #undef LANG_HOOKS_TYPE_FOR_SIZE
 #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_SIGNED_OR_UNSIGNED_TYPE
-#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE c_common_signed_or_unsigned_type
 #undef LANG_HOOKS_INCOMPLETE_TYPE_ERROR
 #define LANG_HOOKS_INCOMPLETE_TYPE_ERROR c_incomplete_type_error
 #undef LANG_HOOKS_TYPE_PROMOTES_TO
--- gcc/c-format.c	(/gcc/trunk)	(revision 125384)
+++ gcc/c-format.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -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 == unsigned_type_for (cur_type)
+	      ? wanted_type == c_common_unsigned_type (cur_type)
 	      : wanted_type == c_common_signed_type (cur_type)))
 	continue;
       /* Likewise, "signed char", "unsigned char" and "char" are
--- gcc/expr.c	(/gcc/trunk)	(revision 125384)
+++ gcc/expr.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -4394,7 +4394,7 @@ store_expr (tree exp, rtx target, int ca
 	      /* Some types, e.g. Fortran's logical*4, won't have a signed
 		 version, so use the mode instead.  */
 	      tree ntype
-		= (get_signed_or_unsigned_type
+		= (signed_or_unsigned_type_for
 		   (SUBREG_PROMOTED_UNSIGNED_P (target), TREE_TYPE (exp)));
 	      if (ntype == NULL)
 		ntype = lang_hooks.types.type_for_mode
--- gcc/ada/trans.c	(/gcc/trunk)	(revision 125384)
+++ gcc/ada/trans.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -876,8 +876,8 @@ Attribute_to_gnu (Node_Id gnat_node, tre
 	  /* 'Length or 'Range_Length.  */
 	  {
 	    tree gnu_compute_type
-	      = get_signed_or_unsigned_type (0,
-					      get_base_type (gnu_result_type));
+	      = signed_or_unsigned_type_for (0,
+					     get_base_type (gnu_result_type));
 
 	    gnu_result
 	      = build_binary_op
--- gcc/ada/misc.c	(/gcc/trunk)	(revision 125384)
+++ gcc/ada/misc.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -157,8 +157,6 @@ static tree gnat_type_max_size		(tree);
 #define LANG_HOOKS_TYPE_FOR_MODE	gnat_type_for_mode
 #undef  LANG_HOOKS_TYPE_FOR_SIZE
 #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_ATTRIBUTE_TABLE
 #define LANG_HOOKS_ATTRIBUTE_TABLE	gnat_internal_attribute_table
 #undef  LANG_HOOKS_BUILTIN_FUNCTION
--- gcc/c-decl.c	(/gcc/trunk)	(revision 125384)
+++ gcc/c-decl.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -4074,7 +4074,7 @@ grokdeclarator (const struct c_declarato
      "signed".  */
   if (bitfield && !flag_signed_bitfields && !declspecs->explicit_signed_p
       && TREE_CODE (type) == INTEGER_TYPE)
-    type = unsigned_type_for (type);
+    type = c_common_unsigned_type (type);
 
   /* Figure out the type qualifiers for the declaration.  There are
      two ways a declaration can become qualified.  One is something
--- gcc/fortran/trans-types.c	(/gcc/trunk)	(revision 125384)
+++ gcc/fortran/trans-types.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -1847,12 +1847,4 @@ gfc_type_for_mode (enum machine_mode mod
   return NULL_TREE;
 }
 
-/* Return a signed type the same as TYPE in other respects.  */
-
-tree
-gfc_signed_type (tree type)
-{
-  return get_signed_or_unsigned_type (0, type);
-}
-
 #include "gt-fortran-trans-types.h"
--- gcc/fortran/trans-types.h	(/gcc/trunk)	(revision 125384)
+++ gcc/fortran/trans-types.h	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -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_signed_type (tree);
 
 tree gfc_get_element_type (tree);
 tree gfc_get_array_type_bounds (tree, int, tree *, tree *, int);
--- gcc/fortran/f95-lang.c	(/gcc/trunk)	(revision 125384)
+++ gcc/fortran/f95-lang.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -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_SIGNED_TYPE
 #undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
 #undef LANG_HOOKS_CLEAR_BINDING_STACK
 #undef LANG_HOOKS_GET_ALIAS_SET
@@ -137,7 +136,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_SIGNED_TYPE             gfc_signed_type
 #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gfc_expand_function
 #define LANG_HOOKS_CLEAR_BINDING_STACK     gfc_clear_binding_stack
 #define LANG_HOOKS_GET_ALIAS_SET	   gfc_get_alias_set
--- gcc/langhooks.c	(/gcc/trunk)	(revision 125384)
+++ gcc/langhooks.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -570,24 +570,3 @@ lhd_builtin_function (tree decl)
   lang_hooks.decls.pushdecl (decl);
   return decl;
 }
-
-/* If TYPE is an integral type, return an equivalent type which is
-    unsigned iff UNSIGNEDP is true.  If TYPE is not an integral type,
-    return TYPE itself.  */
-
-tree
-get_signed_or_unsigned_type (int unsignedp, tree type)
-{
-  return lang_hooks.types.signed_or_unsigned_type(unsignedp, type);
-}
-
-/* Default implementation of the signed_or_unsigned_type language hook */
-
-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);
-}
--- gcc/langhooks.h	(/gcc/trunk)	(revision 125384)
+++ gcc/langhooks.h	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -103,14 +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 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);
-
   /* True if the type is an instantiation of a generic type,
      e.g. C++ template implicit specializations.  */
   bool (*generic_p) (tree);
@@ -445,6 +437,5 @@ extern tree add_builtin_function (const 
 				  int function_code, enum built_in_class cl,
 				  const char *library_name,
 				  tree attrs);
-extern tree lhd_signed_or_unsigned_type (int unsignedp, tree type);
 
 #endif /* GCC_LANG_HOOKS_H */
--- gcc/c-typeck.c	(/gcc/trunk)	(revision 125384)
+++ gcc/c-typeck.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -4098,8 +4098,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
-	  || (unsigned_type_for (mvl)
-	      == unsigned_type_for (mvr)))
+	  || (c_common_unsigned_type (mvl)
+	      == c_common_unsigned_type (mvr)))
 	{
 	  if (pedantic
 	      && ((VOID_TYPE_P (ttl) && TREE_CODE (ttr) == FUNCTION_TYPE)
--- gcc/treelang/treetree.c	(/gcc/trunk)	(revision 125384)
+++ gcc/treelang/treetree.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -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_signed_type (tree type_node);
 
 /* Functions to keep track of the current scope.  */
 static void pushlevel (int ignore);
@@ -150,8 +149,6 @@ static void treelang_expand_function (tr
 
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #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_TYPE_FOR_MODE
 #define LANG_HOOKS_TYPE_FOR_MODE tree_lang_type_for_mode
 #undef LANG_HOOKS_TYPE_FOR_SIZE
@@ -862,14 +859,6 @@ tree_lang_type_for_mode (enum machine_mo
     return NULL_TREE;
 }
 
-/* Return the signed version of a TYPE_NODE, a scalar type.  */
-
-static tree
-tree_lang_signed_type (tree type_node)
-{
-  return tree_lang_type_for_size (TYPE_PRECISION (type_node), 0);
-}
-
 
 /* These functions and variables deal with binding contours.  We only
    need these functions for the list of PARM_DECLs, but we leave the
--- gcc/expmed.c	(/gcc/trunk)	(revision 125384)
+++ gcc/expmed.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -5050,14 +5050,14 @@ make_tree (tree type, rtx x)
 				    	 make_tree (type, XEXP (x, 1))));
 
     case ASHIFTRT:
-      t = lang_hooks.types.signed_type (type);
+      t = signed_type_for (type);
       return fold_convert (type, build2 (RSHIFT_EXPR, t,
 					 make_tree (t, XEXP (x, 0)),
 				    	 make_tree (type, XEXP (x, 1))));
 
     case DIV:
       if (TREE_CODE (type) != REAL_TYPE)
-	t = lang_hooks.types.signed_type (type);
+	t = signed_type_for (type);
       else
 	t = type;
 
--- gcc/c-common.c	(/gcc/trunk)	(revision 125384)
+++ gcc/c-common.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -1343,7 +1343,7 @@ warnings_for_convert_and_check (tree typ
           else
             conversion_warning (type, expr);
         }
-      else if (!int_fits_type_p (expr, unsigned_type_for (type))) 
+      else if (!int_fits_type_p (expr, c_common_unsigned_type (type))) 
 	warning (OPT_Woverflow,
 		 "overflow in implicit constant conversion");
       /* No warning for converting 0x80000000 to int.  */
@@ -2038,37 +2038,17 @@ c_common_type_for_mode (enum machine_mod
   return 0;
 }
 
+tree
+c_common_unsigned_type (tree type)
+{
+  return c_common_signed_or_unsigned_type (1, type);
+}
+
 /* Return a signed type the same as TYPE in other respects.  */
 
 tree
 c_common_signed_type (tree type)
 {
-  tree type1 = TYPE_MAIN_VARIANT (type);
-  if (type1 == unsigned_char_type_node || type1 == char_type_node)
-    return signed_char_type_node;
-  if (type1 == unsigned_type_node)
-    return integer_type_node;
-  if (type1 == short_unsigned_type_node)
-    return short_integer_type_node;
-  if (type1 == long_unsigned_type_node)
-    return long_integer_type_node;
-  if (type1 == long_long_unsigned_type_node)
-    return long_long_integer_type_node;
-  if (type1 == widest_unsigned_literal_type_node)
-    return widest_integer_literal_type_node;
-#if HOST_BITS_PER_WIDE_INT >= 64
-  if (type1 == unsigned_intTI_type_node)
-    return intTI_type_node;
-#endif
-  if (type1 == unsigned_intDI_type_node)
-    return intDI_type_node;
-  if (type1 == unsigned_intSI_type_node)
-    return intSI_type_node;
-  if (type1 == unsigned_intHI_type_node)
-    return intHI_type_node;
-  if (type1 == unsigned_intQI_type_node)
-    return intQI_type_node;
-
   return c_common_signed_or_unsigned_type (0, type);
 }
 
@@ -2515,8 +2495,7 @@ shorten_compare (tree *op0_ptr, tree *op
 	      default:
 		break;
 	      }
-	  /* unsigned_type_for doesn't support C bit fields */
-	  type = c_common_signed_or_unsigned_type (1, type);
+	  type = c_common_unsigned_type (type);
 	}
 
       if (TREE_CODE (primop0) != INTEGER_CST)
@@ -3686,7 +3665,7 @@ c_common_nodes_and_builtins (void)
   else
     {
       signed_wchar_type_node = c_common_signed_type (wchar_type_node);
-      unsigned_wchar_type_node = unsigned_type_for (wchar_type_node);
+      unsigned_wchar_type_node = c_common_unsigned_type (wchar_type_node);
     }
 
   /* This is for wide string constants.  */
@@ -3704,7 +3683,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 = unsigned_type_for (ptrdiff_type_node);
+  unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
 
   lang_hooks.decls.pushdecl
     (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
@@ -6919,8 +6898,8 @@ same_scalar_type_ignoring_signedness (tr
 
   /* Equality works here because c_common_signed_type uses
      TYPE_MAIN_VARIANT.  */
-  return lang_hooks.types.signed_type (t1)
-    == lang_hooks.types.signed_type (t2);
+  return c_common_signed_type (t1)
+    == c_common_signed_type (t2);
 }
 
 /* Check for missing format attributes on function pointers.  LTYPE is
--- gcc/c-common.h	(/gcc/trunk)	(revision 125384)
+++ gcc/c-common.h	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -667,6 +667,7 @@ 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/convert.c	(/gcc/trunk)	(revision 125384)
+++ gcc/convert.c	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -658,7 +658,7 @@ convert_to_integer (tree type, tree expr
 				|| ex_form == MINUS_EXPR)))
 		      typex = unsigned_type_for (typex);
 		    else
-		      typex = lang_hooks.types.signed_type (typex);
+		      typex = signed_type_for (typex);
 		    return convert (type,
 				    fold_build2 (ex_form, typex,
 						 convert (typex, arg0),
@@ -680,7 +680,7 @@ convert_to_integer (tree type, tree expr
 	    if (TYPE_UNSIGNED (TREE_TYPE (expr)))
 	      typex = unsigned_type_for (type);
 	    else
-	      typex = lang_hooks.types.signed_type (type);
+	      typex = signed_type_for (type);
 	    return convert (type,
 			    fold_build1 (ex_form, typex,
 					 convert (typex,
--- gcc/langhooks-def.h	(/gcc/trunk)	(revision 125384)
+++ gcc/langhooks-def.h	(/local/remove-signed_or_unsigned_type)	(revision 125384)
@@ -120,7 +120,6 @@ extern void lhd_omp_firstprivatize_type_
 #define LANG_HOOKS_TREE_SIZE		lhd_tree_size
 #define LANG_HOOKS_TYPES_COMPATIBLE_P	lhd_types_compatible_p
 #define LANG_HOOKS_BUILTIN_FUNCTION	lhd_builtin_function
-#define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE	lhd_signed_or_unsigned_type
 #define LANG_HOOKS_EXPR_TO_DECL		lhd_expr_to_decl
 #define LANG_HOOKS_TO_TARGET_CHARSET	lhd_to_target_charset
 #define LANG_HOOKS_INIT_TS		lhd_do_nothing
@@ -207,8 +206,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_SIGNED_TYPE, \
-  LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE, \
   LANG_HOOKS_GENERIC_TYPE_P, \
   LANG_HOOKS_TYPE_PROMOTES_TO, \
   LANG_HOOKS_REGISTER_BUILTIN_TYPE, \

Property changes on: 
___________________________________________________________________
Name: svk:merge
 +138bc75d-0d04-0410-961f-82ee72b054a4:/trunk:125328
  23c3ee16-a423-49b3-8738-b114dc1aabb6:/local/gcc-clean:839
  23c3ee16-a423-49b3-8738-b114dc1aabb6:/local/gcc-pta-dev:259
  23c3ee16-a423-49b3-8738-b114dc1aabb6:/local/gcc-trunk:531


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]