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 /// AMDGPU specific subclass of TargetSubtarget.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
16 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H
19 #include "AMDGPUCallLowering.h"
20 #include "R600FrameLowering.h"
21 #include "R600ISelLowering.h"
22 #include "R600InstrInfo.h"
23 #include "SIFrameLowering.h"
24 #include "SIISelLowering.h"
25 #include "SIInstrInfo.h"
26 #include "Utils/AMDGPUBaseInfo.h"
27 #include "llvm/ADT/Triple.h"
28 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
29 #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
30 #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h"
31 #include "llvm/CodeGen/MachineFunction.h"
32 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
33 #include "llvm/MC/MCInstrItineraries.h"
34 #include "llvm/Support/MathExtras.h"
40 #define GET_SUBTARGETINFO_HEADER
41 #include "AMDGPUGenSubtargetInfo.inc"
42 #define GET_SUBTARGETINFO_HEADER
43 #include "R600GenSubtargetInfo.inc"
49 class AMDGPUSubtarget
{
66 const FeatureBitset
&SubtargetFeatureBits
;
75 bool HasFminFmaxLegacy
;
76 bool EnablePromoteAlloca
;
78 unsigned WavefrontSize
;
81 AMDGPUSubtarget(const Triple
&TT
, const FeatureBitset
&FeatureBits
);
83 static const AMDGPUSubtarget
&get(const MachineFunction
&MF
);
84 static const AMDGPUSubtarget
&get(const TargetMachine
&TM
,
87 /// \returns Default range flat work group size for a calling convention.
88 std::pair
<unsigned, unsigned> getDefaultFlatWorkGroupSize(CallingConv::ID CC
) const;
90 /// \returns Subtarget's default pair of minimum/maximum flat work group sizes
91 /// for function \p F, or minimum/maximum flat work group sizes explicitly
92 /// requested using "amdgpu-flat-work-group-size" attribute attached to
95 /// \returns Subtarget's default values if explicitly requested values cannot
96 /// be converted to integer, or violate subtarget's specifications.
97 std::pair
<unsigned, unsigned> getFlatWorkGroupSizes(const Function
&F
) const;
99 /// \returns Subtarget's default pair of minimum/maximum number of waves per
100 /// execution unit for function \p F, or minimum/maximum number of waves per
101 /// execution unit explicitly requested using "amdgpu-waves-per-eu" attribute
102 /// attached to function \p F.
104 /// \returns Subtarget's default values if explicitly requested values cannot
105 /// be converted to integer, violate subtarget's specifications, or are not
106 /// compatible with minimum/maximum number of waves limited by flat work group
107 /// size, register usage, and/or lds usage.
108 std::pair
<unsigned, unsigned> getWavesPerEU(const Function
&F
) const;
110 /// Return the amount of LDS that can be used that will not restrict the
111 /// occupancy lower than WaveCount.
112 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount
,
113 const Function
&) const;
115 /// Inverse of getMaxLocalMemWithWaveCount. Return the maximum wavecount if
116 /// the given LDS memory size is the only constraint.
117 unsigned getOccupancyWithLocalMemSize(uint32_t Bytes
, const Function
&) const;
119 unsigned getOccupancyWithLocalMemSize(const MachineFunction
&MF
) const;
121 bool isAmdHsaOS() const {
122 return TargetTriple
.getOS() == Triple::AMDHSA
;
125 bool isAmdPalOS() const {
126 return TargetTriple
.getOS() == Triple::AMDPAL
;
129 bool isMesa3DOS() const {
130 return TargetTriple
.getOS() == Triple::Mesa3D
;
133 bool isMesaKernel(const Function
&F
) const {
134 return isMesa3DOS() && !AMDGPU::isShader(F
.getCallingConv());
137 bool isAmdCodeObjectV2(const Function
&F
) const {
138 return isAmdHsaOS() || isMesaKernel(F
);
141 bool has16BitInsts() const {
142 return Has16BitInsts
;
145 bool hasMadMixInsts() const {
146 return HasMadMixInsts
;
149 bool hasFP32Denormals() const {
150 return FP32Denormals
;
153 bool hasFPExceptions() const {
157 bool hasSDWA() const {
161 bool hasVOP3PInsts() const {
162 return HasVOP3PInsts
;
165 bool hasMulI24() const {
169 bool hasMulU24() const {
173 bool hasFminFmaxLegacy() const {
174 return HasFminFmaxLegacy
;
177 bool isPromoteAllocaEnabled() const {
178 return EnablePromoteAlloca
;
181 unsigned getWavefrontSize() const {
182 return WavefrontSize
;
185 int getLocalMemorySize() const {
186 return LocalMemorySize
;
189 unsigned getAlignmentForImplicitArgPtr() const {
190 return isAmdHsaOS() ? 8 : 4;
193 /// Returns the offset in bytes from the start of the input buffer
194 /// of the first explicit kernel argument.
195 unsigned getExplicitKernelArgOffset(const Function
&F
) const {
196 return isAmdCodeObjectV2(F
) ? 0 : 36;
199 /// \returns Maximum number of work groups per compute unit supported by the
200 /// subtarget and limited by given \p FlatWorkGroupSize.
201 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize
) const {
202 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(SubtargetFeatureBits
,
206 /// \returns Minimum flat work group size supported by the subtarget.
207 unsigned getMinFlatWorkGroupSize() const {
208 return AMDGPU::IsaInfo::getMinFlatWorkGroupSize(SubtargetFeatureBits
);
211 /// \returns Maximum flat work group size supported by the subtarget.
212 unsigned getMaxFlatWorkGroupSize() const {
213 return AMDGPU::IsaInfo::getMaxFlatWorkGroupSize(SubtargetFeatureBits
);
216 /// \returns Maximum number of waves per execution unit supported by the
217 /// subtarget and limited by given \p FlatWorkGroupSize.
218 unsigned getMaxWavesPerEU(unsigned FlatWorkGroupSize
) const {
219 return AMDGPU::IsaInfo::getMaxWavesPerEU(SubtargetFeatureBits
,
223 /// \returns Minimum number of waves per execution unit supported by the
225 unsigned getMinWavesPerEU() const {
226 return AMDGPU::IsaInfo::getMinWavesPerEU(SubtargetFeatureBits
);
229 unsigned getMaxWavesPerEU() const { return 10; }
231 /// Creates value range metadata on an workitemid.* inrinsic call or load.
232 bool makeLIDRangeMetadata(Instruction
*I
) const;
234 virtual ~AMDGPUSubtarget() {}
237 class GCNSubtarget
: public AMDGPUGenSubtargetInfo
,
238 public AMDGPUSubtarget
{
259 enum TrapHandlerAbi
{
260 TrapHandlerAbiNone
= 0,
261 TrapHandlerAbiHsa
= 1
265 TrapIDHardwareReserved
= 0,
266 TrapIDHSADebugTrap
= 1,
268 TrapIDLLVMDebugTrap
= 3,
269 TrapIDDebugBreakpoint
= 7,
270 TrapIDDebugReserved8
= 8,
271 TrapIDDebugReservedFE
= 0xfe,
272 TrapIDDebugReservedFF
= 0xff
276 LLVMTrapHandlerRegValue
= 1
280 /// GlobalISel related APIs.
281 std::unique_ptr
<AMDGPUCallLowering
> CallLoweringInfo
;
282 std::unique_ptr
<InstructionSelector
> InstSelector
;
283 std::unique_ptr
<LegalizerInfo
> Legalizer
;
284 std::unique_ptr
<RegisterBankInfo
> RegBankInfo
;
287 // Basic subtarget description.
292 unsigned MaxPrivateElementSize
;
294 // Possibly statically set by tablegen, but may want to be overridden.
298 // Dynamially set bits that enable features.
299 bool FP64FP16Denormals
;
302 bool AutoWaitcntBeforeBarrier
;
304 bool UnalignedScratchAccess
;
305 bool UnalignedBufferAccess
;
306 bool HasApertureRegs
;
309 bool DebuggerInsertNops
;
310 bool DebuggerEmitPrologue
;
313 bool EnableHugePrivateBuffer
;
314 bool EnableVGPRSpilling
;
315 bool EnableLoadStoreOpt
;
316 bool EnableUnsafeDSOffsetFolding
;
317 bool EnableSIScheduler
;
321 // Subtarget statically properties set by tablegen
330 bool HasSMemRealTime
;
334 bool HasVGPRIndexMode
;
335 bool HasScalarStores
;
336 bool HasScalarAtomics
;
337 bool HasInv2PiInlineImm
;
342 bool HasSDWAOutModsVOPC
;
345 bool D16PreservesUnusedBits
;
346 bool FlatAddressSpace
;
347 bool FlatInstOffsets
;
348 bool FlatGlobalInsts
;
349 bool FlatScratchInsts
;
350 bool AddNoCarryInsts
;
351 bool HasUnpackedD16VMem
;
356 short TexVTXClauseSize
;
357 bool ScalarizeGlobal
;
359 // Dummy feature to use for assembler in tablegen.
362 SelectionDAGTargetInfo TSInfo
;
365 SIInstrInfo InstrInfo
;
366 SITargetLowering TLInfo
;
367 SIFrameLowering FrameLowering
;
370 GCNSubtarget(const Triple
&TT
, StringRef GPU
, StringRef FS
,
371 const GCNTargetMachine
&TM
);
372 ~GCNSubtarget() override
;
374 GCNSubtarget
&initializeSubtargetDependencies(const Triple
&TT
,
375 StringRef GPU
, StringRef FS
);
377 const SIInstrInfo
*getInstrInfo() const override
{
381 const SIFrameLowering
*getFrameLowering() const override
{
382 return &FrameLowering
;
385 const SITargetLowering
*getTargetLowering() const override
{
389 const SIRegisterInfo
*getRegisterInfo() const override
{
390 return &InstrInfo
.getRegisterInfo();
393 const CallLowering
*getCallLowering() const override
{
394 return CallLoweringInfo
.get();
397 const InstructionSelector
*getInstructionSelector() const override
{
398 return InstSelector
.get();
401 const LegalizerInfo
*getLegalizerInfo() const override
{
402 return Legalizer
.get();
405 const RegisterBankInfo
*getRegBankInfo() const override
{
406 return RegBankInfo
.get();
409 // Nothing implemented, just prevent crashes on use.
410 const SelectionDAGTargetInfo
*getSelectionDAGInfo() const override
{
414 void ParseSubtargetFeatures(StringRef CPU
, StringRef FS
);
416 Generation
getGeneration() const {
417 return (Generation
)Gen
;
420 unsigned getWavefrontSizeLog2() const {
421 return Log2_32(WavefrontSize
);
424 int getLDSBankCount() const {
428 unsigned getMaxPrivateElementSize() const {
429 return MaxPrivateElementSize
;
432 AMDGPUAS
getAMDGPUAS() const {
436 bool hasIntClamp() const {
440 bool hasFP64() const {
444 bool hasMIMG_R128() const {
448 bool hasHWFP64() const {
452 bool hasFastFMAF32() const {
456 bool hasHalfRate64Ops() const {
457 return HalfRate64Ops
;
460 bool hasAddr64() const {
461 return (getGeneration() < AMDGPUSubtarget::VOLCANIC_ISLANDS
);
464 bool hasBFE() const {
468 bool hasBFI() const {
472 bool hasBFM() const {
476 bool hasBCNT(unsigned Size
) const {
480 bool hasFFBL() const {
484 bool hasFFBH() const {
488 bool hasMed3_16() const {
489 return getGeneration() >= AMDGPUSubtarget::GFX9
;
492 bool hasMin3Max3_16() const {
493 return getGeneration() >= AMDGPUSubtarget::GFX9
;
496 bool hasFmaMixInsts() const {
497 return HasFmaMixInsts
;
500 bool hasCARRY() const {
504 bool hasFMA() const {
508 TrapHandlerAbi
getTrapHandlerAbi() const {
509 return isAmdHsaOS() ? TrapHandlerAbiHsa
: TrapHandlerAbiNone
;
512 bool enableHugePrivateBuffer() const {
513 return EnableHugePrivateBuffer
;
516 bool unsafeDSOffsetFoldingEnabled() const {
517 return EnableUnsafeDSOffsetFolding
;
520 bool dumpCode() const {
524 /// Return the amount of LDS that can be used that will not restrict the
525 /// occupancy lower than WaveCount.
526 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount
,
527 const Function
&) const;
529 bool hasFP16Denormals() const {
530 return FP64FP16Denormals
;
533 bool hasFP64Denormals() const {
534 return FP64FP16Denormals
;
537 bool supportsMinMaxDenormModes() const {
538 return getGeneration() >= AMDGPUSubtarget::GFX9
;
541 bool enableDX10Clamp() const {
545 bool enableIEEEBit(const MachineFunction
&MF
) const {
546 return AMDGPU::isCompute(MF
.getFunction().getCallingConv());
549 bool useFlatForGlobal() const {
550 return FlatForGlobal
;
553 /// \returns If target supports ds_read/write_b128 and user enables generation
554 /// of ds_read/write_b128.
555 bool useDS128() const {
556 return CIInsts
&& EnableDS128
;
559 /// \returns If MUBUF instructions always perform range checking, even for
560 /// buffer resources used for private memory access.
561 bool privateMemoryResourceIsRangeChecked() const {
562 return getGeneration() < AMDGPUSubtarget::GFX9
;
565 bool hasAutoWaitcntBeforeBarrier() const {
566 return AutoWaitcntBeforeBarrier
;
569 bool hasCodeObjectV3() const {
573 bool hasUnalignedBufferAccess() const {
574 return UnalignedBufferAccess
;
577 bool hasUnalignedScratchAccess() const {
578 return UnalignedScratchAccess
;
581 bool hasApertureRegs() const {
582 return HasApertureRegs
;
585 bool isTrapHandlerEnabled() const {
589 bool isXNACKEnabled() const {
593 bool hasFlatAddressSpace() const {
594 return FlatAddressSpace
;
597 bool hasFlatInstOffsets() const {
598 return FlatInstOffsets
;
601 bool hasFlatGlobalInsts() const {
602 return FlatGlobalInsts
;
605 bool hasFlatScratchInsts() const {
606 return FlatScratchInsts
;
609 bool hasFlatLgkmVMemCountInOrder() const {
610 return getGeneration() > GFX9
;
613 bool hasD16LoadStore() const {
614 return getGeneration() >= GFX9
;
617 /// Return if most LDS instructions have an m0 use that require m0 to be
619 bool ldsRequiresM0Init() const {
620 return getGeneration() < GFX9
;
623 bool hasAddNoCarry() const {
624 return AddNoCarryInsts
;
627 bool hasUnpackedD16VMem() const {
628 return HasUnpackedD16VMem
;
631 // Covers VS/PS/CS graphics shaders
632 bool isMesaGfxShader(const Function
&F
) const {
633 return isMesa3DOS() && AMDGPU::isShader(F
.getCallingConv());
636 bool hasMad64_32() const {
637 return getGeneration() >= SEA_ISLANDS
;
640 bool hasSDWAOmod() const {
644 bool hasSDWAScalar() const {
645 return HasSDWAScalar
;
648 bool hasSDWASdst() const {
652 bool hasSDWAMac() const {
656 bool hasSDWAOutModsVOPC() const {
657 return HasSDWAOutModsVOPC
;
660 bool vmemWriteNeedsExpWaitcnt() const {
661 return getGeneration() < SEA_ISLANDS
;
664 bool hasDLInsts() const {
668 bool d16PreservesUnusedBits() const {
669 return D16PreservesUnusedBits
;
672 /// \returns Number of bytes of arguments that are passed to a shader or
673 /// kernel in addition to the explicit ones declared for the function.
674 unsigned getImplicitArgNumBytes(const Function
&F
) const {
677 return AMDGPU::getIntegerAttribute(F
, "amdgpu-implicitarg-num-bytes", 0);
680 // Scratch is allocated in 256 dword per wave blocks for the entire
681 // wavefront. When viewed from the perspecive of an arbitrary workitem, this
682 // is 4-byte aligned.
684 // Only 4-byte alignment is really needed to access anything. Transformations
685 // on the pointer value itself may rely on the alignment / known low bits of
686 // the pointer. Set this to something above the minimum to avoid needing
687 // dynamic realignment in common cases.
688 unsigned getStackAlignment() const {
692 bool enableMachineScheduler() const override
{
696 bool enableSubRegLiveness() const override
{
700 void setScalarizeGlobalBehavior(bool b
) { ScalarizeGlobal
= b
; }
701 bool getScalarizeGlobalBehavior() const { return ScalarizeGlobal
; }
703 /// \returns Number of execution units per compute unit supported by the
705 unsigned getEUsPerCU() const {
706 return AMDGPU::IsaInfo::getEUsPerCU(MCSubtargetInfo::getFeatureBits());
709 /// \returns Maximum number of waves per compute unit supported by the
710 /// subtarget without any kind of limitation.
711 unsigned getMaxWavesPerCU() const {
712 return AMDGPU::IsaInfo::getMaxWavesPerCU(MCSubtargetInfo::getFeatureBits());
715 /// \returns Maximum number of waves per compute unit supported by the
716 /// subtarget and limited by given \p FlatWorkGroupSize.
717 unsigned getMaxWavesPerCU(unsigned FlatWorkGroupSize
) const {
718 return AMDGPU::IsaInfo::getMaxWavesPerCU(MCSubtargetInfo::getFeatureBits(),
722 /// \returns Maximum number of waves per execution unit supported by the
723 /// subtarget without any kind of limitation.
724 unsigned getMaxWavesPerEU() const {
725 return AMDGPU::IsaInfo::getMaxWavesPerEU();
728 /// \returns Number of waves per work group supported by the subtarget and
729 /// limited by given \p FlatWorkGroupSize.
730 unsigned getWavesPerWorkGroup(unsigned FlatWorkGroupSize
) const {
731 return AMDGPU::IsaInfo::getWavesPerWorkGroup(
732 MCSubtargetInfo::getFeatureBits(), FlatWorkGroupSize
);
736 static bool hasHalfRate64Ops(const TargetSubtargetInfo
&STI
);
738 // XXX - Why is this here if it isn't in the default pass set?
739 bool enableEarlyIfConversion() const override
{
743 void overrideSchedPolicy(MachineSchedPolicy
&Policy
,
744 unsigned NumRegionInstrs
) const override
;
746 bool isVGPRSpillingEnabled(const Function
&F
) const;
748 unsigned getMaxNumUserSGPRs() const {
752 bool hasSMemRealTime() const {
753 return HasSMemRealTime
;
756 bool hasMovrel() const {
760 bool hasVGPRIndexMode() const {
761 return HasVGPRIndexMode
;
764 bool useVGPRIndexMode(bool UserEnable
) const {
765 return !hasMovrel() || (UserEnable
&& hasVGPRIndexMode());
768 bool hasScalarCompareEq64() const {
769 return getGeneration() >= VOLCANIC_ISLANDS
;
772 bool hasScalarStores() const {
773 return HasScalarStores
;
776 bool hasScalarAtomics() const {
777 return HasScalarAtomics
;
780 bool hasInv2PiInlineImm() const {
781 return HasInv2PiInlineImm
;
784 bool hasDPP() const {
788 bool enableSIScheduler() const {
789 return EnableSIScheduler
;
792 bool debuggerSupported() const {
793 return debuggerInsertNops() && debuggerEmitPrologue();
796 bool debuggerInsertNops() const {
797 return DebuggerInsertNops
;
800 bool debuggerEmitPrologue() const {
801 return DebuggerEmitPrologue
;
804 bool loadStoreOptEnabled() const {
805 return EnableLoadStoreOpt
;
808 bool hasSGPRInitBug() const {
812 bool has12DWordStoreHazard() const {
813 return getGeneration() != AMDGPUSubtarget::SOUTHERN_ISLANDS
;
816 bool hasSMovFedHazard() const {
817 return getGeneration() >= AMDGPUSubtarget::GFX9
;
820 bool hasReadM0MovRelInterpHazard() const {
821 return getGeneration() >= AMDGPUSubtarget::GFX9
;
824 bool hasReadM0SendMsgHazard() const {
825 return getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS
;
828 uint64_t getExplicitKernArgSize(const Function
&F
) const;
829 unsigned getKernArgSegmentSize(const Function
&F
,
830 int64_t ExplicitArgBytes
= -1) const;
832 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs
834 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs
) const;
836 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
838 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs
) const;
840 /// \returns true if the flat_scratch register should be initialized with the
841 /// pointer to the wave's scratch memory rather than a size and offset.
842 bool flatScratchIsPointer() const {
843 return getGeneration() >= AMDGPUSubtarget::GFX9
;
846 /// \returns true if the machine has merged shaders in which s0-s7 are
847 /// reserved by the hardware and user SGPRs start at s8
848 bool hasMergedShaders() const {
849 return getGeneration() >= GFX9
;
852 /// \returns SGPR allocation granularity supported by the subtarget.
853 unsigned getSGPRAllocGranule() const {
854 return AMDGPU::IsaInfo::getSGPRAllocGranule(
855 MCSubtargetInfo::getFeatureBits());
858 /// \returns SGPR encoding granularity supported by the subtarget.
859 unsigned getSGPREncodingGranule() const {
860 return AMDGPU::IsaInfo::getSGPREncodingGranule(
861 MCSubtargetInfo::getFeatureBits());
864 /// \returns Total number of SGPRs supported by the subtarget.
865 unsigned getTotalNumSGPRs() const {
866 return AMDGPU::IsaInfo::getTotalNumSGPRs(MCSubtargetInfo::getFeatureBits());
869 /// \returns Addressable number of SGPRs supported by the subtarget.
870 unsigned getAddressableNumSGPRs() const {
871 return AMDGPU::IsaInfo::getAddressableNumSGPRs(
872 MCSubtargetInfo::getFeatureBits());
875 /// \returns Minimum number of SGPRs that meets the given number of waves per
876 /// execution unit requirement supported by the subtarget.
877 unsigned getMinNumSGPRs(unsigned WavesPerEU
) const {
878 return AMDGPU::IsaInfo::getMinNumSGPRs(MCSubtargetInfo::getFeatureBits(),
882 /// \returns Maximum number of SGPRs that meets the given number of waves per
883 /// execution unit requirement supported by the subtarget.
884 unsigned getMaxNumSGPRs(unsigned WavesPerEU
, bool Addressable
) const {
885 return AMDGPU::IsaInfo::getMaxNumSGPRs(MCSubtargetInfo::getFeatureBits(),
886 WavesPerEU
, Addressable
);
889 /// \returns Reserved number of SGPRs for given function \p MF.
890 unsigned getReservedNumSGPRs(const MachineFunction
&MF
) const;
892 /// \returns Maximum number of SGPRs that meets number of waves per execution
893 /// unit requirement for function \p MF, or number of SGPRs explicitly
894 /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
896 /// \returns Value that meets number of waves per execution unit requirement
897 /// if explicitly requested value cannot be converted to integer, violates
898 /// subtarget's specifications, or does not meet number of waves per execution
899 /// unit requirement.
900 unsigned getMaxNumSGPRs(const MachineFunction
&MF
) const;
902 /// \returns VGPR allocation granularity supported by the subtarget.
903 unsigned getVGPRAllocGranule() const {
904 return AMDGPU::IsaInfo::getVGPRAllocGranule(
905 MCSubtargetInfo::getFeatureBits());
908 /// \returns VGPR encoding granularity supported by the subtarget.
909 unsigned getVGPREncodingGranule() const {
910 return AMDGPU::IsaInfo::getVGPREncodingGranule(
911 MCSubtargetInfo::getFeatureBits());
914 /// \returns Total number of VGPRs supported by the subtarget.
915 unsigned getTotalNumVGPRs() const {
916 return AMDGPU::IsaInfo::getTotalNumVGPRs(MCSubtargetInfo::getFeatureBits());
919 /// \returns Addressable number of VGPRs supported by the subtarget.
920 unsigned getAddressableNumVGPRs() const {
921 return AMDGPU::IsaInfo::getAddressableNumVGPRs(
922 MCSubtargetInfo::getFeatureBits());
925 /// \returns Minimum number of VGPRs that meets given number of waves per
926 /// execution unit requirement supported by the subtarget.
927 unsigned getMinNumVGPRs(unsigned WavesPerEU
) const {
928 return AMDGPU::IsaInfo::getMinNumVGPRs(MCSubtargetInfo::getFeatureBits(),
932 /// \returns Maximum number of VGPRs that meets given number of waves per
933 /// execution unit requirement supported by the subtarget.
934 unsigned getMaxNumVGPRs(unsigned WavesPerEU
) const {
935 return AMDGPU::IsaInfo::getMaxNumVGPRs(MCSubtargetInfo::getFeatureBits(),
939 /// \returns Maximum number of VGPRs that meets number of waves per execution
940 /// unit requirement for function \p MF, or number of VGPRs explicitly
941 /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
943 /// \returns Value that meets number of waves per execution unit requirement
944 /// if explicitly requested value cannot be converted to integer, violates
945 /// subtarget's specifications, or does not meet number of waves per execution
946 /// unit requirement.
947 unsigned getMaxNumVGPRs(const MachineFunction
&MF
) const;
949 void getPostRAMutations(
950 std::vector
<std::unique_ptr
<ScheduleDAGMutation
>> &Mutations
)
954 class R600Subtarget final
: public R600GenSubtargetInfo
,
955 public AMDGPUSubtarget
{
957 R600InstrInfo InstrInfo
;
958 R600FrameLowering FrameLowering
;
966 short TexVTXClauseSize
;
968 R600TargetLowering TLInfo
;
969 InstrItineraryData InstrItins
;
970 SelectionDAGTargetInfo TSInfo
;
974 R600Subtarget(const Triple
&TT
, StringRef CPU
, StringRef FS
,
975 const TargetMachine
&TM
);
977 const R600InstrInfo
*getInstrInfo() const override
{ return &InstrInfo
; }
979 const R600FrameLowering
*getFrameLowering() const override
{
980 return &FrameLowering
;
983 const R600TargetLowering
*getTargetLowering() const override
{
987 const R600RegisterInfo
*getRegisterInfo() const override
{
988 return &InstrInfo
.getRegisterInfo();
991 const InstrItineraryData
*getInstrItineraryData() const override
{
995 // Nothing implemented, just prevent crashes on use.
996 const SelectionDAGTargetInfo
*getSelectionDAGInfo() const override
{
1000 void ParseSubtargetFeatures(StringRef CPU
, StringRef FS
);
1002 Generation
getGeneration() const {
1006 unsigned getStackAlignment() const {
1010 R600Subtarget
&initializeSubtargetDependencies(const Triple
&TT
,
1011 StringRef GPU
, StringRef FS
);
1013 bool hasBFE() const {
1014 return (getGeneration() >= EVERGREEN
);
1017 bool hasBFI() const {
1018 return (getGeneration() >= EVERGREEN
);
1021 bool hasBCNT(unsigned Size
) const {
1023 return (getGeneration() >= EVERGREEN
);
1028 bool hasBORROW() const {
1029 return (getGeneration() >= EVERGREEN
);
1032 bool hasCARRY() const {
1033 return (getGeneration() >= EVERGREEN
);
1036 bool hasCaymanISA() const {
1040 bool hasFFBL() const {
1041 return (getGeneration() >= EVERGREEN
);
1044 bool hasFFBH() const {
1045 return (getGeneration() >= EVERGREEN
);
1048 bool hasFMA() const { return FMA
; }
1050 bool hasCFAluBug() const { return CFALUBug
; }
1052 bool hasVertexCache() const { return HasVertexCache
; }
1054 short getTexVTXClauseSize() const { return TexVTXClauseSize
; }
1056 AMDGPUAS
getAMDGPUAS() const { return AS
; }
1058 bool enableMachineScheduler() const override
{
1062 bool enableSubRegLiveness() const override
{
1067 } // end namespace llvm
1069 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUSUBTARGET_H