Exception handling has been implemented.
[oota-llvm.git] / lib / CodeGen / LLVMTargetMachine.cpp
index 641c04653a07a2f68b24cf99ad2f201cb5729836..4e3982df62aa1c9f2d4160e80fa949ef719b74df 100644 (file)
 #include "llvm/Support/CommandLine.h"
 using namespace llvm;
 
-static cl::opt<bool> PrintLSR("print-lsr-output");
+static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden,
+    cl::desc("Print LLVM IR produced by the loop-reduce pass"));
+static cl::opt<bool> PrintISelInput("print-isel-input", cl::Hidden,
+    cl::desc("Print LLVM IR input to isel pass"));
 
 FileModel::Model
 LLVMTargetMachine::addPassesToEmitFile(FunctionPassManager &PM,
@@ -40,14 +43,20 @@ LLVMTargetMachine::addPassesToEmitFile(FunctionPassManager &PM,
   
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
-  
-  // FIXME: Implement the invoke/unwind instructions!
+
   if (!ExceptionHandling)
     PM.add(createLowerInvokePass(getTargetLowering()));
-  
+
   // Make sure that no unreachable blocks are instruction selected.
   PM.add(createUnreachableBlockEliminationPass());
 
+  if (!Fast)
+    PM.add(createCodeGenPreparePass(getTargetLowering()));
+
+  if (PrintISelInput)
+    PM.add(new PrintFunctionPass("\n\n*** Final LLVM Code input to ISel *** \n",
+                                 &cerr));
+  
   // Ask the target for an isel.
   if (addInstSelector(PM, Fast))
     return FileModel::Error;
@@ -71,7 +80,7 @@ LLVMTargetMachine::addPassesToEmitFile(FunctionPassManager &PM,
   
   // Branch folding must be run after regalloc and prolog/epilog insertion.
   if (!Fast)
-    PM.add(createBranchFoldingPass());
+    PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
     
   // Fold redundant debug labels.
   PM.add(createDebugLabelFoldingPass());
@@ -126,7 +135,11 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
   // Standard LLVM-Level Passes.
   
   // Run loop strength reduction before anything else.
-  if (!Fast) PM.add(createLoopStrengthReducePass(getTargetLowering()));
+  if (!Fast) {
+    PM.add(createLoopStrengthReducePass(getTargetLowering()));
+    if (PrintLSR)
+      PM.add(new PrintFunctionPass("\n\n*** Code after LSR *** \n", &cerr));
+  }
   
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
@@ -137,6 +150,13 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
   // Make sure that no unreachable blocks are instruction selected.
   PM.add(createUnreachableBlockEliminationPass());
 
+  if (!Fast)
+    PM.add(createCodeGenPreparePass(getTargetLowering()));
+
+  if (PrintISelInput)
+    PM.add(new PrintFunctionPass("\n\n*** Final LLVM Code input to ISel *** \n",
+                                 &cerr));
+
   // Ask the target for an isel.
   if (addInstSelector(PM, Fast))
     return true;
@@ -163,7 +183,7 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
   
   // Branch folding must be run after regalloc and prolog/epilog insertion.
   if (!Fast)
-    PM.add(createBranchFoldingPass());
+    PM.add(createBranchFoldingPass(getEnableTailMergeDefault()));
   
   if (addPreEmitPass(PM, Fast) && PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));