diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-24 05:48:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-24 05:48:56 +0000 |
commit | 522b7b104c864da81c19d8b16c43b7a1f6a2fc40 (patch) | |
tree | b3466074088bcbf9feee242542d7938cc639a235 /lib/Bitcode/Reader/BitcodeReader.h | |
parent | 0eef08046e0758f1800f32c63b817fd22264577b (diff) |
implement support for reading aggregate constants, including handling forward
constant references, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36391 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.h')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h index bdb64c8c99..c7c61529ff 100644 --- a/lib/Bitcode/Reader/BitcodeReader.h +++ b/lib/Bitcode/Reader/BitcodeReader.h @@ -14,21 +14,48 @@ #ifndef BITCODE_READER_H #define BITCODE_READER_H -#include "llvm/Type.h" #include "llvm/ModuleProvider.h" +#include "llvm/Type.h" +#include "llvm/User.h" #include "llvm/Bitcode/LLVMBitCodes.h" #include <vector> namespace llvm { class BitstreamReader; - class Value; - class GlobalVariable; + +class BitcodeReaderValueList : public User { + std::vector<Use> Uses; +public: + BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {} + + // vector compatibility methods + unsigned size() const { return getNumOperands(); } + void push_back(Value *V) { + Uses.push_back(Use(V, this)); + OperandList = &Uses[0]; + ++NumOperands; + } + + Value *operator[](unsigned i) const { return getOperand(i); } + + Value *back() const { return Uses.back(); } + void pop_back() { Uses.pop_back(); --NumOperands; } + bool empty() const { return NumOperands == 0; } + virtual void print(std::ostream&) const {} + + Constant *getConstantFwdRef(unsigned Idx, const Type *Ty); + void initVal(unsigned Idx, Value *V) { + assert(Uses[Idx] == 0 && "Cannot init an already init'd Use!"); + Uses[Idx].init(V, this); + } +}; + class BitcodeReader : public ModuleProvider { const char *ErrorString; std::vector<PATypeHolder> TypeList; - std::vector<Value*> ValueList; + BitcodeReaderValueList ValueList; std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits; public: virtual ~BitcodeReader() {} |