OLD | NEW |
1 //===- BitcodeReader.h - Internal BitcodeReader impl ------------*- C++ -*-===// | 1 //===- BitcodeReader.h - Internal BitcodeReader impl ------------*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This header defines the BitcodeReader class. | 10 // This header defines the BitcodeReader class. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 Value *getValueFwdRef(unsigned Idx); | 120 Value *getValueFwdRef(unsigned Idx); |
121 void AssignValue(Value *V, unsigned Idx); | 121 void AssignValue(Value *V, unsigned Idx); |
122 }; | 122 }; |
123 | 123 |
124 class BitcodeReader : public GVMaterializer { | 124 class BitcodeReader : public GVMaterializer { |
125 LLVMContext &Context; | 125 LLVMContext &Context; |
126 Module *TheModule; | 126 Module *TheModule; |
127 MemoryBuffer *Buffer; | 127 MemoryBuffer *Buffer; |
128 bool BufferOwned; | 128 bool BufferOwned; |
129 BitstreamReader StreamFile; | 129 OwningPtr<BitstreamReader> StreamFile; |
130 BitstreamCursor Stream; | 130 BitstreamCursor Stream; |
131 | 131 |
132 const char *ErrorString; | 132 const char *ErrorString; |
133 | 133 |
134 std::vector<Type*> TypeList; | 134 std::vector<Type*> TypeList; |
135 BitcodeReaderValueList ValueList; | 135 BitcodeReaderValueList ValueList; |
136 BitcodeReaderMDValueList MDValueList; | 136 BitcodeReaderMDValueList MDValueList; |
137 SmallVector<Instruction *, 64> InstructionList; | 137 SmallVector<Instruction *, 64> InstructionList; |
138 | 138 |
139 std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits; | 139 std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits; |
(...skipping 27 matching lines...) Expand all Loading... |
167 /// DeferredFunctionInfo - When function bodies are initially scanned, this | 167 /// DeferredFunctionInfo - When function bodies are initially scanned, this |
168 /// map contains info about where to find deferred function body in the | 168 /// map contains info about where to find deferred function body in the |
169 /// stream. | 169 /// stream. |
170 DenseMap<Function*, uint64_t> DeferredFunctionInfo; | 170 DenseMap<Function*, uint64_t> DeferredFunctionInfo; |
171 | 171 |
172 /// BlockAddrFwdRefs - These are blockaddr references to basic blocks. These | 172 /// BlockAddrFwdRefs - These are blockaddr references to basic blocks. These |
173 /// are resolved lazily when functions are loaded. | 173 /// are resolved lazily when functions are loaded. |
174 typedef std::pair<unsigned, GlobalVariable*> BlockAddrRefTy; | 174 typedef std::pair<unsigned, GlobalVariable*> BlockAddrRefTy; |
175 DenseMap<Function*, std::vector<BlockAddrRefTy> > BlockAddrFwdRefs; | 175 DenseMap<Function*, std::vector<BlockAddrRefTy> > BlockAddrFwdRefs; |
176 | 176 |
| 177 StreamChunkCallback StreamCallback; |
| 178 |
177 public: | 179 public: |
178 explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C) | 180 explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C) |
179 : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false), | 181 : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false), |
180 ErrorString(0), ValueList(C), MDValueList(C) { | 182 ErrorString(0), ValueList(C), MDValueList(C), StreamCallback(0) { |
| 183 HasReversedFunctionsWithBodies = false; |
| 184 } |
| 185 BitcodeReader(StreamChunkCallback cb, LLVMContext &C) |
| 186 : Context(C), TheModule(0), Buffer(0), BufferOwned(false), |
| 187 ErrorString(0), ValueList(C), MDValueList(C), StreamCallback(cb) { |
181 HasReversedFunctionsWithBodies = false; | 188 HasReversedFunctionsWithBodies = false; |
182 } | 189 } |
183 ~BitcodeReader() { | 190 ~BitcodeReader() { |
184 FreeState(); | 191 FreeState(); |
185 } | 192 } |
186 | 193 |
187 void FreeState(); | 194 void FreeState(); |
188 | 195 |
189 /// setBufferOwned - If this is true, the reader will destroy the MemoryBuffer | 196 /// setBufferOwned - If this is true, the reader will destroy the MemoryBuffer |
190 /// when the reader is destroyed. | 197 /// when the reader is destroyed. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 271 |
265 bool ParseOldTypeSymbolTable(); // FIXME: Remove in LLVM 3.1 | 272 bool ParseOldTypeSymbolTable(); // FIXME: Remove in LLVM 3.1 |
266 bool ParseValueSymbolTable(); | 273 bool ParseValueSymbolTable(); |
267 bool ParseConstants(); | 274 bool ParseConstants(); |
268 bool RememberAndSkipFunctionBody(); | 275 bool RememberAndSkipFunctionBody(); |
269 bool ParseFunctionBody(Function *F); | 276 bool ParseFunctionBody(Function *F); |
270 bool ResolveGlobalAndAliasInits(); | 277 bool ResolveGlobalAndAliasInits(); |
271 bool ParseMetadata(); | 278 bool ParseMetadata(); |
272 bool ParseMetadataAttachment(); | 279 bool ParseMetadataAttachment(); |
273 bool ParseModuleTriple(std::string &Triple); | 280 bool ParseModuleTriple(std::string &Triple); |
| 281 bool InitStream(); |
| 282 bool InitStreamFromBuffer(); |
| 283 bool InitLazyStream(); |
274 }; | 284 }; |
275 | 285 |
276 } // End llvm namespace | 286 } // End llvm namespace |
277 | 287 |
278 #endif | 288 #endif |
OLD | NEW |