Large scale changes to implement new command line argument facility


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp
index 4843a70..0ad1dbd 100644
--- a/lib/CodeGen/InstrSelection/InstrSelection.cpp
+++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp
@@ -10,8 +10,6 @@
 //***************************************************************************
 
 
-//*************************** User Include Files ***************************/
-
 #include "llvm/CodeGen/InstrSelection.h"
 #include "llvm/Method.h"
 #include "llvm/BasicBlock.h"
@@ -20,7 +18,20 @@
 #include "llvm/Instruction.h"
 #include "llvm/LLC/CompileContext.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/Tools/CommandLine.h"
 
+enum DebugLev {
+  NoDebugInfo,
+  DebugInstTrees, 
+  DebugBurgTrees,
+};
+
+// Enable Debug Options to be specified on the command line
+cl::Enum<enum DebugLev> DebugLevel("debug_select", cl::NoFlags, // cl::Hidden
+   "enable instruction selection debugging information",
+   clEnumVal(NoDebugInfo   , "disable debug output"),
+   clEnumVal(DebugInstTrees, "print instruction trees"),
+   clEnumVal(DebugBurgTrees, "print burg trees"), 0);
 
 //************************* Forward Declarations ***************************/
 
@@ -36,8 +47,7 @@
 // Returns true if instruction selection failed, false otherwise.
 //---------------------------------------------------------------------------
 
-bool SelectInstructionsForMethod(Method* method, CompileContext& ccontext,
-				 int DebugLevel) {
+bool SelectInstructionsForMethod(Method* method, CompileContext& ccontext) {
   bool failed = false;
   
   InstrForest instrForest;
@@ -59,7 +69,7 @@
       // Invoke BURM to label each tree node with a state
       (void) burm_label(basicNode);
       
-      if (DebugLevel >= DEBUG_BURG_TREES)
+      if (DebugLevel.getValue() >= DebugBurgTrees)
 	{
 	  printcover(basicNode, 1, 0);
 	  cerr << "\nCover cost == " << treecost(basicNode, 1, 0) << "\n\n";
@@ -76,7 +86,7 @@
   
   if (!failed)
     {
-      if (DebugLevel >= DEBUG_INSTR_TREES)
+      if (DebugLevel.getValue() >= DebugInstTrees)
 	{
 	  cout << "\n\n*** Instruction trees for method "
 	       << (method->hasName()? method->getName() : "")
@@ -84,7 +94,7 @@
 	  instrForest.dump();
 	}
       
-      if (DebugLevel >= DEBUG_TREES_NONE)
+      if (DebugLevel.getValue() > NoDebugInfo)
 	PrintMachineInstructions(method);
     }