summaryrefslogtreecommitdiff
path: root/lib/Target/PTX/PTXSubtarget.h
blob: 57cd43da4763190b4943f1a5fc7b538d16ba8af3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//====-- PTXSubtarget.h - Define Subtarget for the PTX ---------*- C++ -*--===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the PTX specific subclass of TargetSubtarget.
//
//===----------------------------------------------------------------------===//

#ifndef PTX_SUBTARGET_H
#define PTX_SUBTARGET_H

#include "llvm/Target/TargetSubtarget.h"

namespace llvm {
  class PTXSubtarget : public TargetSubtarget {
    private:

      /**
       * Enumeration of Shader Models supported by the back-end.
       */
      enum PTXShaderModelEnum {
        PTX_SM_1_0, /*< Shader Model 1.0 */
        PTX_SM_1_3, /*< Shader Model 1.3 */
        PTX_SM_2_0  /*< Shader Model 2.0 */
      };

      /**
       * Enumeration of PTX versions supported by the back-end.
       *
       * Currently, PTX 2.0 is the minimum supported version.
       */
      enum PTXVersionEnum {
        PTX_VERSION_2_0,  /*< PTX Version 2.0 */
        PTX_VERSION_2_1,  /*< PTX Version 2.1 */
        PTX_VERSION_2_2   /*< PTX Version 2.2 */
      };

      /// Shader Model supported on the target GPU.
      PTXShaderModelEnum PTXShaderModel;

      /// PTX Language Version.
      PTXVersionEnum PTXVersion;

      // The native .f64 type is supported on the hardware.
      bool SupportsDouble;

      // Use .u64 instead of .u32 for addresses.
      bool Use64BitAddresses;

    public:
      PTXSubtarget(const std::string &TT, const std::string &FS);

      std::string getTargetString() const;

      std::string getPTXVersionString() const;

      bool supportsDouble() const { return SupportsDouble; }

      bool use64BitAddresses() const { return Use64BitAddresses; }

      bool supportsSM13() const { return PTXShaderModel >= PTX_SM_1_3; }

      bool supportsSM20() const { return PTXShaderModel >= PTX_SM_2_0; }

      bool supportsPTX21() const { return PTXVersion >= PTX_VERSION_2_1; }

      bool supportsPTX22() const { return PTXVersion >= PTX_VERSION_2_2; }

      std::string ParseSubtargetFeatures(const std::string &FS,
                                         const std::string &CPU);
  }; // class PTXSubtarget
} // namespace llvm

#endif // PTX_SUBTARGET_H