2ebe6cfdc839fb8b7cefa2752deeb80140354709
[oota-llvm.git] / lib / Target / PTX / PTXSubtarget.h
1 //====-- 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
19 namespace llvm {
20   class PTXSubtarget : public TargetSubtarget {
21     public:
22
23       /**
24        * Enumeration of Shader Models supported by the back-end.
25        */
26       enum PTXShaderModelEnum {
27         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 */
30       };
31
32       /**
33        * Enumeration of PTX versions supported by the back-end.
34        *
35        * Currently, PTX 2.0 is the minimum supported version.
36        */
37       enum PTXVersionEnum {
38         PTX_VERSION_2_0,  /*< PTX Version 2.0 */
39         PTX_VERSION_2_1,  /*< PTX Version 2.1 */
40         PTX_VERSION_2_2,  /*< PTX Version 2.2 */
41         PTX_VERSION_2_3   /*< PTX Version 2.3 */
42       };
43
44   private:
45
46       /// 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;
54
55       // Support the fused-multiply add (FMA) and multiply-add (MAD)
56       // instructions
57       bool SupportsFMA;
58
59       // Use .u64 instead of .u32 for addresses.
60       bool Is64Bit;
61
62     public:
63
64       PTXSubtarget(const std::string &TT, const std::string &FS, bool is64Bit);
65
66       // Target architecture accessors
67       std::string getTargetString() const;
68
69       std::string getPTXVersionString() const;
70
71       bool supportsDouble() const { return SupportsDouble; }
72
73       bool is64Bit() const { return Is64Bit; }
74
75       bool supportsFMA() const { return SupportsFMA; }
76
77       bool supportsSM13() const { return PTXShaderModel >= PTX_SM_1_3; }
78
79       bool supportsSM20() const { return PTXShaderModel >= PTX_SM_2_0; }
80
81       bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; }
82
83       bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; }
84
85       bool supportsPTX23() const { return PTXVersion >= PTX_VERSION_2_3; }
86
87       PTXShaderModelEnum getShaderModel() const { return PTXShaderModel; }
88
89
90       std::string ParseSubtargetFeatures(const std::string &FS,
91                                          const std::string &CPU);
92   }; // class PTXSubtarget
93 } // namespace llvm
94
95 #endif // PTX_SUBTARGET_H