+2004-09-11 Zack Weinberg <zack@codesourcery.com>
+
+ * tree.c (tree_code_size): New function, bulk of code from tree_size.
+ (tree_size, make_node): Use it.
+ * tree-ssa-pre.c (init_pre): Use it.
+ * tree.h: Prototype it.
+
2004-09-11 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* tree-cfg.c (set_bb_for_stmt): Use PHI_BB.
* tree-pretty-print.c (dump_decl_name): Print unnamed decls as
D.xxx rather than <Dxxx>.
-2004-09-10 Adam Nemet <anemet@lnxw.com>
+2004-09-10 Adam Nemet <anemet@lnxw.com>
* configure.ac (AC_MSG_CHECKING(what linker to use)):
in_tree_ld_is_elf should be true for LynxOS.
- * configure: Regenerate.
+ * configure: Regenerate.
2004-09-10 Adam Nemet <anemet@lnxw.com>
static void
init_pre (void)
{
- size_t tsize;
basic_block bb;
connect_infinite_loops_to_exit ();
sizeof (struct value_set_node), 30);
calculate_dominance_info (CDI_POST_DOMINATORS);
calculate_dominance_info (CDI_DOMINATORS);
- tsize = tree_size (build (PLUS_EXPR, void_type_node, NULL_TREE, NULL_TREE));
- binary_node_pool = create_alloc_pool ("Binary tree nodes", tsize, 30);
- tsize = tree_size (build1 (NEGATE_EXPR, void_type_node, NULL_TREE));
- unary_node_pool = create_alloc_pool ("Unary tree nodes", tsize, 30);
- tsize = tree_size (build (COMPONENT_REF, void_type_node, NULL_TREE,
- NULL_TREE, NULL_TREE));
- reference_node_pool = create_alloc_pool ("Reference tree nodes", tsize, 30);
+ binary_node_pool = create_alloc_pool ("Binary tree nodes",
+ tree_code_size (PLUS_EXPR), 30);
+ unary_node_pool = create_alloc_pool ("Unary tree nodes",
+ tree_code_size (NEGATE_EXPR), 30);
+ reference_node_pool = create_alloc_pool ("Reference tree nodes",
+ tree_code_size (COMPONENT_REF), 30);
FOR_ALL_BB (bb)
{
EXP_GEN (bb) = set_new (true);
return DECL_CHECK (decl)->decl.assembler_name;
}
-/* Compute the number of bytes occupied by 'node'. This routine only
- looks at TREE_CODE and, if the code is TREE_VEC, TREE_VEC_LENGTH. */
+/* Compute the number of bytes occupied by a tree with code CODE. This
+ function cannot be used for TREE_VEC or PHI_NODE codes, which are of
+ variable length. */
size_t
-tree_size (tree node)
+tree_code_size (enum tree_code code)
{
- enum tree_code code = TREE_CODE (node);
+ /* We can't state the size of a TREE_VEC or PHI_NODE
+ without knowing how many elements it will have. */
+ gcc_assert (code != TREE_VEC);
+ gcc_assert (code != PHI_NODE);
switch (TREE_CODE_CLASS (code))
{
case '1': /* a unary arithmetic expression */
case '2': /* a binary arithmetic expression */
return (sizeof (struct tree_exp)
- + TREE_CODE_LENGTH (code) * sizeof (char *) - sizeof (char *));
+ + (TREE_CODE_LENGTH (code) - 1) * sizeof (char *));
case 'c': /* a constant */
switch (code)
{
case IDENTIFIER_NODE: return lang_hooks.identifier_size;
case TREE_LIST: return sizeof (struct tree_list);
- case TREE_VEC: return (sizeof (struct tree_vec)
- + TREE_VEC_LENGTH(node) * sizeof(char *)
- - sizeof (char *));
case ERROR_MARK:
case PLACEHOLDER_EXPR: return sizeof (struct tree_common);
- case PHI_NODE: return (sizeof (struct tree_phi_node)
- + (PHI_ARG_CAPACITY (node) - 1) *
- sizeof (struct phi_arg_d));
+ case PHI_NODE:
case SSA_NAME: return sizeof (struct tree_ssa_name);
}
}
-/* Return a newly allocated node of code CODE.
- For decl and type nodes, some other fields are initialized.
- The rest of the node is initialized to zero.
+/* Compute the number of bytes occupied by NODE. This routine only
+ looks at TREE_CODE, except for PHI_NODE and TREE_VEC nodes. */
+size_t
+tree_size (tree node)
+{
+ enum tree_code code = TREE_CODE (node);
+ switch (code)
+ {
+ case PHI_NODE:
+ return (sizeof (struct tree_phi_node)
+ + (PHI_ARG_CAPACITY (node) - 1) * sizeof (struct phi_arg_d));
+
+ case TREE_VEC:
+ return (sizeof (struct tree_vec)
+ + (TREE_VEC_LENGTH (node) - 1) * sizeof(char *));
+
+ default:
+ return tree_code_size (code);
+ }
+}
+
+/* Return a newly allocated node of code CODE. For decl and type
+ nodes, some other fields are initialized. The rest of the node is
+ initialized to zero. This function cannot be used for PHI_NODE or
+ TREE_VEC nodes, which is enforced by asserts in tree_code_size.
Achoo! I got a code in the node. */
{
tree t;
int type = TREE_CODE_CLASS (code);
- size_t length;
+ size_t length = tree_code_size (code);
#ifdef GATHER_STATISTICS
tree_node_kind kind;
-#endif
- struct tree_common ttmp;
- /* We can't allocate a TREE_VEC, PHI_NODE, or STRING_CST
- without knowing how many elements it will have. */
- gcc_assert (code != TREE_VEC);
- gcc_assert (code != PHI_NODE);
-
- TREE_SET_CODE ((tree)&ttmp, code);
- length = tree_size ((tree)&ttmp);
-
-#ifdef GATHER_STATISTICS
switch (type)
{
case 'd': /* A decl node */