Misc. new entry.
[oota-llvm.git] / lib / Target / X86 / X86TargetMachine.cpp
index b4de879750868e693c75a99a7bb08879311bfba5..2c3c5306847cda4a966630448621b5053582d3a6 100644 (file)
@@ -15,7 +15,6 @@
 #include "X86.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/Target/TargetOptions.h"
@@ -26,8 +25,6 @@
 #include <iostream>
 using namespace llvm;
 
-bool llvm::X86PatIsel = true;
-
 /// X86TargetMachineModule - Note that this is used on hosts that cannot link
 /// in a library unless there are references into the library.  In particular,
 /// it seems that it is not possible to get things to work on Win32 without
@@ -39,11 +36,6 @@ namespace {
   cl::opt<bool> DisableOutput("disable-x86-llc-output", cl::Hidden,
                               cl::desc("Disable the X86 asm printer, for use "
                                        "when profiling the code generator."));
-  cl::opt<bool, true> EnableX86PatISel("enable-x86-pattern-isel", cl::Hidden,
-                      cl::desc("Enable the pattern based isel for X86"),
-                      cl::location(X86PatIsel),
-                      cl::init(false));
-  
   // Register the target.
   RegisterTarget<X86TargetMachine> X("x86", "  IA-32 (Pentium and above)");
 }
@@ -75,14 +67,18 @@ unsigned X86TargetMachine::getModuleMatchQuality(const Module &M) {
 
 /// X86TargetMachine ctor - Create an ILP32 architecture model
 ///
-X86TargetMachine::X86TargetMachine(const Module &M,
-                                  IntrinsicLowering *IL,
-                                  const std::string &FS)
-  : TargetMachine("X86", IL, true, 4, 4, 4, 4, 4),
+X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS)
+  : TargetMachine("X86"),
     Subtarget(M, FS),
+    DataLayout("e-p:32:32-d:32-l:32"),
     FrameInfo(TargetFrameInfo::StackGrowsDown,
               Subtarget.getStackAlignment(), -4),
-    JITInfo(*this) {
+    InstrInfo(*this), JITInfo(*this), TLInfo(*this) {
+  if (getRelocationModel() == Reloc::Default)
+    if (Subtarget.isTargetDarwin())
+      setRelocationModel(Reloc::DynamicNoPIC);
+    else
+      setRelocationModel(Reloc::PIC);
 }
 
 
@@ -94,23 +90,20 @@ bool X86TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
   if (FileType != TargetMachine::AssemblyFile &&
       FileType != TargetMachine::ObjectFile) return true;
 
+  // Run loop strength reduction before anything else.
+  PM.add(createLoopStrengthReducePass(&TLInfo));
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
   // FIXME: Implement the invoke/unwind instructions!
   PM.add(createLowerInvokePass());
 
-  // FIXME: Implement the switch instruction in the instruction selector!
-  PM.add(createLowerSwitchPass());
-
   // Make sure that no unreachable blocks are instruction selected.
   PM.add(createUnreachableBlockEliminationPass());
 
   // Install an instruction selector.
-  if (X86PatIsel)
-    PM.add(createX86ISelPattern(*this));
-  else
-    PM.add(createX86ISelDag(*this));
+  PM.add(createX86ISelDag(*this));
 
   // Print the instruction selected machine code...
   if (PrintMachineCode)
@@ -159,23 +152,23 @@ bool X86TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
 /// not supported for this target.
 ///
 void X86JITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
+  // The JIT should use static relocation model.
+  TM.setRelocationModel(Reloc::Static);
+
+  // Run loop strength reduction before anything else.
+  PM.add(createLoopStrengthReducePass(TM.getTargetLowering()));
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
   // FIXME: Implement the invoke/unwind instructions!
   PM.add(createLowerInvokePass());
 
-  // FIXME: Implement the switch instruction in the instruction selector!
-  PM.add(createLowerSwitchPass());
-
   // Make sure that no unreachable blocks are instruction selected.
   PM.add(createUnreachableBlockEliminationPass());
 
   // Install an instruction selector.
-  if (X86PatIsel)
-    PM.add(createX86ISelPattern(TM));
-  else
-    PM.add(createX86ISelDag(TM));
+  PM.add(createX86ISelDag(TM));
 
   // Print the instruction selected machine code...
   if (PrintMachineCode)