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