mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
Implemented prototype serialization of pointers, including support
for backpatching. Added Deserialize::ReadVal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43319 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
#include "llvm/Bitcode/Serialization.h"
|
||||
#include "llvm/Bitcode/BitstreamWriter.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -25,6 +26,10 @@ class Serializer {
|
||||
BitstreamWriter& Stream;
|
||||
SmallVector<uint64_t,10> Record;
|
||||
bool inBlock;
|
||||
|
||||
typedef DenseMap<void*,unsigned> MapTy;
|
||||
MapTy PtrMap;
|
||||
|
||||
public:
|
||||
Serializer(BitstreamWriter& stream, unsigned BlockID = 0);
|
||||
~Serializer();
|
||||
@ -35,13 +40,22 @@ public:
|
||||
void EmitInt(unsigned X);
|
||||
void EmitBool(bool X) { EmitInt(X); }
|
||||
void EmitCStr(const char* beg, const char* end);
|
||||
void EmitCStr(const char* cstr);
|
||||
void EmitCStr(const char* cstr);
|
||||
|
||||
void EmitPtr(void* ptr) { EmitInt(getPtrId(ptr)); }
|
||||
|
||||
template <typename T>
|
||||
void EmitOwnedPtr(T* ptr) {
|
||||
EmitPtr(ptr);
|
||||
SerializeTrait<T>::Emit(*this,*ptr);
|
||||
}
|
||||
|
||||
void Flush() { if (inRecord()) EmitRecord(); }
|
||||
|
||||
private:
|
||||
void EmitRecord();
|
||||
inline bool inRecord() { return Record.size() > 0; }
|
||||
inline bool inRecord() { return Record.size() > 0; }
|
||||
unsigned getPtrId(void* ptr);
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
Reference in New Issue
Block a user