GCC Middle and Back End API Reference
pointer-set.c File Reference
#include "config.h"
#include "system.h"
#include "pointer-set.h"
Include dependency graph for pointer-set.c:

Data Structures

struct  pointer_map_t

Functions

static size_t hash1 ()
struct pointer_set_tpointer_set_create ()
void pointer_set_destroy ()
bool pointer_set_lookup ()
int pointer_set_contains ()
int pointer_set_insert ()
void pointer_set_traverse (const struct pointer_set_t *pset, bool(*fn)(const void *, void *), void *data)
struct pointer_map_tpointer_map_create ()
void pointer_map_destroy (struct pointer_map_t *pmap)
void ** pointer_map_contains ()
void ** pointer_map_insert ()
void pointer_map_traverse (const struct pointer_map_t *pmap, bool(*fn)(const void *, void **, void *), void *data)

Function Documentation

static size_t hash1 ( )
inlinestatic

Set operations on pointers Copyright (C) 2004-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. Use the multiplicative method, as described in Knuth 6.4, to obtain a hash code for P in the range [0, MAX). MAX == 2^LOGMAX.

Summary of this method: Multiply p by some number A that's relatively prime to 2^sizeof(size_t). The result is two words. Discard the most significant word, and return the most significant N bits of the least significant word. As suggested by Knuth, our choice for A is the integer part of (ULONG_MAX + 1.0) / phi, where phi is the golden ratio.

We don't need to do anything special for full-width multiplication because we're only interested in the least significant word of the product, and unsigned arithmetic in C is modulo the word size.

void** pointer_map_contains ( )
struct pointer_map_t* pointer_map_create ( void  )
read
void** pointer_map_insert ( )

Inserts P into PMAP if it wasn't already there. Returns a pointer to the value. P must be nonnull.

For simplicity, expand the map even if P is already there. This can be superfluous but can happen at most once.

Referenced by bound_index(), cgraph_node_set_new(), current_function_has_exception_handlers(), delete_unreachable_blocks_update_callgraph(), free_cgraph_node_set(), and get_frame_field().

void pointer_map_traverse ( const struct pointer_map_t pmap,
bool(*)(const void *, void **, void *)  fn,
void *  data 
)

Pass each pointer in PMAP to the function in FN, together with the pointer to the value and the fixed parameter DATA. If FN returns false, the iteration stops.

Referenced by adjust_iv_update_pos(), and free_var_map_entry().

int pointer_set_contains ( )

Returns nonzero if PSET contains P. P must be nonnull.

Collisions are resolved by linear probing.

References pointer_set_t::n_elements, and pointer_set_t::n_slots.

Referenced by function_always_visible_to_compiler_p(), and gimple_move_stmt_histograms().

void pointer_set_destroy ( )
int pointer_set_insert ( )

Inserts P into PSET if it wasn't already there. Returns nonzero if it was already there. P must be nonnull.

For simplicity, expand the set even if P is already there. This can be superfluous but can happen at most once.

References pointer_set_t::log_slots, pointer_set_t::n_slots, pointer_set_lookup(), and pointer_set_t::slots.

Referenced by annotate_all_with_location(), build_type_inheritance_graph(), canonicalize_component_ref(), go_output_typedef(), is_use_properly_guarded(), maybe_record_node(), odr_hasher::remove(), symtab_remove_unreachable_nodes(), and walk_polymorphic_call_targets().

bool pointer_set_lookup ( )

Lookup the slot for the pointer P and return true if it exists, otherwise return false in which case *IX points to the slot that would be used on insertion.

References pointer_set_t::n_slots, and pointer_set_t::slots.

Referenced by pointer_map< T >::insert(), pointer_map_destroy(), pointer_set_insert(), and pointer_map< T >::~pointer_map().

void pointer_set_traverse ( const struct pointer_set_t pset,
bool(*)(const void *, void *)  fn,
void *  data 
)

Pass each pointer in PSET to the function in FN, together with the fixed parameter DATA. If FN returns false, the iteration stops.

References pointer_map_t::pset, and pointer_map_t::values.