[llvm-commits] [llvm] r49480 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp

Gabor Greif ggreif at gmail.com
Thu Apr 10 06:08:37 PDT 2008


Author: ggreif
Date: Thu Apr 10 08:08:37 2008
New Revision: 49480

URL: http://llvm.org/viewvc/llvm-project?rev=49480&view=rev
Log:
ReturnInst: various cleanups, define 'operator delete' to do the right thing

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
    llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp

Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49480&r1=49479&r2=49480&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 08:08:37 2008
@@ -1511,25 +1511,25 @@
 class ReturnInst : public TerminatorInst {
   ReturnInst(const ReturnInst &RI);
   void init(Value * const* retVals, unsigned N);
+  void *operator new(size_t, unsigned); // Do not implement
 
 private:
   // ReturnInst constructors:
   // ReturnInst()                  - 'ret void' instruction
   // ReturnInst(    null)          - 'ret void' instruction
   // ReturnInst(Value* X)          - 'ret X'    instruction
-  // ReturnInst(    null, Inst *)  - 'ret void' instruction, insert before I
+  // ReturnInst(    null, Inst *I) - 'ret void' instruction, insert before I
   // ReturnInst(Value* X, Inst *I) - 'ret X'    instruction, insert before I
-  // ReturnInst(    null, BB *B)   - 'ret void' instruction, insert @ end of BB
-  // ReturnInst(Value* X, BB *B)   - 'ret X'    instruction, insert @ end of BB
+  // ReturnInst(    null, BB *B)   - 'ret void' instruction, insert @ end of B
+  // ReturnInst(Value* X, BB *B)   - 'ret X'    instruction, insert @ end of B
   // ReturnInst(Value* X, N)          - 'ret X,X+1...X+N-1' instruction
-  // ReturnInst(Value* X, N, Inst *)  - 'ret X,X+1...X+N-1', insert before I
-  // ReturnInst(Value* X, N, BB *)    - 'ret X,X+1...X+N-1', insert @ end of BB
+  // ReturnInst(Value* X, N, Inst *I) - 'ret X,X+1...X+N-1', insert before I
+  // ReturnInst(Value* X, N, BB *B)   - 'ret X,X+1...X+N-1', insert @ end of B
   //
   // NOTE: If the Value* passed is of type void then the constructor behaves as
   // if it was passed NULL.
   explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
   ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
-/*  ReturnInst(Value * const* retVals, unsigned N);*/
   ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0);
   ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd);
   explicit ReturnInst(BasicBlock *InsertAtEnd);
@@ -1540,9 +1540,6 @@
   static ReturnInst* Create(Value *retVal, BasicBlock *InsertAtEnd) {
     return new(!!retVal) ReturnInst(retVal, InsertAtEnd);
   }
-//  static ReturnInst* Create(Value * const* retVals, unsigned N) {
-//    return new(N) ReturnInst(retVals, N);
-//  }
   static ReturnInst* Create(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0) {
     return new(N) ReturnInst(retVals, N, InsertBefore);
   }
@@ -1553,19 +1550,14 @@
     return new(0) ReturnInst(InsertAtEnd);
   }
   virtual ~ReturnInst();
+  inline void operator delete(void*);
 
   virtual ReturnInst *clone() const;
 
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
-/*
-  Value *getOperand(unsigned n = 0) const {
-    if (getNumOperands() > 1)
-      return TerminatorInst::getOperand(n);
-    else
-      return Op<0>();
-  }
-*/
+
+  /// Convenience accessor
   Value *getReturnValue(unsigned n = 0) const {
     return getOperand(n);
   }
@@ -1591,6 +1583,9 @@
 };
 
 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value)
+void ReturnInst::operator delete(void *it) {
+  OperandTraits<ReturnInst>::op_begin(static_cast<ReturnInst*>(it));
+}
 
 //===----------------------------------------------------------------------===//
 //                               BranchInst Class

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

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Thu Apr 10 08:08:37 2008
@@ -458,7 +458,7 @@
 //===----------------------------------------------------------------------===//
 
 ReturnInst::ReturnInst(const ReturnInst &RI)
-  : TerminatorInst(Type::VoidTy/*FIXME: correct?*/, Instruction::Ret,
+  : TerminatorInst(Type::VoidTy, Instruction::Ret,
                    OperandTraits<ReturnInst>::op_end(this) - RI.getNumOperands(),
                    RI.getNumOperands()) {
   unsigned N = RI.getNumOperands();
@@ -507,11 +507,6 @@
   if (N != 0)
     init(retVals, N);
 }
-//ReturnInst::ReturnInst(Value * const* retVals, unsigned N)
-//  : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N) {
-//  if (N != 0)
-//    init(retVals, N);
-//}
 
 void ReturnInst::init(Value * const* retVals, unsigned N) {
   assert (N > 0 && "Invalid operands numbers in ReturnInst init");
@@ -550,8 +545,6 @@
 }
 
 ReturnInst::~ReturnInst() {
-//  if (NumOperands > 1)
-//    delete [] OperandList;
 }
 
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list