LLVM  10.0.0svn
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
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:
Inheritance graph
[legend]
Collaboration diagram for llvm::BitstreamCursor:
Collaboration graph
[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 #. More...
 
Expected< BitstreamEntryadvance (unsigned Flags=0)
 Advance the current bitstream, returning the next entry in the stream. More...
 
Expected< BitstreamEntryadvanceSkippingSubblocks (unsigned Flags=0)
 This is a convenience function for clients that don't expect any subblocks. More...
 
Expected< unsignedReadCode ()
 
Expected< unsignedReadSubBlockID ()
 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 ()
 
const BitCodeAbbrevgetAbbrev (unsigned AbbrevID)
 Return the abbreviation for the specified AbbrevId. More...
 
Expected< unsignedskipRecord (unsigned AbbrevID)
 Read the current record and discard it, returning the code for the record. More...
 
Expected< unsignedreadRecord (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...
 

Static Public Attributes

static const size_t MaxChunkSize = sizeof(word_t) * 8
 

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 339 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 387 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

Definition at line 363 of file BitstreamReader.h.

◆ BitstreamCursor() [3/4]

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

Definition at line 365 of file BitstreamReader.h.

◆ BitstreamCursor() [4/4]

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

Member Function Documentation

◆ advance()

Expected<BitstreamEntry> llvm::BitstreamCursor::advance ( unsigned  Flags = 0)
inline

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

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

Referenced by llvm::MetadataLoader::MetadataLoaderImpl::upgradeDebugIntrinsics().

◆ EnterSubBlock()

Error BitstreamCursor::EnterSubBlock ( unsigned  BlockID,
unsigned NumWordsP = nullptr 
)

◆ getAbbrev()

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

Return the abbreviation for the specified AbbrevId.

Definition at line 523 of file BitstreamReader.h.

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

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

Referenced by jumpToValueSymbolTable().

◆ ReadAbbrevRecord()

Error BitstreamCursor::ReadAbbrevRecord ( )

◆ ReadBlockEnd()

bool llvm::BitstreamCursor::ReadBlockEnd ( )
inline

◆ ReadBlockInfoBlock()

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.

Parameters
ReadBlockInfoNamesWhether to read block/record name information in the BlockInfo block. Only llvm-bcanalyzer uses this.

Definition at line 432 of file BitstreamReader.cpp.

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

◆ ReadCode()

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

Definition at line 454 of file BitstreamReader.h.

Referenced by llvm::BitcodeAnalyzer::analyze().

◆ readRecord()

Expected< unsigned > BitstreamCursor::readRecord ( unsigned  AbbrevID,
SmallVectorImpl< uint64_t > &  Vals,
StringRef Blob = nullptr 
)

◆ ReadSubBlockID()

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

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

Definition at line 460 of file BitstreamReader.h.

References llvm::bitc::BlockIDWidth.

Referenced by llvm::BitcodeAnalyzer::analyze().

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

Referenced by llvm::BitcodeAnalyzer::analyze().

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

References llvm::BitstreamBlockInfo::BlockInfo::BlockID, llvm::bitc::BlockSizeWidth, llvm::bitc::CodeLenWidth, llvm::createStringError(), llvm::Expected< T >::get(), llvm::Error::success(), and llvm::Expected< T >::takeError().

◆ skipRecord()

Expected< unsigned > BitstreamCursor::skipRecord ( unsigned  AbbrevID)

Member Data Documentation

◆ MaxChunkSize

const size_t llvm::BitstreamCursor::MaxChunkSize = sizeof(word_t) * 8
static

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