blob: eaf81df5abcc95a5643a3329632ba75cf0678db7 [file] [log] [blame]
Chris Lattner02a3d832002-10-29 22:37:54 +00001//===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00002//
John Criswell29265fe2003-10-21 15:17:13 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Brukmanc88330a2005-04-21 23:38:14 +00007//
John Criswell29265fe2003-10-21 15:17:13 +00008//===----------------------------------------------------------------------===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00009//
Chris Lattner02a3d832002-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 Anderson8c2c1e92006-05-12 06:33:49 +000018#include "llvm/Target/TargetData.h"
Chris Lattner871e5912002-12-28 21:00:25 +000019#include "llvm/Target/TargetFrameInfo.h"
Evan Cheng2dd2c652006-03-13 23:20:37 +000020#include "X86.h"
Bill Wendlingc1f10352007-01-27 02:56:16 +000021#include "X86ELFWriterInfo.h"
Chris Lattner02a3d832002-10-29 22:37:54 +000022#include "X86InstrInfo.h"
Chris Lattner833c3c22003-12-20 01:22:19 +000023#include "X86JITInfo.h"
Nate Begemanf26625e2005-07-12 01:41:54 +000024#include "X86Subtarget.h"
Evan Cheng2dd2c652006-03-13 23:20:37 +000025#include "X86ISelLowering.h"
Chris Lattner02a3d832002-10-29 22:37:54 +000026
Brian Gaeke960707c2003-11-11 22:41:34 +000027namespace llvm {
Owen Anderson93719642008-08-21 00:14:44 +000028
29class raw_ostream;
Brian Gaeke960707c2003-11-11 22:41:34 +000030
Chris Lattner12e97302006-09-04 04:14:57 +000031class X86TargetMachine : public LLVMTargetMachine {
Evan Cheng2dd2c652006-03-13 23:20:37 +000032 X86Subtarget Subtarget;
Bill Wendlingc1f10352007-01-27 02:56:16 +000033 const TargetData DataLayout; // Calculates type size & alignment
Evan Cheng2dd2c652006-03-13 23:20:37 +000034 TargetFrameInfo FrameInfo;
Evan Chengc8c172e2006-05-30 21:45:53 +000035 X86InstrInfo InstrInfo;
Evan Cheng2dd2c652006-03-13 23:20:37 +000036 X86JITInfo JITInfo;
37 X86TargetLowering TLInfo;
Bill Wendlingc1f10352007-01-27 02:56:16 +000038 X86ELFWriterInfo ELFWriterInfo;
Evan Cheng345a00b2007-12-22 09:40:20 +000039 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Jim Laskeyae92ce82006-09-07 23:39:26 +000040
41protected:
42 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +000043
44 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
45 // set this functions to ctor pointer at startup time if they are linked in.
Owen Anderson93719642008-08-21 00:14:44 +000046 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +000047 X86TargetMachine &tm);
48 static AsmPrinterCtorFn AsmPrinterCtor;
49
Chris Lattner02a3d832002-10-29 22:37:54 +000050public:
Evan Cheng11b0a5d2006-09-08 06:48:29 +000051 X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit);
Chris Lattner02a3d832002-10-29 22:37:54 +000052
Chris Lattner82baa9c2004-06-02 05:55:25 +000053 virtual const X86InstrInfo *getInstrInfo() const { return &InstrInfo; }
54 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
Dan Gohmaneabd6472008-05-14 01:58:56 +000055 virtual X86JITInfo *getJITInfo() { return &JITInfo; }
56 virtual const X86Subtarget *getSubtargetImpl() const{ return &Subtarget; }
Chris Lattnerb19ce6c2006-05-12 21:14:20 +000057 virtual X86TargetLowering *getTargetLowering() const {
58 return const_cast<X86TargetLowering*>(&TLInfo);
59 }
Dan Gohmaneabd6472008-05-14 01:58:56 +000060 virtual const X86RegisterInfo *getRegisterInfo() const {
Chris Lattner362b26c2002-12-28 20:33:52 +000061 return &InstrInfo.getRegisterInfo();
62 }
Owen Anderson20a631f2006-05-03 01:29:57 +000063 virtual const TargetData *getTargetData() const { return &DataLayout; }
Bill Wendlingc1f10352007-01-27 02:56:16 +000064 virtual const X86ELFWriterInfo *getELFWriterInfo() const {
Bill Wendling2aa9a422007-02-08 01:39:44 +000065 return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
Bill Wendlingc1f10352007-01-27 02:56:16 +000066 }
Chris Lattner362b26c2002-12-28 20:33:52 +000067
Chris Lattner4266f802004-07-11 02:48:49 +000068 static unsigned getModuleMatchQuality(const Module &M);
69 static unsigned getJITMatchQuality();
Anton Korobeynikovc5faeb82008-08-17 13:53:59 +000070
71 static void registerAsmPrinter(AsmPrinterCtorFn F) {
72 AsmPrinterCtor = F;
73 }
74
Chris Lattner12e97302006-09-04 04:14:57 +000075 // Set up the pass pipeline.
Anton Korobeynikov26590112008-04-23 18:23:05 +000076 virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
77 virtual bool addPreRegAlloc(PassManagerBase &PM, bool Fast);
Dan Gohman24570832008-03-11 22:29:46 +000078 virtual bool addPostRegAlloc(PassManagerBase &PM, bool Fast);
79 virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
Owen Anderson93719642008-08-21 00:14:44 +000080 raw_ostream &Out);
Dan Gohman24570832008-03-11 22:29:46 +000081 virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng9d5df0a2007-07-20 21:56:13 +000082 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohman24570832008-03-11 22:29:46 +000083 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng9d5df0a2007-07-20 21:56:13 +000084 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohman007a6bb2008-09-26 19:15:30 +000085
86 // symbolicAddressesAreRIPRel - Return true if symbolic addresses are
87 // RIP-relative on this machine, taking into consideration the relocation
88 // model and subtarget. RIP-relative addresses cannot have a separate
89 // base or index register.
90 bool symbolicAddressesAreRIPRel() const;
Chris Lattner02a3d832002-10-29 22:37:54 +000091};
Evan Cheng11b0a5d2006-09-08 06:48:29 +000092
93/// X86_32TargetMachine - X86 32-bit target machine.
94///
95class X86_32TargetMachine : public X86TargetMachine {
96public:
97 X86_32TargetMachine(const Module &M, const std::string &FS);
98
99 static unsigned getJITMatchQuality();
100 static unsigned getModuleMatchQuality(const Module &M);
101};
102
103/// X86_64TargetMachine - X86 64-bit target machine.
104///
105class X86_64TargetMachine : public X86TargetMachine {
106public:
107 X86_64TargetMachine(const Module &M, const std::string &FS);
108
109 static unsigned getJITMatchQuality();
110 static unsigned getModuleMatchQuality(const Module &M);
111};
112
Brian Gaeke960707c2003-11-11 22:41:34 +0000113} // End llvm namespace
114
Chris Lattner02a3d832002-10-29 22:37:54 +0000115#endif