Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 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 TargetSubtarget. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef PTX_SUBTARGET_H |
| 15 | #define PTX_SUBTARGET_H |
| 16 | |
| 17 | #include "llvm/Target/TargetSubtarget.h" |
| 18 | |
| 19 | namespace llvm { |
| 20 | class PTXSubtarget : public TargetSubtarget { |
| 21 | private: |
Justin Holewinski | 625eec1 | 2011-03-15 13:24:15 +0000 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Enumeration of Shader Models supported by the back-end. |
| 25 | */ |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 26 | enum PTXShaderModelEnum { |
Justin Holewinski | 625eec1 | 2011-03-15 13:24:15 +0000 | [diff] [blame] | 27 | PTX_SM_1_0, /*< Shader Model 1.0 */ |
| 28 | PTX_SM_1_3, /*< Shader Model 1.3 */ |
| 29 | PTX_SM_2_0 /*< Shader Model 2.0 */ |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
Justin Holewinski | 625eec1 | 2011-03-15 13:24:15 +0000 | [diff] [blame] | 32 | /** |
| 33 | * Enumeration of PTX versions supported by the back-end. |
| 34 | * |
| 35 | * Currently, PTX 2.0 is the minimum supported version. |
| 36 | */ |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 37 | enum PTXVersionEnum { |
Justin Holewinski | 625eec1 | 2011-03-15 13:24:15 +0000 | [diff] [blame] | 38 | PTX_VERSION_2_0, /*< PTX Version 2.0 */ |
| 39 | PTX_VERSION_2_1, /*< PTX Version 2.1 */ |
Justin Holewinski | ab0145d | 2011-05-06 11:40:36 +0000 | [diff] [blame^] | 40 | PTX_VERSION_2_2, /*< PTX Version 2.2 */ |
| 41 | PTX_VERSION_2_3 /*< PTX Version 2.3 */ |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | /// Shader Model supported on the target GPU. |
| 45 | PTXShaderModelEnum PTXShaderModel; |
| 46 | |
| 47 | /// PTX Language Version. |
| 48 | PTXVersionEnum PTXVersion; |
| 49 | |
| 50 | // The native .f64 type is supported on the hardware. |
| 51 | bool SupportsDouble; |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 52 | |
Che-Liang Chiou | f48817c | 2011-03-02 07:36:48 +0000 | [diff] [blame] | 53 | // Use .u64 instead of .u32 for addresses. |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 54 | bool Is64Bit; |
Che-Liang Chiou | f48817c | 2011-03-02 07:36:48 +0000 | [diff] [blame] | 55 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 56 | public: |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 57 | PTXSubtarget(const std::string &TT, const std::string &FS, bool is64Bit); |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 58 | |
Che-Liang Chiou | fd8978b | 2011-03-02 03:20:28 +0000 | [diff] [blame] | 59 | std::string getTargetString() const; |
| 60 | |
| 61 | std::string getPTXVersionString() const; |
| 62 | |
| 63 | bool supportsDouble() const { return SupportsDouble; } |
| 64 | |
Justin Holewinski | e1fee48 | 2011-04-20 15:37:17 +0000 | [diff] [blame] | 65 | bool is64Bit() const { return Is64Bit; } |
Che-Liang Chiou | f48817c | 2011-03-02 07:36:48 +0000 | [diff] [blame] | 66 | |
Justin Holewinski | fca9efc | 2011-03-10 16:57:18 +0000 | [diff] [blame] | 67 | bool supportsSM13() const { return PTXShaderModel >= PTX_SM_1_3; } |
| 68 | |
| 69 | bool supportsSM20() const { return PTXShaderModel >= PTX_SM_2_0; } |
| 70 | |
Justin Holewinski | fca9efc | 2011-03-10 16:57:18 +0000 | [diff] [blame] | 71 | bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; } |
| 72 | |
Justin Holewinski | 625eec1 | 2011-03-15 13:24:15 +0000 | [diff] [blame] | 73 | bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; } |
| 74 | |
Eric Christopher | 50880d0 | 2010-09-18 18:52:28 +0000 | [diff] [blame] | 75 | std::string ParseSubtargetFeatures(const std::string &FS, |
| 76 | const std::string &CPU); |
| 77 | }; // class PTXSubtarget |
| 78 | } // namespace llvm |
| 79 | |
| 80 | #endif // PTX_SUBTARGET_H |