]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree.c (signed_or_unsigned_type_for): Use build_nonstandard_integer_type.
authorRichard Guenther <rguenther@suse.de>
Mon, 12 Mar 2012 13:04:43 +0000 (13:04 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 12 Mar 2012 13:04:43 +0000 (13:04 +0000)
2012-03-12  Richard Guenther  <rguenther@suse.de>

* tree.c (signed_or_unsigned_type_for): Use
build_nonstandard_integer_type.
(signed_type_for): Adjust documentation.
(unsigned_type_for): Likewise.
* tree-pretty-print.c (dump_generic_node): Use standard names
for non-standard integer types if available.

From-SVN: r185226

gcc/ChangeLog
gcc/tree-pretty-print.c
gcc/tree.c

index faddb0bcb7aac2231f824a1438fadfb69c713d7e..76ec87daa6dd6c9752d4844c8ce2b75dcea90763 100644 (file)
@@ -1,3 +1,12 @@
+2012-03-12  Richard Guenther  <rguenther@suse.de>
+
+       * tree.c (signed_or_unsigned_type_for): Use
+       build_nonstandard_integer_type.
+       (signed_type_for): Adjust documentation.
+       (unsigned_type_for): Likewise.
+       * tree-pretty-print.c (dump_generic_node): Use standard names
+       for non-standard integer types if available.
+
 2012-03-12  Tristan Gingold  <gingold@adacore.com>
 
        * config/vms/vms.opt: Add vms-opts.h header.
index 4b9b4536641469a999a26fba7201421c4a372989..227999cd0d609be7577ed98e479b8a1e78b269f4 100644 (file)
@@ -723,11 +723,41 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
              }
            else if (TREE_CODE (node) == INTEGER_TYPE)
              {
-               pp_string (buffer, (TYPE_UNSIGNED (node)
-                                   ? "<unnamed-unsigned:"
-                                   : "<unnamed-signed:"));
-               pp_decimal_int (buffer, TYPE_PRECISION (node));
-               pp_string (buffer, ">");
+               if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
+                 pp_string (buffer, (TYPE_UNSIGNED (node)
+                                     ? "unsigned char"
+                                     : "signed char"));
+               else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
+                 pp_string (buffer, (TYPE_UNSIGNED (node)
+                                     ? "unsigned short"
+                                     : "signed short"));
+               else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
+                 pp_string (buffer, (TYPE_UNSIGNED (node)
+                                     ? "unsigned int"
+                                     : "signed int"));
+               else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
+                 pp_string (buffer, (TYPE_UNSIGNED (node)
+                                     ? "unsigned long"
+                                     : "signed long"));
+               else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
+                 pp_string (buffer, (TYPE_UNSIGNED (node)
+                                     ? "unsigned long long"
+                                     : "signed long long"));
+               else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
+                        && exact_log2 (TYPE_PRECISION (node)))
+                 {
+                   pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
+                   pp_decimal_int (buffer, TYPE_PRECISION (node));
+                   pp_string (buffer, "_t");
+                 }
+               else
+                 {
+                   pp_string (buffer, (TYPE_UNSIGNED (node)
+                                       ? "<unnamed-unsigned:"
+                                       : "<unnamed-signed:"));
+                   pp_decimal_int (buffer, TYPE_PRECISION (node));
+                   pp_string (buffer, ">");
+                 }
              }
            else if (TREE_CODE (node) == COMPLEX_TYPE)
              {
index c5d10f99bdc84dd98ce6ac5f98b141823e5c154f..3989a9b1b6a5b90ff88e7041a2740eabee9509af 100644 (file)
@@ -10197,32 +10197,26 @@ widest_int_cst_value (const_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.  */
+/* If TYPE is an integral or pointer type, return an integer type with
+   the same precision which is unsigned iff UNSIGNEDP is true, or itself
+   if TYPE is already an integer type of signedness UNSIGNEDP.  */
 
 tree
 signed_or_unsigned_type_for (int unsignedp, tree type)
 {
-  tree t = type;
-  if (POINTER_TYPE_P (type))
-    {
-      /* If the pointer points to the normal address space, use the
-        size_type_node.  Otherwise use an appropriate size for the pointer
-        based on the named address space it points to.  */
-      if (!TYPE_ADDR_SPACE (TREE_TYPE (t)))
-       t = size_type_node;
-      else
-       return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
-    }
+  if (TREE_CODE (type) == INTEGER_TYPE && TYPE_UNSIGNED (type) == unsignedp)
+    return type;
 
-  if (!INTEGRAL_TYPE_P (t) || TYPE_UNSIGNED (t) == unsignedp)
-    return t;
+  if (!INTEGRAL_TYPE_P (type)
+      && !POINTER_TYPE_P (type))
+    return NULL_TREE;
 
-  return lang_hooks.types.type_for_size (TYPE_PRECISION (t), unsignedp);
+  return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp);
 }
 
-/* Returns unsigned variant of TYPE.  */
+/* If TYPE is an integral or pointer type, return an integer type with
+   the same precision which is unsigned, or itself if TYPE is already an
+   unsigned integer type.  */
 
 tree
 unsigned_type_for (tree type)
@@ -10230,7 +10224,9 @@ unsigned_type_for (tree type)
   return signed_or_unsigned_type_for (1, type);
 }
 
-/* Returns signed variant of TYPE.  */
+/* If TYPE is an integral or pointer type, return an integer type with
+   the same precision which is signed, or itself if TYPE is already a
+   signed integer type.  */
 
 tree
 signed_type_for (tree type)