[llvm-commits] [llvm] r49588 - /llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp

Gabor Greif ggreif at gmail.com
Sat Apr 12 13:59:44 PDT 2008


Author: ggreif
Date: Sat Apr 12 15:59:44 2008
New Revision: 49588

URL: http://llvm.org/viewvc/llvm-project?rev=49588&view=rev
Log:
convert GetElementPtrConstantExpr; namespace confusion will be cleaned up next

Modified:
    llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp

Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp?rev=49588&r1=49587&r2=49588&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp Sat Apr 12 15:59:44 2008
@@ -403,6 +403,7 @@
 //  delete [] OperandList;
 }
 
+namespace llvm {
 // We declare several classes private to this file, so use an anonymous
 // namespace
 namespace {
@@ -515,23 +516,49 @@
 /// used behind the scenes to implement getelementpr constant exprs.
 class VISIBILITY_HIDDEN GetElementPtrConstantExpr : public ConstantExpr {
   GetElementPtrConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
-                            const Type *DestTy)
+                            const Type *DestTy);/*
     : ConstantExpr(DestTy, Instruction::GetElementPtr,
-                   allocHangoffUses(IdxList.size()+1), IdxList.size()+1) {
+                   OperandTraits<GetElementPtrConstantExpr>::op_end(this)
+                   - (IdxList.size()+1),
+                   IdxList.size()+1) {
     OperandList[0].init(C, this);
     for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
       OperandList[i+1].init(IdxList[i], this);
-  }
+      }*/
 public:
   static GetElementPtrConstantExpr *Create(Constant *C, const std::vector<Constant*> &IdxList,
-                                    const Type *DestTy) {
-    return new(IdxList.size() + 1/*FIXME*/) GetElementPtrConstantExpr(C, IdxList, DestTy);
-  }
-  ~GetElementPtrConstantExpr() {
-    delete [] OperandList;
+                                           const Type *DestTy) {
+    return new(IdxList.size() + 1) GetElementPtrConstantExpr(C, IdxList, DestTy);
   }
+  //  ~GetElementPtrConstantExpr() {
+    //    delete [] OperandList;
+  //  }
+
+  /// Transparently provide more efficient getOperand methods.
+  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+};
+} // end anonymous namespace
+
+template <>
+struct OperandTraits<GetElementPtrConstantExpr> : VariadicOperandTraits<1> {
 };
 
+GetElementPtrConstantExpr::GetElementPtrConstantExpr
+  (Constant *C,
+   const std::vector<Constant*> &IdxList,
+   const Type *DestTy)
+    : ConstantExpr(DestTy, Instruction::GetElementPtr,
+                   OperandTraits<GetElementPtrConstantExpr>::op_end(this)
+                   - (IdxList.size()+1),
+                   IdxList.size()+1) {
+  OperandList[0].init(C, this);
+  for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
+    OperandList[i+1].init(IdxList[i], this);
+}
+
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrConstantExpr, Value)
+
+namespace {
 // CompareConstantExpr - This class is private to Constants.cpp, and is used
 // behind the scenes to implement ICmp and FCmp constant expressions. This is
 // needed in order to store the predicate value for these instructions.
@@ -551,6 +578,7 @@
 };
 
 } // end anonymous namespace
+} // End llvm namespace
 
 
 // Utility function for determining if a ConstantExpr is a CastOp or not. This





More information about the llvm-commits mailing list