LLVM
8.0.1
|
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor. More...
#include "llvm/Bitcode/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... | |
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... | |
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 BitCodeAbbrev * | getAbbrev (unsigned AbbrevID) |
Return the abbreviation for the specified AbbrevId. More... | |
unsigned | skipRecord (unsigned AbbrevID) |
Read the current record and discard it, returning the code for the record. More... | |
unsigned | readRecord (unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr) |
void | ReadAbbrevRecord () |
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... | |
Static Public Attributes | |
static const size_t | MaxChunkSize = sizeof(word_t) * 8 |
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 312 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 359 of file BitstreamReader.h.
|
default |
|
inlineexplicit |
Definition at line 336 of file BitstreamReader.h.
|
inlineexplicit |
Definition at line 338 of file BitstreamReader.h.
|
inlineexplicit |
Definition at line 340 of file BitstreamReader.h.
References llvm::SimpleBitstreamCursor::AtEndOfStream(), llvm::SimpleBitstreamCursor::canSkipToPos(), llvm::SimpleBitstreamCursor::fillCurWord(), llvm::SimpleBitstreamCursor::getBitcodeBytes(), llvm::SimpleBitstreamCursor::GetCurrentBitNo(), llvm::SimpleBitstreamCursor::getCurrentByteNo(), llvm::SimpleBitstreamCursor::getPointerToByte(), llvm::SimpleBitstreamCursor::JumpToBit(), llvm::SimpleBitstreamCursor::Read(), llvm::SimpleBitstreamCursor::ReadVBR(), and llvm::SimpleBitstreamCursor::ReadVBR64().
|
inline |
Advance the current bitstream, returning the next entry in the stream.
Definition at line 370 of file BitstreamReader.h.
References llvm::bitc::DEFINE_ABBREV, llvm::bitc::END_BLOCK, llvm::bitc::ENTER_SUBBLOCK, llvm::BitstreamEntry::getEndBlock(), llvm::BitstreamEntry::getError(), llvm::BitstreamEntry::getRecord(), and llvm::BitstreamEntry::getSubBlock().
Referenced by llvm::getBitcodeFileContents(), llvm::BitcodeModule::getLTOInfo(), hasObjCCategory(), jumpToValueSymbolTable(), readBlobInRecord(), readIdentificationBlock(), readIdentificationCode(), and readTriple().
|
inline |
This is a convenience function for clients that don't expect any subblocks.
This just skips over them automatically.
Definition at line 400 of file BitstreamReader.h.
References llvm::BitstreamEntry::getError(), llvm::BitstreamEntry::Kind, and llvm::BitstreamEntry::SubBlock.
Referenced by decodeLLVMAttributesForBitcode(), getAttrFromCode(), getEnableSplitLTOUnitFlag(), hasObjCCategoryInModule(), jumpToValueSymbolTable(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadataKinds(), ReadBlockInfoBlock(), readModuleTriple(), readWideAPInt(), setImmutableRefs(), and llvm::MetadataLoader::MetadataLoaderImpl::upgradeDebugIntrinsics().
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 23 of file BitstreamReader.cpp.
References llvm::SimpleBitstreamCursor::AtEndOfStream(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::bitc::BlockSizeWidth, llvm::bitc::CodeLenWidth, llvm::BitstreamBlockInfo::getBlockInfo(), Info, MaxChunkSize, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SimpleBitstreamCursor::Read(), llvm::SimpleBitstreamCursor::ReadVBR(), and llvm::SimpleBitstreamCursor::SkipToFourByteBoundary().
Referenced by decodeLLVMAttributesForBitcode(), getAttrFromCode(), getEnableSplitLTOUnitFlag(), llvm::BitcodeModule::getLTOInfo(), hasObjCCategoryInModule(), jumpToValueSymbolTable(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadataKinds(), readBlobInRecord(), ReadBlockInfoBlock(), readIdentificationBlock(), readModuleTriple(), readWideAPInt(), and setImmutableRefs().
|
inline |
Return the abbreviation for the specified AbbrevId.
Definition at line 473 of file BitstreamReader.h.
References llvm::bitc::FIRST_APPLICATION_ABBREV, and llvm::report_fatal_error().
Referenced by readRecord(), and skipRecord().
|
inline |
Return the number of bits used to encode an abbrev #.
Definition at line 356 of file BitstreamReader.h.
Referenced by jumpToValueSymbolTable().
void BitstreamCursor::ReadAbbrevRecord | ( | ) |
Definition at line 285 of file BitstreamReader.cpp.
References llvm::Data, E, llvm::BitCodeAbbrevOp::Fixed, llvm::BitCodeAbbrevOp::hasEncodingData(), MaxChunkSize, llvm::SimpleBitstreamCursor::Read(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::ReadVBR64(), llvm::report_fatal_error(), and llvm::BitCodeAbbrevOp::VBR.
Referenced by ReadBlockInfoBlock().
|
inline |
Definition at line 448 of file BitstreamReader.h.
References llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::SmallVectorBase::empty(), and llvm::SmallVectorTemplateBase< T, bool >::pop_back().
Referenced by llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata().
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 324 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::SmallVectorImpl< T >::clear(), llvm::bitc::DEFINE_ABBREV, llvm::BitstreamEntry::EndBlock, EnterSubBlock(), llvm::BitstreamEntry::Error, llvm::BitstreamBlockInfo::getOrCreateBlockInfo(), llvm::BitstreamEntry::ID, llvm::BitstreamEntry::Kind, llvm::BitstreamBlockInfo::BlockInfo::Name, Name, llvm::None, ReadAbbrevRecord(), readRecord(), llvm::BitstreamEntry::Record, llvm::BitstreamBlockInfo::BlockInfo::RecordNames, llvm::SmallVectorBase::size(), and llvm::BitstreamEntry::SubBlock.
|
inline |
Definition at line 413 of file BitstreamReader.h.
unsigned BitstreamCursor::readRecord | ( | unsigned | AbbrevID, |
SmallVectorImpl< uint64_t > & | Vals, | ||
StringRef * | Blob = nullptr |
||
) |
Definition at line 179 of file BitstreamReader.cpp.
References llvm::SmallVectorImpl< T >::append(), llvm::BitCodeAbbrevOp::Array, assert(), llvm::BitCodeAbbrevOp::Blob, llvm::SimpleBitstreamCursor::canSkipToPos(), llvm::BitCodeAbbrevOp::Char6, llvm::BitCodeAbbrevOp::DecodeChar6(), llvm::BitCodeAbbrevOp::Fixed, getAbbrev(), llvm::SimpleBitstreamCursor::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::JumpToBit(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SimpleBitstreamCursor::Read(), readAbbreviatedField(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::ReadVBR64(), llvm::report_fatal_error(), llvm::SimpleBitstreamCursor::skipToEnd(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::bitc::UNABBREV_RECORD, and llvm::BitCodeAbbrevOp::VBR.
Referenced by decodeLLVMAttributesForBitcode(), getAttrFromCode(), getEnableSplitLTOUnitFlag(), hasObjCCategoryInModule(), jumpToValueSymbolTable(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadataAttachment(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadataKinds(), readBlobInRecord(), ReadBlockInfoBlock(), readIdentificationBlock(), readModuleTriple(), readWideAPInt(), setImmutableRefs(), and llvm::MetadataLoader::MetadataLoaderImpl::upgradeDebugIntrinsics().
|
inline |
Having read the ENTER_SUBBLOCK code, read the BlockID for the block.
Definition at line 421 of file BitstreamReader.h.
References llvm::bitc::BlockIDWidth.
|
inline |
Set the block info to be used by this BitstreamCursor to interpret abbreviated records.
Definition at line 501 of file BitstreamReader.h.
Referenced by readTriple().
|
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 427 of file BitstreamReader.h.
References llvm::BitstreamBlockInfo::BlockInfo::BlockID, llvm::bitc::BlockSizeWidth, and llvm::bitc::CodeLenWidth.
Referenced by llvm::getBitcodeFileContents(), llvm::BitcodeModule::getLTOInfo(), hasObjCCategory(), llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(), readBlobInRecord(), readIdentificationCode(), readTriple(), and readWideAPInt().
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::BitCodeAbbrevOp::Array, assert(), llvm::BitCodeAbbrevOp::Blob, llvm::SimpleBitstreamCursor::canSkipToPos(), llvm::BitCodeAbbrevOp::Char6, llvm::BitCodeAbbrevOp::Fixed, getAbbrev(), llvm::SimpleBitstreamCursor::GetCurrentBitNo(), llvm::BitCodeAbbrevOp::getEncoding(), llvm::BitCodeAbbrevOp::getEncodingData(), llvm::BitCodeAbbrevOp::getLiteralValue(), llvm::BitCodeAbbrev::getNumOperandInfos(), llvm::BitCodeAbbrev::getOperandInfo(), llvm::BitCodeAbbrevOp::isLiteral(), llvm::SimpleBitstreamCursor::JumpToBit(), MaxChunkSize, readAbbreviatedField(), llvm::SimpleBitstreamCursor::ReadVBR(), llvm::SimpleBitstreamCursor::ReadVBR64(), llvm::report_fatal_error(), skipAbbreviatedField(), llvm::SimpleBitstreamCursor::skipToEnd(), llvm::SimpleBitstreamCursor::SkipToFourByteBoundary(), llvm::bitc::UNABBREV_RECORD, and llvm::BitCodeAbbrevOp::VBR.
Referenced by llvm::getBitcodeFileContents(), llvm::BitcodeModule::getLTOInfo(), hasObjCCategory(), readIdentificationCode(), readTriple(), and llvm::MetadataLoader::MetadataLoaderImpl::upgradeDebugIntrinsics().
Definition at line 333 of file BitstreamReader.h.
Referenced by EnterSubBlock(), readAbbreviatedField(), ReadAbbrevRecord(), skipAbbreviatedField(), and skipRecord().