NVPTXSubtarget.h revision 243830
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 17239310Sdim#include "llvm/Target/TargetSubtargetInfo.h" 18239310Sdim#include "NVPTX.h" 19239310Sdim 20239310Sdim#define GET_SUBTARGETINFO_HEADER 21239310Sdim#include "NVPTXGenSubtargetInfo.inc" 22239310Sdim 23239310Sdim#include <string> 24239310Sdim 25239310Sdimnamespace llvm { 26239310Sdim 27239310Sdimclass NVPTXSubtarget : public NVPTXGenSubtargetInfo { 28243830Sdim 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; } 60239310Sdim bool hasLDU() const { return SmVersion >= 20; } 61239310Sdim bool hasGenericLdSt() const { return SmVersion >= 20; } 62239310Sdim inline bool hasHWROT32() const { return false; } 63239310Sdim inline bool hasSWROT32() const { 64239310Sdim return true; 65239310Sdim } 66239310Sdim inline bool hasROT32() const { return hasHWROT32() || hasSWROT32() ; } 67239310Sdim inline bool hasROT64() const { return SmVersion >= 20; } 68239310Sdim 69239310Sdim 70239310Sdim bool is64Bit() const { return Is64Bit; } 71239310Sdim 72239310Sdim unsigned int getSmVersion() const { return SmVersion; } 73239310Sdim NVPTX::DrvInterface getDrvInterface() const { return drvInterface; } 74239310Sdim std::string getTargetName() const { return TargetName; } 75239310Sdim 76243830Sdim unsigned getPTXVersion() const { return PTXVersion; } 77243830Sdim 78239310Sdim void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 79239310Sdim 80239310Sdim std::string getDataLayout() const { 81239310Sdim const char *p; 82239310Sdim if (is64Bit()) 83239310Sdim p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" 84239310Sdim "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-" 85239310Sdim "n16:32:64"; 86239310Sdim else 87239310Sdim p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" 88239310Sdim "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-" 89239310Sdim "n16:32:64"; 90239310Sdim 91239310Sdim return std::string(p); 92239310Sdim } 93239310Sdim 94239310Sdim}; 95239310Sdim 96239310Sdim} // End llvm namespace 97239310Sdim 98239310Sdim#endif // NVPTXSUBTARGET_H 99