Merge PPCJITInfo.h and PPC32JITInfo.h. Note that the PowerPCJITInfo
[oota-llvm.git] / lib / Target / PowerPC / PPCSubtarget.cpp
index 2c1b7839a5fc2a520586627ece6b6d483913cbd1..b0861d734566af03ca74568075a5d56e985288c8 100644 (file)
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "PowerPCSubtarget.h"
-#include "PowerPC.h"
+#include "PPCSubtarget.h"
+#include "PPC.h"
 #include "llvm/Module.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Target/SubtargetFeature.h"
@@ -25,11 +25,10 @@ namespace llvm {
   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"),
+                          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"));
 }
 
 enum PowerPCFeature {
@@ -41,25 +40,31 @@ enum PowerPCFeature {
 
 /// Sorted (by key) array of values for CPU subtype.
 static const SubtargetFeatureKV PowerPCSubTypeKV[] = {
-  { "601"    , 0 },
-  { "602"    , 0 },
-  { "603"    , 0 },
-  { "603e"   , 0 },
-  { "603ev"  , 0 },
-  { "604"    , 0 },
-  { "604e"   , 0 },
-  { "620"    , 0 },
-  { "7400"   , PowerPCFeatureAltivec },
-  { "7450"   , PowerPCFeatureAltivec },
-  { "750"    , 0 },
-  { "970"    , PowerPCFeature64Bit | PowerPCFeatureAltivec |
+  { "601"    , "Select the PowerPC 601 processor", 0 },
+  { "602"    , "Select the PowerPC 602 processor", 0 },
+  { "603"    , "Select the PowerPC 603 processor", 0 },
+  { "603e"   , "Select the PowerPC 603e processor", 0 },
+  { "603ev"  , "Select the PowerPC 603ev processor", 0 },
+  { "604"    , "Select the PowerPC 604 processor", 0 },
+  { "604e"   , "Select the PowerPC 604e processor", 0 },
+  { "620"    , "Select the PowerPC 620 processor", 0 },
+  { "7400"   , "Select the PowerPC 7400 (G4) processor",
+               PowerPCFeatureAltivec },
+  { "7450"   , "Select the PowerPC 7450 (G4+) processor",
+               PowerPCFeatureAltivec },
+  { "750"    , "Select the PowerPC 750 (G3) processor", 0 },
+  { "970"    , "Select the PowerPC 970 (G5 - GPUL) processor",
+               PowerPCFeature64Bit | PowerPCFeatureAltivec |
                PowerPCFeatureFSqrt | PowerPCFeatureGPUL },
-  { "g3"     , 0 },
-  { "g4"     , PowerPCFeatureAltivec },
-  { "g4+"    , PowerPCFeatureAltivec },
-  { "g5"     , PowerPCFeature64Bit | PowerPCFeatureAltivec |
+  { "g3"     , "Select the PowerPC G3 (750) processor", 0 },
+  { "g4"     , "Select the PowerPC G4 (7400) processor",
+               PowerPCFeatureAltivec },
+  { "g4+"    , "Select the PowerPC G4+ (7450) processor",
+               PowerPCFeatureAltivec },
+  { "g5"     , "Select the PowerPC g5 (970 - GPUL)  processor",
+               PowerPCFeature64Bit | PowerPCFeatureAltivec |
                PowerPCFeatureFSqrt | PowerPCFeatureGPUL },
-  { "generic", 0 }
+  { "generic", "Select instructions for a generic PowerPC processor", 0 }
 };
 /// Length of PowerPCSubTypeKV.
 static const unsigned PowerPCSubTypeKVSize = sizeof(PowerPCSubTypeKV)
@@ -67,10 +72,10 @@ static const unsigned PowerPCSubTypeKVSize = sizeof(PowerPCSubTypeKV)
 
 /// Sorted (by key) array of values for CPU features.
 static SubtargetFeatureKV PowerPCFeatureKV[] = {
-  { "64bit"  , PowerPCFeature64Bit   },
-  { "altivec", PowerPCFeatureAltivec },
-  { "fsqrt"  , PowerPCFeatureFSqrt },
-  { "gpul"   , PowerPCFeatureGPUL    }
+  { "64bit"  , "Should 64 bit instructions be used"  , PowerPCFeature64Bit   },
+  { "altivec", "Should Altivec instructions be used" , PowerPCFeatureAltivec },
+  { "fsqrt"  , "Should the fsqrt instruction be used", PowerPCFeatureFSqrt   },
+  { "gpul"   , "Should GPUL instructions be used"    , PowerPCFeatureGPUL    }
  };
 /// Length of PowerPCFeatureKV.
 static const unsigned PowerPCFeatureKVSize = sizeof(PowerPCFeatureKV)
@@ -118,7 +123,7 @@ PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS)
   : StackAlignment(16), IsGigaProcessor(false), IsAIX(false), IsDarwin(false) {
 
   // Determine default and user specified characteristics
-  std::string CPU;
+  std::string CPU = "generic";
 #if defined(__APPLE__)
   CPU = GetCurrentPowerPCCPU();
 #endif
@@ -126,7 +131,9 @@ PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS)
   SubtargetFeatures::Parse(FS, CPU,
                            PowerPCSubTypeKV, PowerPCSubTypeKVSize,
                            PowerPCFeatureKV, PowerPCFeatureKVSize);
-  IsGigaProcessor = (Bits & PowerPCFeatureGPUL) != 0;
+  IsGigaProcessor = (Bits & PowerPCFeatureGPUL ) != 0;
+  Is64Bit         = (Bits & PowerPCFeature64Bit) != 0;
+  HasFSQRT        = (Bits & PowerPCFeatureFSqrt) != 0;
 
   // Set the boolean corresponding to the current target triple, or the default
   // if one cannot be determined, to true.
@@ -140,7 +147,4 @@ PPCSubtarget::PPCSubtarget(const Module &M, const std::string &FS)
     IsDarwin = true;
 #endif
   }
-  
-  // If GP opts are forced on by the commandline, do so now.
-  if (EnableGPOPT) IsGigaProcessor = true;
 }