1 //===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
3 // This file defines the X86 specific subclass of TargetMachine.
5 //===----------------------------------------------------------------------===//
7 #include "X86TargetMachine.h"
9 #include "llvm/Target/TargetMachineImpls.h"
10 #include "llvm/CodeGen/MachineFunction.h"
11 #include "llvm/CodeGen/Passes.h"
12 #include "llvm/PassManager.h"
13 #include "Support/CommandLine.h"
14 #include "Support/Statistic.h"
18 cl::opt<bool> NoLocalRA("disable-local-ra",
19 cl::desc("Use Simple RA instead of Local RegAlloc"));
20 cl::opt<bool> PrintCode("print-machineinstrs",
21 cl::desc("Print generated machine code"));
24 // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine
25 // that implements the X86 backend.
27 TargetMachine *allocateX86TargetMachine(unsigned Configuration) {
28 return new X86TargetMachine(Configuration);
32 /// X86TargetMachine ctor - Create an ILP32 architecture model
34 X86TargetMachine::X86TargetMachine(unsigned Config)
35 : TargetMachine("X86",
36 (Config & TM::EndianMask) == TM::LittleEndian,
38 (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4,
39 (Config & TM::PtrSizeMask) == TM::PtrSize64 ? 8 : 4),
40 FrameInfo(TargetFrameInfo::StackGrowsDown, 8/*16 for SSE*/, 4) {
43 /// addPassesToJITCompile - Add passes to the specified pass manager to
44 /// implement a fast dynamic compiler for this target. Return true if this is
45 /// not supported for this target.
47 bool X86TargetMachine::addPassesToJITCompile(PassManager &PM) {
48 PM.add(createSimpleX86InstructionSelector(*this));
50 // TODO: optional optimizations go here
52 // FIXME: Add SSA based peephole optimizer here.
54 // Print the instruction selected machine code...
56 PM.add(createMachineFunctionPrinterPass());
58 // Perform register allocation to convert to a concrete x86 representation
60 PM.add(createSimpleRegisterAllocator());
62 PM.add(createLocalRegisterAllocator());
65 PM.add(createMachineFunctionPrinterPass());
67 PM.add(createX86FloatingPointStackifierPass());
70 PM.add(createMachineFunctionPrinterPass());
72 // Insert prolog/epilog code. Eliminate abstract frame index references...
73 PM.add(createPrologEpilogCodeInserter());
75 PM.add(createX86PeepholeOptimizerPass());
77 if (PrintCode) // Print the register-allocated code
78 PM.add(createX86CodePrinterPass(std::cerr));
80 return false; // success!