PR middle-end/52977
* tree.h (VECTOR_CST_NELTS): Adjust.
(struct tree_vector): Add explicit length field.
(make_vector_stat): Declare.
(make_vector): Define.
* tree.c (make_vector_stat): New function.
(build_vector_stat): Use it.
* tree-streamer-in.c (streamer_alloc_tree): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186494
138bc75d-0d04-0410-961f-
82ee72b054a4
+2012-04-16 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/52977
+ * tree.h (VECTOR_CST_NELTS): Adjust.
+ (struct tree_vector): Add explicit length field.
+ (make_vector_stat): Declare.
+ (make_vector): Define.
+ * tree.c (make_vector_stat): New function.
+ (build_vector_stat): Use it.
+ * tree-streamer-in.c (streamer_alloc_tree): Likewise.
+
2012-04-16 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/52976
else if (CODE_CONTAINS_STRUCT (code, TS_VECTOR))
{
HOST_WIDE_INT len = streamer_read_hwi (ib);
- result = ggc_alloc_zone_cleared_tree_node ((len - 1) * sizeof (tree)
- + sizeof (struct tree_vector),
- &tree_zone);
- TREE_SET_CODE (result, VECTOR_CST);
+ result = make_vector (len);
}
else if (CODE_CONTAINS_STRUCT (code, TS_BINFO))
{
|| TREE_INT_CST_HIGH (x) == -1);
}
+/* Build a newly constructed TREE_VEC node of length LEN. */
+
+tree
+make_vector_stat (unsigned len MEM_STAT_DECL)
+{
+ tree t;
+ unsigned length = (len - 1) * sizeof (tree) + sizeof (struct tree_vector);
+
+ record_node_allocation_statistics (VECTOR_CST, length);
+
+ t = ggc_alloc_zone_cleared_tree_node_stat (&tree_zone, length PASS_MEM_STAT);
+
+ TREE_SET_CODE (t, VECTOR_CST);
+ TREE_CONSTANT (t) = 1;
+ VECTOR_CST_NELTS (t) = len;
+
+ return t;
+}
+
/* Return a new VECTOR_CST node whose type is TYPE and whose values
are in a list pointed to by VALS. */
{
int over = 0;
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_SET_CODE (v, VECTOR_CST);
- TREE_CONSTANT (v) = 1;
+ tree v = make_vector (TYPE_VECTOR_SUBPARTS (type));
TREE_TYPE (v) = type;
/* Iterate through elements and check for overflow. */
};
/* In a VECTOR_CST node. */
-#define VECTOR_CST_NELTS(NODE) (TYPE_VECTOR_SUBPARTS (TREE_TYPE (NODE)))
+#define VECTOR_CST_NELTS(NODE) (VECTOR_CST_CHECK (NODE)->vector.length)
#define VECTOR_CST_ELTS(NODE) (VECTOR_CST_CHECK (NODE)->vector.elts)
#define VECTOR_CST_ELT(NODE,IDX) (VECTOR_CST_CHECK (NODE)->vector.elts[IDX])
struct GTY(()) tree_vector {
struct tree_typed typed;
- tree GTY ((length ("TYPE_VECTOR_SUBPARTS (TREE_TYPE ((tree)&%h))"))) elts[1];
+ unsigned length;
+ tree GTY ((length ("%h.length"))) elts[1];
};
\f
#include "symtab.h"
extern tree build_int_cst (tree, HOST_WIDE_INT);
extern tree build_int_cst_type (tree, HOST_WIDE_INT);
extern tree build_int_cst_wide (tree, unsigned HOST_WIDE_INT, HOST_WIDE_INT);
+extern tree make_vector_stat (unsigned MEM_STAT_DECL);
+#define make_vector(n) make_vector_stat (n MEM_STAT_INFO)
extern tree build_vector_stat (tree, tree * MEM_STAT_DECL);
#define build_vector(t,v) build_vector_stat (t, v MEM_STAT_INFO)
extern tree build_vector_from_ctor (tree, VEC(constructor_elt,gc) *);