aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2012-03-16 09:47:09 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2012-03-16 09:47:09 +0000
commitd2a12ae77fa3efbe2329f7126b4acc24c35ef401 (patch)
tree61b2d8308768796bdf3f7e0c34b84aa6cc0bae11 /gcc/tree.c
parent20bfad56eb81a52c7449521282401c88deee391b (diff)
downloadgcc-d2a12ae77fa3efbe2329f7126b4acc24c35ef401.zip
gcc-d2a12ae77fa3efbe2329f7126b4acc24c35ef401.tar.gz
gcc-d2a12ae77fa3efbe2329f7126b4acc24c35ef401.tar.bz2
tree.h (TREE_VECTOR_CST_ELTS): Remove.
2012-03-16 Richard Guenther <rguenther@suse.de> * tree.h (TREE_VECTOR_CST_ELTS): Remove. (VECTOR_CST_NELTS, VECTOR_CST_ELTS, VECTOR_CST_ELT): New defines. (struct tree_vector): Remove elements member, add variable size elts array member. (build_vector_stat): Declare. (build_vector): Define in terms of build_vector_stat. * tree.c (build_vector): Rename to ... (build_vector_stat): ... this. Take array of trees as parameter. (build_vector_from_ctor): Adjust. (integer_zerop, integer_onep, integer_all_onesp, iterative_hash_expr, initializer_zerop): Adjust. * cfgexpand.c (expand_debug_expr): Likewise. * expr.c (categorize_ctor_elements_1, expand_expr_real_1, const_vector_from_tree): Likewise. * fold-const.c (const_binop, operand_equal_p, native_encode_vector, native_interpret_vector, fold_unary_loc, vec_cst_ctor_to_array, fold_vec_perm, fold_binary_loc, fold_ternary_loc): Likewise. * tree-streamer-in.c (streamer_alloc_tree): Handle TS_VECTOR. (lto_input_ts_vector_tree_pointers): Adjust. * tree-streamer-out.c (streamer_write_tree_header): Handle TS_VECTOR. (write_ts_vector_tree_pointers): Adjust. * varasm.c (const_hash_1, compare_constant, copy_constant, output_constant): Adjust. * gimple-fold.c (gimple_fold_stmt_to_constant_1): Adjust. * print-tree.c (print_node): Adjust. * tree-pretty-print.c (dump_generic_node): Adjust. * tree-vect-generic.c (uniform_vector_p, vector_element, lower_vec_perm): Adjust. * tree-vect-loop.c (get_initial_def_for_reduction): Adjust. * tree-vect-slp.c (vect_get_constant_vectors, vect_transform_slp_perm_load): Adjust. * tree-vect-stmts.c (vect_gen_perm_mask): Adjust. * expmed.c (make_tree): Adjust. * config/i386/i386.c (ix86_expand_builtin): Adjust. * config/sparc/sparc.c (sparc_handle_vis_mul8x16): Adjust interface and implementation. (sparc_fold_builtin): Adjust. c-family/ * c-pretty-print.c (pp_c_initializer_list): Adjust. From-SVN: r185458
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c69
1 files changed, 41 insertions, 28 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index c90331c..1734fc5 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1315,21 +1315,28 @@ cst_and_fits_in_hwi (const_tree x)
are in a list pointed to by VALS. */
tree
-build_vector (tree type, tree vals)
+build_vector_stat (tree type, tree *vals MEM_STAT_DECL)
{
- tree v = make_node (VECTOR_CST);
int over = 0;
- tree link;
unsigned cnt = 0;
+ tree v;
+ int length = ((TYPE_VECTOR_SUBPARTS (type) - 1) * sizeof (tree)
+ + sizeof (struct tree_vector));
+
+ record_node_allocation_statistics (VECTOR_CST, length);
+
+ v = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
- TREE_VECTOR_CST_ELTS (v) = vals;
+ TREE_SET_CODE (v, VECTOR_CST);
+ TREE_CONSTANT (v) = 1;
TREE_TYPE (v) = type;
/* Iterate through elements and check for overflow. */
- for (link = vals; link; link = TREE_CHAIN (link))
+ for (cnt = 0; cnt < TYPE_VECTOR_SUBPARTS (type); ++cnt)
{
- tree value = TREE_VALUE (link);
- cnt++;
+ tree value = vals[cnt];
+
+ VECTOR_CST_ELT (v, cnt) = value;
/* Don't crash if we get an address constant. */
if (!CONSTANT_CLASS_P (value))
@@ -1338,8 +1345,6 @@ build_vector (tree type, tree vals)
over |= TREE_OVERFLOW (value);
}
- gcc_assert (cnt == TYPE_VECTOR_SUBPARTS (type));
-
TREE_OVERFLOW (v) = over;
return v;
}
@@ -1350,16 +1355,16 @@ build_vector (tree type, tree vals)
tree
build_vector_from_ctor (tree type, VEC(constructor_elt,gc) *v)
{
- tree list = NULL_TREE;
+ tree *vec = XALLOCAVEC (tree, TYPE_VECTOR_SUBPARTS (type));
unsigned HOST_WIDE_INT idx;
tree value;
FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
- list = tree_cons (NULL_TREE, value, list);
+ vec[idx] = value;
for (; idx < TYPE_VECTOR_SUBPARTS (type); ++idx)
- list = tree_cons (NULL_TREE,
- build_zero_cst (TREE_TYPE (type)), list);
- return build_vector (type, nreverse (list));
+ vec[idx] = build_zero_cst (TREE_TYPE (type));
+
+ return build_vector (type, vec);
}
/* Build a vector of type VECTYPE where all the elements are SCs. */
@@ -1724,9 +1729,9 @@ integer_zerop (const_tree expr)
&& integer_zerop (TREE_IMAGPART (expr)));
case VECTOR_CST:
{
- tree elt;
- for (elt = TREE_VECTOR_CST_ELTS (expr); elt; elt = TREE_CHAIN (elt))
- if (!integer_zerop (TREE_VALUE (elt)))
+ unsigned i;
+ for (i = 0; i < VECTOR_CST_NELTS (expr); ++i)
+ if (!integer_zerop (VECTOR_CST_ELT (expr, i)))
return false;
return true;
}
@@ -1753,9 +1758,9 @@ integer_onep (const_tree expr)
&& integer_zerop (TREE_IMAGPART (expr)));
case VECTOR_CST:
{
- tree elt;
- for (elt = TREE_VECTOR_CST_ELTS (expr); elt; elt = TREE_CHAIN (elt))
- if (!integer_onep (TREE_VALUE (elt)))
+ unsigned i;
+ for (i = 0; i < VECTOR_CST_NELTS (expr); ++i)
+ if (!integer_onep (VECTOR_CST_ELT (expr, i)))
return false;
return true;
}
@@ -1782,9 +1787,9 @@ integer_all_onesp (const_tree expr)
else if (TREE_CODE (expr) == VECTOR_CST)
{
- tree elt;
- for (elt = TREE_VECTOR_CST_ELTS (expr); elt; elt = TREE_CHAIN (elt))
- if (!integer_all_onesp (TREE_VALUE (elt)))
+ unsigned i;
+ for (i = 0; i < VECTOR_CST_NELTS (expr); ++i)
+ if (!integer_all_onesp (VECTOR_CST_ELT (expr, i)))
return 0;
return 1;
}
@@ -6944,7 +6949,12 @@ iterative_hash_expr (const_tree t, hashval_t val)
val = iterative_hash_expr (TREE_REALPART (t), val);
return iterative_hash_expr (TREE_IMAGPART (t), val);
case VECTOR_CST:
- return iterative_hash_expr (TREE_VECTOR_CST_ELTS (t), val);
+ {
+ unsigned i;
+ for (i = 0; i < VECTOR_CST_NELTS (t); ++i)
+ val = iterative_hash_expr (VECTOR_CST_ELT (t, i), val);
+ return val;
+ }
case SSA_NAME:
/* We can just compare by pointer. */
return iterative_hash_host_wide_int (SSA_NAME_VERSION (t), val);
@@ -9889,10 +9899,13 @@ initializer_zerop (const_tree init)
&& ! REAL_VALUE_MINUS_ZERO (TREE_REAL_CST (TREE_IMAGPART (init))));
case VECTOR_CST:
- for (elt = TREE_VECTOR_CST_ELTS (init); elt; elt = TREE_CHAIN (elt))
- if (!initializer_zerop (TREE_VALUE (elt)))
- return false;
- return true;
+ {
+ unsigned i;
+ for (i = 0; i < VECTOR_CST_NELTS (init); ++i)
+ if (!initializer_zerop (VECTOR_CST_ELT (init, i)))
+ return false;
+ return true;
+ }
case CONSTRUCTOR:
{