diff options
author | Sam Bishop <sam@bishop.dhs.org> | 2008-04-07 21:36:46 +0000 |
---|---|---|
committer | Sam Bishop <sam@bishop.dhs.org> | 2008-04-07 21:36:46 +0000 |
commit | b7091432f8cace3d3cf2ea3cfbc2139f54ea7f00 (patch) | |
tree | e65b463b7b95f206b5021f65f1c414397cb045da | |
parent | 1fad9e6ca2c608b4cd09275e3c302ebc18ebc33a (diff) | |
download | external_llvm-b7091432f8cace3d3cf2ea3cfbc2139f54ea7f00.zip external_llvm-b7091432f8cace3d3cf2ea3cfbc2139f54ea7f00.tar.gz external_llvm-b7091432f8cace3d3cf2ea3cfbc2139f54ea7f00.tar.bz2 |
Added support for Create() calls that take an argument besides the
deserializer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49350 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Bitcode/Deserialize.h | 131 |
1 files changed, 128 insertions, 3 deletions
diff --git a/include/llvm/Bitcode/Deserialize.h b/include/llvm/Bitcode/Deserialize.h index 49389a8..6e20434 100644 --- a/include/llvm/Bitcode/Deserialize.h +++ b/include/llvm/Bitcode/Deserialize.h @@ -172,7 +172,22 @@ public: return x; } - + + template <typename T, typename Arg1> + inline T* ReadOwnedPtr(Arg1& arg1, bool AutoRegister = true) { + SerializedPtrID PtrID = ReadPtrID(); + + if (!PtrID) + return NULL; + + T* x = SerializeTrait<T>::Create(*this, arg1); + + if (AutoRegister) + RegisterPtr(PtrID,x); + + return x; + } + template <typename T> inline void ReadOwnedPtr(T*& Ptr, bool AutoRegister = true) { Ptr = ReadOwnedPtr<T>(AutoRegister); @@ -192,6 +207,20 @@ public: if (ID2 && A2) RegisterPtr(ID2,P2); } + template <typename T1, typename T2, typename Arg1> + void BatchReadOwnedPtrs(T1*& P1, T2*& P2, Arg1& arg1, + bool A1=true, bool A2=true) { + + SerializedPtrID ID1 = ReadPtrID(); + SerializedPtrID ID2 = ReadPtrID(); + + P1 = (ID1) ? SerializeTrait<T1>::Create(*this, arg1) : NULL; + if (ID1 && A1) RegisterPtr(ID1,P1); + + P2 = (ID2) ? SerializeTrait<T2>::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + } + template <typename T1, typename T2, typename T3> void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3, bool A1=true, bool A2=true, bool A3=true) { @@ -209,7 +238,25 @@ public: P3 = (ID3) ? SerializeTrait<T3>::Create(*this) : NULL; if (ID3 && A3) RegisterPtr(ID3,P3); } - + + template <typename T1, typename T2, typename T3, typename Arg1> + void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3, Arg1& arg1, + bool A1=true, bool A2=true, bool A3=true) { + + SerializedPtrID ID1 = ReadPtrID(); + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); + + P1 = (ID1) ? SerializeTrait<T1>::Create(*this, arg1) : NULL; + if (ID1 && A1) RegisterPtr(ID1,P1); + + P2 = (ID2) ? SerializeTrait<T2>::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + + P3 = (ID3) ? SerializeTrait<T3>::Create(*this, arg1) : NULL; + if (ID3 && A3) RegisterPtr(ID3,P3); + } + template <typename T> void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) { llvm::SmallVector<SerializedPtrID,10> BatchIDVec; @@ -229,6 +276,27 @@ public: } } + template <typename T, typename Arg1> + void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, Arg1& arg1, + bool AutoRegister=true) { + + llvm::SmallVector<SerializedPtrID,10> BatchIDVec; + + for (unsigned i = 0; i < NumPtrs; ++i) + BatchIDVec.push_back(ReadPtrID()); + + for (unsigned i = 0; i < NumPtrs; ++i) { + SerializedPtrID& PtrID = BatchIDVec[i]; + + T* p = PtrID ? SerializeTrait<T>::Create(*this, arg1) : NULL; + + if (PtrID && AutoRegister) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + } + template <typename T1, typename T2> void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, bool A1=true, bool A2=true) { @@ -255,6 +323,32 @@ public: if (ID2 && A2) RegisterPtr(ID2,P2); } + template <typename T1, typename T2, typename Arg1> + void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, Arg1& arg1, + bool A1=true, bool A2=true) { + + llvm::SmallVector<SerializedPtrID,10> BatchIDVec; + + for (unsigned i = 0; i < NumT1Ptrs; ++i) + BatchIDVec.push_back(ReadPtrID()); + + SerializedPtrID ID2 = ReadPtrID(); + + for (unsigned i = 0; i < NumT1Ptrs; ++i) { + SerializedPtrID& PtrID = BatchIDVec[i]; + + T1* p = PtrID ? SerializeTrait<T1>::Create(*this, arg1) : NULL; + + if (PtrID && A1) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + + P2 = (ID2) ? SerializeTrait<T2>::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + } + template <typename T1, typename T2, typename T3> void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, T3*& P3, @@ -285,7 +379,38 @@ public: P3 = (ID3) ? SerializeTrait<T3>::Create(*this) : NULL; if (ID3 && A3) RegisterPtr(ID3,P3); } - + + template <typename T1, typename T2, typename T3, typename Arg1> + void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, + T2*& P2, T3*& P3, Arg1& arg1, + bool A1=true, bool A2=true, bool A3=true) { + + llvm::SmallVector<SerializedPtrID,10> BatchIDVec; + + for (unsigned i = 0; i < NumT1Ptrs; ++i) + BatchIDVec.push_back(ReadPtrID()); + + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); + + for (unsigned i = 0; i < NumT1Ptrs; ++i) { + SerializedPtrID& PtrID = BatchIDVec[i]; + + T1* p = PtrID ? SerializeTrait<T1>::Create(*this, arg1) : NULL; + + if (PtrID && A1) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + + P2 = (ID2) ? SerializeTrait<T2>::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + + P3 = (ID3) ? SerializeTrait<T3>::Create(*this, arg1) : NULL; + if (ID3 && A3) RegisterPtr(ID3,P3); + } + template <typename T> void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) { ReadUIntPtr(reinterpret_cast<uintptr_t&>(PtrRef), AllowBackpatch); |