blob: d1569aa9d75100fa4c8171ec663c8bf0bee62afb [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 Korobeynikov16c29b52011-01-10 12:39:04 +000021#include "X86FrameLowering.h"
Anton Korobeynikov33464912010-11-15 00:06:54 +000022#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"
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000027#include "llvm/Target/TargetFrameLowering.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;
Evan Cheng43966132011-07-19 06:37:02 +000032class StringRef;
Brian Gaeked0fde302003-11-11 22:41:34 +000033
Chris Lattner1911fd42006-09-04 04:14:57 +000034class X86TargetMachine : public LLVMTargetMachine {
Evan Chengc4c62572006-03-13 23:20:37 +000035 X86Subtarget Subtarget;
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000036 X86FrameLowering FrameLowering;
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000037 X86ELFWriterInfo ELFWriterInfo;
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000038
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000039public:
Evan Cheng43966132011-07-19 06:37:02 +000040 X86TargetMachine(const Target &T, StringRef TT,
41 StringRef CPU, StringRef FS,
Evan Cheng34ad6db2011-07-20 07:51:56 +000042 Reloc::Model RM, CodeModel::Model CM,
43 bool is64Bit);
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000044
Rafael Espindola0febc462010-10-03 18:59:45 +000045 virtual const X86InstrInfo *getInstrInfo() const {
46 llvm_unreachable("getInstrInfo not implemented");
47 }
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000048 virtual const TargetFrameLowering *getFrameLowering() const {
49 return &FrameLowering;
50 }
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:
Evan Cheng43966132011-07-19 06:37:02 +000086 X86_32TargetMachine(const Target &T, StringRef TT,
Evan Cheng34ad6db2011-07-20 07:51:56 +000087 StringRef CPU, StringRef FS,
88 Reloc::Model RM, CodeModel::Model CM);
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:
Evan Cheng43966132011-07-19 06:37:02 +0000113 X86_64TargetMachine(const Target &T, StringRef TT,
Evan Cheng34ad6db2011-07-20 07:51:56 +0000114 StringRef CPU, StringRef FS,
115 Reloc::Model RM, CodeModel::Model CM);
Rafael Espindola0febc462010-10-03 18:59:45 +0000116 virtual const TargetData *getTargetData() const { return &DataLayout; }
117 virtual const X86TargetLowering *getTargetLowering() const {
118 return &TLInfo;
119 }
120 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
121 return &TSInfo;
122 }
123 virtual const X86InstrInfo *getInstrInfo() const {
124 return &InstrInfo;
125 }
126 virtual X86JITInfo *getJITInfo() {
127 return &JITInfo;
128 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000129};
130
Brian Gaeked0fde302003-11-11 22:41:34 +0000131} // End llvm namespace
132
Chris Lattnerb4f68ed2002-10-29 22:37:54 +0000133#endif