Add support for the new va_arg instruction
[oota-llvm.git] / lib / Transforms / IPO / OldPoolAllocate.cpp
index 50f21e23978a74c15cfa49df583dae3ab1a3ac14..bf86403d86b7256b00deba0f6808aa62cb542265 100644 (file)
@@ -4,14 +4,12 @@
 // allocated out of different pools of memory, increasing locality and shrinking
 // pointer size.
 //
-// This pass requires a DCE & instcombine pass to be run after it for best
-// results.
-//
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Transforms/IPO/PoolAllocate.h"
-#include "llvm/Transforms/Utils/CloneFunction.h"
-#include "llvm/Analysis/DataStructureGraph.h"
+#if 0
+#include "llvm/Transforms/IPO.h"
+#include "llvm/Transforms/Utils/Cloning.h"
+#include "llvm/Analysis/DataStructure.h"
 #include "llvm/Module.h"
 #include "llvm/iMemory.h"
 #include "llvm/iTerminators.h"
@@ -30,8 +28,6 @@ using std::map;
 using std::string;
 using std::set;
 
-#if 0
-
 // DEBUG_CREATE_POOLS - Enable this to turn on debug output for the pool
 // creation phase in the top level function of a transformed data structure.
 //
@@ -52,13 +48,18 @@ enum PtrSize {
   Ptr8bits, Ptr16bits, Ptr32bits
 };
 
-static cl::Enum<enum PtrSize> ReqPointerSize("ptrsize", 0,
-                                      "Set pointer size for -poolalloc pass",
+static cl::opt<PtrSize>
+ReqPointerSize("poolalloc-ptr-size",
+               cl::desc("Set pointer size for -poolalloc pass"),
+               cl::values(
   clEnumValN(Ptr32bits, "32", "Use 32 bit indices for pointers"),
   clEnumValN(Ptr16bits, "16", "Use 16 bit indices for pointers"),
-  clEnumValN(Ptr8bits ,  "8", "Use 8 bit indices for pointers"), 0);
+  clEnumValN(Ptr8bits ,  "8", "Use 8 bit indices for pointers"),
+                          0));
 
-static cl::Flag DisableRLE("no-pool-load-elim", "Disable pool load elimination after poolalloc pass", cl::Hidden);
+static cl::opt<bool>
+DisableRLE("no-pool-load-elim",  cl::Hidden,
+           cl::desc("Disable pool load elimination after poolalloc pass"));
 
 const Type *POINTERTYPE;
 
@@ -202,8 +203,6 @@ namespace {
 
   // Define the pass class that we implement...
   struct PoolAllocate : public Pass {
-    const char *getPassName() const { return "Pool Allocate"; }
-
     PoolAllocate() {
       switch (ReqPointerSize) {
       case Ptr32bits: POINTERTYPE = Type::UIntTy; break;
@@ -243,7 +242,7 @@ namespace {
     // to be able to see what is pool allocatable.
     //
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.addRequired(DataStructure::ID);
+      AU.addRequired<DataStructure>();
     }
 
   public:
@@ -311,6 +310,9 @@ namespace {
                            map<DSNode*, PoolInfo> &PoolDescs);
 
   };
+
+  RegisterOpt<PoolAllocate> X("poolalloc",
+                              "Pool allocate disjoint datastructures");
 }
 
 // isNotPoolableAlloc - This is a predicate that returns true if the specified
@@ -1633,9 +1635,8 @@ void PoolAllocate::CreatePools(Function *F, const vector<AllocDSNode*> &Allocs,
            "Pool type should not be abstract anymore!");
 
     // Add an allocation and a free for each pool...
-    AllocaInst *PoolAlloc
-      = new AllocaInst(PointerType::get(PI.PoolType), 0,
-                       CurModule->getTypeName(PI.PoolType));
+    AllocaInst *PoolAlloc = new AllocaInst(PI.PoolType, 0,
+                                           CurModule->getTypeName(PI.PoolType));
     PI.Handle = PoolAlloc;
     EntryNodeInsts.push_back(PoolAlloc);
     AllocationInst *AI = Allocs[i]->getAllocation();
@@ -1746,12 +1747,13 @@ bool PoolAllocate::run(Module &M) {
   DS = 0;
   return false;
 }
-#endif
 
 // createPoolAllocatePass - Global function to access the functionality of this
 // pass...
 //
 Pass *createPoolAllocatePass() { 
   assert(0 && "Pool allocator disabled!");
+  return 0;
   //return new PoolAllocate(); 
 }
+#endif