X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FBitcode%2FDeserialize.h;h=8c9ea89d15225817f73fd14b3bbeee0262be7262;hb=5eca075b74d62c621b160aa216b4cd50829a2cc7;hp=ef25da71409e24f4fb3280f4a00ed126f2633c36;hpb=07cad1c6ceebd108db87309814c8dc47041c58c3;p=oota-llvm.git diff --git a/include/llvm/Bitcode/Deserialize.h b/include/llvm/Bitcode/Deserialize.h index ef25da71409..8c9ea89d152 100644 --- a/include/llvm/Bitcode/Deserialize.h +++ b/include/llvm/Bitcode/Deserialize.h @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Ted Kremenek and is distributed under the -// University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -125,7 +125,7 @@ private: llvm::SmallVector BlockStack; unsigned AbbrevNo; unsigned RecordCode; - Location StreamStart; + uint64_t StreamStart; //===----------------------------------------------------------===// // Public Interface. @@ -137,13 +137,7 @@ public: uint64_t ReadInt(); int64_t ReadSInt(); - SerializedPtrID ReadPtrID() { return (SerializedPtrID) ReadInt(); } - - SerializedPtrID ReadDiffPtrID(SerializedPtrID& PrevID) { - bool x = ReadBool(); - return (SerializedPtrID) (x ? (PrevID+1) : 0); - } bool ReadBool() { @@ -162,7 +156,7 @@ public: } char* ReadCStr(char* cstr = NULL, unsigned MaxLen=0, bool isNullTerm=true); - void ReadCStr(std::vector& buff, bool isNullTerm=false); + void ReadCStr(std::vector& buff, bool isNullTerm=false, unsigned Idx=0); template inline T* ReadOwnedPtr(bool AutoRegister = true) { @@ -178,7 +172,22 @@ public: return x; } - + + template + inline T* ReadOwnedPtr(Arg1& arg1, bool AutoRegister = true) { + SerializedPtrID PtrID = ReadPtrID(); + + if (!PtrID) + return NULL; + + T* x = SerializeTrait::Create(*this, arg1); + + if (AutoRegister) + RegisterPtr(PtrID,x); + + return x; + } + template inline void ReadOwnedPtr(T*& Ptr, bool AutoRegister = true) { Ptr = ReadOwnedPtr(AutoRegister); @@ -189,7 +198,7 @@ public: bool A1=true, bool A2=true) { SerializedPtrID ID1 = ReadPtrID(); - SerializedPtrID ID2 = ReadDiffPtrID(ID2); + SerializedPtrID ID2 = ReadPtrID(); P1 = (ID1) ? SerializeTrait::Create(*this) : NULL; if (ID1 && A1) RegisterPtr(ID1,P1); @@ -198,13 +207,27 @@ public: if (ID2 && A2) RegisterPtr(ID2,P2); } + template + void BatchReadOwnedPtrs(T1*& P1, T2*& P2, Arg1& arg1, + bool A1=true, bool A2=true) { + + SerializedPtrID ID1 = ReadPtrID(); + SerializedPtrID ID2 = ReadPtrID(); + + P1 = (ID1) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID1 && A1) RegisterPtr(ID1,P1); + + P2 = (ID2) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + } + template void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3, bool A1=true, bool A2=true, bool A3=true) { SerializedPtrID ID1 = ReadPtrID(); - SerializedPtrID ID2 = ReadDiffPtrID(ID1); - SerializedPtrID ID3 = ReadDiffPtrID(ID2); + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); P1 = (ID1) ? SerializeTrait::Create(*this) : NULL; if (ID1 && A1) RegisterPtr(ID1,P1); @@ -215,38 +238,31 @@ public: P3 = (ID3) ? SerializeTrait::Create(*this) : NULL; if (ID3 && A3) RegisterPtr(ID3,P3); } - - template - void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3, T4*& P4, - bool A1=true, bool A2=true, bool A3=true, bool A4=true) { - + + template + void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3, Arg1& arg1, + bool A1=true, bool A2=true, bool A3=true) { + SerializedPtrID ID1 = ReadPtrID(); - SerializedPtrID ID2 = ReadDiffPtrID(ID1); - SerializedPtrID ID3 = ReadDiffPtrID(ID2); - SerializedPtrID ID4 = ReadDiffPtrID(ID3); - - P1 = (ID1) ? SerializeTrait::Create(*this) : NULL; - if (ID1 && A1) RegisterPtr(ID1,P1); - - P2 = (ID2) ? SerializeTrait::Create(*this) : NULL; + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); + + P1 = (ID1) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID1 && A1) RegisterPtr(ID1,P1); + + P2 = (ID2) ? SerializeTrait::Create(*this, arg1) : NULL; if (ID2 && A2) RegisterPtr(ID2,P2); - - P3 = (ID3) ? SerializeTrait::Create(*this) : NULL; + + P3 = (ID3) ? SerializeTrait::Create(*this, arg1) : NULL; if (ID3 && A3) RegisterPtr(ID3,P3); - - P4 = (ID4) ? SerializeTrait::Create(*this) : NULL; - if (ID4 && A4) RegisterPtr(ID4,P4); } - + template void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, bool AutoRegister=true) { llvm::SmallVector BatchIDVec; - SerializedPtrID TempPtrID; - for (unsigned i = 0; i < NumPtrs; ++i) { - TempPtrID = i ? ReadDiffPtrID(TempPtrID) : ReadPtrID(); - BatchIDVec.push_back(TempPtrID); - } + for (unsigned i = 0; i < NumPtrs; ++i) + BatchIDVec.push_back(ReadPtrID()); for (unsigned i = 0; i < NumPtrs; ++i) { SerializedPtrID& PtrID = BatchIDVec[i]; @@ -260,22 +276,37 @@ public: } } + template + void BatchReadOwnedPtrs(unsigned NumPtrs, T** Ptrs, Arg1& arg1, + bool AutoRegister=true) { + + llvm::SmallVector 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::Create(*this, arg1) : NULL; + + if (PtrID && AutoRegister) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + } + template void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, bool A1=true, bool A2=true) { - - SerializedPtrID ID2 = ReadPtrID(); - SerializedPtrID TempID = ID2; - - llvm::SmallVector BatchIDVec; - for (unsigned i = 0; i < NumT1Ptrs; ++i) { - TempID = ReadDiffPtrID(TempID); - BatchIDVec.push_back(TempID); - } + llvm::SmallVector BatchIDVec; + + for (unsigned i = 0; i < NumT1Ptrs; ++i) + BatchIDVec.push_back(ReadPtrID()); - P2 = (ID2) ? SerializeTrait::Create(*this) : NULL; - if (ID2 && A2) RegisterPtr(ID2,P2); + SerializedPtrID ID2 = ReadPtrID(); for (unsigned i = 0; i < NumT1Ptrs; ++i) { SerializedPtrID& PtrID = BatchIDVec[i]; @@ -286,31 +317,50 @@ public: RegisterPtr(PtrID,p); Ptrs[i] = p; - } + } + + P2 = (ID2) ? SerializeTrait::Create(*this) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); } + template + void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, Arg1& arg1, + bool A1=true, bool A2=true) { + + llvm::SmallVector 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::Create(*this, arg1) : NULL; + + if (PtrID && A1) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + + P2 = (ID2) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + } + template void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, T2*& P2, T3*& P3, bool A1=true, bool A2=true, bool A3=true) { - - SerializedPtrID ID2 = ReadPtrID(); - SerializedPtrID ID3 = ReadDiffPtrID(ID2); - - SerializedPtrID TempID = ID3; llvm::SmallVector BatchIDVec; - for (unsigned i = 0; i < NumT1Ptrs; ++i) { - TempID = ReadDiffPtrID(TempID); - BatchIDVec.push_back(TempID); - } + for (unsigned i = 0; i < NumT1Ptrs; ++i) + BatchIDVec.push_back(ReadPtrID()); - P2 = (ID2) ? SerializeTrait::Create(*this) : NULL; - if (ID2 && A2) RegisterPtr(ID2,P2); - - P3 = (ID3) ? SerializeTrait::Create(*this) : NULL; - if (ID3 && A3) RegisterPtr(ID3,P3); + SerializedPtrID ID2 = ReadPtrID(); + SerializedPtrID ID3 = ReadPtrID(); for (unsigned i = 0; i < NumT1Ptrs; ++i) { SerializedPtrID& PtrID = BatchIDVec[i]; @@ -322,8 +372,45 @@ public: Ptrs[i] = p; } + + P2 = (ID2) ? SerializeTrait::Create(*this) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + + P3 = (ID3) ? SerializeTrait::Create(*this) : NULL; + if (ID3 && A3) RegisterPtr(ID3,P3); } - + + template + void BatchReadOwnedPtrs(unsigned NumT1Ptrs, T1** Ptrs, + T2*& P2, T3*& P3, Arg1& arg1, + bool A1=true, bool A2=true, bool A3=true) { + + llvm::SmallVector 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::Create(*this, arg1) : NULL; + + if (PtrID && A1) + RegisterPtr(PtrID,p); + + Ptrs[i] = p; + } + + P2 = (ID2) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID2 && A2) RegisterPtr(ID2,P2); + + P3 = (ID3) ? SerializeTrait::Create(*this, arg1) : NULL; + if (ID3 && A3) RegisterPtr(ID3,P3); + } + template void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) { ReadUIntPtr(reinterpret_cast(PtrRef), AllowBackpatch); @@ -349,7 +436,7 @@ public: } template - T* ReadPtr() { T* x; ReadPtr(x,false); return x; } + T* ReadPtr() { T* x = 0; ReadPtr(x,false); return x; } void ReadUIntPtr(uintptr_t& PtrRef, const SerializedPtrID& PtrID, bool AllowBackpatch = true); @@ -386,7 +473,7 @@ public: bool FinishedBlock(Location BlockLoc); bool JumpTo(const Location& BlockLoc); - void Rewind() { JumpTo(StreamStart); } + void Rewind(); bool AtEnd(); bool inRecord();