• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 #define GET_SUBTARGETINFO_HEADER
21 #include "NVPTXGenSubtargetInfo.inc"
22 
23 #include <string>
24 
25 namespace llvm {
26 
27 class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
28 
29   std::string TargetName;
30   NVPTX::DrvInterface drvInterface;
31   bool Is64Bit;
32 
33   // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
34   unsigned PTXVersion;
35 
36   // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
37   unsigned int SmVersion;
38 
39 public:
40   /// This constructor initializes the data members to match that
41   /// of the specified module.
42   ///
43   NVPTXSubtarget(const std::string &TT, const std::string &CPU,
44                  const std::string &FS, bool is64Bit);
45 
hasBrkPt()46   bool hasBrkPt() const { return SmVersion >= 11; }
hasAtomRedG32()47   bool hasAtomRedG32() const { return SmVersion >= 11; }
hasAtomRedS32()48   bool hasAtomRedS32() const { return SmVersion >= 12; }
hasAtomRedG64()49   bool hasAtomRedG64() const { return SmVersion >= 12; }
hasAtomRedS64()50   bool hasAtomRedS64() const { return SmVersion >= 20; }
hasAtomRedGen32()51   bool hasAtomRedGen32() const { return SmVersion >= 20; }
hasAtomRedGen64()52   bool hasAtomRedGen64() const { return SmVersion >= 20; }
hasAtomAddF32()53   bool hasAtomAddF32() const { return SmVersion >= 20; }
hasVote()54   bool hasVote() const { return SmVersion >= 12; }
hasDouble()55   bool hasDouble() const { return SmVersion >= 13; }
reqPTX20()56   bool reqPTX20() const { return SmVersion >= 20; }
hasF32FTZ()57   bool hasF32FTZ() const { return SmVersion >= 20; }
hasFMAF32()58   bool hasFMAF32() const { return SmVersion >= 20; }
hasFMAF64()59   bool hasFMAF64() const { return SmVersion >= 13; }
hasLDG()60   bool hasLDG() const { return SmVersion >= 32; }
hasLDU()61   bool hasLDU() const { return SmVersion >= 20; }
hasGenericLdSt()62   bool hasGenericLdSt() const { return SmVersion >= 20; }
hasHWROT32()63   inline bool hasHWROT32() const { return false; }
hasSWROT32()64   inline bool hasSWROT32() const {
65     return true;
66   }
hasROT32()67   inline bool hasROT32() const { return hasHWROT32() || hasSWROT32() ; }
hasROT64()68   inline bool hasROT64() const { return SmVersion >= 20; }
69 
70 
is64Bit()71   bool is64Bit() const { return Is64Bit; }
72 
getSmVersion()73   unsigned int getSmVersion() const { return SmVersion; }
getDrvInterface()74   NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
getTargetName()75   std::string getTargetName() const { return TargetName; }
76 
getPTXVersion()77   unsigned getPTXVersion() const { return PTXVersion; }
78 
79   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
80 
getDataLayout()81   std::string getDataLayout() const {
82     const char *p;
83     if (is64Bit())
84       p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
85           "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
86           "n16:32:64";
87     else
88       p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
89           "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
90           "n16:32:64";
91 
92     return std::string(p);
93   }
94 
95 };
96 
97 } // End llvm namespace
98 
99 #endif  // NVPTXSUBTARGET_H
100