Print "circular" warning message only in debug mode.
[oota-llvm.git] / lib / Target / TargetMachine.cpp
index 84149f8934b131a9b2061b9e0057d776cde7b1e3..5a0acfd4399fff9731671902e85af28d13b5afac 100644 (file)
@@ -9,9 +9,11 @@
 #include "llvm/Target/MachineInstrInfo.h"
 #include "llvm/Target/MachineCacheInfo.h"
 #include "llvm/CodeGen/PreSelection.h"
+#include "llvm/CodeGen/StackSlots.h"
 #include "llvm/CodeGen/InstrSelection.h"
 #include "llvm/CodeGen/InstrScheduling.h"
 #include "llvm/CodeGen/RegisterAllocation.h"
+#include "llvm/CodeGen/PeepholeOpts.h"
 #include "llvm/CodeGen/MachineCodeForMethod.h"
 #include "llvm/CodeGen/MachineCodeForInstruction.h"
 #include "llvm/Reoptimizer/Mapping/MappingInfo.h" 
@@ -32,6 +34,9 @@ static cl::opt<bool> DisablePreSelect("nopreselect",
 static cl::opt<bool> DisableSched("nosched",
                                   cl::desc("Disable local scheduling pass"));
 
+static cl::opt<bool> DisablePeephole("nopeephole",
+                                     cl::desc("Disable peephole optimization pass"));
+
 //---------------------------------------------------------------------------
 // class TargetMachine
 // 
@@ -115,14 +120,18 @@ TargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
   // Construct and initialize the MachineCodeForMethod object for this fn.
   PM.add(new ConstructMachineCodeForFunction(*this));
 
+  //Insert empty stackslots in the stack frame of each function
+  //so %fp+offset-8 and %fp+offset-16 are empty slots now!
+  PM.add(createStackSlotsPass(*this));
+
   // Specialize LLVM code for this target machine and then
   // run basic dataflow optimizations on LLVM code.
   if (!DisablePreSelect)
     {
       PM.add(createPreSelectionPass(*this));
-      PM.add(createReassociatePass());
-      PM.add(createGCSEPass());
+      /* PM.add(createReassociatePass()); */
       PM.add(createLICMPass());
+      PM.add(createGCSEPass());
     }
 
   PM.add(createInstructionSelectionPass(*this));
@@ -132,13 +141,11 @@ TargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
 
   PM.add(getRegisterAllocator(*this));
 
-  //PM.add(new OptimizeLeafProcedures());
-  //PM.add(new DeleteFallThroughBranches());
-  //PM.add(new RemoveChainedBranches());    // should be folded with previous
-  //PM.add(new RemoveRedundantOps());       // operations with %g0, NOP, etc.
-
   PM.add(getPrologEpilogInsertionPass());
 
+  if (!DisablePeephole)
+    PM.add(createPeepholeOptsPass(*this));
+
   PM.add(MappingInfoForFunction(Out));  
 
   // Output assembly language to the .s file.  Assembly emission is split into