mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Move calls to push_back out of readAbbreviated(Literal|Field).
These functions always return a single value and not all callers want to push them into a SmallVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221934 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -50,40 +50,27 @@ bool BitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void readAbbreviatedLiteral(const BitCodeAbbrevOp &Op,
|
static uint64_t readAbbreviatedField(BitstreamCursor &Cursor,
|
||||||
SmallVectorImpl<uint64_t> &Vals) {
|
const BitCodeAbbrevOp &Op) {
|
||||||
assert(Op.isLiteral() && "Not a literal");
|
assert(!Op.isLiteral() && "Not to be used with literals!");
|
||||||
// If the abbrev specifies the literal value to use, use it.
|
|
||||||
Vals.push_back(Op.getLiteralValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void readAbbreviatedField(BitstreamCursor &Cursor,
|
|
||||||
const BitCodeAbbrevOp &Op,
|
|
||||||
SmallVectorImpl<uint64_t> &Vals) {
|
|
||||||
assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!");
|
|
||||||
|
|
||||||
// Decode the value as we are commanded.
|
// Decode the value as we are commanded.
|
||||||
uint64_t Val;
|
|
||||||
switch (Op.getEncoding()) {
|
switch (Op.getEncoding()) {
|
||||||
case BitCodeAbbrevOp::Array:
|
case BitCodeAbbrevOp::Array:
|
||||||
case BitCodeAbbrevOp::Blob:
|
case BitCodeAbbrevOp::Blob:
|
||||||
llvm_unreachable("Should not reach here");
|
llvm_unreachable("Should not reach here");
|
||||||
case BitCodeAbbrevOp::Fixed:
|
case BitCodeAbbrevOp::Fixed:
|
||||||
Val = Cursor.Read((unsigned)Op.getEncodingData());
|
return Cursor.Read((unsigned)Op.getEncodingData());
|
||||||
break;
|
|
||||||
case BitCodeAbbrevOp::VBR:
|
case BitCodeAbbrevOp::VBR:
|
||||||
Val = Cursor.ReadVBR64((unsigned)Op.getEncodingData());
|
return Cursor.ReadVBR64((unsigned)Op.getEncodingData());
|
||||||
break;
|
|
||||||
case BitCodeAbbrevOp::Char6:
|
case BitCodeAbbrevOp::Char6:
|
||||||
Val = BitCodeAbbrevOp::DecodeChar6(Cursor.Read(6));
|
return BitCodeAbbrevOp::DecodeChar6(Cursor.Read(6));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Vals.push_back(Val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void skipAbbreviatedField(BitstreamCursor &Cursor,
|
static void skipAbbreviatedField(BitstreamCursor &Cursor,
|
||||||
const BitCodeAbbrevOp &Op) {
|
const BitCodeAbbrevOp &Op) {
|
||||||
assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!");
|
assert(!Op.isLiteral() && "Not to be used with literals!");
|
||||||
|
|
||||||
// Decode the value as we are commanded.
|
// Decode the value as we are commanded.
|
||||||
switch (Op.getEncoding()) {
|
switch (Op.getEncoding()) {
|
||||||
@ -179,22 +166,22 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
|
|||||||
// Read the record code first.
|
// Read the record code first.
|
||||||
assert(Abbv->getNumOperandInfos() != 0 && "no record code in abbreviation?");
|
assert(Abbv->getNumOperandInfos() != 0 && "no record code in abbreviation?");
|
||||||
const BitCodeAbbrevOp &CodeOp = Abbv->getOperandInfo(0);
|
const BitCodeAbbrevOp &CodeOp = Abbv->getOperandInfo(0);
|
||||||
|
unsigned Code;
|
||||||
if (CodeOp.isLiteral())
|
if (CodeOp.isLiteral())
|
||||||
readAbbreviatedLiteral(CodeOp, Vals);
|
Code = CodeOp.getLiteralValue();
|
||||||
else
|
else
|
||||||
readAbbreviatedField(*this, CodeOp, Vals);
|
Code = readAbbreviatedField(*this, CodeOp);
|
||||||
unsigned Code = (unsigned)Vals.pop_back_val();
|
|
||||||
|
|
||||||
for (unsigned i = 1, e = Abbv->getNumOperandInfos(); i != e; ++i) {
|
for (unsigned i = 1, 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);
|
Vals.push_back(Op.getLiteralValue());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Op.getEncoding() != BitCodeAbbrevOp::Array &&
|
if (Op.getEncoding() != BitCodeAbbrevOp::Array &&
|
||||||
Op.getEncoding() != BitCodeAbbrevOp::Blob) {
|
Op.getEncoding() != BitCodeAbbrevOp::Blob) {
|
||||||
readAbbreviatedField(*this, Op, Vals);
|
Vals.push_back(readAbbreviatedField(*this, Op));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +195,7 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
|
|||||||
|
|
||||||
// Read all the elements.
|
// Read all the elements.
|
||||||
for (; NumElts; --NumElts)
|
for (; NumElts; --NumElts)
|
||||||
readAbbreviatedField(*this, EltEnc, Vals);
|
Vals.push_back(readAbbreviatedField(*this, EltEnc));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user