diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-11-07 23:18:40 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-11-07 23:18:40 +0000 |
commit | 441e88542f94d9916fa8f83ad50f1822340af72b (patch) | |
tree | 40b9661e7e07b83e8a35ec3bb80d733ea89ce46f | |
parent | bf54b245c6ebd236d1e332252c17412ad90667f4 (diff) | |
download | external_llvm-441e88542f94d9916fa8f83ad50f1822340af72b.zip external_llvm-441e88542f94d9916fa8f83ad50f1822340af72b.tar.gz external_llvm-441e88542f94d9916fa8f83ad50f1822340af72b.tar.bz2 |
Added version of BatchEmitOwnedPtrs and BatchReadOwnedPtrs that emits/reads
an array of pointers of the same type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43852 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Bitcode/Deserialize.h | 12 | ||||
-rw-r--r-- | include/llvm/Bitcode/Serialize.h | 9 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/llvm/Bitcode/Deserialize.h b/include/llvm/Bitcode/Deserialize.h index e77c6c9..5f8e137 100644 --- a/include/llvm/Bitcode/Deserialize.h +++ b/include/llvm/Bitcode/Deserialize.h @@ -166,6 +166,18 @@ public: P3 = (ID3) ? SerializeTrait<T2>::Materialize(*this) : NULL; if (ID3 && A3) RegisterPtr(ID3,P3); } + + template <typename T> + void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs) { + llvm::SmallVector<unsigned,20> PtrIDs; + PtrIDs.reserve(NumPtrs); + + for (unsigned i = 0; i < NumPtrs; ++i) + PtrIDs.push_back(ReadInt()); + + for (unsigned i = 0; i < NumPtrs; ++i) + Ptrs[i] = PtrIDs[i] ? SerializeTrait<T>::Materialize(*this) : NULL; + } template <typename T> diff --git a/include/llvm/Bitcode/Serialize.h b/include/llvm/Bitcode/Serialize.h index b92d49a..24e9f60 100644 --- a/include/llvm/Bitcode/Serialize.h +++ b/include/llvm/Bitcode/Serialize.h @@ -85,6 +85,15 @@ public: if (p4) SerializeTrait<T4>::Emit(*this,*p4); } + template <typename T> + void BatchEmitOwnedPtrs(unsigned NumPtrs, T** Ptrs) { + for (unsigned i = 0; i < NumPtrs; ++i) + EmitPtr(Ptrs[i]); + + for (unsigned i = 0; i < NumPtrs; ++i) + if (Ptrs[i]) SerializeTrait<T>::Emit(*this,Ptrs[i]); + } + void FlushRecord() { if (inRecord()) EmitRecord(); } void EnterBlock(unsigned BlockID = 8, unsigned CodeLen = 3); |