1 //===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===//
3 // This file defines the X86 specific subclass of TargetMachine.
5 //===----------------------------------------------------------------------===//
7 #include "X86TargetMachine.h"
8 #include "llvm/Transforms/Scalar.h"
9 #include "llvm/Target/TargetMachineImpls.h"
10 #include "llvm/CodeGen/MachineFunction.h"
11 #include "llvm/PassManager.h"
13 #include "Support/CommandLine.h"
14 #include "Support/Statistic.h"
18 cl::opt<bool> NoLocalRA("no-local-ra",
19 cl::desc("Use Simple RA instead of Local RegAlloc"));
22 // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine
23 // that implements the X86 backend.
25 TargetMachine *allocateX86TargetMachine() { return new X86TargetMachine(); }
28 /// X86TargetMachine ctor - Create an ILP32 architecture model
30 X86TargetMachine::X86TargetMachine() : TargetMachine("X86", 1, 4, 4, 4) {
34 /// addPassesToJITCompile - Add passes to the specified pass manager to
35 /// implement a fast dynamic compiler for this target. Return true if this is
36 /// not supported for this target.
38 bool X86TargetMachine::addPassesToJITCompile(PassManager &PM) {
39 // For the moment we have decided that malloc and free will be
40 // taken care of by converting them to calls, using the existing
41 // LLVM scalar transforms pass to do this.
42 PM.add(createLowerAllocationsPass());
44 PM.add(createSimpleX86InstructionSelector(*this));
46 // TODO: optional optimizations go here
48 // Print the instruction selected machine code...
49 DEBUG(PM.add(createMachineFunctionPrinterPass()));
51 // Perform register allocation to convert to a concrete x86 representation
53 PM.add(createSimpleRegisterAllocator(*this));
55 PM.add(createLocalRegisterAllocator(*this));
57 // Print the instruction selected machine code...
58 // PM.add(createMachineFunctionPrinterPass());
60 // Print the register-allocated code
61 DEBUG(PM.add(createX86CodePrinterPass(*this, std::cerr)));
63 return false; // success!