OSDN Git Service

2010-04-26 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / tree.c
index 9dbd084..8eeecff 100644 (file)
@@ -1082,30 +1082,6 @@ build_int_cst_wide_type (tree type,
   return build_int_cst_wide (type, low, high);
 }
 
-/* Constructs tree in type TYPE from with value given by CST.  Signedness
-   of CST is assumed to be the same as the signedness of TYPE.  */
-
-tree
-double_int_to_tree (tree type, double_int cst)
-{
-  cst = double_int_ext (cst, TYPE_PRECISION (type), TYPE_UNSIGNED (type));
-
-  return build_int_cst_wide (type, cst.low, cst.high);
-}
-
-/* Returns true if CST fits into range of TYPE.  Signedness of CST is assumed
-   to be the same as the signedness of TYPE.  */
-
-bool
-double_int_fits_to_tree_p (const_tree type, double_int cst)
-{
-  double_int ext = double_int_ext (cst,
-                                  TYPE_PRECISION (type),
-                                  TYPE_UNSIGNED (type));
-
-  return double_int_equal_p (cst, ext);
-}
-
 /* These are the hash table functions for the hash table of INTEGER_CST
    nodes of a sizetype.  */
 
@@ -1332,22 +1308,8 @@ tree
 build_constructor (tree type, VEC(constructor_elt,gc) *vals)
 {
   tree c = make_node (CONSTRUCTOR);
-  unsigned int i;
-  constructor_elt *elt;
-  bool constant_p = true;
-
   TREE_TYPE (c) = type;
   CONSTRUCTOR_ELTS (c) = vals;
-
-  for (i = 0; VEC_iterate (constructor_elt, vals, i, elt); i++)
-    if (!TREE_CONSTANT (elt->value))
-      {
-       constant_p = false;
-       break;
-      }
-
-  TREE_CONSTANT (c) = constant_p;
-
   return c;
 }
 
@@ -1358,13 +1320,16 @@ build_constructor_single (tree type, tree index, tree value)
 {
   VEC(constructor_elt,gc) *v;
   constructor_elt *elt;
+  tree t;
 
   v = VEC_alloc (constructor_elt, gc, 1);
   elt = VEC_quick_push (constructor_elt, v, NULL);
   elt->index = index;
   elt->value = value;
 
-  return build_constructor (type, v);
+  t = build_constructor (type, v);
+  TREE_CONSTANT (t) = TREE_CONSTANT (value);
+  return t;
 }
 
 
@@ -1373,17 +1338,27 @@ build_constructor_single (tree type, tree index, tree value)
 tree
 build_constructor_from_list (tree type, tree vals)
 {
-  tree t;
+  tree t, val;
   VEC(constructor_elt,gc) *v = NULL;
+  bool constant_p = true;
 
   if (vals)
     {
       v = VEC_alloc (constructor_elt, gc, list_length (vals));
       for (t = vals; t; t = TREE_CHAIN (t))
-       CONSTRUCTOR_APPEND_ELT (v, TREE_PURPOSE (t), TREE_VALUE (t));
+       {
+         constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL);
+         val = TREE_VALUE (t);
+         elt->index = TREE_PURPOSE (t);
+         elt->value = val;
+         if (!TREE_CONSTANT (val))
+           constant_p = false;
+       }
     }
 
-  return build_constructor (type, v);
+  t = build_constructor (type, v);
+  TREE_CONSTANT (t) = constant_p;
+  return t;
 }
 
 /* Return a new FIXED_CST node whose type is TYPE and value is F.  */
@@ -2124,6 +2099,25 @@ tree_cons_stat (tree purpose, tree value, tree chain MEM_STAT_DECL)
   return node;
 }
 
+/* Return the elements of a CONSTRUCTOR as a TREE_LIST.  */
+
+tree
+ctor_to_list (tree ctor)
+{
+  tree list = NULL_TREE;
+  tree *p = &list;
+  unsigned ix;
+  tree purpose, val;
+
+  FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), ix, purpose, val)
+    {
+      *p = build_tree_list (purpose, val);
+      p = &TREE_CHAIN (*p);
+    }
+
+  return list;
+}
+
 /* Return the values of the elements of a CONSTRUCTOR as a vector of
    trees.  */
 
@@ -4156,26 +4150,6 @@ build_type_attribute_variant (tree ttype, tree attribute)
 }
 
 
-/* Reset the expression *EXPR_P, a size or position.
-
-   ??? We could reset all non-constant sizes or positions.  But it's cheap
-   enough to not do so and refrain from adding workarounds to dwarf2out.c.
-
-   We need to reset self-referential sizes or positions because they cannot
-   be gimplified and thus can contain a CALL_EXPR after the gimplification
-   is finished, which will run afoul of LTO streaming.  And they need to be
-   reset to something essentially dummy but not constant, so as to preserve
-   the properties of the object they are attached to.  */
-
-static inline void
-free_lang_data_in_one_sizepos (tree *expr_p)
-{
-  tree expr = *expr_p;
-  if (CONTAINS_PLACEHOLDER_P (expr))
-    *expr_p = build0 (PLACEHOLDER_EXPR, TREE_TYPE (expr));
-}
-
-
 /* Reset all the fields in a binfo node BINFO.  We only keep
    BINFO_VIRTUALS, which is used by gimple_fold_obj_type_ref.  */
 
@@ -4282,19 +4256,8 @@ free_lang_data_in_type (tree type)
       /* For non-aggregate types, clear out the language slot (which
         overloads TYPE_BINFO).  */
       TYPE_LANG_SLOT_1 (type) = NULL_TREE;
-
-      if (INTEGRAL_TYPE_P (type)
-         || SCALAR_FLOAT_TYPE_P (type)
-         || FIXED_POINT_TYPE_P (type))
-       {
-         free_lang_data_in_one_sizepos (&TYPE_MIN_VALUE (type));
-         free_lang_data_in_one_sizepos (&TYPE_MAX_VALUE (type));
-       }
     }
 
-  free_lang_data_in_one_sizepos (&TYPE_SIZE (type));
-  free_lang_data_in_one_sizepos (&TYPE_SIZE_UNIT (type));
-
   if (debug_info_level < DINFO_LEVEL_TERSE
       || (TYPE_CONTEXT (type)
          && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_DECL
@@ -4430,10 +4393,9 @@ free_lang_data_in_decl (tree decl)
        }
    }
 
-  free_lang_data_in_one_sizepos (&DECL_SIZE (decl));
-  free_lang_data_in_one_sizepos (&DECL_SIZE_UNIT (decl));
-  if (TREE_CODE (decl) == FIELD_DECL)
-    free_lang_data_in_one_sizepos (&DECL_FIELD_OFFSET (decl));
+ /* ???  We could free non-constant DECL_SIZE, DECL_SIZE_UNIT
+    and DECL_FIELD_OFFSET.  But it's cheap enough to not do
+    that and refrain from adding workarounds to dwarf2out.c  */
 
  /* DECL_FCONTEXT is only used for debug info generation.  */
  if (TREE_CODE (decl) == FIELD_DECL
@@ -4647,10 +4609,6 @@ find_decls_types_r (tree *tp, int *ws, void *data)
          fld_worklist_push (DECL_COMDAT_GROUP (t), fld);
        }
 
-      if ((TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL)
-         && DECL_HAS_VALUE_EXPR_P (t))
-       fld_worklist_push (DECL_VALUE_EXPR (t), fld);
-
       if (TREE_CODE (t) != FIELD_DECL)
        fld_worklist_push (TREE_CHAIN (t), fld);
       *ws = 0;
@@ -5020,6 +4978,7 @@ free_lang_data (void)
   lang_hooks.dwarf_name = lhd_dwarf_name;
   lang_hooks.decl_printable_name = gimple_decl_printable_name;
   lang_hooks.set_decl_assembler_name = lhd_set_decl_assembler_name;
+  lang_hooks.fold_obj_type_ref = gimple_fold_obj_type_ref;
 
   /* Reset diagnostic machinery.  */
   diagnostic_starter (global_dc) = default_diagnostic_starter;
@@ -6608,12 +6567,11 @@ iterative_hash_expr (const_tree t, hashval_t val)
       return iterative_hash_expr (TREE_IMAGPART (t), val);
     case VECTOR_CST:
       return iterative_hash_expr (TREE_VECTOR_CST_ELTS (t), val);
+
     case SSA_NAME:
-      /* We can just compare by pointer.  */
+      /* we can just compare by pointer.  */
       return iterative_hash_host_wide_int (SSA_NAME_VERSION (t), val);
-    case PLACEHOLDER_EXPR:
-      /* The node itself doesn't matter.  */
-      return val;
+
     case TREE_LIST:
       /* A list of expressions, for a CALL_EXPR or as the elements of a
         VECTOR_CST.  */
@@ -7978,8 +7936,7 @@ bool
 auto_var_in_fn_p (const_tree var, const_tree fn)
 {
   return (DECL_P (var) && DECL_CONTEXT (var) == fn
-         && ((((TREE_CODE (var) == VAR_DECL && ! DECL_EXTERNAL (var))
-               || TREE_CODE (var) == PARM_DECL)
+         && (((TREE_CODE (var) == VAR_DECL || TREE_CODE (var) == PARM_DECL)
               && ! TREE_STATIC (var))
              || TREE_CODE (var) == LABEL_DECL
              || TREE_CODE (var) == RESULT_DECL));
@@ -9395,19 +9352,6 @@ initializer_zerop (const_tree init)
        return true;
       }
 
-    case STRING_CST:
-      {
-       int i;
-
-       /* We need to loop through all elements to handle cases like
-          "\0" and "\0foobar".  */
-       for (i = 0; i < TREE_STRING_LENGTH (init); ++i)
-         if (TREE_STRING_POINTER (init)[i] != '\0')
-           return false;
-
-       return true;
-      }
-
     default:
       return false;
     }