29 BlockScope.
back().PrevAbbrevs.swap(CurAbbrevs);
43 CurCodeSize = MaybeVBR.
get();
47 std::errc::illegal_byte_sequence,
48 "can't read more than %zu at a time, trying to read %u", +
MaxChunkSize,
57 *NumWordsP = NumWords;
61 std::errc::illegal_byte_sequence,
62 "can't enter sub-block: current code size is 0");
65 std::errc::illegal_byte_sequence,
66 "can't enter sub block: already at end of stream");
73 assert(!
Op.isLiteral() &&
"Not to be used with literals!");
76 switch (
Op.getEncoding()) {
82 return Cursor.
Read((
unsigned)
Op.getEncodingData());
85 return Cursor.
ReadVBR64((
unsigned)
Op.getEncodingData());
90 return Res.takeError();
102 unsigned Code = MaybeCode.
get();
106 unsigned NumElts = MaybeVBR.
get();
107 for (
unsigned i = 0; i != NumElts; ++i)
111 return Res.takeError();
128 std::errc::illegal_byte_sequence,
129 "Abbreviation starts with an Array or a Blob");
133 Code = MaybeCode.
get();
146 return MaybeField.takeError();
154 unsigned NumElts = MaybeNum.
get();
157 assert(i+2 == e &&
"array op not second to last?");
164 return error(
"Array element type can't be an Array or a Blob");
174 for (; NumElts; --NumElts)
179 return Res.takeError();
194 unsigned NumElts = MaybeNum.
get();
229 return error(
"Size is not plausible");
232 for (
unsigned i = 0; i != NumElts; ++i)
236 return MaybeVal.takeError();
254 return error(
"Abbreviation starts with an Array or a Blob");
256 Code = MaybeCode.get();
258 return MaybeCode.takeError();
263 if (
Op.isLiteral()) {
273 return MaybeVal.takeError();
286 return error(
"Size is not plausible");
291 return error(
"Array op not second to last");
295 "Array element type has to be an encoding of a type");
300 return error(
"Array element type can't be an Array or a Blob");
302 for (; NumElts; --NumElts)
307 return MaybeVal.takeError();
310 for (; NumElts; --NumElts)
315 return MaybeVal.takeError();
318 for (; NumElts; --NumElts)
322 return MaybeVal.takeError();
337 const size_t NewEnd =
342 return error(
"Blob ends too soon");
356 auto *UPtr =
reinterpret_cast<const unsigned char *
>(
Ptr);
357 Vals.
append(UPtr, UPtr + NumElts);
365 auto Abbv = std::make_shared<BitCodeAbbrev>();
369 unsigned NumOpInfo = MaybeNumOpInfo.
get();
370 for (
unsigned i = 0; i != NumOpInfo; ++i) {
374 bool IsLiteral = MaybeIsLiteral.
get();
387 return error(
"Invalid encoding");
408 return error(
"Fixed or VBR abbrev record with size > MaxChunkData");
415 if (Abbv->getNumOperandInfos() == 0)
416 return error(
"Abbrev record with no operands");
417 CurAbbrevs.push_back(std::move(Abbv));
440 switch (Entry.Kind) {
445 return std::move(NewBlockInfo);
460 CurBlockInfo->
Abbrevs.push_back(std::move(CurAbbrevs.back()));
461 CurAbbrevs.pop_back();
470 switch (MaybeBlockInfo.
get()) {
481 if (!ReadBlockInfoNames)
489 if (!ReadBlockInfoNames)
static Expected< uint64_t > readAbbreviatedField(BitstreamCursor &Cursor, const BitCodeAbbrevOp &Op)
Analysis containing CSE Info
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
uint64_t getLiteralValue() const
static bool isValidEncoding(uint64_t E)
bool hasEncodingData() const
Encoding getEncoding() const
static char DecodeChar6(unsigned V)
uint64_t getEncodingData() const
BitCodeAbbrev - This class represents an abbreviation record.
unsigned getNumOperandInfos() const
const BitCodeAbbrevOp & getOperandInfo(unsigned N) const
This class maintains the abbreviations read from a block info block.
const BlockInfo * getBlockInfo(unsigned BlockID) const
If there is block info for the specified ID, return it, otherwise return null.
BlockInfo & getOrCreateBlockInfo(unsigned BlockID)
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.
Error JumpToBit(uint64_t BitNo)
Reset the stream to the specified bit number.
uint64_t GetCurrentBitNo() const
Return the bit # of the bit we are reading.
Expected< uint64_t > ReadVBR64(const unsigned NumBits)
static const size_t MaxChunkSize
Expected< word_t > Read(unsigned NumBits)
Expected< BitstreamEntry > advanceSkippingSubblocks(unsigned Flags=0)
This is a convenience function for clients that don't expect any subblocks.
Expected< const BitCodeAbbrev * > getAbbrev(unsigned AbbrevID)
Return the abbreviation for the specified AbbrevId.
Expected< unsigned > readRecord(unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr)
Error EnterSubBlock(unsigned BlockID, unsigned *NumWordsP=nullptr)
Having read the ENTER_SUBBLOCK abbrevid, and enter the block.
@ AF_DontAutoprocessAbbrevs
If this flag is used, abbrev entries are returned just like normal records.
Expected< unsigned > skipRecord(unsigned AbbrevID)
Read the current record and discard it, returning the code for the record.
void skipToEnd()
Skip to the end of the file.
Expected< std::optional< BitstreamBlockInfo > > ReadBlockInfoBlock(bool ReadBlockInfoNames=false)
Read and return a block info block from the bitstream.
Expected< uint32_t > ReadVBR(const unsigned NumBits)
bool canSkipToPos(size_t pos) const
This class represents an Operation in the Expression.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
const uint8_t * getPointerToBit(uint64_t BitNo, uint64_t NumBytes)
Get a pointer into the bitstream at the specified bit offset.
size_t word_t
This is the current data we have pulled from the stream but have not returned to the client.
void SkipToFourByteBoundary()
bool isSizePlausible(size_t Size) const
Check whether a reservation of Size elements is plausible.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ BLOCKINFO_CODE_BLOCKNAME
@ BLOCKINFO_CODE_SETRECORDNAME
@ BLOCKINFO_BLOCK_ID
BLOCKINFO_BLOCK is used to define metadata about blocks, for example, standard abbrevs that should be...
@ DEFINE_ABBREV
DEFINE_ABBREV - Defines an abbrev for the current block.
This is an optimization pass for GlobalISel generic memory operations.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
const char * toString(DWARFSectionKind Kind)
This contains information emitted to BLOCKINFO_BLOCK blocks.
std::vector< std::pair< unsigned, std::string > > RecordNames
std::vector< std::shared_ptr< BitCodeAbbrev > > Abbrevs
When advancing through a bitstream cursor, each advance can discover a few different kinds of entries...