blob: 2ebe6cfdc839fb8b7cefa2752deeb80140354709 [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 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000026 enum PTXShaderModelEnum {
Justin Holewinski625eec12011-03-15 13:24:15 +000027 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 Chioufd8978b2011-03-02 03:20:28 +000030 };
31
Justin Holewinski625eec12011-03-15 13:24:15 +000032 /**
33 * Enumeration of PTX versions supported by the back-end.
34 *
35 * Currently, PTX 2.0 is the minimum supported version.
36 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000037 enum PTXVersionEnum {
Justin Holewinski625eec12011-03-15 13:24:15 +000038 PTX_VERSION_2_0, /*< PTX Version 2.0 */
39 PTX_VERSION_2_1, /*< PTX Version 2.1 */
Justin Holewinskiab0145d2011-05-06 11:40:36 +000040 PTX_VERSION_2_2, /*< PTX Version 2.2 */
41 PTX_VERSION_2_3 /*< PTX Version 2.3 */
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000042 };
43
Justin Holewinski67a91842011-06-23 18:10:03 +000044 private:
45
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000046 /// Shader Model supported on the target GPU.
47 PTXShaderModelEnum PTXShaderModel;
48
49 /// PTX Language Version.
50 PTXVersionEnum PTXVersion;
51
52 // The native .f64 type is supported on the hardware.
53 bool SupportsDouble;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000054
55 // Support the fused-multiply add (FMA) and multiply-add (MAD)
56 // instructions
Justin Holewinski657d1be2011-05-18 15:42:23 +000057 bool SupportsFMA;
Justin Holewinskiec3141b2011-06-16 15:17:11 +000058
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000059 // Use .u64 instead of .u32 for addresses.
Justin Holewinskie1fee482011-04-20 15:37:17 +000060 bool Is64Bit;
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000061
Eric Christopher50880d02010-09-18 18:52:28 +000062 public:
Justin Holewinski67a91842011-06-23 18:10:03 +000063
Justin Holewinskie1fee482011-04-20 15:37:17 +000064 PTXSubtarget(const std::string &TT, const std::string &FS, bool is64Bit);
Eric Christopher50880d02010-09-18 18:52:28 +000065
Justin Holewinski67a91842011-06-23 18:10:03 +000066 // Target architecture accessors
Che-Liang Chioufd8978b2011-03-02 03:20:28 +000067 std::string getTargetString() const;
68
69 std::string getPTXVersionString() const;
70
71 bool supportsDouble() const { return SupportsDouble; }
72
Justin Holewinskie1fee482011-04-20 15:37:17 +000073 bool is64Bit() const { return Is64Bit; }
Che-Liang Chiouf48817c2011-03-02 07:36:48 +000074
Justin Holewinski657d1be2011-05-18 15:42:23 +000075 bool supportsFMA() const { return SupportsFMA; }
Justin Holewinskiec3141b2011-06-16 15:17:11 +000076
Justin Holewinskifca9efc2011-03-10 16:57:18 +000077 bool supportsSM13() const { return PTXShaderModel >= PTX_SM_1_3; }
78
79 bool supportsSM20() const { return PTXShaderModel >= PTX_SM_2_0; }
80
Justin Holewinskifca9efc2011-03-10 16:57:18 +000081 bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; }
82
Justin Holewinski625eec12011-03-15 13:24:15 +000083 bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; }
84
Justin Holewinski0d109702011-05-10 12:32:11 +000085 bool supportsPTX23() const { return PTXVersion >= PTX_VERSION_2_3; }
86
Justin Holewinski67a91842011-06-23 18:10:03 +000087 PTXShaderModelEnum getShaderModel() const { return PTXShaderModel; }
88
89
Eric Christopher50880d02010-09-18 18:52:28 +000090 std::string ParseSubtargetFeatures(const std::string &FS,
91 const std::string &CPU);
92 }; // class PTXSubtarget
93} // namespace llvm
94
95#endif // PTX_SUBTARGET_H