LLVM API Documentation
00001 //=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- C++ -*--====// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares the NVPTX specific subclass of TargetSubtarget. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H 00015 #define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H 00016 00017 #include "NVPTX.h" 00018 #include "NVPTXFrameLowering.h" 00019 #include "NVPTXISelLowering.h" 00020 #include "NVPTXInstrInfo.h" 00021 #include "NVPTXRegisterInfo.h" 00022 #include "llvm/IR/DataLayout.h" 00023 #include "llvm/Target/TargetSelectionDAGInfo.h" 00024 #include "llvm/Target/TargetSubtargetInfo.h" 00025 #include <string> 00026 00027 #define GET_SUBTARGETINFO_HEADER 00028 #include "NVPTXGenSubtargetInfo.inc" 00029 00030 namespace llvm { 00031 00032 class NVPTXSubtarget : public NVPTXGenSubtargetInfo { 00033 virtual void anchor(); 00034 std::string TargetName; 00035 NVPTX::DrvInterface drvInterface; 00036 bool Is64Bit; 00037 00038 // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31 00039 unsigned PTXVersion; 00040 00041 // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31 00042 unsigned int SmVersion; 00043 00044 const DataLayout DL; // Calculates type size & alignment 00045 NVPTXInstrInfo InstrInfo; 00046 NVPTXTargetLowering TLInfo; 00047 TargetSelectionDAGInfo TSInfo; 00048 00049 // NVPTX does not have any call stack frame, but need a NVPTX specific 00050 // FrameLowering class because TargetFrameLowering is abstract. 00051 NVPTXFrameLowering FrameLowering; 00052 00053 public: 00054 /// This constructor initializes the data members to match that 00055 /// of the specified module. 00056 /// 00057 NVPTXSubtarget(const std::string &TT, const std::string &CPU, 00058 const std::string &FS, const TargetMachine &TM, bool is64Bit); 00059 00060 const TargetFrameLowering *getFrameLowering() const override { 00061 return &FrameLowering; 00062 } 00063 const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; } 00064 const DataLayout *getDataLayout() const override { return &DL; } 00065 const NVPTXRegisterInfo *getRegisterInfo() const override { 00066 return &InstrInfo.getRegisterInfo(); 00067 } 00068 const NVPTXTargetLowering *getTargetLowering() const override { 00069 return &TLInfo; 00070 } 00071 const TargetSelectionDAGInfo *getSelectionDAGInfo() const override { 00072 return &TSInfo; 00073 } 00074 00075 bool hasBrkPt() const { return SmVersion >= 11; } 00076 bool hasAtomRedG32() const { return SmVersion >= 11; } 00077 bool hasAtomRedS32() const { return SmVersion >= 12; } 00078 bool hasAtomRedG64() const { return SmVersion >= 12; } 00079 bool hasAtomRedS64() const { return SmVersion >= 20; } 00080 bool hasAtomRedGen32() const { return SmVersion >= 20; } 00081 bool hasAtomRedGen64() const { return SmVersion >= 20; } 00082 bool hasAtomAddF32() const { return SmVersion >= 20; } 00083 bool hasVote() const { return SmVersion >= 12; } 00084 bool hasDouble() const { return SmVersion >= 13; } 00085 bool reqPTX20() const { return SmVersion >= 20; } 00086 bool hasF32FTZ() const { return SmVersion >= 20; } 00087 bool hasFMAF32() const { return SmVersion >= 20; } 00088 bool hasFMAF64() const { return SmVersion >= 13; } 00089 bool hasLDG() const { return SmVersion >= 32; } 00090 bool hasLDU() const { return ((SmVersion >= 20) && (SmVersion < 30)); } 00091 bool hasGenericLdSt() const { return SmVersion >= 20; } 00092 inline bool hasHWROT32() const { return SmVersion >= 32; } 00093 inline bool hasSWROT32() const { 00094 return ((SmVersion >= 20) && (SmVersion < 32)); 00095 } 00096 inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); } 00097 inline bool hasROT64() const { return SmVersion >= 20; } 00098 00099 bool hasImageHandles() const { 00100 // Enable handles for Kepler+, where CUDA supports indirect surfaces and 00101 // textures 00102 if (getDrvInterface() == NVPTX::CUDA) 00103 return (SmVersion >= 30); 00104 00105 // Disabled, otherwise 00106 return false; 00107 } 00108 bool is64Bit() const { return Is64Bit; } 00109 00110 unsigned int getSmVersion() const { return SmVersion; } 00111 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; } 00112 std::string getTargetName() const { return TargetName; } 00113 00114 unsigned getPTXVersion() const { return PTXVersion; } 00115 00116 NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); 00117 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 00118 }; 00119 00120 } // End llvm namespace 00121 00122 #endif