LLVM  9.0.0svn
Classes | Public Types | Public Member Functions | List of all members
llvm::SmallBitVector Class Reference

This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is small. More...

#include "llvm/ADT/SmallBitVector.h"

Classes

class  reference
 

Public Types

using size_type = unsigned
 
using const_set_bits_iterator = const_set_bits_iterator_impl< SmallBitVector >
 
using set_iterator = const_set_bits_iterator
 

Public Member Functions

 SmallBitVector ()=default
 Creates an empty bitvector. More...
 
 SmallBitVector (unsigned s, bool t=false)
 Creates a bitvector of specified number of bits. More...
 
 SmallBitVector (const SmallBitVector &RHS)
 SmallBitVector copy ctor. More...
 
 SmallBitVector (SmallBitVector &&RHS)
 
 ~SmallBitVector ()
 
const_set_bits_iterator set_bits_begin () const
 
const_set_bits_iterator set_bits_end () const
 
iterator_range< const_set_bits_iteratorset_bits () const
 
bool isSmall () const
 
bool empty () const
 Tests whether there are no bits in this bitvector. More...
 
size_t size () const
 Returns the number of bits in this bitvector. More...
 
size_type count () const
 Returns the number of bits which are set. More...
 
bool any () const
 Returns true if any bit is set. More...
 
bool all () const
 Returns true if all bits are set. More...
 
bool none () const
 Returns true if none of the bits are set. More...
 
int find_first () const
 Returns the index of the first set bit, -1 if none of the bits are set. More...
 
int find_last () const
 
int find_first_unset () const
 Returns the index of the first unset bit, -1 if all of the bits are set. More...
 
int find_last_unset () const
 
int find_next (unsigned Prev) const
 Returns the index of the next set bit following the "Prev" bit. More...
 
int find_next_unset (unsigned Prev) const
 Returns the index of the next unset bit following the "Prev" bit. More...
 
int find_prev (unsigned PriorTo) const
 find_prev - Returns the index of the first set bit that precedes the the bit at PriorTo. More...
 
void clear ()
 Clear all bits. More...
 
void resize (unsigned N, bool t=false)
 Grow or shrink the bitvector. More...
 
void reserve (unsigned N)
 
SmallBitVectorset ()
 
SmallBitVectorset (unsigned Idx)
 
SmallBitVectorset (unsigned I, unsigned E)
 Efficiently set a range of bits in [I, E) More...
 
SmallBitVectorreset ()
 
SmallBitVectorreset (unsigned Idx)
 
SmallBitVectorreset (unsigned I, unsigned E)
 Efficiently reset a range of bits in [I, E) More...
 
SmallBitVectorflip ()
 
SmallBitVectorflip (unsigned Idx)
 
SmallBitVector operator~ () const
 
reference operator[] (unsigned Idx)
 
bool operator[] (unsigned Idx) const
 
bool test (unsigned Idx) const
 
void push_back (bool Val)
 
bool anyCommon (const SmallBitVector &RHS) const
 Test if any common bits are set. More...
 
bool operator== (const SmallBitVector &RHS) const
 
bool operator!= (const SmallBitVector &RHS) const
 
SmallBitVectoroperator &= (const SmallBitVector &RHS)
 
SmallBitVectorreset (const SmallBitVector &RHS)
 Reset bits that are set in RHS. Same as *this &= ~RHS. More...
 
bool test (const SmallBitVector &RHS) const
 Check if (This - RHS) is zero. This is the same as reset(RHS) and any(). More...
 
SmallBitVectoroperator|= (const SmallBitVector &RHS)
 
SmallBitVectoroperator^= (const SmallBitVector &RHS)
 
SmallBitVectoroperator<<= (unsigned N)
 
SmallBitVectoroperator>>= (unsigned N)
 
const SmallBitVectoroperator= (const SmallBitVector &RHS)
 
const SmallBitVectoroperator= (SmallBitVector &&RHS)
 
void swap (SmallBitVector &RHS)
 
void setBitsInMask (const uint32_t *Mask, unsigned MaskWords=~0u)
 Add '1' bits from Mask to this vector. More...
 
void clearBitsInMask (const uint32_t *Mask, unsigned MaskWords=~0u)
 Clear any bits in this vector that are set in Mask. More...
 
void setBitsNotInMask (const uint32_t *Mask, unsigned MaskWords=~0u)
 Add a bit to this vector for every '0' bit in Mask. More...
 
void clearBitsNotInMask (const uint32_t *Mask, unsigned MaskWords=~0u)
 Clear a bit in this vector for every '0' bit in Mask. More...
 

Detailed Description

This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is small.

It contains one pointer-sized field, which is directly used as a plain collection of bits when possible, or as a pointer to a larger heap-allocated array when necessary. This allows normal "small" cases to be fast without losing generality for large inputs.

Definition at line 34 of file SmallBitVector.h.

Member Typedef Documentation

◆ const_set_bits_iterator

Definition at line 169 of file SmallBitVector.h.

◆ set_iterator

Definition at line 170 of file SmallBitVector.h.

◆ size_type

Definition at line 63 of file SmallBitVector.h.

Constructor & Destructor Documentation

◆ SmallBitVector() [1/4]

llvm::SmallBitVector::SmallBitVector ( )
default

Creates an empty bitvector.

Referenced by llvm::SmallBitVector::reference::operator bool(), and operator~().

◆ SmallBitVector() [2/4]

llvm::SmallBitVector::SmallBitVector ( unsigned  s,
bool  t = false 
)
inlineexplicit

Creates a bitvector of specified number of bits.

All bits are initialized to the specified value.

Definition at line 145 of file SmallBitVector.h.

◆ SmallBitVector() [3/4]

llvm::SmallBitVector::SmallBitVector ( const SmallBitVector RHS)
inline

SmallBitVector copy ctor.

Definition at line 153 of file SmallBitVector.h.

References isSmall().

◆ SmallBitVector() [4/4]

llvm::SmallBitVector::SmallBitVector ( SmallBitVector &&  RHS)
inline

Definition at line 160 of file SmallBitVector.h.

◆ ~SmallBitVector()

llvm::SmallBitVector::~SmallBitVector ( )
inline

Definition at line 164 of file SmallBitVector.h.

References isSmall().

Member Function Documentation

◆ all()

bool llvm::SmallBitVector::all ( ) const
inline

Returns true if all bits are set.

Definition at line 213 of file SmallBitVector.h.

References isSmall().

◆ any()

bool llvm::SmallBitVector::any ( ) const
inline

Returns true if any bit is set.

Definition at line 206 of file SmallBitVector.h.

References isSmall().

◆ anyCommon()

bool llvm::SmallBitVector::anyCommon ( const SmallBitVector RHS) const
inline

Test if any common bits are set.

Definition at line 473 of file SmallBitVector.h.

References isSmall(), size(), and test().

◆ clear()

void llvm::SmallBitVector::clear ( )
inline

◆ clearBitsInMask()

void llvm::SmallBitVector::clearBitsInMask ( const uint32_t Mask,
unsigned  MaskWords = ~0u 
)
inline

Clear any bits in this vector that are set in Mask.

Don't resize. This computes "*this &= ~Mask".

Definition at line 640 of file SmallBitVector.h.

References isSmall(), and llvm::BitmaskEnumDetail::Mask().

◆ clearBitsNotInMask()

void llvm::SmallBitVector::clearBitsNotInMask ( const uint32_t Mask,
unsigned  MaskWords = ~0u 
)
inline

Clear a bit in this vector for every '0' bit in Mask.

Don't resize. This computes "*this &= Mask".

Definition at line 658 of file SmallBitVector.h.

References assert(), isSmall(), and llvm::BitmaskEnumDetail::Mask().

◆ count()

size_type llvm::SmallBitVector::count ( ) const
inline

Returns the number of bits which are set.

Definition at line 197 of file SmallBitVector.h.

References llvm::tgtok::Bits, llvm::countPopulation(), and isSmall().

Referenced by find_first_unset(), find_last_unset(), lowerShuffleAsSplitOrBlend(), and mayUsePostIncMode().

◆ empty()

bool llvm::SmallBitVector::empty ( ) const
inline

Tests whether there are no bits in this bitvector.

Definition at line 187 of file SmallBitVector.h.

References isSmall().

◆ find_first()

int llvm::SmallBitVector::find_first ( ) const
inline

Returns the index of the first set bit, -1 if none of the bits are set.

Definition at line 227 of file SmallBitVector.h.

References llvm::tgtok::Bits, llvm::countTrailingZeros(), and isSmall().

◆ find_first_unset()

int llvm::SmallBitVector::find_first_unset ( ) const
inline

Returns the index of the first unset bit, -1 if all of the bits are set.

Definition at line 248 of file SmallBitVector.h.

References llvm::tgtok::Bits, count(), llvm::countTrailingOnes(), and isSmall().

◆ find_last()

int llvm::SmallBitVector::find_last ( ) const
inline

Definition at line 237 of file SmallBitVector.h.

References llvm::tgtok::Bits, llvm::countLeadingZeros(), and isSmall().

◆ find_last_unset()

int llvm::SmallBitVector::find_last_unset ( ) const
inline

Definition at line 259 of file SmallBitVector.h.

References llvm::tgtok::Bits, count(), llvm::countLeadingOnes(), and isSmall().

◆ find_next()

int llvm::SmallBitVector::find_next ( unsigned  Prev) const
inline

Returns the index of the next set bit following the "Prev" bit.

Returns -1 if the next set bit is not found.

Definition at line 274 of file SmallBitVector.h.

References llvm::tgtok::Bits, llvm::countTrailingZeros(), and isSmall().

Referenced by dumpSmallBitVector().

◆ find_next_unset()

int llvm::SmallBitVector::find_next_unset ( unsigned  Prev) const
inline

Returns the index of the next unset bit following the "Prev" bit.

Returns -1 if the next unset bit is not found.

Definition at line 288 of file SmallBitVector.h.

References llvm::tgtok::Bits, llvm::countTrailingOnes(), isSmall(), and llvm::BitmaskEnumDetail::Mask().

◆ find_prev()

int llvm::SmallBitVector::find_prev ( unsigned  PriorTo) const
inline

find_prev - Returns the index of the first set bit that precedes the the bit at PriorTo.

Returns -1 if all previous bits are unset.

Definition at line 305 of file SmallBitVector.h.

References llvm::tgtok::Bits, llvm::countLeadingZeros(), and isSmall().

◆ flip() [1/2]

SmallBitVector& llvm::SmallBitVector::flip ( )
inline

Definition at line 429 of file SmallBitVector.h.

References isSmall().

◆ flip() [2/2]

SmallBitVector& llvm::SmallBitVector::flip ( unsigned  Idx)
inline

Definition at line 437 of file SmallBitVector.h.

References isSmall().

◆ isSmall()

bool llvm::SmallBitVector::isSmall ( ) const
inline

◆ none()

bool llvm::SmallBitVector::none ( ) const
inline

Returns true if none of the bits are set.

Definition at line 220 of file SmallBitVector.h.

References isSmall().

◆ operator &=()

SmallBitVector& llvm::SmallBitVector::operator&= ( const SmallBitVector RHS)
inline

Definition at line 508 of file SmallBitVector.h.

References isSmall(), llvm::max(), reset(), resize(), size(), and test().

◆ operator!=()

bool llvm::SmallBitVector::operator!= ( const SmallBitVector RHS) const
inline

Definition at line 502 of file SmallBitVector.h.

◆ operator<<=()

SmallBitVector& llvm::SmallBitVector::operator<<= ( unsigned  N)
inline

Definition at line 583 of file SmallBitVector.h.

References isSmall(), and N.

◆ operator=() [1/2]

const SmallBitVector& llvm::SmallBitVector::operator= ( const SmallBitVector RHS)
inline

Definition at line 600 of file SmallBitVector.h.

References isSmall().

◆ operator=() [2/2]

const SmallBitVector& llvm::SmallBitVector::operator= ( SmallBitVector &&  RHS)
inline

Definition at line 617 of file SmallBitVector.h.

References clear(), and swap().

◆ operator==()

bool llvm::SmallBitVector::operator== ( const SmallBitVector RHS) const
inline

Definition at line 486 of file SmallBitVector.h.

References isSmall(), and size().

◆ operator>>=()

SmallBitVector& llvm::SmallBitVector::operator>>= ( unsigned  N)
inline

Definition at line 591 of file SmallBitVector.h.

References isSmall(), and N.

◆ operator[]() [1/2]

reference llvm::SmallBitVector::operator[] ( unsigned  Idx)
inline

Definition at line 451 of file SmallBitVector.h.

References assert(), llvm::SmallBitVector::reference::reference(), and size().

◆ operator[]() [2/2]

bool llvm::SmallBitVector::operator[] ( unsigned  Idx) const
inline

Definition at line 456 of file SmallBitVector.h.

References assert(), isSmall(), and size().

◆ operator^=()

SmallBitVector& llvm::SmallBitVector::operator^= ( const SmallBitVector RHS)
inline

Definition at line 570 of file SmallBitVector.h.

References isSmall(), llvm::max(), resize(), size(), and test().

◆ operator|=()

SmallBitVector& llvm::SmallBitVector::operator|= ( const SmallBitVector RHS)
inline

Definition at line 557 of file SmallBitVector.h.

References isSmall(), llvm::max(), resize(), size(), and test().

◆ operator~()

SmallBitVector llvm::SmallBitVector::operator~ ( ) const
inline

Definition at line 446 of file SmallBitVector.h.

References SmallBitVector().

◆ push_back()

void llvm::SmallBitVector::push_back ( bool  Val)
inline

Definition at line 468 of file SmallBitVector.h.

References resize(), and size().

◆ reserve()

void llvm::SmallBitVector::reserve ( unsigned  N)
inline

Definition at line 345 of file SmallBitVector.h.

References isSmall(), llvm::BitVector::reserve(), and llvm::BitVector::set().

◆ reset() [1/4]

SmallBitVector& llvm::SmallBitVector::reset ( )
inline

◆ reset() [2/4]

SmallBitVector& llvm::SmallBitVector::reset ( unsigned  Idx)
inline

Definition at line 406 of file SmallBitVector.h.

References isSmall().

◆ reset() [3/4]

SmallBitVector& llvm::SmallBitVector::reset ( unsigned  I,
unsigned  E 
)
inline

Efficiently reset a range of bits in [I, E)

Definition at line 415 of file SmallBitVector.h.

References assert(), E, I, isSmall(), llvm::BitmaskEnumDetail::Mask(), and size().

◆ reset() [4/4]

SmallBitVector& llvm::SmallBitVector::reset ( const SmallBitVector RHS)
inline

Reset bits that are set in RHS. Same as *this &= ~RHS.

Definition at line 525 of file SmallBitVector.h.

References isSmall(), reset(), size(), and test().

◆ resize()

void llvm::SmallBitVector::resize ( unsigned  N,
bool  t = false 
)
inline

◆ set() [1/3]

SmallBitVector& llvm::SmallBitVector::set ( )
inline

◆ set() [2/3]

SmallBitVector& llvm::SmallBitVector::set ( unsigned  Idx)
inline

Definition at line 371 of file SmallBitVector.h.

References assert(), and isSmall().

◆ set() [3/3]

SmallBitVector& llvm::SmallBitVector::set ( unsigned  I,
unsigned  E 
)
inline

Efficiently set a range of bits in [I, E)

Definition at line 384 of file SmallBitVector.h.

References assert(), E, I, isSmall(), llvm::BitmaskEnumDetail::Mask(), and size().

◆ set_bits()

iterator_range<const_set_bits_iterator> llvm::SmallBitVector::set_bits ( ) const
inline

◆ set_bits_begin()

const_set_bits_iterator llvm::SmallBitVector::set_bits_begin ( ) const
inline

Definition at line 172 of file SmallBitVector.h.

Referenced by set_bits().

◆ set_bits_end()

const_set_bits_iterator llvm::SmallBitVector::set_bits_end ( ) const
inline

Definition at line 176 of file SmallBitVector.h.

Referenced by set_bits().

◆ setBitsInMask()

void llvm::SmallBitVector::setBitsInMask ( const uint32_t Mask,
unsigned  MaskWords = ~0u 
)
inline

Add '1' bits from Mask to this vector.

Don't resize. This computes "*this |= Mask".

Definition at line 631 of file SmallBitVector.h.

References isSmall(), and llvm::BitmaskEnumDetail::Mask().

◆ setBitsNotInMask()

void llvm::SmallBitVector::setBitsNotInMask ( const uint32_t Mask,
unsigned  MaskWords = ~0u 
)
inline

Add a bit to this vector for every '0' bit in Mask.

Don't resize. This computes "*this |= ~Mask".

Definition at line 649 of file SmallBitVector.h.

References isSmall(), and llvm::BitmaskEnumDetail::Mask().

◆ size()

size_t llvm::SmallBitVector::size ( ) const
inline

◆ swap()

void llvm::SmallBitVector::swap ( SmallBitVector RHS)
inline

Definition at line 625 of file SmallBitVector.h.

References std::swap().

Referenced by operator=(), and std::swap().

◆ test() [1/2]

bool llvm::SmallBitVector::test ( unsigned  Idx) const
inline

◆ test() [2/2]

bool llvm::SmallBitVector::test ( const SmallBitVector RHS) const
inline

Check if (This - RHS) is zero. This is the same as reset(RHS) and any().

Definition at line 539 of file SmallBitVector.h.

References isSmall(), size(), and test().


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