Fold adds and subtracts of zero immediately, instead of waiting
[oota-llvm.git] / lib / CodeGen / LLVMTargetMachine.cpp
index bae7140bfb17b5f6e7b7c603025ee764d9620abb..9a3510939c53f318c7f5c1386103eb5ea6ddfa7e 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/Collector.h"
 #include "llvm/Target/TargetOptions.h"
+#include "llvm/Target/TargetAsmInfo.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Support/CommandLine.h"
 using namespace llvm;
@@ -38,7 +39,7 @@ EnableSinking("enable-sinking", cl::init(false), cl::Hidden,
               cl::desc("Perform sinking on machine code"));
 static cl::opt<bool>
 AlignLoops("align-loops", cl::init(true), cl::Hidden,
-              cl::desc("Align loop headers"));
+           cl::desc("Align loop headers"));
 static cl::opt<bool>
 PerformLICM("machine-licm",
             cl::init(false), cl::Hidden,
@@ -66,7 +67,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
   
   PM.add(createGCLoweringPass());
 
-  if (!ExceptionHandling)
+  if (!getTargetAsmInfo()->doesSupportExceptionHandling())
     PM.add(createLowerInvokePass(getTargetLowering()));
 
   // Make sure that no unreachable blocks are instruction selected.
@@ -93,6 +94,10 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
   if (EnableSinking)
     PM.add(createMachineSinkingPass());
 
+  // Run pre-ra passes.
+  if (addPreRegAlloc(PM, Fast) && PrintMachineCode)
+    PM.add(createMachineFunctionPrinterPass(cerr));
+
   // Perform register allocation to convert to a concrete x86 representation
   PM.add(createRegisterAllocator());
   
@@ -192,7 +197,7 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM,
   
   PM.add(createGCLoweringPass());
   
-  if (!ExceptionHandling)
+  if (!getTargetAsmInfo()->doesSupportExceptionHandling())
     PM.add(createLowerInvokePass(getTargetLowering()));
   
   // Make sure that no unreachable blocks are instruction selected.
@@ -219,6 +224,10 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM,
   if (EnableSinking)
     PM.add(createMachineSinkingPass());
 
+  // Run pre-ra passes.
+  if (addPreRegAlloc(PM, Fast) && PrintMachineCode)
+    PM.add(createMachineFunctionPrinterPass(cerr));
+
   // Perform register allocation to convert to a concrete x86 representation
   PM.add(createRegisterAllocator());