blob: 3ac176937a3c318f7b240ce30cae7f0a4e96f82b [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,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000041 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Cheng34ad6db2011-07-20 07:51:56 +000042 Reloc::Model RM, CodeModel::Model CM,
Evan Chengb95fc312011-11-16 08:38:26 +000043 CodeGenOpt::Level OL,
Evan Cheng34ad6db2011-07-20 07:51:56 +000044 bool is64Bit);
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000045
Rafael Espindola0febc462010-10-03 18:59:45 +000046 virtual const X86InstrInfo *getInstrInfo() const {
47 llvm_unreachable("getInstrInfo not implemented");
48 }
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000049 virtual const TargetFrameLowering *getFrameLowering() const {
50 return &FrameLowering;
51 }
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.
Evan Chengb95fc312011-11-16 08:38:26 +000070 virtual bool addInstSelector(PassManagerBase &PM);
71 virtual bool addPreRegAlloc(PassManagerBase &PM);
72 virtual bool addPostRegAlloc(PassManagerBase &PM);
73 virtual bool addPreEmitPass(PassManagerBase &PM);
74 virtual bool addCodeEmitter(PassManagerBase &PM,
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:
Evan Cheng43966132011-07-19 06:37:02 +000087 X86_32TargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000088 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengb95fc312011-11-16 08:38:26 +000089 Reloc::Model RM, CodeModel::Model CM,
90 CodeGenOpt::Level OL);
Rafael Espindola0febc462010-10-03 18:59:45 +000091 virtual const TargetData *getTargetData() const { return &DataLayout; }
92 virtual const X86TargetLowering *getTargetLowering() const {
93 return &TLInfo;
94 }
95 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
96 return &TSInfo;
97 }
98 virtual const X86InstrInfo *getInstrInfo() const {
99 return &InstrInfo;
100 }
101 virtual X86JITInfo *getJITInfo() {
102 return &JITInfo;
103 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000104};
105
106/// X86_64TargetMachine - X86 64-bit target machine.
107///
108class X86_64TargetMachine : public X86TargetMachine {
Rafael Espindola0febc462010-10-03 18:59:45 +0000109 const TargetData DataLayout; // Calculates type size & alignment
110 X86InstrInfo InstrInfo;
111 X86SelectionDAGInfo TSInfo;
112 X86TargetLowering TLInfo;
113 X86JITInfo JITInfo;
Evan Cheng25ab6902006-09-08 06:48:29 +0000114public:
Evan Cheng43966132011-07-19 06:37:02 +0000115 X86_64TargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +0000116 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengb95fc312011-11-16 08:38:26 +0000117 Reloc::Model RM, CodeModel::Model CM,
118 CodeGenOpt::Level OL);
Rafael Espindola0febc462010-10-03 18:59:45 +0000119 virtual const TargetData *getTargetData() const { return &DataLayout; }
120 virtual const X86TargetLowering *getTargetLowering() const {
121 return &TLInfo;
122 }
123 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
124 return &TSInfo;
125 }
126 virtual const X86InstrInfo *getInstrInfo() const {
127 return &InstrInfo;
128 }
129 virtual X86JITInfo *getJITInfo() {
130 return &JITInfo;
131 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000132};
133
Brian Gaeked0fde302003-11-11 22:41:34 +0000134} // End llvm namespace
135
Chris Lattnerb4f68ed2002-10-29 22:37:54 +0000136#endif