Go to the documentation of this file.
27 BlockScope.push_back(Block(CurCodeSize));
28 BlockScope.back().PrevAbbrevs.
swap(CurAbbrevs);
42 CurCodeSize = MaybeVBR.
get();
46 std::errc::illegal_byte_sequence,
47 "can't read more than %zu at a time, trying to read %u", +
MaxChunkSize,
56 *NumWordsP = NumWords;
60 std::errc::illegal_byte_sequence,
61 "can't enter sub-block: current code size is 0");
64 std::errc::illegal_byte_sequence,
65 "can't enter sub block: already at end of stream");
72 assert(!
Op.isLiteral() &&
"Not to be used with literals!");
75 switch (
Op.getEncoding()) {
81 return Cursor.
Read((
unsigned)
Op.getEncodingData());
84 return Cursor.
ReadVBR64((
unsigned)
Op.getEncodingData());
89 return Res.takeError();
101 unsigned Code = MaybeCode.
get();
105 unsigned NumElts = MaybeVBR.
get();
106 for (
unsigned i = 0;
i != NumElts; ++
i)
110 return Res.takeError();
127 std::errc::illegal_byte_sequence,
128 "Abbreviation starts with an Array or a Blob");
132 Code = MaybeCode.
get();
145 return MaybeField.takeError();
153 unsigned NumElts = MaybeNum.
get();
156 assert(
i+2 ==
e &&
"array op not second to last?");
163 return error(
"Array element type can't be an Array or a Blob");
173 for (; NumElts; --NumElts)
178 return Res.takeError();
193 unsigned NumElts = MaybeNum.
get();
228 return error(
"Size is not plausible");
229 Vals.
reserve(Vals.size() + NumElts);
231 for (
unsigned i = 0;
i != NumElts; ++
i)
233 Vals.push_back(MaybeVal.get());
235 return MaybeVal.takeError();
253 return error(
"Abbreviation starts with an Array or a Blob");
255 Code = MaybeCode.get();
257 return MaybeCode.takeError();
262 if (
Op.isLiteral()) {
263 Vals.push_back(
Op.getLiteralValue());
270 Vals.push_back(MaybeVal.get());
272 return MaybeVal.takeError();
285 return error(
"Size is not plausible");
286 Vals.
reserve(Vals.size() + NumElts);
290 return error(
"Array op not second to last");
294 "Array element type has to be an encoding of a type");
299 return error(
"Array element type can't be an Array or a Blob");
301 for (; NumElts; --NumElts)
304 Vals.push_back(MaybeVal.get());
306 return MaybeVal.takeError();
309 for (; NumElts; --NumElts)
312 Vals.push_back(MaybeVal.get());
314 return MaybeVal.takeError();
317 for (; NumElts; --NumElts)
321 return MaybeVal.takeError();
336 const size_t NewEnd = CurBitPos +
alignTo(NumElts, 4) * 8;
340 return error(
"Blob ends too soon");
354 auto *UPtr =
reinterpret_cast<const unsigned char *
>(Ptr);
355 Vals.
append(UPtr, UPtr + NumElts);
363 auto Abbv = std::make_shared<BitCodeAbbrev>();
367 unsigned NumOpInfo = MaybeNumOpInfo.
get();
368 for (
unsigned i = 0;
i != NumOpInfo; ++
i) {
372 bool IsLiteral = MaybeIsLiteral.
get();
385 return error(
"Invalid encoding");
406 return error(
"Fixed or VBR abbrev record with size > MaxChunkData");
413 if (Abbv->getNumOperandInfos() == 0)
414 return error(
"Abbrev record with no operands");
438 switch (Entry.Kind) {
451 if (!CurBlockInfo)
return None;
458 CurAbbrevs.pop_back();
467 switch (MaybeBlockInfo.
get()) {
478 if (!ReadBlockInfoNames)
484 if (!CurBlockInfo)
return None;
485 if (!ReadBlockInfoNames)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
unsigned getNumOperandInfos() const
static Expected< uint64_t > readAbbreviatedField(BitstreamCursor &Cursor, const BitCodeAbbrevOp &Op)
This is an optimization pass for GlobalISel generic memory operations.
Expected< uint64_t > ReadVBR64(const unsigned NumBits)
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.
@ DEFINE_ABBREV
DEFINE_ABBREV - Defines an abbrev for the current block.
static ErrorSuccess success()
Create a success value.
const uint8_t * getPointerToBit(uint64_t BitNo, uint64_t NumBytes)
Get a pointer into the bitstream at the specified bit offset.
Error JumpToBit(uint64_t BitNo)
Reset the stream to the specified bit number.
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.
@ BLOCKINFO_BLOCK_ID
BLOCKINFO_BLOCK is used to define metadata about blocks, for example, standard abbrevs that should be...
std::vector< std::pair< unsigned, std::string > > RecordNames
Tagged union holding either a T or a Error.
@ AF_DontAutoprocessAbbrevs
If this flag is used, abbrev entries are returned just like normal records.
bool hasEncodingData() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
@ BLOCKINFO_CODE_SETRECORDNAME
Expected< uint32_t > ReadVBR(const unsigned NumBits)
Analysis containing CSE Info
Error EnterSubBlock(unsigned BlockID, unsigned *NumWordsP=nullptr)
Having read the ENTER_SUBBLOCK abbrevid, and enter the block.
Expected< uint64_t > ReadVBR64(const unsigned NumBits)
Encoding getEncoding() const
Expected< word_t > Read(unsigned NumBits)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
BlockInfo & getOrCreateBlockInfo(unsigned BlockID)
This contains information emitted to BLOCKINFO_BLOCK blocks.
Expected< BitstreamEntry > advanceSkippingSubblocks(unsigned Flags=0)
This is a convenience function for clients that don't expect any subblocks.
Expected< word_t > Read(unsigned NumBits)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const size_t MaxChunkSize
Expected< Optional< BitstreamBlockInfo > > ReadBlockInfoBlock(bool ReadBlockInfoNames=false)
Read and return a block info block from the bitstream.
uint64_t getEncodingData() const
static bool isValidEncoding(uint64_t E)
Expected< unsigned > readRecord(unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr)
std::vector< std::shared_ptr< BitCodeAbbrev > > Abbrevs
@ BLOCKINFO_CODE_BLOCKNAME
const BitCodeAbbrevOp & getOperandInfo(unsigned N) const
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.
reference get()
Returns a reference to the stored T value.
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void swap(SmallVectorImpl &RHS)
When advancing through a bitstream cursor, each advance can discover a few different kinds of entries...
uint64_t getLiteralValue() const
const char * toString(DWARFSectionKind Kind)
Lightweight error class with error context and mandatory checking.
bool isSizePlausible(size_t Size) const
Check whether a reservation of Size elements is plausible.
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
Error takeError()
Take ownership of the stored error.
BitCodeAbbrev - This class represents an abbreviation record.
void SkipToFourByteBoundary()
uint64_t GetCurrentBitNo() const
Return the bit # of the bit we are reading.
Expected< unsigned > skipRecord(unsigned AbbrevID)
Read the current record and discard it, returning the code for the record.
static Error error(const char *Message)
void reserve(size_type N)
bool canSkipToPos(size_t pos) const
void skipToEnd()
Skip to the end of the file.
static char DecodeChar6(unsigned V)
Expected< const BitCodeAbbrev * > getAbbrev(unsigned AbbrevID)
Return the abbreviation for the specified AbbrevId.