blob: 0404200992000d83e6c1eeda014cf05b400b246f [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 Cheng0ddff1b2011-07-07 07:07:08 +000023class StringRef;
24
Evan Cheng94214702011-07-01 20:45:01 +000025 class PTXSubtarget : public PTXGenSubtargetInfo {
Justin Holewinski67a91842011-06-23 18:10:03 +000026 public:
Justin Holewinski625eec12011-03-15 13:24:15 +000027
28 /**
29 * Enumeration of Shader Models supported by the back-end.
30 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000031 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
Justin Holewinski625eec12011-03-15 13:24:15 +000039 PTX_SM_1_0, /*< Shader Model 1.0 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000040 PTX_SM_1_1, /*< Shader Model 1.1 */
41 PTX_SM_1_2, /*< Shader Model 1.2 */
Justin Holewinski625eec12011-03-15 13:24:15 +000042 PTX_SM_1_3, /*< Shader Model 1.3 */
Justin Holewinski35f4fb32011-06-24 16:27:49 +000043 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
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000048 };
49
Justin Holewinski625eec12011-03-15 13:24:15 +000050 /**
51 * Enumeration of PTX versions supported by the back-end.
52 *
53 * Currently, PTX 2.0 is the minimum supported version.
54 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000055 enum PTXVersionEnum {
Justin Holewinski625eec12011-03-15 13:24:15 +000056 PTX_VERSION_2_0, /*< PTX Version 2.0 */
57 PTX_VERSION_2_1, /*< PTX Version 2.1 */
Justin Holewinskiab0145d2011-05-06 11:40:36 +000058 PTX_VERSION_2_2, /*< PTX Version 2.2 */
59 PTX_VERSION_2_3 /*< PTX Version 2.3 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000060 };
61
Justin Holewinski67a91842011-06-23 18:10:03 +000062 private:
63
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000064 /// Shader Model supported on the target GPU.
Justin Holewinski35f4fb32011-06-24 16:27:49 +000065 PTXTargetEnum PTXTarget;
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000066
67 /// PTX Language Version.
68 PTXVersionEnum PTXVersion;
69
70 // The native .f64 type is supported on the hardware.
71 bool SupportsDouble;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000072
73 // Support the fused-multiply add (FMA) and multiply-add (MAD)
74 // instructions
Justin Holewinski657d1be2011-05-18 15:42:23 +000075 bool SupportsFMA;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000076
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000077 // Use .u64 instead of .u32 for addresses.
Justin Holewinskie1fee482011-04-20 15:37:17 +000078 bool Is64Bit;
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000079
Eric Christopher50880d02010-09-18 18:52:28 +000080 public:
Justin Holewinski67a91842011-06-23 18:10:03 +000081
Evan Cheng276365d2011-06-30 01:53:36 +000082 PTXSubtarget(const std::string &TT, const std::string &CPU,
83 const std::string &FS, bool is64Bit);
Eric Christopher50880d02010-09-18 18:52:28 +000084
Justin Holewinski67a91842011-06-23 18:10:03 +000085 // Target architecture accessors
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000086 std::string getTargetString() const;
87
88 std::string getPTXVersionString() const;
89
90 bool supportsDouble() const { return SupportsDouble; }
91
Justin Holewinskie1fee482011-04-20 15:37:17 +000092 bool is64Bit() const { return Is64Bit; }
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000093
Justin Holewinski657d1be2011-05-18 15:42:23 +000094 bool supportsFMA() const { return SupportsFMA; }
Justin Holewinskiec3141b2011-06-16 15:17:11 +000095
Justin Holewinskifca9efc2011-03-10 16:57:18 +000096 bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; }
97
Justin Holewinski625eec12011-03-15 13:24:15 +000098 bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; }
99
Justin Holewinski0d109702011-05-10 12:32:11 +0000100 bool supportsPTX23() const { return PTXVersion >= PTX_VERSION_2_3; }
101
Justin Holewinski35f4fb32011-06-24 16:27:49 +0000102 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 }
Justin Holewinski67a91842011-06-23 18:10:03 +0000106
Justin Holewinski35f4fb32011-06-24 16:27:49 +0000107 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 }
Justin Holewinski67a91842011-06-23 18:10:03 +0000116
Justin Holewinski4bdd4ed2011-08-09 17:36:31 +0000117 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 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Eric Christopher50880d02010-09-18 18:52:28 +0000123 }; // class PTXSubtarget
124} // namespace llvm
125
126#endif // PTX_SUBTARGET_H