#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"
#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
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)");
}
/// 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);
}
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)
/// 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)