LLVM 24.0.0git
llvm::SimpleBitstreamCursor Class Reference

This represents a position within a bitstream. More...

#include "llvm/Bitstream/BitstreamReader.h"

Inheritance diagram for llvm::SimpleBitstreamCursor:
[legend]

Public Types

using word_t = size_t
 The type of the values returned by Read.

Public Member Functions

 SimpleBitstreamCursor ()=default
 SimpleBitstreamCursor (ArrayRef< uint8_t > BitcodeBytes)
 SimpleBitstreamCursor (StringRef BitcodeBytes)
 SimpleBitstreamCursor (MemoryBufferRef BitcodeBytes)
bool canSkipToPos (size_t pos) const
bool AtEndOfStream ()
uint64_t GetCurrentBitNo () const
 Return the bit # of the bit we are reading.
uint64_t getCurrentByteNo () const
ArrayRef< uint8_t > getBitcodeBytes () const
Error JumpToBit (uint64_t NewBitNo)
 Reset the stream to the specified bit number.
const uint8_t * getPointerToByte (uint64_t ByteNo, uint64_t NumBytes)
 Get a pointer into the bitstream at the specified byte offset.
const uint8_t * getPointerToBit (uint64_t BitNo, uint64_t NumBytes)
 Get a pointer into the bitstream at the specified bit offset.
Expected< word_t > Read (unsigned NumBits)
LLVM_ABI Expected< word_t > readSlow (unsigned NumBits)
 Read NumBits bits that don't fit in a word load from the current byte, or are near the end of the stream.
Expected< uint32_t > ReadVBR (const unsigned NumBits)
Expected< uint64_t > ReadVBR64 (const unsigned NumBits)
void SkipToFourByteBoundary ()
size_t SizeInBytes () const
 Return the size of the stream in bytes.
uint64_t sizeInBits () const
 Return the size of the stream in bits.
void skipToEnd ()
 Skip to the end of the file.
bool isSizePlausible (size_t Size) const
 Check whether a reservation of Size elements is plausible.

Detailed Description

This represents a position within a bitstream.

There may be multiple independent cursors reading within one bitstream, each maintaining their own local state.

Definition at line 82 of file BitstreamReader.h.

Member Typedef Documentation

◆ word_t

The type of the values returned by Read.

This is specifically and intentionally defined to follow the word size of the host machine for efficiency. We use word_t in places that are aware of this to make it perfectly explicit what is going on.

Definition at line 96 of file BitstreamReader.h.

Constructor & Destructor Documentation

◆ SimpleBitstreamCursor() [1/4]

◆ SimpleBitstreamCursor() [2/4]

llvm::SimpleBitstreamCursor::SimpleBitstreamCursor ( ArrayRef< uint8_t > BitcodeBytes)
inlineexplicit

Definition at line 103 of file BitstreamReader.h.

References llvm::size().

◆ SimpleBitstreamCursor() [3/4]

llvm::SimpleBitstreamCursor::SimpleBitstreamCursor ( StringRef BitcodeBytes)
inlineexplicit

Definition at line 108 of file BitstreamReader.h.

References llvm::arrayRefFromStringRef(), and SimpleBitstreamCursor().

◆ SimpleBitstreamCursor() [4/4]

llvm::SimpleBitstreamCursor::SimpleBitstreamCursor ( MemoryBufferRef BitcodeBytes)
inlineexplicit

Definition at line 110 of file BitstreamReader.h.

References SimpleBitstreamCursor().

Member Function Documentation

◆ AtEndOfStream()

bool llvm::SimpleBitstreamCursor::AtEndOfStream ( )
inline

Definition at line 118 of file BitstreamReader.h.

References sizeInBits().

◆ canSkipToPos()

bool llvm::SimpleBitstreamCursor::canSkipToPos ( size_t pos) const
inline

Definition at line 113 of file BitstreamReader.h.

Referenced by JumpToBit().

◆ getBitcodeBytes()

ArrayRef< uint8_t > llvm::SimpleBitstreamCursor::getBitcodeBytes ( ) const
inline

Definition at line 126 of file BitstreamReader.h.

◆ GetCurrentBitNo()

uint64_t llvm::SimpleBitstreamCursor::GetCurrentBitNo ( ) const
inline

Return the bit # of the bit we are reading.

Definition at line 121 of file BitstreamReader.h.

References uint64_t.

Referenced by getCurrentByteNo().

◆ getCurrentByteNo()

uint64_t llvm::SimpleBitstreamCursor::getCurrentByteNo ( ) const
inline

Definition at line 124 of file BitstreamReader.h.

References GetCurrentBitNo(), and uint64_t.

◆ getPointerToBit()

const uint8_t * llvm::SimpleBitstreamCursor::getPointerToBit ( uint64_t BitNo,
uint64_t NumBytes )
inline

Get a pointer into the bitstream at the specified bit offset.

The bit offset must be on a byte boundary.

Definition at line 148 of file BitstreamReader.h.

References assert(), getPointerToByte(), and uint64_t.

Referenced by llvm::BitstreamCursor::readRecord().

◆ getPointerToByte()

const uint8_t * llvm::SimpleBitstreamCursor::getPointerToByte ( uint64_t ByteNo,
uint64_t NumBytes )
inline

Get a pointer into the bitstream at the specified byte offset.

Definition at line 141 of file BitstreamReader.h.

References uint64_t.

Referenced by getPointerToBit().

◆ isSizePlausible()

bool llvm::SimpleBitstreamCursor::isSizePlausible ( size_t Size) const
inline

Check whether a reservation of Size elements is plausible.

Definition at line 264 of file BitstreamReader.h.

References llvm::Size.

Referenced by llvm::BitstreamCursor::readRecord().

◆ JumpToBit()

Error llvm::SimpleBitstreamCursor::JumpToBit ( uint64_t NewBitNo)
inline

Reset the stream to the specified bit number.

Definition at line 129 of file BitstreamReader.h.

References assert(), canSkipToPos(), llvm::createStringError(), sizeInBits(), llvm::Error::success(), and uint64_t.

◆ Read()

Expected< word_t > llvm::SimpleBitstreamCursor::Read ( unsigned NumBits)
inline

Definition at line 164 of file BitstreamReader.h.

References assert(), and readSlow().

◆ readSlow()

Expected< SimpleBitstreamCursor::word_t > SimpleBitstreamCursor::readSlow ( unsigned NumBits)

Read NumBits bits that don't fit in a word load from the current byte, or are near the end of the stream.

Definition at line 27 of file BitstreamReader.cpp.

References llvm::createStringError(), llvm::little, llvm::support::endian::readAtBitAlignment(), sizeInBits(), and llvm::support::unaligned.

Referenced by Read().

◆ ReadVBR()

Expected< uint32_t > llvm::SimpleBitstreamCursor::ReadVBR ( const unsigned NumBits)
inline

◆ ReadVBR64()

Expected< uint64_t > llvm::SimpleBitstreamCursor::ReadVBR64 ( const unsigned NumBits)
inline

◆ sizeInBits()

uint64_t llvm::SimpleBitstreamCursor::sizeInBits ( ) const
inline

Return the size of the stream in bits.

Definition at line 258 of file BitstreamReader.h.

References uint64_t.

Referenced by AtEndOfStream(), JumpToBit(), readSlow(), skipToEnd(), and SkipToFourByteBoundary().

◆ SizeInBytes()

size_t llvm::SimpleBitstreamCursor::SizeInBytes ( ) const
inline

Return the size of the stream in bytes.

Definition at line 255 of file BitstreamReader.h.

◆ skipToEnd()

void llvm::SimpleBitstreamCursor::skipToEnd ( )
inline

Skip to the end of the file.

Definition at line 261 of file BitstreamReader.h.

References sizeInBits().

◆ SkipToFourByteBoundary()


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