Consolidate the GPOpt stuff to all use the Subtarget, instead of still
depending on the command line option.  Now the command line option just
sets the subtarget as appropriate.  G5 opts will now default to on on
G5-enabled nightly testers among other machines.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22688 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/PowerPC/PPCSubtarget.cpp b/lib/Target/PowerPC/PPCSubtarget.cpp
index 3bfa7a6..686c11c 100644
--- a/lib/Target/PowerPC/PPCSubtarget.cpp
+++ b/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -12,7 +12,23 @@
 //===----------------------------------------------------------------------===//
 
 #include "PowerPCSubtarget.h"
+#include "PowerPC.h"
 #include "llvm/Module.h"
+#include "llvm/Support/CommandLine.h"
+using namespace llvm;
+PPCTargetEnum llvm::PPCTarget = TargetDefault;
+
+namespace llvm {
+  cl::opt<PPCTargetEnum, true>
+  PPCTargetArg(cl::desc("Force generation of code for a specific PPC target:"),
+               cl::values(
+                          clEnumValN(TargetAIX,  "aix", "  Enable AIX codegen"),
+                          clEnumValN(TargetDarwin,"darwin","  Enable Darwin codegen"),
+                          clEnumValEnd),
+               cl::location(PPCTarget), cl::init(TargetDefault));
+  cl::opt<bool> EnableGPOPT("enable-gpopt", cl::Hidden,
+                             cl::desc("Enable optimizations for GP cpus"));
+}
 
 #if defined(__APPLE__)
 #include <mach/mach.h>
@@ -33,25 +49,26 @@
 } 
 #endif
 
-using namespace llvm;
-
 PPCSubtarget::PPCSubtarget(const Module &M)
-  : TargetSubtarget(), stackAlignment(16), isGigaProcessor(false), isAIX(false),
-    isDarwin(false) {
-  // Set the boolean corresponding to the current target triple, or the default
+  : StackAlignment(16), IsGigaProcessor(false), IsAIX(false), IsDarwin(false) {
+
+    // Set the boolean corresponding to the current target triple, or the default
   // if one cannot be determined, to true.
   const std::string& TT = M.getTargetTriple();
   if (TT.length() > 5) {
-    isDarwin = TT.find("darwin") != std::string::npos;
+    IsDarwin = TT.find("darwin") != std::string::npos;
 #if defined(__APPLE__)
-    isGigaProcessor = IsGP();
+    IsGigaProcessor = IsGP();
 #endif
   } else if (TT.empty()) {
 #if defined(_POWER)
-    isAIX = true;
+    IsAIX = true;
 #elif defined(__APPLE__)
-    isDarwin = true;
-    isGigaProcessor = IsGP();
+    IsDarwin = true;
+    IsGigaProcessor = IsGP();
 #endif
   }
+  
+  // If GP opts are forced on by the commandline, do so now.
+  if (EnableGPOPT) IsGigaProcessor = true;
 }