blob: a844b37b6be583e47e79435e1db43a99c6cb2bf8 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//=====-- AMDGPUSubtarget.h - Define Subtarget for the AMDIL ---*- 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/// \file
11/// \brief AMDGPU specific subclass of TargetSubtarget.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef AMDGPUSUBTARGET_H
16#define AMDGPUSUBTARGET_H
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000017#include "AMDGPU.h"
Tom Stellard2e59a452014-06-13 01:32:00 +000018#include "AMDGPUInstrInfo.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000019#include "llvm/ADT/StringExtras.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/Target/TargetSubtargetInfo.h"
22
23#define GET_SUBTARGETINFO_HEADER
24#include "AMDGPUGenSubtargetInfo.inc"
25
26#define MAX_CB_SIZE (1 << 16)
27
28namespace llvm {
29
30class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
Tom Stellard2e59a452014-06-13 01:32:00 +000031
32 std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
33
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000034public:
35 enum Generation {
36 R600 = 0,
37 R700,
38 EVERGREEN,
39 NORTHERN_ISLANDS,
Tom Stellard6e1ee472013-10-29 16:37:28 +000040 SOUTHERN_ISLANDS,
41 SEA_ISLANDS
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000042 };
43
Tom Stellard75aadc22012-12-11 21:25:42 +000044private:
Tom Stellard75aadc22012-12-11 21:25:42 +000045 std::string DevName;
46 bool Is64bit;
Tom Stellard75aadc22012-12-11 21:25:42 +000047 bool DumpCode;
48 bool R600ALUInst;
Vincent Lejeunec2991642013-04-30 00:13:39 +000049 bool HasVertexCache;
Vincent Lejeunef9f4e1e2013-05-17 16:49:55 +000050 short TexVTXClauseSize;
Matt Arsenaultd782d052014-06-27 17:57:00 +000051 Generation Gen;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000052 bool FP64;
Matt Arsenaultf171cf22014-07-14 23:40:49 +000053 bool FP64Denormals;
54 bool FP32Denormals;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000055 bool CaymanISA;
Tom Stellarded0ceec2013-10-10 17:11:12 +000056 bool EnableIRStructurizer;
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000057 bool EnablePromoteAlloca;
Tom Stellard783893a2013-11-18 19:43:33 +000058 bool EnableIfCvt;
Tom Stellard8c347b02014-01-22 21:55:40 +000059 unsigned WavefrontSize;
Tom Stellard348273d2014-01-23 16:18:02 +000060 bool CFALUBug;
Tom Stellard880a80a2014-06-17 16:53:14 +000061 int LocalMemorySize;
Tom Stellard75aadc22012-12-11 21:25:42 +000062
63 InstrItineraryData InstrItins;
64
65public:
66 AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +000067
Tom Stellard2e59a452014-06-13 01:32:00 +000068 const AMDGPUInstrInfo *getInstrInfo() const {
69 return InstrInfo.get();
70 }
Matt Arsenaultd782d052014-06-27 17:57:00 +000071
72 const InstrItineraryData &getInstrItineraryData() const {
73 return InstrItins;
74 }
75
Craig Topperee7b0f32014-04-30 05:53:27 +000076 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +000077
Matt Arsenaultd782d052014-06-27 17:57:00 +000078 bool is64bit() const {
79 return Is64bit;
80 }
81
82 bool hasVertexCache() const {
83 return HasVertexCache;
84 }
85
86 short getTexVTXClauseSize() const {
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000087 return TexVTXClauseSize;
Matt Arsenaultd782d052014-06-27 17:57:00 +000088 }
89
90 Generation getGeneration() const {
91 return Gen;
92 }
93
94 bool hasHWFP64() const {
95 return FP64;
96 }
97
98 bool hasCaymanISA() const {
99 return CaymanISA;
100 }
Matt Arsenaultfae02982014-03-17 18:58:11 +0000101
Matt Arsenaultf171cf22014-07-14 23:40:49 +0000102 bool hasFP32Denormals() const {
103 return FP32Denormals;
104 }
105
106 bool hasFP64Denormals() const {
107 return FP64Denormals;
108 }
109
Matt Arsenaultfae02982014-03-17 18:58:11 +0000110 bool hasBFE() const {
111 return (getGeneration() >= EVERGREEN);
112 }
113
Matt Arsenault6e439652014-06-10 19:00:20 +0000114 bool hasBFI() const {
115 return (getGeneration() >= EVERGREEN);
116 }
117
Matt Arsenaultfae02982014-03-17 18:58:11 +0000118 bool hasBFM() const {
119 return hasBFE();
120 }
121
Matt Arsenault60425062014-06-10 19:18:28 +0000122 bool hasBCNT(unsigned Size) const {
123 if (Size == 32)
124 return (getGeneration() >= EVERGREEN);
125
Matt Arsenault3dd43fc2014-07-18 06:07:13 +0000126 if (Size == 64)
127 return (getGeneration() >= SOUTHERN_ISLANDS);
128
129 return false;
Matt Arsenault60425062014-06-10 19:18:28 +0000130 }
131
Tom Stellard50122a52014-04-07 19:45:41 +0000132 bool hasMulU24() const {
133 return (getGeneration() >= EVERGREEN);
134 }
135
136 bool hasMulI24() const {
137 return (getGeneration() >= SOUTHERN_ISLANDS ||
138 hasCaymanISA());
139 }
140
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000141 bool hasFFBL() const {
142 return (getGeneration() >= EVERGREEN);
143 }
144
145 bool hasFFBH() const {
146 return (getGeneration() >= EVERGREEN);
147 }
148
Matt Arsenaultd782d052014-06-27 17:57:00 +0000149 bool IsIRStructurizerEnabled() const {
150 return EnableIRStructurizer;
151 }
152
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000153 bool isPromoteAllocaEnabled() const {
154 return EnablePromoteAlloca;
155 }
156
Matt Arsenaultd782d052014-06-27 17:57:00 +0000157 bool isIfCvtEnabled() const {
158 return EnableIfCvt;
159 }
160
161 unsigned getWavefrontSize() const {
162 return WavefrontSize;
163 }
164
Tom Stellarda40f9712014-01-22 21:55:43 +0000165 unsigned getStackEntrySize() const;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000166
167 bool hasCFAluBug() const {
168 assert(getGeneration() <= NORTHERN_ISLANDS);
169 return CFALUBug;
170 }
171
172 int getLocalMemorySize() const {
173 return LocalMemorySize;
174 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000175
Craig Topper5656db42014-04-29 07:57:24 +0000176 bool enableMachineScheduler() const override {
Andrew Trick978674b2013-09-20 05:14:41 +0000177 return getGeneration() <= NORTHERN_ISLANDS;
178 }
179
Tom Stellard75aadc22012-12-11 21:25:42 +0000180 // Helper functions to simplify if statements
Matt Arsenaultd782d052014-06-27 17:57:00 +0000181 bool isTargetELF() const {
182 return false;
183 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000184
Matt Arsenaultd782d052014-06-27 17:57:00 +0000185 StringRef getDeviceName() const {
186 return DevName;
187 }
188
189 bool dumpCode() const {
190 return DumpCode;
191 }
192 bool r600ALUEncoding() const {
193 return R600ALUInst;
194 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000195};
196
197} // End namespace llvm
198
199#endif // AMDGPUSUBTARGET_H