NVPTXSubtarget.h revision dce4a407a24b04eebc6a376f8e62b41aaa7b071f
1//=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- 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 NVPTX specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef NVPTXSUBTARGET_H
15#define NVPTXSUBTARGET_H
16
17#include "NVPTX.h"
18#include "llvm/Target/TargetSubtargetInfo.h"
19#include <string>
20
21#define GET_SUBTARGETINFO_HEADER
22#include "NVPTXGenSubtargetInfo.inc"
23
24namespace llvm {
25
26class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
27  virtual void anchor();
28  std::string TargetName;
29  NVPTX::DrvInterface drvInterface;
30  bool Is64Bit;
31
32  // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
33  unsigned PTXVersion;
34
35  // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
36  unsigned int SmVersion;
37
38public:
39  /// This constructor initializes the data members to match that
40  /// of the specified module.
41  ///
42  NVPTXSubtarget(const std::string &TT, const std::string &CPU,
43                 const std::string &FS, bool is64Bit);
44
45  bool hasBrkPt() const { return SmVersion >= 11; }
46  bool hasAtomRedG32() const { return SmVersion >= 11; }
47  bool hasAtomRedS32() const { return SmVersion >= 12; }
48  bool hasAtomRedG64() const { return SmVersion >= 12; }
49  bool hasAtomRedS64() const { return SmVersion >= 20; }
50  bool hasAtomRedGen32() const { return SmVersion >= 20; }
51  bool hasAtomRedGen64() const { return SmVersion >= 20; }
52  bool hasAtomAddF32() const { return SmVersion >= 20; }
53  bool hasVote() const { return SmVersion >= 12; }
54  bool hasDouble() const { return SmVersion >= 13; }
55  bool reqPTX20() const { return SmVersion >= 20; }
56  bool hasF32FTZ() const { return SmVersion >= 20; }
57  bool hasFMAF32() const { return SmVersion >= 20; }
58  bool hasFMAF64() const { return SmVersion >= 13; }
59  bool hasLDG() const { return SmVersion >= 32; }
60  bool hasLDU() const { return SmVersion >= 20; }
61  bool hasGenericLdSt() const { return SmVersion >= 20; }
62  inline bool hasHWROT32() const { return false; }
63  inline bool hasSWROT32() const { return true; }
64  inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
65  inline bool hasROT64() const { return SmVersion >= 20; }
66
67  bool hasImageHandles() const {
68    // Currently disabled
69    return false;
70  }
71  bool is64Bit() const { return Is64Bit; }
72
73  unsigned int getSmVersion() const { return SmVersion; }
74  NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
75  std::string getTargetName() const { return TargetName; }
76
77  unsigned getPTXVersion() const { return PTXVersion; }
78
79  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
80};
81
82} // End llvm namespace
83
84#endif // NVPTXSUBTARGET_H
85