aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bytecode/Reader/ReaderInternals.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-07 16:37:43 +0000
committerChris Lattner <sabre@nondot.org>2001-09-07 16:37:43 +0000
commit1d670cc40299cb51198c58f9c0c97a9b54248760 (patch)
treeb14d1e0dfa9c6ba68f0fdeead83f6e7fdc733203 /lib/Bytecode/Reader/ReaderInternals.h
parent007377f381e253cc559db8d3c94fa89b0eb55fad (diff)
downloadexternal_llvm-1d670cc40299cb51198c58f9c0c97a9b54248760.zip
external_llvm-1d670cc40299cb51198c58f9c0c97a9b54248760.tar.gz
external_llvm-1d670cc40299cb51198c58f9c0c97a9b54248760.tar.bz2
* Remove support for internal constant pool
* Support globally unique constants * Support recursive and forward referenced types * Support abstract types * Add new BCR_TRACE macro to enable debugging of why the bytecode reader occasionally refuses to read something git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@448 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/ReaderInternals.h')
-rw-r--r--lib/Bytecode/Reader/ReaderInternals.h39
1 files changed, 30 insertions, 9 deletions
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index 5721c73..b94b791 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -14,6 +14,16 @@
#include <map>
#include <utility>
+// Enable to trace to figure out what the heck is going on when parsing fails
+#define TRACE_LEVEL 0
+
+#if TRACE_LEVEL // ByteCodeReading_TRACEer
+#include "llvm/Assembly/Writer.h"
+#define BCR_TRACE(n, X) if (n < TRACE_LEVEL) cerr << string(n*2, ' ') << X
+#else
+#define BCR_TRACE(n, X)
+#endif
+
class BasicBlock;
class Method;
class Module;
@@ -32,7 +42,7 @@ struct RawInst { // The raw fields out of the bytecode stream...
};
};
-class BytecodeParser {
+class BytecodeParser : public AbstractTypeUser {
public:
BytecodeParser() {
// Define this in case we don't see a ModuleGlobalInfo block.
@@ -43,10 +53,15 @@ public:
private: // All of this data is transient across calls to ParseBytecode
typedef vector<Value *> ValueList;
typedef vector<ValueList> ValueTable;
- typedef map<const Type *, unsigned> TypeMapType;
ValueTable Values, LateResolveValues;
ValueTable ModuleValues, LateResolveModuleValues;
- TypeMapType TypeMap;
+
+ // TypesLoaded - This vector mirrors the Values[TypeTyID] plane. It is used
+ // to deal with forward references to types.
+ //
+ typedef vector<PATypeHandle<Type> > TypeValuesListTy;
+ TypeValuesListTy ModuleTypeValues;
+ TypeValuesListTy MethodTypeValues;
// Information read from the ModuleGlobalInfo section of the file...
unsigned FirstDerivedTyID;
@@ -61,19 +76,19 @@ private: // All of this data is transient across calls to ParseBytecode
private:
bool ParseModule (const uchar * Buf, const uchar *End, Module *&);
bool ParseModuleGlobalInfo (const uchar *&Buf, const uchar *End, Module *);
- bool ParseSymbolTable (const uchar *&Buf, const uchar *End);
- bool ParseMethod (const uchar *&Buf, const uchar *End, Module *);
+ bool ParseSymbolTable (const uchar *&Buf, const uchar *End, SymbolTable *);
+ bool ParseMethod (const uchar *&Buf, const uchar *End, Module *);
bool ParseBasicBlock (const uchar *&Buf, const uchar *End, BasicBlock *&);
bool ParseInstruction (const uchar *&Buf, const uchar *End, Instruction *&);
bool ParseRawInst (const uchar *&Buf, const uchar *End, RawInst &);
bool ParseConstantPool(const uchar *&Buf, const uchar *EndBuf,
- SymTabValue::ConstantPoolType &CP, ValueTable &Tab);
-
-
+ ValueTable &Tab, TypeValuesListTy &TypeTab);
bool parseConstPoolValue(const uchar *&Buf, const uchar *End,
const Type *Ty, ConstPoolVal *&V);
- bool parseTypeConstant (const uchar *&Buf, const uchar *, ConstPoolVal *&);
+ bool parseTypeConstants(const uchar *&Buf, const uchar *EndBuf,
+ TypeValuesListTy &Tab, unsigned NumEntries);
+ const Type *parseTypeConstant(const uchar *&Buf, const uchar *EndBuf);
Value *getValue(const Type *Ty, unsigned num, bool Create = true);
const Type *getType(unsigned ID);
@@ -82,6 +97,12 @@ private:
bool postResolveValues(ValueTable &ValTab);
bool getTypeSlot(const Type *Ty, unsigned &Slot);
+
+
+ // refineAbstractType - The callback method is invoked when one of the
+ // elements of TypeValues becomes more concrete...
+ //
+ virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
};
template<class SuperType>