Move stuff out of the Optimizations directories into the appropriate Transforms
directories.  Eliminate the opt namespace.

llvm-svn: 1520
diff --git a/llvm/lib/Transforms/ExprTypeConvert.cpp b/llvm/lib/Transforms/ExprTypeConvert.cpp
index 7f33fe2..d75a8ac 100644
--- a/llvm/lib/Transforms/ExprTypeConvert.cpp
+++ b/llvm/lib/Transforms/ExprTypeConvert.cpp
@@ -12,8 +12,8 @@
 #include "llvm/iPHINode.h"
 #include "llvm/iMemory.h"
 #include "llvm/ConstantVals.h"
-#include "llvm/Optimizations/ConstantHandling.h"
-#include "llvm/Optimizations/DCE.h"
+#include "llvm/Transforms/Scalar/ConstantHandling.h"
+#include "llvm/Transforms/Scalar/DCE.h"
 #include "llvm/Analysis/Expressions.h"
 #include "Support/STLExtras.h"
 #include <map>
@@ -190,7 +190,7 @@
     // it can convert the value...
     //
     if (Constant *CPV = dyn_cast<Constant>(V))
-      if (opt::ConstantFoldCastInstruction(CPV, Ty))
+      if (ConstantFoldCastInstruction(CPV, Ty))
         return true;  // Don't worry about deallocating, it's a constant.
 
     return false;              // Otherwise, we can't convert!
@@ -369,7 +369,7 @@
     if (Constant *CPV = cast<Constant>(V)) {
       // Constants are converted by constant folding the cast that is required.
       // We assume here that all casts are implemented for constant prop.
-      Value *Result = opt::ConstantFoldCastInstruction(CPV, Ty);
+      Value *Result = ConstantFoldCastInstruction(CPV, Ty);
       assert(Result && "ConstantFoldCastInstruction Failed!!!");
       assert(Result->getType() == Ty && "Const prop of cast failed!");
 
diff --git a/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp
index 9d86c86..a71acd2 100644
--- a/llvm/lib/Transforms/IPO/InlineSimple.cpp
+++ b/llvm/lib/Transforms/IPO/InlineSimple.cpp
@@ -9,17 +9,16 @@
 //   . Has a smart heuristic for when to inline a method
 //
 // Notice that:
-//   * This pass has a habit of introducing duplicated constant pool entries, 
-//     and also opens up a lot of opportunities for constant propogation.  It is
-//     a good idea to to run a constant propogation pass, then a DCE pass 
+//   * This pass opens up a lot of opportunities for constant propogation.  It
+//     is a good idea to to run a constant propogation pass, then a DCE pass 
 //     sometime after running this pass.
 //
 // TODO: Currently this throws away all of the symbol names in the method being
-//       inlined to try to avoid name clashes.  Use a name if it's not taken
+//       inlined.  This shouldn't happen.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Optimizations/MethodInlining.h"
+#include "llvm/Transforms/MethodInlining.h"
 #include "llvm/Module.h"
 #include "llvm/Method.h"
 #include "llvm/iTerminators.h"
@@ -32,8 +31,6 @@
 
 #include "llvm/Assembly/Writer.h"
 
-using namespace opt;
-
 // RemapInstruction - Convert the instruction operands from referencing the 
 // current values into those specified by ValueMap.
 //
@@ -65,7 +62,7 @@
 // exists in the instruction stream.  Similiarly this will inline a recursive
 // method by one level.
 //
-bool opt::InlineMethod(BasicBlock::iterator CIIt) {
+bool InlineMethod(BasicBlock::iterator CIIt) {
   assert(isa<CallInst>(*CIIt) && "InlineMethod only works on CallInst nodes!");
   assert((*CIIt)->getParent() && "Instruction not embedded in basic block!");
   assert((*CIIt)->getParent()->getParent() && "Instruction not in method!");
@@ -207,7 +204,7 @@
   return true;
 }
 
-bool opt::InlineMethod(CallInst *CI) {
+bool InlineMethod(CallInst *CI) {
   assert(CI->getParent() && "CallInst not embeded in BasicBlock!");
   BasicBlock *PBB = CI->getParent();
 
@@ -248,7 +245,7 @@
   return false;
 }
 
-bool opt::MethodInlining::doMethodInlining(Method *M) {
+bool MethodInlining::doMethodInlining(Method *M) {
   bool Changed = false;
 
   // Loop through now and inline instructions a basic block at a time...
diff --git a/llvm/lib/Transforms/LevelRaise.cpp b/llvm/lib/Transforms/LevelRaise.cpp
index f140676..3886500 100644
--- a/llvm/lib/Transforms/LevelRaise.cpp
+++ b/llvm/lib/Transforms/LevelRaise.cpp
@@ -12,9 +12,9 @@
 #include "llvm/iOther.h"
 #include "llvm/iMemory.h"
 #include "llvm/ConstantVals.h"
-#include "llvm/Optimizations/ConstantHandling.h"
-#include "llvm/Optimizations/DCE.h"
-#include "llvm/Optimizations/ConstantProp.h"
+#include "llvm/Transforms/Scalar/DCE.h"
+#include "llvm/Transforms/Scalar/ConstantHandling.h"
+#include "llvm/Transforms/Scalar/ConstantProp.h"
 #include "llvm/Analysis/Expressions.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
@@ -413,8 +413,8 @@
 #if DEBUG_PEEPHOLE_INSTS
       cerr << "Processing: " << *BI;
 #endif
-      if (opt::DeadCodeElimination::dceInstruction(BIL, BI) ||
-	  opt::ConstantPropogation::doConstantPropogation(BB, BI)) {
+      if (DeadCodeElimination::dceInstruction(BIL, BI) ||
+	  ConstantPropogation::doConstantPropogation(BB, BI)) {
         Changed = true; 
 #ifdef DEBUG_PEEPHOLE_INSTS
         cerr << "DeadCode Elinated!\n";
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp
index 45a57a2..01046b0 100644
--- a/llvm/lib/Transforms/Scalar/ADCE.cpp
+++ b/llvm/lib/Transforms/Scalar/ADCE.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Optimizations/DCE.h"
+#include "llvm/Transforms/Scalar/DCE.h"
 #include "llvm/Instruction.h"
 #include "llvm/Type.h"
 #include "llvm/Analysis/Dominators.h"
@@ -297,7 +297,7 @@
 
 // doADCE - Execute the Agressive Dead Code Elimination Algorithm
 //
-bool opt::AgressiveDCE::doADCE(Method *M) {
+bool AgressiveDCE::doADCE(Method *M) {
   if (M->isExternal()) return false;
   ADCE DCE(M);
   return DCE.doADCE();
diff --git a/llvm/lib/Transforms/Scalar/ConstantProp.cpp b/llvm/lib/Transforms/Scalar/ConstantProp.cpp
index a961bad..190bd4b 100644
--- a/llvm/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstantProp.cpp
@@ -21,8 +21,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Optimizations/ConstantProp.h"
-#include "llvm/Optimizations/ConstantHandling.h"
+#include "llvm/Transforms/Scalar/ConstantProp.h"
+#include "llvm/Transforms/Scalar/ConstantHandling.h"
 #include "llvm/Module.h"
 #include "llvm/Method.h"
 #include "llvm/BasicBlock.h"
@@ -34,8 +34,7 @@
 inline static bool 
 ConstantFoldUnaryInst(BasicBlock *BB, BasicBlock::iterator &II,
                       UnaryOperator *Op, Constant *D) {
-  Constant *ReplaceWith = 
-    opt::ConstantFoldUnaryInstruction(Op->getOpcode(), D);
+  Constant *ReplaceWith = ConstantFoldUnaryInstruction(Op->getOpcode(), D);
 
   if (!ReplaceWith) return false;   // Nothing new to change...
 
@@ -57,8 +56,7 @@
 inline static bool 
 ConstantFoldCast(BasicBlock *BB, BasicBlock::iterator &II,
                  CastInst *CI, Constant *D) {
-  Constant *ReplaceWith = 
-    opt::ConstantFoldCastInstruction(D, CI->getType());
+  Constant *ReplaceWith = ConstantFoldCastInstruction(D, CI->getType());
 
   if (!ReplaceWith) return false;   // Nothing new to change...
 
@@ -81,8 +79,7 @@
 ConstantFoldBinaryInst(BasicBlock *BB, BasicBlock::iterator &II,
 		       BinaryOperator *Op,
 		       Constant *D1, Constant *D2) {
-  Constant *ReplaceWith =
-    opt::ConstantFoldBinaryInstruction(Op->getOpcode(), D1, D2);
+  Constant *ReplaceWith = ConstantFoldBinaryInstruction(Op->getOpcode(), D1,D2);
   if (!ReplaceWith) return false;   // Nothing new to change...
 
   // Replaces all of the uses of a variable with uses of the constant.
@@ -104,7 +101,7 @@
 // constant value, convert it into an unconditional branch to the constant
 // destination.
 //
-bool opt::ConstantFoldTerminator(TerminatorInst *T) {
+bool ConstantFoldTerminator(TerminatorInst *T) {
   // Branch - See if we are conditional jumping on constant
   if (BranchInst *BI = dyn_cast<BranchInst>(T)) {
     if (BI->isUnconditional()) return false;  // Can't optimize uncond branch
@@ -156,8 +153,8 @@
 // ConstantFoldInstruction - If an instruction references constants, try to fold
 // them together...
 //
-bool opt::ConstantPropogation::doConstantPropogation(BasicBlock *BB,
-						     BasicBlock::iterator &II) {
+bool ConstantPropogation::doConstantPropogation(BasicBlock *BB,
+                                                BasicBlock::iterator &II) {
   Instruction *Inst = *II;
   if (isa<BinaryOperator>(Inst)) {
     Constant *D1 = dyn_cast<Constant>(Inst->getOperand(0));
@@ -174,7 +171,7 @@
     Constant *D = dyn_cast<Constant>(UInst->getOperand(0));
     if (D) return ConstantFoldUnaryInst(BB, II, UInst, D);
   } else if (TerminatorInst *TInst = dyn_cast<TerminatorInst>(Inst)) {
-    return opt::ConstantFoldTerminator(TInst);
+    return ConstantFoldTerminator(TInst);
 
   } else if (PHINode *PN = dyn_cast<PHINode>(Inst)) {
     // If it's a PHI node and only has one operand
@@ -203,7 +200,7 @@
   for (Method::iterator BBI = M->begin(); BBI != M->end(); ++BBI) {
     BasicBlock *BB = *BBI;
     for (BasicBlock::iterator I = BB->begin(); I != BB->end(); )
-      if (opt::ConstantPropogation::doConstantPropogation(BB, I))
+      if (ConstantPropogation::doConstantPropogation(BB, I))
 	SomethingChanged = true;
       else
 	++I;
@@ -214,7 +211,7 @@
 
 // returns whether or not the underlying method was modified
 //
-bool opt::ConstantPropogation::doConstantPropogation(Method *M) {
+bool ConstantPropogation::doConstantPropogation(Method *M) {
   bool Modified = false;
 
   // Fold constants until we make no progress...
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index eadf7b1..218c0ad 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/lib/Transforms/Scalar/DCE.cpp
@@ -23,7 +23,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Optimizations/DCE.h"
+#include "llvm/Transforms/Scalar/DCE.h"
 #include "llvm/Module.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/Method.h"
@@ -39,8 +39,8 @@
 // to point to the instruction that immediately succeeded the original
 // instruction.
 //
-bool opt::DeadCodeElimination::dceInstruction(BasicBlock::InstListType &BBIL,
-                                              BasicBlock::iterator &BBI) {
+bool DeadCodeElimination::dceInstruction(BasicBlock::InstListType &BBIL,
+                                         BasicBlock::iterator &BBI) {
   // Look for un"used" definitions...
   if ((*BBI)->use_empty() && !(*BBI)->hasSideEffects() && 
       !isa<TerminatorInst>(*BBI)) {
@@ -54,7 +54,7 @@
   bool Changed = false;
   for (BasicBlock::InstListType::iterator DI = Vals.begin(); 
        DI != Vals.end(); )
-    if (opt::DeadCodeElimination::dceInstruction(Vals, DI))
+    if (DeadCodeElimination::dceInstruction(Vals, DI))
       Changed = true;
     else
       ++DI;
@@ -155,7 +155,7 @@
 //
 // WARNING:  The entry node of a method may not be simplified.
 //
-bool opt::SimplifyCFG(Method::iterator &BBIt) {
+bool SimplifyCFG(Method::iterator &BBIt) {
   BasicBlock *BB = *BBIt;
   Method *M = BB->getParent();
 
@@ -282,7 +282,7 @@
   // if they are unneeded...
   //
   for (BBIt = M->begin(), ++BBIt; BBIt != M->end(); ) {
-    if (opt::SimplifyCFG(BBIt)) {
+    if (SimplifyCFG(BBIt)) {
       Changed = true;
     } else {
       ++BBIt;
@@ -296,13 +296,13 @@
 // It is possible that we may require multiple passes over the code to fully
 // eliminate dead code.  Iterate until we are done.
 //
-bool opt::DeadCodeElimination::doDCE(Method *M) {
+bool DeadCodeElimination::doDCE(Method *M) {
   bool Changed = false;
   while (DoDCEPass(M)) Changed = true;
   return Changed;
 }
 
-bool opt::DeadCodeElimination::RemoveUnusedGlobalValues(Module *Mod) {
+bool DeadCodeElimination::RemoveUnusedGlobalValues(Module *Mod) {
   bool Changed = false;
 
   for (Module::iterator MI = Mod->begin(); MI != Mod->end(); ) {
diff --git a/llvm/lib/Transforms/Scalar/InductionVars.cpp b/llvm/lib/Transforms/Scalar/InductionVars.cpp
index 93ab189..cab778e 100644
--- a/llvm/lib/Transforms/Scalar/InductionVars.cpp
+++ b/llvm/lib/Transforms/Scalar/InductionVars.cpp
@@ -19,7 +19,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Optimizations/InductionVars.h"
+#include "llvm/Transforms/Scalar/InductionVars.h"
 #include "llvm/ConstantVals.h"
 #include "llvm/Analysis/IntervalPartition.h"
 #include "llvm/Assembly/Writer.h"
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 795418f..2559066 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -15,12 +15,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Transforms/Scalar/InstructionCombining.h"
-#include "../TransformInternals.h"
-#include "llvm/Optimizations/ConstantHandling.h"
+#include "llvm/Transforms/Scalar/ConstantHandling.h"
 #include "llvm/Method.h"
 #include "llvm/iMemory.h"
-
-using namespace opt;
+#include "../TransformInternals.h"
 
 static Instruction *CombineBinOp(BinaryOperator *I) {
   bool Changed = false;
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 68be844..9b2343c 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -15,8 +15,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Optimizations/ConstantProp.h"
-#include "llvm/Optimizations/ConstantHandling.h"
+#include "llvm/Transforms/Scalar/ConstantProp.h"
+#include "llvm/Transforms/Scalar/ConstantHandling.h"
 #include "llvm/Method.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/ConstantVals.h"
@@ -273,7 +273,7 @@
       MadeChanges = true;
       continue;   // Skip the ++II at the end of the loop here...
     } else if (Inst->isTerminator()) {
-      MadeChanges |= opt::ConstantFoldTerminator(cast<TerminatorInst>(Inst));
+      MadeChanges |= ConstantFoldTerminator(cast<TerminatorInst>(Inst));
     }
 
     ++II;
@@ -446,9 +446,8 @@
       markOverdefined(I);
     } else if (VState.isConstant()) {    // Propogate constant value
       Constant *Result = isa<CastInst>(I)
-        ? opt::ConstantFoldCastInstruction(VState.getConstant(), I->getType())
-        : opt::ConstantFoldUnaryInstruction(I->getOpcode(),
-                                            VState.getConstant());
+        ? ConstantFoldCastInstruction(VState.getConstant(), I->getType())
+        : ConstantFoldUnaryInstruction(I->getOpcode(), VState.getConstant());
 
       if (Result) {
         // This instruction constant folds!
@@ -473,9 +472,9 @@
       markOverdefined(I);
     } else if (V1State.isConstant() && V2State.isConstant()) {
       Constant *Result =
-        opt::ConstantFoldBinaryInstruction(I->getOpcode(),
-                                             V1State.getConstant(),
-                                             V2State.getConstant());
+        ConstantFoldBinaryInstruction(I->getOpcode(),
+                                      V1State.getConstant(),
+                                      V2State.getConstant());
       if (Result) {
         // This instruction constant folds!
         markConstant(I, Result);
@@ -511,7 +510,7 @@
 // DoSparseConditionalConstantProp - Use Sparse Conditional Constant Propogation
 // to prove whether a value is constant and whether blocks are used.
 //
-bool opt::SCCPPass::doSCCP(Method *M) {
+bool SCCPPass::doSCCP(Method *M) {
   if (M->isExternal()) return false;
   SCCP S(M);
   return S.doSCCP();
diff --git a/llvm/lib/Transforms/Scalar/SymbolStripping.cpp b/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
index 417376b..12f8e91 100644
--- a/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
+++ b/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
@@ -14,7 +14,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Optimizations/AllOpts.h"
+#include "llvm/Transforms/SymbolStripping.h"
 #include "llvm/Module.h"
 #include "llvm/Method.h"
 #include "llvm/SymbolTable.h"
@@ -44,14 +44,14 @@
 
 // DoSymbolStripping - Remove all symbolic information from a method
 //
-bool opt::SymbolStripping::doSymbolStripping(Method *M) {
+bool SymbolStripping::doSymbolStripping(Method *M) {
   return StripSymbolTable(M->getSymbolTable());
 }
 
 // doStripGlobalSymbols - Remove all symbolic information from all methods 
 // in a module, and all module level symbols. (method names, etc...)
 //
-bool opt::FullSymbolStripping::doStripGlobalSymbols(Module *M) {
+bool FullSymbolStripping::doStripGlobalSymbols(Module *M) {
   // Remove all symbols from methods in this module... and then strip all of the
   // symbols in this module...
   //