blob: ce93fef02a117d012678a74f984afc055f89a436 [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- PTXSubtarget.h - Define Subtarget for the PTX -----------*- C++ -*-===//
Eric Christopher50880d02010-09-18 18:52:28 +00002//
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 Cheng0ddff1b2011-07-07 07:07:08 +000023class StringRef;
24
Evan Cheng94214702011-07-01 20:45:01 +000025 class PTXSubtarget : public PTXGenSubtargetInfo {
David Blaikie2d24e2a2011-12-20 02:50:00 +000026 virtual void anchor();
Justin Holewinski67a91842011-06-23 18:10:03 +000027 public:
Justin Holewinski625eec12011-03-15 13:24:15 +000028
29 /**
30 * Enumeration of Shader Models supported by the back-end.
31 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000032 enum PTXTargetEnum {
33 PTX_COMPUTE_1_0, /*< Compute Compatibility 1.0 */
34 PTX_COMPUTE_1_1, /*< Compute Compatibility 1.1 */
35 PTX_COMPUTE_1_2, /*< Compute Compatibility 1.2 */
36 PTX_COMPUTE_1_3, /*< Compute Compatibility 1.3 */
37 PTX_COMPUTE_2_0, /*< Compute Compatibility 2.0 */
38 PTX_LAST_COMPUTE,
39
Justin Holewinski625eec12011-03-15 13:24:15 +000040 PTX_SM_1_0, /*< Shader Model 1.0 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000041 PTX_SM_1_1, /*< Shader Model 1.1 */
42 PTX_SM_1_2, /*< Shader Model 1.2 */
Justin Holewinski625eec12011-03-15 13:24:15 +000043 PTX_SM_1_3, /*< Shader Model 1.3 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000044 PTX_SM_2_0, /*< Shader Model 2.0 */
45 PTX_SM_2_1, /*< Shader Model 2.1 */
46 PTX_SM_2_2, /*< Shader Model 2.2 */
47 PTX_SM_2_3, /*< Shader Model 2.3 */
48 PTX_LAST_SM
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000049 };
50
Justin Holewinski625eec12011-03-15 13:24:15 +000051 /**
52 * Enumeration of PTX versions supported by the back-end.
53 *
54 * Currently, PTX 2.0 is the minimum supported version.
55 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000056 enum PTXVersionEnum {
Justin Holewinski625eec12011-03-15 13:24:15 +000057 PTX_VERSION_2_0, /*< PTX Version 2.0 */
58 PTX_VERSION_2_1, /*< PTX Version 2.1 */
Justin Holewinskiab0145d2011-05-06 11:40:36 +000059 PTX_VERSION_2_2, /*< PTX Version 2.2 */
60 PTX_VERSION_2_3 /*< PTX Version 2.3 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000061 };
62
Justin Holewinski67a91842011-06-23 18:10:03 +000063 private:
64
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000065 /// Shader Model supported on the target GPU.
Justin Holewinski35f4fb32011-06-24 16:27:49 +000066 PTXTargetEnum PTXTarget;
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000067
68 /// PTX Language Version.
69 PTXVersionEnum PTXVersion;
70
71 // The native .f64 type is supported on the hardware.
72 bool SupportsDouble;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000073
74 // Support the fused-multiply add (FMA) and multiply-add (MAD)
75 // instructions
Justin Holewinski657d1be2011-05-18 15:42:23 +000076 bool SupportsFMA;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000077
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000078 // Use .u64 instead of .u32 for addresses.
Justin Holewinskie1fee482011-04-20 15:37:17 +000079 bool Is64Bit;
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000080
Eric Christopher50880d02010-09-18 18:52:28 +000081 public:
Justin Holewinski67a91842011-06-23 18:10:03 +000082
Evan Cheng276365d2011-06-30 01:53:36 +000083 PTXSubtarget(const std::string &TT, const std::string &CPU,
84 const std::string &FS, bool is64Bit);
Eric Christopher50880d02010-09-18 18:52:28 +000085
Justin Holewinski67a91842011-06-23 18:10:03 +000086 // Target architecture accessors
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000087 std::string getTargetString() const;
88
89 std::string getPTXVersionString() const;
90
91 bool supportsDouble() const { return SupportsDouble; }
92
Justin Holewinskie1fee482011-04-20 15:37:17 +000093 bool is64Bit() const { return Is64Bit; }
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000094
Justin Holewinski657d1be2011-05-18 15:42:23 +000095 bool supportsFMA() const { return SupportsFMA; }
Justin Holewinskiec3141b2011-06-16 15:17:11 +000096
Justin Holewinskifca9efc2011-03-10 16:57:18 +000097 bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; }
98
Justin Holewinski625eec12011-03-15 13:24:15 +000099 bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; }
100
Justin Holewinski0d109702011-05-10 12:32:11 +0000101 bool supportsPTX23() const { return PTXVersion >= PTX_VERSION_2_3; }
102
Justin Holewinski35f4fb32011-06-24 16:27:49 +0000103 bool fdivNeedsRoundingMode() const {
104 return (PTXTarget >= PTX_SM_1_3 && PTXTarget < PTX_LAST_SM) ||
105 (PTXTarget >= PTX_COMPUTE_1_3 && PTXTarget < PTX_LAST_COMPUTE);
106 }
Justin Holewinski67a91842011-06-23 18:10:03 +0000107
Justin Holewinski35f4fb32011-06-24 16:27:49 +0000108 bool fmadNeedsRoundingMode() const {
109 return (PTXTarget >= PTX_SM_1_3 && PTXTarget < PTX_LAST_SM) ||
110 (PTXTarget >= PTX_COMPUTE_1_3 && PTXTarget < PTX_LAST_COMPUTE);
111 }
112
113 bool useParamSpaceForDeviceArgs() const {
114 return (PTXTarget >= PTX_SM_2_0 && PTXTarget < PTX_LAST_SM) ||
115 (PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE);
116 }
Justin Holewinski67a91842011-06-23 18:10:03 +0000117
Justin Holewinski4bdd4ed2011-08-09 17:36:31 +0000118 bool callsAreHandled() const {
119 return (PTXTarget >= PTX_SM_2_0 && PTXTarget < PTX_LAST_SM) ||
120 (PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE);
121 }
122
Justin Holewinski68226a42011-10-09 15:42:02 +0000123 bool emitPtrAttribute() const {
124 return PTXVersion >= PTX_VERSION_2_2;
125 }
126
Justin Holewinski4bdd4ed2011-08-09 17:36:31 +0000127 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Eric Christopher50880d02010-09-18 18:52:28 +0000128 }; // class PTXSubtarget
129} // namespace llvm
130
131#endif // PTX_SUBTARGET_H