blob: 299bb93be67a8b76a5439d499a30c8d5a0e8e86c [file] [log] [blame]
Justin Holewinskiae556d32012-05-04 20:18:50 +00001//=====-- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
15#define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
Justin Holewinskiae556d32012-05-04 20:18:50 +000016
Justin Holewinskiae556d32012-05-04 20:18:50 +000017#include "NVPTX.h"
Eric Christopher493f91b2014-06-27 04:33:14 +000018#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"
Chandler Carruth802d7552012-12-04 07:12:27 +000024#include "llvm/Target/TargetSubtargetInfo.h"
Chandler Carruthff555932014-04-22 02:28:45 +000025#include <string>
Justin Holewinskiae556d32012-05-04 20:18:50 +000026
27#define GET_SUBTARGETINFO_HEADER
28#include "NVPTXGenSubtargetInfo.inc"
29
Justin Holewinskiae556d32012-05-04 20:18:50 +000030namespace llvm {
31
32class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000033 virtual void anchor();
Justin Holewinskiae556d32012-05-04 20:18:50 +000034 std::string TargetName;
Justin Holewinskiae556d32012-05-04 20:18:50 +000035 bool Is64Bit;
36
Justin Holewinski1812ee92012-11-12 03:16:43 +000037 // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
38 unsigned PTXVersion;
39
40 // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
41 unsigned int SmVersion;
42
Eric Christopher6aad8b12015-02-19 00:08:14 +000043 const NVPTXTargetMachine &TM;
Eric Christopher493f91b2014-06-27 04:33:14 +000044 NVPTXInstrInfo InstrInfo;
45 NVPTXTargetLowering TLInfo;
46 TargetSelectionDAGInfo TSInfo;
47
48 // NVPTX does not have any call stack frame, but need a NVPTX specific
49 // FrameLowering class because TargetFrameLowering is abstract.
50 NVPTXFrameLowering FrameLowering;
51
Justin Holewinskiae556d32012-05-04 20:18:50 +000052public:
53 /// This constructor initializes the data members to match that
54 /// of the specified module.
55 ///
56 NVPTXSubtarget(const std::string &TT, const std::string &CPU,
Eric Christopher6aad8b12015-02-19 00:08:14 +000057 const std::string &FS, const NVPTXTargetMachine &TM,
58 bool is64Bit);
Eric Christopher493f91b2014-06-27 04:33:14 +000059
Eric Christopherd9134482014-08-04 21:25:23 +000060 const TargetFrameLowering *getFrameLowering() const override {
61 return &FrameLowering;
62 }
63 const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
Eric Christopherd9134482014-08-04 21:25:23 +000064 const NVPTXRegisterInfo *getRegisterInfo() const override {
Eric Christopher493f91b2014-06-27 04:33:14 +000065 return &InstrInfo.getRegisterInfo();
66 }
Eric Christopherd9134482014-08-04 21:25:23 +000067 const NVPTXTargetLowering *getTargetLowering() const override {
68 return &TLInfo;
69 }
70 const TargetSelectionDAGInfo *getSelectionDAGInfo() const override {
71 return &TSInfo;
72 }
Justin Holewinskiae556d32012-05-04 20:18:50 +000073
74 bool hasBrkPt() const { return SmVersion >= 11; }
75 bool hasAtomRedG32() const { return SmVersion >= 11; }
76 bool hasAtomRedS32() const { return SmVersion >= 12; }
77 bool hasAtomRedG64() const { return SmVersion >= 12; }
78 bool hasAtomRedS64() const { return SmVersion >= 20; }
79 bool hasAtomRedGen32() const { return SmVersion >= 20; }
80 bool hasAtomRedGen64() const { return SmVersion >= 20; }
81 bool hasAtomAddF32() const { return SmVersion >= 20; }
82 bool hasVote() const { return SmVersion >= 12; }
83 bool hasDouble() const { return SmVersion >= 13; }
84 bool reqPTX20() const { return SmVersion >= 20; }
85 bool hasF32FTZ() const { return SmVersion >= 20; }
86 bool hasFMAF32() const { return SmVersion >= 20; }
87 bool hasFMAF64() const { return SmVersion >= 13; }
Justin Holewinskibe8dc642013-02-12 14:18:49 +000088 bool hasLDG() const { return SmVersion >= 32; }
Justin Holewinskic3f31eb2014-06-27 18:35:16 +000089 bool hasLDU() const { return ((SmVersion >= 20) && (SmVersion < 30)); }
Justin Holewinskiae556d32012-05-04 20:18:50 +000090 bool hasGenericLdSt() const { return SmVersion >= 20; }
Justin Holewinskic3f31eb2014-06-27 18:35:16 +000091 inline bool hasHWROT32() const { return SmVersion >= 32; }
92 inline bool hasSWROT32() const {
93 return ((SmVersion >= 20) && (SmVersion < 32));
94 }
Justin Holewinski0497ab12013-03-30 14:29:21 +000095 inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
Justin Holewinskiae556d32012-05-04 20:18:50 +000096 inline bool hasROT64() const { return SmVersion >= 20; }
97
Justin Holewinski30d56a72014-04-09 15:39:15 +000098 bool hasImageHandles() const {
Justin Holewinski9a2350e2014-07-17 11:59:04 +000099 // Enable handles for Kepler+, where CUDA supports indirect surfaces and
100 // textures
101 if (getDrvInterface() == NVPTX::CUDA)
102 return (SmVersion >= 30);
103
104 // Disabled, otherwise
Justin Holewinski30d56a72014-04-09 15:39:15 +0000105 return false;
106 }
Justin Holewinskiae556d32012-05-04 20:18:50 +0000107 bool is64Bit() const { return Is64Bit; }
108
109 unsigned int getSmVersion() const { return SmVersion; }
Eric Christopher6aad8b12015-02-19 00:08:14 +0000110 NVPTX::DrvInterface getDrvInterface() const;
Justin Holewinskiae556d32012-05-04 20:18:50 +0000111 std::string getTargetName() const { return TargetName; }
112
Justin Holewinski1812ee92012-11-12 03:16:43 +0000113 unsigned getPTXVersion() const { return PTXVersion; }
114
Eric Christopher493f91b2014-06-27 04:33:14 +0000115 NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +0000116 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +0000117};
118
119} // End llvm namespace
120
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000121#endif