mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-21 16:24:47 +00:00
refcount BitCodeAbbrev objects
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36747 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f0799fe155
commit
299b2d2070
@ -58,9 +58,9 @@ namespace bitc {
|
|||||||
/// 2. It could be an encoding specification ("this operand encoded like so").
|
/// 2. It could be an encoding specification ("this operand encoded like so").
|
||||||
///
|
///
|
||||||
class BitCodeAbbrevOp {
|
class BitCodeAbbrevOp {
|
||||||
uint64_t Val; // A literal value or data for an encoding.
|
uint64_t Val; // A literal value or data for an encoding.
|
||||||
bool IsLiteral : 1; // Indicate whether this is a literal value or not.
|
bool IsLiteral : 1; // Indicate whether this is a literal value or not.
|
||||||
unsigned Enc : 3; // The encoding to use.
|
unsigned Enc : 3; // The encoding to use.
|
||||||
public:
|
public:
|
||||||
enum Encoding {
|
enum Encoding {
|
||||||
FixedWidth = 1, // A fixed with field, Val specifies number of bits.
|
FixedWidth = 1, // A fixed with field, Val specifies number of bits.
|
||||||
@ -89,8 +89,14 @@ public:
|
|||||||
|
|
||||||
class BitCodeAbbrev {
|
class BitCodeAbbrev {
|
||||||
SmallVector<BitCodeAbbrevOp, 8> OperandList;
|
SmallVector<BitCodeAbbrevOp, 8> OperandList;
|
||||||
|
unsigned char RefCount; // Number of things using this.
|
||||||
|
~BitCodeAbbrev() {}
|
||||||
public:
|
public:
|
||||||
|
BitCodeAbbrev() : RefCount(1) {}
|
||||||
|
|
||||||
|
void addRef() { ++RefCount; }
|
||||||
|
void dropRef() { if (--RefCount == 0) delete this; }
|
||||||
|
|
||||||
unsigned getNumOperandInfos() const { return OperandList.size(); }
|
unsigned getNumOperandInfos() const { return OperandList.size(); }
|
||||||
const BitCodeAbbrevOp &getOperandInfo(unsigned N) const {
|
const BitCodeAbbrevOp &getOperandInfo(unsigned N) const {
|
||||||
return OperandList[N];
|
return OperandList[N];
|
||||||
|
@ -75,12 +75,12 @@ public:
|
|||||||
// Abbrevs could still exist if the stream was broken. If so, don't leak
|
// Abbrevs could still exist if the stream was broken. If so, don't leak
|
||||||
// them.
|
// them.
|
||||||
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
||||||
delete CurAbbrevs[i];
|
CurAbbrevs[i]->dropRef();
|
||||||
|
|
||||||
for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) {
|
for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) {
|
||||||
std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;
|
std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;
|
||||||
for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i)
|
for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i)
|
||||||
delete Abbrevs[i];
|
Abbrevs[i]->dropRef();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ public:
|
|||||||
|
|
||||||
// Delete abbrevs from popped scope.
|
// Delete abbrevs from popped scope.
|
||||||
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
||||||
delete CurAbbrevs[i];
|
CurAbbrevs[i]->dropRef();
|
||||||
|
|
||||||
BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);
|
BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);
|
||||||
BlockScope.pop_back();
|
BlockScope.pop_back();
|
||||||
|
@ -160,7 +160,7 @@ public:
|
|||||||
|
|
||||||
// Delete all abbrevs.
|
// Delete all abbrevs.
|
||||||
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
||||||
delete CurAbbrevs[i];
|
CurAbbrevs[i]->dropRef();
|
||||||
|
|
||||||
const Block &B = BlockScope.back();
|
const Block &B = BlockScope.back();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user