Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 1 | //===-- PTXTargetMachine.h - Define TargetMachine for PTX -------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file declares the PTX specific subclass of TargetMachine. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef PTX_TARGET_MACHINE_H |
| 15 | #define PTX_TARGET_MACHINE_H |
| 16 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 17 | #include "PTXISelLowering.h" |
| 18 | #include "PTXInstrInfo.h" |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 19 | #include "PTXFrameLowering.h" |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 20 | #include "PTXSubtarget.h" |
| 21 | #include "llvm/Target/TargetData.h" |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetFrameLowering.h" |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetMachine.h" |
| 24 | |
| 25 | namespace llvm { |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 26 | class PTXTargetMachine : public LLVMTargetMachine { |
| 27 | private: |
Che-Liang Chiou | f48817c | 2011-03-02 07:36:48 +0000 | [diff] [blame] | 28 | const TargetData DataLayout; |
Che-Liang Chiou | 31c488c | 2011-03-02 07:58:46 +0000 | [diff] [blame] | 29 | PTXSubtarget Subtarget; // has to be initialized before FrameLowering |
Che-Liang Chiou | f48817c | 2011-03-02 07:36:48 +0000 | [diff] [blame] | 30 | PTXFrameLowering FrameLowering; |
| 31 | PTXInstrInfo InstrInfo; |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 32 | PTXTargetLowering TLInfo; |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 33 | |
| 34 | public: |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 35 | PTXTargetMachine(const Target &T, StringRef TT, |
Evan Cheng | 34ad6db | 2011-07-20 07:51:56 +0000 | [diff] [blame] | 36 | StringRef CPU, StringRef FS, |
| 37 | Reloc::Model RM, CodeModel::Model CM, |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 38 | bool is64Bit); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 39 | |
| 40 | virtual const TargetData *getTargetData() const { return &DataLayout; } |
| 41 | |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 42 | virtual const TargetFrameLowering *getFrameLowering() const { |
| 43 | return &FrameLowering; |
| 44 | } |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 45 | |
| 46 | virtual const PTXInstrInfo *getInstrInfo() const { return &InstrInfo; } |
| 47 | virtual const TargetRegisterInfo *getRegisterInfo() const { |
| 48 | return &InstrInfo.getRegisterInfo(); } |
| 49 | |
| 50 | virtual const PTXTargetLowering *getTargetLowering() const { |
| 51 | return &TLInfo; } |
| 52 | |
| 53 | virtual const PTXSubtarget *getSubtargetImpl() const { return &Subtarget; } |
| 54 | |
| 55 | virtual bool addInstSelector(PassManagerBase &PM, |
| 56 | CodeGenOpt::Level OptLevel); |
Che-Liang Chiou | ad83c1d | 2011-01-01 10:50:37 +0000 | [diff] [blame] | 57 | virtual bool addPostRegAlloc(PassManagerBase &PM, |
| 58 | CodeGenOpt::Level OptLevel); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 59 | }; // class PTXTargetMachine |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 60 | |
| 61 | |
| 62 | class PTX32TargetMachine : public PTXTargetMachine { |
| 63 | public: |
| 64 | |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 65 | PTX32TargetMachine(const Target &T, StringRef TT, |
Evan Cheng | 34ad6db | 2011-07-20 07:51:56 +0000 | [diff] [blame] | 66 | StringRef CPU, StringRef FS, |
| 67 | Reloc::Model RM, CodeModel::Model CM); |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 68 | }; // class PTX32TargetMachine |
| 69 | |
| 70 | class PTX64TargetMachine : public PTXTargetMachine { |
| 71 | public: |
| 72 | |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 73 | PTX64TargetMachine(const Target &T, StringRef TT, |
Evan Cheng | 34ad6db | 2011-07-20 07:51:56 +0000 | [diff] [blame] | 74 | StringRef CPU, StringRef FS, |
| 75 | Reloc::Model RM, CodeModel::Model CM); |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 76 | }; // class PTX32TargetMachine |
| 77 | |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 78 | } // namespace llvm |
| 79 | |
| 80 | #endif // PTX_TARGET_MACHINE_H |