X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FBytecode%2FReader%2FReaderInternals.h;h=54cda44a6b49da07981354cfe3a1e9005dbbc0ed;hb=e7506a366e8bd56c97d10beb68e4db953aebaeca;hp=3a8dbb8c2a9bb3de3484c232ccc0cccc517239ae;hpb=d6b65255fec99708c8317cde601b12ec09f538d9;p=oota-llvm.git diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index 3a8dbb8c2a9..54cda44a6b4 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -10,27 +10,23 @@ #include "llvm/Bytecode/Primitives.h" #include "llvm/SymTabValue.h" #include "llvm/Method.h" +#include "llvm/BasicBlock.h" #include "llvm/Instruction.h" +#include "llvm/DerivedTypes.h" #include #include #include // Enable to trace to figure out what the heck is going on when parsing fails -#define TRACE_LEVEL 10 +#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 +#define BCR_TRACE(n, X) if (n < TRACE_LEVEL) cerr << std::string(n*2, ' ') << X #else #define BCR_TRACE(n, X) #endif -class BasicBlock; -class Method; -class Module; -class Type; -class PointerType; - typedef unsigned char uchar; struct RawInst { // The raw fields out of the bytecode stream... @@ -40,12 +36,12 @@ struct RawInst { // The raw fields out of the bytecode stream... unsigned Arg1, Arg2; union { unsigned Arg3; - vector *VarArgs; // Contains arg #3,4,5... if NumOperands > 3 + std::vector *VarArgs; // Contains arg #3,4,5... if NumOperands > 3 }; }; class BytecodeParser : public AbstractTypeUser { - string Error; // Error message string goes here... + std::string Error; // Error message string goes here... public: BytecodeParser() { // Define this in case we don't see a ModuleGlobalInfo block. @@ -54,13 +50,13 @@ public: Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf); - string getError() const { return Error; } + std::string getError() const { return Error; } private: // All of this data is transient across calls to ParseBytecode Module *TheModule; // Current Module being read into... - typedef vector ValueList; - typedef vector ValueTable; + typedef std::vector ValueList; + typedef std::vector ValueTable; ValueTable Values, LateResolveValues; ValueTable ModuleValues, LateResolveModuleValues; @@ -69,14 +65,14 @@ private: // All of this data is transient across calls to ParseBytecode // are defined, and if so, the temporary object that they represent is held // here. // - typedef map, GlobalVariable*> - GlobalRefsType; + typedef std::map, + GlobalVariable*> GlobalRefsType; GlobalRefsType GlobalRefs; // TypesLoaded - This vector mirrors the Values[TypeTyID] plane. It is used // to deal with forward references to types. // - typedef vector > TypeValuesListTy; + typedef std::vector > TypeValuesListTy; TypeValuesListTy ModuleTypeValues; TypeValuesListTy MethodTypeValues; @@ -88,11 +84,11 @@ private: // All of this data is transient across calls to ParseBytecode // into its slot to reserve it. When the method is loaded, this placeholder // is replaced. // - list > MethodSignatureList; + std::list > MethodSignatureList; private: - bool ParseModule (const uchar * Buf, const uchar *End, Module *&); - bool ParseModuleGlobalInfo (const uchar *&Buf, const uchar *End, Module *); + 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, SymbolTable *); bool ParseMethod (const uchar *&Buf, const uchar *End, Module *); bool ParseBasicBlock (const uchar *&Buf, const uchar *End, BasicBlock *&); @@ -101,8 +97,8 @@ private: bool ParseConstantPool(const uchar *&Buf, const uchar *EndBuf, ValueTable &Tab, TypeValuesListTy &TypeTab); - bool parseConstPoolValue(const uchar *&Buf, const uchar *End, - const Type *Ty, ConstPoolVal *&V); + bool parseConstantValue(const uchar *&Buf, const uchar *End, + const Type *Ty, Constant *&V); bool parseTypeConstants(const uchar *&Buf, const uchar *EndBuf, TypeValuesListTy &Tab, unsigned NumEntries); const Type *parseTypeConstant(const uchar *&Buf, const uchar *EndBuf); @@ -110,13 +106,13 @@ private: Value *getValue(const Type *Ty, unsigned num, bool Create = true); const Type *getType(unsigned ID); - int insertValue(Value *D, vector &D); // -1 = Failure + int insertValue(Value *D, std::vector &D); // -1 = Failure bool postResolveValues(ValueTable &ValTab); bool getTypeSlot(const Type *Ty, unsigned &Slot); // DeclareNewGlobalValue - Patch up forward references to global values in the - // form of ConstPoolPointerRefs. + // form of ConstantPointerRefs. // void DeclareNewGlobalValue(GlobalValue *GV, unsigned Slot); @@ -149,7 +145,7 @@ struct BBPlaceHolderHelper : public BasicBlock { struct MethPlaceHolderHelper : public Method { MethPlaceHolderHelper(const Type *Ty) - : Method(cast(Ty)) { + : Method(cast(Ty), true) { } };