LLVM 24.0.0git
GCNSubtarget.h
Go to the documentation of this file.
1//=====-- GCNSubtarget.h - Define GCN Subtarget for AMDGPU ------*- C++ -*-===//
2//
3// 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
6//
7//==-----------------------------------------------------------------------===//
8//
9/// \file
10/// AMD GCN specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
15#define LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
16
17#include "AMDGPUCallLowering.h"
19#include "AMDGPUSubtarget.h"
20#include "SIFrameLowering.h"
21#include "SIISelLowering.h"
22#include "SIInstrInfo.h"
26
27#define GET_SUBTARGETINFO_HEADER
28#include "AMDGPUGenSubtargetInfo.inc"
29
30namespace llvm {
31
32class GCNTargetMachine;
33
34/// Module flag names controlling out-of-bounds buffer access semantics.
35/// Each flag is an i32 with Module::Max merge behaviour and tri-state values:
36/// 0 = any (absent/default - backend currently treats as strict)
37/// 1 = relaxed
38/// 2 = strict
39namespace AMDGPUOOBMode {
40inline constexpr StringLiteral BufferFlag("amdgpu.buffer.oob.mode");
41inline constexpr StringLiteral TBufferFlag("amdgpu.tbuffer.oob.mode");
42} // namespace AMDGPUOOBMode
43
45 public AMDGPUSubtarget {
46public:
48
49 // Following 2 enums are documented at:
50 // - https://llvm.org/docs/AMDGPUUsage.html#trap-handler-abi
51 enum class TrapHandlerAbi {
52 NONE = 0x00,
53 AMDHSA = 0x01,
54 };
55
56 enum class TrapID {
59 };
60
61private:
62 /// SelectionDAGISel related APIs.
63 std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
64
65 /// GlobalISel related APIs.
66 std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
67 std::unique_ptr<InlineAsmLowering> InlineAsmLoweringInfo;
68 std::unique_ptr<InstructionSelector> InstSelector;
69 std::unique_ptr<LegalizerInfo> Legalizer;
70 std::unique_ptr<AMDGPURegisterBankInfo> RegBankInfo;
71
72protected:
73 // Basic subtarget description.
75 unsigned Gen = INVALID;
77 int LDSBankCount = 0;
79
80 // Instruction cache line size in bytes; set from TableGen subtarget features.
81 unsigned InstCacheLineSize = 0;
82
83 // Data (VMEM) cache line size in bytes; set from TableGen subtarget features.
84 unsigned DataCacheLineSize = 0;
85
86 // Dynamically set bits that enable features.
87 bool DynamicVGPR = false;
89 bool ScalarizeGlobal = false;
90 const bool BufferOOBRelaxed;
92
93 /// The maximum number of instructions that may be placed within an S_CLAUSE,
94 /// which is one greater than the maximum argument to S_CLAUSE. A value of 0
95 /// indicates a lack of S_CLAUSE support.
96 unsigned MaxHardClauseLength = 0;
97
98#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
99 bool ATTRIBUTE = DEFAULT;
100#include "AMDGPUGenSubtargetInfo.inc"
101
102private:
103 SIInstrInfo InstrInfo;
104 SITargetLowering TLInfo;
105 SIFrameLowering FrameLowering;
106
107 /// Get the register that represents the actual dependency between the
108 /// definition and the use. The definition might only affect a subregister
109 /// that is not actually used. Works for both virtual and physical registers.
110 /// Note: Currently supports VOP3P instructions (without WMMA an SWMMAC).
111 /// Returns the definition register if there is a real dependency and no
112 /// better match is found.
113 Register getRealSchedDependency(const MachineInstr &DefI, int DefOpIdx,
114 const MachineInstr &UseI, int UseOpIdx) const;
115
116public:
118 const Triple &TT, StringRef GPU, StringRef FS, const GCNTargetMachine &TM,
119 bool BufferOOBRelaxed = false, bool TBufferOOBRelaxed = false,
120 AMDGPU::TargetIDSetting XnackSetting = AMDGPU::TargetIDSetting::Any,
121 AMDGPU::TargetIDSetting SramEccSetting = AMDGPU::TargetIDSetting::Any);
122 ~GCNSubtarget() override;
123
125 StringRef FS);
126
127 /// Diagnose inconsistent subtarget features before attempting to codegen
128 /// function \p F.
129 void checkSubtargetFeatures(const Function &F) const;
130
131 const SIInstrInfo *getInstrInfo() const override { return &InstrInfo; }
132
133 const SIFrameLowering *getFrameLowering() const override {
134 return &FrameLowering;
135 }
136
137 const SITargetLowering *getTargetLowering() const override { return &TLInfo; }
138
139 const SIRegisterInfo *getRegisterInfo() const override {
140 return &InstrInfo.getRegisterInfo();
141 }
142
143 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
144
145 const CallLowering *getCallLowering() const override {
146 return CallLoweringInfo.get();
147 }
148
149 const InlineAsmLowering *getInlineAsmLowering() const override {
150 return InlineAsmLoweringInfo.get();
151 }
152
154 return InstSelector.get();
155 }
156
157 const LegalizerInfo *getLegalizerInfo() const override {
158 return Legalizer.get();
159 }
160
161 const AMDGPURegisterBankInfo *getRegBankInfo() const override {
162 return RegBankInfo.get();
163 }
164
165 const AMDGPU::TargetID &getTargetID() const { return TargetID; }
166
168 return &InstrItins;
169 }
170
172
174
175 bool isGFX11Plus() const { return getGeneration() >= GFX11; }
176
177#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
178 bool GETTER() const override { return ATTRIBUTE; }
179#include "AMDGPUGenSubtargetInfo.inc"
180
181 unsigned getMaxWaveScratchSize() const {
182 // See COMPUTE_TMPRING_SIZE.WAVESIZE.
183 if (getGeneration() >= GFX12) {
184 // 18-bit field in units of 64-dword.
185 return (64 * 4) * ((1 << 18) - 1);
186 }
187 if (getGeneration() == GFX11) {
188 // 15-bit field in units of 64-dword.
189 return (64 * 4) * ((1 << 15) - 1);
190 }
191 // 13-bit field in units of 256-dword.
192 return (256 * 4) * ((1 << 13) - 1);
193 }
194
195 /// Return the number of high bits known to be zero for a frame index.
199
200 int getLDSBankCount() const { return LDSBankCount; }
201
202 /// Instruction cache line size in bytes (64 for pre-GFX11, 128 for GFX11+).
203 unsigned getInstCacheLineSize() const { return InstCacheLineSize; }
204
205 /// Data (VMEM) cache line size in bytes (128 for gfx12), has no use before
206 /// GFX12.
207 unsigned getDataCacheLineSize() const { return DataCacheLineSize; }
208
209 unsigned getMaxPrivateElementSize(bool ForBufferRSrc = false) const {
210 return (ForBufferRSrc || !hasFlatScratchEnabled()) ? MaxPrivateElementSize
211 : 16;
212 }
213
214 unsigned getConstantBusLimit(unsigned Opcode) const;
215
216 /// Returns if the result of this instruction with a 16-bit result returned in
217 /// a 32-bit register implicitly zeroes the high 16-bits, rather than preserve
218 /// the original value.
219 bool zeroesHigh16BitsOfDest(unsigned Opcode) const;
220
221 bool hasHWFP64() const { return HasFP64; }
222
223 bool hasAddr64() const {
225 }
226
227 bool hasFlat() const {
229 }
230
231 // Return true if the target only has the reverse operand versions of VALU
232 // shift instructions (e.g. v_lshrrev_b32, and no v_lshr_b32).
233 bool hasOnlyRevVALUShifts() const {
235 }
236
237 bool hasFractBug() const { return getGeneration() == SOUTHERN_ISLANDS; }
238
239 bool hasMed3_16() const { return getGeneration() >= AMDGPUSubtarget::GFX9; }
240
241 bool hasMin3Max3_16() const {
243 }
244
245 bool hasSwap() const { return HasGFX9Insts; }
246
247 bool hasScalarPackInsts() const { return HasGFX9Insts; }
248
249 bool hasScalarMulHiInsts() const { return HasGFX9Insts; }
250
251 bool hasScalarSubwordLoads() const { return getGeneration() >= GFX12; }
252
253 bool hasAsyncMark() const { return hasVMemToLDSLoad() || HasAsynccnt; }
254
258
260 // The S_GETREG DOORBELL_ID is supported by all GFX9 onward targets.
261 return getGeneration() >= GFX9;
262 }
263
264 /// True if the offset field of DS instructions works as expected. On SI, the
265 /// offset uses a 16-bit adder and does not always wrap properly.
266 bool hasUsableDSOffset() const { return getGeneration() >= SEA_ISLANDS; }
267
269 return EnableUnsafeDSOffsetFolding;
270 }
271
272 /// Condition output from div_scale is usable.
276
277 /// Extra wait hazard is needed in some cases before
278 /// s_cbranch_vccnz/s_cbranch_vccz.
279 bool hasReadVCCZBug() const { return getGeneration() <= SEA_ISLANDS; }
280
281 /// Writes to VCC_LO/VCC_HI update the VCCZ flag.
282 bool partialVCCWritesUpdateVCCZ() const { return getGeneration() >= GFX10; }
283
284 /// A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR
285 /// was written by a VALU instruction.
288 }
289
290 /// A read of an SGPR by a VMEM instruction requires 5 wait states when the
291 /// SGPR was written by a VALU Instruction.
294 }
295
296 bool hasRFEHazards() const { return getGeneration() >= VOLCANIC_ISLANDS; }
297
298 /// Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
299 unsigned getSetRegWaitStates() const {
300 return getGeneration() <= SEA_ISLANDS ? 1 : 2;
301 }
302
303 /// Return the amount of LDS that can be used that will not restrict the
304 /// occupancy lower than WaveCount.
305 unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount,
306 const Function &) const;
307
310 }
311
312 /// \returns If target supports S_DENORM_MODE.
313 bool hasDenormModeInst() const {
315 }
316
317 /// \returns If target supports ds_read/write_b128 and user enables generation
318 /// of ds_read/write_b128.
319 bool useDS128() const { return HasCIInsts && EnableDS128; }
320
321 /// \return If target supports ds_read/write_b96/128.
322 bool hasDS96AndDS128() const { return HasCIInsts; }
323
324 /// Have v_trunc_f64, v_ceil_f64, v_rndne_f64
325 bool haveRoundOpsF64() const { return HasCIInsts; }
326
327 /// \returns If MUBUF instructions always perform range checking, even for
328 /// buffer resources used for private memory access.
332
333 /// \returns If target requires PRT Struct NULL support (zero result registers
334 /// for sparse texture support).
335 bool usePRTStrictNull() const { return EnablePRTStrictNull; }
336
338 return HasUnalignedBufferAccess && HasUnalignedAccessMode;
339 }
340
342 return HasUnalignedDSAccess && HasUnalignedAccessMode;
343 }
344
346 return HasUnalignedScratchAccess && HasUnalignedAccessMode;
347 }
348
349 bool isXNACKEnabled() const {
350 return enableXNACK() || TargetID.isXnackOnOrAny();
351 }
352
355
356 bool isCuModeEnabled() const { return EnableCuMode; }
357
358 bool isPreciseMemoryEnabled() const { return EnablePreciseMemory; }
359
360 bool hasFlatScrRegister() const { return hasFlatAddressSpace(); }
361
362 // Check if target supports ST addressing mode with FLAT scratch instructions.
363 // The ST addressing mode means no registers are used, either VGPR or SGPR,
364 // but only immediate offset is swizzled and added to the FLAT scratch base.
365 bool hasFlatScratchSTMode() const {
366 return hasFlatScratchInsts() && (hasGFX10_3Insts() || hasGFX940Insts());
367 }
368
369 bool hasFlatScratchSVSMode() const { return HasGFX940Insts || HasGFX11Insts; }
370
372 return hasArchitectedFlatScratch() ||
373 (EnableFlatScratch && hasFlatScratchInsts());
374 }
375
376 bool hasGlobalAddTidInsts() const { return HasGFX10_BEncoding; }
377
378 bool hasAtomicCSub() const { return HasGFX10_BEncoding; }
379
380 bool hasExportInsts() const {
381 return !hasGFX940Insts() && !hasGFX1250Insts();
382 }
383
384 bool hasVINTERPEncoding() const {
385 return HasGFX11Insts && !hasGFX1250Insts();
386 }
387
389 return getGeneration() >= GFX9;
390 }
391
392 bool hasFlatLgkmVMemCountInOrder() const { return getGeneration() > GFX9; }
393
394 bool hasD16LoadStore() const { return getGeneration() >= GFX9; }
395
397 return hasD16LoadStore() && !TargetID.isSramEccOnOrAny();
398 }
399
400 bool hasD16Images() const { return getGeneration() >= VOLCANIC_ISLANDS; }
401
402 /// Return if most LDS instructions have an m0 use that require m0 to be
403 /// initialized.
404 bool ldsRequiresM0Init() const { return getGeneration() < GFX9; }
405
406 // True if the hardware rewinds and replays GWS operations if a wave is
407 // preempted.
408 //
409 // If this is false, a GWS operation requires testing if a nack set the
410 // MEM_VIOL bit, and repeating if so.
411 bool hasGWSAutoReplay() const { return getGeneration() >= GFX9; }
412
413 /// \returns if target has ds_gws_sema_release_all instruction.
414 bool hasGWSSemaReleaseAll() const { return HasCIInsts; }
415
416 bool hasScalarAddSub64() const { return getGeneration() >= GFX12; }
417
418 bool hasScalarSMulU64() const { return getGeneration() >= GFX12; }
419
420 // Covers VS/PS/CS graphics shaders
421 bool isMesaGfxShader(const Function &F) const {
422 return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv());
423 }
424
425 bool hasMad64_32() const { return getGeneration() >= SEA_ISLANDS; }
426
427 bool hasAtomicFaddInsts() const {
428 return HasAtomicFaddRtnInsts || HasAtomicFaddNoRtnInsts;
429 }
430
432 return getGeneration() < SEA_ISLANDS;
433 }
434
435 bool hasInstPrefetch() const {
436 return getGeneration() == GFX10 || getGeneration() == GFX11;
437 }
438
439 bool hasPrefetch() const { return HasGFX12Insts; }
440
441 bool hasInstPrefSize() const { return isGFX11Plus(); }
442
443 void getInstPrefSizeArgs(uint32_t &Mask, uint32_t &Shift, uint32_t &Width,
444 uint32_t &CacheLineSize) const {
447 if (getGeneration() == GFX11) {
448 Mask = amdhsa::COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE;
449 Shift = amdhsa::COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE_SHIFT;
450 Width = amdhsa::COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE_WIDTH;
451 } else {
452 Mask = amdhsa::COMPUTE_PGM_RSRC3_GFX12_PLUS_INST_PREF_SIZE;
453 Shift = amdhsa::COMPUTE_PGM_RSRC3_GFX12_PLUS_INST_PREF_SIZE_SHIFT;
454 Width = amdhsa::COMPUTE_PGM_RSRC3_GFX12_PLUS_INST_PREF_SIZE_WIDTH;
455 }
456 }
457
458 // Has s_cmpk_* instructions.
459 bool hasSCmpK() const { return getGeneration() < GFX12; }
460
461 // Scratch is allocated in 256 dword per wave blocks for the entire
462 // wavefront. When viewed from the perspective of an arbitrary workitem, this
463 // is 4-byte aligned.
464 //
465 // Only 4-byte alignment is really needed to access anything. Transformations
466 // on the pointer value itself may rely on the alignment / known low bits of
467 // the pointer. Set this to something above the minimum to avoid needing
468 // dynamic realignment in common cases.
469 Align getStackAlignment() const { return Align(16); }
470
471 bool enableMachineScheduler() const override { return true; }
472
473 bool useAA() const override;
474
475 bool enableSubRegLiveness() const override { return true; }
476
479
480 // static wrappers
481 static bool hasHalfRate64Ops(const TargetSubtargetInfo &STI);
482
483 // XXX - Why is this here if it isn't in the default pass set?
484 bool enableEarlyIfConversion() const override { return true; }
485
487 const SchedRegion &Region) const override;
488
490 const SchedRegion &Region) const override;
491
492 void mirFileLoaded(MachineFunction &MF) const override;
493
494 unsigned getMaxNumUserSGPRs() const {
495 return AMDGPU::getMaxNumUserSGPRs(*this);
496 }
497
498 bool useVGPRIndexMode() const;
499
500 bool hasScalarCompareEq64() const {
502 }
503
504 bool hasLDSFPAtomicAddF32() const { return HasGFX8Insts; }
505 bool hasLDSFPAtomicAddF64() const {
506 return HasGFX90AInsts || HasGFX1250Insts;
507 }
508
509 /// \returns true if the subtarget has the v_permlane64_b32 instruction.
510 bool hasPermLane64() const { return getGeneration() >= GFX11; }
511
512 /// \returns true if the subtarget supports the ds_swizzle rotate and FFT
513 /// swizzle modes (GFX9+).
514 bool hasDsSwizzleRotateMode() const { return getGeneration() >= GFX9; }
515
516 bool hasDPPRowShare() const {
517 return HasDPP && (HasGFX90AInsts || getGeneration() >= GFX10);
518 }
519
520 // Has V_PK_MOV_B32 opcode
521 bool hasPkMovB32() const { return HasGFX90AInsts; }
522
524 return getGeneration() >= GFX10 || hasGFX940Insts();
525 }
526
527 bool hasFmaakFmamkF64Insts() const { return hasGFX1250Insts(); }
528
529 bool hasNonNSAEncoding() const { return getGeneration() < GFX12; }
530
531 unsigned getNSAMaxSize(bool HasSampler = false) const {
532 return AMDGPU::getNSAMaxSize(*this, HasSampler);
533 }
534
535 bool hasMadF16() const;
536
537 // Scalar and global loads support scale_offset bit.
538 bool hasScaleOffset() const { return HasGFX1250Insts; }
539
540 // FLAT GLOBAL VOffset is signed
541 bool hasSignedGVSOffset() const { return HasGFX1250Insts; }
542
544
546 return HasUserSGPRInit16Bug && isWave32();
547 }
548
552
553 // \returns true if the subtarget supports DWORDX3 load/store instructions.
554 bool hasDwordx3LoadStores() const { return HasCIInsts; }
555
559
564
567 }
568
571 }
572
574 return HasLDSMisalignedBug && !EnableCuMode;
575 }
576
577 // Shift amount of a 64 bit shift cannot be a highest allocated register
578 // if also at the end of the allocation block.
579 bool hasShift64HighRegBug() const { return HasGFX90AInsts; }
580
581 // v_dot2c_f32_f16 unconditionally flushes f16 subnormal inputs to zero
582 // regardless of the MODE register, unlike v_fma_mix_f32 which respects it.
584 return HasGFX90AInsts && !HasGFX940Insts;
585 }
586
587 // Has one cycle hazard on transcendental instruction feeding a
588 // non transcendental VALU.
589 bool hasTransForwardingHazard() const { return HasGFX940Insts; }
590
591 // Has one cycle hazard on a VALU instruction partially writing dst with
592 // a shift of result bits feeding another VALU instruction.
593 bool hasDstSelForwardingHazard() const { return HasGFX940Insts; }
594
595 // Cannot use op_sel with v_dot instructions.
596 bool hasDOTOpSelHazard() const { return HasGFX940Insts || HasGFX11Insts; }
597
598 // Does not have HW interlocs for VALU writing and then reading SGPRs.
599 bool hasVDecCoExecHazard() const { return HasGFX940Insts; }
600
601 bool hasHardClauses() const { return MaxHardClauseLength > 0; }
602
604 return getGeneration() == GFX10;
605 }
606
607 bool hasVOP3DPP() const { return getGeneration() >= GFX11; }
608
609 bool hasLdsDirect() const { return getGeneration() >= GFX11; }
610
611 bool hasLdsWaitVMSRC() const { return getGeneration() >= GFX12; }
612
614 return getGeneration() == GFX11;
615 }
616
617 bool hasCvtScaleForwardingHazard() const { return HasGFX950Insts; }
618
619 // All GFX9 targets experience a fetch delay when an instruction at the start
620 // of a loop header is split by a 32-byte fetch window boundary, but GFX950
621 // is uniquely sensitive to this: the delay triggers further performance
622 // degradation beyond the fetch latency itself.
623 bool hasLoopHeadInstSplitSensitivity() const { return HasGFX950Insts; }
624
625 bool requiresCodeObjectV6() const { return RequiresCOV6; }
626
627 bool useVGPRBlockOpsForCSR() const { return UseBlockVGPROpsForCSR; }
628
629 bool hasVALUMaskWriteHazard() const { return getGeneration() == GFX11; }
630
632 return HasGFX12Insts && !HasGFX1250Insts;
633 }
634
635 bool setRegModeNeedsVNOPs() const {
636 return HasGFX1250Insts && getGeneration() == GFX12;
637 }
638
639 /// Return if operations acting on VGPR tuples require even alignment.
640 bool needsAlignedVGPRs() const { return RequiresAlignVGPR; }
641
642 /// Return true if the target has the S_PACK_HL_B32_B16 instruction.
643 bool hasSPackHL() const { return HasGFX11Insts; }
644
645 /// Return true if the target has the V_CVT_PK_I16_F32/V_CVT_PK_U16_F32
646 /// instructions.
647 bool hasVCvtPkIU16F32() const { return HasGFX11Insts; }
648
649 /// Return true if the target's EXP instruction supports the NULL export
650 /// target.
651 bool hasNullExportTarget() const { return !HasGFX11Insts; }
652
653 bool hasFlatScratchSVSSwizzleBug() const { return getGeneration() == GFX11; }
654
655 /// Return true if the target has the S_DELAY_ALU instruction.
656 bool hasDelayAlu() const { return HasGFX11Insts; }
657
658 /// Returns true if the target supports
659 /// global_load_lds_dwordx3/global_load_lds_dwordx4 or
660 /// buffer_load_dwordx3/buffer_load_dwordx4 with the lds bit.
661 bool hasLDSLoadB96_B128() const { return hasGFX950Insts(); }
662
663 /// \returns true if the target uses LOADcnt/SAMPLEcnt/BVHcnt, DScnt/KMcnt
664 /// and STOREcnt rather than VMcnt, LGKMcnt and VScnt respectively.
665 bool hasExtendedWaitCounts() const { return getGeneration() >= GFX12; }
666
667 /// \returns true if the target has packed f32 instructions that only read 32
668 /// bits from a scalar operand (SGPR or literal) and replicates the bits to
669 /// both channels.
671 return getGeneration() == GFX12 && HasGFX1250Insts;
672 }
673
674 bool hasAddPC64Inst() const { return HasGFX1250Insts; }
675
676 /// \returns true if the target supports expert scheduling mode 2 which relies
677 /// on the compiler to insert waits to avoid hazards between VMEM and VALU
678 /// instructions in some instances.
679 bool hasExpertSchedulingMode() const { return getGeneration() >= GFX12; }
680
681 /// \returns The maximum number of instructions that can be enclosed in an
682 /// S_CLAUSE on the given subtarget, or 0 for targets that do not support that
683 /// instruction.
684 unsigned maxHardClauseLength() const { return MaxHardClauseLength; }
685
686 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs
687 /// SGPRs
688 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
689
690 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
691 /// VGPRs
692 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs,
693 unsigned DynamicVGPRBlockSize) const;
694
695 /// Subtarget's minimum/maximum occupancy, in number of waves per EU, that can
696 /// be achieved when the only function running on a CU is \p F, each workgroup
697 /// uses \p LDSSize bytes of LDS, and each wave uses \p NumSGPRs SGPRs and \p
698 /// NumVGPRs VGPRs. The flat workgroup sizes associated to the function are a
699 /// range, so this returns a range as well.
700 ///
701 /// Note that occupancy can be affected by the scratch allocation as well, but
702 /// we do not have enough information to compute it.
703 std::pair<unsigned, unsigned> computeOccupancy(const Function &F,
704 unsigned LDSSize = 0,
705 unsigned NumSGPRs = 0,
706 unsigned NumVGPRs = 0) const;
707
708 /// \returns true if the flat_scratch register should be initialized with the
709 /// pointer to the wave's scratch memory rather than a size and offset.
710 bool flatScratchIsPointer() const {
712 }
713
714 /// \returns true if the machine has merged shaders in which s0-s7 are
715 /// reserved by the hardware and user SGPRs start at s8
716 bool hasMergedShaders() const { return getGeneration() >= GFX9; }
717
718 // \returns true if the target supports the pre-NGG legacy geometry path.
719 bool hasLegacyGeometry() const { return getGeneration() < GFX11; }
720
721 // \returns true if the target has split barriers feature
722 bool hasSplitBarriers() const { return getGeneration() >= GFX12; }
723
724 // \returns true if the target has WG_RR_MODE kernel descriptor mode bit
725 bool hasRrWGMode() const { return getGeneration() >= GFX12; }
726
727 /// \returns true if VADDR and SADDR fields in VSCRATCH can use negative
728 /// values.
729 bool hasSignedScratchOffsets() const { return getGeneration() >= GFX12; }
730
731 bool hasINVWBL2WaitCntRequirement() const { return HasGFX1250Insts; }
732
733 bool hasVOPD3() const { return HasGFX1250Insts; }
734
735 // \returns true if the target has V_PK_{MIN|MAX}3_{I|U}16 instructions.
736 bool hasPkMinMax3Insts() const { return HasGFX1250Insts; }
737
738 // \returns ture if target has S_GET_SHADER_CYCLES_U64 instruction.
739 bool hasSGetShaderCyclesInst() const { return HasGFX1250Insts; }
740
741 // \returns true if S_GETPC_B64 zero-extends the result from 48 bits instead
742 // of sign-extending. Note that GFX1250 has not only fixed the bug but also
743 // extended VA to 57 bits.
745 return HasGFX12Insts && !HasGFX1250Insts;
746 }
747
748 // \returns true if the target needs to create a prolog for backward
749 // compatibility when preloading kernel arguments.
751 return hasKernargPreload() && !HasGFX1250Insts;
752 }
753
754 bool hasCondSubInsts() const { return HasGFX12Insts; }
755
756 bool hasSubClampInsts() const { return hasGFX10_3Insts(); }
757
758 bool hasAnyPackedFP32Ops() const {
759 return hasPackedFP32Ops() || hasPackedFP32SingleSGPROps();
760 };
761
762 bool hasAnyPackedFP64Ops() const { return hasPackedFP64SingleSGPROps(); };
763
764 bool hasAnyPackedU64Ops() const { return hasPackedU64SingleSGPROps(); };
765
766 /// \returns SGPR allocation granularity supported by the subtarget.
767 unsigned getSGPRAllocGranule() const {
768 return AMDGPU::getSGPRAllocGranule(getTargetID().getGPUKind());
769 }
770
771 /// \returns SGPR encoding granularity supported by the subtarget.
772 unsigned getSGPREncodingGranule() const {
774 }
775
776 /// \returns Total number of SGPRs supported by the subtarget.
777 unsigned getTotalNumSGPRs() const {
778 return AMDGPU::getTotalNumSGPRs(getTargetID().getGPUKind());
779 }
780
781 /// \returns Addressable number of SGPRs supported by the subtarget.
782 unsigned getAddressableNumSGPRs() const {
783 return AMDGPU::getAddressableNumSGPRs(getTargetID().getGPUKind());
784 }
785
786 /// \returns Minimum number of SGPRs that meets the given number of waves per
787 /// execution unit requirement supported by the subtarget.
788 unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
789 return AMDGPU::IsaInfo::getMinNumSGPRs(*this, WavesPerEU);
790 }
791
792 /// \returns Maximum number of SGPRs that meets the given number of waves per
793 /// execution unit requirement supported by the subtarget.
794 unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
795 return AMDGPU::IsaInfo::getMaxNumSGPRs(*this, WavesPerEU, Addressable);
796 }
797
798 /// \returns Reserved number of SGPRs. This is common
799 /// utility function called by MachineFunction and
800 /// Function variants of getReservedNumSGPRs.
801 unsigned getBaseReservedNumSGPRs(const bool HasFlatScratch) const;
802 /// \returns Reserved number of SGPRs for given machine function \p MF.
803 unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
804
805 /// \returns Reserved number of SGPRs for given function \p F.
806 unsigned getReservedNumSGPRs(const Function &F) const;
807
808 /// \returns Maximum number of preloaded SGPRs for the subtarget.
809 unsigned getMaxNumPreloadedSGPRs() const;
810
811 /// \returns max num SGPRs. This is the common utility
812 /// function called by MachineFunction and Function
813 /// variants of getMaxNumSGPRs.
814 unsigned getBaseMaxNumSGPRs(const Function &F,
815 std::pair<unsigned, unsigned> WavesPerEU,
816 unsigned PreloadedSGPRs,
817 unsigned ReservedNumSGPRs) const;
818
819 /// \returns Maximum number of SGPRs that meets number of waves per execution
820 /// unit requirement for function \p MF, or number of SGPRs explicitly
821 /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
822 ///
823 /// \returns Value that meets number of waves per execution unit requirement
824 /// if explicitly requested value cannot be converted to integer, violates
825 /// subtarget's specifications, or does not meet number of waves per execution
826 /// unit requirement.
827 unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
828
829 /// \returns Maximum number of SGPRs that meets number of waves per execution
830 /// unit requirement for function \p F, or number of SGPRs explicitly
831 /// requested using "amdgpu-num-sgpr" attribute attached to function \p F.
832 ///
833 /// \returns Value that meets number of waves per execution unit requirement
834 /// if explicitly requested value cannot be converted to integer, violates
835 /// subtarget's specifications, or does not meet number of waves per execution
836 /// unit requirement.
837 unsigned getMaxNumSGPRs(const Function &F) const;
838
839 /// \returns VGPR allocation granularity supported by the subtarget.
840 unsigned getVGPRAllocGranule(unsigned DynamicVGPRBlockSize) const {
841 return AMDGPU::IsaInfo::getVGPRAllocGranule(*this, DynamicVGPRBlockSize);
842 }
843
844 /// \returns VGPR encoding granularity supported by the subtarget.
845 unsigned getVGPREncodingGranule() const {
847 }
848
849 /// \returns Total number of VGPRs supported by the subtarget.
850 unsigned getTotalNumVGPRs() const {
852 }
853
854 /// \returns Addressable number of architectural VGPRs supported by the
855 /// subtarget.
859
860 /// \returns Addressable number of VGPRs supported by the subtarget.
861 unsigned getAddressableNumVGPRs(unsigned DynamicVGPRBlockSize) const {
862 return AMDGPU::IsaInfo::getAddressableNumVGPRs(*this, DynamicVGPRBlockSize);
863 }
864
865 /// \returns the minimum number of VGPRs that will prevent achieving more than
866 /// the specified number of waves \p WavesPerEU.
867 unsigned getMinNumVGPRs(unsigned WavesPerEU,
868 unsigned DynamicVGPRBlockSize) const {
869 return AMDGPU::IsaInfo::getMinNumVGPRs(*this, WavesPerEU,
870 DynamicVGPRBlockSize);
871 }
872
873 /// \returns the maximum number of VGPRs that can be used and still achieved
874 /// at least the specified number of waves \p WavesPerEU.
875 unsigned getMaxNumVGPRs(unsigned WavesPerEU,
876 unsigned DynamicVGPRBlockSize) const {
877 return AMDGPU::IsaInfo::getMaxNumVGPRs(*this, WavesPerEU,
878 DynamicVGPRBlockSize);
879 }
880
881 /// \returns max num VGPRs. This is the common utility function
882 /// called by MachineFunction and Function variants of getMaxNumVGPRs.
883 unsigned
885 std::pair<unsigned, unsigned> NumVGPRBounds) const;
886
887 /// \returns Maximum number of VGPRs that meets number of waves per execution
888 /// unit requirement for function \p F, or number of VGPRs explicitly
889 /// requested using "amdgpu-num-vgpr" attribute attached to function \p F.
890 ///
891 /// \returns Value that meets number of waves per execution unit requirement
892 /// if explicitly requested value cannot be converted to integer, violates
893 /// subtarget's specifications, or does not meet number of waves per execution
894 /// unit requirement.
895 unsigned getMaxNumVGPRs(const Function &F) const;
896
897 unsigned getMaxNumAGPRs(const Function &F) const { return getMaxNumVGPRs(F); }
898
899 /// Return a pair of maximum numbers of VGPRs and AGPRs that meet the number
900 /// of waves per execution unit required for the function \p MF.
901 std::pair<unsigned, unsigned> getMaxNumVectorRegs(const Function &F) const;
902
903 /// \returns Maximum number of VGPRs that meets number of waves per execution
904 /// unit requirement for function \p MF, or number of VGPRs explicitly
905 /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
906 ///
907 /// \returns Value that meets number of waves per execution unit requirement
908 /// if explicitly requested value cannot be converted to integer, violates
909 /// subtarget's specifications, or does not meet number of waves per execution
910 /// unit requirement.
911 unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
912
913 bool isWave32() const { return getWavefrontSize() == 32; }
914
915 bool isWave64() const { return getWavefrontSize() == 64; }
916
917 /// Returns if the wavesize of this subtarget is known reliable. This is false
918 /// only for the a default target-cpu that does not have an explicit
919 /// +wavefrontsize target feature.
920 bool isWaveSizeKnown() const {
921 return hasFeature(AMDGPU::FeatureWavefrontSize32) ||
922 hasFeature(AMDGPU::FeatureWavefrontSize64);
923 }
924
926 return getRegisterInfo()->getBoolRC();
927 }
928
929 /// \returns Maximum number of work groups per compute unit supported by the
930 /// subtarget and limited by given \p FlatWorkGroupSize.
931 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
932 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(*this, FlatWorkGroupSize);
933 }
934
935 /// \returns Minimum flat work group size supported by the subtarget.
936 unsigned getMinFlatWorkGroupSize() const override {
938 }
939
940 /// \returns Maximum flat work group size supported by the subtarget.
941 unsigned getMaxFlatWorkGroupSize() const override {
943 }
944
945 /// \returns Number of waves per execution unit required to support the given
946 /// \p FlatWorkGroupSize.
947 unsigned
948 getWavesPerEUForWorkGroup(unsigned FlatWorkGroupSize) const override {
949 return AMDGPU::IsaInfo::getWavesPerEUForWorkGroup(*this, FlatWorkGroupSize);
950 }
951
952 /// \returns Minimum number of waves per execution unit supported by the
953 /// subtarget.
954 unsigned getMinWavesPerEU() const override {
956 }
957
958 void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx,
959 SDep &Dep,
960 const TargetSchedModel *SchedModel) const override;
961
962 // \returns true if it's beneficial on this subtarget for the scheduler to
963 // cluster stores as well as loads.
964 bool shouldClusterStores() const { return getGeneration() >= GFX11; }
965
966 // \returns the number of address arguments from which to enable MIMG NSA
967 // on supported architectures.
968 unsigned getNSAThreshold(const MachineFunction &MF) const;
969
970 // \returns true if the subtarget has a hazard requiring an "s_nop 0"
971 // instruction before "s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)".
972 bool requiresNopBeforeDeallocVGPRs() const { return !HasGFX1250Insts; }
973
974 // \returns true if the subtarget needs S_WAIT_ALU 0 before S_GETREG_B32 on
975 // STATUS, STATE_PRIV, EXCP_FLAG_PRIV, or EXCP_FLAG_USER.
976 bool requiresWaitIdleBeforeGetReg() const { return HasGFX1250Insts; }
977
978 bool isDynamicVGPREnabled() const { return DynamicVGPR; }
979 unsigned getDynamicVGPRBlockSize() const {
980 return DynamicVGPRBlockSize32 ? 32 : 16;
981 }
982
984 // AMDGPU doesn't care if early-clobber and undef operands are allocated
985 // to the same register.
986 return false;
987 }
988
989 // DS_ATOMIC_ASYNC_BARRIER_ARRIVE_B64 shall not be claused with anything
990 // and surronded by S_WAIT_ALU(0xFFE3).
992 return getGeneration() == GFX12;
993 }
994
995 // Requires s_wait_alu(0) after s102/s103 write and src_flat_scratch_base
996 // read.
998 return HasGFX1250Insts && getGeneration() == GFX12;
999 }
1000
1001 // src_flat_scratch_hi cannot be used as a source in SALU producing a 64-bit
1002 // result.
1004 return HasGFX1250Insts && getGeneration() == GFX12;
1005 }
1006
1007 /// \returns true if the subtarget requires a wait for xcnt before VMEM
1008 /// accesses that must never be repeated in the event of a page fault/re-try.
1009 /// Atomic stores/rmw and all volatile accesses fall under this criteria.
1011 return HasGFX1250Insts;
1012 }
1013
1014 /// \returns the number of significant bits in the immediate field of the
1015 /// S_NOP instruction.
1016 unsigned getSNopBits() const {
1018 return 7;
1020 return 4;
1021 return 3;
1022 }
1023
1027
1029 return (getGeneration() <= AMDGPUSubtarget::GFX9 ||
1031 isWave32();
1032 }
1033
1034 /// Return true if real (non-fake) variants of True16 instructions using
1035 /// 16-bit registers should be code-generated. Fake True16 instructions are
1036 /// identical to non-fake ones except that they take 32-bit registers as
1037 /// operands and always use their low halves.
1038 // TODO: Remove and use hasTrue16BitInsts() instead once True16 is fully
1039 // supported and the support for fake True16 instructions is removed.
1040 bool useRealTrue16Insts() const {
1041 return hasTrue16BitInsts() && EnableRealTrue16Insts;
1042 }
1043
1044 bool requiresWaitOnWorkgroupReleaseFence(bool TgSplit) const {
1045 return getGeneration() >= GFX10 || TgSplit;
1046 }
1047};
1048
1050public:
1051 bool hasImplicitBufferPtr() const { return ImplicitBufferPtr; }
1052
1053 bool hasPrivateSegmentBuffer() const { return PrivateSegmentBuffer; }
1054
1055 bool hasDispatchPtr() const { return DispatchPtr; }
1056
1057 bool hasQueuePtr() const { return QueuePtr; }
1058
1059 bool hasKernargSegmentPtr() const { return KernargSegmentPtr; }
1060
1061 bool hasDispatchID() const { return DispatchID; }
1062
1063 bool hasFlatScratchInit() const { return FlatScratchInit; }
1064
1065 bool hasPrivateSegmentSize() const { return PrivateSegmentSize; }
1066
1067 unsigned getNumKernargPreloadSGPRs() const { return NumKernargPreloadSGPRs; }
1068
1069 unsigned getNumUsedUserSGPRs() const { return NumUsedUserSGPRs; }
1070
1071 unsigned getNumFreeUserSGPRs();
1072
1073 void allocKernargPreloadSGPRs(unsigned NumSGPRs);
1074
1085
1086 // Returns the size in number of SGPRs for preload user SGPR field.
1088 switch (ID) {
1090 return 2;
1092 return 4;
1093 case DispatchPtrID:
1094 return 2;
1095 case QueuePtrID:
1096 return 2;
1098 return 2;
1099 case DispatchIdID:
1100 return 2;
1101 case FlatScratchInitID:
1102 return 2;
1104 return 1;
1105 }
1106 llvm_unreachable("Unknown UserSGPRID.");
1107 }
1108
1109 GCNUserSGPRUsageInfo(const Function &F, const GCNSubtarget &ST);
1110
1111private:
1112 const GCNSubtarget &ST;
1113
1114 // Private memory buffer
1115 // Compute directly in sgpr[0:1]
1116 // Other shaders indirect 64-bits at sgpr[0:1]
1117 bool ImplicitBufferPtr = false;
1118
1119 bool PrivateSegmentBuffer = false;
1120
1121 bool DispatchPtr = false;
1122
1123 bool QueuePtr = false;
1124
1125 bool KernargSegmentPtr = false;
1126
1127 bool DispatchID = false;
1128
1129 bool FlatScratchInit = false;
1130
1131 bool PrivateSegmentSize = false;
1132
1133 unsigned NumKernargPreloadSGPRs = 0;
1134
1135 unsigned NumUsedUserSGPRs = 0;
1136};
1137
1138} // end namespace llvm
1139
1140#endif // LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< bool > EnableLoadStoreOpt("aarch64-enable-ldst-opt", cl::desc("Enable the load/store pair" " optimization pass"), cl::init(true), cl::Hidden)
This file describes how to lower LLVM calls to machine code calls.
This file declares the targeting of the RegisterBankInfo class for AMDGPU.
Base class for AMDGPU specific classes of TargetSubtarget.
static cl::opt< bool > SramEccSetting("amdgpu-sramecc", cl::desc("Force amdgpu.sramecc for testing"), cl::ReallyHidden)
static cl::opt< bool > XnackSetting("amdgpu-xnack", cl::desc("Force amdgpu.xnack value for testing"), cl::ReallyHidden)
AMDHSA kernel descriptor definitions.
static bool hasFeature(StringRef Feature, const FeatureBitset &FeatureBits, ArrayRef< SubtargetFeatureKV > ProcFeatures)
#define F(x, y, z)
Definition MD5.cpp:54
Promote Memory to Register
Definition Mem2Reg.cpp:110
SI DAG Lowering interface definition.
Interface definition for SIInstrInfo.
static cl::opt< unsigned > CacheLineSize("cache-line-size", cl::init(0), cl::Hidden, cl::desc("Use this to override the target cache line size when " "specified by the user."))
unsigned getWavefrontSizeLog2() const
AMDGPUSubtarget(const Triple &TT)
unsigned getMaxWavesPerEU() const
unsigned getWavefrontSize() const
bool hasPrefetch() const
bool hasFlat() const
bool hasD16Images() const
InstrItineraryData InstrItins
bool useVGPRIndexMode() const
bool dot2UnconditionalFlush() const
bool partialVCCWritesUpdateVCCZ() const
Writes to VCC_LO/VCC_HI update the VCCZ flag.
bool hasSwap() const
bool hasPkMinMax3Insts() const
bool hasD16LoadStore() const
bool hasMergedShaders() const
bool hasRrWGMode() const
bool hasScalarCompareEq64() const
int getLDSBankCount() const
bool hasOnlyRevVALUShifts() const
bool hasNonNSAEncoding() const
bool hasUsableDivScaleConditionOutput() const
Condition output from div_scale is usable.
bool hasExpertSchedulingMode() const
void mirFileLoaded(MachineFunction &MF) const override
bool hasUsableDSOffset() const
True if the offset field of DS instructions works as expected.
bool loadStoreOptEnabled() const
bool enableSubRegLiveness() const override
unsigned getSGPRAllocGranule() const
bool hasFlatLgkmVMemCountInOrder() const
bool flatScratchIsPointer() const
bool hasShift64HighRegBug() const
unsigned MaxPrivateElementSize
bool unsafeDSOffsetFoldingEnabled() const
bool hasFPAtomicToDenormModeHazard() const
unsigned getAddressableNumArchVGPRs() const
bool vmemWriteNeedsExpWaitcnt() const
bool shouldClusterStores() const
unsigned getMinNumSGPRs(unsigned WavesPerEU) const
bool hasUserSGPRInit16BugInWave32() const
unsigned getSGPREncodingGranule() const
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
bool hasFlatScratchHiInB64InstHazard() const
bool hasDstSelForwardingHazard() const
void setScalarizeGlobalBehavior(bool b)
bool hasFlatScratchEnabled() const
bool hasRelaxedBufferOOBMode() const
unsigned DataCacheLineSize
unsigned getSNopBits() const
bool hasLDSLoadB96_B128() const
Returns true if the target supports global_load_lds_dwordx3/global_load_lds_dwordx4 or buffer_load_dw...
bool hasMultiDwordFlatScratchAddressing() const
bool hasFmaakFmamkF64Insts() const
bool hasDsSwizzleRotateMode() const
bool hasHWFP64() const
bool hasScaleOffset() const
bool hasAnyPackedFP64Ops() const
bool hasDenormModeInst() const
bool hasCvtScaleForwardingHazard() const
unsigned getTotalNumVGPRs() const
unsigned getMinWavesPerEU() const override
bool hasUnalignedDSAccessEnabled() const
const SIInstrInfo * getInstrInfo() const override
unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override
unsigned getConstantBusLimit(unsigned Opcode) const
bool hasVALUMaskWriteHazard() const
bool hasCondSubInsts() const
const InlineAsmLowering * getInlineAsmLowering() const override
unsigned getTotalNumSGPRs() const
const InstrItineraryData * getInstrItineraryData() const override
void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx, SDep &Dep, const TargetSchedModel *SchedModel) const override
void overridePostRASchedPolicy(MachineSchedPolicy &Policy, const SchedRegion &Region) const override
unsigned getMaxLocalMemSizeWithWaveCount(unsigned WaveCount, const Function &) const
Return the amount of LDS that can be used that will not restrict the occupancy lower than WaveCount.
bool hasPkMovB32() const
bool needsAlignedVGPRs() const
Return if operations acting on VGPR tuples require even alignment.
Align getStackAlignment() const
bool privateMemoryResourceIsRangeChecked() const
bool hasScalarSubwordLoads() const
const bool BufferOOBRelaxed
bool hasMadF16() const
bool hasDsAtomicAsyncBarrierArriveB64PipeBug() const
unsigned getInstCacheLineSize() const
Instruction cache line size in bytes (64 for pre-GFX11, 128 for GFX11+).
bool hasLoopHeadInstSplitSensitivity() const
bool hasDwordx3LoadStores() const
bool hasSignedScratchOffsets() const
bool hasGlobalAddTidInsts() const
bool hasFlatScrRegister() const
bool hasGetPCZeroExtension() const
bool hasPermLane64() const
bool requiresNopBeforeDeallocVGPRs() const
unsigned getMinNumVGPRs(unsigned WavesPerEU, unsigned DynamicVGPRBlockSize) const
bool supportsGetDoorbellID() const
unsigned getMaxNumAGPRs(const Function &F) const
bool hasReadM0MovRelInterpHazard() const
bool isDynamicVGPREnabled() const
bool hasInstPrefSize() const
const SIRegisterInfo * getRegisterInfo() const override
bool hasDOTOpSelHazard() const
bool hasLdsWaitVMSRC() const
const TargetRegisterClass * getBoolRC() const
unsigned getBaseMaxNumVGPRs(const Function &F, std::pair< unsigned, unsigned > NumVGPRBounds) const
bool hasFmaakFmamkF32Insts() const
bool hasMad64_32() const
InstructionSelector * getInstructionSelector() const override
unsigned getVGPREncodingGranule() const
bool hasHardClauses() const
bool useDS128() const
bool hasExtendedWaitCounts() const
bool d16PreservesUnusedBits() const
bool hasInstPrefetch() const
bool hasAddPC64Inst() const
unsigned maxHardClauseLength() const
bool hasAnyPackedFP32Ops() const
bool isMesaGfxShader(const Function &F) const
bool hasExportInsts() const
bool hasVINTERPEncoding() const
const AMDGPURegisterBankInfo * getRegBankInfo() const override
bool hasLegacyGeometry() const
TrapHandlerAbi getTrapHandlerAbi() const
bool isCuModeEnabled() const
const SIFrameLowering * getFrameLowering() const override
bool hasDPPRowShare() const
bool zeroesHigh16BitsOfDest(unsigned Opcode) const
Returns if the result of this instruction with a 16-bit result returned in a 32-bit register implicit...
unsigned getBaseMaxNumSGPRs(const Function &F, std::pair< unsigned, unsigned > WavesPerEU, unsigned PreloadedSGPRs, unsigned ReservedNumSGPRs) const
unsigned getMaxNumPreloadedSGPRs() const
GCNSubtarget & initializeSubtargetDependencies(const Triple &TT, StringRef GPU, StringRef FS)
bool has12DWordStoreHazard() const
bool hasVALUPartialForwardingHazard() const
void overrideSchedPolicy(MachineSchedPolicy &Policy, const SchedRegion &Region) const override
bool useVGPRBlockOpsForCSR() const
std::pair< unsigned, unsigned > computeOccupancy(const Function &F, unsigned LDSSize=0, unsigned NumSGPRs=0, unsigned NumVGPRs=0) const
Subtarget's minimum/maximum occupancy, in number of waves per EU, that can be achieved when the only ...
bool requiresWaitOnWorkgroupReleaseFence(bool TgSplit) const
bool needsKernArgPreloadProlog() const
bool hasMin3Max3_16() const
unsigned getMaxNumVGPRs(unsigned WavesPerEU, unsigned DynamicVGPRBlockSize) const
unsigned getVGPRAllocGranule(unsigned DynamicVGPRBlockSize) const
AMDGPU::TargetID TargetID
unsigned getSetRegWaitStates() const
Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
const SITargetLowering * getTargetLowering() const override
bool hasTransForwardingHazard() const
bool enableMachineScheduler() const override
bool hasLDSFPAtomicAddF64() const
unsigned getNSAThreshold(const MachineFunction &MF) const
bool getScalarizeGlobalBehavior() const
bool hasPKF32InstsReplicatingLower32BitsOfScalarInput() const
bool hasReadM0LdsDmaHazard() const
bool hasScalarSMulU64() const
const AMDGPU::TargetID & getTargetID() const
unsigned getKnownHighZeroBitsForFrameIndex() const
Return the number of high bits known to be zero for a frame index.
bool hasScratchBaseForwardingHazard() const
GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS, const GCNTargetMachine &TM, bool BufferOOBRelaxed=false, bool TBufferOOBRelaxed=false, AMDGPU::TargetIDSetting XnackSetting=AMDGPU::TargetIDSetting::Any, AMDGPU::TargetIDSetting SramEccSetting=AMDGPU::TargetIDSetting::Any)
bool hasRelaxedTBufferOOBMode() const
bool hasScalarPackInsts() const
bool requiresDisjointEarlyClobberAndUndef() const override
bool hasVALUReadSGPRHazard() const
bool usePRTStrictNull() const
unsigned getAddressableNumVGPRs(unsigned DynamicVGPRBlockSize) const
bool supportsWaveWideBPermute() const
bool hasMed3_16() const
unsigned getReservedNumSGPRs(const MachineFunction &MF) const
bool hasUnalignedScratchAccessEnabled() const
bool hasNullExportTarget() const
Return true if the target's EXP instruction supports the NULL export target.
bool ldsRequiresM0Init() const
Return if most LDS instructions have an m0 use that require m0 to be initialized.
bool useRealTrue16Insts() const
Return true if real (non-fake) variants of True16 instructions using 16-bit registers should be code-...
const bool TBufferOOBRelaxed
bool useAA() const override
bool isWave32() const
bool isGFX11Plus() const
unsigned getOccupancyWithNumVGPRs(unsigned VGPRs, unsigned DynamicVGPRBlockSize) const
Return the maximum number of waves per SIMD for kernels using VGPRs VGPRs.
bool hasUnalignedBufferAccessEnabled() const
bool isWaveSizeKnown() const
Returns if the wavesize of this subtarget is known reliable.
unsigned getMaxPrivateElementSize(bool ForBufferRSrc=false) const
unsigned getMinFlatWorkGroupSize() const override
bool hasAsyncMark() const
bool hasSPackHL() const
Return true if the target has the S_PACK_HL_B32_B16 instruction.
bool supportsMinMaxDenormModes() const
bool supportsBPermute() const
bool hasFlatScratchSVSMode() const
unsigned InstCacheLineSize
bool hasAtomicFaddInsts() const
bool hasSubClampInsts() const
bool requiresWaitXCntForSingleAccessInstructions() const
unsigned getNSAMaxSize(bool HasSampler=false) const
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const
Return the maximum number of waves per SIMD for kernels using SGPRs SGPRs.
bool hasVOP3DPP() const
void getInstPrefSizeArgs(uint32_t &Mask, uint32_t &Shift, uint32_t &Width, uint32_t &CacheLineSize) const
unsigned getMaxFlatWorkGroupSize() const override
unsigned getMaxNumUserSGPRs() const
unsigned MaxHardClauseLength
The maximum number of instructions that may be placed within an S_CLAUSE, which is one greater than t...
bool hasFlatScratchSVSSwizzleBug() const
bool hasVDecCoExecHazard() const
bool hasSignedGVSOffset() const
bool hasLDSFPAtomicAddF32() const
unsigned getWavesPerEUForWorkGroup(unsigned FlatWorkGroupSize) const override
bool haveRoundOpsF64() const
Have v_trunc_f64, v_ceil_f64, v_rndne_f64.
bool hasDelayAlu() const
Return true if the target has the S_DELAY_ALU instruction.
unsigned getDataCacheLineSize() const
Data (VMEM) cache line size in bytes (128 for gfx12), has no use before GFX12.
bool hasReadM0SendMsgHazard() const
bool hasScalarMulHiInsts() const
bool hasSCmpK() const
bool hasVCvtPkIU16F32() const
Return true if the target has the V_CVT_PK_I16_F32/V_CVT_PK_U16_F32 instructions.
const LegalizerInfo * getLegalizerInfo() const override
bool requiresWaitIdleBeforeGetReg() const
bool hasDS96AndDS128() const
bool hasReadM0LdsDirectHazard() const
static bool hasHalfRate64Ops(const TargetSubtargetInfo &STI)
Generation getGeneration() const
unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const
std::pair< unsigned, unsigned > getMaxNumVectorRegs(const Function &F) const
Return a pair of maximum numbers of VGPRs and AGPRs that meet the number of waves per execution unit ...
bool isXNACKEnabled() const
bool hasScalarAddSub64() const
bool hasSplitBarriers() const
bool enableEarlyIfConversion() const override
bool hasSMRDReadVALUDefHazard() const
A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR was written by a VALU inst...
bool hasSGetShaderCyclesInst() const
bool hasINVWBL2WaitCntRequirement() const
bool hasRFEHazards() const
bool hasVMEMReadSGPRVALUDefHazard() const
A read of an SGPR by a VMEM instruction requires 5 wait states when the SGPR was written by a VALU In...
bool hasFlatScratchSTMode() const
unsigned getBaseReservedNumSGPRs(const bool HasFlatScratch) const
bool hasGWSSemaReleaseAll() const
bool hasAddr64() const
unsigned getAddressableNumSGPRs() const
bool hasReadVCCZBug() const
Extra wait hazard is needed in some cases before s_cbranch_vccnz/s_cbranch_vccz.
bool isWave64() const
unsigned getDynamicVGPRBlockSize() const
bool setRegModeNeedsVNOPs() const
bool hasFractBug() const
bool isPreciseMemoryEnabled() const
unsigned getMaxWaveScratchSize() const
bool hasLDSMisalignedBugInWGPMode() const
bool hasAnyPackedU64Ops() const
void checkSubtargetFeatures(const Function &F) const
Diagnose inconsistent subtarget features before attempting to codegen function F.
~GCNSubtarget() override
const SelectionDAGTargetInfo * getSelectionDAGInfo() const override
bool hasVOPD3() const
bool hasAtomicCSub() const
bool requiresCodeObjectV6() const
const CallLowering * getCallLowering() const override
bool hasLdsDirect() const
bool hasGWSAutoReplay() const
static unsigned getNumUserSGPRForField(UserSGPRID ID)
void allocKernargPreloadSGPRs(unsigned NumSGPRs)
bool hasPrivateSegmentBuffer() const
unsigned getNumKernargPreloadSGPRs() const
unsigned getNumUsedUserSGPRs() const
GCNUserSGPRUsageInfo(const Function &F, const GCNSubtarget &ST)
Itinerary data supplied by a subtarget to be used by a target.
Scheduling dependency.
Definition ScheduleDAG.h:52
const TargetRegisterClass * getBoolRC() const
Scheduling unit. This is a node in the scheduling DAG.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition StringRef.h:888
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Provide an instruction scheduling machine model to CodeGen passes.
TargetSubtargetInfo - Generic base class for all target subtargets.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Module flag names controlling out-of-bounds buffer access semantics.
constexpr StringLiteral BufferFlag("amdgpu.buffer.oob.mode")
constexpr StringLiteral TBufferFlag("amdgpu.tbuffer.oob.mode")
unsigned getAddressableNumArchVGPRs(const MCSubtargetInfo &STI)
unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo &STI)
unsigned getVGPREncodingGranule(const MCSubtargetInfo &STI, std::optional< bool > EnableWavefrontSize32)
unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getMinNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU)
unsigned getMaxNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, bool Addressable)
unsigned getWavesPerEUForWorkGroup(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
constexpr unsigned getMaxFlatWorkGroupSize()
unsigned getSGPREncodingGranule(const MCSubtargetInfo &STI)
unsigned getTotalNumVGPRs(const MCSubtargetInfo &STI)
unsigned getMinNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getAddressableNumVGPRs(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize)
unsigned getMaxNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getVGPRAllocGranule(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getMinWavesPerEU(const MCSubtargetInfo &STI)
LLVM_READNONE constexpr bool isShader(CallingConv::ID CC)
unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI)
unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler)
LLVM_ABI unsigned getAddressableNumSGPRs(GPUKind AK)
LLVM_ABI unsigned getTotalNumSGPRs(GPUKind AK)
LLVM_ABI unsigned getSGPRAllocGranule(GPUKind AK)
This is an optimization pass for GlobalISel generic memory operations.
int countl_zero(T Val)
Count number of 0's from the most significant bit to the least stopping at the first 1.
Definition bit.h:263
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Define a generic scheduling policy for targets that don't provide their own MachineSchedStrategy.
A region of an MBB for scheduling.