blob: 57a084e6b3e953954157f1357dda14ff5e5bd5af [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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_R600_AMDGPUSUBTARGET_H
16#define LLVM_LIB_TARGET_R600_AMDGPUSUBTARGET_H
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000017#include "AMDGPU.h"
Eric Christopherac4b69e2014-07-25 22:22:39 +000018#include "AMDGPUFrameLowering.h"
Tom Stellard2e59a452014-06-13 01:32:00 +000019#include "AMDGPUInstrInfo.h"
Eric Christopherac4b69e2014-07-25 22:22:39 +000020#include "AMDGPUIntrinsicInfo.h"
21#include "AMDGPUSubtarget.h"
22#include "R600ISelLowering.h"
Tom Stellard75aadc22012-12-11 21:25:42 +000023#include "llvm/ADT/StringExtras.h"
24#include "llvm/ADT/StringRef.h"
25#include "llvm/Target/TargetSubtargetInfo.h"
26
27#define GET_SUBTARGETINFO_HEADER
28#include "AMDGPUGenSubtargetInfo.inc"
29
Tom Stellard75aadc22012-12-11 21:25:42 +000030namespace llvm {
31
Tom Stellarde99fb652015-01-20 19:33:04 +000032class SIMachineFunctionInfo;
33
Tom Stellard75aadc22012-12-11 21:25:42 +000034class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
Tom Stellard2e59a452014-06-13 01:32:00 +000035
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000036public:
37 enum Generation {
38 R600 = 0,
39 R700,
40 EVERGREEN,
41 NORTHERN_ISLANDS,
Tom Stellard6e1ee472013-10-29 16:37:28 +000042 SOUTHERN_ISLANDS,
Marek Olsak5df00d62014-12-07 12:18:57 +000043 SEA_ISLANDS,
44 VOLCANIC_ISLANDS,
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000045 };
46
Marek Olsak4d00dd22015-03-09 15:48:09 +000047 enum {
48 FIXED_SGPR_COUNT_FOR_INIT_BUG = 80
49 };
50
Tom Stellard75aadc22012-12-11 21:25:42 +000051private:
Tom Stellard75aadc22012-12-11 21:25:42 +000052 std::string DevName;
53 bool Is64bit;
Tom Stellard75aadc22012-12-11 21:25:42 +000054 bool DumpCode;
55 bool R600ALUInst;
Vincent Lejeunec2991642013-04-30 00:13:39 +000056 bool HasVertexCache;
Vincent Lejeunef9f4e1e2013-05-17 16:49:55 +000057 short TexVTXClauseSize;
Matt Arsenaultd782d052014-06-27 17:57:00 +000058 Generation Gen;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000059 bool FP64;
Matt Arsenaultf171cf22014-07-14 23:40:49 +000060 bool FP64Denormals;
61 bool FP32Denormals;
Matt Arsenaultb035a572015-01-29 19:34:25 +000062 bool FastFMAF32;
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000063 bool CaymanISA;
Matt Arsenault3f981402014-09-15 15:41:53 +000064 bool FlatAddressSpace;
Tom Stellarded0ceec2013-10-10 17:11:12 +000065 bool EnableIRStructurizer;
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +000066 bool EnablePromoteAlloca;
Tom Stellard783893a2013-11-18 19:43:33 +000067 bool EnableIfCvt;
Matt Arsenault41033282014-10-10 22:01:59 +000068 bool EnableLoadStoreOpt;
Tom Stellard8c347b02014-01-22 21:55:40 +000069 unsigned WavefrontSize;
Tom Stellard348273d2014-01-23 16:18:02 +000070 bool CFALUBug;
Tom Stellard880a80a2014-06-17 16:53:14 +000071 int LocalMemorySize;
Tom Stellarde99fb652015-01-20 19:33:04 +000072 bool EnableVGPRSpilling;
Marek Olsak4d00dd22015-03-09 15:48:09 +000073 bool SGPRInitBug;
Tom Stellardd7e6f132015-04-08 01:09:26 +000074 bool IsGCN;
75 bool GCN1Encoding;
76 bool GCN3Encoding;
Tom Stellardd1f0f022015-04-23 19:33:54 +000077 bool CIInsts;
78 bool FeatureDisable;
Tom Stellard75aadc22012-12-11 21:25:42 +000079
Eric Christopherac4b69e2014-07-25 22:22:39 +000080 AMDGPUFrameLowering FrameLowering;
Eric Christopherac4b69e2014-07-25 22:22:39 +000081 std::unique_ptr<AMDGPUTargetLowering> TLInfo;
82 std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
Tom Stellard75aadc22012-12-11 21:25:42 +000083 InstrItineraryData InstrItins;
Tom Stellard794c8c02014-12-02 17:05:41 +000084 Triple TargetTriple;
Tom Stellard75aadc22012-12-11 21:25:42 +000085
86public:
Eric Christopherac4b69e2014-07-25 22:22:39 +000087 AMDGPUSubtarget(StringRef TT, StringRef CPU, StringRef FS, TargetMachine &TM);
Tom Stellardeba56482015-01-28 15:38:42 +000088 AMDGPUSubtarget &initializeSubtargetDependencies(StringRef TT, StringRef GPU,
89 StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +000090
Eric Christopherd9134482014-08-04 21:25:23 +000091 const AMDGPUFrameLowering *getFrameLowering() const override {
92 return &FrameLowering;
93 }
94 const AMDGPUInstrInfo *getInstrInfo() const override {
95 return InstrInfo.get();
96 }
97 const AMDGPURegisterInfo *getRegisterInfo() const override {
Eric Christopherac4b69e2014-07-25 22:22:39 +000098 return &InstrInfo->getRegisterInfo();
Tom Stellard2e59a452014-06-13 01:32:00 +000099 }
Eric Christopherd9134482014-08-04 21:25:23 +0000100 AMDGPUTargetLowering *getTargetLowering() const override {
101 return TLInfo.get();
102 }
Eric Christopherd9134482014-08-04 21:25:23 +0000103 const InstrItineraryData *getInstrItineraryData() const override {
104 return &InstrItins;
105 }
Matt Arsenaultd782d052014-06-27 17:57:00 +0000106
Craig Topperee7b0f32014-04-30 05:53:27 +0000107 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000108
Matt Arsenaultd782d052014-06-27 17:57:00 +0000109 bool is64bit() const {
110 return Is64bit;
111 }
112
113 bool hasVertexCache() const {
114 return HasVertexCache;
115 }
116
117 short getTexVTXClauseSize() const {
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000118 return TexVTXClauseSize;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000119 }
120
121 Generation getGeneration() const {
122 return Gen;
123 }
124
125 bool hasHWFP64() const {
126 return FP64;
127 }
128
129 bool hasCaymanISA() const {
130 return CaymanISA;
131 }
Matt Arsenaultfae02982014-03-17 18:58:11 +0000132
Matt Arsenaultf171cf22014-07-14 23:40:49 +0000133 bool hasFP32Denormals() const {
134 return FP32Denormals;
135 }
136
137 bool hasFP64Denormals() const {
138 return FP64Denormals;
139 }
140
Matt Arsenaultb035a572015-01-29 19:34:25 +0000141 bool hasFastFMAF32() const {
142 return FastFMAF32;
143 }
144
Matt Arsenault3f981402014-09-15 15:41:53 +0000145 bool hasFlatAddressSpace() const {
146 return FlatAddressSpace;
147 }
148
Matt Arsenaultfae02982014-03-17 18:58:11 +0000149 bool hasBFE() const {
150 return (getGeneration() >= EVERGREEN);
151 }
152
Matt Arsenault6e439652014-06-10 19:00:20 +0000153 bool hasBFI() const {
154 return (getGeneration() >= EVERGREEN);
155 }
156
Matt Arsenaultfae02982014-03-17 18:58:11 +0000157 bool hasBFM() const {
158 return hasBFE();
159 }
160
Matt Arsenault60425062014-06-10 19:18:28 +0000161 bool hasBCNT(unsigned Size) const {
162 if (Size == 32)
163 return (getGeneration() >= EVERGREEN);
164
Matt Arsenault3dd43fc2014-07-18 06:07:13 +0000165 if (Size == 64)
166 return (getGeneration() >= SOUTHERN_ISLANDS);
167
168 return false;
Matt Arsenault60425062014-06-10 19:18:28 +0000169 }
170
Tom Stellard50122a52014-04-07 19:45:41 +0000171 bool hasMulU24() const {
172 return (getGeneration() >= EVERGREEN);
173 }
174
175 bool hasMulI24() const {
176 return (getGeneration() >= SOUTHERN_ISLANDS ||
177 hasCaymanISA());
178 }
179
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000180 bool hasFFBL() const {
181 return (getGeneration() >= EVERGREEN);
182 }
183
184 bool hasFFBH() const {
185 return (getGeneration() >= EVERGREEN);
186 }
187
Jan Vesely808fff52015-04-30 17:15:56 +0000188 bool hasCARRY() const {
189 return (getGeneration() >= EVERGREEN);
190 }
191
192 bool hasBORROW() const {
193 return (getGeneration() >= EVERGREEN);
194 }
195
Matt Arsenaultd782d052014-06-27 17:57:00 +0000196 bool IsIRStructurizerEnabled() const {
197 return EnableIRStructurizer;
198 }
199
Matt Arsenaultd9a23ab2014-07-13 02:08:26 +0000200 bool isPromoteAllocaEnabled() const {
201 return EnablePromoteAlloca;
202 }
203
Matt Arsenaultd782d052014-06-27 17:57:00 +0000204 bool isIfCvtEnabled() const {
205 return EnableIfCvt;
206 }
207
Matt Arsenault41033282014-10-10 22:01:59 +0000208 bool loadStoreOptEnabled() const {
209 return EnableLoadStoreOpt;
210 }
211
Matt Arsenaultd782d052014-06-27 17:57:00 +0000212 unsigned getWavefrontSize() const {
213 return WavefrontSize;
214 }
215
Tom Stellarda40f9712014-01-22 21:55:43 +0000216 unsigned getStackEntrySize() const;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000217
218 bool hasCFAluBug() const {
219 assert(getGeneration() <= NORTHERN_ISLANDS);
220 return CFALUBug;
221 }
222
223 int getLocalMemorySize() const {
224 return LocalMemorySize;
225 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000226
Marek Olsak4d00dd22015-03-09 15:48:09 +0000227 bool hasSGPRInitBug() const {
228 return SGPRInitBug;
229 }
230
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000231 unsigned getAmdKernelCodeChipID() const;
232
Craig Topper5656db42014-04-29 07:57:24 +0000233 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000234 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000235 }
236
Tom Stellard83f0bce2015-01-29 16:55:25 +0000237 void overrideSchedPolicy(MachineSchedPolicy &Policy,
238 MachineInstr *begin, MachineInstr *end,
239 unsigned NumRegionInstrs) const override;
240
Tom Stellard75aadc22012-12-11 21:25:42 +0000241 // Helper functions to simplify if statements
Matt Arsenaultd782d052014-06-27 17:57:00 +0000242 bool isTargetELF() const {
243 return false;
244 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000245
Matt Arsenaultd782d052014-06-27 17:57:00 +0000246 StringRef getDeviceName() const {
247 return DevName;
248 }
249
250 bool dumpCode() const {
251 return DumpCode;
252 }
253 bool r600ALUEncoding() const {
254 return R600ALUInst;
255 }
Tom Stellard794c8c02014-12-02 17:05:41 +0000256 bool isAmdHsaOS() const {
257 return TargetTriple.getOS() == Triple::AMDHSA;
258 }
Tom Stellarde99fb652015-01-20 19:33:04 +0000259 bool isVGPRSpillingEnabled(const SIMachineFunctionInfo *MFI) const;
Tom Stellard83f0bce2015-01-29 16:55:25 +0000260
261 unsigned getMaxWavesPerCU() const {
262 if (getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS)
263 return 10;
264
265 // FIXME: Not sure what this is for other subtagets.
266 llvm_unreachable("do not know max waves per CU for this subtarget.");
267 }
Tom Stellardf6afc802015-02-04 23:14:18 +0000268
269 bool enableSubRegLiveness() const override {
Tom Stellard06485882015-02-11 18:24:53 +0000270 return false;
Tom Stellardf6afc802015-02-04 23:14:18 +0000271 }
Tom Stellard75aadc22012-12-11 21:25:42 +0000272};
273
274} // End namespace llvm
275
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000276#endif