LLVM API Documentation
#include <BitstreamReader.h>
Classes | |
struct | Block |
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 | isEndPos (size_t pos) |
bool | canSkipToPos (size_t pos) const |
uint32_t | getWord (size_t pos) |
bool | AtEndOfStream () |
unsigned | getAbbrevIDWidth () const |
getAbbrevIDWidth - Return the number of bits used to encode an abbrev #. | |
uint64_t | GetCurrentBitNo () const |
GetCurrentBitNo - Return the bit # of the bit we are reading. | |
BitstreamReader * | getBitStreamReader () |
const BitstreamReader * | getBitStreamReader () const |
BitstreamEntry | advance (unsigned Flags=0) |
BitstreamEntry | advanceSkippingSubblocks (unsigned Flags=0) |
void | JumpToBit (uint64_t BitNo) |
JumpToBit - Reset the stream to the specified bit number. | |
uint32_t | Read (unsigned NumBits) |
uint64_t | Read64 (unsigned NumBits) |
uint32_t | ReadVBR (unsigned NumBits) |
uint64_t | ReadVBR64 (unsigned NumBits) |
unsigned | ReadCode () |
unsigned | ReadSubBlockID () |
bool | SkipBlock () |
bool | EnterSubBlock (unsigned BlockID, unsigned *NumWordsP=nullptr) |
bool | ReadBlockEnd () |
const BitCodeAbbrev * | getAbbrev (unsigned AbbrevID) |
getAbbrev - Return the abbreviation for the specified AbbrevId. | |
void | skipRecord (unsigned AbbrevID) |
skipRecord - Read the current record and discard it. | |
unsigned | readRecord (unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr) |
void | ReadAbbrevRecord () |
bool | ReadBlockInfoBlock () |
Friends | |
class | Deserializer |
BitstreamCursor - 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 176 of file BitstreamReader.h.
anonymous enum |
Flags that modify the behavior of advance().
AF_DontPopBlockAtEnd |
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 |
AF_DontAutoprocessAbbrevs - If this flag is used, abbrev entries are returned just like normal records. |
Definition at line 269 of file BitstreamReader.h.
llvm::BitstreamCursor::BitstreamCursor | ( | ) | [inline] |
Definition at line 212 of file BitstreamReader.h.
llvm::BitstreamCursor::BitstreamCursor | ( | BitstreamReader & | R | ) | [inline, explicit] |
Definition at line 214 of file BitstreamReader.h.
BitstreamEntry llvm::BitstreamCursor::advance | ( | unsigned | Flags = 0 | ) | [inline] |
advance - Advance the current bitstream, returning the next entry in the stream.
Definition at line 282 of file BitstreamReader.h.
References AF_DontAutoprocessAbbrevs, AF_DontPopBlockAtEnd, llvm::tgtok::Code, llvm::bitc::DEFINE_ABBREV, llvm::bitc::END_BLOCK, llvm::bitc::ENTER_SUBBLOCK, llvm::BitstreamEntry::getEndBlock(), llvm::BitstreamEntry::getError(), llvm::BitstreamEntry::getRecord(), llvm::BitstreamEntry::getSubBlock(), ReadAbbrevRecord(), ReadBlockEnd(), ReadCode(), and ReadSubBlockID().
Referenced by advanceSkippingSubblocks(), llvm::BitcodeReader::ParseBitcodeInto(), and llvm::BitcodeReader::parseTriple().
BitstreamEntry llvm::BitstreamCursor::advanceSkippingSubblocks | ( | unsigned | Flags = 0 | ) | [inline] |
advanceSkippingSubblocks - This is a convenience function for clients that don't expect any subblocks. This just skips over them automatically.
Definition at line 309 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 249 of file BitstreamReader.h.
References isEndPos().
Referenced by EnterSubBlock(), llvm::BitcodeReader::ParseBitcodeInto(), and SkipBlock().
bool llvm::BitstreamCursor::canSkipToPos | ( | size_t | pos | ) | const [inline] |
Definition at line 237 of file BitstreamReader.h.
References llvm::BitstreamReader::getBitcodeBytes(), and llvm::StreamableMemoryObject::isValidAddress().
Referenced by JumpToBit(), readRecord(), SkipBlock(), and skipRecord().
bool BitstreamCursor::EnterSubBlock | ( | unsigned | BlockID, |
unsigned * | NumWordsP = nullptr |
||
) |
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::bitc::BlockSizeWidth, llvm::bitc::CodeLenWidth, llvm::BitstreamReader::getBlockInfo(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), Read(), and ReadVBR().
Referenced by ReadBlockInfoBlock().
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] |
getAbbrev - Return the abbreviation for the specified AbbrevId.
Definition at line 528 of file BitstreamReader.h.
References llvm::bitc::FIRST_APPLICATION_ABBREV.
Referenced by readRecord(), and skipRecord().
unsigned llvm::BitstreamCursor::getAbbrevIDWidth | ( | ) | const [inline] |
getAbbrevIDWidth - Return the number of bits used to encode an abbrev #.
Definition at line 254 of file BitstreamReader.h.
Referenced by llvm::BitcodeReader::ParseBitcodeInto().
BitstreamReader* llvm::BitstreamCursor::getBitStreamReader | ( | ) | [inline] |
Definition at line 261 of file BitstreamReader.h.
const BitstreamReader* llvm::BitstreamCursor::getBitStreamReader | ( | ) | const [inline] |
Definition at line 264 of file BitstreamReader.h.
uint64_t llvm::BitstreamCursor::GetCurrentBitNo | ( | ) | const [inline] |
GetCurrentBitNo - Return the bit # of the bit we are reading.
Definition at line 257 of file BitstreamReader.h.
Referenced by readRecord(), SkipBlock(), and skipRecord().
uint32_t llvm::BitstreamCursor::getWord | ( | size_t | pos | ) | [inline] |
Definition at line 243 of file BitstreamReader.h.
References llvm::BitstreamReader::getBitcodeBytes(), and llvm::StreamableMemoryObject::readBytes().
void llvm::BitstreamCursor::init | ( | BitstreamReader & | R | ) | [inline] |
Definition at line 221 of file BitstreamReader.h.
References freeState().
bool llvm::BitstreamCursor::isEndPos | ( | size_t | pos | ) | [inline] |
Definition at line 233 of file BitstreamReader.h.
References llvm::BitstreamReader::getBitcodeBytes(), and llvm::StreamableMemoryObject::isObjectEnd().
Referenced by AtEndOfStream(), and Read().
void llvm::BitstreamCursor::JumpToBit | ( | uint64_t | BitNo | ) | [inline] |
JumpToBit - Reset the stream to the specified bit number.
Definition at line 323 of file BitstreamReader.h.
References canSkipToPos(), Read(), and Read64().
Referenced by llvm::BitcodeReader::Materialize(), readRecord(), SkipBlock(), and skipRecord().
uint32_t llvm::BitstreamCursor::Read | ( | unsigned | NumBits | ) | [inline] |
Definition at line 343 of file BitstreamReader.h.
References llvm::BitstreamReader::getBitcodeBytes(), isEndPos(), llvm::support::little, llvm::LibFunc::memcpy, llvm::StreamableMemoryObject::readBytes(), and llvm::support::unaligned.
Referenced by EnterSubBlock(), JumpToBit(), llvm::BitcodeReader::ParseBitcodeInto(), llvm::BitcodeReader::parseTriple(), Read64(), ReadAbbrevRecord(), ReadCode(), ReadVBR(), ReadVBR64(), and SkipBlock().
uint64_t llvm::BitstreamCursor::Read64 | ( | unsigned | NumBits | ) | [inline] |
void BitstreamCursor::ReadAbbrevRecord | ( | ) |
Definition at line 248 of file BitstreamReader.cpp.
References llvm::BitCodeAbbrev::Add(), llvm::BitCodeAbbrevOp::Fixed, llvm::BitCodeAbbrevOp::hasEncodingData(), Read(), ReadVBR(), ReadVBR64(), and llvm::BitCodeAbbrevOp::VBR.
Referenced by advance(), and ReadBlockInfoBlock().
bool llvm::BitstreamCursor::ReadBlockEnd | ( | ) | [inline] |
Definition at line 494 of file BitstreamReader.h.
References llvm::SmallVectorBase::empty().
Referenced by advance().
Definition at line 278 of file BitstreamReader.cpp.
References llvm::BitstreamReader::BlockInfo::Abbrevs, advanceSkippingSubblocks(), AF_DontAutoprocessAbbrevs, llvm::bitc::BLOCKINFO_BLOCK_ID, llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, llvm::bitc::BLOCKINFO_CODE_SETBID, llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, llvm::SmallVectorImpl< T >::clear(), llvm::bitc::DEFINE_ABBREV, llvm::BitstreamEntry::EndBlock, EnterSubBlock(), llvm::BitstreamEntry::Error, llvm::BitstreamReader::getOrCreateBlockInfo(), llvm::BitstreamReader::hasBlockInfoRecords(), llvm::BitstreamEntry::ID, llvm::BitstreamReader::isIgnoringBlockInfoNames(), llvm::BitstreamEntry::Kind, llvm::BitstreamReader::BlockInfo::Name, Name, ReadAbbrevRecord(), readRecord(), llvm::BitstreamEntry::Record, llvm::BitstreamReader::BlockInfo::RecordNames, llvm::SmallVectorTemplateCommon< T >::size(), SkipBlock(), and llvm::BitstreamEntry::SubBlock.
Referenced by llvm::BitcodeReader::ParseBitcodeInto().
unsigned llvm::BitstreamCursor::ReadCode | ( | ) | [inline] |
unsigned BitstreamCursor::readRecord | ( | unsigned | AbbrevID, |
SmallVectorImpl< uint64_t > & | Vals, | ||
StringRef * | Blob = nullptr |
||
) |
Definition at line 162 of file BitstreamReader.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::BitCodeAbbrevOp::Array, llvm::BitCodeAbbrevOp::Blob, canSkipToPos(), llvm::tgtok::Code, getAbbrev(), llvm::BitstreamReader::getBitcodeBytes(), GetCurrentBitNo(), llvm::BitCodeAbbrevOp::getEncoding(), llvm::StreamableMemoryObject::getExtent(), llvm::BitCodeAbbrev::getNumOperandInfos(), llvm::BitCodeAbbrev::getOperandInfo(), llvm::StreamableMemoryObject::getPointer(), llvm::BitCodeAbbrevOp::isLiteral(), JumpToBit(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), ReadVBR(), ReadVBR64(), and llvm::bitc::UNABBREV_RECORD.
Referenced by ReadBlockInfoBlock().
unsigned llvm::BitstreamCursor::ReadSubBlockID | ( | ) | [inline] |
ReadSubBlockID - Having read the ENTER_SUBBLOCK code, read the BlockID for the block.
Definition at line 466 of file BitstreamReader.h.
References llvm::bitc::BlockIDWidth, and ReadVBR().
Referenced by advance().
uint32_t llvm::BitstreamCursor::ReadVBR | ( | unsigned | NumBits | ) | [inline] |
Definition at line 402 of file BitstreamReader.h.
References Read().
Referenced by EnterSubBlock(), ReadAbbrevRecord(), readRecord(), ReadSubBlockID(), SkipBlock(), and skipRecord().
uint64_t llvm::BitstreamCursor::ReadVBR64 | ( | unsigned | NumBits | ) | [inline] |
Definition at line 422 of file BitstreamReader.h.
References Read().
Referenced by ReadAbbrevRecord(), readRecord(), and skipRecord().
bool llvm::BitstreamCursor::SkipBlock | ( | ) | [inline] |
SkipBlock - 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 473 of file BitstreamReader.h.
References AtEndOfStream(), llvm::bitc::BlockSizeWidth, canSkipToPos(), llvm::bitc::CodeLenWidth, GetCurrentBitNo(), JumpToBit(), Read(), and ReadVBR().
Referenced by advanceSkippingSubblocks(), llvm::BitcodeReader::ParseBitcodeInto(), llvm::BitcodeReader::parseTriple(), and ReadBlockInfoBlock().
void BitstreamCursor::skipRecord | ( | unsigned | AbbrevID | ) |
skipRecord - Read the current record and discard it.
Definition at line 104 of file BitstreamReader.cpp.
References llvm::BitCodeAbbrevOp::Array, llvm::BitCodeAbbrevOp::Blob, canSkipToPos(), llvm::tgtok::Code, getAbbrev(), llvm::BitstreamReader::getBitcodeBytes(), GetCurrentBitNo(), llvm::BitCodeAbbrevOp::getEncoding(), llvm::StreamableMemoryObject::getExtent(), llvm::BitCodeAbbrev::getNumOperandInfos(), llvm::BitCodeAbbrev::getOperandInfo(), llvm::BitCodeAbbrevOp::isLiteral(), JumpToBit(), ReadVBR(), ReadVBR64(), and llvm::bitc::UNABBREV_RECORD.
Referenced by llvm::BitcodeReader::parseTriple().
friend class Deserializer [friend] |
Definition at line 177 of file BitstreamReader.h.