LLVM  3.7.0
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
llvm::BitstreamCursor Class Reference

This represents a position within a bitcode file. More...

#include <BitstreamReader.h>

Collaboration diagram for llvm::BitstreamCursor:
[legend]

Public Types

enum  { AF_DontPopBlockAtEnd = 1, AF_DontAutoprocessAbbrevs = 2 }
 Flags that modify the behavior of advance(). More...
 

Public Member Functions

 BitstreamCursor ()
 
 BitstreamCursor (BitstreamReader &R)
 
void init (BitstreamReader *R)
 
void freeState ()
 
bool canSkipToPos (size_t pos) const
 
bool AtEndOfStream ()
 
unsigned getAbbrevIDWidth () const
 Return the number of bits used to encode an abbrev #. More...
 
uint64_t GetCurrentBitNo () const
 Return the bit # of the bit we are reading. More...
 
BitstreamReadergetBitStreamReader ()
 
const BitstreamReadergetBitStreamReader () const
 
BitstreamEntry advance (unsigned Flags=0)
 Advance the current bitstream, returning the next entry in the stream. More...
 
BitstreamEntry advanceSkippingSubblocks (unsigned Flags=0)
 This is a convenience function for clients that don't expect any subblocks. More...
 
void JumpToBit (uint64_t BitNo)
 Reset the stream to the specified bit number. More...
 
void fillCurWord ()
 
word_t Read (unsigned NumBits)
 
uint32_t ReadVBR (unsigned NumBits)
 
uint64_t ReadVBR64 (unsigned NumBits)
 
unsigned ReadCode ()
 
unsigned ReadSubBlockID ()
 Having read the ENTER_SUBBLOCK code, read the BlockID for the block. More...
 
bool SkipBlock ()
 Having read the ENTER_SUBBLOCK abbrevid and a BlockID, skip over the body of this block. More...
 
bool EnterSubBlock (unsigned BlockID, unsigned *NumWordsP=nullptr)
 Having read the ENTER_SUBBLOCK abbrevid, enter the block, and return true if the block has an error. More...
 
bool ReadBlockEnd ()
 
const BitCodeAbbrevgetAbbrev (unsigned AbbrevID)
 Return the abbreviation for the specified AbbrevId. More...
 
void skipRecord (unsigned AbbrevID)
 Read the current record and discard it. More...
 
unsigned readRecord (unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr)
 
void ReadAbbrevRecord ()
 
bool ReadBlockInfoBlock ()
 

Static Public Attributes

static const size_t MaxChunkSize = sizeof(word_t) * 8
 

Detailed Description

This represents a position within a bitcode file.

There may be multiple independent cursors reading within one bitstream, each maintaining their own local state.

Unlike iterators, BitstreamCursors are heavy-weight objects that should not be passed by value.

Definition at line 164 of file BitstreamReader.h.

Member Enumeration Documentation

anonymous enum

Flags that modify the behavior of advance().

Enumerator
AF_DontPopBlockAtEnd 

If this flag is used, the advance() method does not automatically pop the block scope when the end of a block is reached.

AF_DontAutoprocessAbbrevs 

If this flag is used, abbrev entries are returned just like normal records.

Definition at line 250 of file BitstreamReader.h.

Constructor & Destructor Documentation

llvm::BitstreamCursor::BitstreamCursor ( )
inline

Definition at line 203 of file BitstreamReader.h.

References init().

llvm::BitstreamCursor::BitstreamCursor ( BitstreamReader R)
inlineexplicit

Definition at line 205 of file BitstreamReader.h.

References init().

Member Function Documentation

BitstreamEntry llvm::BitstreamCursor::advance ( unsigned  Flags = 0)
inline
BitstreamEntry llvm::BitstreamCursor::advanceSkippingSubblocks ( unsigned  Flags = 0)
inline

This is a convenience function for clients that don't expect any subblocks.

This just skips over them automatically.

Definition at line 288 of file BitstreamReader.h.

References advance(), llvm::BitstreamEntry::getError(), llvm::BitstreamEntry::Kind, SkipBlock(), and llvm::BitstreamEntry::SubBlock.

Referenced by ReadBlockInfoBlock().

bool llvm::BitstreamCursor::AtEndOfStream ( )
inline

Definition at line 225 of file BitstreamReader.h.

References fillCurWord().

Referenced by EnterSubBlock(), and SkipBlock().

bool llvm::BitstreamCursor::canSkipToPos ( size_t  pos) const
inline
bool BitstreamCursor::EnterSubBlock ( unsigned  BlockID,
unsigned NumWordsP = nullptr 
)

Having read the ENTER_SUBBLOCK abbrevid, enter the block, and return true if the block has an error.

EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter the block, and return true if the block has an error.

Definition at line 28 of file BitstreamReader.cpp.

References AtEndOfStream(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::Block, llvm::bitc::BlockSizeWidth, llvm::bitc::CodeLenWidth, llvm::BitstreamReader::getBlockInfo(), MaxChunkSize, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), Read(), and ReadVBR().

Referenced by ReadBlockInfoBlock().

void llvm::BitstreamCursor::fillCurWord ( )
inline
void BitstreamCursor::freeState ( )

Definition at line 18 of file BitstreamReader.cpp.

References llvm::SmallVectorImpl< T >::clear().

Referenced by init().

const BitCodeAbbrev* llvm::BitstreamCursor::getAbbrev ( unsigned  AbbrevID)
inline

Return the abbreviation for the specified AbbrevId.

Definition at line 494 of file BitstreamReader.h.

References llvm::bitc::FIRST_APPLICATION_ABBREV, and llvm::report_fatal_error().

Referenced by readRecord(), and skipRecord().

unsigned llvm::BitstreamCursor::getAbbrevIDWidth ( ) const
inline

Return the number of bits used to encode an abbrev #.

Definition at line 235 of file BitstreamReader.h.

BitstreamReader* llvm::BitstreamCursor::getBitStreamReader ( )
inline

Definition at line 242 of file BitstreamReader.h.

const BitstreamReader* llvm::BitstreamCursor::getBitStreamReader ( ) const
inline

Definition at line 245 of file BitstreamReader.h.

uint64_t llvm::BitstreamCursor::GetCurrentBitNo ( ) const
inline

Return the bit # of the bit we are reading.

Definition at line 238 of file BitstreamReader.h.

Referenced by readRecord(), SkipBlock(), and skipRecord().

void llvm::BitstreamCursor::init ( BitstreamReader R)
inline

Definition at line 207 of file BitstreamReader.h.

References freeState().

Referenced by BitstreamCursor().

void llvm::BitstreamCursor::JumpToBit ( uint64_t  BitNo)
inline

Reset the stream to the specified bit number.

Definition at line 302 of file BitstreamReader.h.

References canSkipToPos(), and Read().

Referenced by readRecord(), SkipBlock(), and skipRecord().

word_t llvm::BitstreamCursor::Read ( unsigned  NumBits)
inline
void BitstreamCursor::ReadAbbrevRecord ( )
bool llvm::BitstreamCursor::ReadBlockEnd ( )
inline

Definition at line 468 of file BitstreamReader.h.

References llvm::SmallVectorBase::empty().

Referenced by advance().

bool BitstreamCursor::ReadBlockInfoBlock ( )
unsigned llvm::BitstreamCursor::ReadCode ( )
inline

Definition at line 432 of file BitstreamReader.h.

References Read().

Referenced by advance().

unsigned BitstreamCursor::readRecord ( unsigned  AbbrevID,
SmallVectorImpl< uint64_t > &  Vals,
StringRef Blob = nullptr 
)
unsigned llvm::BitstreamCursor::ReadSubBlockID ( )
inline

Having read the ENTER_SUBBLOCK code, read the BlockID for the block.

Definition at line 441 of file BitstreamReader.h.

References llvm::bitc::BlockIDWidth, and ReadVBR().

Referenced by advance().

uint32_t llvm::BitstreamCursor::ReadVBR ( unsigned  NumBits)
inline

Definition at line 379 of file BitstreamReader.h.

References Read().

Referenced by EnterSubBlock(), ReadAbbrevRecord(), readRecord(), ReadSubBlockID(), SkipBlock(), and skipRecord().

uint64_t llvm::BitstreamCursor::ReadVBR64 ( unsigned  NumBits)
inline
bool llvm::BitstreamCursor::SkipBlock ( )
inline

Having read the ENTER_SUBBLOCK abbrevid and a BlockID, skip over the body of this block.

If the block record is malformed, return true.

Definition at line 447 of file BitstreamReader.h.

References AtEndOfStream(), llvm::bitc::BlockSizeWidth, canSkipToPos(), llvm::bitc::CodeLenWidth, GetCurrentBitNo(), JumpToBit(), Read(), and ReadVBR().

Referenced by advanceSkippingSubblocks(), and ReadBlockInfoBlock().

void BitstreamCursor::skipRecord ( unsigned  AbbrevID)

Member Data Documentation

const size_t llvm::BitstreamCursor::MaxChunkSize = sizeof(word_t) * 8
static

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