Implement cast bool to X
[oota-llvm.git] / lib / Target / X86 / X86TargetMachine.cpp
index 4273dafefcf5eb99f4cac448ce7e5172ff60818c..7d5e5ce4e96b822f214207d21c2edf1dc395f099 100644 (file)
@@ -5,7 +5,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "X86TargetMachine.h"
+#include "llvm/Transforms/Scalar.h"
 #include "llvm/Target/TargetMachineImpls.h"
+#include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/PassManager.h"
 #include "X86.h"
 #include <iostream>
@@ -27,13 +29,25 @@ 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());
+
   // Perform register allocation to convert to a concrete x86 representation
-  //PM.add(createSimpleX86RegisterAllocator(*this));
+  PM.add(createSimpleX86RegisterAllocator(*this));
+
+  // Print the instruction selected machine code...
+  // PM.add(createMachineFunctionPrinterPass());
 
+  // Print the register-allocated code
   PM.add(createX86CodePrinterPass(*this, std::cerr));
 
   //PM.add(createEmitX86CodeToMemory(*this));