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 LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H 15 #define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H 16 17 #include "NVPTX.h" 18 #include "NVPTXFrameLowering.h" 19 #include "NVPTXISelLowering.h" 20 #include "NVPTXInstrInfo.h" 21 #include "NVPTXRegisterInfo.h" 22 #include "llvm/CodeGen/SelectionDAGTargetInfo.h" 23 #include "llvm/CodeGen/TargetSubtargetInfo.h" 24 #include "llvm/IR/DataLayout.h" 25 #include <string> 26 27 #define GET_SUBTARGETINFO_HEADER 28 #include "NVPTXGenSubtargetInfo.inc" 29 30 namespace llvm { 31 32 class NVPTXSubtarget : public NVPTXGenSubtargetInfo { 33 virtual void anchor(); 34 std::string TargetName; 35 36 // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31 37 unsigned PTXVersion; 38 39 // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31 40 unsigned int SmVersion; 41 42 const NVPTXTargetMachine &TM; 43 NVPTXInstrInfo InstrInfo; 44 NVPTXTargetLowering TLInfo; 45 SelectionDAGTargetInfo TSInfo; 46 47 // NVPTX does not have any call stack frame, but need a NVPTX specific 48 // FrameLowering class because TargetFrameLowering is abstract. 49 NVPTXFrameLowering FrameLowering; 50 51 public: 52 /// This constructor initializes the data members to match that 53 /// of the specified module. 54 /// 55 NVPTXSubtarget(const Triple &TT, const std::string &CPU, 56 const std::string &FS, const NVPTXTargetMachine &TM); 57 getFrameLowering()58 const TargetFrameLowering *getFrameLowering() const override { 59 return &FrameLowering; 60 } getInstrInfo()61 const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; } getRegisterInfo()62 const NVPTXRegisterInfo *getRegisterInfo() const override { 63 return &InstrInfo.getRegisterInfo(); 64 } getTargetLowering()65 const NVPTXTargetLowering *getTargetLowering() const override { 66 return &TLInfo; 67 } getSelectionDAGInfo()68 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { 69 return &TSInfo; 70 } 71 hasAtomAddF64()72 bool hasAtomAddF64() const { return SmVersion >= 60; } hasAtomScope()73 bool hasAtomScope() const { return SmVersion >= 60; } hasAtomBitwise64()74 bool hasAtomBitwise64() const { return SmVersion >= 32; } hasAtomMinMax64()75 bool hasAtomMinMax64() const { return SmVersion >= 32; } hasLDG()76 bool hasLDG() const { return SmVersion >= 32; } hasHWROT32()77 inline bool hasHWROT32() const { return SmVersion >= 32; } 78 bool hasImageHandles() const; hasFP16Math()79 bool hasFP16Math() const { return SmVersion >= 53; } 80 bool allowFP16Math() const; getSmVersion()81 unsigned int getSmVersion() const { return SmVersion; } getTargetName()82 std::string getTargetName() const { return TargetName; } 83 getPTXVersion()84 unsigned getPTXVersion() const { return PTXVersion; } 85 86 NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); 87 void ParseSubtargetFeatures(StringRef CPU, StringRef FS); 88 }; 89 90 } // End llvm namespace 91 92 #endif 93