Make function code generation printing debug-only.
[oota-llvm.git] / lib / Target / X86 / X86TargetMachine.cpp
index 50780fa61d5522af4ca4671fd25adabadd9dbc0e..b3c84fb821ab0bf1e40a315dcd8c13854cd5a655 100644 (file)
@@ -5,8 +5,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "X86TargetMachine.h"
+#include "llvm/Transforms/Scalar.h"
 #include "llvm/Target/TargetMachineImpls.h"
 #include "llvm/CodeGen/MachineFunction.h"
+#include "Support/Statistic.h"
 #include "llvm/PassManager.h"
 #include "X86.h"
 #include <iostream>
@@ -28,19 +30,26 @@ X86TargetMachine::X86TargetMachine() : TargetMachine("X86", 1, 4, 4, 4) {
 /// not supported for this target.
 ///
 bool X86TargetMachine::addPassesToJITCompile(PassManager &PM) {
+  // For the moment we have decided that malloc and free will be
+  // taken care of by converting them to calls, using the existing
+  // LLVM scalar transforms pass to do this.
+  PM.add(createLowerAllocationsPass());
+
   PM.add(createSimpleX86InstructionSelector(*this));
 
   // TODO: optional optimizations go here
 
   // Print the instruction selected machine code...
-  PM.add(createMachineFunctionPrinterPass());
+  DEBUG(PM.add(createMachineFunctionPrinterPass()));
 
   // Perform register allocation to convert to a concrete x86 representation
-  //PM.add(createSimpleX86RegisterAllocator(*this));
+  PM.add(createSimpleX86RegisterAllocator(*this));
 
-  PM.add(createX86CodePrinterPass(*this, std::cerr));
+  // Print the instruction selected machine code...
+  // PM.add(createMachineFunctionPrinterPass());
 
-  //PM.add(createEmitX86CodeToMemory(*this));
+  // Print the register-allocated code
+  DEBUG(PM.add(createX86CodePrinterPass(*this, std::cerr)));
 
   return false; // success!
 }