Add a 'normalize' method to the Triple class, which takes a mucked up
[oota-llvm.git] / include / llvm / User.h
index f2df23e34125570414dca070f1b9b4c7d54d2b13..f8277952ee4ba9fa7cd03e8ee116c4a4fbb9f5fa 100644 (file)
@@ -41,7 +41,6 @@ struct OperandTraits<User> {
   struct Layout {
     typedef U overlay;
   };
-  static inline void *allocate(unsigned);
 };
 
 class User : public Value {
@@ -62,6 +61,7 @@ protected:
   unsigned NumOperands;
 
   void *operator new(size_t s, unsigned Us);
+  void *operator new(size_t s, unsigned Us, bool Prefix);
   User(const Type *ty, unsigned vty, Use *OpList, unsigned NumOps)
     : Value(ty, vty), OperandList(OpList), NumOperands(NumOps) {}
   Use *allocHungoffUses(unsigned) const;
@@ -74,7 +74,8 @@ protected:
   }
 public:
   ~User() {
-    Use::zap(OperandList, OperandList + NumOperands);
+    if ((intptr_t(OperandList) & 1) == 0)
+      Use::zap(OperandList, OperandList + NumOperands);
   }
   /// operator delete - free memory allocated for User and Use objects
   void operator delete(void *Usr);
@@ -82,12 +83,21 @@ public:
   void operator delete(void*, unsigned) {
     assert(0 && "Constructor throws?");
   }
+  /// placement delete - required by std, but never called.
+  void operator delete(void*, unsigned, bool) {
+    assert(0 && "Constructor throws?");
+  }
 protected:
-  template <unsigned Idx> Use &Op() {
-    return OperandTraits<User>::op_begin(this)[Idx];
+  template <int Idx, typename U> static Use &OpFrom(const U *that) {
+    return Idx < 0
+      ? OperandTraits<U>::op_end(const_cast<U*>(that))[Idx]
+      : OperandTraits<U>::op_begin(const_cast<U*>(that))[Idx];
+  }
+  template <int Idx> Use &Op() {
+    return OpFrom<Idx>(this);
   }
-  template <unsigned Idx> const Use &Op() const {
-    return OperandTraits<User>::op_begin(const_cast<User*>(this))[Idx];
+  template <int Idx> const Use &Op() const {
+    return OpFrom<Idx>(this);
   }
 public:
   Value *getOperand(unsigned i) const {