blob: eaf81df5abcc95a5643a3329632ba75cf0678db7 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// 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"
18#include "llvm/Target/TargetData.h"
19#include "llvm/Target/TargetFrameInfo.h"
20#include "X86.h"
21#include "X86ELFWriterInfo.h"
22#include "X86InstrInfo.h"
23#include "X86JITInfo.h"
24#include "X86Subtarget.h"
25#include "X86ISelLowering.h"
26
27namespace llvm {
Owen Anderson847b99b2008-08-21 00:14:44 +000028
29class raw_ostream;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030
31class X86TargetMachine : public LLVMTargetMachine {
32 X86Subtarget Subtarget;
33 const TargetData DataLayout; // Calculates type size & alignment
34 TargetFrameInfo FrameInfo;
35 X86InstrInfo InstrInfo;
36 X86JITInfo JITInfo;
37 X86TargetLowering TLInfo;
38 X86ELFWriterInfo ELFWriterInfo;
Evan Cheng8ee6bab2007-12-22 09:40:20 +000039 Reloc::Model DefRelocModel; // Reloc model before it's overridden.
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
41protected:
42 virtual const TargetAsmInfo *createTargetAsmInfo() const;
Anton Korobeynikov9ff5bee2008-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 Anderson847b99b2008-08-21 00:14:44 +000046 typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o,
Anton Korobeynikov9ff5bee2008-08-17 13:53:59 +000047 X86TargetMachine &tm);
48 static AsmPrinterCtorFn AsmPrinterCtor;
49
Dan Gohmanf17a25c2007-07-18 16:29:46 +000050public:
51 X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit);
52
53 virtual const X86InstrInfo *getInstrInfo() const { return &InstrInfo; }
54 virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
Dan Gohmanb41dfba2008-05-14 01:58:56 +000055 virtual X86JITInfo *getJITInfo() { return &JITInfo; }
56 virtual const X86Subtarget *getSubtargetImpl() const{ return &Subtarget; }
Dan Gohmanf17a25c2007-07-18 16:29:46 +000057 virtual X86TargetLowering *getTargetLowering() const {
58 return const_cast<X86TargetLowering*>(&TLInfo);
59 }
Dan Gohmanb41dfba2008-05-14 01:58:56 +000060 virtual const X86RegisterInfo *getRegisterInfo() const {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 return &InstrInfo.getRegisterInfo();
62 }
63 virtual const TargetData *getTargetData() const { return &DataLayout; }
64 virtual const X86ELFWriterInfo *getELFWriterInfo() const {
65 return Subtarget.isTargetELF() ? &ELFWriterInfo : 0;
66 }
67
68 static unsigned getModuleMatchQuality(const Module &M);
69 static unsigned getJITMatchQuality();
Anton Korobeynikov9ff5bee2008-08-17 13:53:59 +000070
71 static void registerAsmPrinter(AsmPrinterCtorFn F) {
72 AsmPrinterCtor = F;
73 }
74
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075 // Set up the pass pipeline.
Anton Korobeynikov194ae6c2008-04-23 18:23:05 +000076 virtual bool addInstSelector(PassManagerBase &PM, bool Fast);
77 virtual bool addPreRegAlloc(PassManagerBase &PM, bool Fast);
Dan Gohmane34aa772008-03-11 22:29:46 +000078 virtual bool addPostRegAlloc(PassManagerBase &PM, bool Fast);
79 virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast,
Owen Anderson847b99b2008-08-21 00:14:44 +000080 raw_ostream &Out);
Dan Gohmane34aa772008-03-11 22:29:46 +000081 virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng77547212007-07-20 21:56:13 +000082 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohmane34aa772008-03-11 22:29:46 +000083 virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast,
Evan Cheng77547212007-07-20 21:56:13 +000084 bool DumpAsm, MachineCodeEmitter &MCE);
Dan Gohmanc6413362008-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;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000091};
92
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
113} // End llvm namespace
114
115#endif