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;
36 // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
39 // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
40 unsigned int SmVersion;
42 const NVPTXTargetMachine &TM;
43 NVPTXInstrInfo InstrInfo;
44 NVPTXTargetLowering TLInfo;
45 TargetSelectionDAGInfo TSInfo;
47 // NVPTX does not have any call stack frame, but need a NVPTX specific
48 // FrameLowering class because TargetFrameLowering is abstract.
49 NVPTXFrameLowering FrameLowering;
52 /// This constructor initializes the data members to match that
53 /// of the specified module.
55 NVPTXSubtarget(const Triple &TT, const std::string &CPU,
56 const std::string &FS, const NVPTXTargetMachine &TM);
58 const TargetFrameLowering *getFrameLowering() const override {
59 return &FrameLowering;
61 const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
62 const NVPTXRegisterInfo *getRegisterInfo() const override {
63 return &InstrInfo.getRegisterInfo();
65 const NVPTXTargetLowering *getTargetLowering() const override {
68 const TargetSelectionDAGInfo *getSelectionDAGInfo() const override {
72 bool hasBrkPt() const { return SmVersion >= 11; }
73 bool hasAtomRedG32() const { return SmVersion >= 11; }
74 bool hasAtomRedS32() const { return SmVersion >= 12; }
75 bool hasAtomRedG64() const { return SmVersion >= 12; }
76 bool hasAtomRedS64() const { return SmVersion >= 20; }
77 bool hasAtomRedGen32() const { return SmVersion >= 20; }
78 bool hasAtomRedGen64() const { return SmVersion >= 20; }
79 bool hasAtomAddF32() const { return SmVersion >= 20; }
80 bool hasVote() const { return SmVersion >= 12; }
81 bool hasDouble() const { return SmVersion >= 13; }
82 bool reqPTX20() const { return SmVersion >= 20; }
83 bool hasF32FTZ() const { return SmVersion >= 20; }
84 bool hasFMAF32() const { return SmVersion >= 20; }
85 bool hasFMAF64() const { return SmVersion >= 13; }
86 bool hasLDG() const { return SmVersion >= 32; }
87 bool hasLDU() const { return ((SmVersion >= 20) && (SmVersion < 30)); }
88 bool hasGenericLdSt() const { return SmVersion >= 20; }
89 inline bool hasHWROT32() const { return SmVersion >= 32; }
90 inline bool hasSWROT32() const {
91 return ((SmVersion >= 20) && (SmVersion < 32));
93 inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
94 inline bool hasROT64() const { return SmVersion >= 20; }
95 bool hasImageHandles() const;
97 unsigned int getSmVersion() const { return SmVersion; }
98 std::string getTargetName() const { return TargetName; }
100 unsigned getPTXVersion() const { return PTXVersion; }
102 NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
103 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
106 } // End llvm namespace