blob: 913f0a2da3979a55159347a0cf0cbaedd41aca3c [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//
Evan Cheng5b1b44892011-07-01 21:01:15 +000010// This file declares the PTX specific subclass of TargetSubtargetInfo.
Eric Christopher50880d02010-09-18 18:52:28 +000011//
12//===----------------------------------------------------------------------===//
13
14#ifndef PTX_SUBTARGET_H
15#define PTX_SUBTARGET_H
16
Evan Cheng5b1b44892011-07-01 21:01:15 +000017#include "llvm/Target/TargetSubtargetInfo.h"
Eric Christopher50880d02010-09-18 18:52:28 +000018
Evan Cheng94214702011-07-01 20:45:01 +000019#define GET_SUBTARGETINFO_HEADER
Evan Cheng385e9302011-07-01 22:36:09 +000020#include "PTXGenSubtargetInfo.inc"
Evan Cheng94214702011-07-01 20:45:01 +000021
Eric Christopher50880d02010-09-18 18:52:28 +000022namespace llvm {
Evan Cheng94214702011-07-01 20:45:01 +000023 class PTXSubtarget : public PTXGenSubtargetInfo {
Justin Holewinski67a91842011-06-23 18:10:03 +000024 public:
Justin Holewinski625eec12011-03-15 13:24:15 +000025
26 /**
27 * Enumeration of Shader Models supported by the back-end.
28 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000029 enum PTXTargetEnum {
30 PTX_COMPUTE_1_0, /*< Compute Compatibility 1.0 */
31 PTX_COMPUTE_1_1, /*< Compute Compatibility 1.1 */
32 PTX_COMPUTE_1_2, /*< Compute Compatibility 1.2 */
33 PTX_COMPUTE_1_3, /*< Compute Compatibility 1.3 */
34 PTX_COMPUTE_2_0, /*< Compute Compatibility 2.0 */
35 PTX_LAST_COMPUTE,
36
Justin Holewinski625eec12011-03-15 13:24:15 +000037 PTX_SM_1_0, /*< Shader Model 1.0 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000038 PTX_SM_1_1, /*< Shader Model 1.1 */
39 PTX_SM_1_2, /*< Shader Model 1.2 */
Justin Holewinski625eec12011-03-15 13:24:15 +000040 PTX_SM_1_3, /*< Shader Model 1.3 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000041 PTX_SM_2_0, /*< Shader Model 2.0 */
42 PTX_SM_2_1, /*< Shader Model 2.1 */
43 PTX_SM_2_2, /*< Shader Model 2.2 */
44 PTX_SM_2_3, /*< Shader Model 2.3 */
45 PTX_LAST_SM
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000046 };
47
Justin Holewinski625eec12011-03-15 13:24:15 +000048 /**
49 * Enumeration of PTX versions supported by the back-end.
50 *
51 * Currently, PTX 2.0 is the minimum supported version.
52 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000053 enum PTXVersionEnum {
Justin Holewinski625eec12011-03-15 13:24:15 +000054 PTX_VERSION_2_0, /*< PTX Version 2.0 */
55 PTX_VERSION_2_1, /*< PTX Version 2.1 */
Justin Holewinskiab0145d2011-05-06 11:40:36 +000056 PTX_VERSION_2_2, /*< PTX Version 2.2 */
57 PTX_VERSION_2_3 /*< PTX Version 2.3 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000058 };
59
Justin Holewinski67a91842011-06-23 18:10:03 +000060 private:
61
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000062 /// Shader Model supported on the target GPU.
Justin Holewinski35f4fb32011-06-24 16:27:49 +000063 PTXTargetEnum PTXTarget;
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000064
65 /// PTX Language Version.
66 PTXVersionEnum PTXVersion;
67
68 // The native .f64 type is supported on the hardware.
69 bool SupportsDouble;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000070
71 // Support the fused-multiply add (FMA) and multiply-add (MAD)
72 // instructions
Justin Holewinski657d1be2011-05-18 15:42:23 +000073 bool SupportsFMA;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000074
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000075 // Use .u64 instead of .u32 for addresses.
Justin Holewinskie1fee482011-04-20 15:37:17 +000076 bool Is64Bit;
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000077
Eric Christopher50880d02010-09-18 18:52:28 +000078 public:
Justin Holewinski67a91842011-06-23 18:10:03 +000079
Evan Cheng276365d2011-06-30 01:53:36 +000080 PTXSubtarget(const std::string &TT, const std::string &CPU,
81 const std::string &FS, bool is64Bit);
Eric Christopher50880d02010-09-18 18:52:28 +000082
Justin Holewinski67a91842011-06-23 18:10:03 +000083 // Target architecture accessors
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000084 std::string getTargetString() const;
85
86 std::string getPTXVersionString() const;
87
88 bool supportsDouble() const { return SupportsDouble; }
89
Justin Holewinskie1fee482011-04-20 15:37:17 +000090 bool is64Bit() const { return Is64Bit; }
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000091
Justin Holewinski657d1be2011-05-18 15:42:23 +000092 bool supportsFMA() const { return SupportsFMA; }
Justin Holewinskiec3141b2011-06-16 15:17:11 +000093
Justin Holewinskifca9efc2011-03-10 16:57:18 +000094 bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; }
95
Justin Holewinski625eec12011-03-15 13:24:15 +000096 bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; }
97
Justin Holewinski0d109702011-05-10 12:32:11 +000098 bool supportsPTX23() const { return PTXVersion >= PTX_VERSION_2_3; }
99
Justin Holewinski35f4fb32011-06-24 16:27:49 +0000100 bool fdivNeedsRoundingMode() const {
101 return (PTXTarget >= PTX_SM_1_3 && PTXTarget < PTX_LAST_SM) ||
102 (PTXTarget >= PTX_COMPUTE_1_3 && PTXTarget < PTX_LAST_COMPUTE);
103 }
Justin Holewinski67a91842011-06-23 18:10:03 +0000104
Justin Holewinski35f4fb32011-06-24 16:27:49 +0000105 bool fmadNeedsRoundingMode() const {
106 return (PTXTarget >= PTX_SM_1_3 && PTXTarget < PTX_LAST_SM) ||
107 (PTXTarget >= PTX_COMPUTE_1_3 && PTXTarget < PTX_LAST_COMPUTE);
108 }
109
110 bool useParamSpaceForDeviceArgs() const {
111 return (PTXTarget >= PTX_SM_2_0 && PTXTarget < PTX_LAST_SM) ||
112 (PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE);
113 }
Justin Holewinski67a91842011-06-23 18:10:03 +0000114
Evan Cheng276365d2011-06-30 01:53:36 +0000115 void ParseSubtargetFeatures(const std::string &FS,
116 const std::string &CPU);
Eric Christopher50880d02010-09-18 18:52:28 +0000117 }; // class PTXSubtarget
118} // namespace llvm
119
120#endif // PTX_SUBTARGET_H