mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-19 04:29:21 +00:00
use a template to eliminate manual code duplication
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36757 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4222d806fa
commit
8d42fc3da2
@ -217,7 +217,8 @@ public:
|
|||||||
|
|
||||||
/// EmitRecord - Emit the specified record to the stream, using an abbrev if
|
/// EmitRecord - Emit the specified record to the stream, using an abbrev if
|
||||||
/// we have one to compress the output.
|
/// we have one to compress the output.
|
||||||
void EmitRecord(unsigned Code, SmallVectorImpl<uint64_t> &Vals,
|
template<typename uintty>
|
||||||
|
void EmitRecord(unsigned Code, SmallVectorImpl<uintty> &Vals,
|
||||||
unsigned Abbrev = 0) {
|
unsigned Abbrev = 0) {
|
||||||
if (Abbrev) {
|
if (Abbrev) {
|
||||||
unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV;
|
unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV;
|
||||||
@ -261,52 +262,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EmitRecord - Emit the specified record to the stream, using an abbrev if
|
|
||||||
/// we have one to compress the output.
|
|
||||||
void EmitRecord(unsigned Code, SmallVectorImpl<unsigned> &Vals,
|
|
||||||
unsigned Abbrev = 0) {
|
|
||||||
if (Abbrev) {
|
|
||||||
unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV;
|
|
||||||
assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!");
|
|
||||||
BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo];
|
|
||||||
|
|
||||||
EmitCode(Abbrev);
|
|
||||||
|
|
||||||
// Insert the code into Vals to treat it uniformly.
|
|
||||||
Vals.insert(Vals.begin(), Code);
|
|
||||||
|
|
||||||
unsigned RecordIdx = 0;
|
|
||||||
for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {
|
|
||||||
assert(RecordIdx < Vals.size() && "Invalid abbrev/record");
|
|
||||||
const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);
|
|
||||||
|
|
||||||
if (Op.isLiteral() || Op.getEncoding() != BitCodeAbbrevOp::Array) {
|
|
||||||
EmitAbbreviatedField(Op, Vals[RecordIdx]);
|
|
||||||
++RecordIdx;
|
|
||||||
} else {
|
|
||||||
assert(i+2 == e && "array op not second to last?");
|
|
||||||
const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i);
|
|
||||||
|
|
||||||
// Emit a vbr6 to indicate the number of elements present.
|
|
||||||
EmitVBR(Vals.size()-RecordIdx, 6);
|
|
||||||
|
|
||||||
// Emit each field.
|
|
||||||
for (; RecordIdx != Vals.size(); ++RecordIdx)
|
|
||||||
EmitAbbreviatedField(EltEnc, Vals[RecordIdx]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert(RecordIdx == Vals.size() && "Not all record operands emitted!");
|
|
||||||
} else {
|
|
||||||
// If we don't have an abbrev to use, emit this in its fully unabbreviated
|
|
||||||
// form.
|
|
||||||
EmitCode(bitc::UNABBREV_RECORD);
|
|
||||||
EmitVBR(Code, 6);
|
|
||||||
EmitVBR(Vals.size(), 6);
|
|
||||||
for (unsigned i = 0, e = Vals.size(); i != e; ++i)
|
|
||||||
EmitVBR(Vals[i], 6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Abbrev Emission
|
// Abbrev Emission
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
Loading…
Reference in New Issue
Block a user