mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
move some private methods out of line, add a skipRecord() method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172931 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -488,31 +488,12 @@ private:
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReadAbbreviatedLiteral(const BitCodeAbbrevOp &Op,
|
void readAbbreviatedLiteral(const BitCodeAbbrevOp &Op,
|
||||||
SmallVectorImpl<uint64_t> &Vals) {
|
SmallVectorImpl<uint64_t> &Vals);
|
||||||
assert(Op.isLiteral() && "Not a literal");
|
void readAbbreviatedField(const BitCodeAbbrevOp &Op,
|
||||||
// If the abbrev specifies the literal value to use, use it.
|
SmallVectorImpl<uint64_t> &Vals);
|
||||||
Vals.push_back(Op.getLiteralValue());
|
void skipAbbreviatedField(const BitCodeAbbrevOp &Op);
|
||||||
}
|
|
||||||
|
|
||||||
void ReadAbbreviatedField(const BitCodeAbbrevOp &Op,
|
|
||||||
SmallVectorImpl<uint64_t> &Vals) {
|
|
||||||
assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!");
|
|
||||||
|
|
||||||
// Decode the value as we are commanded.
|
|
||||||
switch (Op.getEncoding()) {
|
|
||||||
default: llvm_unreachable("Unknown encoding!");
|
|
||||||
case BitCodeAbbrevOp::Fixed:
|
|
||||||
Vals.push_back(Read((unsigned)Op.getEncodingData()));
|
|
||||||
break;
|
|
||||||
case BitCodeAbbrevOp::VBR:
|
|
||||||
Vals.push_back(ReadVBR64((unsigned)Op.getEncodingData()));
|
|
||||||
break;
|
|
||||||
case BitCodeAbbrevOp::Char6:
|
|
||||||
Vals.push_back(BitCodeAbbrevOp::DecodeChar6(Read(6)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// getAbbrev - Return the abbreviation for the specified AbbrevId.
|
/// getAbbrev - Return the abbreviation for the specified AbbrevId.
|
||||||
@@ -522,6 +503,9 @@ public:
|
|||||||
return CurAbbrevs[AbbrevNo];
|
return CurAbbrevs[AbbrevNo];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// skipRecord - Read the current record and discard it.
|
||||||
|
void skipRecord(unsigned AbbrevID);
|
||||||
|
|
||||||
unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
|
unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
|
||||||
const char **BlobStart = 0, unsigned *BlobLen = 0);
|
const char **BlobStart = 0, unsigned *BlobLen = 0);
|
||||||
|
|
||||||
@@ -530,7 +514,6 @@ public:
|
|||||||
return ReadRecord(AbbrevID, Vals, &BlobStart, &BlobLen);
|
return ReadRecord(AbbrevID, Vals, &BlobStart, &BlobLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Abbrev Processing
|
// Abbrev Processing
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
@@ -89,6 +89,114 @@ bool BitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BitstreamCursor::readAbbreviatedLiteral(const BitCodeAbbrevOp &Op,
|
||||||
|
SmallVectorImpl<uint64_t> &Vals) {
|
||||||
|
assert(Op.isLiteral() && "Not a literal");
|
||||||
|
// If the abbrev specifies the literal value to use, use it.
|
||||||
|
Vals.push_back(Op.getLiteralValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitstreamCursor::readAbbreviatedField(const BitCodeAbbrevOp &Op,
|
||||||
|
SmallVectorImpl<uint64_t> &Vals) {
|
||||||
|
assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!");
|
||||||
|
|
||||||
|
// Decode the value as we are commanded.
|
||||||
|
switch (Op.getEncoding()) {
|
||||||
|
case BitCodeAbbrevOp::Array:
|
||||||
|
case BitCodeAbbrevOp::Blob:
|
||||||
|
assert(0 && "Should not reach here");
|
||||||
|
case BitCodeAbbrevOp::Fixed:
|
||||||
|
Vals.push_back(Read((unsigned)Op.getEncodingData()));
|
||||||
|
break;
|
||||||
|
case BitCodeAbbrevOp::VBR:
|
||||||
|
Vals.push_back(ReadVBR64((unsigned)Op.getEncodingData()));
|
||||||
|
break;
|
||||||
|
case BitCodeAbbrevOp::Char6:
|
||||||
|
Vals.push_back(BitCodeAbbrevOp::DecodeChar6(Read(6)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitstreamCursor::skipAbbreviatedField(const BitCodeAbbrevOp &Op) {
|
||||||
|
assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!");
|
||||||
|
|
||||||
|
// Decode the value as we are commanded.
|
||||||
|
switch (Op.getEncoding()) {
|
||||||
|
case BitCodeAbbrevOp::Array:
|
||||||
|
case BitCodeAbbrevOp::Blob:
|
||||||
|
assert(0 && "Should not reach here");
|
||||||
|
case BitCodeAbbrevOp::Fixed:
|
||||||
|
(void)Read((unsigned)Op.getEncodingData());
|
||||||
|
break;
|
||||||
|
case BitCodeAbbrevOp::VBR:
|
||||||
|
(void)ReadVBR64((unsigned)Op.getEncodingData());
|
||||||
|
break;
|
||||||
|
case BitCodeAbbrevOp::Char6:
|
||||||
|
(void)Read(6);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// skipRecord - Read the current record and discard it.
|
||||||
|
void BitstreamCursor::skipRecord(unsigned AbbrevID) {
|
||||||
|
// Skip unabbreviated records by reading past their entries.
|
||||||
|
if (AbbrevID == bitc::UNABBREV_RECORD) {
|
||||||
|
unsigned Code = ReadVBR(6);
|
||||||
|
(void)Code;
|
||||||
|
unsigned NumElts = ReadVBR(6);
|
||||||
|
for (unsigned i = 0; i != NumElts; ++i)
|
||||||
|
(void)ReadVBR64(6);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID);
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {
|
||||||
|
const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);
|
||||||
|
if (Op.isLiteral())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Op.getEncoding() != BitCodeAbbrevOp::Array &&
|
||||||
|
Op.getEncoding() != BitCodeAbbrevOp::Blob) {
|
||||||
|
skipAbbreviatedField(Op);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Op.getEncoding() == BitCodeAbbrevOp::Array) {
|
||||||
|
// Array case. Read the number of elements as a vbr6.
|
||||||
|
unsigned NumElts = ReadVBR(6);
|
||||||
|
|
||||||
|
// Get the element encoding.
|
||||||
|
assert(i+2 == e && "array op not second to last?");
|
||||||
|
const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i);
|
||||||
|
|
||||||
|
// Read all the elements.
|
||||||
|
for (; NumElts; --NumElts)
|
||||||
|
skipAbbreviatedField(EltEnc);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(Op.getEncoding() == BitCodeAbbrevOp::Blob);
|
||||||
|
// Blob case. Read the number of bytes as a vbr6.
|
||||||
|
unsigned NumElts = ReadVBR(6);
|
||||||
|
SkipToWord(); // 32-bit alignment
|
||||||
|
|
||||||
|
// Figure out where the end of this blob will be including tail padding.
|
||||||
|
size_t NewEnd = NextChar+((NumElts+3)&~3);
|
||||||
|
|
||||||
|
// If this would read off the end of the bitcode file, just set the
|
||||||
|
// record to empty and return.
|
||||||
|
if (!canSkipToPos(NewEnd)) {
|
||||||
|
NextChar = BitStream->getBitcodeBytes().getExtent();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip over the blob.
|
||||||
|
NextChar = NewEnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned BitstreamCursor::ReadRecord(unsigned AbbrevID,
|
unsigned BitstreamCursor::ReadRecord(unsigned AbbrevID,
|
||||||
SmallVectorImpl<uint64_t> &Vals,
|
SmallVectorImpl<uint64_t> &Vals,
|
||||||
@@ -106,13 +214,13 @@ unsigned BitstreamCursor::ReadRecord(unsigned AbbrevID,
|
|||||||
for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {
|
for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {
|
||||||
const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);
|
const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);
|
||||||
if (Op.isLiteral()) {
|
if (Op.isLiteral()) {
|
||||||
ReadAbbreviatedLiteral(Op, Vals);
|
readAbbreviatedLiteral(Op, Vals);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Op.getEncoding() != BitCodeAbbrevOp::Array &&
|
if (Op.getEncoding() != BitCodeAbbrevOp::Array &&
|
||||||
Op.getEncoding() != BitCodeAbbrevOp::Blob) {
|
Op.getEncoding() != BitCodeAbbrevOp::Blob) {
|
||||||
ReadAbbreviatedField(Op, Vals);
|
readAbbreviatedField(Op, Vals);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +234,7 @@ unsigned BitstreamCursor::ReadRecord(unsigned AbbrevID,
|
|||||||
|
|
||||||
// Read all the elements.
|
// Read all the elements.
|
||||||
for (; NumElts; --NumElts)
|
for (; NumElts; --NumElts)
|
||||||
ReadAbbreviatedField(EltEnc, Vals);
|
readAbbreviatedField(EltEnc, Vals);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user