fold-const.c (fold_comparison): Use ssizetype.
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 18 Apr 2010 21:49:29 +0000 (21:49 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 18 Apr 2010 21:49:29 +0000 (21:49 +0000)
2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>

* fold-const.c (fold_comparison): Use ssizetype.
* gimple-fold.c (maybe_fold_offset_to_array_ref): Likewise.
* ipa-prop.c (ipa_modify_call_arguments): Use sizetype.
* tree-loop-distribution.c (build_size_arg_loc): Likewise.
* tree-object-size.c (compute_object_sizes): Use size_type_node.

* tree.h (initialize_sizetypes): Remove parameter.
(build_common_tree_nodes): Remove second parameter.
* stor-layout.c (initialize_sizetypes): Remove parameter.
Always create an unsigned type.
(set_sizetype): Assert that the passed type is unsigned and simplify.
* tree.c (build_common_tree_nodes): Remove second parameter.
Adjust call to initialize_sizetypes.
* c-decl.c (c_init_decl_processing): Remove second argument in call to
build_common_tree_nodes.
cp/
* decl.c (cxx_init_decl_processing): Remove second argument in call to
build_common_tree_nodes.
java/
* decl.c (java_init_decl_processing): Remove argument in call to
initialize_sizetypes
fortran/
* f95-lang.c (gfc_init_decl_processing): Remove second argument in call
to build_common_tree_nodes.
ada/
* gcc-interface/misc.c (gnat_init): Remove second argument in call to
build_common_tree_nodes.
lto/
* lto-lang.c (lto_init): Remove second argument in call to
build_common_tree_nodes.

From-SVN: r158496

20 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/misc.c
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/fold-const.c
gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/gimple-fold.c
gcc/ipa-prop.c
gcc/java/ChangeLog
gcc/java/decl.c
gcc/lto/ChangeLog
gcc/lto/lto-lang.c
gcc/stor-layout.c
gcc/tree-loop-distribution.c
gcc/tree-object-size.c
gcc/tree.c
gcc/tree.h

index 024b7e66c1ba038a1fac77bde7df02a997c402aa..2490cb2b0e4781da26969521f9c45b585868c2d3 100644 (file)
@@ -1,3 +1,21 @@
+2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * fold-const.c (fold_comparison): Use ssizetype.
+       * gimple-fold.c (maybe_fold_offset_to_array_ref): Likewise.
+       * ipa-prop.c (ipa_modify_call_arguments): Use sizetype.
+       * tree-loop-distribution.c (build_size_arg_loc): Likewise.
+       * tree-object-size.c (compute_object_sizes): Use size_type_node.
+
+       * tree.h (initialize_sizetypes): Remove parameter.
+       (build_common_tree_nodes): Remove second parameter.
+       * stor-layout.c (initialize_sizetypes): Remove parameter.
+       Always create an unsigned type.
+       (set_sizetype): Assert that the passed type is unsigned and simplify.
+       * tree.c (build_common_tree_nodes): Remove second parameter.
+       Adjust call to initialize_sizetypes.
+       * c-decl.c (c_init_decl_processing): Remove second argument in call to
+       build_common_tree_nodes.
+
 2010-04-18  Matthias Klose  <doko@ubuntu.com>
 
        * gcc.c (main): Search for liblto_plugin.so with mode R_OK.
index ee70230c08e736a1826ec2348d6ab521c7bf039e..76aa31591c1355ee1319b401a31a59253d2db021 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/misc.c (gnat_init): Remove second argument in call to
+       build_common_tree_nodes.
+
 2010-04-18  Ozkan Sezer  <sezeroz@gmail.com>
 
        * gsocket.h: Make sure that winsock2.h is included before windows.h.
index b54598c4f97f1c5bc6c6fd5d2d30d0f182ac7561..41c61853c7065441d40a4ca35a661129181e021b 100644 (file)
@@ -391,7 +391,7 @@ gnat_init (void)
   /* Do little here, most of the standard declarations are set up after the
      front-end has been run.  Use the same `char' as C, this doesn't really
      matter since we'll use the explicit `unsigned char' for Character.  */
-  build_common_tree_nodes (flag_signed_char, false);
+  build_common_tree_nodes (flag_signed_char);
 
   /* In Ada, we use the unsigned type corresponding to the width of Pmode as
      SIZETYPE.  In most cases when ptr_mode and Pmode differ, C will use the
index bf8555715b072ec92f91be31ccc444491f7e434d..230b4aada9468f2741f2c2df1452c6dfcdbc4843 100644 (file)
@@ -3454,7 +3454,7 @@ c_init_decl_processing (void)
      using preprocessed headers.  */
   input_location = BUILTINS_LOCATION;
 
-  build_common_tree_nodes (flag_signed_char, false);
+  build_common_tree_nodes (flag_signed_char);
 
   c_common_nodes_and_builtins ();
 
index 6a11a946300071186ffa21df08cc1e7876f563fc..0c59a92d3e3f6eba081c0e399cec78f16f2ab9a7 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * decl.c (cxx_init_decl_processing): Remove second argument in call to
+       build_common_tree_nodes.
+
 2010-04-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/36625
index 32aeda2b18b843141ff8a971436b06858c8e889a..c31aa5ccefc6061ac7ed00caef0bf3e84d71e5bc 100644 (file)
@@ -3358,7 +3358,7 @@ cxx_init_decl_processing (void)
   tree void_ftype;
   tree void_ftype_ptr;
 
-  build_common_tree_nodes (flag_signed_char, false);
+  build_common_tree_nodes (flag_signed_char);
 
   /* Create all the identifiers we need.  */
   initialize_predefined_identifiers ();
index c1af8248a395f55c1d51a914681dbfada7ec3a21..85f9cd1fd91611f6ff79f552bef4c87aa76ee5bc 100644 (file)
@@ -8695,24 +8695,19 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
                   && ((code == EQ_EXPR || code == NE_EXPR)
                       || POINTER_TYPE_OVERFLOW_UNDEFINED))
            {
-             tree signed_size_type_node;
-             signed_size_type_node = signed_type_for (size_type_node);
-
              /* By converting to signed size type we cover middle-end pointer
                 arithmetic which operates on unsigned pointer types of size
                 type size and ARRAY_REF offsets which are properly sign or
                 zero extended from their type in case it is narrower than
                 size type.  */
              if (offset0 == NULL_TREE)
-               offset0 = build_int_cst (signed_size_type_node, 0);
+               offset0 = build_int_cst (ssizetype, 0);
              else
-               offset0 = fold_convert_loc (loc, signed_size_type_node,
-                                           offset0);
+               offset0 = fold_convert_loc (loc, ssizetype, offset0);
              if (offset1 == NULL_TREE)
-               offset1 = build_int_cst (signed_size_type_node, 0);
+               offset1 = build_int_cst (ssizetype, 0);
              else
-               offset1 = fold_convert_loc (loc, signed_size_type_node,
-                                           offset1);
+               offset1 = fold_convert_loc (loc, ssizetype, offset1);
 
              if (code != EQ_EXPR
                  && code != NE_EXPR
index 377fe183f51e81a6dce903e61e90ef31afa93bfa..61297f9f12c46537dab53abdb5ecee98318d2147 100644 (file)
@@ -1,12 +1,17 @@
+2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * f95-lang.c (gfc_init_decl_processing): Remove second argument in call
+       to build_common_tree_nodes.
+
 2010-04-17  Steven G. Kargl  <kargl@gcc.gnu.org>
 
-   PR fortran/31538
-   * fortran/trans-array.c (gfc_conv_ss_startstride): Remove the use of
-   gfc_msg_bounds by using 'Array bound mismatch' directly.
-   (gfc_trans_dummy_array_bias):  Remove the use of gfc_msg_bounds.  Reword
-   error message to include the mismatch in the extent of array bound.
-   * fortran/trans.c: Remove gfc_msg_bounds.  It is only used in one place.
-   * fortran/trans.h: Remove extern definition of gfc_msg_bounds.
+       PR fortran/31538
+       * fortran/trans-array.c (gfc_conv_ss_startstride): Remove the use of
+       gfc_msg_bounds by using 'Array bound mismatch' directly.
+       (gfc_trans_dummy_array_bias):  Remove the use of gfc_msg_bounds.  Reword
+       error message to include the mismatch in the extent of array bound.
+       * fortran/trans.c: Remove gfc_msg_bounds.  It is only used in one place.
+       * fortran/trans.h: Remove extern definition of gfc_msg_bounds.
 
 2010-04-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
index 5d2846c8890ac84aff89fa2ad9347250c70ec203..96ff8bb2ef3f9c65f6b4209382c1f26f32d9760d 100644 (file)
@@ -542,7 +542,7 @@ gfc_init_decl_processing (void)
   /* Build common tree nodes. char_type_node is unsigned because we
      only use it for actual characters, not for INTEGER(1). Also, we
      want double_type_node to actually have double precision.  */
-  build_common_tree_nodes (false, false);
+  build_common_tree_nodes (false);
   /* x86_64 mingw32 has a sizetype of "unsigned long long", most other hosts
      have a sizetype of "unsigned long". Therefore choose the correct size
      in mostly target independent way.  */
index 270475c0c6cdc484b6b21ba0e2e5d484d7f5b084..ab076348be0e216fc3a4b27aac25e61c2cc1df04 100644 (file)
@@ -159,7 +159,7 @@ maybe_fold_offset_to_array_ref (location_t loc, tree base, tree offset,
     return NULL_TREE;
 
   /* Use signed size type for intermediate computation on the index.  */
-  idx_type = signed_type_for (size_type_node);
+  idx_type = ssizetype;
 
   /* If OFFSET and ELT_OFFSET are zero, we don't care about the size of the
      element type (so we can use the alignment if it's not constant).
index c6d58b1d4526592429aea6974ea386ec1876ace5..ec9f63d89a7b4abc9077759b8eefabcf39047c14 100644 (file)
@@ -1700,7 +1700,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
              if (!useless_type_conversion_p (ptrtype, TREE_TYPE (expr)))
                expr = fold_convert (ptrtype, expr);
              expr = fold_build2 (POINTER_PLUS_EXPR, ptrtype, expr,
-                                 build_int_cst (size_type_node,
+                                 build_int_cst (sizetype,
                                                 adj->offset / BITS_PER_UNIT));
              if (!adj->by_ref)
                expr = fold_build1 (INDIRECT_REF, adj->type, expr);
index f1a60807436cef817053b21576846194ee4004c3..b88bd1974ed49777f37ce4ac169a6b16d7705f3a 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * decl.c (java_init_decl_processing): Remove argument in call to
+       initialize_sizetypes
+
 2010-04-07  Jakub Jelinek  <jakub@redhat.com>
 
        * exception.cc (_Jv_Throw): Avoid set but not used warning.
index c593b53df5cef54c1a6c03fb44e1947a7f06a7d1..4cd4d9668dc77e484361c8fc4fdf47afa77b5d98 100644 (file)
@@ -579,7 +579,7 @@ java_init_decl_processing (void)
   TREE_TYPE (error_mark_node) = error_mark_node;
 
   /* Create sizetype first - needed for other types. */
-  initialize_sizetypes (false);
+  initialize_sizetypes ();
 
   byte_type_node = make_signed_type (8);
   pushdecl (build_decl (BUILTINS_LOCATION,
index 20b89d69761d7b0bd437a2607b150ee3a9d81166..464a2ef28c3fe8f1f6910dd77fb6c7df298db50e 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * lto-lang.c (lto_init): Remove second argument in call to
+       build_common_tree_nodes.
+
 2010-04-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * lto-elf.c [!HAVE_ELF_GETSHDRSTRNDX] (elf_getshdrstrndx): New
index 05577a29371f1a1c08f8c6c90251d11b64cc539e..aea5ab22d35a690dd71f924efccfc5627f1b8454 100644 (file)
@@ -1039,7 +1039,7 @@ lto_init (void)
   linemap_add (line_table, LC_RENAME, 0, NULL, 0);
 
   /* Create the basic integer types.  */
-  build_common_tree_nodes (flag_signed_char, /*signed_sizetype=*/false);
+  build_common_tree_nodes (flag_signed_char);
 
   /* Share char_type_node with whatever would be the default for the target.
      char_type_node will be used for internal types such as
index 46ac33398034c8633cb439f5fbcef8cf876b6f7a..151092c06a4af9e667a2362e2e4668b5afb595cc 100644 (file)
@@ -2214,37 +2214,35 @@ make_accum_type (int precision, int unsignedp, int satp)
    value to enable integer types to be created.  */
 
 void
-initialize_sizetypes (bool signed_p)
+initialize_sizetypes (void)
 {
   tree t = make_node (INTEGER_TYPE);
   int precision = GET_MODE_BITSIZE (SImode);
 
   SET_TYPE_MODE (t, SImode);
   TYPE_ALIGN (t) = GET_MODE_ALIGNMENT (SImode);
-  TYPE_USER_ALIGN (t) = 0;
   TYPE_IS_SIZETYPE (t) = 1;
-  TYPE_UNSIGNED (t) = !signed_p;
+  TYPE_UNSIGNED (t) = 1;
   TYPE_SIZE (t) = build_int_cst (t, precision);
   TYPE_SIZE_UNIT (t) = build_int_cst (t, GET_MODE_SIZE (SImode));
   TYPE_PRECISION (t) = precision;
 
-  /* Set TYPE_MIN_VALUE and TYPE_MAX_VALUE.  */
-  set_min_and_max_values_for_integral_type (t, precision, !signed_p);
+  set_min_and_max_values_for_integral_type (t, precision, true);
 
   sizetype = t;
   bitsizetype = build_distinct_type_copy (t);
 }
 
-/* Make sizetype a version of TYPE, and initialize *sizetype
-   accordingly.  We do this by overwriting the stub sizetype and
-   bitsizetype nodes created by initialize_sizetypes.  This makes sure
-   that (a) anything stubby about them no longer exists, (b) any
-   INTEGER_CSTs created with such a type, remain valid.  */
+/* Make sizetype a version of TYPE, and initialize *sizetype accordingly.
+   We do this by overwriting the stub sizetype and bitsizetype nodes created
+   by initialize_sizetypes.  This makes sure that (a) anything stubby about
+   them no longer exists and (b) any INTEGER_CSTs created with such a type,
+   remain valid.  */
 
 void
 set_sizetype (tree type)
 {
-  tree t;
+  tree t, max;
   int oprecision = TYPE_PRECISION (type);
   /* The *bitsizetype types use a precision that avoids overflows when
      calculating signed sizes / offsets in bits.  However, when
@@ -2257,11 +2255,11 @@ set_sizetype (tree type)
   if (precision > HOST_BITS_PER_WIDE_INT * 2)
     precision = HOST_BITS_PER_WIDE_INT * 2;
 
-  gcc_assert (TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype));
+  /* sizetype must be an unsigned type.  */
+  gcc_assert (TYPE_UNSIGNED (type));
 
   t = build_distinct_type_copy (type);
-  /* We do want to use sizetype's cache, as we will be replacing that
-     type.  */
+  /* We want to use sizetype's cache, as we will be replacing that type.  */
   TYPE_CACHED_VALUES (t) = TYPE_CACHED_VALUES (sizetype);
   TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (sizetype);
   TREE_TYPE (TYPE_CACHED_VALUES (t)) = type;
@@ -2273,10 +2271,17 @@ set_sizetype (tree type)
   TYPE_MAIN_VARIANT (sizetype) = sizetype;
   TYPE_CANONICAL (sizetype) = sizetype;
 
+  /* sizetype is unsigned but we need to fix TYPE_MAX_VALUE so that it is
+     sign-extended in a way consistent with force_fit_type.  */
+  max = TYPE_MAX_VALUE (sizetype);
+  TYPE_MAX_VALUE (sizetype)
+    = build_int_cst_wide_type (sizetype,
+                              TREE_INT_CST_LOW (max),
+                              TREE_INT_CST_HIGH (max));
+
   t = make_node (INTEGER_TYPE);
   TYPE_NAME (t) = get_identifier ("bit_size_type");
-  /* We do want to use bitsizetype's cache, as we will be replacing that
-     type.  */
+  /* We want to use bitsizetype's cache, as we will be replacing that type.  */
   TYPE_CACHED_VALUES (t) = TYPE_CACHED_VALUES (bitsizetype);
   TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (bitsizetype);
   TYPE_PRECISION (t) = precision;
@@ -2288,36 +2293,13 @@ set_sizetype (tree type)
   TYPE_MAIN_VARIANT (bitsizetype) = bitsizetype;
   TYPE_CANONICAL (bitsizetype) = bitsizetype;
 
-  if (TYPE_UNSIGNED (type))
-    {
-      fixup_unsigned_type (bitsizetype);
-      ssizetype = make_signed_type (oprecision);
-      TYPE_IS_SIZETYPE (ssizetype) = 1;
-      sbitsizetype = make_signed_type (precision);
-      TYPE_IS_SIZETYPE (sbitsizetype) = 1;
-    }
-  else
-    {
-      fixup_signed_type (bitsizetype);
-      ssizetype = sizetype;
-      sbitsizetype = bitsizetype;
-    }
-
-  /* If SIZETYPE is unsigned, we need to fix TYPE_MAX_VALUE so that
-     it is sign extended in a way consistent with force_fit_type.  */
-  if (TYPE_UNSIGNED (type))
-    {
-      tree orig_max, new_max;
+  fixup_unsigned_type (bitsizetype);
 
-      orig_max = TYPE_MAX_VALUE (sizetype);
-
-      /* Build a new node with the same values, but a different type.
-        Sign extend it to ensure consistency.  */
-      new_max = build_int_cst_wide_type (sizetype,
-                                        TREE_INT_CST_LOW (orig_max),
-                                        TREE_INT_CST_HIGH (orig_max));
-      TYPE_MAX_VALUE (sizetype) = new_max;
-    }
+  /* Create the signed variants of *sizetype.  */
+  ssizetype = make_signed_type (oprecision);
+  TYPE_IS_SIZETYPE (ssizetype) = 1;
+  sbitsizetype = make_signed_type (precision);
+  TYPE_IS_SIZETYPE (sbitsizetype) = 1;
 }
 \f
 /* TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE
index 384e43c770cf303fcb8fc7782d6b9aa8ff1623b9..fbab7db96765384db3cfa3ea4ad3ced64091ed20 100644 (file)
@@ -227,12 +227,9 @@ build_size_arg_loc (location_t loc, tree nb_iter, tree op,
                    gimple_seq *stmt_list)
 {
   gimple_seq stmts;
-  tree x;
-
-  x = fold_build2_loc (loc, MULT_EXPR, size_type_node,
-                      fold_convert_loc (loc, size_type_node, nb_iter),
-                      fold_convert_loc (loc, size_type_node,
-                                        TYPE_SIZE_UNIT (TREE_TYPE (op))));
+  tree x = size_binop_loc (loc, MULT_EXPR,
+                          fold_convert_loc (loc, sizetype, nb_iter),
+                          TYPE_SIZE_UNIT (TREE_TYPE (op)));
   x = force_gimple_operand (x, &stmts, true, NULL);
   gimple_seq_add_seq (stmt_list, stmts);
 
index 135342d58b07681d1d0b594435ab4fab7236c577..2892e84600c26b24447938e91e5215b08a5bfeff 100644 (file)
@@ -1203,7 +1203,8 @@ compute_object_sizes (void)
                        result = fold_convert (size_type_node,
                                               integer_minus_one_node);
                      else if (object_size_type < 4)
-                       result = size_zero_node;
+                       result = fold_convert (size_type_node,
+                                              integer_zero_node);
                    }
                }
 
index 6ac1318667517c8ebde35df5bb4f6e27bee5e360..0eab137863b938553608da11f832aa4a7311b6c2 100644 (file)
@@ -8747,12 +8747,12 @@ make_or_reuse_accum_type (unsigned size, int unsignedp, int satp)
    this function to select one of the types as sizetype.  */
 
 void
-build_common_tree_nodes (bool signed_char, bool signed_sizetype)
+build_common_tree_nodes (bool signed_char)
 {
   error_mark_node = make_node (ERROR_MARK);
   TREE_TYPE (error_mark_node) = error_mark_node;
 
-  initialize_sizetypes (signed_sizetype);
+  initialize_sizetypes ();
 
   /* Define both `signed char' and `unsigned char'.  */
   signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
index ee6f1a4f598d579ff80588d6800342574dc5acd8..d900dc08638975c7977d72fa9aad782181d0f797 100644 (file)
@@ -3967,7 +3967,7 @@ 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);
+extern void initialize_sizetypes (void);
 extern void set_sizetype (tree);
 extern void fixup_unsigned_type (tree);
 extern tree build_pointer_type_for_mode (tree, enum machine_mode, bool);
@@ -4981,7 +4981,7 @@ extern int real_onep (const_tree);
 extern int real_twop (const_tree);
 extern int real_minus_onep (const_tree);
 extern void init_ttree (void);
-extern void build_common_tree_nodes (bool, bool);
+extern void build_common_tree_nodes (bool);
 extern void build_common_tree_nodes_2 (int);
 extern void build_common_builtin_nodes (void);
 extern tree build_nonstandard_integer_type (unsigned HOST_WIDE_INT, int);