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 const bool BufferOOBRelaxed;
94
95 /// The maximum number of instructions that may be placed within an S_CLAUSE,
96 /// which is one greater than the maximum argument to S_CLAUSE. A value of 0
97 /// indicates a lack of S_CLAUSE support.
98 unsigned MaxHardClauseLength = 0;
99
100#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
101 bool ATTRIBUTE = DEFAULT;
102#include "AMDGPUGenSubtargetInfo.inc"
103
104private:
105 SIInstrInfo InstrInfo;
106 SITargetLowering TLInfo;
107 SIFrameLowering FrameLowering;
108
109 /// Get the register that represents the actual dependency between the
110 /// definition and the use. The definition might only affect a subregister
111 /// that is not actually used. Works for both virtual and physical registers.
112 /// Note: Currently supports VOP3P instructions (without WMMA an SWMMAC).
113 /// Returns the definition register if there is a real dependency and no
114 /// better match is found.
115 Register getRealSchedDependency(const MachineInstr &DefI, int DefOpIdx,
116 const MachineInstr &UseI, int UseOpIdx) const;
117
118public:
120 const Triple &TT, StringRef GPU, StringRef FS, const GCNTargetMachine &TM,
121 bool BufferOOBRelaxed = false, bool TBufferOOBRelaxed = false,
122 AMDGPU::TargetIDSetting XnackSetting = AMDGPU::TargetIDSetting::Any,
123 AMDGPU::TargetIDSetting SramEccSetting = AMDGPU::TargetIDSetting::Any);
124 ~GCNSubtarget() override;
125
128 AMDGPU::TargetIDSetting XnackSetting,
129 AMDGPU::TargetIDSetting SramEccSetting);
130
131 /// Diagnose inconsistent subtarget features before attempting to codegen
132 /// function \p F.
133 void checkSubtargetFeatures(const Function &F) const;
134
135 const SIInstrInfo *getInstrInfo() const override { return &InstrInfo; }
136
137 const SIFrameLowering *getFrameLowering() const override {
138 return &FrameLowering;
139 }
140
141 const SITargetLowering *getTargetLowering() const override { return &TLInfo; }
142
143 const SIRegisterInfo *getRegisterInfo() const override {
144 return &InstrInfo.getRegisterInfo();
145 }
146
147 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
148
149 const CallLowering *getCallLowering() const override {
150 return CallLoweringInfo.get();
151 }
152
153 const InlineAsmLowering *getInlineAsmLowering() const override {
154 return InlineAsmLoweringInfo.get();
155 }
156
158 return InstSelector.get();
159 }
160
161 const LegalizerInfo *getLegalizerInfo() const override {
162 return Legalizer.get();
163 }
164
165 const AMDGPURegisterBankInfo *getRegBankInfo() const override {
166 return RegBankInfo.get();
167 }
168
169 const AMDGPU::TargetID &getTargetID() const { return TargetID; }
170
172 return &InstrItins;
173 }
174
176
178
179 bool isGFX11Plus() const { return getGeneration() >= GFX11; }
180
181#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \
182 bool GETTER() const override { return ATTRIBUTE; }
183#include "AMDGPUGenSubtargetInfo.inc"
184
185 unsigned getMaxWaveScratchSize() const {
186 // See COMPUTE_TMPRING_SIZE.WAVESIZE.
187 if (getGeneration() >= GFX12) {
188 // 18-bit field in units of 64-dword.
189 return (64 * 4) * ((1 << 18) - 1);
190 }
191 if (getGeneration() == GFX11) {
192 // 15-bit field in units of 64-dword.
193 return (64 * 4) * ((1 << 15) - 1);
194 }
195 // 13-bit field in units of 256-dword.
196 return (256 * 4) * ((1 << 13) - 1);
197 }
198
199 /// Return the number of high bits known to be zero for a frame index.
203
204 int getLDSBankCount() const { return LDSBankCount; }
205
206 /// Instruction cache line size in bytes (64 for pre-GFX11, 128 for GFX11+).
207 unsigned getInstCacheLineSize() const { return InstCacheLineSize; }
208
209 /// Data (VMEM) cache line size in bytes (128 for gfx12), has no use before
210 /// GFX12.
211 unsigned getDataCacheLineSize() const { return DataCacheLineSize; }
212
213 unsigned getMaxPrivateElementSize(bool ForBufferRSrc = false) const {
214 return (ForBufferRSrc || !hasFlatScratchEnabled()) ? MaxPrivateElementSize
215 : 16;
216 }
217
218 unsigned getConstantBusLimit(unsigned Opcode) const;
219
220 /// Returns if the result of this instruction with a 16-bit result returned in
221 /// a 32-bit register implicitly zeroes the high 16-bits, rather than preserve
222 /// the original value.
223 bool zeroesHigh16BitsOfDest(unsigned Opcode) const;
224
225 bool hasAddr64() const {
227 }
228
229 bool hasFlat() const {
231 }
232
233 // Return true if the target only has the reverse operand versions of VALU
234 // shift instructions (e.g. v_lshrrev_b32, and no v_lshr_b32).
235 bool hasOnlyRevVALUShifts() const {
237 }
238
239 bool hasFractBug() const { return getGeneration() == SOUTHERN_ISLANDS; }
240
241 bool hasMed3_16() const { return getGeneration() >= AMDGPUSubtarget::GFX9; }
242
243 bool hasMin3Max3_16() const {
245 }
246
247 bool hasSwap() const { return HasGFX9Insts; }
248
249 bool hasScalarPackInsts() const { return HasGFX9Insts; }
250
251 bool hasScalarMulHiInsts() const { return HasGFX9Insts; }
252
253 bool hasScalarSubwordLoads() const { return getGeneration() >= GFX12; }
254
255 bool hasAsyncMark() const { return hasVMemToLDSLoad() || HasAsynccnt; }
256
260
262 // The S_GETREG DOORBELL_ID is supported by all GFX9 onward targets.
263 return getGeneration() >= GFX9;
264 }
265
266 /// True if the offset field of DS instructions works as expected. On SI, the
267 /// offset uses a 16-bit adder and does not always wrap properly.
268 bool hasUsableDSOffset() const { return getGeneration() >= SEA_ISLANDS; }
269
271 return EnableUnsafeDSOffsetFolding;
272 }
273
274 /// Condition output from div_scale is usable.
278
279 /// Extra wait hazard is needed in some cases before
280 /// s_cbranch_vccnz/s_cbranch_vccz.
281 bool hasReadVCCZBug() const { return getGeneration() <= SEA_ISLANDS; }
282
283 /// Writes to VCC_LO/VCC_HI update the VCCZ flag.
284 bool partialVCCWritesUpdateVCCZ() const { return getGeneration() >= GFX10; }
285
286 /// A read of an SGPR by SMRD instruction requires 4 wait states when the SGPR
287 /// was written by a VALU instruction.
290 }
291
292 /// A read of an SGPR by a VMEM instruction requires 5 wait states when the
293 /// SGPR was written by a VALU Instruction.
296 }
297
298 bool hasRFEHazards() const { return getGeneration() >= VOLCANIC_ISLANDS; }
299
300 /// Number of hazard wait states for s_setreg_b32/s_setreg_imm32_b32.
301 unsigned getSetRegWaitStates() const {
302 return getGeneration() <= SEA_ISLANDS ? 1 : 2;
303 }
304
307 }
308
309 /// \returns If target supports S_DENORM_MODE.
310 bool hasDenormModeInst() const {
312 }
313
314 /// \returns If target supports ds_read/write_b128 and user enables generation
315 /// of ds_read/write_b128.
316 bool useDS128() const { return HasCIInsts && EnableDS128; }
317
318 /// \return If target supports ds_read/write_b96/128.
319 bool hasDS96AndDS128() const { return HasCIInsts; }
320
321 /// Have v_trunc_f64, v_ceil_f64, v_rndne_f64
322 bool haveRoundOpsF64() const { return HasCIInsts; }
323
324 /// \returns If MUBUF instructions always perform range checking, even for
325 /// buffer resources used for private memory access.
329
330 /// \returns If target requires PRT Struct NULL support (zero result registers
331 /// for sparse texture support).
332 bool usePRTStrictNull() const { return EnablePRTStrictNull; }
333
335 return HasUnalignedBufferAccess && HasUnalignedAccessMode;
336 }
337
339 return HasUnalignedDSAccess && HasUnalignedAccessMode;
340 }
341
343 return HasUnalignedScratchAccess && HasUnalignedAccessMode;
344 }
345
346 bool isXNACKEnabled() const { return TargetID.isXnackOnOrAny(); }
347
350
351 /// Return the maximum allowed load/store width for the given type and
352 /// alignment combination based on subtarget flags.
353 /// 1. If unaligned accesses are not enabled, then any load/store that is less
354 /// than word-aligned has to be handled one byte or ushort at a time.
355 /// 2. If relaxed OOB mode is not set, we must ensure that the in-bounds
356 /// part of a partially out of bounds read/write is performed correctly. This
357 /// means that any load that isn't naturally aligned has to be split into
358 /// parts that are naturally aligned, so that, after bitcasting, we don't have
359 /// unaligned loads that could discard valid data.
360 ///
361 /// For example, if we're loading a <8 x i8>, that's actually a load of a <2 x
362 /// i32>, and if we load from an align(2) address, that address might be 2
363 /// bytes from the end of the buffer. The hardware will, when performing the
364 /// <2 x i32> load, mask off the entire first word, causing the two in-bounds
365 /// bytes to be masked off. However, if we know the offset can't be too close
366 /// to the number of records in the buffer (if known), we can skip this
367 /// expansion.
368 ///
369 /// Unlike the complete disablement of unaligned accesses from point 1,
370 /// this does not apply to unaligned scalars, but will apply to cases like
371 /// `load <2 x i32>, align 4` since the left element might be out of bounds.
372 /// Note that if we know that the base offset is known to be
373 /// less than `uint32_max - byte_size(Ty)`, we can skip these alignment
374 /// checks.
376 bool NoWrapFromMax,
377 bool NoPartialOOB) const;
378
379 /// Return the width, in bits, of the num_records field of a buffer resource
380 /// (V#) on this subtarget, or std::nullopt if not yet known.
381 std::optional<unsigned> getBufferResourceNumRecordsWidth() const {
383 return std::nullopt;
385 }
386
387 bool isCuModeEnabled() const { return EnableCuMode; }
388
389 /// \returns Whether a work-group runs on all of the block's SIMDs.
390 bool isFullSIMDMode() const {
391 return (HasGFX1250Insts && getGeneration() < GFX13) || !EnableCuMode;
392 }
393
394 bool isPreciseMemoryEnabled() const { return EnablePreciseMemory; }
395
396 bool hasFlatScrRegister() const { return hasFlatAddressSpace(); }
397
398 // Check if target supports ST addressing mode with FLAT scratch instructions.
399 // The ST addressing mode means no registers are used, either VGPR or SGPR,
400 // but only immediate offset is swizzled and added to the FLAT scratch base.
401 bool hasFlatScratchSTMode() const {
402 return hasFlatScratchInsts() && (hasGFX10_3Insts() || hasGFX940Insts());
403 }
404
405 bool hasFlatScratchSVSMode() const { return HasGFX940Insts || HasGFX11Insts; }
406
408 return hasArchitectedFlatScratch() ||
409 (EnableFlatScratch && hasFlatScratchInsts());
410 }
411
412 bool hasExportInsts() const {
413 return !hasGFX940Insts() && !hasGFX1250Insts();
414 }
415
416 bool hasVINTERPEncoding() const {
417 return HasGFX11Insts && !hasGFX1250Insts();
418 }
419
421 return getGeneration() >= GFX9;
422 }
423
424 bool hasFlatLgkmVMemCountInOrder() const { return getGeneration() > GFX9; }
425
426 bool hasD16LoadStore() const { return getGeneration() >= GFX9; }
427
429 return hasD16LoadStore() && !TargetID.isSramEccOnOrAny();
430 }
431
432 bool hasD16Images() const { return getGeneration() >= VOLCANIC_ISLANDS; }
433
434 /// Return if most LDS instructions have an m0 use that require m0 to be
435 /// initialized.
436 bool ldsRequiresM0Init() const { return getGeneration() < GFX9; }
437
438 // True if the hardware rewinds and replays GWS operations if a wave is
439 // preempted.
440 //
441 // If this is false, a GWS operation requires testing if a nack set the
442 // MEM_VIOL bit, and repeating if so.
443 bool hasGWSAutoReplay() const { return getGeneration() >= GFX9; }
444
445 /// \returns if target has ds_gws_sema_release_all instruction.
446 bool hasGWSSemaReleaseAll() const { return HasCIInsts; }
447
448 bool hasScalarAddSub64() const { return getGeneration() >= GFX12; }
449
450 bool hasScalarSMulU64() const { return getGeneration() >= GFX12; }
451
452 // Covers VS/PS/CS graphics shaders
453 bool isMesaGfxShader(const Function &F) const {
454 return isMesa3DOS() && AMDGPU::isShader(F.getCallingConv());
455 }
456
457 bool hasMad64_32() const { return getGeneration() >= SEA_ISLANDS; }
458
459 bool hasAtomicFaddInsts() const {
460 return HasAtomicFaddRtnInsts || HasAtomicFaddNoRtnInsts;
461 }
462
464 return getGeneration() < SEA_ISLANDS;
465 }
466
467 bool hasInstPrefetch() const {
468 return getGeneration() == GFX10 || getGeneration() == GFX11;
469 }
470
471 bool hasPrefetch() const { return HasGFX12Insts; }
472
473 bool hasInstPrefSize() const { return isGFX11Plus(); }
474
475 void getInstPrefSizeArgs(uint32_t &Mask, uint32_t &Shift, uint32_t &Width,
476 uint32_t &CacheLineSize) const {
479 if (getGeneration() == GFX11) {
480 Mask = amdhsa::COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE;
481 Shift = amdhsa::COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE_SHIFT;
482 Width = amdhsa::COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE_WIDTH;
483 } else {
484 Mask = amdhsa::COMPUTE_PGM_RSRC3_GFX12_PLUS_INST_PREF_SIZE;
485 Shift = amdhsa::COMPUTE_PGM_RSRC3_GFX12_PLUS_INST_PREF_SIZE_SHIFT;
486 Width = amdhsa::COMPUTE_PGM_RSRC3_GFX12_PLUS_INST_PREF_SIZE_WIDTH;
487 }
488 }
489
490 // Has s_cmpk_* instructions.
491 bool hasSCmpK() const { return getGeneration() < GFX12; }
492
493 // Scratch is allocated in 256 dword per wave blocks for the entire
494 // wavefront. When viewed from the perspective of an arbitrary workitem, this
495 // is 4-byte aligned.
496 //
497 // Only 4-byte alignment is really needed to access anything. Transformations
498 // on the pointer value itself may rely on the alignment / known low bits of
499 // the pointer. Set this to something above the minimum to avoid needing
500 // dynamic realignment in common cases.
501 Align getStackAlignment() const { return Align(16); }
502
503 bool enableMachineScheduler() const override { return true; }
504
505 bool enableSSAMachineScheduler() const override { return true; }
506
507 bool useAA() const override;
508
509 bool enableSubRegLiveness() const override { return true; }
510
511 // canReassign() walks the whole allocation order of the evictee on every
512 // local eviction query, which is expensive with a very large VGPR file.
513 bool enableRALocalReassignment(CodeGenOptLevel OptLevel) const override {
514 return !hasVGPRMSBs();
515 }
516
517 // XXX - Why is this here if it isn't in the default pass set?
518 bool enableEarlyIfConversion() const override { return true; }
519
521 const SchedRegion &Region) const override;
522
524 const SchedRegion &Region) const override;
525
526 void overridePipelinerPolicy(MachinePipelinerPolicy &Policy) const override;
527
528 void mirFileLoaded(MachineFunction &MF) const override;
529
530 unsigned getMaxNumUserSGPRs() const {
531 return AMDGPU::getMaxNumUserSGPRs(*this);
532 }
533
534 bool useVGPRIndexMode() const;
535
536 bool hasScalarCompareEq64() const {
538 }
539
540 bool hasLDSFPAtomicAddF32() const { return HasGFX8Insts; }
541
542 /// \returns true if the subtarget has the v_permlane64_b32 instruction.
543 bool hasPermLane64() const { return getGeneration() >= GFX11; }
544
545 /// \returns true if the subtarget supports the ds_swizzle rotate and FFT
546 /// swizzle modes (GFX9+).
547 bool hasDsSwizzleRotateMode() const { return getGeneration() >= GFX9; }
548
549 bool hasDPPRowShare() const {
550 return HasDPP && (HasGFX90AInsts || getGeneration() >= GFX10);
551 }
552
553 // Has V_PK_MOV_B32 opcode
554 bool hasPkMovB32() const { return HasGFX90AInsts; }
555
556 bool hasBufferTFEFormatD16() const { return !HasGFX90AInsts; }
557
559 return getGeneration() >= GFX10 || hasGFX940Insts();
560 }
561
562 bool hasFmaakFmamkF64Insts() const { return hasGFX1250Insts(); }
563
564 bool hasNonNSAEncoding() const { return getGeneration() < GFX12; }
565
566 unsigned getNSAMaxSize(bool HasSampler = false) const {
567 return AMDGPU::getNSAMaxSize(*this, HasSampler);
568 }
569
570 bool hasMadF16() const;
571
572 // FLAT GLOBAL VOffset is signed
573 bool hasSignedGVSOffset() const { return HasGFX1250Insts; }
574
575 bool loadStoreOptEnabled() const { return EnableLoadStoreOpt; }
576
578 return HasUserSGPRInit16Bug && isWave32();
579 }
580
584
585 // \returns true if the subtarget supports DWORDX3 load/store instructions.
586 bool hasDwordx3LoadStores() const { return HasCIInsts; }
587
591
596
599 }
600
603 }
604
606 return HasLDSMisalignedBug && !EnableCuMode;
607 }
608
609 // Shift amount of a 64 bit shift cannot be a highest allocated register
610 // if also at the end of the allocation block.
611 bool hasShift64HighRegBug() const { return HasGFX90AInsts; }
612
613 // v_dot2c_f32_f16 unconditionally flushes f16 subnormal inputs to zero
614 // regardless of the MODE register, unlike v_fma_mix_f32 which respects it.
616 return HasGFX90AInsts && !HasGFX940Insts;
617 }
618
619 // Has one cycle hazard on transcendental instruction feeding a
620 // non transcendental VALU.
621 bool hasTransForwardingHazard() const { return HasGFX940Insts; }
622
623 // Has one cycle hazard on a VALU instruction partially writing dst with
624 // a shift of result bits feeding another VALU instruction.
625 bool hasDstSelForwardingHazard() const { return HasGFX940Insts; }
626
627 // Cannot use op_sel with v_dot instructions.
628 bool hasDOTOpSelHazard() const { return HasGFX940Insts || HasGFX11Insts; }
629
630 // Does not have HW interlocs for VALU writing and then reading SGPRs.
631 bool hasVDecCoExecHazard() const { return HasGFX940Insts; }
632
633 bool hasHardClauses() const { return MaxHardClauseLength > 0; }
634
636 return getGeneration() == GFX10;
637 }
638
639 bool hasVOP3DPP() const { return getGeneration() >= GFX11; }
640
641 bool hasLdsDirect() const { return getGeneration() >= GFX11; }
642
643 bool hasLdsWaitVMSRC() const { return getGeneration() >= GFX12; }
644
646 return getGeneration() == GFX11;
647 }
648
649 bool hasPkF32InvalidOpSel() const { return HasGFX950Insts; }
650
651 bool hasCvtScaleForwardingHazard() const { return HasGFX950Insts; }
652
653 bool hasPermlaneForwardingHazard() const { return HasGFX950Insts; }
654
655 // All GFX9 targets experience a fetch delay when an instruction at the start
656 // of a loop header is split by a 32-byte fetch window boundary, but GFX950
657 // is uniquely sensitive to this: the delay triggers further performance
658 // degradation beyond the fetch latency itself.
659 bool hasLoopHeadInstSplitSensitivity() const { return HasGFX950Insts; }
660
661 bool requiresCodeObjectV6() const { return RequiresCOV6; }
662
663 bool useVGPRBlockOpsForCSR() const { return UseBlockVGPROpsForCSR; }
664
665 bool hasVALUMaskWriteHazard() const { return getGeneration() == GFX11; }
666
668 return HasGFX12Insts && !HasGFX1250Insts;
669 }
670
671 bool setRegModeNeedsVNOPs() const {
672 return HasGFX1250Insts && getGeneration() == GFX12;
673 }
674
675 /// Return if operations acting on VGPR tuples require even alignment.
676 bool needsAlignedVGPRs() const { return RequiresAlignVGPR; }
677
678 /// Return true if the target has the S_PACK_HL_B32_B16 instruction.
679 bool hasSPackHL() const { return HasGFX11Insts; }
680
681 /// Return true if the target has the V_CVT_PK_I16_F32/V_CVT_PK_U16_F32
682 /// instructions.
683 bool hasVCvtPkIU16F32() const { return HasGFX11Insts; }
684
685 /// Return true if the target's EXP instruction supports the NULL export
686 /// target.
687 bool hasNullExportTarget() const { return !HasGFX11Insts; }
688
689 bool hasFlatScratchSVSSwizzleBug() const { return getGeneration() == GFX11; }
690
691 /// Return true if the target has the S_DELAY_ALU instruction.
692 bool hasDelayAlu() const { return HasGFX11Insts; }
693
694 /// Returns true if the target supports
695 /// global_load_lds_dwordx3/global_load_lds_dwordx4 or
696 /// buffer_load_dwordx3/buffer_load_dwordx4 with the lds bit.
697 bool hasLDSLoadB96_B128() const { return hasGFX950Insts(); }
698
699 /// \returns true if the target uses LOADcnt/SAMPLEcnt/BVHcnt, DScnt/KMcnt
700 /// and STOREcnt rather than VMcnt, LGKMcnt and VScnt respectively.
701 bool hasExtendedWaitCounts() const { return getGeneration() >= GFX12; }
702
703 /// \returns true if the target has packed f32 instructions that only read 32
704 /// bits from a scalar operand (SGPR or literal) and replicates the bits to
705 /// both channels.
707 return getGeneration() == GFX12 && HasGFX1250Insts;
708 }
709
710 bool useAddPCI64Inst() const {
711 return hasSAddPCI64Inst() && !hasUnusableSAddPCI64();
712 }
713
714 /// \returns true if the target supports expert scheduling mode 2 which relies
715 /// on the compiler to insert waits to avoid hazards between VMEM and VALU
716 /// instructions in some instances.
717 bool hasExpertSchedulingMode() const { return getGeneration() >= GFX12; }
718
719 /// \returns The maximum number of instructions that can be enclosed in an
720 /// S_CLAUSE on the given subtarget, or 0 for targets that do not support that
721 /// instruction.
722 unsigned maxHardClauseLength() const { return MaxHardClauseLength; }
723
724 /// Return the maximum number of waves per SIMD for kernels using \p SGPRs
725 /// SGPRs
726 unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
727
728 /// Return the maximum number of waves per SIMD for kernels using \p VGPRs
729 /// VGPRs
730 unsigned getOccupancyWithNumVGPRs(unsigned VGPRs,
731 unsigned DynamicVGPRBlockSize) const;
732
733 /// Subtarget's minimum/maximum occupancy, in number of waves per EU, that can
734 /// be achieved when the only function running on a CU is \p F, each workgroup
735 /// uses \p LDSSize bytes of LDS, and each wave uses \p NumSGPRs SGPRs and \p
736 /// NumVGPRs VGPRs. The flat workgroup sizes associated to the function are a
737 /// range, so this returns a range as well.
738 ///
739 /// Note that occupancy can be affected by the scratch allocation as well, but
740 /// we do not have enough information to compute it.
741 std::pair<unsigned, unsigned> computeOccupancy(const Function &F,
742 unsigned LDSSize = 0,
743 unsigned NumSGPRs = 0,
744 unsigned NumVGPRs = 0) const;
745
746 /// \returns true if the flat_scratch register should be initialized with the
747 /// pointer to the wave's scratch memory rather than a size and offset.
748 bool flatScratchIsPointer() const {
750 }
751
752 /// \returns true if the machine has merged shaders in which s0-s7 are
753 /// reserved by the hardware and user SGPRs start at s8
754 bool hasMergedShaders() const { return getGeneration() >= GFX9; }
755
756 // \returns true if the target supports the pre-NGG legacy geometry path.
757 bool hasLegacyGeometry() const { return getGeneration() < GFX11; }
758
759 // \returns true if the target has split barriers feature
760 bool hasSplitBarriers() const { return getGeneration() >= GFX12; }
761
762 // \returns true if the target has WG_RR_MODE kernel descriptor mode bit
763 bool hasRrWGMode() const { return getGeneration() >= GFX12; }
764
765 /// \returns true if VADDR and SADDR fields in VSCRATCH can use negative
766 /// values.
767 bool hasSignedScratchOffsets() const { return getGeneration() >= GFX12; }
768
769 bool hasINVWBL2WaitCntRequirement() const { return HasGFX1250Insts; }
770
771 bool hasVOPD3() const { return HasGFX1250Insts; }
772
773 // \returns true if the target has V_PK_{MIN|MAX}3_{I|U}16 instructions.
774 bool hasPkMinMax3Insts() const { return HasGFX1250Insts; }
775
776 // \returns ture if target has S_GET_SHADER_CYCLES_U64 instruction.
777 bool hasSGetShaderCyclesInst() const { return HasGFX1250Insts; }
778
779 // \returns true if S_GETPC_B64 zero-extends the result from 48 bits instead
780 // of sign-extending. Note that GFX1250 has not only fixed the bug but also
781 // extended VA to 57 bits.
783 return HasGFX12Insts && !HasGFX1250Insts;
784 }
785
786 // \returns true if the target needs to create a prolog for backward
787 // compatibility when preloading kernel arguments.
789 return hasKernargPreload() && !HasGFX1250Insts;
790 }
791
792 bool hasCondSubInsts() const { return HasGFX12Insts; }
793
794 bool hasSubClampInsts() const { return hasGFX10_3Insts(); }
795
796 bool hasAnyBVHInsts() const {
797 return hasBVHRayTracingInsts() || hasBVHDualAndBVH8Insts();
798 }
799
800 bool hasAnyPackedFP32Ops() const {
801 return hasPackedFP32Ops() || hasPackedFP32SingleSGPROps();
802 };
803
804 bool hasAnyPackedFP64Ops() const { return hasPackedFP64SingleSGPROps(); };
805
806 bool hasAnyPackedU64Ops() const { return hasPackedU64SingleSGPROps(); };
807
808 /// \returns SGPR allocation granularity supported by the subtarget.
809 unsigned getSGPRAllocGranule() const {
810 return AMDGPU::getSGPRAllocGranule(getTargetID().getGPUKind());
811 }
812
813 /// \returns SGPR encoding granularity supported by the subtarget.
814 unsigned getSGPREncodingGranule() const {
816 }
817
818 /// \returns Total number of SGPRs supported by the subtarget.
819 unsigned getTotalNumSGPRs() const {
820 return AMDGPU::getTotalNumSGPRs(getTargetID().getGPUKind());
821 }
822
823 /// \returns Addressable number of SGPRs supported by the subtarget.
824 unsigned getAddressableNumSGPRs() const {
825 return AMDGPU::getAddressableNumSGPRs(getTargetID().getGPUKind());
826 }
827
828 /// \returns Minimum number of SGPRs that meets the given number of waves per
829 /// execution unit requirement supported by the subtarget.
830 unsigned getMinNumSGPRs(unsigned WavesPerEU) const {
831 return AMDGPU::IsaInfo::getMinNumSGPRs(*this, WavesPerEU);
832 }
833
834 /// \returns Maximum number of SGPRs that meets the given number of waves per
835 /// execution unit requirement supported by the subtarget.
836 unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const {
837 return AMDGPU::IsaInfo::getMaxNumSGPRs(*this, WavesPerEU, Addressable);
838 }
839
840 /// \returns Reserved number of SGPRs. This is common
841 /// utility function called by MachineFunction and
842 /// Function variants of getReservedNumSGPRs.
843 unsigned getBaseReservedNumSGPRs(const bool HasFlatScratch) const;
844 /// \returns Reserved number of SGPRs for given machine function \p MF.
845 unsigned getReservedNumSGPRs(const MachineFunction &MF) const;
846
847 /// \returns Reserved number of SGPRs for given function \p F.
848 unsigned getReservedNumSGPRs(const Function &F) const;
849
850 /// \returns Maximum number of preloaded SGPRs for the subtarget.
851 unsigned getMaxNumPreloadedSGPRs() const;
852
853 /// \returns max num SGPRs. This is the common utility
854 /// function called by MachineFunction and Function
855 /// variants of getMaxNumSGPRs.
856 unsigned getBaseMaxNumSGPRs(const Function &F,
857 std::pair<unsigned, unsigned> WavesPerEU,
858 unsigned PreloadedSGPRs,
859 unsigned ReservedNumSGPRs) const;
860
861 /// \returns Maximum number of SGPRs that meets number of waves per execution
862 /// unit requirement for function \p MF, or number of SGPRs explicitly
863 /// requested using "amdgpu-num-sgpr" attribute attached to function \p MF.
864 ///
865 /// \returns Value that meets number of waves per execution unit requirement
866 /// if explicitly requested value cannot be converted to integer, violates
867 /// subtarget's specifications, or does not meet number of waves per execution
868 /// unit requirement.
869 unsigned getMaxNumSGPRs(const MachineFunction &MF) const;
870
871 /// \returns Maximum number of SGPRs that meets number of waves per execution
872 /// unit requirement for function \p F, or number of SGPRs explicitly
873 /// requested using "amdgpu-num-sgpr" attribute attached to function \p F.
874 ///
875 /// \returns Value that meets number of waves per execution unit requirement
876 /// if explicitly requested value cannot be converted to integer, violates
877 /// subtarget's specifications, or does not meet number of waves per execution
878 /// unit requirement.
879 unsigned getMaxNumSGPRs(const Function &F) const;
880
881 /// \returns VGPR allocation granularity supported by the subtarget.
882 unsigned getVGPRAllocGranule(unsigned DynamicVGPRBlockSize) const {
883 return AMDGPU::IsaInfo::getVGPRAllocGranule(*this, DynamicVGPRBlockSize);
884 }
885
886 /// \returns VGPR encoding granularity supported by the subtarget.
887 unsigned getVGPREncodingGranule() const {
889 }
890
891 /// \returns Total number of VGPRs supported by the subtarget.
892 unsigned getTotalNumVGPRs() const {
893 return AMDGPU::getTotalNumVGPRs(getTargetID().getGPUKind(), isWave32());
894 }
895
896 /// \returns Addressable number of architectural VGPRs supported by the
897 /// subtarget.
901
902 /// \returns Addressable number of VGPRs supported by the subtarget.
903 unsigned getAddressableNumVGPRs(unsigned DynamicVGPRBlockSize) const {
904 // Dynamic VGPR mode is a per-kernel mode, so it is not covered by the
905 // TargetParser query.
906 if (DynamicVGPRBlockSize != 0) {
908 DynamicVGPRBlockSize);
909 }
910 return AMDGPU::getAddressableNumVGPRs(getTargetID().getGPUKind(),
911 isWave32());
912 }
913
914 /// \returns the minimum number of VGPRs that will prevent achieving more than
915 /// the specified number of waves \p WavesPerEU.
916 unsigned getMinNumVGPRs(unsigned WavesPerEU,
917 unsigned DynamicVGPRBlockSize) const {
918 return AMDGPU::IsaInfo::getMinNumVGPRs(*this, WavesPerEU,
919 DynamicVGPRBlockSize);
920 }
921
922 /// \returns the maximum number of VGPRs that can be used and still achieved
923 /// at least the specified number of waves \p WavesPerEU.
924 unsigned getMaxNumVGPRs(unsigned WavesPerEU,
925 unsigned DynamicVGPRBlockSize) const {
926 return AMDGPU::IsaInfo::getMaxNumVGPRs(*this, WavesPerEU,
927 DynamicVGPRBlockSize);
928 }
929
930 /// \returns max num VGPRs. This is the common utility function
931 /// called by MachineFunction and Function variants of getMaxNumVGPRs.
932 unsigned
934 std::pair<unsigned, unsigned> NumVGPRBounds) const;
935
936 /// \returns Maximum number of VGPRs that meets number of waves per execution
937 /// unit requirement for function \p F, or number of VGPRs explicitly
938 /// requested using "amdgpu-num-vgpr" attribute attached to function \p F.
939 ///
940 /// \returns Value that meets number of waves per execution unit requirement
941 /// if explicitly requested value cannot be converted to integer, violates
942 /// subtarget's specifications, or does not meet number of waves per execution
943 /// unit requirement.
944 unsigned getMaxNumVGPRs(const Function &F) const;
945
946 /// Return a pair of maximum numbers of VGPRs and AGPRs that meet the number
947 /// of waves per execution unit required for the function \p MF.
948 std::pair<unsigned, unsigned> getMaxNumVectorRegs(const Function &F) const;
949
950 /// \returns Maximum number of VGPRs that meets number of waves per execution
951 /// unit requirement for function \p MF, or number of VGPRs explicitly
952 /// requested using "amdgpu-num-vgpr" attribute attached to function \p MF.
953 ///
954 /// \returns Value that meets number of waves per execution unit requirement
955 /// if explicitly requested value cannot be converted to integer, violates
956 /// subtarget's specifications, or does not meet number of waves per execution
957 /// unit requirement.
958 unsigned getMaxNumVGPRs(const MachineFunction &MF) const;
959
960 bool isWave32() const { return getWavefrontSize() == 32; }
961
962 bool isWave64() const { return getWavefrontSize() == 64; }
963
964 /// Returns if the wavesize of this subtarget is known reliable. This is false
965 /// only for the a default target-cpu that does not have an explicit
966 /// +wavefrontsize target feature.
967 bool isWaveSizeKnown() const {
968 return hasFeature(AMDGPU::FeatureWavefrontSize32) ||
969 hasFeature(AMDGPU::FeatureWavefrontSize64);
970 }
971
973 return getRegisterInfo()->getBoolRC();
974 }
975
976 /// \returns Maximum number of work groups per compute unit supported by the
977 /// subtarget and limited by given \p FlatWorkGroupSize.
978 unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override {
979 return AMDGPU::IsaInfo::getMaxWorkGroupsPerCU(*this, FlatWorkGroupSize);
980 }
981
982 /// \returns Minimum flat work group size supported by the subtarget.
983 unsigned getMinFlatWorkGroupSize() const override {
985 }
986
987 /// \returns Maximum flat work group size supported by the subtarget.
988 unsigned getMaxFlatWorkGroupSize() const override {
990 }
991
992 /// \returns Number of waves per execution unit required to support the given
993 /// \p FlatWorkGroupSize.
994 unsigned
995 getWavesPerEUForWorkGroup(unsigned FlatWorkGroupSize) const override {
996 return AMDGPU::IsaInfo::getWavesPerEUForWorkGroup(*this, FlatWorkGroupSize);
997 }
998
999 /// \returns Minimum number of waves per execution unit supported by the
1000 /// subtarget.
1001 unsigned getMinWavesPerEU() const override {
1002 return AMDGPU::getMinWavesPerEU();
1003 }
1004
1005 void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx,
1006 SDep &Dep,
1007 const TargetSchedModel *SchedModel) const override;
1008
1009 // \returns true if it's beneficial on this subtarget for the scheduler to
1010 // cluster stores as well as loads.
1011 bool shouldClusterStores() const { return getGeneration() >= GFX11; }
1012
1013 // \returns the number of address arguments from which to enable MIMG NSA
1014 // on supported architectures.
1015 unsigned getNSAThreshold(const MachineFunction &MF) const;
1016
1017 // \returns true if the subtarget has a hazard requiring an "s_nop 0"
1018 // instruction before "s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)".
1019 bool requiresNopBeforeDeallocVGPRs() const { return !HasGFX1250Insts; }
1020
1021 // \returns true if the subtarget needs S_WAIT_ALU 0 before S_GETREG_B32 on
1022 // STATUS, STATE_PRIV, EXCP_FLAG_PRIV, or EXCP_FLAG_USER.
1023 bool requiresWaitIdleBeforeGetReg() const { return HasGFX1250Insts; }
1024
1026 // AMDGPU doesn't care if early-clobber and undef operands are allocated
1027 // to the same register.
1028 return false;
1029 }
1030
1031 // DS_ATOMIC_ASYNC_BARRIER_ARRIVE_B64 shall not be claused with anything
1032 // and surronded by S_WAIT_ALU(0xFFE3).
1034 return getGeneration() == GFX12;
1035 }
1036
1037 // Requires s_wait_alu(0) after s102/s103 write and src_flat_scratch_base
1038 // read.
1040 return HasGFX1250Insts && getGeneration() == GFX12;
1041 }
1042
1043 // src_flat_scratch_hi cannot be used as a source in SALU producing a 64-bit
1044 // result.
1046 return HasGFX1250Insts && getGeneration() == GFX12;
1047 }
1048
1049 /// \returns true if the subtarget requires a wait for xcnt before VMEM
1050 /// accesses that must never be repeated in the event of a page fault/re-try.
1051 /// Atomic stores/rmw and all volatile accesses fall under this criteria.
1053 return HasGFX1250Insts;
1054 }
1055
1056 /// \returns the number of significant bits in the immediate field of the
1057 /// S_NOP instruction.
1058 unsigned getSNopBits() const {
1060 return 7;
1062 return 4;
1063 return 3;
1064 }
1065
1069
1071 return (getGeneration() <= AMDGPUSubtarget::GFX9 ||
1073 isWave32();
1074 }
1075
1076 /// Return true if real (non-fake) variants of True16 instructions using
1077 /// 16-bit registers should be code-generated. Fake True16 instructions are
1078 /// identical to non-fake ones except that they take 32-bit registers as
1079 /// operands and always use their low halves.
1080 // TODO: Remove and use hasTrue16BitInsts() instead once True16 is fully
1081 // supported and the support for fake True16 instructions is removed.
1082 bool useRealTrue16Insts() const {
1083 return hasTrue16BitInsts() && EnableRealTrue16Insts;
1084 }
1085
1086 bool requiresWaitOnWorkgroupReleaseFence(bool TgSplit) const {
1087 return getGeneration() >= GFX10 || TgSplit;
1088 }
1089
1090 bool useDFAforSMS() const override { return false; }
1091
1092 bool enableWindowScheduler() const override { return false; }
1093
1094 // \returns true if ISel should select the native i64 min/max instructions
1095 // (V_MIN/MAX_{I|U}64).
1096 bool useMinMaxI64Insts() const {
1097 return hasMinMaxI64Insts() && !hasSlowMaxMinMulI64Insts();
1098 }
1099
1100 // \returns true if ISel should select the native i64 mul instruction
1101 // V_MUL_U64.
1102 bool useVMulU64Inst() const {
1103 return hasVMulU64Inst() && !hasSlowMaxMinMulI64Insts();
1104 }
1105};
1106
1108public:
1109 bool hasImplicitBufferPtr() const { return ImplicitBufferPtr; }
1110
1111 bool hasPrivateSegmentBuffer() const { return PrivateSegmentBuffer; }
1112
1113 bool hasDispatchPtr() const { return DispatchPtr; }
1114
1115 bool hasQueuePtr() const { return QueuePtr; }
1116
1117 bool hasKernargSegmentPtr() const { return KernargSegmentPtr; }
1118
1119 bool hasDispatchID() const { return DispatchID; }
1120
1121 bool hasFlatScratchInit() const { return FlatScratchInit; }
1122
1123 bool hasPrivateSegmentSize() const { return PrivateSegmentSize; }
1124
1125 unsigned getNumKernargPreloadSGPRs() const { return NumKernargPreloadSGPRs; }
1126
1127 unsigned getNumFreeUserSGPRs();
1128
1129 void allocKernargPreloadSGPRs(unsigned NumSGPRs);
1130
1141
1142 // Returns the size in number of SGPRs for preload user SGPR field.
1144 switch (ID) {
1146 return 2;
1148 return 4;
1149 case DispatchPtrID:
1150 return 2;
1151 case QueuePtrID:
1152 return 2;
1154 return 2;
1155 case DispatchIdID:
1156 return 2;
1157 case FlatScratchInitID:
1158 return 2;
1160 return 1;
1161 }
1162 llvm_unreachable("Unknown UserSGPRID.");
1163 }
1164
1165 GCNUserSGPRUsageInfo(const Function &F, const GCNSubtarget &ST);
1166
1167private:
1168 const GCNSubtarget &ST;
1169
1170 // Private memory buffer
1171 // Compute directly in sgpr[0:1]
1172 // Other shaders indirect 64-bits at sgpr[0:1]
1173 bool ImplicitBufferPtr = false;
1174
1175 bool PrivateSegmentBuffer = false;
1176
1177 bool DispatchPtr = false;
1178
1179 bool QueuePtr = false;
1180
1181 bool KernargSegmentPtr = false;
1182
1183 bool DispatchID = false;
1184
1185 bool FlatScratchInit = false;
1186
1187 bool PrivateSegmentSize = false;
1188
1189 unsigned NumKernargPreloadSGPRs = 0;
1190
1191 unsigned NumUsedUserSGPRs = 0;
1192};
1193
1194} // end namespace llvm
1195
1196#endif // LLVM_LIB_TARGET_AMDGPU_GCNSUBTARGET_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file describes how to lower LLVM calls to machine code calls.
uint64_t uint64_t
This file declares the targeting of the RegisterBankInfo class for AMDGPU.
Base class for AMDGPU specific classes of TargetSubtarget.
AMDHSA kernel descriptor definitions.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
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
#define T
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
unsigned getMaxWavesPerEU() const
AMDGPUSubtarget(const Triple &TT, const AMDGPUOptions &CLOpts)
unsigned getWavefrontSize() const
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
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
uint64_t getMaxBufferIntrinsicWidth(const DataLayout &DL, Type *T, Align A, bool NoWrapFromMax, bool NoPartialOOB) const
Return the maximum allowed load/store width for the given type and alignment combination based on sub...
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 hasPkF32InvalidOpSel() const
void overridePipelinerPolicy(MachinePipelinerPolicy &Policy) const override
bool hasFlatScratchHiInB64InstHazard() const
bool hasDstSelForwardingHazard() const
GCNSubtarget & initializeSubtargetDependencies(const Triple &TT, StringRef GPU, StringRef FS, AMDGPU::TargetIDSetting XnackSetting, AMDGPU::TargetIDSetting SramEccSetting)
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 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
bool isFullSIMDMode() const
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 enableSSAMachineScheduler() const override
bool hasLoopHeadInstSplitSensitivity() const
bool hasDwordx3LoadStores() const
bool hasSignedScratchOffsets() const
bool hasFlatScrRegister() const
bool hasGetPCZeroExtension() const
bool hasPermLane64() const
bool requiresNopBeforeDeallocVGPRs() const
unsigned getMinNumVGPRs(unsigned WavesPerEU, unsigned DynamicVGPRBlockSize) const
bool supportsGetDoorbellID() 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
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
bool useAddPCI64Inst() const
unsigned getMaxNumPreloadedSGPRs() const
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 useVMulU64Inst() const
unsigned getNSAThreshold(const MachineFunction &MF) 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
bool enableRALocalReassignment(CodeGenOptLevel OptLevel) const override
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 hasAnyBVHInsts() const
bool hasFractBug() const
bool isPreciseMemoryEnabled() const
unsigned getMaxWaveScratchSize() const
bool hasLDSMisalignedBugInWGPMode() const
bool hasAnyPackedU64Ops() const
bool hasBufferTFEFormatD16() 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 requiresCodeObjectV6() const
bool hasPermlaneForwardingHazard() 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
GCNUserSGPRUsageInfo(const Function &F, const GCNSubtarget &ST)
Itinerary data supplied by a subtarget to be used by a target.
Scheduling dependency.
Definition ScheduleDAG.h:54
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
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
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
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
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.