Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 1 | //=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- 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 NVPTX specific subclass of TargetSubtarget. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H |
| 15 | #define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 16 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 17 | #include "NVPTX.h" |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 18 | #include "NVPTXFrameLowering.h" |
| 19 | #include "NVPTXISelLowering.h" |
| 20 | #include "NVPTXInstrInfo.h" |
| 21 | #include "NVPTXRegisterInfo.h" |
| 22 | #include "llvm/IR/DataLayout.h" |
| 23 | #include "llvm/Target/TargetSelectionDAGInfo.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 24 | #include "llvm/Target/TargetSubtargetInfo.h" |
Chandler Carruth | ff55593 | 2014-04-22 02:28:45 +0000 | [diff] [blame] | 25 | #include <string> |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 26 | |
| 27 | #define GET_SUBTARGETINFO_HEADER |
| 28 | #include "NVPTXGenSubtargetInfo.inc" |
| 29 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 30 | namespace llvm { |
| 31 | |
| 32 | class NVPTXSubtarget : public NVPTXGenSubtargetInfo { |
Juergen Ributzka | d12ccbd | 2013-11-19 00:57:56 +0000 | [diff] [blame] | 33 | virtual void anchor(); |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 34 | std::string TargetName; |
| 35 | NVPTX::DrvInterface drvInterface; |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 36 | bool Is64Bit; |
| 37 | |
Justin Holewinski | 1812ee9 | 2012-11-12 03:16:43 +0000 | [diff] [blame] | 38 | // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31 |
| 39 | unsigned PTXVersion; |
| 40 | |
| 41 | // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31 |
| 42 | unsigned int SmVersion; |
| 43 | |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 44 | const DataLayout DL; // Calculates type size & alignment |
| 45 | NVPTXInstrInfo InstrInfo; |
| 46 | NVPTXTargetLowering TLInfo; |
| 47 | TargetSelectionDAGInfo TSInfo; |
| 48 | |
| 49 | // NVPTX does not have any call stack frame, but need a NVPTX specific |
| 50 | // FrameLowering class because TargetFrameLowering is abstract. |
| 51 | NVPTXFrameLowering FrameLowering; |
| 52 | |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 53 | public: |
| 54 | /// This constructor initializes the data members to match that |
| 55 | /// of the specified module. |
| 56 | /// |
| 57 | NVPTXSubtarget(const std::string &TT, const std::string &CPU, |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 58 | const std::string &FS, const TargetMachine &TM, bool is64Bit); |
| 59 | |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 60 | const TargetFrameLowering *getFrameLowering() const override { |
| 61 | return &FrameLowering; |
| 62 | } |
| 63 | const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; } |
| 64 | const DataLayout *getDataLayout() const override { return &DL; } |
| 65 | const NVPTXRegisterInfo *getRegisterInfo() const override { |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 66 | return &InstrInfo.getRegisterInfo(); |
| 67 | } |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 68 | const NVPTXTargetLowering *getTargetLowering() const override { |
| 69 | return &TLInfo; |
| 70 | } |
| 71 | const TargetSelectionDAGInfo *getSelectionDAGInfo() const override { |
| 72 | return &TSInfo; |
| 73 | } |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 74 | |
| 75 | bool hasBrkPt() const { return SmVersion >= 11; } |
| 76 | bool hasAtomRedG32() const { return SmVersion >= 11; } |
| 77 | bool hasAtomRedS32() const { return SmVersion >= 12; } |
| 78 | bool hasAtomRedG64() const { return SmVersion >= 12; } |
| 79 | bool hasAtomRedS64() const { return SmVersion >= 20; } |
| 80 | bool hasAtomRedGen32() const { return SmVersion >= 20; } |
| 81 | bool hasAtomRedGen64() const { return SmVersion >= 20; } |
| 82 | bool hasAtomAddF32() const { return SmVersion >= 20; } |
| 83 | bool hasVote() const { return SmVersion >= 12; } |
| 84 | bool hasDouble() const { return SmVersion >= 13; } |
| 85 | bool reqPTX20() const { return SmVersion >= 20; } |
| 86 | bool hasF32FTZ() const { return SmVersion >= 20; } |
| 87 | bool hasFMAF32() const { return SmVersion >= 20; } |
| 88 | bool hasFMAF64() const { return SmVersion >= 13; } |
Justin Holewinski | be8dc64 | 2013-02-12 14:18:49 +0000 | [diff] [blame] | 89 | bool hasLDG() const { return SmVersion >= 32; } |
Justin Holewinski | c3f31eb | 2014-06-27 18:35:16 +0000 | [diff] [blame] | 90 | bool hasLDU() const { return ((SmVersion >= 20) && (SmVersion < 30)); } |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 91 | bool hasGenericLdSt() const { return SmVersion >= 20; } |
Justin Holewinski | c3f31eb | 2014-06-27 18:35:16 +0000 | [diff] [blame] | 92 | inline bool hasHWROT32() const { return SmVersion >= 32; } |
| 93 | inline bool hasSWROT32() const { |
| 94 | return ((SmVersion >= 20) && (SmVersion < 32)); |
| 95 | } |
Justin Holewinski | 0497ab1 | 2013-03-30 14:29:21 +0000 | [diff] [blame] | 96 | inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); } |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 97 | inline bool hasROT64() const { return SmVersion >= 20; } |
| 98 | |
Justin Holewinski | 30d56a7 | 2014-04-09 15:39:15 +0000 | [diff] [blame] | 99 | bool hasImageHandles() const { |
Justin Holewinski | 9a2350e | 2014-07-17 11:59:04 +0000 | [diff] [blame] | 100 | // Enable handles for Kepler+, where CUDA supports indirect surfaces and |
| 101 | // textures |
| 102 | if (getDrvInterface() == NVPTX::CUDA) |
| 103 | return (SmVersion >= 30); |
| 104 | |
| 105 | // Disabled, otherwise |
Justin Holewinski | 30d56a7 | 2014-04-09 15:39:15 +0000 | [diff] [blame] | 106 | return false; |
| 107 | } |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 108 | bool is64Bit() const { return Is64Bit; } |
| 109 | |
| 110 | unsigned int getSmVersion() const { return SmVersion; } |
| 111 | NVPTX::DrvInterface getDrvInterface() const { return drvInterface; } |
| 112 | std::string getTargetName() const { return TargetName; } |
| 113 | |
Justin Holewinski | 1812ee9 | 2012-11-12 03:16:43 +0000 | [diff] [blame] | 114 | unsigned getPTXVersion() const { return PTXVersion; } |
| 115 | |
Eric Christopher | 493f91b | 2014-06-27 04:33:14 +0000 | [diff] [blame] | 116 | NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 117 | void ParseSubtargetFeatures(StringRef CPU, StringRef FS); |
Justin Holewinski | ae556d3 | 2012-05-04 20:18:50 +0000 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | } // End llvm namespace |
| 121 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 122 | #endif |