blob: 58d192bd8fe02ed444791dac9ae3004810a63a4a [file] [log] [blame]
Eric Christopher50880d02010-09-18 18:52:28 +00001//====-- 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
19namespace llvm {
20 class PTXSubtarget : public TargetSubtarget {
Justin Holewinski67a91842011-06-23 18:10:03 +000021 public:
Justin Holewinski625eec12011-03-15 13:24:15 +000022
23 /**
24 * Enumeration of Shader Models supported by the back-end.
25 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000026 enum PTXTargetEnum {
27 PTX_COMPUTE_1_0, /*< Compute Compatibility 1.0 */
28 PTX_COMPUTE_1_1, /*< Compute Compatibility 1.1 */
29 PTX_COMPUTE_1_2, /*< Compute Compatibility 1.2 */
30 PTX_COMPUTE_1_3, /*< Compute Compatibility 1.3 */
31 PTX_COMPUTE_2_0, /*< Compute Compatibility 2.0 */
32 PTX_LAST_COMPUTE,
33
Justin Holewinski625eec12011-03-15 13:24:15 +000034 PTX_SM_1_0, /*< Shader Model 1.0 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000035 PTX_SM_1_1, /*< Shader Model 1.1 */
36 PTX_SM_1_2, /*< Shader Model 1.2 */
Justin Holewinski625eec12011-03-15 13:24:15 +000037 PTX_SM_1_3, /*< Shader Model 1.3 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000038 PTX_SM_2_0, /*< Shader Model 2.0 */
39 PTX_SM_2_1, /*< Shader Model 2.1 */
40 PTX_SM_2_2, /*< Shader Model 2.2 */
41 PTX_SM_2_3, /*< Shader Model 2.3 */
42 PTX_LAST_SM
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000043 };
44
Justin Holewinski625eec12011-03-15 13:24:15 +000045 /**
46 * Enumeration of PTX versions supported by the back-end.
47 *
48 * Currently, PTX 2.0 is the minimum supported version.
49 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000050 enum PTXVersionEnum {
Justin Holewinski625eec12011-03-15 13:24:15 +000051 PTX_VERSION_2_0, /*< PTX Version 2.0 */
52 PTX_VERSION_2_1, /*< PTX Version 2.1 */
Justin Holewinskiab0145d2011-05-06 11:40:36 +000053 PTX_VERSION_2_2, /*< PTX Version 2.2 */
54 PTX_VERSION_2_3 /*< PTX Version 2.3 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000055 };
56
Justin Holewinski67a91842011-06-23 18:10:03 +000057 private:
58
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000059 /// Shader Model supported on the target GPU.
Justin Holewinski35f4fb32011-06-24 16:27:49 +000060 PTXTargetEnum PTXTarget;
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000061
62 /// PTX Language Version.
63 PTXVersionEnum PTXVersion;
64
65 // The native .f64 type is supported on the hardware.
66 bool SupportsDouble;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000067
68 // Support the fused-multiply add (FMA) and multiply-add (MAD)
69 // instructions
Justin Holewinski657d1be2011-05-18 15:42:23 +000070 bool SupportsFMA;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000071
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000072 // Use .u64 instead of .u32 for addresses.
Justin Holewinskie1fee482011-04-20 15:37:17 +000073 bool Is64Bit;
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000074
Eric Christopher50880d02010-09-18 18:52:28 +000075 public:
Justin Holewinski67a91842011-06-23 18:10:03 +000076
Justin Holewinskie1fee482011-04-20 15:37:17 +000077 PTXSubtarget(const std::string &TT, const std::string &FS, bool is64Bit);
Eric Christopher50880d02010-09-18 18:52:28 +000078
Justin Holewinski67a91842011-06-23 18:10:03 +000079 // Target architecture accessors
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000080 std::string getTargetString() const;
81
82 std::string getPTXVersionString() const;
83
84 bool supportsDouble() const { return SupportsDouble; }
85
Justin Holewinskie1fee482011-04-20 15:37:17 +000086 bool is64Bit() const { return Is64Bit; }
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000087
Justin Holewinski657d1be2011-05-18 15:42:23 +000088 bool supportsFMA() const { return SupportsFMA; }
Justin Holewinskiec3141b2011-06-16 15:17:11 +000089
Justin Holewinskifca9efc2011-03-10 16:57:18 +000090 bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; }
91
Justin Holewinski625eec12011-03-15 13:24:15 +000092 bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; }
93
Justin Holewinski0d109702011-05-10 12:32:11 +000094 bool supportsPTX23() const { return PTXVersion >= PTX_VERSION_2_3; }
95
Justin Holewinski35f4fb32011-06-24 16:27:49 +000096 bool fdivNeedsRoundingMode() const {
97 return (PTXTarget >= PTX_SM_1_3 && PTXTarget < PTX_LAST_SM) ||
98 (PTXTarget >= PTX_COMPUTE_1_3 && PTXTarget < PTX_LAST_COMPUTE);
99 }
Justin Holewinski67a91842011-06-23 18:10:03 +0000100
Justin Holewinski35f4fb32011-06-24 16:27:49 +0000101 bool fmadNeedsRoundingMode() const {
102 return (PTXTarget >= PTX_SM_1_3 && PTXTarget < PTX_LAST_SM) ||
103 (PTXTarget >= PTX_COMPUTE_1_3 && PTXTarget < PTX_LAST_COMPUTE);
104 }
105
106 bool useParamSpaceForDeviceArgs() const {
107 return (PTXTarget >= PTX_SM_2_0 && PTXTarget < PTX_LAST_SM) ||
108 (PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE);
109 }
Justin Holewinski67a91842011-06-23 18:10:03 +0000110
Eric Christopher50880d02010-09-18 18:52:28 +0000111 std::string ParseSubtargetFeatures(const std::string &FS,
112 const std::string &CPU);
113 }; // class PTXSubtarget
114} // namespace llvm
115
116#endif // PTX_SUBTARGET_H