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" |
Justin Holewinski | bc97f44 | 2011-09-26 18:57:27 +0000 | [diff] [blame] | 20 | #include "PTXSelectionDAGInfo.h" |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 21 | #include "PTXSubtarget.h" |
| 22 | #include "llvm/Target/TargetData.h" |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetFrameLowering.h" |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 24 | #include "llvm/Target/TargetMachine.h" |
| 25 | |
| 26 | namespace llvm { |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 27 | class PTXTargetMachine : public LLVMTargetMachine { |
| 28 | private: |
Justin Holewinski | bc97f44 | 2011-09-26 18:57:27 +0000 | [diff] [blame] | 29 | const TargetData DataLayout; |
| 30 | PTXSubtarget Subtarget; // has to be initialized before FrameLowering |
| 31 | PTXFrameLowering FrameLowering; |
| 32 | PTXInstrInfo InstrInfo; |
| 33 | PTXSelectionDAGInfo TSInfo; |
| 34 | PTXTargetLowering TLInfo; |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 35 | |
| 36 | public: |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 37 | PTXTargetMachine(const Target &T, StringRef TT, |
Evan Cheng | 34ad6db | 2011-07-20 07:51:56 +0000 | [diff] [blame] | 38 | StringRef CPU, StringRef FS, |
| 39 | Reloc::Model RM, CodeModel::Model CM, |
Evan Cheng | 276365d | 2011-06-30 01:53:36 +0000 | [diff] [blame] | 40 | bool is64Bit); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 41 | |
| 42 | virtual const TargetData *getTargetData() const { return &DataLayout; } |
| 43 | |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 44 | virtual const TargetFrameLowering *getFrameLowering() const { |
| 45 | return &FrameLowering; |
| 46 | } |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 47 | |
| 48 | virtual const PTXInstrInfo *getInstrInfo() const { return &InstrInfo; } |
| 49 | virtual const TargetRegisterInfo *getRegisterInfo() const { |
| 50 | return &InstrInfo.getRegisterInfo(); } |
| 51 | |
| 52 | virtual const PTXTargetLowering *getTargetLowering() const { |
| 53 | return &TLInfo; } |
| 54 | |
Justin Holewinski | bc97f44 | 2011-09-26 18:57:27 +0000 | [diff] [blame] | 55 | virtual const PTXSelectionDAGInfo* getSelectionDAGInfo() const { |
| 56 | return &TSInfo; |
| 57 | } |
| 58 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 59 | virtual const PTXSubtarget *getSubtargetImpl() const { return &Subtarget; } |
| 60 | |
| 61 | virtual bool addInstSelector(PassManagerBase &PM, |
| 62 | CodeGenOpt::Level OptLevel); |
Che-Liang Chiou | ad83c1d | 2011-01-01 10:50:37 +0000 | [diff] [blame] | 63 | virtual bool addPostRegAlloc(PassManagerBase &PM, |
| 64 | CodeGenOpt::Level OptLevel); |
Justin Holewinski | 40466cc | 2011-09-22 16:45:37 +0000 | [diff] [blame] | 65 | |
| 66 | // We override this method to supply our own set of codegen passes. |
| 67 | virtual bool addPassesToEmitFile(PassManagerBase &, |
| 68 | formatted_raw_ostream &, |
| 69 | CodeGenFileType, |
| 70 | CodeGenOpt::Level, |
| 71 | bool = true); |
| 72 | |
| 73 | // Emission of machine code through JITCodeEmitter is not supported. |
| 74 | virtual bool addPassesToEmitMachineCode(PassManagerBase &, |
| 75 | JITCodeEmitter &, |
| 76 | CodeGenOpt::Level, |
| 77 | bool = true) { |
| 78 | return true; |
| 79 | } |
| 80 | |
| 81 | // Emission of machine code through MCJIT is not supported. |
| 82 | virtual bool addPassesToEmitMC(PassManagerBase &, |
| 83 | MCContext *&, |
| 84 | raw_ostream &, |
| 85 | CodeGenOpt::Level, |
| 86 | bool = true) { |
| 87 | return true; |
| 88 | } |
| 89 | |
| 90 | private: |
| 91 | |
| 92 | bool addCommonCodeGenPasses(PassManagerBase &, CodeGenOpt::Level, |
| 93 | bool DisableVerify, MCContext *&OutCtx); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 94 | }; // class PTXTargetMachine |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 95 | |
| 96 | |
| 97 | class PTX32TargetMachine : public PTXTargetMachine { |
| 98 | public: |
| 99 | |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 100 | PTX32TargetMachine(const Target &T, StringRef TT, |
Evan Cheng | 34ad6db | 2011-07-20 07:51:56 +0000 | [diff] [blame] | 101 | StringRef CPU, StringRef FS, |
| 102 | Reloc::Model RM, CodeModel::Model CM); |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 103 | }; // class PTX32TargetMachine |
| 104 | |
| 105 | class PTX64TargetMachine : public PTXTargetMachine { |
| 106 | public: |
| 107 | |
Evan Cheng | 4396613 | 2011-07-19 06:37:02 +0000 | [diff] [blame] | 108 | PTX64TargetMachine(const Target &T, StringRef TT, |
Evan Cheng | 34ad6db | 2011-07-20 07:51:56 +0000 | [diff] [blame] | 109 | StringRef CPU, StringRef FS, |
| 110 | Reloc::Model RM, CodeModel::Model CM); |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 111 | }; // class PTX32TargetMachine |
| 112 | |
Nick Lewycky | f7a3c50 | 2010-09-07 18:14:24 +0000 | [diff] [blame] | 113 | } // namespace llvm |
| 114 | |
| 115 | #endif // PTX_TARGET_MACHINE_H |