[llvm-commits] [llvm] r43852 - in /llvm/trunk/include/llvm/Bitcode: Deserialize.h Serialize.h
Ted Kremenek
kremenek at apple.com
Wed Nov 7 15:18:40 PST 2007
Author: kremenek
Date: Wed Nov 7 17:18:40 2007
New Revision: 43852
URL: http://llvm.org/viewvc/llvm-project?rev=43852&view=rev
Log:
Added version of BatchEmitOwnedPtrs and BatchReadOwnedPtrs that emits/reads
an array of pointers of the same type.
Modified:
llvm/trunk/include/llvm/Bitcode/Deserialize.h
llvm/trunk/include/llvm/Bitcode/Serialize.h
Modified: llvm/trunk/include/llvm/Bitcode/Deserialize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Deserialize.h?rev=43852&r1=43851&r2=43852&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Deserialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Deserialize.h Wed Nov 7 17:18:40 2007
@@ -166,6 +166,18 @@
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>
Modified: llvm/trunk/include/llvm/Bitcode/Serialize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/Serialize.h?rev=43852&r1=43851&r2=43852&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/Serialize.h (original)
+++ llvm/trunk/include/llvm/Bitcode/Serialize.h Wed Nov 7 17:18:40 2007
@@ -85,6 +85,15 @@
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);
More information about the llvm-commits
mailing list