llvm.org GIT mirror llvm / 299b2d2
refcount BitCodeAbbrev objects git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36747 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
3 changed file(s) with 13 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
5757 /// 2. It could be an encoding specification ("this operand encoded like so").
5858 ///
5959 class BitCodeAbbrevOp {
60 uint64_t Val; // A literal value or data for an encoding.
61 bool IsLiteral : 1; // Indicate whether this is a literal value or not.
62 unsigned Enc : 3; // The encoding to use.
60 uint64_t Val; // A literal value or data for an encoding.
61 bool IsLiteral : 1; // Indicate whether this is a literal value or not.
62 unsigned Enc : 3; // The encoding to use.
6363 public:
6464 enum Encoding {
6565 FixedWidth = 1, // A fixed with field, Val specifies number of bits.
8888
8989 class BitCodeAbbrev {
9090 SmallVector OperandList;
91 unsigned char RefCount; // Number of things using this.
92 ~BitCodeAbbrev() {}
9193 public:
94 BitCodeAbbrev() : RefCount(1) {}
9295
96 void addRef() { ++RefCount; }
97 void dropRef() { if (--RefCount == 0) delete this; }
98
9399 unsigned getNumOperandInfos() const { return OperandList.size(); }
94100 const BitCodeAbbrevOp &getOperandInfo(unsigned N) const {
95101 return OperandList[N];
7474 // Abbrevs could still exist if the stream was broken. If so, don't leak
7575 // them.
7676 for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
77 delete CurAbbrevs[i];
77 CurAbbrevs[i]->dropRef();
7878
7979 for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) {
8080 std::vector &Abbrevs = BlockScope[S].PrevAbbrevs;
8181 for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i)
82 delete Abbrevs[i];
82 Abbrevs[i]->dropRef();
8383 }
8484 }
8585
262262
263263 // Delete abbrevs from popped scope.
264264 for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
265 delete CurAbbrevs[i];
265 CurAbbrevs[i]->dropRef();
266266
267267 BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);
268268 BlockScope.pop_back();
159159
160160 // Delete all abbrevs.
161161 for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
162 delete CurAbbrevs[i];
162 CurAbbrevs[i]->dropRef();
163163
164164 const Block &B = BlockScope.back();
165165