Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 1 | //===-- X86TargetMachine.h - Define TargetMachine for the X86 ---*- C++ -*-===// |
Misha Brukman | 0e0a7a45 | 2005-04-21 23:38:14 +0000 | [diff] [blame] | 2 | // |
John Criswell | 856ba76 | 2003-10-21 15:17:13 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 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. |
Misha Brukman | 0e0a7a45 | 2005-04-21 23:38:14 +0000 | [diff] [blame] | 7 | // |
John Criswell | 856ba76 | 2003-10-21 15:17:13 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Misha Brukman | 0e0a7a45 | 2005-04-21 23:38:14 +0000 | [diff] [blame] | 9 | // |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 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" |
Owen Anderson | 07000c6 | 2006-05-12 06:33:49 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetData.h" |
Chris Lattner | 8bd66e6 | 2002-12-28 21:00:25 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetFrameInfo.h" |
Evan Cheng | c4c6257 | 2006-03-13 23:20:37 +0000 | [diff] [blame] | 20 | #include "X86.h" |
Bill Wendling | fcdea7b | 2007-01-27 02:56:16 +0000 | [diff] [blame] | 21 | #include "X86ELFWriterInfo.h" |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 22 | #include "X86InstrInfo.h" |
Chris Lattner | 1e60a91 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 23 | #include "X86JITInfo.h" |
Nate Begeman | fb5792f | 2005-07-12 01:41:54 +0000 | [diff] [blame] | 24 | #include "X86Subtarget.h" |
Evan Cheng | c4c6257 | 2006-03-13 23:20:37 +0000 | [diff] [blame] | 25 | #include "X86ISelLowering.h" |
Dan Gohman | ff7a562 | 2010-05-11 17:31:57 +0000 | [diff] [blame] | 26 | #include "X86SelectionDAGInfo.h" |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 27 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 28 | namespace llvm { |
Owen Anderson | cb37188 | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 29 | |
David Greene | 7184781 | 2009-07-14 20:18:05 +0000 | [diff] [blame] | 30 | class formatted_raw_ostream; |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 31 | |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 32 | class X86TargetMachine : public LLVMTargetMachine { |
Evan Cheng | c4c6257 | 2006-03-13 23:20:37 +0000 | [diff] [blame] | 33 | X86Subtarget Subtarget; |
| 34 | TargetFrameInfo FrameInfo; |
Bill Wendling | fcdea7b | 2007-01-27 02:56:16 +0000 | [diff] [blame] | 35 | X86ELFWriterInfo ELFWriterInfo; |
Evan Cheng | aabe38b | 2007-12-22 09:40:20 +0000 | [diff] [blame] | 36 | Reloc::Model DefRelocModel; // Reloc model before it's overridden. |
Jim Laskey | fde1b3b | 2006-09-07 23:39:26 +0000 | [diff] [blame] | 37 | |
Eric Christopher | f4f43cb | 2009-12-21 08:15:29 +0000 | [diff] [blame] | 38 | private: |
| 39 | // We have specific defaults for X86. |
| 40 | virtual void setCodeModelForJIT(); |
| 41 | virtual void setCodeModelForStatic(); |
| 42 | |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 43 | public: |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame] | 44 | X86TargetMachine(const Target &T, const std::string &TT, |
| 45 | const std::string &FS, bool is64Bit); |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 46 | |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 47 | virtual const X86InstrInfo *getInstrInfo() const { |
| 48 | llvm_unreachable("getInstrInfo not implemented"); |
| 49 | } |
Chris Lattner | d029cd2 | 2004-06-02 05:55:25 +0000 | [diff] [blame] | 50 | virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; } |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 51 | virtual X86JITInfo *getJITInfo() { |
| 52 | llvm_unreachable("getJITInfo not implemented"); |
| 53 | } |
Dan Gohman | c9f5f3f | 2008-05-14 01:58:56 +0000 | [diff] [blame] | 54 | virtual const X86Subtarget *getSubtargetImpl() const{ return &Subtarget; } |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 55 | virtual const X86TargetLowering *getTargetLowering() const { |
| 56 | llvm_unreachable("getTargetLowering not implemented"); |
Chris Lattner | 98d0d7d | 2006-05-12 21:14:20 +0000 | [diff] [blame] | 57 | } |
Dan Gohman | ff7a562 | 2010-05-11 17:31:57 +0000 | [diff] [blame] | 58 | virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const { |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 59 | llvm_unreachable("getSelectionDAGInfo not implemented"); |
Dan Gohman | ff7a562 | 2010-05-11 17:31:57 +0000 | [diff] [blame] | 60 | } |
Dan Gohman | c9f5f3f | 2008-05-14 01:58:56 +0000 | [diff] [blame] | 61 | virtual const X86RegisterInfo *getRegisterInfo() const { |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 62 | return &getInstrInfo()->getRegisterInfo(); |
Chris Lattner | fde4b51 | 2002-12-28 20:33:52 +0000 | [diff] [blame] | 63 | } |
Bill Wendling | fcdea7b | 2007-01-27 02:56:16 +0000 | [diff] [blame] | 64 | virtual const X86ELFWriterInfo *getELFWriterInfo() const { |
Bill Wendling | eb1ac33 | 2007-02-08 01:39:44 +0000 | [diff] [blame] | 65 | return Subtarget.isTargetELF() ? &ELFWriterInfo : 0; |
Bill Wendling | fcdea7b | 2007-01-27 02:56:16 +0000 | [diff] [blame] | 66 | } |
Chris Lattner | fde4b51 | 2002-12-28 20:33:52 +0000 | [diff] [blame] | 67 | |
Chris Lattner | 1911fd4 | 2006-09-04 04:14:57 +0000 | [diff] [blame] | 68 | // Set up the pass pipeline. |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 69 | virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel); |
| 70 | virtual bool addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel); |
| 71 | virtual bool addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel); |
Jakob Stoklund Olesen | 352aa50 | 2010-03-25 17:25:00 +0000 | [diff] [blame] | 72 | virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel); |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 73 | virtual bool addCodeEmitter(PassManagerBase &PM, CodeGenOpt::Level OptLevel, |
Daniel Dunbar | cfe9a60 | 2009-07-15 22:33:19 +0000 | [diff] [blame] | 74 | JITCodeEmitter &JCE); |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 75 | }; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 76 | |
| 77 | /// X86_32TargetMachine - X86 32-bit target machine. |
| 78 | /// |
| 79 | class X86_32TargetMachine : public X86TargetMachine { |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 80 | const TargetData DataLayout; // Calculates type size & alignment |
| 81 | X86InstrInfo InstrInfo; |
| 82 | X86SelectionDAGInfo TSInfo; |
| 83 | X86TargetLowering TLInfo; |
| 84 | X86JITInfo JITInfo; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 85 | public: |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame] | 86 | X86_32TargetMachine(const Target &T, const std::string &M, |
| 87 | const std::string &FS); |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 88 | virtual const TargetData *getTargetData() const { return &DataLayout; } |
| 89 | virtual const X86TargetLowering *getTargetLowering() const { |
| 90 | return &TLInfo; |
| 91 | } |
| 92 | virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const { |
| 93 | return &TSInfo; |
| 94 | } |
| 95 | virtual const X86InstrInfo *getInstrInfo() const { |
| 96 | return &InstrInfo; |
| 97 | } |
| 98 | virtual X86JITInfo *getJITInfo() { |
| 99 | return &JITInfo; |
| 100 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | /// X86_64TargetMachine - X86 64-bit target machine. |
| 104 | /// |
| 105 | class X86_64TargetMachine : public X86TargetMachine { |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 106 | const TargetData DataLayout; // Calculates type size & alignment |
| 107 | X86InstrInfo InstrInfo; |
| 108 | X86SelectionDAGInfo TSInfo; |
| 109 | X86TargetLowering TLInfo; |
| 110 | X86JITInfo JITInfo; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 111 | public: |
Daniel Dunbar | e28039c | 2009-08-02 23:37:13 +0000 | [diff] [blame] | 112 | X86_64TargetMachine(const Target &T, const std::string &TT, |
| 113 | const std::string &FS); |
Rafael Espindola | 0febc46 | 2010-10-03 18:59:45 +0000 | [diff] [blame^] | 114 | virtual const TargetData *getTargetData() const { return &DataLayout; } |
| 115 | virtual const X86TargetLowering *getTargetLowering() const { |
| 116 | return &TLInfo; |
| 117 | } |
| 118 | virtual const X86SelectionDAGInfo *getSelectionDAGInfo() const { |
| 119 | return &TSInfo; |
| 120 | } |
| 121 | virtual const X86InstrInfo *getInstrInfo() const { |
| 122 | return &InstrInfo; |
| 123 | } |
| 124 | virtual X86JITInfo *getJITInfo() { |
| 125 | return &JITInfo; |
| 126 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 127 | }; |
| 128 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 129 | } // End llvm namespace |
| 130 | |
Chris Lattner | b4f68ed | 2002-10-29 22:37:54 +0000 | [diff] [blame] | 131 | #endif |