llvm.org GIT mirror llvm / 6d8ab4a
Added methods to batch emit and deserialize owned pointers. This allows to group the pointer IDs together in the bitstream before their referenced contents (which will lend itself to more efficient encoding). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43845 91177308-0d34-0410-b5e6-96231b3b80d8 Ted Kremenek 12 years ago
2 changed file(s) with 68 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
116116
117117 template
118118 inline T* ReadOwnedPtr(bool AutoRegister = true) {
119 unsigned PtrId = ReadInt();
120
121 if (PtrId == 0)
119 unsigned PtrID = ReadInt();
120
121 if (!PtrID)
122122 return NULL;
123123
124124 T* x = SerializeTrait::Materialize(*this);
125
125
126126 if (AutoRegister)
127 RegisterPtr(PtrId,x);
127 RegisterPtr(PtrID,x);
128128
129129 return x;
130130 }
133133 inline void ReadOwnedPtr(T*& Ptr, bool AutoRegister = true) {
134134 Ptr = ReadOwnedPtr(AutoRegister);
135135 }
136
137 template
138 void BatchReadOwnedPtrs(T1*& P1, T2*& P2,
139 bool A1=true, bool A2=true) {
140
141 unsigned ID1 = ReadInt();
142 unsigned ID2 = ReadInt();
143
144 P1 = (ID1) ? SerializeTrait::Materialize(*this) : NULL;
145 if (ID1 && A1) RegisterPtr(ID1,P1);
146
147 P2 = (ID2) ? SerializeTrait::Materialize(*this) : NULL;
148 if (ID2 && A2) RegisterPtr(ID2,P2);
149 }
150
151 template
152 void BatchReadOwnedPtrs(T1*& P1, T2*& P2, T3*& P3,
153 bool A1=true, bool A2=true, bool A3=true) {
154
155 unsigned ID1 = ReadInt();
156 unsigned ID2 = ReadInt();
157 unsigned ID3 = ReadInt();
158
159 P1 = (ID1) ? SerializeTrait::Materialize(*this) : NULL;
160 if (ID1 && A1) RegisterPtr(ID1,P1);
161
162 P2 = (ID2) ? SerializeTrait::Materialize(*this) : NULL;
163 if (ID2 && A2) RegisterPtr(ID2,P2);
164
165 P3 = (ID3) ? SerializeTrait::Materialize(*this) : NULL;
166 if (ID3 && A3) RegisterPtr(ID3,P3);
167 }
168
136169
137170 template
138171 void ReadPtr(T*& PtrRef, bool AllowBackpatch = true) {
5353 EmitPtr(ptr);
5454 if (ptr) SerializeTrait::Emit(*this,*ptr);
5555 }
56
57 template
58 void BatchEmitOwnedPtrs(T1* p1, T2* p2) {
59 EmitPtr(p1);
60 EmitPtr(p2);
61 if (p1) SerializeTrait::Emit(*this,*p1);
62 if (p2) SerializeTrait::Emit(*this,*p2);
63 }
64
65 template
66 void BatchEmitOwnedPtrs(T1* p1, T2* p2, T3* p3) {
67 EmitPtr(p1);
68 EmitPtr(p2);
69 EmitPtr(p3);
70 if (p1) SerializeTrait::Emit(*this,*p1);
71 if (p2) SerializeTrait::Emit(*this,*p2);
72 if (p3) SerializeTrait::Emit(*this,*p3);
73 }
74
75 template
76 void BatchEmitOwnedPtrs(T1* p1, T2* p2, T3* p3, T4& p4) {
77 EmitPtr(p1);
78 EmitPtr(p2);
79 EmitPtr(p3);
80 EmitPtr(p4);
81 if (p1) SerializeTrait::Emit(*this,*p1);
82 if (p2) SerializeTrait::Emit(*this,*p2);
83 if (p3) SerializeTrait::Emit(*this,*p3);
84 if (p4) SerializeTrait::Emit(*this,*p4);
85 }
5686
5787 void FlushRecord() { if (inRecord()) EmitRecord(); }
5888