1 //=====-- AMDGPUSubtarget.h - Define Subtarget for AMDGPU ------*- C++ -*-====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //==-----------------------------------------------------------------------===//
11 /// \brief AMDGPU specific subclass of TargetSubtarget.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
16 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
19 #include "AMDGPUFrameLowering.h"
20 #include "AMDGPUInstrInfo.h"
21 #include "AMDGPUISelLowering.h"
22 #include "AMDGPUSubtarget.h"
23 #include "Utils/AMDGPUBaseInfo.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/Target/TargetSubtargetInfo.h"
27 #define GET_SUBTARGETINFO_HEADER
28 #include "AMDGPUGenSubtargetInfo.inc"
32 class SIMachineFunctionInfo;
34 class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
48 FIXED_SGPR_COUNT_FOR_INIT_BUG = 80
65 short TexVTXClauseSize;
72 bool FlatAddressSpace;
74 bool EnableIRStructurizer;
75 bool EnablePromoteAlloca;
77 bool EnableLoadStoreOpt;
78 bool EnableUnsafeDSOffsetFolding;
79 unsigned WavefrontSize;
82 bool EnableVGPRSpilling;
91 bool EnableHugeScratchBuffer;
93 std::unique_ptr<AMDGPUFrameLowering> FrameLowering;
94 std::unique_ptr<AMDGPUTargetLowering> TLInfo;
95 std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
96 InstrItineraryData InstrItins;
100 AMDGPUSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
102 AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
103 StringRef GPU, StringRef FS);
105 const AMDGPUFrameLowering *getFrameLowering() const override {
106 return FrameLowering.get();
108 const AMDGPUInstrInfo *getInstrInfo() const override {
109 return InstrInfo.get();
111 const AMDGPURegisterInfo *getRegisterInfo() const override {
112 return &InstrInfo->getRegisterInfo();
114 AMDGPUTargetLowering *getTargetLowering() const override {
117 const InstrItineraryData *getInstrItineraryData() const override {
121 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
123 bool is64bit() const {
127 bool hasVertexCache() const {
128 return HasVertexCache;
131 short getTexVTXClauseSize() const {
132 return TexVTXClauseSize;
135 Generation getGeneration() const {
139 bool hasHWFP64() const {
143 bool hasCaymanISA() const {
147 bool hasFP32Denormals() const {
148 return FP32Denormals;
151 bool hasFP64Denormals() const {
152 return FP64Denormals;
155 bool hasFastFMAF32() const {
159 bool hasFlatAddressSpace() const {
160 return FlatAddressSpace;
163 bool useFlatForGlobal() const {
164 return FlatForGlobal;
167 bool hasBFE() const {
168 return (getGeneration() >= EVERGREEN);
171 bool hasBFI() const {
172 return (getGeneration() >= EVERGREEN);
175 bool hasBFM() const {
179 bool hasBCNT(unsigned Size) const {
181 return (getGeneration() >= EVERGREEN);
184 return (getGeneration() >= SOUTHERN_ISLANDS);
189 bool hasMulU24() const {
190 return (getGeneration() >= EVERGREEN);
193 bool hasMulI24() const {
194 return (getGeneration() >= SOUTHERN_ISLANDS ||
198 bool hasFFBL() const {
199 return (getGeneration() >= EVERGREEN);
202 bool hasFFBH() const {
203 return (getGeneration() >= EVERGREEN);
206 bool hasCARRY() const {
207 return (getGeneration() >= EVERGREEN);
210 bool hasBORROW() const {
211 return (getGeneration() >= EVERGREEN);
214 bool IsIRStructurizerEnabled() const {
215 return EnableIRStructurizer;
218 bool isPromoteAllocaEnabled() const {
219 return EnablePromoteAlloca;
222 bool isIfCvtEnabled() const {
226 bool loadStoreOptEnabled() const {
227 return EnableLoadStoreOpt;
230 bool unsafeDSOffsetFoldingEnabled() const {
231 return EnableUnsafeDSOffsetFolding;
234 unsigned getWavefrontSize() const {
235 return WavefrontSize;
238 unsigned getStackEntrySize() const;
240 bool hasCFAluBug() const {
241 assert(getGeneration() <= NORTHERN_ISLANDS);
245 int getLocalMemorySize() const {
246 return LocalMemorySize;
249 bool hasSGPRInitBug() const {
253 int getLDSBankCount() const {
257 unsigned getAmdKernelCodeChipID() const;
259 AMDGPU::IsaVersion getIsaVersion() const;
261 bool enableMachineScheduler() const override {
265 void overrideSchedPolicy(MachineSchedPolicy &Policy,
266 MachineInstr *begin, MachineInstr *end,
267 unsigned NumRegionInstrs) const override;
269 // Helper functions to simplify if statements
270 bool isTargetELF() const {
274 StringRef getDeviceName() const {
278 bool enableHugeScratchBuffer() const {
279 return EnableHugeScratchBuffer;
282 bool dumpCode() const {
285 bool r600ALUEncoding() const {
288 bool isAmdHsaOS() const {
289 return TargetTriple.getOS() == Triple::AMDHSA;
291 bool isVGPRSpillingEnabled(const SIMachineFunctionInfo *MFI) const;
293 unsigned getMaxWavesPerCU() const {
294 if (getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS)
297 // FIXME: Not sure what this is for other subtagets.
298 llvm_unreachable("do not know max waves per CU for this subtarget.");
301 bool enableSubRegLiveness() const override {
305 /// \brief Returns the offset in bytes from the start of the input buffer
306 /// of the first explicit kernel argument.
307 unsigned getExplicitKernelArgOffset() const {
308 return isAmdHsaOS() ? 0 : 36;
311 unsigned getMaxNumUserSGPRs() const {
316 } // End namespace llvm