LLVM  10.0.0
AMDGPUSubtarget.cpp
Go to the documentation of this file.
1 //===-- AMDGPUSubtarget.cpp - AMDGPU Subtarget Information ----------------===//
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 /// Implements the AMDGPU specific subclass of TargetSubtarget.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "AMDGPUSubtarget.h"
15 #include "AMDGPU.h"
16 #include "AMDGPUTargetMachine.h"
17 #include "AMDGPUCallLowering.h"
19 #include "AMDGPULegalizerInfo.h"
20 #include "AMDGPURegisterBankInfo.h"
21 #include "SIMachineFunctionInfo.h"
23 #include "llvm/ADT/SmallString.h"
26 #include "llvm/IR/MDBuilder.h"
28 #include <algorithm>
29 
30 using namespace llvm;
31 
32 #define DEBUG_TYPE "amdgpu-subtarget"
33 
34 #define GET_SUBTARGETINFO_TARGET_DESC
35 #define GET_SUBTARGETINFO_CTOR
36 #define AMDGPUSubtarget GCNSubtarget
37 #include "AMDGPUGenSubtargetInfo.inc"
38 #define GET_SUBTARGETINFO_TARGET_DESC
39 #define GET_SUBTARGETINFO_CTOR
40 #undef AMDGPUSubtarget
41 #include "R600GenSubtargetInfo.inc"
42 
44  "amdgpu-disable-power-sched",
45  cl::desc("Disable scheduling to minimize mAI power bursts"),
46  cl::init(false));
47 
49  "amdgpu-vgpr-index-mode",
50  cl::desc("Use GPR indexing mode instead of movrel for vector indexing"),
51  cl::init(false));
52 
53 GCNSubtarget::~GCNSubtarget() = default;
54 
57  StringRef GPU, StringRef FS) {
58  SmallString<256> FullFS("+promote-alloca,");
59  FullFS += FS;
60  ParseSubtargetFeatures(GPU, FullFS);
61 
62  // FIXME: I don't think think Evergreen has any useful support for
63  // denormals, but should be checked. Should we issue a warning somewhere
64  // if someone tries to enable these?
66  FP32Denormals = false;
67  }
68 
71 
72  return *this;
73 }
74 
77  StringRef GPU, StringRef FS) {
78  // Determine default and user-specified characteristics
79  // On SI+, we want FP64 denormals to be on by default. FP32 denormals can be
80  // enabled, but some instructions do not respect them and they run at the
81  // double precision rate, so don't enable by default.
82  //
83  // We want to be able to turn these off, but making this a subtarget feature
84  // for SI has the unhelpful behavior that it unsets everything else if you
85  // disable it.
86  //
87  // Similarly we want enable-prt-strict-null to be on by default and not to
88  // unset everything else if it is disabled
89 
90  // Assuming ECC is enabled is the conservative default.
91  SmallString<256> FullFS("+promote-alloca,+load-store-opt,+sram-ecc,+xnack,");
92 
93  if (isAmdHsaOS()) // Turn on FlatForGlobal for HSA.
94  FullFS += "+flat-for-global,+unaligned-buffer-access,+trap-handler,";
95 
96  // FIXME: I don't think think Evergreen has any useful support for
97  // denormals, but should be checked. Should we issue a warning somewhere
98  // if someone tries to enable these?
100  FullFS += "+fp64-fp16-denormals,";
101  } else {
102  FullFS += "-fp32-denormals,";
103  }
104 
105  FullFS += "+enable-prt-strict-null,"; // This is overridden by a disable in FS
106 
107  // Disable mutually exclusive bits.
108  if (FS.find_lower("+wavefrontsize") != StringRef::npos) {
109  if (FS.find_lower("wavefrontsize16") == StringRef::npos)
110  FullFS += "-wavefrontsize16,";
111  if (FS.find_lower("wavefrontsize32") == StringRef::npos)
112  FullFS += "-wavefrontsize32,";
113  if (FS.find_lower("wavefrontsize64") == StringRef::npos)
114  FullFS += "-wavefrontsize64,";
115  }
116 
117  FullFS += FS;
118 
119  ParseSubtargetFeatures(GPU, FullFS);
120 
121  // We don't support FP64 for EG/NI atm.
123 
124  // Unless +-flat-for-global is specified, turn on FlatForGlobal for all OS-es
125  // on VI and newer hardware to avoid assertion failures due to missing ADDR64
126  // variants of MUBUF instructions.
127  if (!hasAddr64() && !FS.contains("flat-for-global")) {
128  FlatForGlobal = true;
129  }
130 
131  // Set defaults if needed.
132  if (MaxPrivateElementSize == 0)
133  MaxPrivateElementSize = 4;
134 
135  if (LDSBankCount == 0)
136  LDSBankCount = 32;
137 
138  if (TT.getArch() == Triple::amdgcn) {
139  if (LocalMemorySize == 0)
140  LocalMemorySize = 32768;
141 
142  // Do something sensible for unspecified target.
143  if (!HasMovrel && !HasVGPRIndexMode)
144  HasMovrel = true;
145  }
146 
147  // Don't crash on invalid devices.
148  if (WavefrontSize == 0)
149  WavefrontSize = 64;
150 
152 
153  if (DoesNotSupportXNACK && EnableXNACK) {
154  ToggleFeature(AMDGPU::FeatureXNACK);
155  EnableXNACK = false;
156  }
157 
158  // ECC is on by default, but turn it off if the hardware doesn't support it
159  // anyway. This matters for the gfx9 targets with d16 loads, but don't support
160  // ECC.
161  if (DoesNotSupportSRAMECC && EnableSRAMECC) {
162  ToggleFeature(AMDGPU::FeatureSRAMECC);
163  EnableSRAMECC = false;
164  }
165 
166  return *this;
167 }
168 
170  TargetTriple(TT),
175  HasSDWA(false),
177  HasMulI24(true),
178  HasMulU24(true),
183  MaxWavesPerEU(10),
184  LocalMemorySize(0),
185  WavefrontSize(0)
186  { }
187 
189  const GCNTargetMachine &TM) :
190  AMDGPUGenSubtargetInfo(TT, GPU, FS),
191  AMDGPUSubtarget(TT),
192  TargetTriple(TT),
193  Gen(TT.getOS() == Triple::AMDHSA ? SEA_ISLANDS : SOUTHERN_ISLANDS),
194  InstrItins(getInstrItineraryForCPU(GPU)),
195  LDSBankCount(0),
196  MaxPrivateElementSize(0),
197 
198  FastFMAF32(false),
199  HalfRate64Ops(false),
200 
201  FP64FP16Denormals(false),
202  FlatForGlobal(false),
203  AutoWaitcntBeforeBarrier(false),
204  CodeObjectV3(false),
205  UnalignedScratchAccess(false),
206  UnalignedBufferAccess(false),
207 
208  HasApertureRegs(false),
209  EnableXNACK(false),
210  DoesNotSupportXNACK(false),
211  EnableCuMode(false),
212  TrapHandler(false),
213 
215  EnableUnsafeDSOffsetFolding(false),
216  EnableSIScheduler(false),
217  EnableDS128(false),
218  EnablePRTStrictNull(false),
219  DumpCode(false),
220 
221  FP64(false),
222  GCN3Encoding(false),
223  CIInsts(false),
224  GFX8Insts(false),
225  GFX9Insts(false),
226  GFX10Insts(false),
227  GFX7GFX8GFX9Insts(false),
228  SGPRInitBug(false),
229  HasSMemRealTime(false),
230  HasIntClamp(false),
231  HasFmaMixInsts(false),
232  HasMovrel(false),
233  HasVGPRIndexMode(false),
234  HasScalarStores(false),
235  HasScalarAtomics(false),
236  HasSDWAOmod(false),
237  HasSDWAScalar(false),
238  HasSDWASdst(false),
239  HasSDWAMac(false),
240  HasSDWAOutModsVOPC(false),
241  HasDPP(false),
242  HasDPP8(false),
243  HasR128A16(false),
244  HasNSAEncoding(false),
245  HasDLInsts(false),
246  HasDot1Insts(false),
247  HasDot2Insts(false),
248  HasDot3Insts(false),
249  HasDot4Insts(false),
250  HasDot5Insts(false),
251  HasDot6Insts(false),
252  HasMAIInsts(false),
253  HasPkFmacF16Inst(false),
254  HasAtomicFaddInsts(false),
255  EnableSRAMECC(false),
256  DoesNotSupportSRAMECC(false),
257  HasNoSdstCMPX(false),
258  HasVscnt(false),
259  HasRegisterBanking(false),
260  HasVOP3Literal(false),
261  HasNoDataDepHazard(false),
262  FlatAddressSpace(false),
263  FlatInstOffsets(false),
264  FlatGlobalInsts(false),
265  FlatScratchInsts(false),
266  ScalarFlatScratchInsts(false),
267  AddNoCarryInsts(false),
268  HasUnpackedD16VMem(false),
269  LDSMisalignedBug(false),
270  HasMFMAInlineLiteralBug(false),
271 
273 
274  HasVcmpxPermlaneHazard(false),
275  HasVMEMtoScalarWriteHazard(false),
276  HasSMEMtoVectorWriteHazard(false),
277  HasInstFwdPrefetchBug(false),
278  HasVcmpxExecWARHazard(false),
279  HasLdsBranchVmemWARHazard(false),
280  HasNSAtoVMEMBug(false),
281  HasOffset3fBug(false),
282  HasFlatSegmentOffsetBug(false),
283 
284  FeatureDisable(false),
285  InstrInfo(initializeSubtargetDependencies(TT, GPU, FS)),
286  TLInfo(TM, *this),
287  FrameLowering(TargetFrameLowering::StackGrowsUp, getStackAlignment(), 0) {
289  CallLoweringInfo.reset(new AMDGPUCallLowering(*getTargetLowering()));
290  Legalizer.reset(new AMDGPULegalizerInfo(*this, TM));
291  RegBankInfo.reset(new AMDGPURegisterBankInfo(*this));
292  InstSelector.reset(new AMDGPUInstructionSelector(
293  *this, *static_cast<AMDGPURegisterBankInfo *>(RegBankInfo.get()), TM));
294 }
295 
296 unsigned GCNSubtarget::getConstantBusLimit(unsigned Opcode) const {
297  if (getGeneration() < GFX10)
298  return 1;
299 
300  switch (Opcode) {
301  case AMDGPU::V_LSHLREV_B64:
302  case AMDGPU::V_LSHLREV_B64_gfx10:
303  case AMDGPU::V_LSHL_B64:
304  case AMDGPU::V_LSHRREV_B64:
305  case AMDGPU::V_LSHRREV_B64_gfx10:
306  case AMDGPU::V_LSHR_B64:
307  case AMDGPU::V_ASHRREV_I64:
308  case AMDGPU::V_ASHRREV_I64_gfx10:
309  case AMDGPU::V_ASHR_I64:
310  return 1;
311  }
312 
313  return 2;
314 }
315 
317  const Function &F) const {
318  if (NWaves == 1)
319  return getLocalMemorySize();
320  unsigned WorkGroupSize = getFlatWorkGroupSizes(F).second;
321  unsigned WorkGroupsPerCu = getMaxWorkGroupsPerCU(WorkGroupSize);
322  if (!WorkGroupsPerCu)
323  return 0;
324  unsigned MaxWaves = getMaxWavesPerEU();
325  return getLocalMemorySize() * MaxWaves / WorkGroupsPerCu / NWaves;
326 }
327 
329  const Function &F) const {
330  unsigned WorkGroupSize = getFlatWorkGroupSizes(F).second;
331  unsigned WorkGroupsPerCu = getMaxWorkGroupsPerCU(WorkGroupSize);
332  if (!WorkGroupsPerCu)
333  return 0;
334  unsigned MaxWaves = getMaxWavesPerEU();
335  unsigned Limit = getLocalMemorySize() * MaxWaves / WorkGroupsPerCu;
336  unsigned NumWaves = Limit / (Bytes ? Bytes : 1u);
337  NumWaves = std::min(NumWaves, MaxWaves);
338  NumWaves = std::max(NumWaves, 1u);
339  return NumWaves;
340 }
341 
342 unsigned
344  const auto *MFI = MF.getInfo<SIMachineFunctionInfo>();
345  return getOccupancyWithLocalMemSize(MFI->getLDSSize(), MF.getFunction());
346 }
347 
348 std::pair<unsigned, unsigned>
350  switch (CC) {
357  return std::make_pair(1, getWavefrontSize());
358  default:
359  return std::make_pair(1u, getMaxFlatWorkGroupSize());
360  }
361 }
362 
363 std::pair<unsigned, unsigned> AMDGPUSubtarget::getFlatWorkGroupSizes(
364  const Function &F) const {
365  // Default minimum/maximum flat work group sizes.
366  std::pair<unsigned, unsigned> Default =
368 
369  // Requested minimum/maximum flat work group sizes.
370  std::pair<unsigned, unsigned> Requested = AMDGPU::getIntegerPairAttribute(
371  F, "amdgpu-flat-work-group-size", Default);
372 
373  // Make sure requested minimum is less than requested maximum.
374  if (Requested.first > Requested.second)
375  return Default;
376 
377  // Make sure requested values do not violate subtarget's specifications.
378  if (Requested.first < getMinFlatWorkGroupSize())
379  return Default;
380  if (Requested.second > getMaxFlatWorkGroupSize())
381  return Default;
382 
383  return Requested;
384 }
385 
386 std::pair<unsigned, unsigned> AMDGPUSubtarget::getWavesPerEU(
387  const Function &F) const {
388  // Default minimum/maximum number of waves per execution unit.
389  std::pair<unsigned, unsigned> Default(1, getMaxWavesPerEU());
390 
391  // Default/requested minimum/maximum flat work group sizes.
392  std::pair<unsigned, unsigned> FlatWorkGroupSizes = getFlatWorkGroupSizes(F);
393 
394  // If minimum/maximum flat work group sizes were explicitly requested using
395  // "amdgpu-flat-work-group-size" attribute, then set default minimum/maximum
396  // number of waves per execution unit to values implied by requested
397  // minimum/maximum flat work group sizes.
398  unsigned MinImpliedByFlatWorkGroupSize =
399  getMaxWavesPerEU(FlatWorkGroupSizes.second);
400  bool RequestedFlatWorkGroupSize = false;
401 
402  if (F.hasFnAttribute("amdgpu-flat-work-group-size")) {
403  Default.first = MinImpliedByFlatWorkGroupSize;
404  RequestedFlatWorkGroupSize = true;
405  }
406 
407  // Requested minimum/maximum number of waves per execution unit.
408  std::pair<unsigned, unsigned> Requested = AMDGPU::getIntegerPairAttribute(
409  F, "amdgpu-waves-per-eu", Default, true);
410 
411  // Make sure requested minimum is less than requested maximum.
412  if (Requested.second && Requested.first > Requested.second)
413  return Default;
414 
415  // Make sure requested values do not violate subtarget's specifications.
416  if (Requested.first < getMinWavesPerEU() ||
417  Requested.first > getMaxWavesPerEU())
418  return Default;
419  if (Requested.second > getMaxWavesPerEU())
420  return Default;
421 
422  // Make sure requested values are compatible with values implied by requested
423  // minimum/maximum flat work group sizes.
424  if (RequestedFlatWorkGroupSize &&
425  Requested.first < MinImpliedByFlatWorkGroupSize)
426  return Default;
427 
428  return Requested;
429 }
430 
432  Function *Kernel = I->getParent()->getParent();
433  unsigned MinSize = 0;
434  unsigned MaxSize = getFlatWorkGroupSizes(*Kernel).second;
435  bool IdQuery = false;
436 
437  // If reqd_work_group_size is present it narrows value down.
438  if (auto *CI = dyn_cast<CallInst>(I)) {
439  const Function *F = CI->getCalledFunction();
440  if (F) {
441  unsigned Dim = UINT_MAX;
442  switch (F->getIntrinsicID()) {
443  case Intrinsic::amdgcn_workitem_id_x:
444  case Intrinsic::r600_read_tidig_x:
445  IdQuery = true;
447  case Intrinsic::r600_read_local_size_x:
448  Dim = 0;
449  break;
450  case Intrinsic::amdgcn_workitem_id_y:
451  case Intrinsic::r600_read_tidig_y:
452  IdQuery = true;
454  case Intrinsic::r600_read_local_size_y:
455  Dim = 1;
456  break;
457  case Intrinsic::amdgcn_workitem_id_z:
458  case Intrinsic::r600_read_tidig_z:
459  IdQuery = true;
461  case Intrinsic::r600_read_local_size_z:
462  Dim = 2;
463  break;
464  default:
465  break;
466  }
467  if (Dim <= 3) {
468  if (auto Node = Kernel->getMetadata("reqd_work_group_size"))
469  if (Node->getNumOperands() == 3)
470  MinSize = MaxSize = mdconst::extract<ConstantInt>(
471  Node->getOperand(Dim))->getZExtValue();
472  }
473  }
474  }
475 
476  if (!MaxSize)
477  return false;
478 
479  // Range metadata is [Lo, Hi). For ID query we need to pass max size
480  // as Hi. For size query we need to pass Hi + 1.
481  if (IdQuery)
482  MinSize = 0;
483  else
484  ++MaxSize;
485 
486  MDBuilder MDB(I->getContext());
487  MDNode *MaxWorkGroupSizeRange = MDB.createRange(APInt(32, MinSize),
488  APInt(32, MaxSize));
489  I->setMetadata(LLVMContext::MD_range, MaxWorkGroupSizeRange);
490  return true;
491 }
492 
494  Align &MaxAlign) const {
497 
498  const DataLayout &DL = F.getParent()->getDataLayout();
499  uint64_t ExplicitArgBytes = 0;
500  MaxAlign = Align::None();
501 
502  for (const Argument &Arg : F.args()) {
503  Type *ArgTy = Arg.getType();
504 
505  const Align Alignment(DL.getABITypeAlignment(ArgTy));
506  uint64_t AllocSize = DL.getTypeAllocSize(ArgTy);
507  ExplicitArgBytes = alignTo(ExplicitArgBytes, Alignment) + AllocSize;
508  MaxAlign = std::max(MaxAlign, Alignment);
509  }
510 
511  return ExplicitArgBytes;
512 }
513 
515  Align &MaxAlign) const {
516  uint64_t ExplicitArgBytes = getExplicitKernArgSize(F, MaxAlign);
517 
518  unsigned ExplicitOffset = getExplicitKernelArgOffset(F);
519 
520  uint64_t TotalSize = ExplicitOffset + ExplicitArgBytes;
521  unsigned ImplicitBytes = getImplicitArgNumBytes(F);
522  if (ImplicitBytes != 0) {
523  const Align Alignment = getAlignmentForImplicitArgPtr();
524  TotalSize = alignTo(ExplicitArgBytes, Alignment) + ImplicitBytes;
525  }
526 
527  // Being able to dereference past the end is useful for emitting scalar loads.
528  return alignTo(TotalSize, 4);
529 }
530 
532  const TargetMachine &TM) :
533  R600GenSubtargetInfo(TT, GPU, FS),
534  AMDGPUSubtarget(TT),
535  InstrInfo(*this),
536  FrameLowering(TargetFrameLowering::StackGrowsUp, getStackAlignment(), 0),
537  FMA(false),
538  CaymanISA(false),
539  CFALUBug(false),
542  FP64(false),
543  TexVTXClauseSize(0),
544  Gen(R600),
545  TLInfo(TM, initializeSubtargetDependencies(TT, GPU, FS)),
546  InstrItins(getInstrItineraryForCPU(GPU)) { }
547 
549  unsigned NumRegionInstrs) const {
550  // Track register pressure so the scheduler can try to decrease
551  // pressure once register usage is above the threshold defined by
552  // SIRegisterInfo::getRegPressureSetLimit()
553  Policy.ShouldTrackPressure = true;
554 
555  // Enabling both top down and bottom up scheduling seems to give us less
556  // register spills than just using one of these approaches on its own.
557  Policy.OnlyTopDown = false;
558  Policy.OnlyBottomUp = false;
559 
560  // Enabling ShouldTrackLaneMasks crashes the SI Machine Scheduler.
561  if (!enableSIScheduler())
562  Policy.ShouldTrackLaneMasks = true;
563 }
564 
566  return InstrInfo.pseudoToMCOpcode(AMDGPU::V_MAD_F16) != -1;
567 }
568 
570  return !hasMovrel() || (EnableVGPRIndexMode && hasVGPRIndexMode());
571 }
572 
573 unsigned GCNSubtarget::getOccupancyWithNumSGPRs(unsigned SGPRs) const {
575  return getMaxWavesPerEU();
576 
578  if (SGPRs <= 80)
579  return 10;
580  if (SGPRs <= 88)
581  return 9;
582  if (SGPRs <= 100)
583  return 8;
584  return 7;
585  }
586  if (SGPRs <= 48)
587  return 10;
588  if (SGPRs <= 56)
589  return 9;
590  if (SGPRs <= 64)
591  return 8;
592  if (SGPRs <= 72)
593  return 7;
594  if (SGPRs <= 80)
595  return 6;
596  return 5;
597 }
598 
599 unsigned GCNSubtarget::getOccupancyWithNumVGPRs(unsigned VGPRs) const {
600  unsigned MaxWaves = getMaxWavesPerEU();
601  unsigned Granule = getVGPRAllocGranule();
602  if (VGPRs < Granule)
603  return MaxWaves;
604  unsigned RoundedRegs = ((VGPRs + Granule - 1) / Granule) * Granule;
605  return std::min(std::max(getTotalNumVGPRs() / RoundedRegs, 1u), MaxWaves);
606 }
607 
611  return 2; // VCC. FLAT_SCRATCH and XNACK are no longer in SGPRs.
612 
613  if (MFI.hasFlatScratchInit()) {
615  return 6; // FLAT_SCRATCH, XNACK, VCC (in that order).
617  return 4; // FLAT_SCRATCH, VCC (in that order).
618  }
619 
620  if (isXNACKEnabled())
621  return 4; // XNACK, VCC (in that order).
622  return 2; // VCC.
623 }
624 
626  unsigned LDSSize,
627  unsigned NumSGPRs,
628  unsigned NumVGPRs) const {
629  unsigned Occupancy =
630  std::min(getMaxWavesPerEU(),
632  if (NumSGPRs)
633  Occupancy = std::min(Occupancy, getOccupancyWithNumSGPRs(NumSGPRs));
634  if (NumVGPRs)
635  Occupancy = std::min(Occupancy, getOccupancyWithNumVGPRs(NumVGPRs));
636  return Occupancy;
637 }
638 
640  const Function &F = MF.getFunction();
642 
643  // Compute maximum number of SGPRs function can use using default/requested
644  // minimum number of waves per execution unit.
645  std::pair<unsigned, unsigned> WavesPerEU = MFI.getWavesPerEU();
646  unsigned MaxNumSGPRs = getMaxNumSGPRs(WavesPerEU.first, false);
647  unsigned MaxAddressableNumSGPRs = getMaxNumSGPRs(WavesPerEU.first, true);
648 
649  // Check if maximum number of SGPRs was explicitly requested using
650  // "amdgpu-num-sgpr" attribute.
651  if (F.hasFnAttribute("amdgpu-num-sgpr")) {
652  unsigned Requested = AMDGPU::getIntegerAttribute(
653  F, "amdgpu-num-sgpr", MaxNumSGPRs);
654 
655  // Make sure requested value does not violate subtarget's specifications.
656  if (Requested && (Requested <= getReservedNumSGPRs(MF)))
657  Requested = 0;
658 
659  // If more SGPRs are required to support the input user/system SGPRs,
660  // increase to accommodate them.
661  //
662  // FIXME: This really ends up using the requested number of SGPRs + number
663  // of reserved special registers in total. Theoretically you could re-use
664  // the last input registers for these special registers, but this would
665  // require a lot of complexity to deal with the weird aliasing.
666  unsigned InputNumSGPRs = MFI.getNumPreloadedSGPRs();
667  if (Requested && Requested < InputNumSGPRs)
668  Requested = InputNumSGPRs;
669 
670  // Make sure requested value is compatible with values implied by
671  // default/requested minimum/maximum number of waves per execution unit.
672  if (Requested && Requested > getMaxNumSGPRs(WavesPerEU.first, false))
673  Requested = 0;
674  if (WavesPerEU.second &&
675  Requested && Requested < getMinNumSGPRs(WavesPerEU.second))
676  Requested = 0;
677 
678  if (Requested)
679  MaxNumSGPRs = Requested;
680  }
681 
682  if (hasSGPRInitBug())
684 
685  return std::min(MaxNumSGPRs - getReservedNumSGPRs(MF),
686  MaxAddressableNumSGPRs);
687 }
688 
690  const Function &F = MF.getFunction();
692 
693  // Compute maximum number of VGPRs function can use using default/requested
694  // minimum number of waves per execution unit.
695  std::pair<unsigned, unsigned> WavesPerEU = MFI.getWavesPerEU();
696  unsigned MaxNumVGPRs = getMaxNumVGPRs(WavesPerEU.first);
697 
698  // Check if maximum number of VGPRs was explicitly requested using
699  // "amdgpu-num-vgpr" attribute.
700  if (F.hasFnAttribute("amdgpu-num-vgpr")) {
701  unsigned Requested = AMDGPU::getIntegerAttribute(
702  F, "amdgpu-num-vgpr", MaxNumVGPRs);
703 
704  // Make sure requested value is compatible with values implied by
705  // default/requested minimum/maximum number of waves per execution unit.
706  if (Requested && Requested > getMaxNumVGPRs(WavesPerEU.first))
707  Requested = 0;
708  if (WavesPerEU.second &&
709  Requested && Requested < getMinNumVGPRs(WavesPerEU.second))
710  Requested = 0;
711 
712  if (Requested)
713  MaxNumVGPRs = Requested;
714  }
715 
716  return MaxNumVGPRs;
717 }
718 
720  SDep &Dep) const {
721  if (Dep.getKind() != SDep::Kind::Data || !Dep.getReg() ||
722  !Src->isInstr() || !Dst->isInstr())
723  return;
724 
725  MachineInstr *SrcI = Src->getInstr();
726  MachineInstr *DstI = Dst->getInstr();
727 
728  if (SrcI->isBundle()) {
730  auto Reg = Dep.getReg();
733  unsigned Lat = 0;
734  for (++I; I != E && I->isBundledWithPred(); ++I) {
735  if (I->modifiesRegister(Reg, TRI))
736  Lat = InstrInfo.getInstrLatency(getInstrItineraryData(), *I);
737  else if (Lat)
738  --Lat;
739  }
740  Dep.setLatency(Lat);
741  } else if (DstI->isBundle()) {
743  auto Reg = Dep.getReg();
746  unsigned Lat = InstrInfo.getInstrLatency(getInstrItineraryData(), *SrcI);
747  for (++I; I != E && I->isBundledWithPred() && Lat; ++I) {
748  if (I->readsRegister(Reg, TRI))
749  break;
750  --Lat;
751  }
752  Dep.setLatency(Lat);
753  }
754 }
755 
756 namespace {
757 struct MemOpClusterMutation : ScheduleDAGMutation {
758  const SIInstrInfo *TII;
759 
760  MemOpClusterMutation(const SIInstrInfo *tii) : TII(tii) {}
761 
762  void apply(ScheduleDAGInstrs *DAG) override {
763  SUnit *SUa = nullptr;
764  // Search for two consequent memory operations and link them
765  // to prevent scheduler from moving them apart.
766  // In DAG pre-process SUnits are in the original order of
767  // the instructions before scheduling.
768  for (SUnit &SU : DAG->SUnits) {
769  MachineInstr &MI2 = *SU.getInstr();
770  if (!MI2.mayLoad() && !MI2.mayStore()) {
771  SUa = nullptr;
772  continue;
773  }
774  if (!SUa) {
775  SUa = &SU;
776  continue;
777  }
778 
779  MachineInstr &MI1 = *SUa->getInstr();
780  if ((TII->isVMEM(MI1) && TII->isVMEM(MI2)) ||
781  (TII->isFLAT(MI1) && TII->isFLAT(MI2)) ||
782  (TII->isSMRD(MI1) && TII->isSMRD(MI2)) ||
783  (TII->isDS(MI1) && TII->isDS(MI2))) {
784  SU.addPredBarrier(SUa);
785 
786  for (const SDep &SI : SU.Preds) {
787  if (SI.getSUnit() != SUa)
788  SUa->addPred(SDep(SI.getSUnit(), SDep::Artificial));
789  }
790 
791  if (&SU != &DAG->ExitSU) {
792  for (const SDep &SI : SUa->Succs) {
793  if (SI.getSUnit() != &SU)
794  SI.getSUnit()->addPred(SDep(&SU, SDep::Artificial));
795  }
796  }
797  }
798 
799  SUa = &SU;
800  }
801  }
802 };
803 
804 struct FillMFMAShadowMutation : ScheduleDAGMutation {
805  const SIInstrInfo *TII;
806 
807  ScheduleDAGMI *DAG;
808 
809  FillMFMAShadowMutation(const SIInstrInfo *tii) : TII(tii) {}
810 
811  bool isSALU(const SUnit *SU) const {
812  const MachineInstr *MI = SU->getInstr();
813  return MI && TII->isSALU(*MI) && !MI->isTerminator();
814  }
815 
816  bool isVALU(const SUnit *SU) const {
817  const MachineInstr *MI = SU->getInstr();
818  return MI && TII->isVALU(*MI);
819  }
820 
821  bool canAddEdge(const SUnit *Succ, const SUnit *Pred) const {
822  if (Pred->NodeNum < Succ->NodeNum)
823  return true;
824 
825  SmallVector<const SUnit*, 64> Succs({Succ}), Preds({Pred});
826 
827  for (unsigned I = 0; I < Succs.size(); ++I) {
828  for (const SDep &SI : Succs[I]->Succs) {
829  const SUnit *SU = SI.getSUnit();
830  if (SU != Succs[I] && llvm::find(Succs, SU) == Succs.end())
831  Succs.push_back(SU);
832  }
833  }
834 
836  while (!Preds.empty()) {
837  const SUnit *SU = Preds.pop_back_val();
838  if (llvm::find(Succs, SU) != Succs.end())
839  return false;
840  Visited.insert(SU);
841  for (const SDep &SI : SU->Preds)
842  if (SI.getSUnit() != SU && !Visited.count(SI.getSUnit()))
843  Preds.push_back(SI.getSUnit());
844  }
845 
846  return true;
847  }
848 
849  // Link as much SALU intructions in chain as possible. Return the size
850  // of the chain. Links up to MaxChain instructions.
851  unsigned linkSALUChain(SUnit *From, SUnit *To, unsigned MaxChain,
852  SmallPtrSetImpl<SUnit *> &Visited) const {
853  SmallVector<SUnit *, 8> Worklist({To});
854  unsigned Linked = 0;
855 
856  while (!Worklist.empty() && MaxChain-- > 0) {
857  SUnit *SU = Worklist.pop_back_val();
858  if (!Visited.insert(SU).second)
859  continue;
860 
861  LLVM_DEBUG(dbgs() << "Inserting edge from\n" ; DAG->dumpNode(*From);
862  dbgs() << "to\n"; DAG->dumpNode(*SU); dbgs() << '\n');
863 
864  if (SU->addPred(SDep(From, SDep::Artificial), false))
865  ++Linked;
866 
867  for (SDep &SI : From->Succs) {
868  SUnit *SUv = SI.getSUnit();
869  if (SUv != From && isVALU(SUv) && canAddEdge(SUv, SU))
870  SUv->addPred(SDep(SU, SDep::Artificial), false);
871  }
872 
873  for (SDep &SI : SU->Succs) {
874  SUnit *Succ = SI.getSUnit();
875  if (Succ != SU && isSALU(Succ) && canAddEdge(From, Succ))
876  Worklist.push_back(Succ);
877  }
878  }
879 
880  return Linked;
881  }
882 
883  void apply(ScheduleDAGInstrs *DAGInstrs) override {
884  const GCNSubtarget &ST = DAGInstrs->MF.getSubtarget<GCNSubtarget>();
885  if (!ST.hasMAIInsts() || DisablePowerSched)
886  return;
887  DAG = static_cast<ScheduleDAGMI*>(DAGInstrs);
888  const TargetSchedModel *TSchedModel = DAGInstrs->getSchedModel();
889  if (!TSchedModel || DAG->SUnits.empty())
890  return;
891 
892  // Scan for MFMA long latency instructions and try to add a dependency
893  // of available SALU instructions to give them a chance to fill MFMA
894  // shadow. That is desirable to fill MFMA shadow with SALU instructions
895  // rather than VALU to prevent power consumption bursts and throttle.
896  auto LastSALU = DAG->SUnits.begin();
897  auto E = DAG->SUnits.end();
898  SmallPtrSet<SUnit*, 32> Visited;
899  for (SUnit &SU : DAG->SUnits) {
900  MachineInstr &MAI = *SU.getInstr();
901  if (!TII->isMAI(MAI) ||
902  MAI.getOpcode() == AMDGPU::V_ACCVGPR_WRITE_B32 ||
903  MAI.getOpcode() == AMDGPU::V_ACCVGPR_READ_B32)
904  continue;
905 
906  unsigned Lat = TSchedModel->computeInstrLatency(&MAI) - 1;
907 
908  LLVM_DEBUG(dbgs() << "Found MFMA: "; DAG->dumpNode(SU);
909  dbgs() << "Need " << Lat
910  << " instructions to cover latency.\n");
911 
912  // Find up to Lat independent scalar instructions as early as
913  // possible such that they can be scheduled after this MFMA.
914  for ( ; Lat && LastSALU != E; ++LastSALU) {
915  if (Visited.count(&*LastSALU))
916  continue;
917 
918  if (!isSALU(&*LastSALU) || !canAddEdge(&*LastSALU, &SU))
919  continue;
920 
921  Lat -= linkSALUChain(&SU, &*LastSALU, Lat, Visited);
922  }
923  }
924  }
925 };
926 } // namespace
927 
929  std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations) const {
930  Mutations.push_back(std::make_unique<MemOpClusterMutation>(&InstrInfo));
931  Mutations.push_back(std::make_unique<FillMFMAShadowMutation>(&InstrInfo));
932 }
933 
936  return static_cast<const AMDGPUSubtarget&>(MF.getSubtarget<GCNSubtarget>());
937  else
938  return static_cast<const AMDGPUSubtarget&>(MF.getSubtarget<R600Subtarget>());
939 }
940 
942  if (TM.getTargetTriple().getArch() == Triple::amdgcn)
943  return static_cast<const AMDGPUSubtarget&>(TM.getSubtarget<GCNSubtarget>(F));
944  else
945  return static_cast<const AMDGPUSubtarget&>(TM.getSubtarget<R600Subtarget>(F));
946 }
bool makeLIDRangeMetadata(Instruction *I) const
Creates value range metadata on an workitemid.* inrinsic call or load.
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
Definition: CallingConv.h:218
This file declares the targeting of the RegisterBankInfo class for AMDGPU.
This class represents an incoming formal argument to a Function.
Definition: Argument.h:29
AMDGPU specific subclass of TargetSubtarget.
instr_iterator instr_end()
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static cl::opt< bool > DisablePowerSched("amdgpu-disable-power-sched", cl::desc("Disable scheduling to minimize mAI power bursts"), cl::init(false))
unsigned getImplicitArgNumBytes(const Function &F) const
unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const
Inverse of getMaxLocalMemWithWaveCount.
unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const override
bool useVGPRIndexMode() const
unsigned getVGPRAllocGranule(const MCSubtargetInfo *STI, Optional< bool > EnableWavefrontSize32)
This file describes how to lower LLVM calls to machine code calls.
unsigned Reg
std::pair< unsigned, unsigned > getDefaultFlatWorkGroupSize(CallingConv::ID CC) const
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:744
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:323
Mutate the DAG as a postpass after normal DAG building.
unsigned const TargetRegisterInfo * TRI
Metadata node.
Definition: Metadata.h:872
F(f)
block Block Frequency true
unsigned getKernArgSegmentSize(const Function &F, Align &MaxAlign) const
InstrItineraryData InstrItins
unsigned getReg() const
Returns the register associated with this edge.
Definition: ScheduleDAG.h:218
Calling convention used for AMDPAL vertex shader if tessellation is in use.
Definition: CallingConv.h:226
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
Generation getGeneration() const
static bool isSMRD(const MachineInstr &MI)
Definition: SIInstrInfo.h:461
SmallVector< SDep, 4 > Preds
All sunit predecessors.
Definition: ScheduleDAG.h:256
Calling convention used for Mesa/AMDPAL geometry shaders.
Definition: CallingConv.h:202
std::pair< int, int > getIntegerPairAttribute(const Function &F, StringRef Name, std::pair< int, int > Default, bool OnlyFirstRequired)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:343
MachineFunction & MF
Machine function.
Definition: ScheduleDAG.h:560
static bool isDS(const MachineInstr &MI)
Definition: SIInstrInfo.h:471
static const AMDGPUSubtarget & get(const MachineFunction &MF)
unsigned int getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const override
SPIR_KERNEL - Calling convention for SPIR kernel functions.
Definition: CallingConv.h:147
static bool isFLAT(const MachineInstr &MI)
Definition: SIInstrInfo.h:497
This file declares the targeting of the InstructionSelector class for AMDGPU.
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:369
Provide an instruction scheduling machine model to CodeGen passes.
const HexagonInstrInfo * TII
int getLocalMemorySize() const
void getPostRAMutations(std::vector< std::unique_ptr< ScheduleDAGMutation >> &Mutations) const override
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1443
void apply(Opt *O, const Mod &M, const Mods &... Ms)
Definition: CommandLine.h:1301
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
Definition: MachineInstr.h:698
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Definition: MachineInstr.h:426
static bool isVALU(const MachineInstr &MI)
Definition: SIInstrInfo.h:341
unsigned getMaxNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU, bool Addressable)
unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI)
static cl::opt< bool > ScalarizeGlobal("amdgpu-scalarize-global-loads", cl::desc("Enable global load scalarization"), cl::init(true), cl::Hidden)
static cl::opt< bool > EnableLoadStoreOpt("aarch64-enable-ldst-opt", cl::desc("Enable the load/store pair" " optimization pass"), cl::init(true), cl::Hidden)
bool isBundle() const
Align getAlignmentForImplicitArgPtr() const
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:297
unsigned getMaxNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
Align getStackAlignment() const
SUnit * getSUnit() const
Definition: ScheduleDAG.h:480
const InstrItineraryData * getInstrItineraryData() const override
Scheduling dependency.
Definition: ScheduleDAG.h:49
std::pair< unsigned, unsigned > getWavesPerEU(const Function &F) const
unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
Definition: MachineInstr.h:869
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:435
void overrideSchedPolicy(MachineSchedPolicy &Policy, unsigned NumRegionInstrs) const override
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
Definition: ScheduleDAG.h:373
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
unsigned getReservedNumSGPRs(const MachineFunction &MF) const
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM)
void adjustSchedDependency(SUnit *Src, SUnit *Dst, SDep &Dep) const override
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:370
bool ShouldTrackLaneMasks
Track LaneMasks to allow reordering of independent subregister writes of the same vreg...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Generation getGeneration() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
const Triple & getTargetTriple() const
std::pair< unsigned, unsigned > getWavesPerEU() const
const TargetSchedModel * getSchedModel() const
Gets the machine model for instruction scheduling.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:381
self_iterator getIterator()
Definition: ilist_node.h:81
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Definition: StringRef.h:453
The AMDGPU TargetMachine interface definition for hw codgen targets.
static constexpr const Align None()
Returns a default constructed Align which corresponds to no alignment.
Definition: Alignment.h:93
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1203
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition: Metadata.cpp:1224
constexpr char NumSGPRs[]
Key for Kernel::CodeProps::Metadata::mNumSGPRs.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
static cl::opt< bool > EnableVGPRIndexMode("amdgpu-vgpr-index-mode", cl::desc("Use GPR indexing mode instead of movrel for vector indexing"), cl::init(false))
unsigned getWavefrontSize() const
const R600RegisterInfo * getRegisterInfo() const override
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:443
BlockVerifier::State From
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:390
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Definition: Function.h:212
static bool isSALU(const MachineInstr &MI)
Definition: SIInstrInfo.h:333
unsigned getExplicitKernelArgOffset(const Function &F) const
Returns the offset in bytes from the start of the input buffer of the first explicit kernel argument...
Calling convention used for Mesa/AMDPAL pixel shaders.
Definition: CallingConv.h:205
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
Information about stack frame layout on the target.
LLVM_NODISCARD size_t find_lower(char C, size_t From=0) const
Search for the first character C in the string, ignoring case.
Definition: StringRef.cpp:58
bool hasCaymanISA() const
bool addPredBarrier(SUnit *SU)
Adds a barrier edge to SU by calling addPred(), with latency 0 generally or latency 1 for a store fol...
Definition: ScheduleDAG.h:384
This class provides the information for the target register banks.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Definition: Function.h:193
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
unsigned getMaxWavesPerEU(const MCSubtargetInfo *STI)
Class for arbitrary precision integers.
Definition: APInt.h:69
GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS, const GCNTargetMachine &TM)
This file declares the targeting of the Machinelegalizer class for AMDGPU.
unsigned computeOccupancy(const MachineFunction &MF, unsigned LDSSize=0, unsigned NumSGPRs=0, unsigned NumVGPRs=0) const
Return occupancy for the given function.
constexpr char NumVGPRs[]
Key for Kernel::CodeProps::Metadata::mNumVGPRs.
void dumpNode(const SUnit &SU) const override
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const
Return the maximum number of waves per SIMD for kernels using SGPRs SGPRs.
void setLatency(unsigned Lat)
Sets the latency for this edge.
Definition: ScheduleDAG.h:147
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:271
unsigned getMaxWavesPerEU() const
Provides AMDGPU specific target descriptions.
A ScheduleDAG for scheduling lists of MachineInstr.
Define a generic scheduling policy for targets that don&#39;t provide their own MachineSchedStrategy.
Representation of each machine instruction.
Definition: MachineInstr.h:63
SUnit ExitSU
Special node for the region exit.
Definition: ScheduleDAG.h:564
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:163
static const size_t npos
Definition: StringRef.h:56
AMDGPUSubtarget(const Triple &TT)
static bool isMAI(const MachineInstr &MI)
Definition: SIInstrInfo.h:582
uint64_t getExplicitKernArgSize(const Function &F, Align &MaxAlign) const
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:106
Calling convention used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (ve...
Definition: CallingConv.h:199
int getIntegerAttribute(const Function &F, StringRef Name, int Default)
#define I(x, y, z)
Definition: MD5.cpp:58
static bool isVMEM(const MachineInstr &MI)
Definition: SIInstrInfo.h:349
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
unsigned getMaxFlatWorkGroupSize() const override
Kind getKind() const
Returns an enum value representing the kind of the dependence.
Definition: ScheduleDAG.h:486
unsigned getMinFlatWorkGroupSize() const override
unsigned NodeNum
Entry # of node in the node vector.
Definition: ScheduleDAG.h:264
unsigned getMaxNumVGPRs(unsigned WavesPerEU) const
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
Definition: MachineInstr.h:856
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool addPred(const SDep &D, bool Required=true)
Adds the specified edge as a pred of the current node if not already.
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:575
~GCNSubtarget() override
SmallVector< SDep, 4 > Succs
All sunit successors.
Definition: ScheduleDAG.h:257
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:279
Arbitrary strong DAG edge (no real dependence).
Definition: ScheduleDAG.h:72
GCNSubtarget & initializeSubtargetDependencies(const Triple &TT, StringRef GPU, StringRef FS)
bool hasMAIInsts() const
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
unsigned getMinNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:54
unsigned getConstantBusLimit(unsigned Opcode) const
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...
std::vector< SUnit > SUnits
The scheduling units.
Definition: ScheduleDAG.h:562
unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const
Return the maximum number of waves per SIMD for kernels using VGPRs VGPRs.
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
unsigned getMinWavesPerEU() const override
const SITargetLowering * getTargetLowering() const override
#define LLVM_DEBUG(X)
Definition: Debug.h:122
std::pair< unsigned, unsigned > getFlatWorkGroupSizes(const Function &F) const
R600Subtarget & initializeSubtargetDependencies(const Triple &TT, StringRef GPU, StringRef FS)
Calling convention for AMDGPU code object kernels.
Definition: CallingConv.h:211
bool isInstr() const
Returns true if this SUnit refers to a machine instruction as opposed to an SDNode.
Definition: ScheduleDAG.h:362
iterator_range< arg_iterator > args()
Definition: Function.h:730
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:242
Calling convention used for AMDPAL shader stage before geometry shader if geometry is in use...
Definition: CallingConv.h:231
const BasicBlock * getParent() const
Definition: Instruction.h:66