summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorak <ak@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-01 02:51:46 +0000
committerak <ak@138bc75d-0d04-0410-961f-82ee72b054a4>2014-08-01 02:51:46 +0000
commit7fdbd1ec7e1f10a846f11cedd10d7f38531026de (patch)
tree9412b4e4e83474bf33e0a8d77c44c60844e63b6b /gcc
parentd49ae015242960c5efb755d6ffa2845ba7307d5b (diff)
downloadgcc-7fdbd1ec7e1f10a846f11cedd10d7f38531026de.tar.gz
Change inchash to name space.
Change class inchash to move into a inchash namespace as requested. The class is now inchash::hash Rename iterative_hstate_expr to inchash::add_expr ... and convert existing users. It wasn't possible to use hash::, because that lead to name space conflicts with cp and objc. So class inchash is now inchash::hash and iterative_hstate_expr is now inchash::add_expr. gcc/: 2014-07-31 Andi Kleen <ak@linux.intel.com> * inchash.h (inchash): Change inchash class to namespace. (class hash): ... Rename from inchash. (add_object): Move from macro to class template. * lto-streamer-out.c (hash_tree): Change inchash to inchash::hash. * tree.c (build_type_attribute_qual_variant): Dito. (type_hash_list): Dito. (attribute_hash_list): Dito. (iterative_hstate_expr): Rename to inchash::add_expr (build_range_type_1): Change inchash to inchash::hash and use hash::add_expr. (build_array_type_1): Dito. (build_function_type): Dito (build_method_type_directly): Dito. (build_offset_type): Dito. (build_complex_type): Dito. (make_vector_type): Dito. * tree.h (iterative_hash_expr): Dito. gcc/lto/: 2014-07-31 Andi Kleen <ak@linux.intel.com> * lto.c (hash_canonical_type): Use inchash::hash and use inchash::add_expr. (iterative_hash_canonical_type): Dito. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@213394 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/inchash.h18
-rw-r--r--gcc/lto-streamer-out.c2
-rw-r--r--gcc/lto/ChangeLog6
-rw-r--r--gcc/lto/lto.c10
-rw-r--r--gcc/tree.c57
-rw-r--r--gcc/tree.h12
7 files changed, 86 insertions, 40 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b64b5fff82e..3bd3e7abde2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,24 @@
+2014-07-31 Andi Kleen <ak@linux.intel.com>
+
+ * inchash.h (inchash): Change inchash class to namespace.
+ (class hash): ... Rename from inchash.
+ (add_object): Move from macro to class template.
+ * lto-streamer-out.c (hash_tree): Change inchash
+ to inchash::hash.
+ * tree.c (build_type_attribute_qual_variant): Dito.
+ (type_hash_list): Dito.
+ (attribute_hash_list): Dito.
+ (iterative_hstate_expr): Rename to inchash::add_expr
+ (build_range_type_1): Change inchash to inchash::hash
+ and use hash::add_expr.
+ (build_array_type_1): Dito.
+ (build_function_type): Dito
+ (build_method_type_directly): Dito.
+ (build_offset_type): Dito.
+ (build_complex_type): Dito.
+ (make_vector_type): Dito.
+ * tree.h (iterative_hash_expr): Dito.
+
2014-07-31 Chen Gang <gang.chen.5i5j@gmail.com>
* gcc.c (do_spec_1): Allocate enough space for saved_suffix.
diff --git a/gcc/inchash.h b/gcc/inchash.h
index 7af0baaddbd..c157e302509 100644
--- a/gcc/inchash.h
+++ b/gcc/inchash.h
@@ -35,12 +35,15 @@ along with GCC; see the file COPYING3. If not see
extern hashval_t iterative_hash_host_wide_int (HOST_WIDE_INT, hashval_t);
extern hashval_t iterative_hash_hashval_t (hashval_t, hashval_t);
-class inchash
+namespace inchash
+{
+
+class hash
{
public:
/* Start incremential hashing, optionally with SEED. */
- inchash (hashval_t seed = 0)
+ hash (hashval_t seed = 0)
{
val = seed;
bits = 0;
@@ -83,11 +86,16 @@ class inchash
}
/* Hash in state from other inchash OTHER. */
- void merge (inchash &other)
+ void merge (hash &other)
{
merge_hash (other.val);
}
+ template<class T> void add_object(T &obj)
+ {
+ add (&obj, sizeof(T));
+ }
+
/* Support for accumulating boolean flags */
void add_flag (bool flag)
@@ -105,7 +113,7 @@ class inchash
based on their value. This is useful for hashing commutative
expressions, so that A+B and B+A get the same hash. */
- void add_commutative (inchash &a, inchash &b)
+ void add_commutative (hash &a, hash &b)
{
if (a.end() > b.end())
{
@@ -124,6 +132,6 @@ class inchash
unsigned bits;
};
-#define add_object(o) add (&(o), sizeof (o))
+}
#endif
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 2a32958a023..23449f70aee 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -732,7 +732,7 @@ DFS::DFS_write_tree_body (struct output_block *ob,
static hashval_t
hash_tree (struct streamer_tree_cache_d *cache, hash_map<tree, hashval_t> *map, tree t)
{
- inchash hstate;
+ inchash::hash hstate;
#define visit(SIBLING) \
do { \
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index a0a21b87b76..fbb9d6b82c1 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,9 @@
+2014-07-31 Andi Kleen <ak@linux.intel.com>
+
+ * lto.c (hash_canonical_type): Use inchash::hash
+ and use inchash::add_expr.
+ (iterative_hash_canonical_type): Dito.
+
2014-07-30 Richard Biener <rguenther@suse.de>
* lto-streamer.h (lto_write_data): New function.
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 2de00fbf518..7ecdec25808 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -267,7 +267,7 @@ static hash_map<const_tree, hashval_t> *canonical_type_hash_cache;
static unsigned long num_canonical_type_hash_entries;
static unsigned long num_canonical_type_hash_queries;
-static void iterative_hash_canonical_type (tree type, inchash &hstate);
+static void iterative_hash_canonical_type (tree type, inchash::hash &hstate);
static hashval_t gimple_canonical_type_hash (const void *p);
static void gimple_register_canonical_type_1 (tree t, hashval_t hash);
@@ -279,7 +279,7 @@ static void gimple_register_canonical_type_1 (tree t, hashval_t hash);
static hashval_t
hash_canonical_type (tree type)
{
- inchash hstate;
+ inchash::hash hstate;
/* Combine a few common features of types so that types are grouped into
smaller sets; when searching for existing matching types to merge,
@@ -327,9 +327,9 @@ hash_canonical_type (tree type)
/* OMP lowering can introduce error_mark_node in place of
random local decls in types. */
if (TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != error_mark_node)
- iterative_hstate_expr (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), hstate);
+ inchash::add_expr (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), hstate);
if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != error_mark_node)
- iterative_hstate_expr (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), hstate);
+ inchash::add_expr (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), hstate);
}
/* Recurse for aggregates with a single element type. */
@@ -380,7 +380,7 @@ hash_canonical_type (tree type)
/* Returning a hash value for gimple type TYPE combined with VAL. */
static void
-iterative_hash_canonical_type (tree type, inchash &hstate)
+iterative_hash_canonical_type (tree type, inchash::hash &hstate)
{
hashval_t v;
/* An already processed type. */
diff --git a/gcc/tree.c b/gcc/tree.c
index 6669a8466c0..074be6ee2e3 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -231,8 +231,8 @@ static void print_type_hash_statistics (void);
static void print_debug_expr_statistics (void);
static void print_value_expr_statistics (void);
static int type_hash_marked_p (const void *);
-static void type_hash_list (const_tree, inchash &);
-static void attribute_hash_list (const_tree, inchash &);
+static void type_hash_list (const_tree, inchash::hash &);
+static void attribute_hash_list (const_tree, inchash::hash &);
tree global_trees[TI_MAX];
tree integer_types[itk_none];
@@ -4593,7 +4593,7 @@ build_type_attribute_qual_variant (tree ttype, tree attribute, int quals)
{
if (! attribute_list_equal (TYPE_ATTRIBUTES (ttype), attribute))
{
- inchash hstate;
+ inchash::hash hstate;
tree ntype;
int i;
tree t;
@@ -6631,7 +6631,7 @@ decl_debug_args_insert (tree from)
of the individual types. */
static void
-type_hash_list (const_tree list, inchash &hstate)
+type_hash_list (const_tree list, inchash::hash &hstate)
{
const_tree tail;
@@ -6866,7 +6866,7 @@ print_type_hash_statistics (void)
by adding the hash codes of the individual attributes. */
static void
-attribute_hash_list (const_tree list, inchash &hstate)
+attribute_hash_list (const_tree list, inchash::hash &hstate)
{
const_tree tail;
@@ -7384,13 +7384,16 @@ commutative_ternary_tree_code (enum tree_code code)
return false;
}
+namespace inchash
+{
+
/* Generate a hash value for an expression. This can be used iteratively
by passing a previous result as the HSTATE argument.
This function is intended to produce the same hash for expressions which
would compare equal using operand_equal_p. */
void
-iterative_hstate_expr (const_tree t, inchash &hstate)
+add_expr (const_tree t, inchash::hash &hstate)
{
int i;
enum tree_code code;
@@ -7431,14 +7434,14 @@ iterative_hstate_expr (const_tree t, inchash &hstate)
hstate.add ((const void *) TREE_STRING_POINTER (t), TREE_STRING_LENGTH (t));
return;
case COMPLEX_CST:
- iterative_hstate_expr (TREE_REALPART (t), hstate);
- iterative_hstate_expr (TREE_IMAGPART (t), hstate);
+ inchash::add_expr (TREE_REALPART (t), hstate);
+ inchash::add_expr (TREE_IMAGPART (t), hstate);
return;
case VECTOR_CST:
{
unsigned i;
for (i = 0; i < VECTOR_CST_NELTS (t); ++i)
- iterative_hstate_expr (VECTOR_CST_ELT (t, i), hstate);
+ inchash::add_expr (VECTOR_CST_ELT (t, i), hstate);
return;
}
case SSA_NAME:
@@ -7452,7 +7455,7 @@ iterative_hstate_expr (const_tree t, inchash &hstate)
/* A list of expressions, for a CALL_EXPR or as the elements of a
VECTOR_CST. */
for (; t; t = TREE_CHAIN (t))
- iterative_hstate_expr (TREE_VALUE (t), hstate);
+ inchash::add_expr (TREE_VALUE (t), hstate);
return;
case CONSTRUCTOR:
{
@@ -7460,8 +7463,8 @@ iterative_hstate_expr (const_tree t, inchash &hstate)
tree field, value;
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), idx, field, value)
{
- iterative_hstate_expr (field, hstate);
- iterative_hstate_expr (value, hstate);
+ inchash::add_expr (field, hstate);
+ inchash::add_expr (value, hstate);
}
return;
}
@@ -7500,7 +7503,7 @@ iterative_hstate_expr (const_tree t, inchash &hstate)
{
/* Make sure to include signness in the hash computation. */
hstate.add_int (TYPE_UNSIGNED (TREE_TYPE (t)));
- iterative_hstate_expr (TREE_OPERAND (t, 0), hstate);
+ inchash::add_expr (TREE_OPERAND (t, 0), hstate);
}
else if (commutative_tree_code (code))
@@ -7509,19 +7512,21 @@ iterative_hstate_expr (const_tree t, inchash &hstate)
however it appears. We do this by first hashing both operands
and then rehashing based on the order of their independent
hashes. */
- inchash one, two;
- iterative_hstate_expr (TREE_OPERAND (t, 0), one);
- iterative_hstate_expr (TREE_OPERAND (t, 1), two);
+ inchash::hash one, two;
+ inchash::add_expr (TREE_OPERAND (t, 0), one);
+ inchash::add_expr (TREE_OPERAND (t, 1), two);
hstate.add_commutative (one, two);
}
else
for (i = TREE_OPERAND_LENGTH (t) - 1; i >= 0; --i)
- iterative_hstate_expr (TREE_OPERAND (t, i), hstate);
+ inchash::add_expr (TREE_OPERAND (t, i), hstate);
}
return;
}
}
+}
+
/* Constructors for pointer, array and function types.
(RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
constructed by language-dependent code, not here.) */
@@ -7711,7 +7716,7 @@ static tree
build_range_type_1 (tree type, tree lowval, tree highval, bool shared)
{
tree itype = make_node (INTEGER_TYPE);
- inchash hstate;
+ inchash::hash hstate;
TREE_TYPE (itype) = type;
@@ -7739,8 +7744,8 @@ build_range_type_1 (tree type, tree lowval, tree highval, bool shared)
return itype;
}
- iterative_hstate_expr (TYPE_MIN_VALUE (itype), hstate);
- iterative_hstate_expr (TYPE_MAX_VALUE (itype), hstate);
+ inchash::add_expr (TYPE_MIN_VALUE (itype), hstate);
+ inchash::add_expr (TYPE_MAX_VALUE (itype), hstate);
hstate.merge_hash (TYPE_HASH (type));
itype = type_hash_canon (hstate.end (), itype);
@@ -7847,7 +7852,7 @@ build_array_type_1 (tree elt_type, tree index_type, bool shared)
if (shared)
{
- inchash hstate;
+ inchash::hash hstate;
hstate.add_object (TYPE_HASH (elt_type));
if (index_type)
hstate.add_object (TYPE_HASH (index_type));
@@ -7991,7 +7996,7 @@ tree
build_function_type (tree value_type, tree arg_types)
{
tree t;
- inchash hstate;
+ inchash::hash hstate;
bool any_structural_p, any_noncanonical_p;
tree canon_argtypes;
@@ -8146,7 +8151,7 @@ build_method_type_directly (tree basetype,
{
tree t;
tree ptype;
- inchash hstate;
+ inchash::hash hstate;
bool any_structural_p, any_noncanonical_p;
tree canon_argtypes;
@@ -8214,7 +8219,7 @@ tree
build_offset_type (tree basetype, tree type)
{
tree t;
- inchash hstate;
+ inchash::hash hstate;
/* Make a node of the sort we want. */
t = make_node (OFFSET_TYPE);
@@ -8251,7 +8256,7 @@ tree
build_complex_type (tree component_type)
{
tree t;
- inchash hstate;
+ inchash::hash hstate;
gcc_assert (INTEGRAL_TYPE_P (component_type)
|| SCALAR_FLOAT_TYPE_P (component_type)
@@ -9403,7 +9408,7 @@ static tree
make_vector_type (tree innertype, int nunits, enum machine_mode mode)
{
tree t;
- inchash hstate;
+ inchash::hash hstate;
t = make_node (VECTOR_TYPE);
TREE_TYPE (t) = TYPE_MAIN_VARIANT (innertype);
diff --git a/gcc/tree.h b/gcc/tree.h
index 2bb6d1fc185..9f9090a1803 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4284,14 +4284,20 @@ extern int tree_log2 (const_tree);
extern int tree_floor_log2 (const_tree);
extern unsigned int tree_ctz (const_tree);
extern int simple_cst_equal (const_tree, const_tree);
-extern void iterative_hstate_expr (const_tree, inchash &);
+
+namespace inchash
+{
+
+extern void add_expr (const_tree, hash &);
+
+}
/* Compat version until all callers are converted. Return hash for
TREE with SEED. */
static inline hashval_t iterative_hash_expr(const_tree tree, hashval_t seed)
{
- inchash hstate (seed);
- iterative_hstate_expr (tree, hstate);
+ inchash::hash hstate (seed);
+ inchash::add_expr (tree, hstate);
return hstate.end ();
}