blob: 7d5e5ce4e96b822f214207d21c2edf1dc395f099 [file] [log] [blame]
Chris Lattnerb4f68ed2002-10-29 22:37:54 +00001//===-- 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 Gaekee48ec012002-12-13 06:46:31 +00008#include "llvm/Transforms/Scalar.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +00009#include "llvm/Target/TargetMachineImpls.h"
Chris Lattner3dffa792002-10-30 00:47:49 +000010#include "llvm/CodeGen/MachineFunction.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000011#include "llvm/PassManager.h"
12#include "X86.h"
13#include <iostream>
14
15// allocateX86TargetMachine - Allocate and return a subclass of TargetMachine
16// that implements the X86 backend.
17//
18TargetMachine *allocateX86TargetMachine() { return new X86TargetMachine(); }
19
20
21/// X86TargetMachine ctor - Create an ILP32 architecture model
22///
23X86TargetMachine::X86TargetMachine() : TargetMachine("X86", 1, 4, 4, 4) {
24}
25
26
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.
30///
31bool X86TargetMachine::addPassesToJITCompile(PassManager &PM) {
Brian Gaekee48ec012002-12-13 06:46:31 +000032 // 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());
36
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000037 PM.add(createSimpleX86InstructionSelector(*this));
38
39 // TODO: optional optimizations go here
40
Chris Lattner3dffa792002-10-30 00:47:49 +000041 // Print the instruction selected machine code...
42 PM.add(createMachineFunctionPrinterPass());
43
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000044 // Perform register allocation to convert to a concrete x86 representation
Misha Brukmanf88a2852002-11-22 22:45:07 +000045 PM.add(createSimpleX86RegisterAllocator(*this));
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000046
Misha Brukmanf88a2852002-11-22 22:45:07 +000047 // Print the instruction selected machine code...
48 // PM.add(createMachineFunctionPrinterPass());
49
50 // Print the register-allocated code
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000051 PM.add(createX86CodePrinterPass(*this, std::cerr));
52
53 //PM.add(createEmitX86CodeToMemory(*this));
54
55 return false; // success!
56}
57