blob: 4c41e4e470dd431377735a1ae3a87378c7ade2d3 [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
14#ifndef NVPTXSUBTARGET_H
15#define NVPTXSUBTARGET_H
16
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;
35 NVPTX::DrvInterface drvInterface;
Justin Holewinskiae556d32012-05-04 20:18:50 +000036 bool Is64Bit;
37
Justin Holewinski1812ee92012-11-12 03:16:43 +000038 // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
39 unsigned PTXVersion;
40
41 // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
42 unsigned int SmVersion;
43
Eric Christopher493f91b2014-06-27 04:33:14 +000044 const DataLayout DL; // Calculates type size & alignment
45 NVPTXInstrInfo InstrInfo;
46 NVPTXTargetLowering TLInfo;
47 TargetSelectionDAGInfo TSInfo;
48
49 // NVPTX does not have any call stack frame, but need a NVPTX specific
50 // FrameLowering class because TargetFrameLowering is abstract.
51 NVPTXFrameLowering FrameLowering;
52
Justin Holewinskiae556d32012-05-04 20:18:50 +000053public:
54 /// This constructor initializes the data members to match that
55 /// of the specified module.
56 ///
57 NVPTXSubtarget(const std::string &TT, const std::string &CPU,
Eric Christopher493f91b2014-06-27 04:33:14 +000058 const std::string &FS, const TargetMachine &TM, bool is64Bit);
59
60 const TargetFrameLowering *getFrameLowering() const { return &FrameLowering; }
61 const NVPTXInstrInfo *getInstrInfo() const { return &InstrInfo; }
62 const DataLayout *getDataLayout() const { return &DL; }
63 const NVPTXRegisterInfo *getRegisterInfo() const {
64 return &InstrInfo.getRegisterInfo();
65 }
66 const NVPTXTargetLowering *getTargetLowering() const { return &TLInfo; }
67 const TargetSelectionDAGInfo *getSelectionDAGInfo() const { return &TSInfo; }
Justin Holewinskiae556d32012-05-04 20:18:50 +000068
69 bool hasBrkPt() const { return SmVersion >= 11; }
70 bool hasAtomRedG32() const { return SmVersion >= 11; }
71 bool hasAtomRedS32() const { return SmVersion >= 12; }
72 bool hasAtomRedG64() const { return SmVersion >= 12; }
73 bool hasAtomRedS64() const { return SmVersion >= 20; }
74 bool hasAtomRedGen32() const { return SmVersion >= 20; }
75 bool hasAtomRedGen64() const { return SmVersion >= 20; }
76 bool hasAtomAddF32() const { return SmVersion >= 20; }
77 bool hasVote() const { return SmVersion >= 12; }
78 bool hasDouble() const { return SmVersion >= 13; }
79 bool reqPTX20() const { return SmVersion >= 20; }
80 bool hasF32FTZ() const { return SmVersion >= 20; }
81 bool hasFMAF32() const { return SmVersion >= 20; }
82 bool hasFMAF64() const { return SmVersion >= 13; }
Justin Holewinskibe8dc642013-02-12 14:18:49 +000083 bool hasLDG() const { return SmVersion >= 32; }
Justin Holewinskic3f31eb2014-06-27 18:35:16 +000084 bool hasLDU() const { return ((SmVersion >= 20) && (SmVersion < 30)); }
Justin Holewinskiae556d32012-05-04 20:18:50 +000085 bool hasGenericLdSt() const { return SmVersion >= 20; }
Justin Holewinskic3f31eb2014-06-27 18:35:16 +000086 inline bool hasHWROT32() const { return SmVersion >= 32; }
87 inline bool hasSWROT32() const {
88 return ((SmVersion >= 20) && (SmVersion < 32));
89 }
Justin Holewinski0497ab12013-03-30 14:29:21 +000090 inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
Justin Holewinskiae556d32012-05-04 20:18:50 +000091 inline bool hasROT64() const { return SmVersion >= 20; }
92
Justin Holewinski30d56a72014-04-09 15:39:15 +000093 bool hasImageHandles() const {
Justin Holewinski9a2350e2014-07-17 11:59:04 +000094 // Enable handles for Kepler+, where CUDA supports indirect surfaces and
95 // textures
96 if (getDrvInterface() == NVPTX::CUDA)
97 return (SmVersion >= 30);
98
99 // Disabled, otherwise
Justin Holewinski30d56a72014-04-09 15:39:15 +0000100 return false;
101 }
Justin Holewinskiae556d32012-05-04 20:18:50 +0000102 bool is64Bit() const { return Is64Bit; }
103
104 unsigned int getSmVersion() const { return SmVersion; }
105 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
106 std::string getTargetName() const { return TargetName; }
107
Justin Holewinski1812ee92012-11-12 03:16:43 +0000108 unsigned getPTXVersion() const { return PTXVersion; }
109
Eric Christopher493f91b2014-06-27 04:33:14 +0000110 NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +0000111 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +0000112};
113
114} // End llvm namespace
115
Justin Holewinski0497ab12013-03-30 14:29:21 +0000116#endif // NVPTXSUBTARGET_H