GCC Middle and Back End API Reference
hash_table< Descriptor, Lazy, Allocator > Class Template Reference

#include <hash-table.h>

Data Structures

class  iterator
 

Public Member Functions

 hash_table (size_t, bool ggc=false, bool sanitize_eq_and_hash=true, bool gather_mem_stats=GATHER_STATISTICS, mem_alloc_origin origin=HASH_TABLE_ORIGIN CXX_MEM_STAT_INFO)
 
 hash_table (const hash_table &, bool ggc=false, bool sanitize_eq_and_hash=true, bool gather_mem_stats=GATHER_STATISTICS, mem_alloc_origin origin=HASH_TABLE_ORIGIN CXX_MEM_STAT_INFO)
 
 ~hash_table ()
 
size_t size () const
 
size_t elements () const
 
size_t elements_with_deleted () const
 
void empty ()
 
bool is_empty () const
 
void clear_slot (value_type *)
 
value_typefind_with_hash (const compare_type &, hashval_t)
 
value_typefind (const value_type &value)
 
value_typefind_slot (const value_type &value, insert_option insert)
 
value_typefind_slot_with_hash (const compare_type &comparable, hashval_t hash, enum insert_option insert)
 
void remove_elt_with_hash (const compare_type &, hashval_t)
 
void remove_elt (const value_type &value)
 
template<typename Argument , int(*)(value_type *slot, Argument argument) Callback>
void traverse_noresize (Argument argument)
 
template<typename Argument , int(*)(value_type *slot, Argument argument) Callback>
void traverse (Argument argument)
 
iterator begin () const
 
iterator end () const
 
double collisions () const
 
void check_complete_insertion () const
 

Static Public Member Functions

static hash_tablecreate_ggc (size_t n, bool sanitize_eq_and_hash=true CXX_MEM_STAT_INFO)
 

Private Types

typedef Descriptor::value_type value_type
 
typedef Descriptor::compare_type compare_type
 

Private Member Functions

void operator= (hash_table &)
 
void empty_slow ()
 
value_typealloc_entries (size_t n CXX_MEM_STAT_INFO) const
 
value_typefind_empty_slot_for_expand (hashval_t)
 
void verify (const compare_type &comparable, hashval_t hash)
 
bool too_empty_p (unsigned int)
 
void expand ()
 
value_typecheck_insert_slot (value_type *ret)
 

Static Private Member Functions

static bool is_deleted (value_type &v)
 
static bool is_empty (value_type &v)
 
static void mark_deleted (value_type &v)
 
static void mark_empty (value_type &v)
 

Private Attributes

value_typem_entries
 
size_t m_size
 
size_t m_n_elements
 
size_t m_n_deleted
 
unsigned int m_searches
 
unsigned int m_collisions
 
unsigned int m_size_prime_index
 
bool m_ggc
 
bool m_sanitize_eq_and_hash
 

Static Private Attributes

static const bool m_gather_mem_stats = false
 

Friends

template<typename T >
void gt_ggc_mx (hash_table< T > *)
 
template<typename T >
void gt_pch_nx (hash_table< T > *)
 
template<typename T >
void hashtab_entry_note_pointers (void *, void *, gt_pointer_operator, void *)
 
template<typename T , typename U , typename V >
void gt_pch_nx (hash_map< T, U, V > *, gt_pointer_operator, void *)
 
template<typename T , typename U >
void gt_pch_nx (hash_set< T, false, U > *, gt_pointer_operator, void *)
 
template<typename T >
void gt_pch_nx (hash_table< T > *, gt_pointer_operator, void *)
 
template<typename T >
void gt_cleare_cache (hash_table< T > *)
 

Detailed Description

template<typename Descriptor, bool Lazy = false, template< typename Type > class Allocator = xcallocator>
class hash_table< Descriptor, Lazy, Allocator >
User-facing hash table type.

  The table stores elements of type Descriptor::value_type and uses
  the static descriptor functions described at the top of the file
  to hash, compare and remove elements.

  Specify the template Allocator to allocate and free memory.
    The default is xcallocator.

    Storage is an implementation detail and should not be used outside the
    hash table code.

Member Typedef Documentation

◆ compare_type

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
typedef Descriptor::compare_type hash_table< Descriptor, Lazy, Allocator >::compare_type
private

◆ value_type

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
typedef Descriptor::value_type hash_table< Descriptor, Lazy, Allocator >::value_type
private

Constructor & Destructor Documentation

◆ hash_table() [1/2]

◆ hash_table() [2/2]

◆ ~hash_table()

Member Function Documentation

◆ alloc_entries()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
hash_table< Descriptor, Lazy, Allocator >::value_type * hash_table< Descriptor, Lazy, Allocator >::alloc_entries ( size_t n MEM_STAT_DECL) const
inlineprivate

◆ begin()

◆ check_complete_insertion()

◆ check_insert_slot()

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
value_type * hash_table< Descriptor, Lazy, Allocator >::check_insert_slot ( value_type * ret)
inlineprivate

◆ clear_slot()

◆ collisions()

◆ create_ggc()

◆ elements()

◆ elements_with_deleted()

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
size_t hash_table< Descriptor, Lazy, Allocator >::elements_with_deleted ( ) const
inline

◆ empty()

◆ empty_slow()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
void hash_table< Descriptor, Lazy, Allocator >::empty_slow ( )
private
Implements empty() in cases where it isn't a no-op.   

References ggc_alloc(), ggc_free(), hash_table_higher_prime_index(), i, is_empty(), prime_ent::prime, and prime_tab.

Referenced by hash_table< Descriptor, Lazy, Allocator >::empty().

◆ end()

◆ expand()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
void hash_table< Descriptor, Lazy, Allocator >::expand ( )
private
The following function changes size of memory allocated for the
entries and repeatedly inserts the table elements.  The occupancy
of the table after the call will be about 50%.  Naturally the hash
table must already exist.  Remember also that the place of the
table entries is changed.  If memory allocation fails, this function
will abort.   

References gcc_checking_assert, ggc_alloc(), ggc_free(), hash_table_higher_prime_index(), hash_table_usage(), is_empty(), prime_ent::prime, and prime_tab.

◆ find()

◆ find_empty_slot_for_expand()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
hash_table< Descriptor, Lazy, Allocator >::value_type * hash_table< Descriptor, Lazy, Allocator >::find_empty_slot_for_expand ( hashval_t hash)
private
Similar to find_slot, but without several unwanted side effects:
 - Does not call equal when it finds an existing entry.
 - Does not change the count of elements/searches/collisions in the
   hash table.
This function also assumes there are no deleted entries in the table.
HASH is the hash value for the element to be inserted.   

References gcc_checking_assert, ggc_alloc(), hash_table_mod1(), hash_table_mod2(), and is_empty().

◆ find_slot()

◆ find_slot_with_hash()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
hash_table< Descriptor, Lazy, Allocator >::value_type * hash_table< Descriptor, Lazy, Allocator >::find_slot_with_hash ( const compare_type & comparable,
hashval_t hash,
enum insert_option insert )
This function searches for a hash table slot containing an entry
equal to the given COMPARABLE element and starting with the given
HASH.  To delete an entry, call this with insert=NO_INSERT, then
call clear_slot on the slot returned (possibly after doing some
checks).  To insert an entry, call this with insert=INSERT, then
write the value you want into the returned slot.  When inserting an
entry, NULL may be returned if memory allocation fails.  

References ggc_alloc(), hash_table_mod1(), hash_table_mod2(), insert(), is_empty(), and NULL.

Referenced by hash_set< KeyId, Lazy, Traits >::add(), cgraph_add_edge_to_call_site_hash(), cgraph_update_edge_in_call_site_hash(), hash_set< KeyId, Lazy, Traits >::contains(), cvc_insert(), do_unwind(), find_coalesce_pair(), hash_table< Descriptor, Lazy, Allocator >::find_slot(), force_const_mem(), symtab_node::get_for_asmname(), get_odr_type(), symbol_table::insert_to_assembler_name_hash(), move_sese_region_to_fn(), notify_dependents_of_changed_value(), optimize_constant_pool(), avail_exprs_stack::record_cond(), release_section_hash_entry(), remove_value_from_changed_variables(), symtab_node::set_section_for_node(), shared_hash_find_slot_1(), shared_hash_find_slot_noinsert_1(), shared_hash_find_slot_unshare_1(), symbol_table::unlink_from_assembler_name_hash(), unshare_variable(), variable_from_dropped(), variable_was_changed(), vars_copy(), visit_reference_op_call(), vn_nary_op_lookup_1(), vn_phi_insert(), vn_phi_lookup(), vn_reference_insert(), vn_reference_insert_pieces(), vn_reference_lookup_1(), and vn_reference_lookup_2().

◆ find_with_hash()

◆ is_deleted()

◆ is_empty() [1/2]

◆ is_empty() [2/2]

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
static bool hash_table< Descriptor, Lazy, Allocator >::is_empty ( value_type & v)
inlinestaticprivate

◆ mark_deleted()

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
static void hash_table< Descriptor, Lazy, Allocator >::mark_deleted ( value_type & v)
inlinestaticprivate

◆ mark_empty()

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
static void hash_table< Descriptor, Lazy, Allocator >::mark_empty ( value_type & v)
inlinestaticprivate

◆ operator=()

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
void hash_table< Descriptor, Lazy, Allocator >::operator= ( hash_table< Descriptor, Lazy, Allocator > & )
private

◆ remove_elt()

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
void hash_table< Descriptor, Lazy, Allocator >::remove_elt ( const value_type & value)
inline

◆ remove_elt_with_hash()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
void hash_table< Descriptor, Lazy, Allocator >::remove_elt_with_hash ( const compare_type & comparable,
hashval_t hash )
This function deletes an element with the given COMPARABLE value
from hash table starting with the given HASH.  If there is no
matching element in the hash table, this function does nothing.  

References ggc_alloc(), and NULL.

Referenced by hash_set< KeyId, Lazy, Traits >::remove(), cgraph_edge::remove_caller(), hash_table< Descriptor, Lazy, Allocator >::remove_elt(), and cgraph_edge::set_call_stmt().

◆ size()

◆ too_empty_p()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
bool hash_table< Descriptor, Lazy, Allocator >::too_empty_p ( unsigned int elts)
inlineprivate
Return true if the current table is excessively big for ELTS elements.   

◆ traverse()

◆ traverse_noresize()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
void hash_table< Descriptor, Lazy, Allocator >::traverse_noresize ( Argument argument)
This function scans over the entire hash table calling CALLBACK for
each live entry.  If CALLBACK returns false, the iteration stops.
ARGUMENT is passed as CALLBACK's second argument.  

References ggc_alloc(), is_empty(), and NULL.

Referenced by statistics_fini().

◆ verify()

template<typename Descriptor , bool Lazy, template< typename Type > class Allocator>
void hash_table< Descriptor, Lazy, Allocator >::verify ( const compare_type & comparable,
hashval_t hash )
private
Verify that all existing elements in the hash table which are
equal to COMPARABLE have an equal HASH value provided as argument.
Also check that the hash table element counts are correct.   

References gcc_checking_assert, ggc_alloc(), hash_table_sanitize_eq_limit, hashtab_chk_error(), i, is_empty(), and MIN.

Friends And Related Symbol Documentation

◆ gt_cleare_cache

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
template<typename T >
void gt_cleare_cache ( hash_table< T > * )
friend

◆ gt_ggc_mx

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
template<typename T >
void gt_ggc_mx ( hash_table< T > * )
friend

◆ gt_pch_nx [1/4]

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
template<typename T , typename U , typename V >
void gt_pch_nx ( hash_map< T, U, V > * ,
gt_pointer_operator ,
void *  )
friend

◆ gt_pch_nx [2/4]

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
template<typename T , typename U >
void gt_pch_nx ( hash_set< T, false, U > * ,
gt_pointer_operator ,
void *  )
friend

◆ gt_pch_nx [3/4]

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
template<typename T >
void gt_pch_nx ( hash_table< T > * )
friend

◆ gt_pch_nx [4/4]

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
template<typename T >
void gt_pch_nx ( hash_table< T > * ,
gt_pointer_operator ,
void *  )
friend

◆ hashtab_entry_note_pointers

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
template<typename T >
void hashtab_entry_note_pointers ( void * obj,
void * h,
gt_pointer_operator op,
void * cookie )
friend

Field Documentation

◆ m_collisions

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
unsigned int hash_table< Descriptor, Lazy, Allocator >::m_collisions
private

◆ m_entries

◆ m_gather_mem_stats

◆ m_ggc

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
bool hash_table< Descriptor, Lazy, Allocator >::m_ggc
private

◆ m_n_deleted

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
size_t hash_table< Descriptor, Lazy, Allocator >::m_n_deleted
private

◆ m_n_elements

◆ m_sanitize_eq_and_hash

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
bool hash_table< Descriptor, Lazy, Allocator >::m_sanitize_eq_and_hash
private

◆ m_searches

template<typename Descriptor , bool Lazy = false, template< typename Type > class Allocator = xcallocator>
unsigned int hash_table< Descriptor, Lazy, Allocator >::m_searches
private

◆ m_size

◆ m_size_prime_index


The documentation for this class was generated from the following file: