diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-09 20:22:47 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-09 20:22:47 +0000 |
commit | 927b185c175a8eb6d64ea97e1735fc6102114766 (patch) | |
tree | 61b9ae5b740d44fe2ec5292181b989e444d83155 /lib/Bytecode/Reader/ReaderInternals.h | |
parent | 3483f54367e990c61eda61a6a550ba2634a13cb9 (diff) |
Major refactoring of the bytecode reader. This includes the following
changes:
* BytecodeReader::getType(...) used to return a null pointer
on error. This was only checked about half the time. Now we convert
it to throw an exception, and delete the half that checked for error.
This was checked in before, but psmith crashed and lost the change :(
* insertValue no longer returns -1 on error, so callers don't need to
check for it.
* Substantial rewrite of InstructionReader.cpp, to use more efficient,
simpler, data structures. This provides another 5% speedup. This also
makes the code much easier to read and understand.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/ReaderInternals.h')
-rw-r--r-- | lib/Bytecode/Reader/ReaderInternals.h | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index 42f7e1b463..1fefe23faf 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -14,8 +14,6 @@ #include "llvm/Bytecode/Primitives.h" #include <utility> #include <map> -#include <memory> -class Module; // Enable to trace to figure out what the heck is going on when parsing fails //#define TRACE_LEVEL 10 @@ -27,17 +25,6 @@ class Module; #define BCR_TRACE(n, X) #endif -struct RawInst { // The raw fields out of the bytecode stream... - unsigned NumOperands; - unsigned Opcode; - const Type *Ty; - unsigned Arg1, Arg2; - union { - unsigned Arg3; - std::vector<unsigned> *VarArgs; // Contains arg #3,4,5... if NumOperands > 3 - }; -}; - struct LazyFunctionInfo { const unsigned char *Buf, *EndBuf; unsigned FunctionSlot; @@ -62,11 +49,9 @@ public: Module* releaseModule() { // Since we're losing control of this Module, we must hand it back complete - materializeModule(); + Module *M = ModuleProvider::releaseModule(); freeState(); - Module *tempM = TheModule; - TheModule = 0; - return tempM; + return M; } void ParseBytecode(const unsigned char *Buf, unsigned Length, @@ -165,8 +150,6 @@ private: Instruction *ParseInstruction(const unsigned char *&Buf, const unsigned char *End); - std::auto_ptr<RawInst> ParseRawInst(const unsigned char *&Buf, - const unsigned char *End); void ParseConstantPool(const unsigned char *&Buf, const unsigned char *EndBuf, ValueTable &Tab, TypeValuesListTy &TypeTab); @@ -185,7 +168,7 @@ private: BasicBlock *getBasicBlock(unsigned ID); Constant *getConstantValue(const Type *Ty, unsigned num); - int insertValue(Value *V, ValueTable &Table); // -1 = Failure + unsigned insertValue(Value *V, ValueTable &Table); unsigned getTypeSlot(const Type *Ty); |