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;
80 unsigned WavefrontSize;
83 bool EnableVGPRSpilling;
92 bool EnableHugeScratchBuffer;
94 std::unique_ptr<AMDGPUFrameLowering> FrameLowering;
95 std::unique_ptr<AMDGPUTargetLowering> TLInfo;
96 std::unique_ptr<AMDGPUInstrInfo> InstrInfo;
97 InstrItineraryData InstrItins;
101 AMDGPUSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
103 AMDGPUSubtarget &initializeSubtargetDependencies(const Triple &TT,
104 StringRef GPU, StringRef FS);
106 const AMDGPUFrameLowering *getFrameLowering() const override {
107 return FrameLowering.get();
109 const AMDGPUInstrInfo *getInstrInfo() const override {
110 return InstrInfo.get();
112 const AMDGPURegisterInfo *getRegisterInfo() const override {
113 return &InstrInfo->getRegisterInfo();
115 AMDGPUTargetLowering *getTargetLowering() const override {
118 const InstrItineraryData *getInstrItineraryData() const override {
122 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
124 bool is64bit() const {
128 bool hasVertexCache() const {
129 return HasVertexCache;
132 short getTexVTXClauseSize() const {
133 return TexVTXClauseSize;
136 Generation getGeneration() const {
140 bool hasHWFP64() const {
144 bool hasCaymanISA() const {
148 bool hasFP32Denormals() const {
149 return FP32Denormals;
152 bool hasFP64Denormals() const {
153 return FP64Denormals;
156 bool hasFastFMAF32() const {
160 bool hasFlatAddressSpace() const {
161 return FlatAddressSpace;
164 bool useFlatForGlobal() const {
165 return FlatForGlobal;
168 bool hasBFE() const {
169 return (getGeneration() >= EVERGREEN);
172 bool hasBFI() const {
173 return (getGeneration() >= EVERGREEN);
176 bool hasBFM() const {
180 bool hasBCNT(unsigned Size) const {
182 return (getGeneration() >= EVERGREEN);
185 return (getGeneration() >= SOUTHERN_ISLANDS);
190 bool hasMulU24() const {
191 return (getGeneration() >= EVERGREEN);
194 bool hasMulI24() const {
195 return (getGeneration() >= SOUTHERN_ISLANDS ||
199 bool hasFFBL() const {
200 return (getGeneration() >= EVERGREEN);
203 bool hasFFBH() const {
204 return (getGeneration() >= EVERGREEN);
207 bool hasCARRY() const {
208 return (getGeneration() >= EVERGREEN);
211 bool hasBORROW() const {
212 return (getGeneration() >= EVERGREEN);
215 bool IsIRStructurizerEnabled() const {
216 return EnableIRStructurizer;
219 bool isPromoteAllocaEnabled() const {
220 return EnablePromoteAlloca;
223 bool isIfCvtEnabled() const {
227 bool loadStoreOptEnabled() const {
228 return EnableLoadStoreOpt;
231 bool unsafeDSOffsetFoldingEnabled() const {
232 return EnableUnsafeDSOffsetFolding;
235 unsigned getWavefrontSize() const {
236 return WavefrontSize;
239 unsigned getStackEntrySize() const;
241 bool hasCFAluBug() const {
242 assert(getGeneration() <= NORTHERN_ISLANDS);
246 int getLocalMemorySize() const {
247 return LocalMemorySize;
250 bool hasSGPRInitBug() const {
254 int getLDSBankCount() const {
258 unsigned getAmdKernelCodeChipID() const;
260 AMDGPU::IsaVersion getIsaVersion() const;
262 bool enableMachineScheduler() const override {
266 void overrideSchedPolicy(MachineSchedPolicy &Policy,
267 MachineInstr *begin, MachineInstr *end,
268 unsigned NumRegionInstrs) const override;
270 // Helper functions to simplify if statements
271 bool isTargetELF() const {
275 StringRef getDeviceName() const {
279 bool enableHugeScratchBuffer() const {
280 return EnableHugeScratchBuffer;
283 bool dumpCode() const {
286 bool r600ALUEncoding() const {
289 bool isAmdHsaOS() const {
290 return TargetTriple.getOS() == Triple::AMDHSA;
292 bool isVGPRSpillingEnabled(const SIMachineFunctionInfo *MFI) const;
294 bool isXNACKEnabled() const {
298 unsigned getMaxWavesPerCU() const {
299 if (getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS)
302 // FIXME: Not sure what this is for other subtagets.
303 llvm_unreachable("do not know max waves per CU for this subtarget.");
306 bool enableSubRegLiveness() const override {
310 /// \brief Returns the offset in bytes from the start of the input buffer
311 /// of the first explicit kernel argument.
312 unsigned getExplicitKernelArgOffset() const {
313 return isAmdHsaOS() ? 0 : 36;
316 unsigned getMaxNumUserSGPRs() const {
321 } // End namespace llvm