Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 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 | |
| 27 | namespace llvm { |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame^] | 28 | |
| 29 | class raw_ostream; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 30 | |
| 31 | class 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 Cheng | 8ee6bab | 2007-12-22 09:40:20 +0000 | [diff] [blame] | 39 | Reloc::Model DefRelocModel; // Reloc model before it's overridden. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 40 | |
| 41 | protected: |
| 42 | virtual const TargetAsmInfo *createTargetAsmInfo() const; |
Anton Korobeynikov | 9ff5bee | 2008-08-17 13:53:59 +0000 | [diff] [blame] | 43 | |
| 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 Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame^] | 46 | typedef FunctionPass *(*AsmPrinterCtorFn)(raw_ostream &o, |
Anton Korobeynikov | 9ff5bee | 2008-08-17 13:53:59 +0000 | [diff] [blame] | 47 | X86TargetMachine &tm); |
| 48 | static AsmPrinterCtorFn AsmPrinterCtor; |
| 49 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 50 | public: |
| 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 Gohman | b41dfba | 2008-05-14 01:58:56 +0000 | [diff] [blame] | 55 | virtual X86JITInfo *getJITInfo() { return &JITInfo; } |
| 56 | virtual const X86Subtarget *getSubtargetImpl() const{ return &Subtarget; } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 57 | virtual X86TargetLowering *getTargetLowering() const { |
| 58 | return const_cast<X86TargetLowering*>(&TLInfo); |
| 59 | } |
Dan Gohman | b41dfba | 2008-05-14 01:58:56 +0000 | [diff] [blame] | 60 | virtual const X86RegisterInfo *getRegisterInfo() const { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 61 | 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 Korobeynikov | 9ff5bee | 2008-08-17 13:53:59 +0000 | [diff] [blame] | 70 | |
| 71 | static void registerAsmPrinter(AsmPrinterCtorFn F) { |
| 72 | AsmPrinterCtor = F; |
| 73 | } |
| 74 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 75 | // Set up the pass pipeline. |
Anton Korobeynikov | 194ae6c | 2008-04-23 18:23:05 +0000 | [diff] [blame] | 76 | virtual bool addInstSelector(PassManagerBase &PM, bool Fast); |
| 77 | virtual bool addPreRegAlloc(PassManagerBase &PM, bool Fast); |
Dan Gohman | e34aa77 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 78 | virtual bool addPostRegAlloc(PassManagerBase &PM, bool Fast); |
| 79 | virtual bool addAssemblyEmitter(PassManagerBase &PM, bool Fast, |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame^] | 80 | raw_ostream &Out); |
Dan Gohman | e34aa77 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 81 | virtual bool addCodeEmitter(PassManagerBase &PM, bool Fast, |
Evan Cheng | 7754721 | 2007-07-20 21:56:13 +0000 | [diff] [blame] | 82 | bool DumpAsm, MachineCodeEmitter &MCE); |
Dan Gohman | e34aa77 | 2008-03-11 22:29:46 +0000 | [diff] [blame] | 83 | virtual bool addSimpleCodeEmitter(PassManagerBase &PM, bool Fast, |
Evan Cheng | 7754721 | 2007-07-20 21:56:13 +0000 | [diff] [blame] | 84 | bool DumpAsm, MachineCodeEmitter &MCE); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | /// X86_32TargetMachine - X86 32-bit target machine. |
| 88 | /// |
| 89 | class X86_32TargetMachine : public X86TargetMachine { |
| 90 | public: |
| 91 | X86_32TargetMachine(const Module &M, const std::string &FS); |
| 92 | |
| 93 | static unsigned getJITMatchQuality(); |
| 94 | static unsigned getModuleMatchQuality(const Module &M); |
| 95 | }; |
| 96 | |
| 97 | /// X86_64TargetMachine - X86 64-bit target machine. |
| 98 | /// |
| 99 | class X86_64TargetMachine : public X86TargetMachine { |
| 100 | public: |
| 101 | X86_64TargetMachine(const Module &M, const std::string &FS); |
| 102 | |
| 103 | static unsigned getJITMatchQuality(); |
| 104 | static unsigned getModuleMatchQuality(const Module &M); |
| 105 | }; |
| 106 | |
| 107 | } // End llvm namespace |
| 108 | |
| 109 | #endif |