1 //====-- PTXSubtarget.h - Define Subtarget for the 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 TargetSubtargetInfo. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef PTX_SUBTARGET_H 15 #define PTX_SUBTARGET_H 16 17 #include "llvm/Target/TargetSubtargetInfo.h" 18 19 #define GET_SUBTARGETINFO_HEADER 20 #include "PTXGenSubtargetInfo.inc" 21 22 namespace llvm { 23 class StringRef; 24 25 class PTXSubtarget : public PTXGenSubtargetInfo { 26 public: 27 28 /** 29 * Enumeration of Shader Models supported by the back-end. 30 */ 31 enum PTXTargetEnum { 32 PTX_COMPUTE_1_0, /*< Compute Compatibility 1.0 */ 33 PTX_COMPUTE_1_1, /*< Compute Compatibility 1.1 */ 34 PTX_COMPUTE_1_2, /*< Compute Compatibility 1.2 */ 35 PTX_COMPUTE_1_3, /*< Compute Compatibility 1.3 */ 36 PTX_COMPUTE_2_0, /*< Compute Compatibility 2.0 */ 37 PTX_LAST_COMPUTE, 38 39 PTX_SM_1_0, /*< Shader Model 1.0 */ 40 PTX_SM_1_1, /*< Shader Model 1.1 */ 41 PTX_SM_1_2, /*< Shader Model 1.2 */ 42 PTX_SM_1_3, /*< Shader Model 1.3 */ 43 PTX_SM_2_0, /*< Shader Model 2.0 */ 44 PTX_SM_2_1, /*< Shader Model 2.1 */ 45 PTX_SM_2_2, /*< Shader Model 2.2 */ 46 PTX_SM_2_3, /*< Shader Model 2.3 */ 47 PTX_LAST_SM 48 }; 49 50 /** 51 * Enumeration of PTX versions supported by the back-end. 52 * 53 * Currently, PTX 2.0 is the minimum supported version. 54 */ 55 enum PTXVersionEnum { 56 PTX_VERSION_2_0, /*< PTX Version 2.0 */ 57 PTX_VERSION_2_1, /*< PTX Version 2.1 */ 58 PTX_VERSION_2_2, /*< PTX Version 2.2 */ 59 PTX_VERSION_2_3 /*< PTX Version 2.3 */ 60 }; 61 62 private: 63 64 /// Shader Model supported on the target GPU. 65 PTXTargetEnum PTXTarget; 66 67 /// PTX Language Version. 68 PTXVersionEnum PTXVersion; 69 70 // The native .f64 type is supported on the hardware. 71 bool SupportsDouble; 72 73 // Support the fused-multiply add (FMA) and multiply-add (MAD) 74 // instructions 75 bool SupportsFMA; 76 77 // Use .u64 instead of .u32 for addresses. 78 bool Is64Bit; 79 80 public: 81 82 PTXSubtarget(const std::string &TT, const std::string &CPU, 83 const std::string &FS, bool is64Bit); 84 85 // Target architecture accessors 86 std::string getTargetString() const; 87 88 std::string getPTXVersionString() const; 89 90 bool supportsDouble() const { return SupportsDouble; } 91 92 bool is64Bit() const { return Is64Bit; } 93 94 bool supportsFMA() const { return SupportsFMA; } 95 96 bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; } 97 98 bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; } 99 100 bool supportsPTX23() const { return PTXVersion >= PTX_VERSION_2_3; } 101 102 bool fdivNeedsRoundingMode() const { 103 return (PTXTarget >= PTX_SM_1_3 && PTXTarget < PTX_LAST_SM) || 104 (PTXTarget >= PTX_COMPUTE_1_3 && PTXTarget < PTX_LAST_COMPUTE); 105 } 106 107 bool fmadNeedsRoundingMode() const { 108 return (PTXTarget >= PTX_SM_1_3 && PTXTarget < PTX_LAST_SM) || 109 (PTXTarget >= PTX_COMPUTE_1_3 && PTXTarget < PTX_LAST_COMPUTE); 110 } 111 112 bool useParamSpaceForDeviceArgs() const { 113 return (PTXTarget >= PTX_SM_2_0 && PTXTarget < PTX_LAST_SM) || 114 (PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE); 115 } 116 117 bool callsAreHandled() const { 118 return (PTXTarget >= PTX_SM_2_0 && PTXTarget < PTX_LAST_SM) || 119 (PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE); 120 } 121 122 bool emitPtrAttribute() const { 123 return PTXVersion >= PTX_VERSION_2_2; 124 } 125 126 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 127 }; // class PTXSubtarget 128 } // namespace llvm 129 130 #endif // PTX_SUBTARGET_H 131