LLVM
15.0.0git
|
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor. More...
#include "llvm/Bitstream/BitstreamReader.h"
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 #. More... | |
Expected< BitstreamEntry > | advance (unsigned Flags=0) |
Advance the current bitstream, returning the next entry in the stream. More... | |
Expected< BitstreamEntry > | advanceSkippingSubblocks (unsigned Flags=0) |
This is a convenience function for clients that don't expect any subblocks. More... | |
Expected< unsigned > | ReadCode () |
Expected< unsigned > | ReadSubBlockID () |
Having read the ENTER_SUBBLOCK code, read the BlockID for the block. More... | |
Error | SkipBlock () |
Having read the ENTER_SUBBLOCK abbrevid and a BlockID, skip over the body of this block. More... | |
Error | EnterSubBlock (unsigned BlockID, unsigned *NumWordsP=nullptr) |
Having read the ENTER_SUBBLOCK abbrevid, and enter the block. More... | |
bool | ReadBlockEnd () |
Expected< const BitCodeAbbrev * > | getAbbrev (unsigned AbbrevID) |
Return the abbreviation for the specified AbbrevId. More... | |
Expected< unsigned > | skipRecord (unsigned AbbrevID) |
Read the current record and discard it, returning the code for the record. More... | |
Expected< unsigned > | readRecord (unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr) |
Error | ReadAbbrevRecord () |
Expected< Optional< BitstreamBlockInfo > > | ReadBlockInfoBlock (bool ReadBlockInfoNames=false) |
Read and return a block info block from the bitstream. More... | |
void | setBlockInfo (BitstreamBlockInfo *BI) |
Set the block info to be used by this BitstreamCursor to interpret abbreviated records. More... | |
bool | AtEndOfStream () |
bool | canSkipToPos (size_t pos) const |
Error | fillCurWord () |
ArrayRef< uint8_t > | getBitcodeBytes () const |
uint64_t | GetCurrentBitNo () const |
Return the bit # of the bit we are reading. More... | |
uint64_t | getCurrentByteNo () const |
const uint8_t * | getPointerToByte (uint64_t ByteNo, uint64_t NumBytes) |
Get a pointer into the bitstream at the specified byte offset. More... | |
Error | JumpToBit (uint64_t BitNo) |
Reset the stream to the specified bit number. More... | |
Expected< word_t > | Read (unsigned NumBits) |
Expected< uint32_t > | ReadVBR (const unsigned NumBits) |
Expected< uint64_t > | ReadVBR64 (const unsigned NumBits) |
size_t | SizeInBytes () const |
Return the size of the stream in bytes. More... | |
void | skipToEnd () |
Skip to the end of the file. More... | |
Static Public Attributes | |
static const size_t | MaxChunkSize = 32 |
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.
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.
|
default |
|
inlineexplicit |
Definition at line 382 of file BitstreamReader.h.
|
inlineexplicit |
Definition at line 384 of file BitstreamReader.h.
|
inlineexplicit |
Definition at line 386 of file BitstreamReader.h.
|
inline |
Advance the current bitstream, returning the next entry in the stream.
Definition at line 418 of file BitstreamReader.h.
References AF_DontAutoprocessAbbrevs, AF_DontPopBlockAtEnd, llvm::SimpleBitstreamCursor::AtEndOfStream(), llvm::bitc::DEFINE_ABBREV, llvm::bitc::END_BLOCK, llvm::bitc::ENTER_SUBBLOCK, llvm::Expected< T >::get(), llvm::BitstreamEntry::getEndBlock(), llvm::BitstreamEntry::getError(), llvm::BitstreamEntry::getSubBlock(), ReadBlockEnd(), ReadCode(), ReadSubBlockID(), and llvm::Expected< T >::takeError().
Referenced by advanceSkippingSubblocks(), and llvm::remarks::BitstreamParserHelper::parseBlockInfoBlock().
|
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().
|
inline |
Definition at line 112 of file BitstreamReader.h.
Referenced by llvm::BitcodeAnalyzer::analyze(), and llvm::remarks::BitstreamParserHelper::atEndOfStream().
|
inline |
Definition at line 107 of file BitstreamReader.h.
Error BitstreamCursor::EnterSubBlock | ( | unsigned | BlockID, |
unsigned * | NumWordsP = nullptr |
||
) |
Having read the ENTER_SUBBLOCK abbrevid, and enter the block.
Having read the ENTER_SUBBLOCK abbrevid, enter the block.
Definition at line 25 of file BitstreamReader.cpp.
References llvm::append_range(), llvm::SimpleBitstreamCursor::AtEndOfStream(), llvm::bitc::BlockSizeWidth, llvm::bitc::CodeLenWidth, llvm::createStringError(), llvm::Expected< T >::get(), llvm::BitstreamBlockInfo::getBlockInfo(), Info, MaxChunkSize, llvm::SimpleBitstreamCursor::Read(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::Error::success(), llvm::SmallVectorImpl< T >::swap(), and llvm::Expected< T >::takeError().
|
inline |
Definition at line 160 of file BitstreamReader.h.
|
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().
|
inline |
Return the number of bits used to encode an abbrev #.
Definition at line 404 of file BitstreamReader.h.
|
inline |
Definition at line 124 of file BitstreamReader.h.
Referenced by llvm::BitcodeAnalyzer::printStats().
|
inline |
Return the bit # of the bit we are reading.
Definition at line 117 of file BitstreamReader.h.
|
inline |
Definition at line 122 of file BitstreamReader.h.
|
inline |
Get a pointer into the bitstream at the specified byte offset.
Definition at line 148 of file BitstreamReader.h.
|
inline |
Reset the stream to the specified bit number.
Definition at line 127 of file BitstreamReader.h.
Definition at line 186 of file BitstreamReader.h.
Referenced by llvm::remarks::BitstreamParserHelper::parseMagic(), and readAbbreviatedField().
Error BitstreamCursor::ReadAbbrevRecord | ( | ) |
Definition at line 362 of file BitstreamReader.cpp.
References llvm::Data, E, error(), llvm::BitCodeAbbrevOp::Fixed, llvm::Expected< T >::get(), llvm::BitCodeAbbrevOp::hasEncodingData(), i, llvm::BitCodeAbbrevOp::isValidEncoding(), MaxChunkSize, move, llvm::SimpleBitstreamCursor::Read(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::ReadVBR64(), llvm::Error::success(), llvm::Expected< T >::takeError(), and llvm::BitCodeAbbrevOp::VBR.
|
inline |
Definition at line 518 of file BitstreamReader.h.
References llvm::SimpleBitstreamCursor::SkipToFourByteBoundary().
Referenced by advance().
Expected< Optional< BitstreamBlockInfo > > BitstreamCursor::ReadBlockInfoBlock | ( | bool | ReadBlockInfoNames = false | ) |
Read and return a block info block from the bitstream.
If an error was encountered, return None.
ReadBlockInfoNames | Whether to read block/record name information in the BlockInfo block. Only llvm-bcanalyzer uses this. |
Definition at line 421 of file BitstreamReader.cpp.
Referenced by llvm::BitcodeAnalyzer::analyze(), and llvm::remarks::BitstreamParserHelper::parseBlockInfoBlock().
|
inline |
Definition at line 474 of file BitstreamReader.h.
References llvm::SimpleBitstreamCursor::Read().
Referenced by advance(), and llvm::BitcodeAnalyzer::analyze().
Expected< unsigned > BitstreamCursor::readRecord | ( | unsigned | AbbrevID, |
SmallVectorImpl< uint64_t > & | Vals, | ||
StringRef * | Blob = nullptr |
||
) |
Definition at line 213 of file BitstreamReader.cpp.
References llvm::alignTo(), llvm::BitCodeAbbrevOp::Array, assert(), llvm::BitCodeAbbrevOp::Blob, llvm::SimpleBitstreamCursor::canSkipToPos(), llvm::BitCodeAbbrevOp::Char6, llvm::BitCodeAbbrevOp::DecodeChar6(), llvm::numbers::e, error(), llvm::BitCodeAbbrevOp::Fixed, llvm::Expected< T >::get(), getAbbrev(), llvm::SimpleBitstreamCursor::GetCurrentBitNo(), llvm::BitCodeAbbrevOp::getEncoding(), llvm::BitCodeAbbrevOp::getEncodingData(), llvm::BitCodeAbbrevOp::getLiteralValue(), llvm::BitCodeAbbrev::getNumOperandInfos(), llvm::BitCodeAbbrev::getOperandInfo(), i, llvm::BitCodeAbbrevOp::isEncoding(), llvm::BitCodeAbbrevOp::isLiteral(), llvm::SimpleBitstreamCursor::isSizePlausible(), llvm::SimpleBitstreamCursor::Read(), readAbbreviatedField(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::ReadVBR64(), llvm::SmallVectorImpl< T >::reserve(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::Expected< T >::takeError(), llvm::toString(), llvm::bitc::UNABBREV_RECORD, and llvm::BitCodeAbbrevOp::VBR.
|
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 llvm::SimpleBitstreamCursor::ReadVBR().
Referenced by advance(), and llvm::BitcodeAnalyzer::analyze().
Definition at line 229 of file BitstreamReader.h.
Definition at line 264 of file BitstreamReader.h.
Referenced by readAbbreviatedField().
|
inline |
Set the block info to be used by this BitstreamCursor to interpret abbreviated records.
Definition at line 573 of file BitstreamReader.h.
Referenced by llvm::BitcodeAnalyzer::analyze(), and llvm::remarks::BitstreamParserHelper::parseBlockInfoBlock().
|
inline |
Return the size of the stream in bytes.
Definition at line 310 of file BitstreamReader.h.
|
inline |
Having read the ENTER_SUBBLOCK abbrevid and a BlockID, skip over the body of this block.
Definition at line 484 of file BitstreamReader.h.
References llvm::SimpleBitstreamCursor::AtEndOfStream(), llvm::bitc::BlockSizeWidth, llvm::SimpleBitstreamCursor::canSkipToPos(), llvm::bitc::CodeLenWidth, llvm::createStringError(), llvm::Expected< T >::get(), llvm::SimpleBitstreamCursor::GetCurrentBitNo(), llvm::SimpleBitstreamCursor::JumpToBit(), llvm::SimpleBitstreamCursor::Read(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::Error::success(), and llvm::Expected< T >::takeError().
Expected< unsigned > BitstreamCursor::skipRecord | ( | unsigned | AbbrevID | ) |
Read the current record and discard it, returning the code for the record.
skipRecord - Read the current record and discard it.
Definition at line 95 of file BitstreamReader.cpp.
References llvm::BitCodeAbbrevOp::Array, assert(), llvm::BitCodeAbbrevOp::Blob, llvm::createStringError(), llvm::numbers::e, error(), llvm::BitCodeAbbrevOp::Fixed, llvm::Expected< T >::get(), getAbbrev(), llvm::BitCodeAbbrevOp::getEncoding(), llvm::BitCodeAbbrevOp::getEncodingData(), llvm::BitCodeAbbrevOp::getLiteralValue(), llvm::BitCodeAbbrev::getNumOperandInfos(), llvm::BitCodeAbbrev::getOperandInfo(), i, llvm::BitCodeAbbrevOp::isLiteral(), MaxChunkSize, readAbbreviatedField(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::ReadVBR64(), llvm::Expected< T >::takeError(), and llvm::bitc::UNABBREV_RECORD.
|
inline |
Skip to the end of the file.
Definition at line 313 of file BitstreamReader.h.
Referenced by llvm::remarks::BitstreamParserHelper::skipToEnd().
Definition at line 379 of file BitstreamReader.h.
Referenced by EnterSubBlock(), readAbbreviatedField(), ReadAbbrevRecord(), and skipRecord().