LLVM 18.0.0git
|
#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 . | |
~BitstreamWriter () | |
uint64_t | GetCurrentBitNo () const |
Retrieve the current position in the stream, in bits. | |
unsigned | GetAbbrevIDWidth () const |
Retrieve the number of bits currently used to encode an abbrev ID. | |
void | BackpatchByte (uint64_t BitNo, uint8_t NewByte) |
Backpatch a byte in the output at the given bit offset with the specified value. | |
void | BackpatchHalfWord (uint64_t BitNo, uint16_t Val) |
void | BackpatchWord (uint64_t BitNo, unsigned Val) |
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. | |
BlockInfo * | getBlockInfo (unsigned BlockID) |
getBlockInfo - If there is block info for the specified ID, return it, otherwise return null. | |
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. | |
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. | |
template<typename Container > | |
void | EmitRecordWithAbbrev (unsigned Abbrev, const Container &Vals) |
EmitRecordWithAbbrev - Emit a record with the specified abbreviation. | |
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. | |
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. | |
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. | |
void | EnterBlockInfoBlock () |
EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK. | |
unsigned | EmitBlockInfoAbbrev (unsigned BlockID, std::shared_ptr< BitCodeAbbrev > Abbv) |
EmitBlockInfoAbbrev - Emit a DEFINE_ABBREV record for the specified BlockID. | |
Definition at line 30 of file BitstreamWriter.h.
|
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. Flushing only occurs at (sub)block boundaries.
Definition at line 113 of file BitstreamWriter.h.
|
inline |
Definition at line 118 of file BitstreamWriter.h.
References assert().
|
inline |
Backpatch a byte in the output at the given bit offset with the specified value.
Definition at line 135 of file BitstreamWriter.h.
References assert(), llvm::little, and llvm::support::endian::readAtBitAlignment().
Referenced by BackpatchHalfWord().
Definition at line 194 of file BitstreamWriter.h.
References BackpatchByte().
Referenced by BackpatchWord().
Definition at line 199 of file BitstreamWriter.h.
References BackpatchHalfWord().
Referenced by BackpatchWord64(), and ExitBlock().
Definition at line 204 of file BitstreamWriter.h.
References BackpatchWord().
Definition at line 209 of file BitstreamWriter.h.
References assert().
Referenced by llvm::dxil::BitcodeWriter::BitcodeWriter(), llvm::remarks::BitstreamRemarkSerializerHelper::setupBlockInfo(), and writeBitcodeHeader().
|
inline |
Emits the abbreviation Abbv
to the stream.
Definition at line 576 of file BitstreamWriter.h.
References llvm::bitc::FIRST_APPLICATION_ABBREV.
Referenced by llvm::BCGenericRecordLayout< IDField, Fields >::emitAbbrev(), and writeIdentificationBlock().
|
inline |
Emit a blob, including flushing before and tail-padding.
Definition at line 472 of file BitstreamWriter.h.
References llvm::all_of(), llvm::SmallVectorImpl< T >::append(), assert(), B, llvm::ArrayRef< T >::begin(), EmitVBR(), llvm::ArrayRef< T >::end(), FlushToWord(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::ArrayRef< T >::size().
Referenced by emitBlob().
Definition at line 488 of file BitstreamWriter.h.
References llvm::StringRef::data(), emitBlob(), and llvm::StringRef::size().
|
inline |
EmitBlockInfoAbbrev - Emit a DEFINE_ABBREV record for the specified BlockID.
Definition at line 618 of file BitstreamWriter.h.
References llvm::bitc::FIRST_APPLICATION_ABBREV, and Info.
Referenced by llvm::remarks::BitstreamRemarkSerializerHelper::setupMetaBlockInfo(), llvm::remarks::BitstreamRemarkSerializerHelper::setupMetaExternalFile(), llvm::remarks::BitstreamRemarkSerializerHelper::setupMetaRemarkVersion(), llvm::remarks::BitstreamRemarkSerializerHelper::setupMetaStrTab(), and llvm::remarks::BitstreamRemarkSerializerHelper::setupRemarkBlockInfo().
|
inline |
EmitCode - Emit the specified code.
Definition at line 267 of file BitstreamWriter.h.
References Emit.
Referenced by EmitRecord(), EnterSubblock(), and ExitBlock().
|
inline |
EmitRecord - Emit the specified record to the stream, using an abbrev if we have one to compress the output.
Definition at line 496 of file BitstreamWriter.h.
References EmitCode(), EmitVBR(), EmitVBR64(), and llvm::bitc::UNABBREV_RECORD.
Referenced by writeFunctionHeapProfileRecords(), writeFunctionTypeMetadataRecords(), writeIdentificationBlock(), writeStringRecord(), and llvm::dxil::DXILBitcodeWriter::writeStringRecord().
|
inline |
EmitRecordWithAbbrev - Emit a record with the specified abbreviation.
Unlike EmitRecord, the code for the record should be included in Vals as the first entry.
Definition at line 516 of file BitstreamWriter.h.
Referenced by llvm::detail::BCRecordCoding< BCArray< ElementTy > >::emit(), llvm::detail::BCRecordCoding< ElementTy >::emit(), llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaBlock(), llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaRemarkVersion(), and llvm::remarks::BitstreamRemarkSerializerHelper::emitRemarkBlock().
|
inline |
Definition at line 545 of file BitstreamWriter.h.
|
inline |
EmitRecordWithArray - Just like EmitRecordWithBlob, works with records that end with an array.
Definition at line 540 of file BitstreamWriter.h.
Referenced by llvm::detail::BCRecordCoding< BCArray< ElementTy > >::emit().
|
inline |
Definition at line 531 of file BitstreamWriter.h.
|
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 526 of file BitstreamWriter.h.
Referenced by llvm::detail::BCRecordCoding< BCBlob >::emit(), llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaExternalFile(), and llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaStrTab().
Definition at line 236 of file BitstreamWriter.h.
References assert(), and Emit.
Referenced by emitBlob(), EmitRecord(), EmitVBR64(), and EnterSubblock().
Definition at line 249 of file BitstreamWriter.h.
References assert(), Emit, and EmitVBR().
Referenced by EmitRecord().
|
inline |
EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK.
Definition at line 588 of file BitstreamWriter.h.
References llvm::bitc::BLOCKINFO_BLOCK_ID, and EnterSubblock().
Referenced by llvm::remarks::BitstreamRemarkSerializerHelper::setupBlockInfo().
Definition at line 288 of file BitstreamWriter.h.
References llvm::append_range(), llvm::bitc::BlockIDWidth, llvm::bitc::BlockSizeWidth, llvm::bitc::CodeLenWidth, Emit, EmitCode(), EmitVBR(), llvm::bitc::ENTER_SUBBLOCK, FlushToWord(), getBlockInfo(), and Info.
Referenced by llvm::BCBlockRAII::BCBlockRAII(), llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaBlock(), llvm::remarks::BitstreamRemarkSerializerHelper::emitRemarkBlock(), EnterBlockInfoBlock(), llvm::dxil::DXILBitcodeWriter::write(), and writeIdentificationBlock().
|
inline |
Definition at line 315 of file BitstreamWriter.h.
References assert(), B, BackpatchWord(), EmitCode(), llvm::bitc::END_BLOCK, and FlushToWord().
Referenced by llvm::remarks::BitstreamRemarkSerializerHelper::emitMetaBlock(), llvm::remarks::BitstreamRemarkSerializerHelper::emitRemarkBlock(), llvm::remarks::BitstreamRemarkSerializerHelper::setupBlockInfo(), llvm::dxil::DXILBitcodeWriter::write(), writeIdentificationBlock(), and llvm::BCBlockRAII::~BCBlockRAII().
|
inline |
Definition at line 228 of file BitstreamWriter.h.
Referenced by emitBlob(), EnterSubblock(), and ExitBlock().
|
inline |
Retrieve the number of bits currently used to encode an abbrev ID.
Definition at line 127 of file BitstreamWriter.h.
|
inline |
getBlockInfo - If there is block info for the specified ID, return it, otherwise return null.
Definition at line 277 of file BitstreamWriter.h.
Referenced by EnterSubblock().
|
inline |
Retrieve the current position in the stream, in bits.
Definition at line 124 of file BitstreamWriter.h.