1 //=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- C++ -*--====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the NVPTX specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
18 #include "NVPTXFrameLowering.h"
19 #include "NVPTXISelLowering.h"
20 #include "NVPTXInstrInfo.h"
21 #include "NVPTXRegisterInfo.h"
22 #include "llvm/IR/DataLayout.h"
23 #include "llvm/Target/TargetSelectionDAGInfo.h"
24 #include "llvm/Target/TargetSubtargetInfo.h"
27 #define GET_SUBTARGETINFO_HEADER
28 #include "NVPTXGenSubtargetInfo.inc"
32 class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
33 virtual void anchor();
34 std::string TargetName;
35 NVPTX::DrvInterface drvInterface;
38 // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
41 // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
42 unsigned int SmVersion;
44 const DataLayout DL; // Calculates type size & alignment
45 NVPTXInstrInfo InstrInfo;
46 NVPTXTargetLowering TLInfo;
47 TargetSelectionDAGInfo TSInfo;
49 // NVPTX does not have any call stack frame, but need a NVPTX specific
50 // FrameLowering class because TargetFrameLowering is abstract.
51 NVPTXFrameLowering FrameLowering;
54 /// This constructor initializes the data members to match that
55 /// of the specified module.
57 NVPTXSubtarget(const std::string &TT, const std::string &CPU,
58 const std::string &FS, const TargetMachine &TM, bool is64Bit);
60 const TargetFrameLowering *getFrameLowering() const override {
61 return &FrameLowering;
63 const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
64 const DataLayout *getDataLayout() const override { return &DL; }
65 const NVPTXRegisterInfo *getRegisterInfo() const override {
66 return &InstrInfo.getRegisterInfo();
68 const NVPTXTargetLowering *getTargetLowering() const override {
71 const TargetSelectionDAGInfo *getSelectionDAGInfo() const override {
75 bool hasBrkPt() const { return SmVersion >= 11; }
76 bool hasAtomRedG32() const { return SmVersion >= 11; }
77 bool hasAtomRedS32() const { return SmVersion >= 12; }
78 bool hasAtomRedG64() const { return SmVersion >= 12; }
79 bool hasAtomRedS64() const { return SmVersion >= 20; }
80 bool hasAtomRedGen32() const { return SmVersion >= 20; }
81 bool hasAtomRedGen64() const { return SmVersion >= 20; }
82 bool hasAtomAddF32() const { return SmVersion >= 20; }
83 bool hasVote() const { return SmVersion >= 12; }
84 bool hasDouble() const { return SmVersion >= 13; }
85 bool reqPTX20() const { return SmVersion >= 20; }
86 bool hasF32FTZ() const { return SmVersion >= 20; }
87 bool hasFMAF32() const { return SmVersion >= 20; }
88 bool hasFMAF64() const { return SmVersion >= 13; }
89 bool hasLDG() const { return SmVersion >= 32; }
90 bool hasLDU() const { return ((SmVersion >= 20) && (SmVersion < 30)); }
91 bool hasGenericLdSt() const { return SmVersion >= 20; }
92 inline bool hasHWROT32() const { return SmVersion >= 32; }
93 inline bool hasSWROT32() const {
94 return ((SmVersion >= 20) && (SmVersion < 32));
96 inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
97 inline bool hasROT64() const { return SmVersion >= 20; }
99 bool hasImageHandles() const {
100 // Enable handles for Kepler+, where CUDA supports indirect surfaces and
102 if (getDrvInterface() == NVPTX::CUDA)
103 return (SmVersion >= 30);
105 // Disabled, otherwise
108 bool is64Bit() const { return Is64Bit; }
110 unsigned int getSmVersion() const { return SmVersion; }
111 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
112 std::string getTargetName() const { return TargetName; }
114 unsigned getPTXVersion() const { return PTXVersion; }
116 NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
117 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
120 } // End llvm namespace