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 "llvm/Target/TargetSubtargetInfo.h" 18 #include "NVPTX.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 unsigned int SmVersion; 30 std::string TargetName; 31 NVPTX::DrvInterface drvInterface; 32 bool dummy; // For the 'dummy' feature, see NVPTX.td 33 bool Is64Bit; 34 35 public: 36 /// This constructor initializes the data members to match that 37 /// of the specified module. 38 /// 39 NVPTXSubtarget(const std::string &TT, const std::string &CPU, 40 const std::string &FS, bool is64Bit); 41 hasBrkPt()42 bool hasBrkPt() const { return SmVersion >= 11; } hasAtomRedG32()43 bool hasAtomRedG32() const { return SmVersion >= 11; } hasAtomRedS32()44 bool hasAtomRedS32() const { return SmVersion >= 12; } hasAtomRedG64()45 bool hasAtomRedG64() const { return SmVersion >= 12; } hasAtomRedS64()46 bool hasAtomRedS64() const { return SmVersion >= 20; } hasAtomRedGen32()47 bool hasAtomRedGen32() const { return SmVersion >= 20; } hasAtomRedGen64()48 bool hasAtomRedGen64() const { return SmVersion >= 20; } hasAtomAddF32()49 bool hasAtomAddF32() const { return SmVersion >= 20; } hasVote()50 bool hasVote() const { return SmVersion >= 12; } hasDouble()51 bool hasDouble() const { return SmVersion >= 13; } reqPTX20()52 bool reqPTX20() const { return SmVersion >= 20; } hasF32FTZ()53 bool hasF32FTZ() const { return SmVersion >= 20; } hasFMAF32()54 bool hasFMAF32() const { return SmVersion >= 20; } hasFMAF64()55 bool hasFMAF64() const { return SmVersion >= 13; } hasLDU()56 bool hasLDU() const { return SmVersion >= 20; } hasGenericLdSt()57 bool hasGenericLdSt() const { return SmVersion >= 20; } hasHWROT32()58 inline bool hasHWROT32() const { return false; } hasSWROT32()59 inline bool hasSWROT32() const { 60 return true; 61 } hasROT32()62 inline bool hasROT32() const { return hasHWROT32() || hasSWROT32() ; } hasROT64()63 inline bool hasROT64() const { return SmVersion >= 20; } 64 65 is64Bit()66 bool is64Bit() const { return Is64Bit; } 67 getSmVersion()68 unsigned int getSmVersion() const { return SmVersion; } getDrvInterface()69 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; } getTargetName()70 std::string getTargetName() const { return TargetName; } 71 72 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 73 getDataLayout()74 std::string getDataLayout() const { 75 const char *p; 76 if (is64Bit()) 77 p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" 78 "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-" 79 "n16:32:64"; 80 else 81 p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" 82 "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-" 83 "n16:32:64"; 84 85 return std::string(p); 86 } 87 88 }; 89 90 } // End llvm namespace 91 92 #endif // NVPTXSUBTARGET_H 93