blob: 2b4b3262d162426f4e13b2c0535276c0a23bfe4f [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
17#include "llvm/Target/TargetMachine.h"
Owen Anderson07000c62006-05-12 06:33:49 +000018#include "llvm/Target/TargetData.h"
Chris Lattner8bd66e62002-12-28 21:00:25 +000019#include "llvm/Target/TargetFrameInfo.h"
Evan Chengc4c62572006-03-13 23:20:37 +000020#include "X86.h"
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000021#include "X86ELFWriterInfo.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000022#include "X86InstrInfo.h"
Chris Lattner1e60a912003-12-20 01:22:19 +000023#include "X86JITInfo.h"
Nate Begemanfb5792f2005-07-12 01:41:54 +000024#include "X86Subtarget.h"
Evan Chengc4c62572006-03-13 23:20:37 +000025#include "X86ISelLowering.h"
Dan Gohmanff7a5622010-05-11 17:31:57 +000026#include "X86SelectionDAGInfo.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000027
Brian Gaeked0fde302003-11-11 22:41:34 +000028namespace llvm {
Owen Andersoncb371882008-08-21 00:14:44 +000029
David Greene71847812009-07-14 20:18:05 +000030class formatted_raw_ostream;
Brian Gaeked0fde302003-11-11 22:41:34 +000031
Chris Lattner1911fd42006-09-04 04:14:57 +000032class X86TargetMachine : public LLVMTargetMachine {
Evan Chengc4c62572006-03-13 23:20:37 +000033 X86Subtarget Subtarget;
34 TargetFrameInfo FrameInfo;
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000035 X86ELFWriterInfo ELFWriterInfo;
Evan Chengaabe38b2007-12-22 09:40:20 +000036 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000037
Eric Christopherf4f43cb2009-12-21 08:15:29 +000038private:
39 // We have specific defaults for X86.
40 virtual void setCodeModelForJIT();
41 virtual void setCodeModelForStatic();
42
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000043public:
Daniel Dunbare28039c2009-08-02 23:37:13 +000044 X86TargetMachine(const Target &T, const std::string &TT,
45 const std::string &FS, bool is64Bit);
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000046
Rafael Espindola0febc462010-10-03 18:59:45 +000047 virtual const X86InstrInfo *getInstrInfo() const {
48 llvm_unreachable("getInstrInfo not implemented");
49 }
Chris Lattnerd029cd22004-06-02 05:55:25 +000050 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
Rafael Espindola0febc462010-10-03 18:59:45 +000051 virtual X86JITInfo *getJITInfo() {
52 llvm_unreachable("getJITInfo not implemented");
53 }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000054 virtual const X86Subtarget *getSubtargetImpl() const{ return &Subtarget; }
Rafael Espindola0febc462010-10-03 18:59:45 +000055 virtual const X86TargetLowering *getTargetLowering() const {
56 llvm_unreachable("getTargetLowering not implemented");
Chris Lattner98d0d7d2006-05-12 21:14:20 +000057 }
Dan Gohmanff7a5622010-05-11 17:31:57 +000058 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
Rafael Espindola0febc462010-10-03 18:59:45 +000059 llvm_unreachable("getSelectionDAGInfo not implemented");
Dan Gohmanff7a5622010-05-11 17:31:57 +000060 }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000061 virtual const X86RegisterInfo *getRegisterInfo() const {
Rafael Espindola0febc462010-10-03 18:59:45 +000062 return &getInstrInfo()->getRegisterInfo();
Chris Lattnerfde4b512002-12-28 20:33:52 +000063 }
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000064 virtual const X86ELFWriterInfo *getELFWriterInfo() const {
Bill Wendlingeb1ac332007-02-08 01:39:44 +000065 return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000066 }
Chris Lattnerfde4b512002-12-28 20:33:52 +000067
Chris Lattner1911fd42006-09-04 04:14:57 +000068 // Set up the pass pipeline.
Bill Wendling98a366d2009-04-29 23:29:43 +000069 virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
70 virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
71 virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Jakob Stoklund Olesen352aa502010-03-25 17:25:00 +000072 virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
Bill Wendling98a366d2009-04-29 23:29:43 +000073 virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel,
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000074 JITCodeEmitter &JCE);
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000075};
Evan Cheng25ab6902006-09-08 06:48:29 +000076
77/// X86_32TargetMachine - X86 32-bit target machine.
78///
79class X86_32TargetMachine : public X86TargetMachine {
Rafael Espindola0febc462010-10-03 18:59:45 +000080 const TargetData DataLayout; // Calculates type size & alignment
81 X86InstrInfo InstrInfo;
82 X86SelectionDAGInfo TSInfo;
83 X86TargetLowering TLInfo;
84 X86JITInfo JITInfo;
Evan Cheng25ab6902006-09-08 06:48:29 +000085public:
Daniel Dunbare28039c2009-08-02 23:37:13 +000086 X86_32TargetMachine(const Target &T, const std::string &M,
87 const std::string &FS);
Rafael Espindola0febc462010-10-03 18:59:45 +000088 virtual const TargetData *getTargetData() const { return &DataLayout; }
89 virtual const X86TargetLowering *getTargetLowering() const {
90 return &TLInfo;
91 }
92 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
93 return &TSInfo;
94 }
95 virtual const X86InstrInfo *getInstrInfo() const {
96 return &InstrInfo;
97 }
98 virtual X86JITInfo *getJITInfo() {
99 return &JITInfo;
100 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000101};
102
103/// X86_64TargetMachine - X86 64-bit target machine.
104///
105class X86_64TargetMachine : public X86TargetMachine {
Rafael Espindola0febc462010-10-03 18:59:45 +0000106 const TargetData DataLayout; // Calculates type size & alignment
107 X86InstrInfo InstrInfo;
108 X86SelectionDAGInfo TSInfo;
109 X86TargetLowering TLInfo;
110 X86JITInfo JITInfo;
Evan Cheng25ab6902006-09-08 06:48:29 +0000111public:
Daniel Dunbare28039c2009-08-02 23:37:13 +0000112 X86_64TargetMachine(const Target &T, const std::string &TT,
113 const std::string &FS);
Rafael Espindola0febc462010-10-03 18:59:45 +0000114 virtual const TargetData *getTargetData() const { return &DataLayout; }
115 virtual const X86TargetLowering *getTargetLowering() const {
116 return &TLInfo;
117 }
118 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
119 return &TSInfo;
120 }
121 virtual const X86InstrInfo *getInstrInfo() const {
122 return &InstrInfo;
123 }
124 virtual X86JITInfo *getJITInfo() {
125 return &JITInfo;
126 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000127};
128
Brian Gaeked0fde302003-11-11 22:41:34 +0000129} // End llvm namespace
130
Chris Lattnerb4f68ed2002-10-29 22:37:54 +0000131#endif