blob: 08878d87fb0962ca95182c6739ca6a14008663ad [file] [log] [blame]
Matt Arsenault0c90e952015-11-06 18:17:45 +00001//=====-- AMDGPUSubtarget.h - Define Subtarget for AMDGPU ------*- C++ -*-====//
Tom Stellard75aadc22012-12-11 21:25:42 +00002//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Tom Stellard75aadc22012-12-11 21:25:42 +00006//
7//==-----------------------------------------------------------------------===//
8//
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// AMDGPU specific subclass of TargetSubtarget.
Tom Stellard75aadc22012-12-11 21:25:42 +000011//
12//===----------------------------------------------------------------------===//
13
Matt Arsenault0c90e952015-11-06 18:17:45 +000014#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
15#define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
Matt Arsenaultf59e5382015-11-06 18:23:00 +000016
Tom Stellarda6c6e1b2013-06-07 20:37:48 +000017#include "AMDGPU.h"
Quentin Colombet61d71a12017-08-15 22:31:51 +000018#include "AMDGPUCallLowering.h"
Matt Arsenault43e92fe2016-06-24 06:30:11 +000019#include "R600FrameLowering.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000020#include "R600ISelLowering.h"
21#include "R600InstrInfo.h"
Matt Arsenault43e92fe2016-06-24 06:30:11 +000022#include "SIFrameLowering.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000023#include "SIISelLowering.h"
24#include "SIInstrInfo.h"
Tom Stellard347ac792015-06-26 21:15:07 +000025#include "Utils/AMDGPUBaseInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000026#include "llvm/ADT/Triple.h"
Quentin Colombet61d71a12017-08-15 22:31:51 +000027#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
28#include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
29#include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000030#include "llvm/CodeGen/MachineFunction.h"
Matt Arsenault56684d42016-08-11 17:31:42 +000031#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000032#include "llvm/MC/MCInstrItineraries.h"
33#include "llvm/Support/MathExtras.h"
34#include <cassert>
35#include <cstdint>
36#include <memory>
37#include <utility>
Tom Stellard75aadc22012-12-11 21:25:42 +000038
39#define GET_SUBTARGETINFO_HEADER
40#include "AMDGPUGenSubtargetInfo.inc"
Tom Stellardc5a154d2018-06-28 23:47:12 +000041#define GET_SUBTARGETINFO_HEADER
42#include "R600GenSubtargetInfo.inc"
Tom Stellard75aadc22012-12-11 21:25:42 +000043
Tom Stellard75aadc22012-12-11 21:25:42 +000044namespace llvm {
45
Matt Arsenault43e92fe2016-06-24 06:30:11 +000046class StringRef;
Tom Stellarde99fb652015-01-20 19:33:04 +000047
Tom Stellard5bfbae52018-07-11 20:59:01 +000048class AMDGPUSubtarget {
49public:
50 enum Generation {
51 R600 = 0,
52 R700 = 1,
Matt Arsenault4bec7d42018-07-20 09:05:08 +000053 EVERGREEN = 2,
Tom Stellard5bfbae52018-07-11 20:59:01 +000054 NORTHERN_ISLANDS = 3,
55 SOUTHERN_ISLANDS = 4,
56 SEA_ISLANDS = 5,
57 VOLCANIC_ISLANDS = 6,
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +000058 GFX9 = 7,
59 GFX10 = 8
Tom Stellard5bfbae52018-07-11 20:59:01 +000060 };
61
Tom Stellardc5a154d2018-06-28 23:47:12 +000062private:
63 Triple TargetTriple;
64
65protected:
Tom Stellardc5a154d2018-06-28 23:47:12 +000066 bool Has16BitInsts;
67 bool HasMadMixInsts;
68 bool FP32Denormals;
69 bool FPExceptions;
70 bool HasSDWA;
71 bool HasVOP3PInsts;
72 bool HasMulI24;
73 bool HasMulU24;
Matt Arsenault6c7ba822018-08-15 21:03:55 +000074 bool HasInv2PiInlineImm;
Tom Stellardc5a154d2018-06-28 23:47:12 +000075 bool HasFminFmaxLegacy;
76 bool EnablePromoteAlloca;
David Stuttard20de3e92018-09-14 10:27:19 +000077 bool HasTrigReducedRange;
Stanislav Mekhanoshin2594fa82019-07-31 01:07:10 +000078 unsigned MaxWavesPerEU;
Tom Stellardc5a154d2018-06-28 23:47:12 +000079 int LocalMemorySize;
80 unsigned WavefrontSize;
81
82public:
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +000083 AMDGPUSubtarget(const Triple &TT);
Tom Stellardc5a154d2018-06-28 23:47:12 +000084
Tom Stellard5bfbae52018-07-11 20:59:01 +000085 static const AMDGPUSubtarget &get(const MachineFunction &MF);
86 static const AMDGPUSubtarget &get(const TargetMachine &TM,
Matt Arsenault4bec7d42018-07-20 09:05:08 +000087 const Function &F);
Tom Stellardc5a154d2018-06-28 23:47:12 +000088
89 /// \returns Default range flat work group size for a calling convention.
90 std::pair<unsigned, unsigned> getDefaultFlatWorkGroupSize(CallingConv::ID CC) const;
91
92 /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
93 /// for function \p F, or minimum/maximum flat work group sizes explicitly
94 /// requested using "amdgpu-flat-work-group-size" attribute attached to
95 /// function \p F.
96 ///
97 /// \returns Subtarget's default values if explicitly requested values cannot
98 /// be converted to integer, or violate subtarget's specifications.
99 std::pair<unsigned, unsigned> getFlatWorkGroupSizes(const Function &F) const;
100
101 /// \returns Subtarget's default pair of minimum/maximum number of waves per
102 /// execution unit for function \p F, or minimum/maximum number of waves per
103 /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
104 /// attached to function \p F.
105 ///
106 /// \returns Subtarget's default values if explicitly requested values cannot
107 /// be converted to integer, violate subtarget's specifications, or are not
108 /// compatible with minimum/maximum number of waves limited by flat work group
109 /// size, register usage, and/or lds usage.
110 std::pair<unsigned, unsigned> getWavesPerEU(const Function &F) const;
111
112 /// Return the amount of LDS that can be used that will not restrict the
113 /// occupancy lower than WaveCount.
114 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
115 const Function &) const;
116
117 /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
118 /// the given LDS memory size is the only constraint.
119 unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const;
120
121 unsigned getOccupancyWithLocalMemSize(const MachineFunction &MF) const;
122
123 bool isAmdHsaOS() const {
124 return TargetTriple.getOS() == Triple::AMDHSA;
125 }
126
127 bool isAmdPalOS() const {
128 return TargetTriple.getOS() == Triple::AMDPAL;
129 }
130
Tom Stellardec4feae2018-07-06 17:16:17 +0000131 bool isMesa3DOS() const {
132 return TargetTriple.getOS() == Triple::Mesa3D;
133 }
134
135 bool isMesaKernel(const Function &F) const {
136 return isMesa3DOS() && !AMDGPU::isShader(F.getCallingConv());
137 }
138
Konstantin Zhuravlyovaa067cb2018-10-04 21:02:16 +0000139 bool isAmdHsaOrMesa(const Function &F) const {
Tom Stellardec4feae2018-07-06 17:16:17 +0000140 return isAmdHsaOS() || isMesaKernel(F);
141 }
142
Tom Stellardc5a154d2018-06-28 23:47:12 +0000143 bool has16BitInsts() const {
144 return Has16BitInsts;
145 }
146
147 bool hasMadMixInsts() const {
148 return HasMadMixInsts;
149 }
150
Matt Arsenaultdb0ed3e2019-10-31 18:50:30 -0700151 bool hasFP32Denormals(const Function &F) const {
152 // FIXME: This should not be a property of the subtarget. This should be a
153 // property with a default set by the calling convention which can be
154 // overridden by attributes. For now, use the subtarget feature as a
155 // placeholder attribute. The function arguments only purpose is to
156 // discourage use without a function context until this is removed.
Tom Stellardc5a154d2018-06-28 23:47:12 +0000157 return FP32Denormals;
158 }
159
160 bool hasFPExceptions() const {
161 return FPExceptions;
162 }
163
164 bool hasSDWA() const {
165 return HasSDWA;
166 }
167
168 bool hasVOP3PInsts() const {
169 return HasVOP3PInsts;
170 }
171
172 bool hasMulI24() const {
173 return HasMulI24;
174 }
175
176 bool hasMulU24() const {
177 return HasMulU24;
178 }
179
Matt Arsenault6c7ba822018-08-15 21:03:55 +0000180 bool hasInv2PiInlineImm() const {
181 return HasInv2PiInlineImm;
182 }
183
Tom Stellardc5a154d2018-06-28 23:47:12 +0000184 bool hasFminFmaxLegacy() const {
185 return HasFminFmaxLegacy;
186 }
187
David Stuttard20de3e92018-09-14 10:27:19 +0000188 bool hasTrigReducedRange() const {
189 return HasTrigReducedRange;
190 }
191
Tom Stellardc5a154d2018-06-28 23:47:12 +0000192 bool isPromoteAllocaEnabled() const {
193 return EnablePromoteAlloca;
194 }
195
196 unsigned getWavefrontSize() const {
197 return WavefrontSize;
198 }
199
200 int getLocalMemorySize() const {
201 return LocalMemorySize;
202 }
203
Guillaume Chateletb65fa482019-10-15 12:56:24 +0000204 Align getAlignmentForImplicitArgPtr() const {
205 return isAmdHsaOS() ? Align(8) : Align(4);
Tom Stellardc5a154d2018-06-28 23:47:12 +0000206 }
207
Tom Stellardec4feae2018-07-06 17:16:17 +0000208 /// Returns the offset in bytes from the start of the input buffer
209 /// of the first explicit kernel argument.
210 unsigned getExplicitKernelArgOffset(const Function &F) const {
Konstantin Zhuravlyovaa067cb2018-10-04 21:02:16 +0000211 return isAmdHsaOrMesa(F) ? 0 : 36;
Tom Stellardec4feae2018-07-06 17:16:17 +0000212 }
213
Tom Stellardc5a154d2018-06-28 23:47:12 +0000214 /// \returns Maximum number of work groups per compute unit supported by the
215 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000216 virtual unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000217
218 /// \returns Minimum flat work group size supported by the subtarget.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000219 virtual unsigned getMinFlatWorkGroupSize() const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000220
221 /// \returns Maximum flat work group size supported by the subtarget.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000222 virtual unsigned getMaxFlatWorkGroupSize() const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000223
224 /// \returns Maximum number of waves per execution unit supported by the
225 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000226 virtual unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000227
228 /// \returns Minimum number of waves per execution unit supported by the
229 /// subtarget.
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000230 virtual unsigned getMinWavesPerEU() const = 0;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000231
Stanislav Mekhanoshin2594fa82019-07-31 01:07:10 +0000232 /// \returns Maximum number of waves per execution unit supported by the
233 /// subtarget without any kind of limitation.
234 unsigned getMaxWavesPerEU() const { return MaxWavesPerEU; }
Tom Stellardc5a154d2018-06-28 23:47:12 +0000235
236 /// Creates value range metadata on an workitemid.* inrinsic call or load.
237 bool makeLIDRangeMetadata(Instruction *I) const;
238
Matt Arsenault4bec7d42018-07-20 09:05:08 +0000239 /// \returns Number of bytes of arguments that are passed to a shader or
240 /// kernel in addition to the explicit ones declared for the function.
241 unsigned getImplicitArgNumBytes(const Function &F) const {
242 if (isMesaKernel(F))
243 return 16;
244 return AMDGPU::getIntegerAttribute(F, "amdgpu-implicitarg-num-bytes", 0);
245 }
Guillaume Chateletb65fa482019-10-15 12:56:24 +0000246 uint64_t getExplicitKernArgSize(const Function &F, Align &MaxAlign) const;
247 unsigned getKernArgSegmentSize(const Function &F, Align &MaxAlign) const;
Matt Arsenault4bec7d42018-07-20 09:05:08 +0000248
Tom Stellard5bfbae52018-07-11 20:59:01 +0000249 virtual ~AMDGPUSubtarget() {}
Tom Stellardc5a154d2018-06-28 23:47:12 +0000250};
251
Tom Stellard5bfbae52018-07-11 20:59:01 +0000252class GCNSubtarget : public AMDGPUGenSubtargetInfo,
253 public AMDGPUSubtarget {
Stanislav Mekhanoshin2594fa82019-07-31 01:07:10 +0000254
255 using AMDGPUSubtarget::getMaxWavesPerEU;
256
Tom Stellarda6c6e1b2013-06-07 20:37:48 +0000257public:
Wei Ding205bfdb2017-02-10 02:15:29 +0000258 enum TrapHandlerAbi {
259 TrapHandlerAbiNone = 0,
260 TrapHandlerAbiHsa = 1
261 };
262
Wei Dingf2cce022017-02-22 23:22:19 +0000263 enum TrapID {
264 TrapIDHardwareReserved = 0,
265 TrapIDHSADebugTrap = 1,
266 TrapIDLLVMTrap = 2,
267 TrapIDLLVMDebugTrap = 3,
268 TrapIDDebugBreakpoint = 7,
269 TrapIDDebugReserved8 = 8,
270 TrapIDDebugReservedFE = 0xfe,
271 TrapIDDebugReservedFF = 0xff
Wei Ding205bfdb2017-02-10 02:15:29 +0000272 };
273
274 enum TrapRegValues {
Wei Dingf2cce022017-02-22 23:22:19 +0000275 LLVMTrapHandlerRegValue = 1
Wei Ding205bfdb2017-02-10 02:15:29 +0000276 };
277
Tom Stellardc5a154d2018-06-28 23:47:12 +0000278private:
Tom Stellardc5a154d2018-06-28 23:47:12 +0000279 /// GlobalISel related APIs.
280 std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
281 std::unique_ptr<InstructionSelector> InstSelector;
282 std::unique_ptr<LegalizerInfo> Legalizer;
283 std::unique_ptr<RegisterBankInfo> RegBankInfo;
284
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000285protected:
286 // Basic subtarget description.
287 Triple TargetTriple;
Tom Stellardc5a154d2018-06-28 23:47:12 +0000288 unsigned Gen;
Stanislav Mekhanoshin06d3b412018-09-17 16:04:32 +0000289 InstrItineraryData InstrItins;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000290 int LDSBankCount;
291 unsigned MaxPrivateElementSize;
292
293 // Possibly statically set by tablegen, but may want to be overridden.
Matt Arsenaultb035a572015-01-29 19:34:25 +0000294 bool FastFMAF32;
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000295 bool HalfRate64Ops;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000296
297 // Dynamially set bits that enable features.
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000298 bool FP64FP16Denormals;
Changpeng Fangb41574a2015-12-22 20:55:23 +0000299 bool FlatForGlobal;
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000300 bool AutoWaitcntBeforeBarrier;
Konstantin Zhuravlyoveda425e2017-10-14 15:59:07 +0000301 bool CodeObjectV3;
Tom Stellard64a9d082016-10-14 18:10:39 +0000302 bool UnalignedScratchAccess;
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000303 bool UnalignedBufferAccess;
Matt Arsenaulte823d922017-02-18 18:29:53 +0000304 bool HasApertureRegs;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000305 bool EnableXNACK;
Matt Arsenaultdf24c922019-05-16 14:48:34 +0000306 bool DoesNotSupportXNACK;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000307 bool EnableCuMode;
Wei Ding205bfdb2017-02-10 02:15:29 +0000308 bool TrapHandler;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000309
310 // Used as options.
Matt Arsenault41033282014-10-10 22:01:59 +0000311 bool EnableLoadStoreOpt;
Matt Arsenault706f9302015-07-06 16:01:58 +0000312 bool EnableUnsafeDSOffsetFolding;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000313 bool EnableSIScheduler;
Marek Olsaka9a58fa2018-04-10 22:48:23 +0000314 bool EnableDS128;
David Stuttardf77079f2019-01-14 11:55:24 +0000315 bool EnablePRTStrictNull;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000316 bool DumpCode;
317
318 // Subtarget statically properties set by tablegen
319 bool FP64;
Jan Vesely39aeab42017-12-04 23:07:28 +0000320 bool FMA;
Dmitry Preobrazhenskye3271ae2018-02-05 12:45:43 +0000321 bool MIMG_R128;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000322 bool IsGCN;
Tom Stellardd7e6f132015-04-08 01:09:26 +0000323 bool GCN3Encoding;
Tom Stellardd1f0f022015-04-23 19:33:54 +0000324 bool CIInsts;
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +0000325 bool GFX8Insts;
Matt Arsenault2021f082017-02-18 19:12:26 +0000326 bool GFX9Insts;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000327 bool GFX10Insts;
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +0000328 bool GFX7GFX8GFX9Insts;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000329 bool SGPRInitBug;
Matt Arsenault9d82ee72016-02-27 08:53:55 +0000330 bool HasSMemRealTime;
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000331 bool HasIntClamp;
Matt Arsenault0084adc2018-04-30 19:08:16 +0000332 bool HasFmaMixInsts;
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000333 bool HasMovrel;
334 bool HasVGPRIndexMode;
Matt Arsenault7b647552016-10-28 21:55:15 +0000335 bool HasScalarStores;
Dmitry Preobrazhensky6bad04e2018-04-02 16:10:25 +0000336 bool HasScalarAtomics;
Sam Kolton3c4933f2017-06-22 06:26:41 +0000337 bool HasSDWAOmod;
338 bool HasSDWAScalar;
339 bool HasSDWASdst;
340 bool HasSDWAMac;
Sam Koltona179d252017-06-27 15:02:23 +0000341 bool HasSDWAOutModsVOPC;
Sam Kolton07dbde22017-01-20 10:01:25 +0000342 bool HasDPP;
Stanislav Mekhanoshin245b5ba2019-06-12 18:02:41 +0000343 bool HasDPP8;
Ryan Taylor1f334d02018-08-28 15:07:30 +0000344 bool HasR128A16;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000345 bool HasNSAEncoding;
Matt Arsenault0084adc2018-04-30 19:08:16 +0000346 bool HasDLInsts;
Stanislav Mekhanoshin0e858b02019-02-09 00:34:21 +0000347 bool HasDot1Insts;
348 bool HasDot2Insts;
Stanislav Mekhanoshin22b2c3d2019-07-09 18:10:06 +0000349 bool HasDot3Insts;
350 bool HasDot4Insts;
Stanislav Mekhanoshinc43e67b2019-06-14 00:33:31 +0000351 bool HasDot5Insts;
352 bool HasDot6Insts;
Stanislav Mekhanoshin22b2c3d2019-07-09 18:10:06 +0000353 bool HasMAIInsts;
354 bool HasPkFmacF16Inst;
355 bool HasAtomicFaddInsts;
Konstantin Zhuravlyov108927b2018-11-05 22:44:19 +0000356 bool EnableSRAMECC;
Matt Arsenaultf426ddb2019-04-03 01:58:57 +0000357 bool DoesNotSupportSRAMECC;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000358 bool HasNoSdstCMPX;
359 bool HasVscnt;
360 bool HasRegisterBanking;
361 bool HasVOP3Literal;
362 bool HasNoDataDepHazard;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000363 bool FlatAddressSpace;
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000364 bool FlatInstOffsets;
365 bool FlatGlobalInsts;
366 bool FlatScratchInsts;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000367 bool ScalarFlatScratchInsts;
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000368 bool AddNoCarryInsts;
Changpeng Fang44dfa1d2018-01-12 21:12:19 +0000369 bool HasUnpackedD16VMem;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000370 bool R600ALUInst;
371 bool CaymanISA;
372 bool CFALUBug;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000373 bool LDSMisalignedBug;
Stanislav Mekhanoshin8fe12452019-08-23 22:09:58 +0000374 bool HasMFMAInlineLiteralBug;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000375 bool HasVertexCache;
376 short TexVTXClauseSize;
Alexander Timofeev18009562016-12-08 17:28:47 +0000377 bool ScalarizeGlobal;
Tom Stellard75aadc22012-12-11 21:25:42 +0000378
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000379 bool HasVcmpxPermlaneHazard;
380 bool HasVMEMtoScalarWriteHazard;
381 bool HasSMEMtoVectorWriteHazard;
382 bool HasInstFwdPrefetchBug;
383 bool HasVcmpxExecWARHazard;
384 bool HasLdsBranchVmemWARHazard;
385 bool HasNSAtoVMEMBug;
Ryan Taylor9ab812d2019-06-26 17:34:57 +0000386 bool HasOffset3fBug;
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000387 bool HasFlatSegmentOffsetBug;
388
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000389 // Dummy feature to use for assembler in tablegen.
390 bool FeatureDisable;
391
Matt Arsenault56684d42016-08-11 17:31:42 +0000392 SelectionDAGTargetInfo TSInfo;
Tom Stellard5bfbae52018-07-11 20:59:01 +0000393private:
Tom Stellard5bfbae52018-07-11 20:59:01 +0000394 SIInstrInfo InstrInfo;
Tom Stellard752ddbd2018-07-11 22:15:15 +0000395 SITargetLowering TLInfo;
Tom Stellard5bfbae52018-07-11 20:59:01 +0000396 SIFrameLowering FrameLowering;
Tom Stellard75aadc22012-12-11 21:25:42 +0000397
Matt Arsenault5c714cb2019-05-23 19:38:14 +0000398 // See COMPUTE_TMPRING_SIZE.WAVESIZE, 13-bit field in units of 256-dword.
399 static const unsigned MaxWaveScratchSize = (256 * 4) * ((1 << 13) - 1);
400
Tom Stellard75aadc22012-12-11 21:25:42 +0000401public:
Tom Stellard5bfbae52018-07-11 20:59:01 +0000402 GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
403 const GCNTargetMachine &TM);
404 ~GCNSubtarget() override;
Eugene Zelenko2bc2f332016-12-09 22:06:55 +0000405
Tom Stellard5bfbae52018-07-11 20:59:01 +0000406 GCNSubtarget &initializeSubtargetDependencies(const Triple &TT,
Daniel Sandersa73f1fd2015-06-10 12:11:26 +0000407 StringRef GPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000408
Tom Stellard5bfbae52018-07-11 20:59:01 +0000409 const SIInstrInfo *getInstrInfo() const override {
410 return &InstrInfo;
411 }
Tom Stellard000c5af2016-04-14 19:09:28 +0000412
Tom Stellardc5a154d2018-06-28 23:47:12 +0000413 const SIFrameLowering *getFrameLowering() const override {
414 return &FrameLowering;
415 }
416
Tom Stellard5bfbae52018-07-11 20:59:01 +0000417 const SITargetLowering *getTargetLowering() const override {
418 return &TLInfo;
419 }
Tom Stellardc5a154d2018-06-28 23:47:12 +0000420
Tom Stellard5bfbae52018-07-11 20:59:01 +0000421 const SIRegisterInfo *getRegisterInfo() const override {
422 return &InstrInfo.getRegisterInfo();
423 }
Tom Stellardc5a154d2018-06-28 23:47:12 +0000424
425 const CallLowering *getCallLowering() const override {
426 return CallLoweringInfo.get();
427 }
428
Amara Emersone14c91b2019-08-13 06:26:59 +0000429 InstructionSelector *getInstructionSelector() const override {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000430 return InstSelector.get();
431 }
432
433 const LegalizerInfo *getLegalizerInfo() const override {
434 return Legalizer.get();
435 }
436
437 const RegisterBankInfo *getRegBankInfo() const override {
438 return RegBankInfo.get();
Eric Christopherd9134482014-08-04 21:25:23 +0000439 }
Matt Arsenaultd782d052014-06-27 17:57:00 +0000440
Matt Arsenault56684d42016-08-11 17:31:42 +0000441 // Nothing implemented, just prevent crashes on use.
442 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
443 return &TSInfo;
444 }
445
Stanislav Mekhanoshin06d3b412018-09-17 16:04:32 +0000446 const InstrItineraryData *getInstrItineraryData() const override {
447 return &InstrItins;
448 }
449
Craig Topperee7b0f32014-04-30 05:53:27 +0000450 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Tom Stellard75aadc22012-12-11 21:25:42 +0000451
Matt Arsenaultd782d052014-06-27 17:57:00 +0000452 Generation getGeneration() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000453 return (Generation)Gen;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000454 }
455
Matt Arsenault4eea3f32017-11-13 22:55:05 +0000456 unsigned getWavefrontSizeLog2() const {
457 return Log2_32(WavefrontSize);
458 }
459
Matt Arsenault5c714cb2019-05-23 19:38:14 +0000460 /// Return the number of high bits known to be zero fror a frame index.
461 unsigned getKnownHighZeroBitsForFrameIndex() const {
462 return countLeadingZeros(MaxWaveScratchSize) + getWavefrontSizeLog2();
463 }
464
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000465 int getLDSBankCount() const {
466 return LDSBankCount;
467 }
468
469 unsigned getMaxPrivateElementSize() const {
470 return MaxPrivateElementSize;
471 }
472
Stanislav Mekhanoshinf2baae02019-05-02 03:47:23 +0000473 unsigned getConstantBusLimit(unsigned Opcode) const;
474
Dmitry Preobrazhenskyff64aa52017-08-16 13:51:56 +0000475 bool hasIntClamp() const {
476 return HasIntClamp;
477 }
478
Jan Veselyd1c9b612017-12-04 22:57:29 +0000479 bool hasFP64() const {
Matt Arsenaultd782d052014-06-27 17:57:00 +0000480 return FP64;
481 }
482
Dmitry Preobrazhenskye3271ae2018-02-05 12:45:43 +0000483 bool hasMIMG_R128() const {
484 return MIMG_R128;
485 }
486
Tom Stellardc5a154d2018-06-28 23:47:12 +0000487 bool hasHWFP64() const {
488 return FP64;
489 }
490
Matt Arsenaultb035a572015-01-29 19:34:25 +0000491 bool hasFastFMAF32() const {
492 return FastFMAF32;
493 }
494
Matt Arsenaulte83690c2016-01-18 21:13:50 +0000495 bool hasHalfRate64Ops() const {
496 return HalfRate64Ops;
497 }
498
Matt Arsenault88701812016-06-09 23:42:48 +0000499 bool hasAddr64() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000500 return (getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS);
Matt Arsenault88701812016-06-09 23:42:48 +0000501 }
502
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000503 // Return true if the target only has the reverse operand versions of VALU
504 // shift instructions (e.g. v_lshrrev_b32, and no v_lshr_b32).
505 bool hasOnlyRevVALUShifts() const {
506 return getGeneration() >= VOLCANIC_ISLANDS;
507 }
508
Matt Arsenaultfae02982014-03-17 18:58:11 +0000509 bool hasBFE() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000510 return true;
Matt Arsenaultfae02982014-03-17 18:58:11 +0000511 }
512
Matt Arsenault6e439652014-06-10 19:00:20 +0000513 bool hasBFI() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000514 return true;
Matt Arsenault6e439652014-06-10 19:00:20 +0000515 }
516
Matt Arsenaultfae02982014-03-17 18:58:11 +0000517 bool hasBFM() const {
518 return hasBFE();
519 }
520
Matt Arsenault60425062014-06-10 19:18:28 +0000521 bool hasBCNT(unsigned Size) const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000522 return true;
Tom Stellard50122a52014-04-07 19:45:41 +0000523 }
524
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000525 bool hasFFBL() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000526 return true;
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000527 }
528
529 bool hasFFBH() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000530 return true;
Jan Vesely6ddb8dd2014-07-15 15:51:09 +0000531 }
532
Matt Arsenault10268f92017-02-27 22:40:39 +0000533 bool hasMed3_16() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000534 return getGeneration() >= AMDGPUSubtarget::GFX9;
Matt Arsenault10268f92017-02-27 22:40:39 +0000535 }
536
Matt Arsenaultee324ff2017-05-17 19:25:06 +0000537 bool hasMin3Max3_16() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000538 return getGeneration() >= AMDGPUSubtarget::GFX9;
Matt Arsenaultd7e23032017-09-07 18:05:07 +0000539 }
540
Matt Arsenault0084adc2018-04-30 19:08:16 +0000541 bool hasFmaMixInsts() const {
542 return HasFmaMixInsts;
543 }
544
Jan Vesely808fff52015-04-30 17:15:56 +0000545 bool hasCARRY() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000546 return true;
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000547 }
548
Jan Vesely39aeab42017-12-04 23:07:28 +0000549 bool hasFMA() const {
550 return FMA;
551 }
552
Stanislav Mekhanoshin79080ec2018-10-29 17:26:01 +0000553 bool hasSwap() const {
554 return GFX9Insts;
555 }
556
Matt Arsenault182f9242019-09-09 17:04:18 +0000557 bool hasScalarPackInsts() const {
558 return GFX9Insts;
559 }
560
Matt Arsenault3ecab8e2019-09-19 16:26:14 +0000561 bool hasScalarMulHiInsts() const {
562 return GFX9Insts;
563 }
564
Wei Ding205bfdb2017-02-10 02:15:29 +0000565 TrapHandlerAbi getTrapHandlerAbi() const {
566 return isAmdHsaOS() ? TrapHandlerAbiHsa : TrapHandlerAbiNone;
567 }
568
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000569 /// True if the offset field of DS instructions works as expected. On SI, the
570 /// offset uses a 16-bit adder and does not always wrap properly.
571 bool hasUsableDSOffset() const {
572 return getGeneration() >= SEA_ISLANDS;
573 }
574
Matt Arsenault706f9302015-07-06 16:01:58 +0000575 bool unsafeDSOffsetFoldingEnabled() const {
576 return EnableUnsafeDSOffsetFolding;
577 }
578
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000579 /// Condition output from div_scale is usable.
580 bool hasUsableDivScaleConditionOutput() const {
581 return getGeneration() != SOUTHERN_ISLANDS;
582 }
583
584 /// Extra wait hazard is needed in some cases before
585 /// s_cbranch_vccnz/s_cbranch_vccz.
586 bool hasReadVCCZBug() const {
587 return getGeneration() <= SEA_ISLANDS;
588 }
589
590 /// A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR
591 /// was written by a VALU instruction.
592 bool hasSMRDReadVALUDefHazard() const {
593 return getGeneration() == SOUTHERN_ISLANDS;
594 }
595
596 /// A read of an SGPR by a VMEM instruction requires 5 wait states when the
597 /// SGPR was written by a VALU Instruction.
598 bool hasVMEMReadSGPRVALUDefHazard() const {
599 return getGeneration() >= VOLCANIC_ISLANDS;
600 }
601
602 bool hasRFEHazards() const {
603 return getGeneration() >= VOLCANIC_ISLANDS;
604 }
605
606 /// Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
607 unsigned getSetRegWaitStates() const {
608 return getGeneration() <= SEA_ISLANDS ? 1 : 2;
609 }
610
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000611 bool dumpCode() const {
612 return DumpCode;
Matt Arsenaultd782d052014-06-27 17:57:00 +0000613 }
614
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000615 /// Return the amount of LDS that can be used that will not restrict the
616 /// occupancy lower than WaveCount.
Stanislav Mekhanoshin2b913b12017-02-01 22:59:50 +0000617 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
618 const Function &) const;
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000619
Matt Arsenaultdb0ed3e2019-10-31 18:50:30 -0700620 /// Alias for hasFP64FP16Denormals
621 bool hasFP16Denormals(const Function &F) const {
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000622 return FP64FP16Denormals;
Konstantin Zhuravlyovf86e4b72016-11-13 07:01:11 +0000623 }
Matt Arsenault8a028bf2016-05-16 21:19:59 +0000624
Matt Arsenaultdb0ed3e2019-10-31 18:50:30 -0700625 /// Alias for hasFP64FP16Denormals
626 bool hasFP64Denormals(const Function &F) const {
627 return FP64FP16Denormals;
628 }
629
630 bool hasFP64FP16Denormals(const Function &F) const {
Matt Arsenaulta6867fd2017-01-23 22:31:03 +0000631 return FP64FP16Denormals;
Matt Arsenault24ee0782016-02-12 02:40:47 +0000632 }
633
Stanislav Mekhanoshindc2890a2017-07-13 23:59:15 +0000634 bool supportsMinMaxDenormModes() const {
635 return getGeneration() >= AMDGPUSubtarget::GFX9;
636 }
637
Austin Kerbowa05c3842019-08-06 02:16:11 +0000638 /// \returns If target supports S_DENORM_MODE.
639 bool hasDenormModeInst() const {
640 return getGeneration() >= AMDGPUSubtarget::GFX10;
641 }
642
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000643 bool useFlatForGlobal() const {
644 return FlatForGlobal;
Tom Stellardec87f842015-05-25 16:15:54 +0000645 }
646
Farhana Aleena7cb3112018-03-09 17:41:39 +0000647 /// \returns If target supports ds_read/write_b128 and user enables generation
648 /// of ds_read/write_b128.
Marek Olsaka9a58fa2018-04-10 22:48:23 +0000649 bool useDS128() const {
650 return CIInsts && EnableDS128;
Farhana Aleena7cb3112018-03-09 17:41:39 +0000651 }
652
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000653 /// Have v_trunc_f64, v_ceil_f64, v_rndne_f64
654 bool haveRoundOpsF64() const {
655 return CIInsts;
656 }
657
Matt Arsenaultcaf0ed42017-11-30 00:52:40 +0000658 /// \returns If MUBUF instructions always perform range checking, even for
659 /// buffer resources used for private memory access.
660 bool privateMemoryResourceIsRangeChecked() const {
661 return getGeneration() < AMDGPUSubtarget::GFX9;
662 }
663
David Stuttardf77079f2019-01-14 11:55:24 +0000664 /// \returns If target requires PRT Struct NULL support (zero result registers
665 /// for sparse texture support).
666 bool usePRTStrictNull() const {
667 return EnablePRTStrictNull;
668 }
669
Konstantin Zhuravlyovbe6c0ca2017-06-02 17:40:26 +0000670 bool hasAutoWaitcntBeforeBarrier() const {
671 return AutoWaitcntBeforeBarrier;
672 }
673
Konstantin Zhuravlyoveda425e2017-10-14 15:59:07 +0000674 bool hasCodeObjectV3() const {
Konstantin Zhuravlyova25e0522018-11-15 02:32:43 +0000675 // FIXME: Need to add code object v3 support for mesa and pal.
676 return isAmdHsaOS() ? CodeObjectV3 : false;
Konstantin Zhuravlyoveda425e2017-10-14 15:59:07 +0000677 }
678
Matt Arsenault7f681ac2016-07-01 23:03:44 +0000679 bool hasUnalignedBufferAccess() const {
680 return UnalignedBufferAccess;
681 }
682
Tom Stellard64a9d082016-10-14 18:10:39 +0000683 bool hasUnalignedScratchAccess() const {
684 return UnalignedScratchAccess;
685 }
686
Matt Arsenaulte823d922017-02-18 18:29:53 +0000687 bool hasApertureRegs() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +0000688 return HasApertureRegs;
Matt Arsenaulte823d922017-02-18 18:29:53 +0000689 }
690
Wei Ding205bfdb2017-02-10 02:15:29 +0000691 bool isTrapHandlerEnabled() const {
692 return TrapHandler;
693 }
694
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000695 bool isXNACKEnabled() const {
696 return EnableXNACK;
697 }
Tom Stellardb8fd6ef2014-12-02 22:00:07 +0000698
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000699 bool isCuModeEnabled() const {
700 return EnableCuMode;
701 }
702
Matt Arsenaultb6491cc2017-01-31 01:20:54 +0000703 bool hasFlatAddressSpace() const {
704 return FlatAddressSpace;
705 }
706
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000707 bool hasFlatScrRegister() const {
708 return hasFlatAddressSpace();
709 }
710
Matt Arsenaultacdc7652017-05-10 21:19:05 +0000711 bool hasFlatInstOffsets() const {
712 return FlatInstOffsets;
713 }
714
715 bool hasFlatGlobalInsts() const {
716 return FlatGlobalInsts;
717 }
718
719 bool hasFlatScratchInsts() const {
720 return FlatScratchInsts;
721 }
722
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000723 bool hasScalarFlatScratchInsts() const {
724 return ScalarFlatScratchInsts;
725 }
726
727 bool hasFlatSegmentOffsetBug() const {
728 return HasFlatSegmentOffsetBug;
729 }
730
Mark Searlesf0b93f12018-06-04 16:51:59 +0000731 bool hasFlatLgkmVMemCountInOrder() const {
732 return getGeneration() > GFX9;
733 }
734
Matt Arsenaulted6e8f02017-09-01 18:36:06 +0000735 bool hasD16LoadStore() const {
736 return getGeneration() >= GFX9;
737 }
738
Matt Arsenaulte8c03a22019-03-08 20:58:11 +0000739 bool d16PreservesUnusedBits() const {
740 return hasD16LoadStore() && !isSRAMECCEnabled();
741 }
742
Matt Arsenaulte4c2e9b2019-06-19 23:54:58 +0000743 bool hasD16Images() const {
744 return getGeneration() >= VOLCANIC_ISLANDS;
745 }
746
Matt Arsenault3f71c0e2017-11-29 00:55:57 +0000747 /// Return if most LDS instructions have an m0 use that require m0 to be
748 /// iniitalized.
749 bool ldsRequiresM0Init() const {
750 return getGeneration() < GFX9;
751 }
752
Matt Arsenault8ad1dec2019-06-20 20:54:32 +0000753 // True if the hardware rewinds and replays GWS operations if a wave is
754 // preempted.
755 //
756 // If this is false, a GWS operation requires testing if a nack set the
757 // MEM_VIOL bit, and repeating if so.
758 bool hasGWSAutoReplay() const {
759 return getGeneration() >= GFX9;
760 }
761
Matt Arsenault740322f2019-06-20 21:11:42 +0000762 /// \returns if target has ds_gws_sema_release_all instruction.
763 bool hasGWSSemaReleaseAll() const {
764 return CIInsts;
765 }
766
Matt Arsenaultc37fe662017-07-20 17:42:47 +0000767 bool hasAddNoCarry() const {
768 return AddNoCarryInsts;
769 }
770
Changpeng Fang44dfa1d2018-01-12 21:12:19 +0000771 bool hasUnpackedD16VMem() const {
772 return HasUnpackedD16VMem;
773 }
774
Tom Stellard2f3f9852017-01-25 01:25:13 +0000775 // Covers VS/PS/CS graphics shaders
Matt Arsenaultceafc552018-05-29 17:42:50 +0000776 bool isMesaGfxShader(const Function &F) const {
777 return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv());
Tom Stellard2f3f9852017-01-25 01:25:13 +0000778 }
779
Matt Arsenault4f6318f2017-11-06 17:04:37 +0000780 bool hasMad64_32() const {
781 return getGeneration() >= SEA_ISLANDS;
782 }
783
Sam Kolton3c4933f2017-06-22 06:26:41 +0000784 bool hasSDWAOmod() const {
785 return HasSDWAOmod;
786 }
787
788 bool hasSDWAScalar() const {
789 return HasSDWAScalar;
790 }
791
792 bool hasSDWASdst() const {
793 return HasSDWASdst;
794 }
795
796 bool hasSDWAMac() const {
797 return HasSDWAMac;
798 }
799
Sam Koltona179d252017-06-27 15:02:23 +0000800 bool hasSDWAOutModsVOPC() const {
801 return HasSDWAOutModsVOPC;
Sam Kolton3c4933f2017-06-22 06:26:41 +0000802 }
803
Matt Arsenault0084adc2018-04-30 19:08:16 +0000804 bool hasDLInsts() const {
805 return HasDLInsts;
806 }
807
Stanislav Mekhanoshin0e858b02019-02-09 00:34:21 +0000808 bool hasDot1Insts() const {
809 return HasDot1Insts;
810 }
811
812 bool hasDot2Insts() const {
813 return HasDot2Insts;
Stanislav Mekhanoshind3757d32019-01-10 03:25:20 +0000814 }
815
Stanislav Mekhanoshin22b2c3d2019-07-09 18:10:06 +0000816 bool hasDot3Insts() const {
817 return HasDot3Insts;
818 }
819
820 bool hasDot4Insts() const {
821 return HasDot4Insts;
822 }
823
Stanislav Mekhanoshinc43e67b2019-06-14 00:33:31 +0000824 bool hasDot5Insts() const {
825 return HasDot5Insts;
826 }
827
828 bool hasDot6Insts() const {
829 return HasDot6Insts;
830 }
831
Stanislav Mekhanoshin22b2c3d2019-07-09 18:10:06 +0000832 bool hasMAIInsts() const {
833 return HasMAIInsts;
834 }
835
836 bool hasPkFmacF16Inst() const {
837 return HasPkFmacF16Inst;
838 }
839
840 bool hasAtomicFaddInsts() const {
841 return HasAtomicFaddInsts;
842 }
843
Konstantin Zhuravlyov108927b2018-11-05 22:44:19 +0000844 bool isSRAMECCEnabled() const {
845 return EnableSRAMECC;
Konstantin Zhuravlyovc2c2eb72018-05-04 20:06:57 +0000846 }
847
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000848 bool hasNoSdstCMPX() const {
849 return HasNoSdstCMPX;
850 }
851
852 bool hasVscnt() const {
853 return HasVscnt;
854 }
855
856 bool hasRegisterBanking() const {
857 return HasRegisterBanking;
858 }
859
860 bool hasVOP3Literal() const {
861 return HasVOP3Literal;
862 }
863
864 bool hasNoDataDepHazard() const {
865 return HasNoDataDepHazard;
866 }
867
868 bool vmemWriteNeedsExpWaitcnt() const {
869 return getGeneration() < SEA_ISLANDS;
870 }
871
Matt Arsenault869fec22017-04-17 19:48:24 +0000872 // Scratch is allocated in 256 dword per wave blocks for the entire
873 // wavefront. When viewed from the perspecive of an arbitrary workitem, this
874 // is 4-byte aligned.
Matt Arsenaultffb132e2018-03-29 20:22:04 +0000875 //
876 // Only 4-byte alignment is really needed to access anything. Transformations
877 // on the pointer value itself may rely on the alignment / known low bits of
878 // the pointer. Set this to something above the minimum to avoid needing
879 // dynamic realignment in common cases.
Guillaume Chatelet882c43d2019-10-17 07:49:39 +0000880 Align getStackAlignment() const { return Align(16); }
Tom Stellard347ac792015-06-26 21:15:07 +0000881
Craig Topper5656db42014-04-29 07:57:24 +0000882 bool enableMachineScheduler() const override {
Tom Stellard83f0bce2015-01-29 16:55:25 +0000883 return true;
Andrew Trick978674b2013-09-20 05:14:41 +0000884 }
885
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000886 bool enableSubRegLiveness() const override {
887 return true;
888 }
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000889
Tom Stellardc5a154d2018-06-28 23:47:12 +0000890 void setScalarizeGlobalBehavior(bool b) { ScalarizeGlobal = b; }
891 bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal; }
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000892
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000893 /// \returns Number of execution units per compute unit supported by the
894 /// subtarget.
895 unsigned getEUsPerCU() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000896 return AMDGPU::IsaInfo::getEUsPerCU(this);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000897 }
898
899 /// \returns Maximum number of waves per compute unit supported by the
900 /// subtarget without any kind of limitation.
901 unsigned getMaxWavesPerCU() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000902 return AMDGPU::IsaInfo::getMaxWavesPerCU(this);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000903 }
904
905 /// \returns Maximum number of waves per compute unit supported by the
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000906 /// subtarget and limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000907 unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000908 return AMDGPU::IsaInfo::getMaxWavesPerCU(this, FlatWorkGroupSize);
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000909 }
910
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +0000911 /// \returns Number of waves per work group supported by the subtarget and
912 /// limited by given \p FlatWorkGroupSize.
Konstantin Zhuravlyov1d650262016-09-06 20:22:28 +0000913 unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +0000914 return AMDGPU::IsaInfo::getWavesPerWorkGroup(this, FlatWorkGroupSize);
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000915 }
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000916
Tom Stellardc5a154d2018-06-28 23:47:12 +0000917 // static wrappers
918 static bool hasHalfRate64Ops(const TargetSubtargetInfo &STI);
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000919
Matt Arsenault9f5e0ef2017-01-25 04:25:02 +0000920 // XXX - Why is this here if it isn't in the default pass set?
921 bool enableEarlyIfConversion() const override {
922 return true;
923 }
924
Tom Stellard83f0bce2015-01-29 16:55:25 +0000925 void overrideSchedPolicy(MachineSchedPolicy &Policy,
Tom Stellard83f0bce2015-01-29 16:55:25 +0000926 unsigned NumRegionInstrs) const override;
927
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000928 unsigned getMaxNumUserSGPRs() const {
929 return 16;
930 }
931
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000932 bool hasSMemRealTime() const {
933 return HasSMemRealTime;
934 }
935
Matt Arsenaultcc88ce32016-10-12 18:00:51 +0000936 bool hasMovrel() const {
937 return HasMovrel;
938 }
939
940 bool hasVGPRIndexMode() const {
941 return HasVGPRIndexMode;
942 }
943
Marek Olsake22fdb92017-03-21 17:00:32 +0000944 bool useVGPRIndexMode(bool UserEnable) const {
945 return !hasMovrel() || (UserEnable && hasVGPRIndexMode());
946 }
947
Matt Arsenault7b1dc2c2016-09-17 02:02:19 +0000948 bool hasScalarCompareEq64() const {
949 return getGeneration() >= VOLCANIC_ISLANDS;
950 }
951
Matt Arsenault7b647552016-10-28 21:55:15 +0000952 bool hasScalarStores() const {
953 return HasScalarStores;
954 }
955
Dmitry Preobrazhensky6bad04e2018-04-02 16:10:25 +0000956 bool hasScalarAtomics() const {
957 return HasScalarAtomics;
958 }
959
Matt Arsenaulta5840c32019-01-22 18:36:06 +0000960 bool hasLDSFPAtomics() const {
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +0000961 return GFX8Insts;
Matt Arsenaulta5840c32019-01-22 18:36:06 +0000962 }
Matt Arsenaultc88ba362016-10-29 04:05:06 +0000963
Sam Kolton07dbde22017-01-20 10:01:25 +0000964 bool hasDPP() const {
965 return HasDPP;
966 }
967
Jay Foadeac23862019-08-23 10:07:43 +0000968 bool hasDPPBroadcasts() const {
969 return HasDPP && getGeneration() < GFX10;
970 }
971
972 bool hasDPPWavefrontShifts() const {
973 return HasDPP && getGeneration() < GFX10;
974 }
975
Stanislav Mekhanoshin245b5ba2019-06-12 18:02:41 +0000976 bool hasDPP8() const {
977 return HasDPP8;
978 }
979
Ryan Taylor1f334d02018-08-28 15:07:30 +0000980 bool hasR128A16() const {
981 return HasR128A16;
982 }
983
Ryan Taylor9ab812d2019-06-26 17:34:57 +0000984 bool hasOffset3fBug() const {
985 return HasOffset3fBug;
986 }
987
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +0000988 bool hasNSAEncoding() const {
989 return HasNSAEncoding;
990 }
991
992 bool hasMadF16() const;
993
Tom Stellardde008d32016-01-21 04:28:34 +0000994 bool enableSIScheduler() const {
995 return EnableSIScheduler;
996 }
997
Matt Arsenault43e92fe2016-06-24 06:30:11 +0000998 bool loadStoreOptEnabled() const {
999 return EnableLoadStoreOpt;
Nicolai Haehnle5b504972016-01-04 23:35:53 +00001000 }
1001
Matt Arsenault43e92fe2016-06-24 06:30:11 +00001002 bool hasSGPRInitBug() const {
1003 return SGPRInitBug;
Matt Arsenault41003af2015-11-30 21:16:07 +00001004 }
Tom Stellard0d23ebe2016-08-29 19:42:52 +00001005
Stanislav Mekhanoshin8fe12452019-08-23 22:09:58 +00001006 bool hasMFMAInlineLiteralBug() const {
1007 return HasMFMAInlineLiteralBug;
1008 }
1009
Tom Stellardb133fbb2016-10-27 23:05:31 +00001010 bool has12DWordStoreHazard() const {
1011 return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS;
1012 }
1013
Neil Henninge85d45a2019-01-10 16:21:08 +00001014 // \returns true if the subtarget supports DWORDX3 load/store instructions.
1015 bool hasDwordx3LoadStores() const {
1016 return CIInsts;
1017 }
1018
Matt Arsenaulte823d922017-02-18 18:29:53 +00001019 bool hasSMovFedHazard() const {
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +00001020 return getGeneration() == AMDGPUSubtarget::GFX9;
Matt Arsenaulte823d922017-02-18 18:29:53 +00001021 }
1022
Matt Arsenaulta41351e2017-11-17 21:35:32 +00001023 bool hasReadM0MovRelInterpHazard() const {
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +00001024 return getGeneration() == AMDGPUSubtarget::GFX9;
Matt Arsenaulte823d922017-02-18 18:29:53 +00001025 }
1026
Matt Arsenaulta41351e2017-11-17 21:35:32 +00001027 bool hasReadM0SendMsgHazard() const {
Stanislav Mekhanoshin7895c032019-04-05 18:24:34 +00001028 return getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS &&
1029 getGeneration() <= AMDGPUSubtarget::GFX9;
Matt Arsenaulta41351e2017-11-17 21:35:32 +00001030 }
1031
Stanislav Mekhanoshincee607e2019-04-24 17:03:15 +00001032 bool hasVcmpxPermlaneHazard() const {
1033 return HasVcmpxPermlaneHazard;
1034 }
1035
1036 bool hasVMEMtoScalarWriteHazard() const {
1037 return HasVMEMtoScalarWriteHazard;
1038 }
1039
1040 bool hasSMEMtoVectorWriteHazard() const {
1041 return HasSMEMtoVectorWriteHazard;
1042 }
1043
1044 bool hasLDSMisalignedBug() const {
1045 return LDSMisalignedBug && !EnableCuMode;
1046 }
1047
1048 bool hasInstFwdPrefetchBug() const {
1049 return HasInstFwdPrefetchBug;
1050 }
1051
1052 bool hasVcmpxExecWARHazard() const {
1053 return HasVcmpxExecWARHazard;
1054 }
1055
1056 bool hasLdsBranchVmemWARHazard() const {
1057 return HasLdsBranchVmemWARHazard;
1058 }
1059
1060 bool hasNSAtoVMEMBug() const {
1061 return HasNSAtoVMEMBug;
1062 }
1063
Tom Stellardc5a154d2018-06-28 23:47:12 +00001064 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs
1065 /// SGPRs
Tom Stellard0d23ebe2016-08-29 19:42:52 +00001066 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
1067
Tom Stellardc5a154d2018-06-28 23:47:12 +00001068 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
1069 /// VGPRs
Tom Stellard0d23ebe2016-08-29 19:42:52 +00001070 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +00001071
Stanislav Mekhanoshin2594fa82019-07-31 01:07:10 +00001072 /// Return occupancy for the given function. Used LDS and a number of
1073 /// registers if provided.
1074 /// Note, occupancy can be affected by the scratch allocation as well, but
1075 /// we do not have enough information to compute it.
1076 unsigned computeOccupancy(const MachineFunction &MF, unsigned LDSSize = 0,
1077 unsigned NumSGPRs = 0, unsigned NumVGPRs = 0) const;
1078
Matt Arsenaulte823d922017-02-18 18:29:53 +00001079 /// \returns true if the flat_scratch register should be initialized with the
1080 /// pointer to the wave's scratch memory rather than a size and offset.
1081 bool flatScratchIsPointer() const {
Tom Stellardc5a154d2018-06-28 23:47:12 +00001082 return getGeneration() >= AMDGPUSubtarget::GFX9;
Konstantin Zhuravlyovd7bdf242016-09-30 16:50:36 +00001083 }
Matt Arsenault4eae3012016-10-28 20:31:47 +00001084
Tim Renouf832f90f2018-02-26 14:46:43 +00001085 /// \returns true if the machine has merged shaders in which s0-s7 are
1086 /// reserved by the hardware and user SGPRs start at s8
1087 bool hasMergedShaders() const {
1088 return getGeneration() >= GFX9;
1089 }
1090
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001091 /// \returns SGPR allocation granularity supported by the subtarget.
1092 unsigned getSGPRAllocGranule() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001093 return AMDGPU::IsaInfo::getSGPRAllocGranule(this);
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +00001094 }
1095
1096 /// \returns SGPR encoding granularity supported by the subtarget.
1097 unsigned getSGPREncodingGranule() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001098 return AMDGPU::IsaInfo::getSGPREncodingGranule(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001099 }
1100
1101 /// \returns Total number of SGPRs supported by the subtarget.
1102 unsigned getTotalNumSGPRs() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001103 return AMDGPU::IsaInfo::getTotalNumSGPRs(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001104 }
1105
1106 /// \returns Addressable number of SGPRs supported by the subtarget.
1107 unsigned getAddressableNumSGPRs() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001108 return AMDGPU::IsaInfo::getAddressableNumSGPRs(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001109 }
1110
1111 /// \returns Minimum number of SGPRs that meets the given number of waves per
1112 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001113 unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001114 return AMDGPU::IsaInfo::getMinNumSGPRs(this, WavesPerEU);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001115 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001116
1117 /// \returns Maximum number of SGPRs that meets the given number of waves per
1118 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001119 unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001120 return AMDGPU::IsaInfo::getMaxNumSGPRs(this, WavesPerEU, Addressable);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001121 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001122
1123 /// \returns Reserved number of SGPRs for given function \p MF.
1124 unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
1125
1126 /// \returns Maximum number of SGPRs that meets number of waves per execution
1127 /// unit requirement for function \p MF, or number of SGPRs explicitly
1128 /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
1129 ///
1130 /// \returns Value that meets number of waves per execution unit requirement
1131 /// if explicitly requested value cannot be converted to integer, violates
1132 /// subtarget's specifications, or does not meet number of waves per execution
1133 /// unit requirement.
1134 unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
1135
1136 /// \returns VGPR allocation granularity supported by the subtarget.
1137 unsigned getVGPRAllocGranule() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001138 return AMDGPU::IsaInfo::getVGPRAllocGranule(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001139 }
1140
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +00001141 /// \returns VGPR encoding granularity supported by the subtarget.
1142 unsigned getVGPREncodingGranule() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001143 return AMDGPU::IsaInfo::getVGPREncodingGranule(this);
Konstantin Zhuravlyove22fbcb2017-02-08 13:18:40 +00001144 }
1145
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001146 /// \returns Total number of VGPRs supported by the subtarget.
1147 unsigned getTotalNumVGPRs() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001148 return AMDGPU::IsaInfo::getTotalNumVGPRs(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001149 }
1150
1151 /// \returns Addressable number of VGPRs supported by the subtarget.
1152 unsigned getAddressableNumVGPRs() const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001153 return AMDGPU::IsaInfo::getAddressableNumVGPRs(this);
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001154 }
1155
1156 /// \returns Minimum number of VGPRs that meets given number of waves per
1157 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001158 unsigned getMinNumVGPRs(unsigned WavesPerEU) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001159 return AMDGPU::IsaInfo::getMinNumVGPRs(this, WavesPerEU);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001160 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001161
1162 /// \returns Maximum number of VGPRs that meets given number of waves per
1163 /// execution unit requirement supported by the subtarget.
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001164 unsigned getMaxNumVGPRs(unsigned WavesPerEU) const {
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001165 return AMDGPU::IsaInfo::getMaxNumVGPRs(this, WavesPerEU);
Konstantin Zhuravlyov9f89ede2017-02-08 14:05:23 +00001166 }
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001167
Konstantin Zhuravlyove03b1d72017-02-08 13:02:33 +00001168 /// \returns Maximum number of VGPRs that meets number of waves per execution
1169 /// unit requirement for function \p MF, or number of VGPRs explicitly
1170 /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
1171 ///
1172 /// \returns Value that meets number of waves per execution unit requirement
1173 /// if explicitly requested value cannot be converted to integer, violates
1174 /// subtarget's specifications, or does not meet number of waves per execution
1175 /// unit requirement.
1176 unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
Stanislav Mekhanoshind4ae4702017-09-19 20:54:38 +00001177
1178 void getPostRAMutations(
1179 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
1180 const override;
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001181
Stanislav Mekhanoshin68a2fef2019-06-13 23:47:36 +00001182 bool isWave32() const {
1183 return WavefrontSize == 32;
1184 }
1185
Stanislav Mekhanoshin52500212019-06-16 17:13:09 +00001186 const TargetRegisterClass *getBoolRC() const {
1187 return getRegisterInfo()->getBoolRC();
1188 }
1189
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001190 /// \returns Maximum number of work groups per compute unit supported by the
1191 /// subtarget and limited by given \p FlatWorkGroupSize.
1192 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
1193 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize);
1194 }
1195
1196 /// \returns Minimum flat work group size supported by the subtarget.
1197 unsigned getMinFlatWorkGroupSize() const override {
1198 return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this);
1199 }
1200
1201 /// \returns Maximum flat work group size supported by the subtarget.
1202 unsigned getMaxFlatWorkGroupSize() const override {
1203 return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this);
1204 }
1205
1206 /// \returns Maximum number of waves per execution unit supported by the
1207 /// subtarget and limited by given \p FlatWorkGroupSize.
1208 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const override {
1209 return AMDGPU::IsaInfo::getMaxWavesPerEU(this, FlatWorkGroupSize);
1210 }
1211
1212 /// \returns Minimum number of waves per execution unit supported by the
1213 /// subtarget.
1214 unsigned getMinWavesPerEU() const override {
1215 return AMDGPU::IsaInfo::getMinWavesPerEU(this);
1216 }
Tom Stellard75aadc22012-12-11 21:25:42 +00001217};
1218
Tom Stellardc5a154d2018-06-28 23:47:12 +00001219class R600Subtarget final : public R600GenSubtargetInfo,
Tom Stellard5bfbae52018-07-11 20:59:01 +00001220 public AMDGPUSubtarget {
Tom Stellardc5a154d2018-06-28 23:47:12 +00001221private:
1222 R600InstrInfo InstrInfo;
1223 R600FrameLowering FrameLowering;
1224 bool FMA;
1225 bool CaymanISA;
1226 bool CFALUBug;
Tom Stellardc5a154d2018-06-28 23:47:12 +00001227 bool HasVertexCache;
1228 bool R600ALUInst;
1229 bool FP64;
1230 short TexVTXClauseSize;
1231 Generation Gen;
1232 R600TargetLowering TLInfo;
1233 InstrItineraryData InstrItins;
1234 SelectionDAGTargetInfo TSInfo;
Tom Stellardc5a154d2018-06-28 23:47:12 +00001235
1236public:
1237 R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
1238 const TargetMachine &TM);
1239
1240 const R600InstrInfo *getInstrInfo() const override { return &InstrInfo; }
1241
1242 const R600FrameLowering *getFrameLowering() const override {
1243 return &FrameLowering;
1244 }
1245
1246 const R600TargetLowering *getTargetLowering() const override {
1247 return &TLInfo;
1248 }
1249
1250 const R600RegisterInfo *getRegisterInfo() const override {
1251 return &InstrInfo.getRegisterInfo();
1252 }
1253
1254 const InstrItineraryData *getInstrItineraryData() const override {
1255 return &InstrItins;
1256 }
1257
1258 // Nothing implemented, just prevent crashes on use.
1259 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
1260 return &TSInfo;
1261 }
1262
1263 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
1264
1265 Generation getGeneration() const {
1266 return Gen;
1267 }
1268
Guillaume Chatelet882c43d2019-10-17 07:49:39 +00001269 Align getStackAlignment() const { return Align(4); }
Tom Stellardc5a154d2018-06-28 23:47:12 +00001270
1271 R600Subtarget &initializeSubtargetDependencies(const Triple &TT,
1272 StringRef GPU, StringRef FS);
1273
1274 bool hasBFE() const {
1275 return (getGeneration() >= EVERGREEN);
1276 }
1277
1278 bool hasBFI() const {
1279 return (getGeneration() >= EVERGREEN);
1280 }
1281
1282 bool hasBCNT(unsigned Size) const {
1283 if (Size == 32)
1284 return (getGeneration() >= EVERGREEN);
1285
1286 return false;
1287 }
1288
1289 bool hasBORROW() const {
1290 return (getGeneration() >= EVERGREEN);
1291 }
1292
1293 bool hasCARRY() const {
1294 return (getGeneration() >= EVERGREEN);
1295 }
1296
1297 bool hasCaymanISA() const {
1298 return CaymanISA;
1299 }
1300
1301 bool hasFFBL() const {
1302 return (getGeneration() >= EVERGREEN);
1303 }
1304
1305 bool hasFFBH() const {
1306 return (getGeneration() >= EVERGREEN);
1307 }
1308
1309 bool hasFMA() const { return FMA; }
1310
Tom Stellardc5a154d2018-06-28 23:47:12 +00001311 bool hasCFAluBug() const { return CFALUBug; }
1312
1313 bool hasVertexCache() const { return HasVertexCache; }
1314
1315 short getTexVTXClauseSize() const { return TexVTXClauseSize; }
1316
Tom Stellardc5a154d2018-06-28 23:47:12 +00001317 bool enableMachineScheduler() const override {
1318 return true;
1319 }
1320
1321 bool enableSubRegLiveness() const override {
1322 return true;
1323 }
Konstantin Zhuravlyov71e43ee2018-09-12 18:50:47 +00001324
1325 /// \returns Maximum number of work groups per compute unit supported by the
1326 /// subtarget and limited by given \p FlatWorkGroupSize.
1327 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
1328 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(this, FlatWorkGroupSize);
1329 }
1330
1331 /// \returns Minimum flat work group size supported by the subtarget.
1332 unsigned getMinFlatWorkGroupSize() const override {
1333 return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(this);
1334 }
1335
1336 /// \returns Maximum flat work group size supported by the subtarget.
1337 unsigned getMaxFlatWorkGroupSize() const override {
1338 return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(this);
1339 }
1340
1341 /// \returns Maximum number of waves per execution unit supported by the
1342 /// subtarget and limited by given \p FlatWorkGroupSize.
1343 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize) const override {
1344 return AMDGPU::IsaInfo::getMaxWavesPerEU(this, FlatWorkGroupSize);
1345 }
1346
1347 /// \returns Minimum number of waves per execution unit supported by the
1348 /// subtarget.
1349 unsigned getMinWavesPerEU() const override {
1350 return AMDGPU::IsaInfo::getMinWavesPerEU(this);
1351 }
Tom Stellardc5a154d2018-06-28 23:47:12 +00001352};
1353
Eugene Zelenko2bc2f332016-12-09 22:06:55 +00001354} // end namespace llvm
Tom Stellard75aadc22012-12-11 21:25:42 +00001355
Eugene Zelenko2bc2f332016-12-09 22:06:55 +00001356#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H