LLVM  13.0.0git
Classes | Public Member Functions | List of all members
llvm::BitstreamWriter Class Reference

#include "llvm/Bitstream/BitstreamWriter.h"

Public Member Functions

 BitstreamWriter (SmallVectorImpl< char > &O, raw_fd_stream *FS=nullptr, uint32_t FlushThreshold=512)
 Create a BitstreamWriter that writes to Buffer O. More...
 
 ~BitstreamWriter ()
 
uint64_t GetCurrentBitNo () const
 Retrieve the current position in the stream, in bits. More...
 
unsigned GetAbbrevIDWidth () const
 Retrieve the number of bits currently used to encode an abbrev ID. More...
 
void BackpatchWord (uint64_t BitNo, unsigned NewWord)
 Backpatch a 32-bit word in the output at the given bit offset with the specified value. More...
 
void BackpatchWord64 (uint64_t BitNo, uint64_t Val)
 
void Emit (uint32_t Val, unsigned NumBits)
 
void FlushToWord ()
 
void EmitVBR (uint32_t Val, unsigned NumBits)
 
void EmitVBR64 (uint64_t Val, unsigned NumBits)
 
void EmitCode (unsigned Val)
 EmitCode - Emit the specified code. More...
 
BlockInfo * getBlockInfo (unsigned BlockID)
 getBlockInfo - If there is block info for the specified ID, return it, otherwise return null. More...
 
void EnterSubblock (unsigned BlockID, unsigned CodeLen)
 
void ExitBlock ()
 
template<class UIntTy >
void emitBlob (ArrayRef< UIntTy > Bytes, bool ShouldEmitSize=true)
 Emit a blob, including flushing before and tail-padding. More...
 
void emitBlob (StringRef Bytes, bool ShouldEmitSize=true)
 
template<typename Container >
void EmitRecord (unsigned Code, const Container &Vals, unsigned Abbrev=0)
 EmitRecord - Emit the specified record to the stream, using an abbrev if we have one to compress the output. More...
 
template<typename Container >
void EmitRecordWithAbbrev (unsigned Abbrev, const Container &Vals)
 EmitRecordWithAbbrev - Emit a record with the specified abbreviation. More...
 
template<typename Container >
void EmitRecordWithBlob (unsigned Abbrev, const Container &Vals, StringRef Blob)
 EmitRecordWithBlob - Emit the specified record to the stream, using an abbrev that includes a blob at the end. More...
 
template<typename Container >
void EmitRecordWithBlob (unsigned Abbrev, const Container &Vals, const char *BlobData, unsigned BlobLen)
 
template<typename Container >
void EmitRecordWithArray (unsigned Abbrev, const Container &Vals, StringRef Array)
 EmitRecordWithArray - Just like EmitRecordWithBlob, works with records that end with an array. More...
 
template<typename Container >
void EmitRecordWithArray (unsigned Abbrev, const Container &Vals, const char *ArrayData, unsigned ArrayLen)
 
unsigned EmitAbbrev (std::shared_ptr< BitCodeAbbrev > Abbv)
 Emits the abbreviation Abbv to the stream. More...
 
void EnterBlockInfoBlock ()
 EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK. More...
 
unsigned EmitBlockInfoAbbrev (unsigned BlockID, std::shared_ptr< BitCodeAbbrev > Abbv)
 EmitBlockInfoAbbrev - Emit a DEFINE_ABBREV record for the specified BlockID. More...
 

Detailed Description

Definition at line 29 of file BitstreamWriter.h.

Constructor & Destructor Documentation

◆ BitstreamWriter()

llvm::BitstreamWriter::BitstreamWriter ( SmallVectorImpl< char > &  O,
raw_fd_stream FS = nullptr,
uint32_t  FlushThreshold = 512 
)
inline

Create a BitstreamWriter that writes to Buffer O.

FS is the file stream that O flushes to incrementally. If FS is null, O does not flush incrementially, but writes to disk at the end.

FlushThreshold is the threshold (unit M) to flush O if FS is valid.

Definition at line 117 of file BitstreamWriter.h.

◆ ~BitstreamWriter()

llvm::BitstreamWriter::~BitstreamWriter ( )
inline

Definition at line 122 of file BitstreamWriter.h.

References assert().

Member Function Documentation

◆ BackpatchWord()

void llvm::BitstreamWriter::BackpatchWord ( uint64_t  BitNo,
unsigned  NewWord 
)
inline

Backpatch a 32-bit word in the output at the given bit offset with the specified value.

Definition at line 139 of file BitstreamWriter.h.

References assert(), i, and llvm::min().

Referenced by BackpatchWord64(), and ExitBlock().

◆ BackpatchWord64()

void llvm::BitstreamWriter::BackpatchWord64 ( uint64_t  BitNo,
uint64_t  Val 
)
inline

Definition at line 197 of file BitstreamWriter.h.

References BackpatchWord().

◆ Emit()

void llvm::BitstreamWriter::Emit ( uint32_t  Val,
unsigned  NumBits 
)
inline

◆ EmitAbbrev()

unsigned llvm::BitstreamWriter::EmitAbbrev ( std::shared_ptr< BitCodeAbbrev Abbv)
inline

Emits the abbreviation Abbv to the stream.

Definition at line 571 of file BitstreamWriter.h.

References llvm::bitc::FIRST_APPLICATION_ABBREV, and move.

Referenced by llvm::BCGenericRecordLayout< BCLiteral< RecordCode >, Fields... >::emitAbbrev(), and writeIdentificationBlock().

◆ emitBlob() [1/2]

template<class UIntTy >
void llvm::BitstreamWriter::emitBlob ( ArrayRef< UIntTy >  Bytes,
bool  ShouldEmitSize = true 
)
inline

Emit a blob, including flushing before and tail-padding.

Definition at line 465 of file BitstreamWriter.h.

References assert(), B, EmitVBR(), FlushToWord(), llvm::isUInt< 8 >(), and llvm::ArrayRef< T >::size().

Referenced by emitBlob().

◆ emitBlob() [2/2]

void llvm::BitstreamWriter::emitBlob ( StringRef  Bytes,
bool  ShouldEmitSize = true 
)
inline

◆ EmitBlockInfoAbbrev()

unsigned llvm::BitstreamWriter::EmitBlockInfoAbbrev ( unsigned  BlockID,
std::shared_ptr< BitCodeAbbrev Abbv 
)
inline

◆ EmitCode()

void llvm::BitstreamWriter::EmitCode ( unsigned  Val)
inline

EmitCode - Emit the specified code.

Definition at line 260 of file BitstreamWriter.h.

References Emit().

Referenced by EmitRecord(), EnterSubblock(), and ExitBlock().

◆ EmitRecord()

template<typename Container >
void llvm::BitstreamWriter::EmitRecord ( unsigned  Code,
const Container &  Vals,
unsigned  Abbrev = 0 
)
inline

EmitRecord - Emit the specified record to the stream, using an abbrev if we have one to compress the output.

Definition at line 491 of file BitstreamWriter.h.

References llvm::numbers::e, EmitCode(), EmitVBR(), EmitVBR64(), i, llvm::makeArrayRef(), and llvm::bitc::UNABBREV_RECORD.

Referenced by writeFunctionTypeMetadataRecords(), writeIdentificationBlock(), and writeStringRecord().

◆ EmitRecordWithAbbrev()

template<typename Container >
void llvm::BitstreamWriter::EmitRecordWithAbbrev ( unsigned  Abbrev,
const Container &  Vals 
)
inline

◆ EmitRecordWithArray() [1/2]

template<typename Container >
void llvm::BitstreamWriter::EmitRecordWithArray ( unsigned  Abbrev,
const Container &  Vals,
const char *  ArrayData,
unsigned  ArrayLen 
)
inline

Definition at line 540 of file BitstreamWriter.h.

References llvm::makeArrayRef(), and llvm::None.

◆ EmitRecordWithArray() [2/2]

template<typename Container >
void llvm::BitstreamWriter::EmitRecordWithArray ( unsigned  Abbrev,
const Container &  Vals,
StringRef  Array 
)
inline

EmitRecordWithArray - Just like EmitRecordWithBlob, works with records that end with an array.

Definition at line 535 of file BitstreamWriter.h.

References llvm::makeArrayRef(), and llvm::None.

Referenced by llvm::detail::BCRecordCoding< BCArray< ElementTy > >::emit().

◆ EmitRecordWithBlob() [1/2]

template<typename Container >
void llvm::BitstreamWriter::EmitRecordWithBlob ( unsigned  Abbrev,
const Container &  Vals,
const char *  BlobData,
unsigned  BlobLen 
)
inline

Definition at line 526 of file BitstreamWriter.h.

References llvm::makeArrayRef(), and llvm::None.

◆ EmitRecordWithBlob() [2/2]

template<typename Container >
void llvm::BitstreamWriter::EmitRecordWithBlob ( unsigned  Abbrev,
const Container &  Vals,
StringRef  Blob 
)
inline

EmitRecordWithBlob - Emit the specified record to the stream, using an abbrev that includes a blob at the end.

The blob data to emit is specified by the pointer and length specified at the end. In contrast to EmitRecord, this routine expects that the first entry in Vals is the code of the record.

Definition at line 521 of file BitstreamWriter.h.

References llvm::makeArrayRef(), and llvm::None.

Referenced by llvm::detail::BCRecordCoding< BCBlob >::emit(), llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaExternalFile(), and llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaStrTab().

◆ EmitVBR()

void llvm::BitstreamWriter::EmitVBR ( uint32_t  Val,
unsigned  NumBits 
)
inline

Definition at line 229 of file BitstreamWriter.h.

References assert(), Emit(), and Threshold.

Referenced by emitBlob(), EmitRecord(), EmitVBR64(), and EnterSubblock().

◆ EmitVBR64()

void llvm::BitstreamWriter::EmitVBR64 ( uint64_t  Val,
unsigned  NumBits 
)
inline

Definition at line 242 of file BitstreamWriter.h.

References assert(), Emit(), EmitVBR(), and Threshold.

Referenced by EmitRecord().

◆ EnterBlockInfoBlock()

void llvm::BitstreamWriter::EnterBlockInfoBlock ( )
inline

EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK.

Definition at line 583 of file BitstreamWriter.h.

References llvm::bitc::BLOCKINFO_BLOCK_ID, and EnterSubblock().

Referenced by llvm::remarks::BitstreamRemarkSerializerHelper::setupBlockInfo().

◆ EnterSubblock()

void llvm::BitstreamWriter::EnterSubblock ( unsigned  BlockID,
unsigned  CodeLen 
)
inline

◆ ExitBlock()

void llvm::BitstreamWriter::ExitBlock ( )
inline

◆ FlushToWord()

void llvm::BitstreamWriter::FlushToWord ( )
inline

Definition at line 221 of file BitstreamWriter.h.

Referenced by emitBlob(), EnterSubblock(), and ExitBlock().

◆ GetAbbrevIDWidth()

unsigned llvm::BitstreamWriter::GetAbbrevIDWidth ( ) const
inline

Retrieve the number of bits currently used to encode an abbrev ID.

Definition at line 131 of file BitstreamWriter.h.

◆ getBlockInfo()

BlockInfo* llvm::BitstreamWriter::getBlockInfo ( unsigned  BlockID)
inline

getBlockInfo - If there is block info for the specified ID, return it, otherwise return null.

Definition at line 270 of file BitstreamWriter.h.

References llvm::numbers::e, and i.

Referenced by EnterSubblock().

◆ GetCurrentBitNo()

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

Retrieve the current position in the stream, in bits.

Definition at line 128 of file BitstreamWriter.h.


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