aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Macleod <amacleod@redhat.com>2015-11-09 21:09:45 +0000
committerAndrew Macleod <amacleod@redhat.com>2015-11-09 21:09:45 +0000
commit9ee386496b7debde1f055480bc1cb4f7f87b07c2 (patch)
treeb0ed7de21e7440f62e935de57a93bc8afc9f9888
parente404bed63b98ea724953469f8932c6f343d0ab54 (diff)
allocate and copy ttype
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ttype-2015@230051 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ggc.h7
-rw-r--r--gcc/tree.c108
-rw-r--r--gcc/tree.h10
3 files changed, 79 insertions, 46 deletions
diff --git a/gcc/ggc.h b/gcc/ggc.h
index a9c7f9014fd..f1979d6ca95 100644
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -286,6 +286,13 @@ ggc_alloc_tree_node_stat (size_t s CXX_MEM_STAT_INFO)
return (struct tree_node *) ggc_internal_alloc (s PASS_MEM_STAT);
}
+static inline class ttype *
+ggc_alloc_ttype_stat (size_t s CXX_MEM_STAT_INFO)
+{
+ return (class ttype *) ggc_internal_alloc (s PASS_MEM_STAT);
+}
+
+
static inline struct tree_node *
ggc_alloc_cleared_tree_node_stat (size_t s CXX_MEM_STAT_INFO)
{
diff --git a/gcc/tree.c b/gcc/tree.c
index 022ce55d491..8f8f9852a9c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -160,7 +160,7 @@ static GTY(()) int next_debug_decl_uid;
struct GTY((for_user)) type_hash {
unsigned long hash;
- tree type;
+ ttype *type;
};
/* Initial size of the hash table (rounded to next prime). */
@@ -1106,6 +1106,41 @@ make_node_stat (enum tree_code code MEM_STAT_DECL)
/* Return a new node with the same contents as NODE except that its
TREE_CHAIN, if it has one, is zero and it has a fresh uid. */
+ttype *
+copy_node_stat (ttype *node MEM_STAT_DECL)
+{
+ ttype *t;
+ enum tree_code code = TREE_CODE (node);
+ size_t length;
+
+ length = tree_size (node);
+ record_node_allocation_statistics (code, length);
+ t = ggc_alloc_ttype_stat (length PASS_MEM_STAT);
+ memcpy (t, node, length);
+
+ TREE_CHAIN (t) = 0;
+ TREE_ASM_WRITTEN (t) = 0;
+ TREE_VISITED (t) = 0;
+
+ TYPE_UID (t) = next_type_uid++;
+ /* The following is so that the debug code for
+ the copy is different from the original type.
+ The two statements usually duplicate each other
+ (because they clear fields of the same union),
+ but the optimizer should catch that. */
+ TYPE_SYMTAB_POINTER (t) = 0;
+ TYPE_SYMTAB_ADDRESS (t) = 0;
+
+ /* Do not copy the values cache. */
+ if (TYPE_CACHED_VALUES_P (t))
+ {
+ TYPE_CACHED_VALUES_P (t) = 0;
+ TYPE_CACHED_VALUES (t) = NULL_TREE;
+ }
+ return t;
+}
+
+
tree
copy_node_stat (tree node MEM_STAT_DECL)
{
@@ -1113,6 +1148,9 @@ copy_node_stat (tree node MEM_STAT_DECL)
enum tree_code code = TREE_CODE (node);
size_t length;
+ if (TREE_CODE_CLASS (code) == tcc_type)
+ return copy_node_stat (as_a<ttype *> (node) MEM_STAT_DECL);
+
gcc_assert (code != STATEMENT_LIST);
length = tree_size (node);
@@ -1158,24 +1196,6 @@ copy_node_stat (tree node MEM_STAT_DECL)
DECL_SYMTAB_NODE (t) = NULL;
}
}
- else if (TREE_CODE_CLASS (code) == tcc_type)
- {
- TYPE_UID (t) = next_type_uid++;
- /* The following is so that the debug code for
- the copy is different from the original type.
- The two statements usually duplicate each other
- (because they clear fields of the same union),
- but the optimizer should catch that. */
- TYPE_SYMTAB_POINTER (t) = 0;
- TYPE_SYMTAB_ADDRESS (t) = 0;
-
- /* Do not copy the values cache. */
- if (TYPE_CACHED_VALUES_P (t))
- {
- TYPE_CACHED_VALUES_P (t) = 0;
- TYPE_CACHED_VALUES (t) = NULL_TREE;
- }
- }
else if (code == TARGET_OPTION_NODE)
{
TREE_TARGET_OPTION (t) = ggc_alloc<struct cl_target_option>();
@@ -6563,22 +6583,22 @@ find_atomic_core_type (tree type)
TYPE_QUALS, if one exists. If no qualified version exists yet,
return NULL_TREE. */
-tree
+ttype *
get_qualified_type (tree type, int type_quals)
{
- tree t;
+ ttype *t;
if (TYPE_QUALS (type) == type_quals)
- return type;
+ return TTYPE (type);
/* Search the chain of variants to see if there is already one there just
like the one we need to have. If so, use that existing one. We must
preserve the TYPE_NAME, since there is code that depends on this. */
- for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
+ for (t = TTYPE_MAIN_VARIANT (type); t; t = TTYPE_NEXT_VARIANT (t))
if (check_qualified_type (t, type, type_quals))
return t;
- return NULL_TREE;
+ return NULL;
}
/* Like get_qualified_type, but creates the type if it does not
@@ -6659,7 +6679,7 @@ build_aligned_type (tree type, unsigned int align)
ttype *
build_distinct_type_copy (tree type)
{
- tree t = copy_node (type);
+ ttype *t = copy_node (TTYPE (type));
TYPE_POINTER_TO (t) = 0;
TYPE_REFERENCE_TO (t) = 0;
@@ -6685,7 +6705,7 @@ build_distinct_type_copy (tree type)
whose TREE_TYPE is not t. This can also happen in the Ada
frontend when using subtypes. */
- return TTYPE (t);
+ return t;
}
/* Create a new variant of TYPE, equivalent but distinct. This is so
@@ -6697,7 +6717,7 @@ build_distinct_type_copy (tree type)
ttype *
build_variant_type_copy (tree type)
{
- tree t, m = TYPE_MAIN_VARIANT (type);
+ ttype *t, *m = TTYPE_MAIN_VARIANT (type);
t = build_distinct_type_copy (type);
@@ -6710,7 +6730,7 @@ build_variant_type_copy (tree type)
TYPE_NEXT_VARIANT (m) = t;
TYPE_MAIN_VARIANT (t) = m;
- return TTYPE (t);
+ return t;
}
/* Return true if the from tree in both tree maps are equal. */
@@ -7096,7 +7116,7 @@ type_hash_canon (unsigned int hashcode, ttype *type)
loc = type_hash_table->find_slot_with_hash (&in, hashcode, INSERT);
if (*loc)
{
- ttype *t1 = TTYPE (((type_hash *) *loc)->type);
+ ttype *t1 = ((type_hash *) *loc)->type;
gcc_assert (TYPE_MAIN_VARIANT (t1) == t1);
if (GATHER_STATISTICS)
{
@@ -7880,7 +7900,7 @@ ttype *
build_pointer_type_for_mode (tree to_type, machine_mode mode,
bool can_alias_all)
{
- tree t;
+ ttype *t;
bool could_alias = can_alias_all;
if (to_type == error_mark_node)
@@ -7901,15 +7921,15 @@ build_pointer_type_for_mode (tree to_type, machine_mode mode,
at the moment. */
if (TYPE_POINTER_TO (to_type) != 0
&& TREE_CODE (TYPE_POINTER_TO (to_type)) != POINTER_TYPE)
- return TTYPE (TYPE_POINTER_TO (to_type));
+ return TTYPE_POINTER_TO (to_type);
/* First, if we already have a type for pointers to TO_TYPE and it's
the proper mode, use it. */
- for (t = TYPE_POINTER_TO (to_type); t; t = TYPE_NEXT_PTR_TO (t))
+ for (t = TTYPE_POINTER_TO (to_type); t; t = TTYPE_NEXT_PTR_TO (t))
if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
- return TTYPE (t);
+ return t;
- t = make_node (POINTER_TYPE);
+ t = make_type_node (POINTER_TYPE);
TREE_TYPE (t) = to_type;
SET_TYPE_MODE (t, mode);
@@ -7928,7 +7948,7 @@ build_pointer_type_for_mode (tree to_type, machine_mode mode,
with expression-construction, and this simplifies them all. */
layout_type (t);
- return TTYPE (t);
+ return t;
}
/* By default build pointers in ptr_mode. */
@@ -7948,7 +7968,7 @@ ttype *
build_reference_type_for_mode (tree to_type, machine_mode mode,
bool can_alias_all)
{
- tree t;
+ ttype *t;
bool could_alias = can_alias_all;
if (to_type == error_mark_node)
@@ -7969,15 +7989,15 @@ build_reference_type_for_mode (tree to_type, machine_mode mode,
at the moment. */
if (TYPE_REFERENCE_TO (to_type) != 0
&& TREE_CODE (TYPE_REFERENCE_TO (to_type)) != REFERENCE_TYPE)
- return TTYPE (TYPE_REFERENCE_TO (to_type));
+ return TTYPE_REFERENCE_TO (to_type);
/* First, if we already have a type for pointers to TO_TYPE and it's
the proper mode, use it. */
- for (t = TYPE_REFERENCE_TO (to_type); t; t = TYPE_NEXT_REF_TO (t))
+ for (t = TTYPE_REFERENCE_TO (to_type); t; t = TTYPE_NEXT_REF_TO (t))
if (TYPE_MODE (t) == mode && TYPE_REF_CAN_ALIAS_ALL (t) == can_alias_all)
- return TTYPE (t);
+ return t;
- t = make_node (REFERENCE_TYPE);
+ t = make_type_node (REFERENCE_TYPE);
TREE_TYPE (t) = to_type;
SET_TYPE_MODE (t, mode);
@@ -7994,7 +8014,7 @@ build_reference_type_for_mode (tree to_type, machine_mode mode,
layout_type (t);
- return TTYPE (t);
+ return t;
}
@@ -9969,11 +9989,11 @@ make_or_reuse_accum_type (unsigned size, int unsignedp, int satp)
static ttype *
build_atomic_base (tree type, unsigned int align)
{
- tree t;
+ ttype *t;
/* Make sure its not already registered. */
if ((t = get_qualified_type (type, TYPE_QUAL_ATOMIC)))
- return TTYPE (t);
+ return t;
t = build_variant_type_copy (type);
set_type_quals (t, TYPE_QUAL_ATOMIC);
@@ -9981,7 +10001,7 @@ build_atomic_base (tree type, unsigned int align)
if (align)
TYPE_ALIGN (t) = align;
- return TTYPE (t);
+ return t;
}
/* Create nodes for all integer types (and error_mark_node) using the sizes
diff --git a/gcc/tree.h b/gcc/tree.h
index be08ce08a96..e9d8fc4ee7f 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1720,6 +1720,8 @@ extern void protected_set_expr_location (tree, location_t);
#define TYPE_CONTEXT(NODE) (TYPE_CHECK (NODE)->u.type_common.context)
+#define TTYPE_POINTER_TO(NODE) TTYPE ((TYPE_CHECK (NODE)->u.type_common.pointer_to))
+#define TTYPE_REFERENCE_TO(NODE) TTYPE ((TYPE_CHECK (NODE)->u.type_common.reference_to))
#define TTYPE_MAIN_VARIANT(NODE) (TTYPE (TYPE_MAIN_VARIANT (NODE)))
#define TTYPE_NEXT_VARIANT(NODE) (TTYPE (TYPE_NEXT_VARIANT(NODE)))
@@ -1982,6 +1984,10 @@ extern machine_mode element_mode (const_tree t);
#define TYPE_MAX_VALUE(NODE) \
(NUMERICAL_TYPE_CHECK (NODE)->u.type_non_common.maxval)
+#define TTYPE_NEXT_PTR_TO(NODE) \
+ TTYPE ((POINTER_TYPE_CHECK (NODE)->u.type_non_common.minval))
+#define TTYPE_NEXT_REF_TO(NODE) \
+ TTYPE ((REFERENCE_TYPE_CHECK (NODE)->u.type_non_common.minval))
/* If non-NULL, this is an upper bound of the size (in bytes) of an
object of the given ARRAY_TYPE_NON_COMMON. This allows temporaries to be
allocated. */
@@ -3706,8 +3712,8 @@ extern tree make_node_stat (enum tree_code MEM_STAT_DECL);
/* Make a copy of a node, with all the same contents. */
extern tree copy_node_stat (tree MEM_STAT_DECL);
+extern ttype *copy_node_stat (ttype *MEM_STAT_DECL);
#define copy_node(t) copy_node_stat (t MEM_STAT_INFO)
-
/* Make a copy of a chain of TREE_LIST nodes. */
extern tree copy_list (tree);
@@ -4095,7 +4101,7 @@ extern bool check_qualified_type (const_tree, const_tree, int);
TYPE_QUALS, if one exists. If no qualified version exists yet,
return NULL_TREE. */
-extern tree get_qualified_type (tree, int);
+extern ttype *get_qualified_type (tree, int);
/* Like get_qualified_type, but creates the type if it does not
exist. This function never returns NULL_TREE. */