Adjust to changes in the User class.
authorChris Lattner <sabre@nondot.org>
Sat, 29 Jan 2005 00:33:00 +0000 (00:33 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 29 Jan 2005 00:33:00 +0000 (00:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19888 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h
include/llvm/GlobalValue.h
include/llvm/GlobalVariable.h
include/llvm/Instruction.h

index e8929f644314db8d115ba2f651a0740b7bc57f4d..d22270e87128ca2c301649b58c05442196ce3ceb 100644 (file)
@@ -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<Constant*> &Val);
+  ~ConstantArray();
 public:
   /// get() - Static factory methods - Return objects of the specified value
   static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
@@ -399,6 +400,7 @@ class ConstantStruct : public Constant {
   ConstantStruct(const ConstantStruct &);      // DO NOT IMPLEMENT
 protected:
   ConstantStruct(const StructType *T, const std::vector<Constant*> &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<Constant*> &Val);
+  ~ConstantPacked();
 public:
   /// get() - Static factory methods - Return objects of the specified value
   static Constant *get(const PackedType *T, const std::vector<Constant*> &);
@@ -476,7 +479,8 @@ class ConstantPointerNull : public Constant {
   ConstantPointerNull(const ConstantPointerNull &);      // DO NOT IMPLEMENT
 protected:
   ConstantPointerNull(const PointerType *T)
-    : Constant(reinterpret_cast<const Type*>(T)) {}
+    : Constant(reinterpret_cast<const Type*>(T),
+               Value::SimpleConstantVal, 0, 0) {}
 
 public:
 
@@ -518,10 +522,9 @@ class ConstantExpr : public Constant {
   friend struct ConvertConstantType<ConstantExpr, Type>;
   
 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, Type, char>;
   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.
index 12863a2c139efb401f4c06588de4b85699279e5c..60176c588d37a4fd66d6cbecb935f1b3f7a28afe 100644 (file)
@@ -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;
index 99c39f179602c91c77686bff6cd0c2e8f7aaf954..1a951774fd351fca780a8bdabe20eef2e05e0f96 100644 (file)
@@ -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<Constant*>(Operands[0].get());
+    return reinterpret_cast<Constant*>(Initializer.get());
   }
   inline Constant *getInitializer() {
     assert(hasInitializer() && "GV doesn't have initializer!");
-    return reinterpret_cast<Constant*>(Operands[0].get());
+    return reinterpret_cast<Constant*>(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<Value*>(CPV);
+      if (!hasInitializer())
+        NumOperands = 1;
+      Initializer.set(CPV);
     }
   }
 
index a7359731db7d513f77bd136acbb5efda4452c6d6..8d69afa7a6df163e6d74ba28dc74b10337968a8b 100644 (file)
@@ -36,7 +36,6 @@ class Instruction : public User {
   friend class SymbolTableListTraits<Instruction, BasicBlock, Function,
                                      ilist_traits<Instruction> >;
   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() {