blob: 8ba7a71b2c5cb2dde4d634c0136a93c87890755f [file] [log] [blame]
Chris Lattnerb4f68ed2002-10-29 22:37:54 +00001//===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===//
Misha Brukman0e0a7a452005-04-21 23:38:14 +00002//
John Criswell856ba762003-10-21 15:17:13 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman0e0a7a452005-04-21 23:38:14 +00007//
John Criswell856ba762003-10-21 15:17:13 +00008//===----------------------------------------------------------------------===//
Misha Brukman0e0a7a452005-04-21 23:38:14 +00009//
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000010// This file declares the X86 specific subclass of TargetMachine.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef X86TARGETMACHINE_H
15#define X86TARGETMACHINE_H
16
Evan Chengc4c62572006-03-13 23:20:37 +000017#include "X86.h"
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000018#include "X86ELFWriterInfo.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000019#include "X86InstrInfo.h"
Evan Chengc4c62572006-03-13 23:20:37 +000020#include "X86ISelLowering.h"
Anton Korobeynikov33464912010-11-15 00:06:54 +000021#include "X86FrameInfo.h"
22#include "X86JITInfo.h"
Dan Gohmanff7a5622010-05-11 17:31:57 +000023#include "X86SelectionDAGInfo.h"
Anton Korobeynikov33464912010-11-15 00:06:54 +000024#include "X86Subtarget.h"
25#include "llvm/Target/TargetMachine.h"
26#include "llvm/Target/TargetData.h"
27#include "llvm/Target/TargetFrameInfo.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000028
Brian Gaeked0fde302003-11-11 22:41:34 +000029namespace llvm {
Owen Andersoncb371882008-08-21 00:14:44 +000030
David Greene71847812009-07-14 20:18:05 +000031class formatted_raw_ostream;
Brian Gaeked0fde302003-11-11 22:41:34 +000032
Chris Lattner1911fd42006-09-04 04:14:57 +000033class X86TargetMachine : public LLVMTargetMachine {
Evan Chengc4c62572006-03-13 23:20:37 +000034 X86Subtarget Subtarget;
Anton Korobeynikov33464912010-11-15 00:06:54 +000035 X86FrameInfo FrameInfo;
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000036 X86ELFWriterInfo ELFWriterInfo;
Evan Chengaabe38b2007-12-22 09:40:20 +000037 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000038
Eric Christopherf4f43cb2009-12-21 08:15:29 +000039private:
40 // We have specific defaults for X86.
41 virtual void setCodeModelForJIT();
42 virtual void setCodeModelForStatic();
43
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000044public:
Daniel Dunbare28039c2009-08-02 23:37:13 +000045 X86TargetMachine(const Target &T, const std::string &TT,
46 const std::string &FS, bool is64Bit);
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000047
Rafael Espindola0febc462010-10-03 18:59:45 +000048 virtual const X86InstrInfo *getInstrInfo() const {
49 llvm_unreachable("getInstrInfo not implemented");
50 }
Chris Lattnerd029cd22004-06-02 05:55:25 +000051 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
Rafael Espindola0febc462010-10-03 18:59:45 +000052 virtual X86JITInfo *getJITInfo() {
53 llvm_unreachable("getJITInfo not implemented");
54 }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000055 virtual const X86Subtarget *getSubtargetImpl() const{ return &Subtarget; }
Rafael Espindola0febc462010-10-03 18:59:45 +000056 virtual const X86TargetLowering *getTargetLowering() const {
57 llvm_unreachable("getTargetLowering not implemented");
Chris Lattner98d0d7d2006-05-12 21:14:20 +000058 }
Dan Gohmanff7a5622010-05-11 17:31:57 +000059 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
Rafael Espindola0febc462010-10-03 18:59:45 +000060 llvm_unreachable("getSelectionDAGInfo not implemented");
Dan Gohmanff7a5622010-05-11 17:31:57 +000061 }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000062 virtual const X86RegisterInfo *getRegisterInfo() const {
Rafael Espindola0febc462010-10-03 18:59:45 +000063 return &getInstrInfo()->getRegisterInfo();
Chris Lattnerfde4b512002-12-28 20:33:52 +000064 }
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000065 virtual const X86ELFWriterInfo *getELFWriterInfo() const {
Bill Wendlingeb1ac332007-02-08 01:39:44 +000066 return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000067 }
Chris Lattnerfde4b512002-12-28 20:33:52 +000068
Chris Lattner1911fd42006-09-04 04:14:57 +000069 // Set up the pass pipeline.
Bill Wendling98a366d2009-04-29 23:29:43 +000070 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
71 virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
72 virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +000073 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Bill Wendling98a366d2009-04-29 23:29:43 +000074 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000075 JITCodeEmitter &JCE);
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000076};
Evan Cheng25ab6902006-09-08 06:48:29 +000077
78/// X86_32TargetMachine - X86 32-bit target machine.
79///
80class X86_32TargetMachine : public X86TargetMachine {
Rafael Espindola0febc462010-10-03 18:59:45 +000081 const TargetData DataLayout; // Calculates type size & alignment
82 X86InstrInfo InstrInfo;
83 X86SelectionDAGInfo TSInfo;
84 X86TargetLowering TLInfo;
85 X86JITInfo JITInfo;
Evan Cheng25ab6902006-09-08 06:48:29 +000086public:
Daniel Dunbare28039c2009-08-02 23:37:13 +000087 X86_32TargetMachine(const Target &T, const std::string &M,
88 const std::string &FS);
Rafael Espindola0febc462010-10-03 18:59:45 +000089 virtual const TargetData *getTargetData() const { return &DataLayout; }
90 virtual const X86TargetLowering *getTargetLowering() const {
91 return &TLInfo;
92 }
93 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
94 return &TSInfo;
95 }
96 virtual const X86InstrInfo *getInstrInfo() const {
97 return &InstrInfo;
98 }
99 virtual X86JITInfo *getJITInfo() {
100 return &JITInfo;
101 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000102};
103
104/// X86_64TargetMachine - X86 64-bit target machine.
105///
106class X86_64TargetMachine : public X86TargetMachine {
Rafael Espindola0febc462010-10-03 18:59:45 +0000107 const TargetData DataLayout; // Calculates type size & alignment
108 X86InstrInfo InstrInfo;
109 X86SelectionDAGInfo TSInfo;
110 X86TargetLowering TLInfo;
111 X86JITInfo JITInfo;
Evan Cheng25ab6902006-09-08 06:48:29 +0000112public:
Daniel Dunbare28039c2009-08-02 23:37:13 +0000113 X86_64TargetMachine(const Target &T, const std::string &TT,
114 const std::string &FS);
Rafael Espindola0febc462010-10-03 18:59:45 +0000115 virtual const TargetData *getTargetData() const { return &DataLayout; }
116 virtual const X86TargetLowering *getTargetLowering() const {
117 return &TLInfo;
118 }
119 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
120 return &TSInfo;
121 }
122 virtual const X86InstrInfo *getInstrInfo() const {
123 return &InstrInfo;
124 }
125 virtual X86JITInfo *getJITInfo() {
126 return &JITInfo;
127 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000128};
129
Brian Gaeked0fde302003-11-11 22:41:34 +0000130} // End llvm namespace
131
Chris Lattnerb4f68ed2002-10-29 22:37:54 +0000132#endif