NVPTXSubtarget.h revision 249423
1239310Sdim//=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- C++ -*--====//
2239310Sdim//
3239310Sdim//                     The LLVM Compiler Infrastructure
4239310Sdim//
5239310Sdim// This file is distributed under the University of Illinois Open Source
6239310Sdim// License. See LICENSE.TXT for details.
7239310Sdim//
8239310Sdim//===----------------------------------------------------------------------===//
9239310Sdim//
10239310Sdim// This file declares the NVPTX specific subclass of TargetSubtarget.
11239310Sdim//
12239310Sdim//===----------------------------------------------------------------------===//
13239310Sdim
14239310Sdim#ifndef NVPTXSUBTARGET_H
15239310Sdim#define NVPTXSUBTARGET_H
16239310Sdim
17249423Sdim#include "NVPTX.h"
18239310Sdim#include "llvm/Target/TargetSubtargetInfo.h"
19239310Sdim
20239310Sdim#define GET_SUBTARGETINFO_HEADER
21239310Sdim#include "NVPTXGenSubtargetInfo.inc"
22239310Sdim
23239310Sdim#include <string>
24239310Sdim
25239310Sdimnamespace llvm {
26239310Sdim
27239310Sdimclass NVPTXSubtarget : public NVPTXGenSubtargetInfo {
28249423Sdim
29239310Sdim  std::string TargetName;
30239310Sdim  NVPTX::DrvInterface drvInterface;
31239310Sdim  bool Is64Bit;
32239310Sdim
33243830Sdim  // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
34243830Sdim  unsigned PTXVersion;
35243830Sdim
36243830Sdim  // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
37243830Sdim  unsigned int SmVersion;
38243830Sdim
39239310Sdimpublic:
40239310Sdim  /// This constructor initializes the data members to match that
41239310Sdim  /// of the specified module.
42239310Sdim  ///
43239310Sdim  NVPTXSubtarget(const std::string &TT, const std::string &CPU,
44239310Sdim                 const std::string &FS, bool is64Bit);
45239310Sdim
46239310Sdim  bool hasBrkPt() const { return SmVersion >= 11; }
47239310Sdim  bool hasAtomRedG32() const { return SmVersion >= 11; }
48239310Sdim  bool hasAtomRedS32() const { return SmVersion >= 12; }
49239310Sdim  bool hasAtomRedG64() const { return SmVersion >= 12; }
50239310Sdim  bool hasAtomRedS64() const { return SmVersion >= 20; }
51239310Sdim  bool hasAtomRedGen32() const { return SmVersion >= 20; }
52239310Sdim  bool hasAtomRedGen64() const { return SmVersion >= 20; }
53239310Sdim  bool hasAtomAddF32() const { return SmVersion >= 20; }
54239310Sdim  bool hasVote() const { return SmVersion >= 12; }
55239310Sdim  bool hasDouble() const { return SmVersion >= 13; }
56239310Sdim  bool reqPTX20() const { return SmVersion >= 20; }
57239310Sdim  bool hasF32FTZ() const { return SmVersion >= 20; }
58239310Sdim  bool hasFMAF32() const { return SmVersion >= 20; }
59239310Sdim  bool hasFMAF64() const { return SmVersion >= 13; }
60249423Sdim  bool hasLDG() const { return SmVersion >= 32; }
61239310Sdim  bool hasLDU() const { return SmVersion >= 20; }
62239310Sdim  bool hasGenericLdSt() const { return SmVersion >= 20; }
63239310Sdim  inline bool hasHWROT32() const { return false; }
64249423Sdim  inline bool hasSWROT32() const { return true; }
65249423Sdim  inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
66239310Sdim  inline bool hasROT64() const { return SmVersion >= 20; }
67239310Sdim
68239310Sdim  bool is64Bit() const { return Is64Bit; }
69239310Sdim
70239310Sdim  unsigned int getSmVersion() const { return SmVersion; }
71239310Sdim  NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
72239310Sdim  std::string getTargetName() const { return TargetName; }
73239310Sdim
74243830Sdim  unsigned getPTXVersion() const { return PTXVersion; }
75243830Sdim
76239310Sdim  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
77239310Sdim
78239310Sdim  std::string getDataLayout() const {
79239310Sdim    const char *p;
80239310Sdim    if (is64Bit())
81239310Sdim      p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
82239310Sdim          "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
83239310Sdim          "n16:32:64";
84239310Sdim    else
85239310Sdim      p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
86239310Sdim          "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
87239310Sdim          "n16:32:64";
88239310Sdim
89239310Sdim    return std::string(p);
90239310Sdim  }
91239310Sdim
92239310Sdim};
93239310Sdim
94239310Sdim} // End llvm namespace
95239310Sdim
96249423Sdim#endif // NVPTXSUBTARGET_H
97