GCC Middle and Back End API Reference
|
Go to the source code of this file.
Data Structures | |
struct | bitmap_obstack |
struct | bitmap_element_def |
struct | bitmap_head_def |
struct | bitmap_iterator |
Macros | |
#define | BITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG * 1u) |
#define | BITMAP_ELEMENT_WORDS ((128 + BITMAP_WORD_BITS - 1) / BITMAP_WORD_BITS) |
#define | BITMAP_ELEMENT_ALL_BITS (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS) |
#define | bitmap_compl_and(DST, A, B) bitmap_and_compl (DST, B, A) |
#define | bitmap_initialize(h, o) bitmap_initialize_stat (h,o MEM_STAT_INFO) |
#define | bitmap_obstack_alloc(t) bitmap_obstack_alloc_stat (t MEM_STAT_INFO) |
#define | bitmap_gc_alloc() bitmap_gc_alloc_stat (ALONE_MEM_STAT_INFO) |
#define | BITMAP_ALLOC(OBSTACK) bitmap_obstack_alloc (OBSTACK) |
#define | BITMAP_GGC_ALLOC() bitmap_gc_alloc () |
#define | BITMAP_FREE(BITMAP) ((void) (bitmap_obstack_free ((bitmap) BITMAP), (BITMAP) = (bitmap) NULL)) |
#define | EXECUTE_IF_SET_IN_BITMAP(BITMAP, MIN, BITNUM, ITER) |
#define | EXECUTE_IF_AND_IN_BITMAP(BITMAP1, BITMAP2, MIN, BITNUM, ITER) |
#define | EXECUTE_IF_AND_COMPL_IN_BITMAP(BITMAP1, BITMAP2, MIN, BITNUM, ITER) |
Typedefs | |
typedef unsigned long | BITMAP_WORD |
typedef struct bitmap_obstack | bitmap_obstack |
typedef struct bitmap_element_def | bitmap_element |
typedef struct bitmap_head_def | bitmap_head |
Variables | |
bitmap_element | bitmap_zero_bits |
bitmap_obstack | bitmap_default_obstack |
#define BITMAP_ALLOC | ( | OBSTACK | ) | bitmap_obstack_alloc (OBSTACK) |
Allocate a bitmap from a bit obstack.
Referenced by add_exit_phis(), add_new_edges_to_heap(), add_scope_conflicts_1(), btr_def_live_range(), build_succ_graph(), check_for_plus_in_loops(), clear_iv_info(), coalesce_partitions(), compute_builtin_object_size(), dead_debug_global_init(), debug_cluster(), df_get_eh_block_artificial_uses(), df_lr_verify_solution_end(), dump_split_point(), dump_update_ssa(), equiv_class_lookup_or_add(), execute_lower_tm(), fill_sons_in_loop(), find_insn_before_first_wild_read(), find_matching_predicate_in_rest_chains(), find_uses_to_rename(), free_all_edge_infos(), gate_tm_memopt(), gate_ud_dce(), get_continuation_for_phi(), get_current_def(), get_stored_val(), equiv_class_hasher::hash(), init_dom_info(), ipa_tm_create_version(), ipa_uninstrument_transaction(), kill_expr(), make_dependent_on_partition(), merge_node_constraints(), ref_indep_loop_p_2(), reorder_basic_blocks(), same_phi_alternatives_1(), scan_reads_spill(), scan_stores_nospill(), scev_reset(), sese_add_exit_phis_edge(), set_livein_block(), stmt_kills_ref_p_1(), update_alias_info_with_stack_vars(), version_to_be_replaced_p(), and vrp_operand_equal_p().
#define bitmap_compl_and | ( | DST, | |
A, | |||
B | |||
) | bitmap_and_compl (DST, B, A) |
#define BITMAP_ELEMENT_ALL_BITS (BITMAP_ELEMENT_WORDS * BITMAP_WORD_BITS) |
Number of bits in each actual element of a bitmap.
Referenced by bitmap_copy().
#define BITMAP_ELEMENT_WORDS ((128 + BITMAP_WORD_BITS - 1) / BITMAP_WORD_BITS) |
Number of words to use for each element in the linked list.
Referenced by bitmap_and(), bitmap_and_into(), bitmap_bit_p(), bitmap_elt_copy(), and bitmap_equal_p().
#define BITMAP_FREE | ( | BITMAP | ) | ((void) (bitmap_obstack_free ((bitmap) BITMAP), (BITMAP) = (bitmap) NULL)) |
Do any cleanup needed on a bitmap when it is no longer used.
Referenced by add_to_partition_kill_list(), coalesce_partitions(), compute_builtin_object_size(), df_chain_create(), dump_static_vars_set_to_file(), get_stored_val(), ipa_analyze_params_uses(), ipa_tm_create_version(), may_eliminate_iv(), ref_indep_loop_p_2(), rewrite_use_address(), same_phi_alternatives_1(), scan_stores_nospill(), sese_add_exit_phis_edge(), union_static_var_sets(), update_alias_info_with_stack_vars(), and update_rep_bb().
#define bitmap_gc_alloc | ( | ) | bitmap_gc_alloc_stat (ALONE_MEM_STAT_INFO) |
#define BITMAP_GGC_ALLOC | ( | ) | bitmap_gc_alloc () |
Allocate a gc'd bitmap.
#define bitmap_initialize | ( | h, | |
o | |||
) | bitmap_initialize_stat (h,o MEM_STAT_INFO) |
#define bitmap_obstack_alloc | ( | t | ) | bitmap_obstack_alloc_stat (t MEM_STAT_INFO) |
#define BITMAP_WORD_BITS (CHAR_BIT * SIZEOF_LONG * 1u) |
BITMAP_WORD_BITS needs to be unsigned, but cannot contain casts as it is used in preprocessor directives – hence the 1u.
#define EXECUTE_IF_AND_COMPL_IN_BITMAP | ( | BITMAP1, | |
BITMAP2, | |||
MIN, | |||
BITNUM, | |||
ITER | |||
) |
Loop over all the bits set in BITMAP1 & ~BITMAP2, starting with MIN and setting BITNUM to the bit number. ITER is a bitmap iterator. BITNUM should be treated as a read-only variable as it contains loop state.
Referenced by ref_indep_loop_p_1().
#define EXECUTE_IF_AND_IN_BITMAP | ( | BITMAP1, | |
BITMAP2, | |||
MIN, | |||
BITNUM, | |||
ITER | |||
) |
Loop over all the bits set in BITMAP1 & BITMAP2, starting with MIN and setting BITNUM to the bit number. ITER is a bitmap iterator. BITNUM should be treated as a read-only variable as it contains loop state.
#define EXECUTE_IF_SET_IN_BITMAP | ( | BITMAP, | |
MIN, | |||
BITNUM, | |||
ITER | |||
) |
Loop over all bits set in BITMAP, starting with MIN and setting BITNUM to the bit number. ITER is a bitmap iterator. BITNUM should be treated as a read-only variable as it contains loop state. See sbitmap.h for the other definition of EXECUTE_IF_SET_IN_BITMAP.
Referenced by add_exit_phis_var(), add_scope_conflicts_1(), alloc_pre_mem(), build_and_add_sum(), build_succ_graph(), compute_builtin_object_size(), compute_code_hoist_vbeinout(), create_rdg_edges_for_scalar(), debug_regset(), df_insn_rescan_debug_internal(), df_live_reset(), df_lr_alloc(), df_lr_local_compute(), df_md_alloc(), dump_replaceable_exprs(), dump_var_map(), duplicate_node_data(), find_call_crossed_cheap_reg(), find_interesting_uses_stmt(), find_invariants_to_move(), find_switch_asserts(), generate_code_for_partition(), iv_ca_add_use(), ivopts_global_cost_for_size(), live_track_live_p(), mark_last_stmt_necessary(), mark_ref_regs(), pp_points_to_solution(), prepare_block_for_update(), remove_node_data(), reset_debug_uses(), sese_add_exit_phis_edge(), setup_try_hard_regno_pseudos(), ssa_conflicts_test_p(), and vop_phi().
typedef struct bitmap_element_def bitmap_element |
Bitmap set element. We use a linked list to hold only the bits that are set. This allows for use to grow the bitset dynamically without having to realloc and copy a giant bit array.
The free list is implemented as a list of lists. There is one outer list connected together by prev fields. Each element of that outer is an inner list (that may consist only of the outer list element) that are connected by the next fields. The prev pointer is undefined for interior elements. This allows bitmap_elt_clear_from to be implemented in unit time rather than linear in the number of elements to be freed.
typedef struct bitmap_head_def bitmap_head |
Head of bitmap linked list. The 'current' member points to something already pointed to by the chain started by first, so it.
typedef struct bitmap_obstack bitmap_obstack |
Obstack for allocating bitmaps and elements from.
typedef unsigned long BITMAP_WORD |
Functions to support general ended bitmaps. Copyright (C) 1997-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/. Implementation of sparse integer sets as a linked list.
This sparse set representation is suitable for sparse sets with an unknown (a priori) universe. The set is represented as a double-linked list of container nodes (struct bitmap_element_def). Each node consists of an index for the first member that could be held in the container, a small array of integers that represent the members in the container, and pointers to the next and previous element in the linked list. The elements in the list are sorted in ascending order, i.e. the head of the list holds the element with the smallest member of the set.
For a given member I in the set:
This representation is very space-efficient for large sparse sets, and the size of the set can be changed dynamically without much overhead. An important parameter is the number of bits per element. In this implementation, there are 128 bits per element. This results in a high storage overhead per element, but a small overall overhead if the set is very sparse.
The downside is that many operations are relatively slow because the linked list has to be traversed to test membership (i.e. member_p/ add_member/remove_member). To improve the performance of this set representation, the last accessed element and its index are cached. For membership tests on members close to recently accessed members, the cached last element improves membership test to a constant-time operation.
The following operations can always be performed in O(1) time:
clear : bitmap_clear choose_one : (not implemented, but could be implemented in constant time)
The following operations can be performed in O(E) time worst-case (with E the number of elements in the linked list), but in O(1) time with a suitable access patterns:
member_p : bitmap_bit_p add_member : bitmap_set_bit remove_member : bitmap_clear_bit
The following operations can be performed in O(E) time:
cardinality : bitmap_count_bits set_size : bitmap_last_set_bit (but this could in constant time with a pointer to the last element in the chain)
Additionally, the linked-list sparse set representation supports enumeration of the members in O(E) time:
forall : EXECUTE_IF_SET_IN_BITMAP set_copy : bitmap_copy set_intersection : bitmap_intersect_p / bitmap_and / bitmap_and_into / EXECUTE_IF_AND_IN_BITMAP set_union : bitmap_ior / bitmap_ior_into set_difference : bitmap_intersect_compl_p / bitmap_and_comp / bitmap_and_comp_into / EXECUTE_IF_AND_COMPL_IN_BITMAP set_disjuction : bitmap_xor_comp / bitmap_xor_comp_into set_compare : bitmap_equal_p
Some operations on 3 sets that occur frequently in in data flow problems are also implemented:
A | (B & C) : bitmap_ior_and_into A | (B & ~C) : bitmap_ior_and_compl / bitmap_ior_and_compl_into
The storage requirements for linked-list sparse sets are O(E), with E->N in the worst case (a sparse set with large distances between the values of the set members).
The linked-list set representation works well for problems involving very sparse sets. The canonical example in GCC is, of course, the "set of sets" for some CFG-based data flow problems (liveness analysis, dominance frontiers, etc.).
This representation also works well for data flow problems where the size of the set may grow dynamically, but care must be taken that the member_p, add_member, and remove_member operations occur with a suitable access pattern.
For random-access sets with a known, relatively small universe size, the SparseSet or simple bitmap representations may be more efficient than a linked-list set. For random-access sets of unknown universe, a hash table or a balanced binary tree representation is likely to be a more suitable choice.
Traversing linked lists is usually cache-unfriendly, even with the last accessed element cached.
Cache performance can be improved by keeping the elements in the set grouped together in memory, using a dedicated obstack for a set (or group of related sets). Elements allocated on obstacks are released to a free-list and taken off the free list. If multiple sets are allocated on the same obstack, elements freed from one set may be re-used for one of the other sets. This usually helps avoid cache misses.
A single free-list is used for all sets allocated in GGC space. This is bad for persistent sets, so persistent sets should be allocated on an obstack whenever possible. Fundamental storage type for bitmap.
void bitmap_and | ( | bitmap | , |
const_bitmap | , | ||
const_bitmap | |||
) |
Boolean operations on bitmaps. The _into variants are two operand versions that modify the first source operand. The other variants are three operand versions that to not destroy the source bitmaps. The operations supported are &, & ~, |, ^.
bool bitmap_and_compl | ( | bitmap | , |
const_bitmap | , | ||
const_bitmap | |||
) |
bool bitmap_and_compl_into | ( | bitmap | , |
const_bitmap | |||
) |
bool bitmap_and_into | ( | bitmap | , |
const_bitmap | |||
) |
int bitmap_bit_p | ( | bitmap | , |
int | |||
) |
Return true if a register is set in a register set.
void bitmap_clear | ( | bitmap | ) |
Clear a bitmap by freeing up the linked list.
Clear a single bit in a bitmap. Return true if the bit changed.
void bitmap_clear_range | ( | bitmap | , |
unsigned | int, | ||
unsigned | int | ||
) |
void bitmap_compl_and_into | ( | bitmap | , |
const_bitmap | |||
) |
void bitmap_copy | ( | bitmap | , |
const_bitmap | |||
) |
Copy a bitmap to another bitmap.
unsigned long bitmap_count_bits | ( | const_bitmap | ) |
Count the number of bits set in the bitmap.
|
inline |
True if MAP is an empty bitmap.
Referenced by add_to_partition_kill_list(), bitmap_set_and(), compute_builtin_object_size(), dse_step3(), find_replaceable_exprs(), find_uses_to_rename(), get_stored_val(), prepare_block_for_update(), remove_from_partition_kill_list(), reset_debug_uses(), and setup_reg_equiv().
bool bitmap_equal_p | ( | const_bitmap | , |
const_bitmap | |||
) |
True if two bitmaps are identical.
unsigned bitmap_first_set_bit | ( | const_bitmap | ) |
bitmap bitmap_gc_alloc_stat | ( | ALONE_MEM_STAT_DECL | ) |
hashval_t bitmap_hash | ( | const_bitmap | ) |
Compute bitmap hash (for purposes of hashing etc.)
|
inlinestatic |
Initialize a bitmap header. OBSTACK indicates the bitmap obstack to allocate from, NULL for GC'd bitmap.
bool bitmap_intersect_compl_p | ( | const_bitmap | , |
const_bitmap | |||
) |
True if the complement of the second intersects the first (their AND_COMPL is non-empty).
bool bitmap_intersect_p | ( | const_bitmap | , |
const_bitmap | |||
) |
True if the bitmaps intersect (their AND is non-empty).
bool bitmap_ior | ( | bitmap | , |
const_bitmap | , | ||
const_bitmap | |||
) |
bool bitmap_ior_and_compl | ( | bitmap | DST, |
const_bitmap | A, | ||
const_bitmap | B, | ||
const_bitmap | C | ||
) |
DST = A | (B & ~C). Return true if DST changes.
bool bitmap_ior_and_compl_into | ( | bitmap | A, |
const_bitmap | B, | ||
const_bitmap | C | ||
) |
A |= (B & ~C). Return true if A changes.
bool bitmap_ior_and_into | ( | bitmap | DST, |
const_bitmap | B, | ||
const_bitmap | C | ||
) |
DST = A | (B & C). Return true if DST changes.
bool bitmap_ior_into | ( | bitmap | , |
const_bitmap | |||
) |
unsigned bitmap_last_set_bit | ( | const_bitmap | ) |
bitmap bitmap_obstack_alloc_stat | ( | bitmap_obstack *obstack | MEM_STAT_DECL | ) |
Allocate and free bitmaps from obstack, malloc and gc'd memory.
void bitmap_obstack_free | ( | bitmap | ) |
void bitmap_obstack_initialize | ( | bitmap_obstack * | ) |
Initialize and release a bitmap obstack.
void bitmap_obstack_release | ( | bitmap_obstack * | ) |
void bitmap_print | ( | FILE * | file, |
const_bitmap | head, | ||
const char * | prefix, | ||
const char * | suffix | ||
) |
Print a bitmap.
Function to print out the contents of a bitmap. Unlike debug_bitmap_file, it does not print anything but the bits.
Referenced by df_clear_flags(), and dse_step3().
void bitmap_register | ( | bitmap | MEM_STAT_DECL | ) |
void bitmap_set_range | ( | bitmap | , |
unsigned | int, | ||
unsigned | int | ||
) |
bool bitmap_single_bit_set_p | ( | const_bitmap | ) |
True if the bitmap has only a single bit set.
void bitmap_xor | ( | bitmap | , |
const_bitmap | , | ||
const_bitmap | |||
) |
void bitmap_xor_into | ( | bitmap | , |
const_bitmap | |||
) |
|
inlinestatic |
Advance to the next nonzero bit of an intersecting pair of bitmaps. We will have already advanced past the just iterated bit. Return true if there is a bit to iterate.
If our current word is nonzero, it contains the bit we want.
Round up to the word boundary. We might have just iterated past the end of the last word, hence the -1. It is not possible for bit_no to point at the beginning of the now last word.
Find the next nonzero word in this elt.
Advance to the next identical element.
Advance elt1 while it is less than elt2. We always want to advance one elt.
Advance elt2 to be no less than elt1. This might not advance.
|
inlinestatic |
Advance to the next nonzero bit in the intersection of complemented bitmaps. We will have already advanced past the just iterated bit.
If our current word is nonzero, it contains the bit we want.
Round up to the word boundary. We might have just iterated past the end of the last word, hence the -1. It is not possible for bit_no to point at the beginning of the now last word.
Find the next nonzero word in this elt.
Advance to the next element of elt1.
Advance elt2 until it is no less than elt1.
|
inlinestatic |
Initialize an iterator to iterate over the bits in MAP1 & ~MAP2.
Advance elt1 until it is not before the block containing start_bit.
Advance elt2 until it is not before elt1.
We might have advanced beyond the start_bit, so reinitialize for that.
If this word is zero, we must make sure we're not pointing at the first bit, otherwise our incrementing to the next word boundary will fail. It won't matter if this increment moves us into the next word.
|
inlinestatic |
Initialize an iterator to iterate over the intersection of two bitmaps. START_BIT is the bit to commence from.
Advance elt1 until it is not before the block containing start_bit.
Advance elt2 until it is not before elt1.
If we're at the same index, then we have some intersecting bits.
We might have advanced beyond the start_bit, so reinitialize for that.
Otherwise we must immediately advance elt1, so initialize for that.
If this word is zero, we must make sure we're not pointing at the first bit, otherwise our incrementing to the next word boundary will fail. It won't matter if this increment moves us into the next word.
|
inlinestatic |
Advance to the next bit in BI. We don't advance to the next nonzero bit yet.
|
inlinestatic |
Advance to first set bit in BI.
|
inlinestatic |
Advance to the next nonzero bit of a single bitmap, we will have already advanced past the just iterated bit. Return true if there is a bit to iterate.
If our current word is nonzero, it contains the bit we want.
Round up to the word boundary. We might have just iterated past the end of the last word, hence the -1. It is not possible for bit_no to point at the beginning of the now last word.
Find the next nonzero word in this elt.
Advance to the next element.
|
inlinestatic |
Initialize a single bitmap iterator. START_BIT is the first bit to iterate from.
Advance elt1 until it is not before the block containing start_bit.
We might have gone past the start bit, so reinitialize it.
Initialize for what is now start_bit.
If this word is zero, we must make sure we're not pointing at the first bit, otherwise our incrementing to the next word boundary will fail. It won't matter if this increment moves us into the next word.
void debug | ( | const bitmap_head_def & | ref | ) |
void debug | ( | const bitmap_head_def * | ptr | ) |
void debug_bitmap | ( | const_bitmap | ) |
Debug functions to print a bitmap linked list.
void debug_bitmap_file | ( | FILE * | , |
const_bitmap | |||
) |
|
inline |
A few compatibility/functions macros for compatibility with sbitmaps
Referenced by cgraph_redirect_edge_call_stmt_to_callee(), distribute_loop(), and dump_use().
void dump_bitmap_statistics | ( | void | ) |
Output per-bitmap memory usage statistics.
bitmap_obstack bitmap_default_obstack |
Referenced by bitmap_obstack_initialize(), df_chain_remove_problem(), and record_operand_use().
bitmap_element bitmap_zero_bits |
Global data