From 5181ac8081dd6c7d78613a5da8829f81a81e9e63 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 29 Jan 2005 00:33:00 +0000 Subject: [PATCH] Adjust to changes in the User class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19888 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Constants.h | 17 ++++++++++------- include/llvm/GlobalValue.h | 6 +++--- include/llvm/GlobalVariable.h | 20 +++++++++++++------- include/llvm/Instruction.h | 8 ++++---- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index e8929f64431..d22270e8712 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -319,7 +319,7 @@ class ConstantAggregateZero : public Constant { ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT protected: ConstantAggregateZero(const Type *Ty) - : Constant(Ty, ConstantAggregateZeroVal) {} + : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {} public: /// get() - static factory method for creating a null aggregate. It is /// illegal to call this method with a non-aggregate type. @@ -351,6 +351,7 @@ class ConstantArray : public Constant { ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT protected: ConstantArray(const ArrayType *T, const std::vector &Val); + ~ConstantArray(); public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const ArrayType *T, const std::vector &); @@ -399,6 +400,7 @@ class ConstantStruct : public Constant { ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT protected: ConstantStruct(const StructType *T, const std::vector &Val); + ~ConstantStruct(); public: /// get() - Static factory methods - Return objects of the specified value /// @@ -439,6 +441,7 @@ class ConstantPacked : public Constant { ConstantPacked(const ConstantPacked &); // DO NOT IMPLEMENT protected: ConstantPacked(const PackedType *T, const std::vector &Val); + ~ConstantPacked(); public: /// get() - Static factory methods - Return objects of the specified value static Constant *get(const PackedType *T, const std::vector &); @@ -476,7 +479,8 @@ class ConstantPointerNull : public Constant { ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT protected: ConstantPointerNull(const PointerType *T) - : Constant(reinterpret_cast(T)) {} + : Constant(reinterpret_cast(T), + Value::SimpleConstantVal, 0, 0) {} public: @@ -518,10 +522,9 @@ class ConstantExpr : public Constant { friend struct ConvertConstantType; protected: - // Cast creation ctor - ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); - // Binary/Shift instruction creation ctor - ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2); + ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps) + : Constant(Ty, ConstantExprVal, Ops, NumOps), iType(Opcode) {} + // Select instruction creation ctor ConstantExpr(Constant *C, Constant *V1, Constant *V2); // GEP instruction creation ctor @@ -642,7 +645,7 @@ class UndefValue : public Constant { friend struct ConstantCreator; UndefValue(const UndefValue &); // DO NOT IMPLEMENT protected: - UndefValue(const Type *T) : Constant(T, UndefValueVal) {} + UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {} public: /// get() - Static factory methods - Return an 'undef' object of the specified /// type. diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h index 12863a2c139..60176c588d3 100644 --- a/include/llvm/GlobalValue.h +++ b/include/llvm/GlobalValue.h @@ -36,9 +36,9 @@ public: GhostLinkage // Stand-in functions for streaming fns from BC files }; protected: - GlobalValue(const Type *Ty, ValueTy vty, LinkageTypes linkage, - const std::string &name = "") - : Constant(Ty, vty, name), Linkage(linkage), Parent(0) { } + GlobalValue(const Type *Ty, ValueTy vty, Use *Ops, unsigned NumOps, + LinkageTypes linkage, const std::string &name = "") + : Constant(Ty, vty, Ops, NumOps, name), Linkage(linkage), Parent(0) { } LinkageTypes Linkage; // The linkage of this global Module *Parent; diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h index 99c39f17960..1a951774fd3 100644 --- a/include/llvm/GlobalVariable.h +++ b/include/llvm/GlobalVariable.h @@ -41,6 +41,8 @@ class GlobalVariable : public GlobalValue { void setPrev(GlobalVariable *N) { Prev = N; } bool isConstantGlobal; // Is this a global constant? + Use Initializer; + public: /// GlobalVariable ctor - If a parent module is specified, the global is /// automatically inserted into the end of the specified modules global list. @@ -56,11 +58,11 @@ public: /// global variable is defined in some other translation unit, and is thus /// externally defined here. /// - virtual bool isExternal() const { return Operands.empty(); } + virtual bool isExternal() const { return getNumOperands() == 0; } /// hasInitializer - Unless a global variable isExternal(), it has an /// initializer. The initializer for the global variable/constant is held by - /// Operands[0] if an initializer is specified. + /// Initializer if an initializer is specified. /// inline bool hasInitializer() const { return !isExternal(); } @@ -70,18 +72,22 @@ public: /// inline Constant *getInitializer() const { assert(hasInitializer() && "GV doesn't have initializer!"); - return reinterpret_cast(Operands[0].get()); + return reinterpret_cast(Initializer.get()); } inline Constant *getInitializer() { assert(hasInitializer() && "GV doesn't have initializer!"); - return reinterpret_cast(Operands[0].get()); + return reinterpret_cast(Initializer.get()); } inline void setInitializer(Constant *CPV) { if (CPV == 0) { - if (hasInitializer()) Operands.pop_back(); + if (hasInitializer()) { + Initializer.set(0); + NumOperands = 0; + } } else { - if (!hasInitializer()) Operands.push_back(Use(0, this)); - Operands[0] = reinterpret_cast(CPV); + if (!hasInitializer()) + NumOperands = 1; + Initializer.set(CPV); } } diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index a7359731db7..8d69afa7a6d 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -36,7 +36,6 @@ class Instruction : public User { friend class SymbolTableListTraits >; void setParent(BasicBlock *P); - void init(); private: // FIXME: This is a dirty hack. Setcc instructions shouldn't encode the CC @@ -44,10 +43,11 @@ private: void setOpcode(unsigned NewOpcode); friend class BinaryOperator; protected: - Instruction(const Type *Ty, unsigned iType, const std::string &Name = "", + Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, + const std::string &Name = "", Instruction *InsertBefore = 0); - Instruction(const Type *Ty, unsigned iType, const std::string &Name, - BasicBlock *InsertAtEnd); + Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, + const std::string &Name, BasicBlock *InsertAtEnd); public: ~Instruction() {