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"
15 // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine
16 // that implements the X86 backend.
18 TargetMachine *allocateX86TargetMachine() { return new X86TargetMachine(); }
21 /// X86TargetMachine ctor - Create an ILP32 architecture model
23 X86TargetMachine::X86TargetMachine() : TargetMachine("X86", 1, 4, 4, 4) {
27 /// addPassesToJITCompile - Add passes to the specified pass manager to
28 /// implement a fast dynamic compiler for this target. Return true if this is
29 /// not supported for this target.
31 bool X86TargetMachine::addPassesToJITCompile(PassManager &PM) {
32 // For the moment we have decided that malloc and free will be
33 // taken care of by converting them to calls, using the existing
34 // LLVM scalar transforms pass to do this.
35 PM.add(createLowerAllocationsPass());
37 PM.add(createSimpleX86InstructionSelector(*this));
39 // TODO: optional optimizations go here
41 // Print the instruction selected machine code...
42 PM.add(createMachineFunctionPrinterPass());
44 // Perform register allocation to convert to a concrete x86 representation
45 PM.add(createSimpleX86RegisterAllocator(*this));
47 // Print the instruction selected machine code...
48 // PM.add(createMachineFunctionPrinterPass());
50 // Print the register-allocated code
51 PM.add(createX86CodePrinterPass(*this, std::cerr));
53 //PM.add(createEmitX86CodeToMemory(*this));
55 return false; // success!