LLVM: llvm::BitstreamCursor Class Reference (original) (raw)
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor. More...
#include "[llvm/Bitstream/BitstreamReader.h](BitstreamReader%5F8h%5Fsource.html)"
| 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< BitstreamEntry > | advance (unsigned Flags=0) |
| Advance the current bitstream, returning the next entry in the stream. | |
| Expected< BitstreamEntry > | advanceSkippingSubblocks (unsigned Flags=0) |
| This is a convenience function for clients that don't expect any subblocks. | |
| Expected< unsigned > | ReadCode () |
| Expected< unsigned > | ReadSubBlockID () |
| 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< unsigned > | skipRecord (unsigned AbbrevID) |
| Read the current record and discard it, returning the code for the record. | |
| LLVM_ABI Expected< unsigned > | readRecord (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_t > | getBitcodeBytes () const |
| uint64_t | GetCurrentBitNo () const |
| Return the bit # of the bit we are reading. | |
| 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. | |
| Error | JumpToBit (uint64_t BitNo) |
| Reset the stream to the specified bit number. | |
| 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. | |
| void | skipToEnd () |
| Skip to the end of the file. |
| 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.
| 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 |
|---|
◆ advance()
Advance the current bitstream, returning the next entry in the stream.
Definition at line 418 of file BitstreamReader.h.
References AF_DontAutoprocessAbbrevs, AF_DontPopBlockAtEnd, 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::getRecord(), llvm::BitstreamEntry::getSubBlock(), ReadAbbrevRecord(), ReadBlockEnd(), ReadCode(), ReadSubBlockID(), and llvm::Expected< T >::takeError().
Referenced by advanceSkippingSubblocks(), expectSubBlock(), llvm::getBitcodeFileContents(), llvm::BitcodeModule::getLTOInfo(), hasObjCCategory(), jumpToValueSymbolTable(), readBlobInRecord(), readIdentificationBlock(), readIdentificationCode(), and readTriple().
◆ advanceSkippingSubblocks()
◆ AtEndOfStream()
| bool llvm::SimpleBitstreamCursor::AtEndOfStream ( ) | inline |
|---|
◆ canSkipToPos()
| bool llvm::SimpleBitstreamCursor::canSkipToPos ( size_t pos) const | inline |
|---|
◆ EnterSubBlock()
Having read the ENTER_SUBBLOCK abbrevid, and enter the block.
Having read the ENTER_SUBBLOCK abbrevid, enter the block.
Definition at line 26 of file BitstreamReader.cpp.
References llvm::append_range(), AtEndOfStream(), llvm::Block, llvm::bitc::BlockSizeWidth, llvm::bitc::CodeLenWidth, llvm::createStringError(), llvm::Expected< T >::get(), MaxChunkSize, llvm::Read, ReadVBR(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::Error::success(), and llvm::Expected< T >::takeError().
Referenced by getEnableSplitLTOUnitAndUnifiedFlag(), llvm::BitcodeModule::getLTOInfo(), hasObjCCategoryInModule(), readBlobInRecord(), ReadBlockInfoBlock(), readIdentificationBlock(), and readModuleTriple().
◆ fillCurWord()
| Error llvm::SimpleBitstreamCursor::fillCurWord ( ) | inline |
|---|
◆ getAbbrev()
◆ 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 |
|---|
◆ GetCurrentBitNo()
| uint64_t llvm::SimpleBitstreamCursor::GetCurrentBitNo ( ) const | inline |
|---|
◆ getCurrentByteNo()
| uint64_t llvm::SimpleBitstreamCursor::getCurrentByteNo ( ) const | inline |
|---|
◆ getPointerToByte()
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()
◆ ReadAbbrevRecord()
| Error BitstreamCursor::ReadAbbrevRecord | ( | ) |
|---|
Definition at line 364 of file BitstreamReader.cpp.
References llvm::Data, error, llvm::BitCodeAbbrevOp::Fixed, llvm::Expected< T >::get(), llvm::BitCodeAbbrevOp::hasEncodingData(), llvm::BitCodeAbbrevOp::isValidEncoding(), MaxChunkSize, llvm::Read, ReadVBR(), ReadVBR64(), llvm::Error::success(), llvm::Expected< T >::takeError(), and llvm::BitCodeAbbrevOp::VBR.
Referenced by advance(), and ReadBlockInfoBlock().
◆ ReadBlockEnd()
| bool llvm::BitstreamCursor::ReadBlockEnd ( ) | inline |
|---|
◆ ReadBlockInfoBlock()
Read and return a block info block from the bitstream.
If an error was encountered, return std::nullopt.
Parameters
| ReadBlockInfoNames | Whether to read block/record name information in the BlockInfo block. Only llvm-bcanalyzer uses this. |
|---|
Definition at line 423 of file BitstreamReader.cpp.
References llvm::BitstreamBlockInfo::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::bitc::DEFINE_ABBREV, llvm::BitstreamEntry::EndBlock, EnterSubBlock(), llvm::BitstreamEntry::Error, llvm::Expected< T >::get(), llvm::BitstreamBlockInfo::getOrCreateBlockInfo(), llvm::BitstreamBlockInfo::BlockInfo::Name, ReadAbbrevRecord(), readRecord(), llvm::BitstreamEntry::Record, llvm::BitstreamBlockInfo::BlockInfo::RecordNames, llvm::BitstreamEntry::SubBlock, and llvm::Expected< T >::takeError().
Referenced by llvm::BitcodeAnalyzer::analyze().
◆ ReadCode()
◆ readRecord()
Definition at line 214 of file BitstreamReader.cpp.
References llvm::alignTo(), llvm::SmallVectorImpl< T >::append(), llvm::BitCodeAbbrevOp::Array, assert(), llvm::BitCodeAbbrevOp::Blob, canSkipToPos(), llvm::BitCodeAbbrevOp::Char6, llvm::BitCodeAbbrevOp::DecodeChar6(), error, llvm::BitCodeAbbrevOp::Fixed, llvm::Expected< T >::get(), getAbbrev(), GetCurrentBitNo(), llvm::BitCodeAbbrevOp::getEncoding(), llvm::BitCodeAbbrevOp::getEncodingData(), llvm::BitCodeAbbrevOp::getLiteralValue(), llvm::BitCodeAbbrev::getNumOperandInfos(), llvm::BitCodeAbbrev::getOperandInfo(), llvm::SimpleBitstreamCursor::getPointerToBit(), llvm::BitCodeAbbrevOp::isEncoding(), llvm::BitCodeAbbrevOp::isLiteral(), llvm::SimpleBitstreamCursor::isSizePlausible(), JumpToBit(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Read, readAbbreviatedField(), ReadVBR(), ReadVBR64(), llvm::SmallVectorImpl< T >::reserve(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::Expected< T >::takeError(), llvm::toString(), llvm::bitc::UNABBREV_RECORD, and llvm::BitCodeAbbrevOp::VBR.
Referenced by getEnableSplitLTOUnitAndUnifiedFlag(), hasObjCCategoryInModule(), readBlobInRecord(), ReadBlockInfoBlock(), readIdentificationBlock(), and readModuleTriple().
◆ ReadSubBlockID()
◆ ReadVBR()
◆ ReadVBR64()
◆ setBlockInfo()
◆ SizeInBytes()
| size_t llvm::SimpleBitstreamCursor::SizeInBytes ( ) const | inline |
|---|
◆ SkipBlock()
| Error llvm::BitstreamCursor::SkipBlock ( ) | 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 AtEndOfStream(), llvm::bitc::BlockSizeWidth, canSkipToPos(), llvm::bitc::CodeLenWidth, llvm::createStringError(), llvm::Expected< T >::get(), GetCurrentBitNo(), JumpToBit(), llvm::Read, ReadVBR(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::Error::success(), and llvm::Expected< T >::takeError().
Referenced by advanceSkippingSubblocks(), llvm::BitcodeAnalyzer::analyze(), llvm::getBitcodeFileContents(), llvm::BitcodeModule::getLTOInfo(), hasObjCCategory(), readBlobInRecord(), readIdentificationCode(), and readTriple().
◆ skipRecord()
Read the current record and discard it, returning the code for the record.
skipRecord - Read the current record and discard it.
Definition at line 96 of file BitstreamReader.cpp.
References llvm::alignTo(), llvm::BitCodeAbbrevOp::Array, assert(), llvm::BitCodeAbbrevOp::Blob, canSkipToPos(), llvm::BitCodeAbbrevOp::Char6, llvm::createStringError(), error, llvm::BitCodeAbbrevOp::Fixed, llvm::Expected< T >::get(), getAbbrev(), GetCurrentBitNo(), llvm::BitCodeAbbrevOp::getEncoding(), llvm::BitCodeAbbrevOp::getEncodingData(), llvm::BitCodeAbbrevOp::getLiteralValue(), llvm::BitCodeAbbrev::getNumOperandInfos(), llvm::BitCodeAbbrev::getOperandInfo(), llvm::BitCodeAbbrevOp::isLiteral(), JumpToBit(), MaxChunkSize, readAbbreviatedField(), ReadVBR(), ReadVBR64(), skipToEnd(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::Expected< T >::takeError(), llvm::bitc::UNABBREV_RECORD, and llvm::BitCodeAbbrevOp::VBR.
Referenced by llvm::getBitcodeFileContents(), llvm::BitcodeModule::getLTOInfo(), hasObjCCategory(), readIdentificationCode(), and readTriple().
◆ skipToEnd()
| void llvm::SimpleBitstreamCursor::skipToEnd ( ) | inline |
|---|
◆ MaxChunkSize
| const size_t llvm::BitstreamCursor::MaxChunkSize = 32 | static |
|---|
The documentation for this class was generated from the following files:
- include/llvm/Bitstream/BitstreamReader.h
- lib/Bitstream/Reader/BitstreamReader.cpp