From 522b7b104c864da81c19d8b16c43b7a1f6a2fc40 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Apr 2007 05:48:56 +0000 Subject: 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 --- lib/Bitcode/Reader/BitcodeReader.h | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'lib/Bitcode/Reader/BitcodeReader.h') 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 namespace llvm { class BitstreamReader; - class Value; - class GlobalVariable; + +class BitcodeReaderValueList : public User { + std::vector 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 TypeList; - std::vector ValueList; + BitcodeReaderValueList ValueList; std::vector > GlobalInits; public: virtual ~BitcodeReader() {} -- cgit v1.2.3-18-g5258