GCC Middle and Back End API Reference
sbitmap.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  simple_bitmap_def
 
struct  sbitmap_iterator
 
class  auto_sbitmap
 

Macros

#define SBITMAP_ELT_BITS   (HOST_BITS_PER_WIDEST_FAST_INT * 1u)
 
#define SBITMAP_ELT_TYPE   unsigned HOST_WIDEST_FAST_INT
 
#define SBITMAP_SET_SIZE(N)   (((N) + SBITMAP_ELT_BITS - 1) / SBITMAP_ELT_BITS)
 
#define SBITMAP_SIZE(BITMAP)   ((BITMAP)->n_bits)
 
#define EXECUTE_IF_SET_IN_BITMAP(BITMAP, MIN, BITNUM, ITER)
 

Functions

void bitmap_check_index (const_sbitmap map, int index)
 
void bitmap_check_sizes (const_sbitmap a, const_sbitmap b)
 
bool bitmap_bit_p (const_sbitmap map, int bitno)
 
bool bitmap_set_bit (sbitmap map, int bitno)
 
bool bitmap_clear_bit (sbitmap map, int bitno)
 
void bmp_iter_set_init (sbitmap_iterator *i, const_sbitmap bmp, unsigned int min, unsigned *bit_no)
 
bool bmp_iter_set (sbitmap_iterator *i, unsigned int *n)
 
void bmp_iter_next (sbitmap_iterator *i, unsigned *bit_no)
 
void sbitmap_free (sbitmap map)
 
void sbitmap_vector_free (sbitmap *vec)
 
void dump_bitmap (FILE *, const_sbitmap)
 
void debug_raw (const simple_bitmap_def &ref)
 
void debug_raw (const simple_bitmap_def *ptr)
 
void dump_bitmap_file (FILE *, const_sbitmap)
 
void debug (const simple_bitmap_def &ref)
 
void debug (const simple_bitmap_def *ptr)
 
void dump_bitmap_vector (FILE *, const char *, const char *, sbitmap *, int)
 
sbitmap sbitmap_alloc (unsigned int)
 
sbitmapsbitmap_vector_alloc (unsigned int, unsigned int)
 
sbitmap sbitmap_resize (sbitmap, unsigned int, int)
 
void bitmap_copy (sbitmap, const_sbitmap)
 
bool bitmap_equal_p (const_sbitmap, const_sbitmap)
 
unsigned int bitmap_count_bits (const_sbitmap)
 
bool bitmap_empty_p (const_sbitmap)
 
void bitmap_clear (sbitmap)
 
void bitmap_clear_range (sbitmap, unsigned, unsigned)
 
void bitmap_set_range (sbitmap, unsigned, unsigned)
 
void bitmap_ones (sbitmap)
 
void bitmap_vector_clear (sbitmap *, unsigned int)
 
void bitmap_vector_ones (sbitmap *, unsigned int)
 
bool bitmap_ior_and_compl (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap)
 
void bitmap_and_compl (sbitmap, const_sbitmap, const_sbitmap)
 
void bitmap_not (sbitmap, const_sbitmap)
 
bool bitmap_or_and (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap)
 
bool bitmap_and_or (sbitmap, const_sbitmap, const_sbitmap, const_sbitmap)
 
bool bitmap_intersect_p (const_sbitmap, const_sbitmap)
 
bool bitmap_and (sbitmap, const_sbitmap, const_sbitmap)
 
bool bitmap_ior (sbitmap, const_sbitmap, const_sbitmap)
 
bool bitmap_xor (sbitmap, const_sbitmap, const_sbitmap)
 
bool bitmap_subset_p (const_sbitmap, const_sbitmap)
 
bool bitmap_bit_in_range_p (const_sbitmap, unsigned int, unsigned int)
 
int bitmap_first_set_bit (const_sbitmap)
 
int bitmap_last_set_bit (const_sbitmap)
 
void debug_bitmap (const_sbitmap)
 
sbitmap sbitmap_realloc (sbitmap, unsigned int)
 

Macro Definition Documentation

◆ EXECUTE_IF_SET_IN_BITMAP

#define EXECUTE_IF_SET_IN_BITMAP ( BITMAP,
MIN,
BITNUM,
ITER )
Value:
for (bmp_iter_set_init (&(ITER), (BITMAP), (MIN), &(BITNUM)); \
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
void bmp_iter_set_init(sbitmap_iterator *i, const_sbitmap bmp, unsigned int min, unsigned *bit_no)
Definition sbitmap.h:181
#define MIN(X, Y)
Definition system.h:392
Loop over all elements of SBITMAP, starting with MIN.  In each
iteration, N is set to the index of the bit being visited.  ITER is
an instance of sbitmap_iterator used to iterate the bitmap.   
See bitmap.h for the other definition of EXECUTE_IF_SET_IN_BITMAP.   

◆ SBITMAP_ELT_BITS

#define SBITMAP_ELT_BITS   (HOST_BITS_PER_WIDEST_FAST_INT * 1u)
Simple bitmaps.
   Copyright (C) 1999-2024 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 sets using simple bitmap vectors.

This set representation is suitable for non-sparse sets with a known
(a priori) universe.  The set is represented as a simple array of the
host's fastest unsigned integer.  For a given member I in the set:
  - the element for I will be at sbitmap[I / (bits per element)]
  - the position for I within element is I % (bits per element)

This representation is very space-efficient for large non-sparse sets
with random access patterns.

The following operations can be performed in O(1) time:

  * set_size                    : SBITMAP_SIZE
  * member_p                    : bitmap_bit_p
  * add_member          : bitmap_set_bit
  * remove_member               : bitmap_clear_bit

Most other operations on this set representation are O(U) where U is
the size of the set universe:

  * clear                       : bitmap_clear
  * choose_one          : bitmap_first_set_bit /
                          bitmap_last_set_bit
  * forall                      : EXECUTE_IF_SET_IN_BITMAP
  * set_copy                    : bitmap_copy
  * set_intersection            : bitmap_and
  * set_union           : bitmap_ior
  * set_difference              : bitmap_and_compl
  * set_disjuction              : (not implemented)
  * set_compare         : bitmap_equal_p
  * bit_in_range_p              : bitmap_bit_in_range_p

Some operations on 3 sets that occur frequently in data flow problems
are also implemented:

   * A | (B & C)                : bitmap_or_and
   * A | (B & ~C)               : bitmap_ior_and_compl
   * A & (B | C)                : bitmap_and_or

Most of the set functions have two variants: One that returns non-zero
if members were added or removed from the target set, and one that just
performs the operation without feedback.  The former operations are a
bit more expensive but the result can often be used to avoid iterations
on other sets.

Allocating a bitmap is done with sbitmap_alloc, and resizing is
performed with sbitmap_resize.

The storage requirements for simple bitmap sets is O(U) where U is the
size of the set universe (colloquially the number of bits in the bitmap).

This set representation works well for relatively small data flow problems
(there are special routines for that, see sbitmap_vector_*).  The set
operations can be vectorized and there is almost no computating overhead,
so that even sparse simple bitmap sets outperform dedicated sparse set
representations like linked-list bitmaps.  For larger problems, the size
overhead of simple bitmap sets gets too high and other set representations
have to be used.   

Referenced by bitmap_bit_in_range_p(), bitmap_bit_p(), bitmap_clear_bit(), bitmap_clear_range(), bitmap_last_set_bit(), bitmap_not(), bitmap_ones(), bitmap_set_bit(), bitmap_set_range(), bmp_iter_set(), bmp_iter_set_init(), dump_bitmap(), pre_edge_insert(), and sbitmap_resize().

◆ SBITMAP_ELT_TYPE

◆ SBITMAP_SET_SIZE

#define SBITMAP_SET_SIZE ( N)    (((N) + SBITMAP_ELT_BITS - 1) / SBITMAP_ELT_BITS)
Return the set size needed for N elements.   

Referenced by gcse_or_cprop_is_too_expensive(), sbitmap_alloc(), sbitmap_realloc(), sbitmap_resize(), and sbitmap_vector_alloc().

◆ SBITMAP_SIZE

Function Documentation

◆ bitmap_and()

bool bitmap_and ( sbitmap dst,
const_sbitmap a,
const_sbitmap b )
extern
Set DST to be (A and B).
Return nonzero if any change is made.   

References a, ap, b, bitmap_check_sizes(), changed, simple_bitmap_def::elms, ggc_alloc(), i, SBITMAP_ELT_TYPE, and simple_bitmap_def::size.

◆ bitmap_and_compl()

void bitmap_and_compl ( sbitmap dst,
const_sbitmap a,
const_sbitmap b )
extern
Set the bits in DST to be the difference between the bits
in A and the bits in B. i.e. dst = a & (~b).   

References a, ap, b, bitmap_check_sizes(), simple_bitmap_def::elms, gcc_assert, ggc_alloc(), i, and simple_bitmap_def::size.

◆ bitmap_and_or()

bool bitmap_and_or ( sbitmap dst,
const_sbitmap a,
const_sbitmap b,
const_sbitmap c )
extern
Set DST to be (A and (B or C)).
Return nonzero if any change is made.   

References a, ap, b, bitmap_check_sizes(), changed, simple_bitmap_def::elms, ggc_alloc(), i, SBITMAP_ELT_TYPE, and simple_bitmap_def::size.

Referenced by compute_earliest(), and compute_farthest().

◆ bitmap_bit_in_range_p()

bool bitmap_bit_in_range_p ( const_sbitmap bmap,
unsigned int start,
unsigned int end )
extern
Return TRUE if any bit between START and END inclusive is set within
the simple bitmap BMAP.  Return FALSE otherwise.   

References bitmap_check_index(), simple_bitmap_def::elms, end(), gcc_checking_assert, ggc_alloc(), SBITMAP_ELT_BITS, and SBITMAP_ELT_TYPE.

Referenced by live_bytes_read().

◆ bitmap_bit_p()

bool bitmap_bit_p ( const_sbitmap map,
int bitno )
inline
Test if bit number bitno in the bitmap is set.   

References bitmap_check_index(), ggc_alloc(), i, map, SBITMAP_ELT_BITS, and SBITMAP_ELT_TYPE.

◆ bitmap_check_index()

void bitmap_check_index ( const_sbitmap map,
int index )
inline
Verify that access at INDEX in bitmap MAP is valid.   

References gcc_checking_assert, and ggc_alloc().

Referenced by bitmap_bit_in_range_p(), bitmap_bit_p(), bitmap_clear_bit(), bitmap_clear_range(), bitmap_set_bit(), and bitmap_set_range().

◆ bitmap_check_sizes()

◆ bitmap_clear()

void bitmap_clear ( sbitmap bmap)
extern
Zero all elements in a bitmap.   

References simple_bitmap_def::elms, ggc_alloc(), and sbitmap_size_bytes().

Referenced by bitmap_vector_clear().

◆ bitmap_clear_bit()

bool bitmap_clear_bit ( sbitmap map,
int bitno )
inline
Reset bit number BITNO in the sbitmap MAP.
Return true if the bit changed.   

References bitmap_check_index(), ggc_alloc(), i, map, SBITMAP_ELT_BITS, and SBITMAP_ELT_TYPE.

◆ bitmap_clear_range()

void bitmap_clear_range ( sbitmap ,
unsigned ,
unsigned  )
extern

◆ bitmap_copy()

void bitmap_copy ( sbitmap dst,
const_sbitmap src )
extern

◆ bitmap_count_bits()

unsigned int bitmap_count_bits ( const_sbitmap bmap)
extern
Count and return the number of bits set in the bitmap BMAP.   

References count, simple_bitmap_def::elms, ggc_alloc(), i, sbitmap_popcount(), and simple_bitmap_def::size.

◆ bitmap_empty_p()

bool bitmap_empty_p ( const_sbitmap bmap)
extern
Return true if the bitmap is empty.   

References simple_bitmap_def::elms, i, and simple_bitmap_def::size.

◆ bitmap_equal_p()

bool bitmap_equal_p ( const_sbitmap a,
const_sbitmap b )
extern
Determine if a == b.   

References a, b, bitmap_check_sizes(), ggc_alloc(), and SBITMAP_ELT_TYPE.

◆ bitmap_first_set_bit()

int bitmap_first_set_bit ( const_sbitmap bmap)
extern
Return number of first bit set in the bitmap, -1 if none.   

References EXECUTE_IF_SET_IN_BITMAP, and ggc_alloc().

◆ bitmap_intersect_p()

bool bitmap_intersect_p ( const_sbitmap a,
const_sbitmap b )
extern
Return true if there are any bits set in A are also set in B.
Return false otherwise.   

References a, ap, b, bitmap_check_sizes(), ggc_alloc(), i, and MIN.

◆ bitmap_ior()

bool bitmap_ior ( sbitmap dst,
const_sbitmap a,
const_sbitmap b )
extern
Set DST to be (A or B)).
Return nonzero if any change is made.   

References a, ap, b, bitmap_check_sizes(), changed, simple_bitmap_def::elms, ggc_alloc(), i, SBITMAP_ELT_TYPE, and simple_bitmap_def::size.

◆ bitmap_ior_and_compl()

bool bitmap_ior_and_compl ( sbitmap dst,
const_sbitmap a,
const_sbitmap b,
const_sbitmap c )
extern
Set DST to be A union (B - C).
DST = A | (B & ~C).
Returns true if any change is made.   

References a, ap, b, bitmap_check_sizes(), changed, simple_bitmap_def::elms, ggc_alloc(), i, SBITMAP_ELT_TYPE, and simple_bitmap_def::size.

◆ bitmap_last_set_bit()

int bitmap_last_set_bit ( const_sbitmap bmap)
extern
Return number of last bit set in the bitmap, -1 if none.   

References simple_bitmap_def::elms, i, SBITMAP_ELT_BITS, SBITMAP_ELT_TYPE, and simple_bitmap_def::size.

◆ bitmap_not()

void bitmap_not ( sbitmap dst,
const_sbitmap src )
extern

◆ bitmap_ones()

◆ bitmap_or_and()

bool bitmap_or_and ( sbitmap dst,
const_sbitmap a,
const_sbitmap b,
const_sbitmap c )
extern
Set DST to be (A or (B and C)).
Return nonzero if any change is made.   

References a, ap, b, bitmap_check_sizes(), changed, simple_bitmap_def::elms, ggc_alloc(), i, SBITMAP_ELT_TYPE, and simple_bitmap_def::size.

Referenced by compute_antinout_edge(), and compute_code_hoist_vbeinout().

◆ bitmap_set_bit()

bool bitmap_set_bit ( sbitmap map,
int bitno )
inline
Set bit number BITNO in the sbitmap MAP.
Return true if the bit changed.   

References bitmap_check_index(), ggc_alloc(), i, map, SBITMAP_ELT_BITS, and SBITMAP_ELT_TYPE.

◆ bitmap_set_range()

void bitmap_set_range ( sbitmap ,
unsigned ,
unsigned  )
extern

◆ bitmap_subset_p()

bool bitmap_subset_p ( const_sbitmap a,
const_sbitmap b )
extern
Return nonzero if A is a subset of B.   

References a, ap, b, bitmap_check_sizes(), ggc_alloc(), and i.

Referenced by disqualify_problematic_components().

◆ bitmap_vector_clear()

◆ bitmap_vector_ones()

void bitmap_vector_ones ( sbitmap * bmap,
unsigned int n_vecs )
extern

◆ bitmap_xor()

bool bitmap_xor ( sbitmap dst,
const_sbitmap a,
const_sbitmap b )
extern
Set DST to be (A xor B)).
Return nonzero if any change is made.   

References a, ap, b, bitmap_check_sizes(), changed, simple_bitmap_def::elms, ggc_alloc(), i, SBITMAP_ELT_TYPE, and simple_bitmap_def::size.

◆ bmp_iter_next()

void bmp_iter_next ( sbitmap_iterator * i,
unsigned * bit_no )
inline
Advance to the next bit.   

References i.

◆ bmp_iter_set()

bool bmp_iter_set ( sbitmap_iterator * i,
unsigned int * n )
inline
Return true if we have more bits to visit, in which case *N is set
to the index of the bit to be visited.  Otherwise, return
false.   

References i, and SBITMAP_ELT_BITS.

◆ bmp_iter_set_init()

void bmp_iter_set_init ( sbitmap_iterator * i,
const_sbitmap bmp,
unsigned int min,
unsigned * bit_no )
inline
Initialize the iterator I with sbitmap BMP and the initial index
MIN.   

References ggc_alloc(), i, and SBITMAP_ELT_BITS.

◆ debug() [1/2]

void debug ( const simple_bitmap_def & ref)
extern

◆ debug() [2/2]

void debug ( const simple_bitmap_def * ptr)
extern

◆ debug_bitmap()

void debug_bitmap ( const_sbitmap bmap)
extern

References dump_bitmap_file(), and ggc_alloc().

◆ debug_raw() [1/2]

void debug_raw ( const simple_bitmap_def & ref)
extern

◆ debug_raw() [2/2]

void debug_raw ( const simple_bitmap_def * ptr)
extern

◆ dump_bitmap()

◆ dump_bitmap_file()

◆ dump_bitmap_vector()

void dump_bitmap_vector ( FILE * file,
const char * title,
const char * subtitle,
sbitmap * bmaps,
int n_maps )
extern

◆ sbitmap_alloc()

◆ sbitmap_free()

◆ sbitmap_realloc()

sbitmap sbitmap_realloc ( sbitmap src,
unsigned int n_elms )
extern
Re-allocate a simple bitmap of N_ELMS bits. New storage is uninitialized.   

References ggc_alloc(), simple_bitmap_def::n_bits, SBITMAP_ELT_TYPE, SBITMAP_SET_SIZE, sbitmap_size_bytes(), and simple_bitmap_def::size.

◆ sbitmap_resize()

sbitmap sbitmap_resize ( sbitmap bmap,
unsigned int n_elms,
int def )
extern
Resize a simple bitmap BMAP to N_ELMS bits.  If increasing the
size of BMAP, clear the new bits to zero if the DEF argument
is zero, and set them to one otherwise.   

References simple_bitmap_def::elms, ggc_alloc(), simple_bitmap_def::n_bits, SBITMAP_ELT_BITS, SBITMAP_ELT_TYPE, SBITMAP_SET_SIZE, sbitmap_size_bytes(), and simple_bitmap_def::size.

Referenced by add_new_name_mapping(), lra_push_insn_1(), and mark_bb_seen().

◆ sbitmap_vector_alloc()

◆ sbitmap_vector_free()