Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 1 | //===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===// |
| 2 | // |
| 3 | // This file defines the X86 specific subclass of TargetMachine. |
| 4 | // |
| 5 | //===----------------------------------------------------------------------===// |
| 6 | |
| 7 | #include "X86TargetMachine.h" |
Brian Gaeke | e48ec01 | 2002-12-13 06:46:31 +0000 | [diff] [blame] | 8 | #include "llvm/Transforms/Scalar.h" |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 9 | #include "llvm/Target/TargetMachineImpls.h" |
Chris Lattner | 3dffa79 | 2002-10-30 00:47:49 +0000 | [diff] [blame] | 10 | #include "llvm/CodeGen/MachineFunction.h" |
Misha Brukman | b8ead9d | 2002-12-13 13:16:14 +0000 | [diff] [blame^] | 11 | #include "Support/Statistic.h" |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 12 | #include "llvm/PassManager.h" |
| 13 | #include "X86.h" |
| 14 | #include <iostream> |
| 15 | |
| 16 | // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine |
| 17 | // that implements the X86 backend. |
| 18 | // |
| 19 | TargetMachine *allocateX86TargetMachine() { return new X86TargetMachine(); } |
| 20 | |
| 21 | |
| 22 | /// X86TargetMachine ctor - Create an ILP32 architecture model |
| 23 | /// |
| 24 | X86TargetMachine::X86TargetMachine() : TargetMachine("X86", 1, 4, 4, 4) { |
| 25 | } |
| 26 | |
| 27 | |
| 28 | /// addPassesToJITCompile - Add passes to the specified pass manager to |
| 29 | /// implement a fast dynamic compiler for this target. Return true if this is |
| 30 | /// not supported for this target. |
| 31 | /// |
| 32 | bool X86TargetMachine::addPassesToJITCompile(PassManager &PM) { |
Brian Gaeke | e48ec01 | 2002-12-13 06:46:31 +0000 | [diff] [blame] | 33 | // For the moment we have decided that malloc and free will be |
| 34 | // taken care of by converting them to calls, using the existing |
| 35 | // LLVM scalar transforms pass to do this. |
| 36 | PM.add(createLowerAllocationsPass()); |
| 37 | |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 38 | PM.add(createSimpleX86InstructionSelector(*this)); |
| 39 | |
| 40 | // TODO: optional optimizations go here |
| 41 | |
Chris Lattner | 3dffa79 | 2002-10-30 00:47:49 +0000 | [diff] [blame] | 42 | // Print the instruction selected machine code... |
Misha Brukman | b8ead9d | 2002-12-13 13:16:14 +0000 | [diff] [blame^] | 43 | DEBUG(PM.add(createMachineFunctionPrinterPass())); |
Chris Lattner | 3dffa79 | 2002-10-30 00:47:49 +0000 | [diff] [blame] | 44 | |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 45 | // Perform register allocation to convert to a concrete x86 representation |
Misha Brukman | f88a285 | 2002-11-22 22:45:07 +0000 | [diff] [blame] | 46 | PM.add(createSimpleX86RegisterAllocator(*this)); |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 47 | |
Misha Brukman | f88a285 | 2002-11-22 22:45:07 +0000 | [diff] [blame] | 48 | // Print the instruction selected machine code... |
| 49 | // PM.add(createMachineFunctionPrinterPass()); |
| 50 | |
| 51 | // Print the register-allocated code |
Misha Brukman | b8ead9d | 2002-12-13 13:16:14 +0000 | [diff] [blame^] | 52 | DEBUG(PM.add(createX86CodePrinterPass(*this, std::cerr))); |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 53 | |
| 54 | return false; // success! |
| 55 | } |
| 56 | |