Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
llvm::BitstreamCursor Class Reference

This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor. More...

#include "llvm/Bitstream/BitstreamReader.h"

Inheritance 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 ()=default
 BitstreamCursor (ArrayRef< uint8_t > BitcodeBytes)
 BitstreamCursor (StringRef BitcodeBytes)
 BitstreamCursor (MemoryBufferRef BitcodeBytes)
unsigned getAbbrevIDWidth () const
 Return the number of bits used to encode an abbrev #.
Expected< BitstreamEntryadvance (unsigned Flags=0)
 Advance the current bitstream, returning the next entry in the stream.
Expected< BitstreamEntryadvanceSkippingSubblocks (unsigned Flags=0)
 This is a convenience function for clients that don't expect any subblocks.
Expected< unsignedReadCode ()
Expected< unsignedReadSubBlockID ()
 Having read the ENTER_SUBBLOCK code, read the BlockID for the block.
Error SkipBlock ()
 Having read the ENTER_SUBBLOCK abbrevid and a BlockID, skip over the body of this block.
LLVM_ABI Error EnterSubBlock (unsigned BlockID, unsigned *NumWordsP=nullptr)
 Having read the ENTER_SUBBLOCK abbrevid, and enter the block.
bool ReadBlockEnd ()
Expected< const BitCodeAbbrev * > getAbbrev (unsigned AbbrevID)
 Return the abbreviation for the specified AbbrevId.
LLVM_ABI Expected< unsignedskipRecord (unsigned AbbrevID)
 Read the current record and discard it, returning the code for the record.
LLVM_ABI Expected< unsignedreadRecord (unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr)
LLVM_ABI Error ReadAbbrevRecord ()
LLVM_ABI Expected< std::optional< BitstreamBlockInfo > > ReadBlockInfoBlock (bool ReadBlockInfoNames=false)
 Read and return a block info block from the bitstream.
void setBlockInfo (BitstreamBlockInfo *BI)
 Set the block info to be used by this BitstreamCursor to interpret abbreviated records.
bool AtEndOfStream ()
bool canSkipToPos (size_t pos) const
Error fillCurWord ()
ArrayRef< uint8_tgetBitcodeBytes () const
uint64_t GetCurrentBitNo () const
 Return the bit # of the bit we are reading.
uint64_t getCurrentByteNo () const
const uint8_tgetPointerToByte (uint64_t ByteNo, uint64_t NumBytes)
 Get a pointer into the bitstream at the specified byte offset.
Error JumpToBit (uint64_t BitNo)
 Reset the stream to the specified bit number.
Expected< word_tRead (unsigned NumBits)
Expected< uint32_tReadVBR (const unsigned NumBits)
Expected< uint64_tReadVBR64 (const unsigned NumBits)
size_t SizeInBytes () const
 Return the size of the stream in bytes.
void skipToEnd ()
 Skip to the end of the file.

Static Public Attributes

static const size_t MaxChunkSize = 32

Detailed Description

This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.

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

Definition at line 358 of file BitstreamReader.h.

Member Enumeration Documentation

◆ anonymous enum

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 407 of file BitstreamReader.h.

Constructor & Destructor Documentation

◆ BitstreamCursor() [1/4]

llvm::BitstreamCursor::BitstreamCursor ( )
default

◆ BitstreamCursor() [2/4]

llvm::BitstreamCursor::BitstreamCursor ( ArrayRef< uint8_t > BitcodeBytes)
inlineexplicit

◆ BitstreamCursor() [3/4]

llvm::BitstreamCursor::BitstreamCursor ( StringRef BitcodeBytes)
inlineexplicit

◆ BitstreamCursor() [4/4]

llvm::BitstreamCursor::BitstreamCursor ( MemoryBufferRef BitcodeBytes)
inlineexplicit

Member Function Documentation

◆ advance()

◆ advanceSkippingSubblocks()

Expected< 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 457 of file BitstreamReader.h.

References advance(), llvm::Expected< T >::get(), SkipBlock(), and llvm::BitstreamEntry::SubBlock.

Referenced by getEnableSplitLTOUnitAndUnifiedFlag(), hasObjCCategoryInModule(), ReadBlockInfoBlock(), and readModuleTriple().

◆ AtEndOfStream()

bool llvm::SimpleBitstreamCursor::AtEndOfStream ( )
inline

◆ canSkipToPos()

bool llvm::SimpleBitstreamCursor::canSkipToPos ( size_t pos) const
inline

Definition at line 108 of file BitstreamReader.h.

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

◆ EnterSubBlock()

◆ fillCurWord()

Error llvm::SimpleBitstreamCursor::fillCurWord ( )
inline

Definition at line 161 of file BitstreamReader.h.

◆ getAbbrev()

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

Return the abbreviation for the specified AbbrevId.

Definition at line 543 of file BitstreamReader.h.

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

Referenced by readRecord(), and skipRecord().

◆ getAbbrevIDWidth()

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

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

Definition at line 404 of file BitstreamReader.h.

◆ getBitcodeBytes()

ArrayRef< uint8_t > llvm::SimpleBitstreamCursor::getBitcodeBytes ( ) const
inline

Definition at line 125 of file BitstreamReader.h.

Referenced by analyzeHeader(), and llvm::getBitcodeFileContents().

◆ GetCurrentBitNo()

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

Return the bit # of the bit we are reading.

Definition at line 118 of file BitstreamReader.h.

Referenced by llvm::getBitcodeFileContents(), jumpToValueSymbolTable(), readRecord(), SkipBlock(), and skipRecord().

◆ getCurrentByteNo()

uint64_t llvm::SimpleBitstreamCursor::getCurrentByteNo ( ) const
inline

Definition at line 123 of file BitstreamReader.h.

Referenced by llvm::getBitcodeFileContents().

◆ getPointerToByte()

const uint8_t * llvm::SimpleBitstreamCursor::getPointerToByte ( uint64_t ByteNo,
uint64_t NumBytes )
inline

Get a pointer into the bitstream at the specified byte offset.

Definition at line 149 of file BitstreamReader.h.

◆ JumpToBit()

Error llvm::SimpleBitstreamCursor::JumpToBit ( uint64_t BitNo)
inline

◆ Read()

Expected< word_t > llvm::SimpleBitstreamCursor::Read ( unsigned NumBits)
inline

Definition at line 186 of file BitstreamReader.h.

Referenced by hasInvalidBitcodeHeader(), and ReadSignature().

◆ ReadAbbrevRecord()

◆ ReadBlockEnd()

bool llvm::BitstreamCursor::ReadBlockEnd ( )
inline

Definition at line 518 of file BitstreamReader.h.

References llvm::SimpleBitstreamCursor::SkipToFourByteBoundary().

Referenced by advance().

◆ ReadBlockInfoBlock()

◆ ReadCode()

Expected< unsigned > llvm::BitstreamCursor::ReadCode ( )
inline

Definition at line 474 of file BitstreamReader.h.

References llvm::Read.

Referenced by advance(), and llvm::BitcodeAnalyzer::analyze().

◆ readRecord()

◆ ReadSubBlockID()

Expected< unsigned > llvm::BitstreamCursor::ReadSubBlockID ( )
inline

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

Definition at line 480 of file BitstreamReader.h.

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

Referenced by advance(), and llvm::BitcodeAnalyzer::analyze().

◆ ReadVBR()

Expected< uint32_t > llvm::SimpleBitstreamCursor::ReadVBR ( const unsigned NumBits)
inline

◆ ReadVBR64()

Expected< uint64_t > llvm::SimpleBitstreamCursor::ReadVBR64 ( const unsigned NumBits)
inline

Definition at line 264 of file BitstreamReader.h.

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

◆ setBlockInfo()

void llvm::BitstreamCursor::setBlockInfo ( BitstreamBlockInfo * BI)
inline

Set the block info to be used by this BitstreamCursor to interpret abbreviated records.

Definition at line 573 of file BitstreamReader.h.

◆ SizeInBytes()

size_t llvm::SimpleBitstreamCursor::SizeInBytes ( ) const
inline

Return the size of the stream in bytes.

Definition at line 310 of file BitstreamReader.h.

◆ SkipBlock()

◆ skipRecord()

◆ skipToEnd()

void llvm::SimpleBitstreamCursor::skipToEnd ( )
inline

Skip to the end of the file.

Definition at line 313 of file BitstreamReader.h.

Referenced by skipRecord().

Member Data Documentation

◆ MaxChunkSize

const size_t llvm::BitstreamCursor::MaxChunkSize = 32
static

Definition at line 379 of file BitstreamReader.h.

Referenced by EnterSubBlock(), ReadAbbrevRecord(), and skipRecord().


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