1 //=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- C++ -*--====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the NVPTX specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef NVPTXSUBTARGET_H
15 #define NVPTXSUBTARGET_H
18 #include "llvm/Target/TargetSubtargetInfo.h"
20 #define GET_SUBTARGETINFO_HEADER
21 #include "NVPTXGenSubtargetInfo.inc"
27 class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
29 std::string TargetName;
30 NVPTX::DrvInterface drvInterface;
33 // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
36 // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
37 unsigned int SmVersion;
39 virtual void anchor();
42 /// This constructor initializes the data members to match that
43 /// of the specified module.
45 NVPTXSubtarget(const std::string &TT, const std::string &CPU,
46 const std::string &FS, bool is64Bit);
48 bool hasBrkPt() const { return SmVersion >= 11; }
49 bool hasAtomRedG32() const { return SmVersion >= 11; }
50 bool hasAtomRedS32() const { return SmVersion >= 12; }
51 bool hasAtomRedG64() const { return SmVersion >= 12; }
52 bool hasAtomRedS64() const { return SmVersion >= 20; }
53 bool hasAtomRedGen32() const { return SmVersion >= 20; }
54 bool hasAtomRedGen64() const { return SmVersion >= 20; }
55 bool hasAtomAddF32() const { return SmVersion >= 20; }
56 bool hasVote() const { return SmVersion >= 12; }
57 bool hasDouble() const { return SmVersion >= 13; }
58 bool reqPTX20() const { return SmVersion >= 20; }
59 bool hasF32FTZ() const { return SmVersion >= 20; }
60 bool hasFMAF32() const { return SmVersion >= 20; }
61 bool hasFMAF64() const { return SmVersion >= 13; }
62 bool hasLDG() const { return SmVersion >= 32; }
63 bool hasLDU() const { return SmVersion >= 20; }
64 bool hasGenericLdSt() const { return SmVersion >= 20; }
65 inline bool hasHWROT32() const { return false; }
66 inline bool hasSWROT32() const { return true; }
67 inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
68 inline bool hasROT64() const { return SmVersion >= 20; }
70 bool is64Bit() const { return Is64Bit; }
72 unsigned int getSmVersion() const { return SmVersion; }
73 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
74 std::string getTargetName() const { return TargetName; }
76 unsigned getPTXVersion() const { return PTXVersion; }
78 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
80 std::string getDataLayout() const {
83 p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
84 "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
87 p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
88 "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
91 return std::string(p);
96 } // End llvm namespace
98 #endif // NVPTXSUBTARGET_H