blob: 143caba5bd14295abd3556f8b11e36a12d1f025e [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 {
Andrew Trick8247e0d2012-02-03 05:12:30 +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 {
Andrew Trick922d3142012-02-01 23:20:51 +000035 X86Subtarget Subtarget;
36 X86FrameLowering FrameLowering;
37 X86ELFWriterInfo ELFWriterInfo;
38 InstrItineraryData InstrItins;
Jim Laskeyfde1b3b2006-09-07 23:39:26 +000039
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000040public:
Andrew Trick8247e0d2012-02-03 05:12:30 +000041 X86TargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000042 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Cheng34ad6db2011-07-20 07:51:56 +000043 Reloc::Model RM, CodeModel::Model CM,
Evan Chengb95fc312011-11-16 08:38:26 +000044 CodeGenOpt::Level OL,
Evan Cheng34ad6db2011-07-20 07:51:56 +000045 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 }
Anton Korobeynikov16c29b52011-01-10 12:39:04 +000050 virtual const TargetFrameLowering *getFrameLowering() const {
51 return &FrameLowering;
52 }
Rafael Espindola0febc462010-10-03 18:59:45 +000053 virtual X86JITInfo *getJITInfo() {
54 llvm_unreachable("getJITInfo not implemented");
55 }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000056 virtual const X86Subtarget *getSubtargetImpl() const{ return &Subtarget; }
Rafael Espindola0febc462010-10-03 18:59:45 +000057 virtual const X86TargetLowering *getTargetLowering() const {
58 llvm_unreachable("getTargetLowering not implemented");
Chris Lattner98d0d7d2006-05-12 21:14:20 +000059 }
Andrew Trick8247e0d2012-02-03 05:12:30 +000060 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
Rafael Espindola0febc462010-10-03 18:59:45 +000061 llvm_unreachable("getSelectionDAGInfo not implemented");
Dan Gohmanff7a5622010-05-11 17:31:57 +000062 }
Dan Gohmanc9f5f3f2008-05-14 01:58:56 +000063 virtual const X86RegisterInfo *getRegisterInfo() const {
Rafael Espindola0febc462010-10-03 18:59:45 +000064 return &getInstrInfo()->getRegisterInfo();
Chris Lattnerfde4b512002-12-28 20:33:52 +000065 }
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000066 virtual const X86ELFWriterInfo *getELFWriterInfo() const {
Bill Wendlingeb1ac332007-02-08 01:39:44 +000067 return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
Bill Wendlingfcdea7b2007-01-27 02:56:16 +000068 }
Andrew Trick922d3142012-02-01 23:20:51 +000069 virtual const InstrItineraryData *getInstrItineraryData() const {
70 return &InstrItins;
71 }
Chris Lattnerfde4b512002-12-28 20:33:52 +000072
Chris Lattner1911fd42006-09-04 04:14:57 +000073 // Set up the pass pipeline.
Andrew Trick061efcf2012-02-04 02:56:59 +000074 virtual TargetPassConfig *createPassConfig(PassManagerBase &PM);
Andrew Trick843ee2e2012-02-03 05:12:41 +000075
Evan Chengb95fc312011-11-16 08:38:26 +000076 virtual bool addCodeEmitter(PassManagerBase &PM,
Daniel Dunbarcfe9a602009-07-15 22:33:19 +000077 JITCodeEmitter &JCE);
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000078};
Evan Cheng25ab6902006-09-08 06:48:29 +000079
80/// X86_32TargetMachine - X86 32-bit target machine.
81///
82class X86_32TargetMachine : public X86TargetMachine {
David Blaikie2d24e2a2011-12-20 02:50:00 +000083 virtual void anchor();
Rafael Espindola0febc462010-10-03 18:59:45 +000084 const TargetData DataLayout; // Calculates type size & alignment
85 X86InstrInfo InstrInfo;
86 X86SelectionDAGInfo TSInfo;
87 X86TargetLowering TLInfo;
88 X86JITInfo JITInfo;
Evan Cheng25ab6902006-09-08 06:48:29 +000089public:
Evan Cheng43966132011-07-19 06:37:02 +000090 X86_32TargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +000091 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengb95fc312011-11-16 08:38:26 +000092 Reloc::Model RM, CodeModel::Model CM,
93 CodeGenOpt::Level OL);
Rafael Espindola0febc462010-10-03 18:59:45 +000094 virtual const TargetData *getTargetData() const { return &DataLayout; }
95 virtual const X86TargetLowering *getTargetLowering() const {
96 return &TLInfo;
97 }
Andrew Trick8247e0d2012-02-03 05:12:30 +000098 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
Rafael Espindola0febc462010-10-03 18:59:45 +000099 return &TSInfo;
100 }
101 virtual const X86InstrInfo *getInstrInfo() const {
102 return &InstrInfo;
103 }
104 virtual X86JITInfo *getJITInfo() {
105 return &JITInfo;
106 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000107};
108
109/// X86_64TargetMachine - X86 64-bit target machine.
110///
111class X86_64TargetMachine : public X86TargetMachine {
David Blaikie2d24e2a2011-12-20 02:50:00 +0000112 virtual void anchor();
Rafael Espindola0febc462010-10-03 18:59:45 +0000113 const TargetData DataLayout; // Calculates type size & alignment
114 X86InstrInfo InstrInfo;
115 X86SelectionDAGInfo TSInfo;
116 X86TargetLowering TLInfo;
117 X86JITInfo JITInfo;
Evan Cheng25ab6902006-09-08 06:48:29 +0000118public:
Evan Cheng43966132011-07-19 06:37:02 +0000119 X86_64TargetMachine(const Target &T, StringRef TT,
Nick Lewycky8a8d4792011-12-02 22:16:29 +0000120 StringRef CPU, StringRef FS, const TargetOptions &Options,
Evan Chengb95fc312011-11-16 08:38:26 +0000121 Reloc::Model RM, CodeModel::Model CM,
122 CodeGenOpt::Level OL);
Rafael Espindola0febc462010-10-03 18:59:45 +0000123 virtual const TargetData *getTargetData() const { return &DataLayout; }
124 virtual const X86TargetLowering *getTargetLowering() const {
125 return &TLInfo;
126 }
Andrew Trick8247e0d2012-02-03 05:12:30 +0000127 virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const {
Rafael Espindola0febc462010-10-03 18:59:45 +0000128 return &TSInfo;
129 }
130 virtual const X86InstrInfo *getInstrInfo() const {
131 return &InstrInfo;
132 }
133 virtual X86JITInfo *getJITInfo() {
134 return &JITInfo;
135 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000136};
137
Brian Gaeked0fde302003-11-11 22:41:34 +0000138} // End llvm namespace
139
Chris Lattnerb4f68ed2002-10-29 22:37:54 +0000140#endif