remove param1_is usage

gcc/

	* hash-map.h (hash_map::iterator): New class.
	(hash_map::begin): New method.
	(hash_map::end): Likewise.
	* alias.c, config/alpha/alpha.c, dwarf2asm.c, omp-low.c, tree.h:
	replace splay_tree with hash_map.

From-SVN: r217869
This commit is contained in:
Trevor Saunders 2014-11-20 15:10:33 +00:00 committed by Trevor Saunders
parent 1f012f560f
commit de144fb24f
7 changed files with 138 additions and 91 deletions

View File

@ -1,3 +1,11 @@
2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* hash-map.h (hash_map::iterator): New class.
(hash_map::begin): New method.
(hash_map::end): Likewise.
* alias.c, config/alpha/alpha.c, dwarf2asm.c, omp-low.c, tree.h:
replace splay_tree with hash_map.
2014-11-20 Trevor Saunders <tsaunders@mozilla.com> 2014-11-20 Trevor Saunders <tsaunders@mozilla.com>
* hash-table.h (hash_table::hash_table): Call alloc_entries. * hash-table.h (hash_table::hash_table): Call alloc_entries.

View File

@ -40,7 +40,7 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h" #include "flags.h"
#include "diagnostic-core.h" #include "diagnostic-core.h"
#include "cselib.h" #include "cselib.h"
#include "splay-tree.h" #include "hash-map.h"
#include "langhooks.h" #include "langhooks.h"
#include "timevar.h" #include "timevar.h"
#include "dumpfile.h" #include "dumpfile.h"
@ -139,6 +139,32 @@ along with GCC; see the file COPYING3. If not see
However, this is no actual entry for alias set zero. It is an However, this is no actual entry for alias set zero. It is an
error to attempt to explicitly construct a subset of zero. */ error to attempt to explicitly construct a subset of zero. */
struct alias_set_traits : default_hashmap_traits
{
template<typename T>
static bool
is_empty (T &e)
{
return e.m_key == INT_MIN;
}
template<typename T>
static bool
is_deleted (T &e)
{
return e.m_key == (INT_MIN + 1);
}
template<typename T> static void mark_empty (T &e) { e.m_key = INT_MIN; }
template<typename T>
static void
mark_deleted (T &e)
{
e.m_key = INT_MIN + 1;
}
};
struct GTY(()) alias_set_entry_d { struct GTY(()) alias_set_entry_d {
/* The alias set number, as stored in MEM_ALIAS_SET. */ /* The alias set number, as stored in MEM_ALIAS_SET. */
alias_set_type alias_set; alias_set_type alias_set;
@ -154,7 +180,7 @@ struct GTY(()) alias_set_entry_d {
continuing our example above, the children here will be all of continuing our example above, the children here will be all of
`int', `double', `float', and `struct S'. */ `int', `double', `float', and `struct S'. */
splay_tree GTY((param1_is (int), param2_is (int))) children; hash_map<int, int, alias_set_traits> *children;
}; };
typedef struct alias_set_entry_d *alias_set_entry; typedef struct alias_set_entry_d *alias_set_entry;
@ -165,7 +191,6 @@ static int base_alias_check (rtx, rtx, rtx, rtx, machine_mode,
machine_mode); machine_mode);
static rtx find_base_value (rtx); static rtx find_base_value (rtx);
static int mems_in_disjoint_alias_sets_p (const_rtx, const_rtx); static int mems_in_disjoint_alias_sets_p (const_rtx, const_rtx);
static int insert_subset_children (splay_tree_node, void*);
static alias_set_entry get_alias_set_entry (alias_set_type); static alias_set_entry get_alias_set_entry (alias_set_type);
static tree decl_for_component_ref (tree); static tree decl_for_component_ref (tree);
static int write_dependence_p (const_rtx, static int write_dependence_p (const_rtx,
@ -405,17 +430,6 @@ mems_in_disjoint_alias_sets_p (const_rtx mem1, const_rtx mem2)
return ! alias_sets_conflict_p (MEM_ALIAS_SET (mem1), MEM_ALIAS_SET (mem2)); return ! alias_sets_conflict_p (MEM_ALIAS_SET (mem1), MEM_ALIAS_SET (mem2));
} }
/* Insert the NODE into the splay tree given by DATA. Used by
record_alias_subset via splay_tree_foreach. */
static int
insert_subset_children (splay_tree_node node, void *data)
{
splay_tree_insert ((splay_tree) data, node->key, node->value);
return 0;
}
/* Return true if the first alias set is a subset of the second. */ /* Return true if the first alias set is a subset of the second. */
bool bool
@ -431,8 +445,7 @@ alias_set_subset_of (alias_set_type set1, alias_set_type set2)
ase = get_alias_set_entry (set2); ase = get_alias_set_entry (set2);
if (ase != 0 if (ase != 0
&& (ase->has_zero_child && (ase->has_zero_child
|| splay_tree_lookup (ase->children, || ase->children->get (set1)))
(splay_tree_key) set1)))
return true; return true;
return false; return false;
} }
@ -452,16 +465,14 @@ alias_sets_conflict_p (alias_set_type set1, alias_set_type set2)
ase = get_alias_set_entry (set1); ase = get_alias_set_entry (set1);
if (ase != 0 if (ase != 0
&& (ase->has_zero_child && (ase->has_zero_child
|| splay_tree_lookup (ase->children, || ase->children->get (set2)))
(splay_tree_key) set2)))
return 1; return 1;
/* Now do the same, but with the alias sets reversed. */ /* Now do the same, but with the alias sets reversed. */
ase = get_alias_set_entry (set2); ase = get_alias_set_entry (set2);
if (ase != 0 if (ase != 0
&& (ase->has_zero_child && (ase->has_zero_child
|| splay_tree_lookup (ase->children, || ase->children->get (set1)))
(splay_tree_key) set1)))
return 1; return 1;
/* The two alias sets are distinct and neither one is the /* The two alias sets are distinct and neither one is the
@ -956,9 +967,7 @@ record_alias_subset (alias_set_type superset, alias_set_type subset)
superset_entry = ggc_cleared_alloc<alias_set_entry_d> (); superset_entry = ggc_cleared_alloc<alias_set_entry_d> ();
superset_entry->alias_set = superset; superset_entry->alias_set = superset;
superset_entry->children superset_entry->children
= splay_tree_new_ggc (splay_tree_compare_ints, = hash_map<int, int, alias_set_traits>::create_ggc (64);
ggc_alloc_splay_tree_scalar_scalar_splay_tree_s,
ggc_alloc_splay_tree_scalar_scalar_splay_tree_node_s);
superset_entry->has_zero_child = 0; superset_entry->has_zero_child = 0;
(*alias_sets)[superset] = superset_entry; (*alias_sets)[superset] = superset_entry;
} }
@ -975,13 +984,14 @@ record_alias_subset (alias_set_type superset, alias_set_type subset)
if (subset_entry->has_zero_child) if (subset_entry->has_zero_child)
superset_entry->has_zero_child = 1; superset_entry->has_zero_child = 1;
splay_tree_foreach (subset_entry->children, insert_subset_children, hash_map<int, int, alias_set_traits>::iterator iter
superset_entry->children); = subset_entry->children->begin ();
for (; iter != subset_entry->children->end (); ++iter)
superset_entry->children->put ((*iter).first, (*iter).second);
} }
/* Enter the SUBSET itself as a child of the SUPERSET. */ /* Enter the SUBSET itself as a child of the SUPERSET. */
splay_tree_insert (superset_entry->children, superset_entry->children->put (subset, 0);
(splay_tree_key) subset, 0);
} }
} }

View File

@ -56,7 +56,7 @@ along with GCC; see the file COPYING3. If not see
#include "common/common-target.h" #include "common/common-target.h"
#include "debug.h" #include "debug.h"
#include "langhooks.h" #include "langhooks.h"
#include "splay-tree.h" #include "hash-map.h"
#include "hash-table.h" #include "hash-table.h"
#include "predict.h" #include "predict.h"
#include "dominance.h" #include "dominance.h"
@ -4860,6 +4860,14 @@ alpha_multipass_dfa_lookahead (void)
struct GTY(()) alpha_links; struct GTY(()) alpha_links;
struct string_traits : default_hashmap_traits
{
static bool equal_keys (const char *const &a, const char *const &b)
{
return strcmp (a, b) == 0;
}
};
struct GTY(()) machine_function struct GTY(()) machine_function
{ {
/* For flag_reorder_blocks_and_partition. */ /* For flag_reorder_blocks_and_partition. */
@ -4869,8 +4877,7 @@ struct GTY(()) machine_function
bool uses_condition_handler; bool uses_condition_handler;
/* Linkage entries. */ /* Linkage entries. */
splay_tree GTY ((param1_is (char *), param2_is (struct alpha_links *))) hash_map<const char *, alpha_links *, string_traits> *links;
links;
}; };
/* How to allocate a 'struct machine_function'. */ /* How to allocate a 'struct machine_function'. */
@ -9642,18 +9649,14 @@ alpha_use_linkage (rtx func, bool lflag, bool rflag)
if (cfun->machine->links) if (cfun->machine->links)
{ {
splay_tree_node lnode;
/* Is this name already defined? */ /* Is this name already defined? */
lnode = splay_tree_lookup (cfun->machine->links, (splay_tree_key) name); alpha_links *slot = cfun->machine->links->get (name);
if (lnode) if (slot)
al = (struct alpha_links *) lnode->value; al = *slot;
} }
else else
cfun->machine->links = splay_tree_new_ggc cfun->machine->links
((splay_tree_compare_fn) strcmp, = hash_map<const char *, alpha_links *, string_traits>::create_ggc (64);
ggc_alloc_splay_tree_str_alpha_links_splay_tree_s,
ggc_alloc_splay_tree_str_alpha_links_splay_tree_node_s);
if (al == NULL) if (al == NULL)
{ {
@ -9681,9 +9684,7 @@ alpha_use_linkage (rtx func, bool lflag, bool rflag)
al->func = func; al->func = func;
al->linkage = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (linksym)); al->linkage = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (linksym));
splay_tree_insert (cfun->machine->links, cfun->machine->links->put (ggc_strdup (name), al);
(splay_tree_key) ggc_strdup (name),
(splay_tree_value) al);
} }
al->rkind = rflag ? KIND_CODEADDR : KIND_LINKAGE; al->rkind = rflag ? KIND_CODEADDR : KIND_LINKAGE;
@ -9695,12 +9696,8 @@ alpha_use_linkage (rtx func, bool lflag, bool rflag)
} }
static int static int
alpha_write_one_linkage (splay_tree_node node, void *data) alpha_write_one_linkage (const char *name, alpha_links *link, FILE *steam)
{ {
const char *const name = (const char *) node->key;
struct alpha_links *link = (struct alpha_links *) node->value;
FILE *stream = (FILE *) data;
ASM_OUTPUT_INTERNAL_LABEL (stream, XSTR (link->linkage, 0)); ASM_OUTPUT_INTERNAL_LABEL (stream, XSTR (link->linkage, 0));
if (link->rkind == KIND_CODEADDR) if (link->rkind == KIND_CODEADDR)
{ {
@ -9750,8 +9747,10 @@ alpha_write_linkage (FILE *stream, const char *funname)
if (cfun->machine->links) if (cfun->machine->links)
{ {
splay_tree_foreach (cfun->machine->links, alpha_write_one_linkage, stream); hash_map<const char *, alpha_links *, string_traits>::iterator iter
/* splay_tree_delete (func->links); */ = cfun->machine->links->begin ();
for (; iter != cfun->machine->links->end (); ++iter)
alpha_write_one_linkage ((*iter).first, (*iter).second, stream);
} }
} }

View File

@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "target.h" #include "target.h"
#include "dwarf2asm.h" #include "dwarf2asm.h"
#include "dwarf2.h" #include "dwarf2.h"
#include "splay-tree.h" #include "hash-map.h"
#include "ggc.h" #include "ggc.h"
#include "tm_p.h" #include "tm_p.h"
@ -790,9 +790,7 @@ dw2_asm_output_delta_sleb128 (const char *lab1 ATTRIBUTE_UNUSED,
} }
#endif /* 0 */ #endif /* 0 */
static int dw2_output_indirect_constant_1 (splay_tree_node, void *); static GTY(()) hash_map<const char *, tree> *indirect_pool;
static GTY((param1_is (char *), param2_is (tree))) splay_tree indirect_pool;
static GTY(()) int dw2_const_labelno; static GTY(()) int dw2_const_labelno;
@ -802,16 +800,16 @@ static GTY(()) int dw2_const_labelno;
# define USE_LINKONCE_INDIRECT 0 # define USE_LINKONCE_INDIRECT 0
#endif #endif
/* Comparison function for a splay tree in which the keys are strings. /* Compare two std::pair<const char *, tree> by their first element.
K1 and K2 have the dynamic type "const char *". Returns <0, 0, or Returns <0, 0, or
>0 to indicate whether K1 is less than, equal to, or greater than >0 to indicate whether K1 is less than, equal to, or greater than
K2, respectively. */ K2, respectively. */
static int static int
splay_tree_compare_strings (splay_tree_key k1, splay_tree_key k2) compare_strings (const void *a, const void *b)
{ {
const char *s1 = (const char *)k1; const char *s1 = ((const std::pair<const char *, tree> *) a)->first;
const char *s2 = (const char *)k2; const char *s2 = ((const std::pair<const char *, tree> *) b)->first;
int ret; int ret;
if (s1 == s2) if (s1 == s2)
@ -836,23 +834,18 @@ splay_tree_compare_strings (splay_tree_key k1, splay_tree_key k2)
rtx rtx
dw2_force_const_mem (rtx x, bool is_public) dw2_force_const_mem (rtx x, bool is_public)
{ {
splay_tree_node node;
const char *key; const char *key;
tree decl_id; tree decl_id;
if (! indirect_pool) if (! indirect_pool)
/* We use strcmp, rather than just comparing pointers, so that the indirect_pool = hash_map<const char *, tree>::create_ggc (64);
sort order will not depend on the host system. */
indirect_pool = splay_tree_new_ggc (splay_tree_compare_strings,
ggc_alloc_splay_tree_str_tree_node_splay_tree_s,
ggc_alloc_splay_tree_str_tree_node_splay_tree_node_s);
gcc_assert (GET_CODE (x) == SYMBOL_REF); gcc_assert (GET_CODE (x) == SYMBOL_REF);
key = XSTR (x, 0); key = XSTR (x, 0);
node = splay_tree_lookup (indirect_pool, (splay_tree_key) key); tree *slot = indirect_pool->get (key);
if (node) if (slot)
decl_id = (tree) node->value; decl_id = *slot;
else else
{ {
tree id; tree id;
@ -881,26 +874,20 @@ dw2_force_const_mem (rtx x, bool is_public)
if (id) if (id)
TREE_SYMBOL_REFERENCED (id) = 1; TREE_SYMBOL_REFERENCED (id) = 1;
splay_tree_insert (indirect_pool, (splay_tree_key) key, indirect_pool->put (key, decl_id);
(splay_tree_value) decl_id);
} }
return gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (decl_id)); return gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (decl_id));
} }
/* A helper function for dw2_output_indirect_constants called through /* A helper function for dw2_output_indirect_constants. Emit one queued
splay_tree_foreach. Emit one queued constant to memory. */ constant to memory. */
static int static int
dw2_output_indirect_constant_1 (splay_tree_node node, dw2_output_indirect_constant_1 (const char *sym, tree id)
void *data ATTRIBUTE_UNUSED)
{ {
const char *sym;
rtx sym_ref; rtx sym_ref;
tree id, decl; tree decl;
sym = (const char *) node->key;
id = (tree) node->value;
decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, id, ptr_type_node); decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, id, ptr_type_node);
SET_DECL_ASSEMBLER_NAME (decl, id); SET_DECL_ASSEMBLER_NAME (decl, id);
@ -930,8 +917,18 @@ dw2_output_indirect_constant_1 (splay_tree_node node,
void void
dw2_output_indirect_constants (void) dw2_output_indirect_constants (void)
{ {
if (indirect_pool) if (!indirect_pool)
splay_tree_foreach (indirect_pool, dw2_output_indirect_constant_1, NULL); return;
auto_vec<std::pair<const char *, tree> > temp (indirect_pool->elements ());
for (hash_map<const char *, tree>::iterator iter = indirect_pool->begin ();
iter != indirect_pool->end (); ++iter)
temp.quick_push (*iter);
temp.qsort (compare_strings);
for (unsigned int i = 0; i < temp.length (); i++)
dw2_output_indirect_constant_1 (temp[i].first, temp[i].second);
} }
/* Like dw2_asm_output_addr_rtx, but encode the pointer as directed. /* Like dw2_asm_output_addr_rtx, but encode the pointer as directed.

View File

@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see
#define hash_map_h #define hash_map_h
#include <new> #include <new>
#include <utility>
#include "hash-table.h" #include "hash-table.h"
/* implement default behavior for traits when types allow it. */ /* implement default behavior for traits when types allow it. */
@ -266,6 +267,39 @@ public:
size_t elements () const { return m_table.elements (); } size_t elements () const { return m_table.elements (); }
class iterator
{
public:
explicit iterator (const typename hash_table<hash_entry>::iterator &iter) :
m_iter (iter) {}
iterator &operator++ ()
{
++m_iter;
return *this;
}
std::pair<Key, Value> operator* ()
{
hash_entry &e = *m_iter;
return std::pair<Key, Value> (e.m_key, e.m_value);
}
bool
operator != (const iterator &other) const
{
return m_iter != other.m_iter;
}
private:
typename hash_table<hash_entry>::iterator m_iter;
};
/* Standard iterator retrieval methods. */
iterator begin () const { return iterator (m_table.begin ()); }
iterator end () const { return iterator (m_table.end ()); }
private: private:
template<typename T, typename U, typename V> friend void gt_ggc_mx (hash_map<T, U, V> *); template<typename T, typename U, typename V> friend void gt_ggc_mx (hash_map<T, U, V> *);

View File

@ -9330,8 +9330,7 @@ lower_omp_ordered (gimple_stmt_iterator *gsi_p, omp_context *ctx)
requires that languages coordinate a symbol name. It is therefore requires that languages coordinate a symbol name. It is therefore
best put here in common code. */ best put here in common code. */
static GTY((param1_is (tree), param2_is (tree))) static GTY(()) hash_map<tree, tree> *critical_name_mutexes;
splay_tree critical_name_mutexes;
static void static void
lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx) lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
@ -9347,15 +9346,11 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
if (name) if (name)
{ {
tree decl; tree decl;
splay_tree_node n;
if (!critical_name_mutexes) if (!critical_name_mutexes)
critical_name_mutexes critical_name_mutexes = hash_map<tree, tree>::create_ggc (10);
= splay_tree_new_ggc (splay_tree_compare_pointers,
ggc_alloc_splay_tree_tree_node_tree_node_splay_tree_s,
ggc_alloc_splay_tree_tree_node_tree_node_splay_tree_node_s);
n = splay_tree_lookup (critical_name_mutexes, (splay_tree_key) name); tree *n = critical_name_mutexes->get (name);
if (n == NULL) if (n == NULL)
{ {
char *new_str; char *new_str;
@ -9383,11 +9378,10 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
varpool_node::finalize_decl (decl); varpool_node::finalize_decl (decl);
splay_tree_insert (critical_name_mutexes, (splay_tree_key) name, critical_name_mutexes->put (name, decl);
(splay_tree_value) decl);
} }
else else
decl = (tree) n->value; decl = *n;
lock = builtin_decl_explicit (BUILT_IN_GOMP_CRITICAL_NAME_START); lock = builtin_decl_explicit (BUILT_IN_GOMP_CRITICAL_NAME_START);
lock = build_call_expr_loc (loc, lock, 1, build_fold_addr_expr_loc (loc, decl)); lock = build_call_expr_loc (loc, lock, 1, build_fold_addr_expr_loc (loc, decl));

View File

@ -4875,4 +4875,9 @@ int_bit_position (const_tree field)
return (wi::lshift (wi::to_offset (DECL_FIELD_OFFSET (field)), BITS_PER_UNIT_LOG) return (wi::lshift (wi::to_offset (DECL_FIELD_OFFSET (field)), BITS_PER_UNIT_LOG)
+ wi::to_offset (DECL_FIELD_BIT_OFFSET (field))).to_shwi (); + wi::to_offset (DECL_FIELD_BIT_OFFSET (field))).to_shwi ();
} }
extern void gt_ggc_mx (tree &);
extern void gt_pch_nx (tree &);
extern void gt_pch_nx (tree &, gt_pointer_operator, void *);
#endif /* GCC_TREE_H */ #endif /* GCC_TREE_H */