wrap a long line
[oota-llvm.git] / lib / Target / PowerPC / PPCTargetMachine.cpp
index a1637a0d26ad925bb3abb9366211e61f290b3447..dd40e1333c7b1f5c2641ffdfb2f0d0c0646efb0c 100644 (file)
@@ -33,6 +33,10 @@ namespace llvm {
   cl::opt<bool> AIX("aix", 
                     cl::desc("Generate AIX/xcoff instead of Darwin/MachO"), 
                     cl::Hidden);
+
+  cl::opt<bool> EnablePPCLSR("enable-lsr-for-ppc", 
+                             cl::desc("Enable LSR for PPC (beta option!)"), 
+                             cl::Hidden);
 }
 
 namespace {
@@ -57,7 +61,6 @@ PowerPCTargetMachine::PowerPCTargetMachine(const std::string &name,
 {}
 
 unsigned PPC32TargetMachine::getJITMatchQuality() {
-  return 0;
 #if defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)
   return 10;
 #else
@@ -71,6 +74,11 @@ unsigned PPC32TargetMachine::getJITMatchQuality() {
 bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
                                                    std::ostream &Out) {
   bool LP64 = (0 != dynamic_cast<PPC64TargetMachine *>(this));
+
+  if (EnablePPCLSR) {
+    PM.add(createLoopStrengthReducePass());
+    PM.add(createCFGSimplificationPass());
+  }
   
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
@@ -114,6 +122,11 @@ bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
 }
 
 void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
+  if (EnablePPCLSR) {
+    PM.add(createLoopStrengthReducePass());
+    PM.add(createCFGSimplificationPass());
+  }
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
@@ -143,20 +156,25 @@ void PowerPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
 ///
 PPC32TargetMachine::PPC32TargetMachine(const Module &M, IntrinsicLowering *IL)
   : PowerPCTargetMachine(PPC32ID, IL, 
-                         TargetData(PPC32ID,false,4,4,4,4,4,4,2,1,4),
+                         TargetData(PPC32ID,false,4,4,4,4,4,4,2,1,1),
                          PowerPCFrameInfo(*this, false)), JITInfo(*this) {}
 
 /// PPC64TargetMachine ctor - Create a LP64 architecture model
 ///
 PPC64TargetMachine::PPC64TargetMachine(const Module &M, IntrinsicLowering *IL)
   : PowerPCTargetMachine(PPC64ID, IL,
-                         TargetData(PPC64ID,false,8,4,4,4,4,4,2,1,4),
+                         TargetData(PPC64ID,false,8,4,4,4,4,4,2,1,1),
                          PowerPCFrameInfo(*this, true)) {}
 
 unsigned PPC32TargetMachine::getModuleMatchQuality(const Module &M) {
+  // We strongly match "powerpc-*".
+  std::string TT = M.getTargetTriple();
+  if (TT.size() >= 8 && std::string(TT.begin(), TT.begin()+8) == "powerpc-")
+    return 20;
+
   if (M.getEndianness()  == Module::BigEndian &&
       M.getPointerSize() == Module::Pointer32)
-    return 10;                                   // Direct match
+    return 10;                                   // Weak match
   else if (M.getEndianness() != Module::AnyEndianness ||
            M.getPointerSize() != Module::AnyPointerSize)
     return 0;                                    // Match for some other target