1 //=====-- AMDGPUSubtarget.h - Define Subtarget for the AMDIL ---*- 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_R600_AMDGPUSUBTARGET_H
16 #define LLVM_LIB_TARGET_R600_AMDGPUSUBTARGET_H
18 #include "AMDGPUFrameLowering.h"
19 #include "AMDGPUInstrInfo.h"
20 #include "AMDGPUIntrinsicInfo.h"
21 #include "AMDGPUSubtarget.h"
22 #include "R600ISelLowering.h"
23 #include "llvm/ADT/StringExtras.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/Target/TargetSubtargetInfo.h"
28 #define GET_SUBTARGETINFO_HEADER
29 #include "AMDGPUGenSubtargetInfo.inc"
33 class SIMachineFunctionInfo
;
35 class AMDGPUSubtarget
: public AMDGPUGenSubtargetInfo
{
54 short TexVTXClauseSize
;
60 bool FlatAddressSpace
;
61 bool EnableIRStructurizer
;
62 bool EnablePromoteAlloca
;
64 bool EnableLoadStoreOpt
;
65 unsigned WavefrontSize
;
68 bool EnableVGPRSpilling
;
71 AMDGPUFrameLowering FrameLowering
;
72 std::unique_ptr
<AMDGPUTargetLowering
> TLInfo
;
73 std::unique_ptr
<AMDGPUInstrInfo
> InstrInfo
;
74 InstrItineraryData InstrItins
;
78 AMDGPUSubtarget(StringRef TT
, StringRef CPU
, StringRef FS
, TargetMachine
&TM
);
79 AMDGPUSubtarget
&initializeSubtargetDependencies(StringRef GPU
, StringRef FS
);
81 const AMDGPUFrameLowering
*getFrameLowering() const override
{
82 return &FrameLowering
;
84 const AMDGPUInstrInfo
*getInstrInfo() const override
{
85 return InstrInfo
.get();
87 const AMDGPURegisterInfo
*getRegisterInfo() const override
{
88 return &InstrInfo
->getRegisterInfo();
90 AMDGPUTargetLowering
*getTargetLowering() const override
{
93 const DataLayout
*getDataLayout() const override
{ return &DL
; }
94 const InstrItineraryData
*getInstrItineraryData() const override
{
98 void ParseSubtargetFeatures(StringRef CPU
, StringRef FS
);
100 bool is64bit() const {
104 bool hasVertexCache() const {
105 return HasVertexCache
;
108 short getTexVTXClauseSize() const {
109 return TexVTXClauseSize
;
112 Generation
getGeneration() const {
116 bool hasHWFP64() const {
120 bool hasCaymanISA() const {
124 bool hasFP32Denormals() const {
125 return FP32Denormals
;
128 bool hasFP64Denormals() const {
129 return FP64Denormals
;
132 bool hasFlatAddressSpace() const {
133 return FlatAddressSpace
;
136 bool hasBFE() const {
137 return (getGeneration() >= EVERGREEN
);
140 bool hasBFI() const {
141 return (getGeneration() >= EVERGREEN
);
144 bool hasBFM() const {
148 bool hasBCNT(unsigned Size
) const {
150 return (getGeneration() >= EVERGREEN
);
153 return (getGeneration() >= SOUTHERN_ISLANDS
);
158 bool hasMulU24() const {
159 return (getGeneration() >= EVERGREEN
);
162 bool hasMulI24() const {
163 return (getGeneration() >= SOUTHERN_ISLANDS
||
167 bool hasFFBL() const {
168 return (getGeneration() >= EVERGREEN
);
171 bool hasFFBH() const {
172 return (getGeneration() >= EVERGREEN
);
175 bool IsIRStructurizerEnabled() const {
176 return EnableIRStructurizer
;
179 bool isPromoteAllocaEnabled() const {
180 return EnablePromoteAlloca
;
183 bool isIfCvtEnabled() const {
187 bool loadStoreOptEnabled() const {
188 return EnableLoadStoreOpt
;
191 unsigned getWavefrontSize() const {
192 return WavefrontSize
;
195 unsigned getStackEntrySize() const;
197 bool hasCFAluBug() const {
198 assert(getGeneration() <= NORTHERN_ISLANDS
);
202 int getLocalMemorySize() const {
203 return LocalMemorySize
;
206 unsigned getAmdKernelCodeChipID() const;
208 bool enableMachineScheduler() const override
{
209 return getGeneration() <= NORTHERN_ISLANDS
;
212 void overrideSchedPolicy(MachineSchedPolicy
&Policy
,
213 MachineInstr
*begin
, MachineInstr
*end
,
214 unsigned NumRegionInstrs
) const override
;
216 // Helper functions to simplify if statements
217 bool isTargetELF() const {
221 StringRef
getDeviceName() const {
225 bool dumpCode() const {
228 bool r600ALUEncoding() const {
231 bool isAmdHsaOS() const {
232 return TargetTriple
.getOS() == Triple::AMDHSA
;
234 bool isVGPRSpillingEnabled(const SIMachineFunctionInfo
*MFI
) const;
236 unsigned getMaxWavesPerCU() const {
237 if (getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS
)
240 // FIXME: Not sure what this is for other subtagets.
241 llvm_unreachable("do not know max waves per CU for this subtarget.");
245 } // End namespace llvm