18 #ifdef LLVM_BUILD_GLOBAL_ISEL
33 #define DEBUG_TYPE "amdgpu-subtarget"
35 #define GET_SUBTARGETINFO_TARGET_DESC
36 #define GET_SUBTARGETINFO_CTOR
37 #include "AMDGPUGenSubtargetInfo.inc"
53 SmallString<256> FullFS(
"+promote-alloca,+fp64-fp16-denormals,+dx10-clamp,+load-store-opt,");
55 FullFS +=
"+flat-for-global,+unaligned-buffer-access,+trap-handler,";
83 #ifdef LLVM_BUILD_GLOBAL_ISEL
87 std::unique_ptr<AMDGPUCallLowering> CallLoweringInfo;
88 std::unique_ptr<InstructionSelector> InstSelector;
90 std::unique_ptr<RegisterBankInfo> RegBankInfo;
92 return CallLoweringInfo.get();
95 return InstSelector.get();
101 return RegBankInfo.get();
112 Gen(TT.getArch() ==
Triple::amdgcn ? SOUTHERN_ISLANDS : R600),
113 IsaVersion(ISAVersion0_0_0),
117 MaxPrivateElementSize(0),
120 HalfRate64Ops(
false),
122 FP32Denormals(
false),
123 FP64FP16Denormals(
false),
126 FlatForGlobal(
false),
127 AutoWaitcntBeforeBarrier(
false),
128 UnalignedScratchAccess(
false),
129 UnalignedBufferAccess(
false),
131 HasApertureRegs(
false),
134 DebuggerInsertNops(
false),
135 DebuggerReserveRegs(
false),
136 DebuggerEmitPrologue(
false),
138 EnableVGPRSpilling(
false),
139 EnablePromoteAlloca(
false),
141 EnableUnsafeDSOffsetFolding(
false),
142 EnableSIScheduler(
false),
152 HasSMemRealTime(
false),
153 Has16BitInsts(
false),
154 HasVOP3PInsts(
false),
156 HasVGPRIndexMode(
false),
157 HasScalarStores(
false),
158 HasInv2PiInlineImm(
false),
161 HasSDWAScalar(
false),
164 HasSDWAOutModsVOPC(
false),
166 FlatAddressSpace(
false),
167 FlatInstOffsets(
false),
168 FlatGlobalInsts(
false),
169 FlatScratchInsts(
false),
174 HasVertexCache(
false),
178 FeatureDisable(
false),
179 InstrItins(getInstrItineraryForCPU(GPU)) {
200 unsigned NumWaves = Limit / (Bytes ? Bytes : 1u);
201 NumWaves =
std::min(NumWaves, MaxWaves);
209 std::pair<unsigned, unsigned>
Default =
218 F,
"amdgpu-max-work-group-size", Default.second);
219 Default.first =
std::min(Default.first, Default.second);
223 F,
"amdgpu-flat-work-group-size", Default);
226 if (Requested.first > Requested.second)
250 unsigned MinImpliedByFlatWorkGroupSize =
252 bool RequestedFlatWorkGroupSize =
false;
258 Default.first = MinImpliedByFlatWorkGroupSize;
259 RequestedFlatWorkGroupSize =
true;
264 F,
"amdgpu-waves-per-eu", Default,
true);
267 if (Requested.second && Requested.first > Requested.second)
279 if (RequestedFlatWorkGroupSize &&
280 Requested.first < MinImpliedByFlatWorkGroupSize)
288 unsigned MinSize = 0;
290 bool IdQuery =
false;
293 if (
auto *CI = dyn_cast<CallInst>(I)) {
294 const Function *
F = CI->getCalledFunction();
296 unsigned Dim = UINT_MAX;
298 case Intrinsic::amdgcn_workitem_id_x:
299 case Intrinsic::r600_read_tidig_x:
302 case Intrinsic::r600_read_local_size_x:
305 case Intrinsic::amdgcn_workitem_id_y:
306 case Intrinsic::r600_read_tidig_y:
309 case Intrinsic::r600_read_local_size_y:
312 case Intrinsic::amdgcn_workitem_id_z:
313 case Intrinsic::r600_read_tidig_z:
316 case Intrinsic::r600_read_local_size_z:
323 if (
auto Node = Kernel->
getMetadata(
"reqd_work_group_size"))
324 if (Node->getNumOperands() == 3)
325 MinSize = MaxSize = mdconst::extract<ConstantInt>(
326 Node->getOperand(Dim))->getZExtValue();
342 MDNode *MaxWorkGroupSizeRange = MDB.createRange(
APInt(32, MinSize),
360 #ifndef LLVM_BUILD_GLOBAL_ISEL
363 SIGISelActualAccessor *GISel =
new SIGISelActualAccessor();
369 *
this, *static_cast<AMDGPURegisterBankInfo *>(GISel->RegBankInfo.get())));
375 unsigned NumRegionInstrs)
const {
396 unsigned ExplicitArgBytes)
const {
398 if (ImplicitBytes == 0)
399 return ExplicitArgBytes;
402 return alignTo(ExplicitArgBytes, Alignment) + ImplicitBytes;
470 std::pair<unsigned, unsigned> WavesPerEU = MFI.
getWavesPerEU();
472 unsigned MaxAddressableNumSGPRs =
getMaxNumSGPRs(WavesPerEU.first,
true);
478 F,
"amdgpu-num-sgpr", MaxNumSGPRs);
492 if (Requested && Requested < InputNumSGPRs)
493 Requested = InputNumSGPRs;
497 if (Requested && Requested >
getMaxNumSGPRs(WavesPerEU.first,
false))
499 if (WavesPerEU.second &&
504 MaxNumSGPRs = Requested;
511 MaxAddressableNumSGPRs);
520 std::pair<unsigned, unsigned> WavesPerEU = MFI.
getWavesPerEU();
527 F,
"amdgpu-num-vgpr", MaxNumVGPRs);
537 if (WavesPerEU.second &&
542 MaxNumVGPRs = Requested;
The goal of this helper class is to gather the accessor to all the APIs related to GlobalISel...
bool hasFlatScratchInit() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This file declares the targeting of the RegisterBankInfo class for AMDGPU.
AMDGPU specific subclass of TargetSubtarget.
unsigned getNumPreloadedSGPRs() const
bool makeLIDRangeMetadata(Instruction *I) const
Creates value range metadata on an workitemid.* inrinsic call or load.
bool isVGPRSpillingEnabled(const Function &F) const
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
unsigned getMinNumSGPRs(unsigned WavesPerEU) const
unsigned getMaxNumVGPRs(unsigned WavesPerEU) const
This file describes how to lower LLVM calls to machine code calls.
AMDGPUSubtarget & initializeSubtargetDependencies(const Triple &TT, StringRef GPU, StringRef FS)
AMDGPUAS getAMDGPUAS(const Module &M)
const Function * getParent() const
Return the enclosing method, or null if none.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
int getLocalMemorySize() const
unsigned getImplicitArgNumBytes(const MachineFunction &MF) const
unsigned getMinNumVGPRs(unsigned WavesPerEU) const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
std::pair< int, int > getIntegerPairAttribute(const Function &F, StringRef Name, std::pair< int, int > Default, bool OnlyFirstRequired)
unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const
Holds all the information related to register banks.
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const
Return the maximum number of waves per SIMD for kernels using SGPRs SGPRs.
bool enableSIScheduler() const
This file declares the targeting of the InstructionSelector class for AMDGPU.
std::pair< unsigned, unsigned > getWavesPerEU(const Function &F) const
static cl::opt< bool > ScalarizeGlobal("amdgpu-scalarize-global-loads", cl::desc("Enable global load scalarization"), cl::init(true), cl::Hidden)
bool isXNACKEnabled() const
SISubtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM)
Generation getGeneration() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
bool hasSGPRInitBug() const
Function Alias Analysis false
bool isCompute(CallingConv::ID cc)
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
unsigned getMaxWavesPerEU() const
unsigned getKernArgSegmentSize(const MachineFunction &MF, unsigned ExplictArgBytes) const
R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM)
unsigned getMinFlatWorkGroupSize() const
bool ShouldTrackLaneMasks
Track LaneMasks to allow reordering of independent subregister writes of the same vreg...
unsigned getOccupancyWithNumVGPRs(unsigned VGPRs) const
Return the maximum number of waves per SIMD for kernels using VGPRs VGPRs.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
The AMDGPU TargetMachine interface definition for hw codgen targets.
unsigned getReservedNumSGPRs(const MachineFunction &MF) const
unsigned getMaxFlatWorkGroupSize() const
unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const
Inverse of getMaxLocalMemWithWaveCount.
LLVMContext & getContext() const
All values hold a context through their type.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Triple - Helper class for working with autoconf configuration names.
unsigned getMinWavesPerEU() const
const SIRegisterInfo * getRegisterInfo() const override
Information about stack frame layout on the target.
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...
Class for arbitrary precision integers.
bool isShader(CallingConv::ID cc)
This file declares the targeting of the Machinelegalizer class for AMDGPU.
void setGISelAccessor(GISelAccessor &GISel)
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
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...
Provides the logic to select generic machine instructions.
Define a generic scheduling policy for targets that don't provide their own MachineSchedStrategy.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
std::pair< unsigned, unsigned > getWavesPerEU() const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
unsigned getReservedNumVGPRs(const MachineFunction &MF) const
int getIntegerAttribute(const Function &F, StringRef Name, int Default)
void overrideSchedPolicy(MachineSchedPolicy &Policy, unsigned NumRegionInstrs) const override
constexpr char WavefrontSize[]
Key for Kernel::CodeProps::Metadata::mWavefrontSize.
~AMDGPUSubtarget() override
unsigned getWavefrontSize() const
AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS, const TargetMachine &TM)
const SITargetLowering * getTargetLowering() const override
static cl::opt< bool > EnableLoadStoreOpt("aarch64-enable-ldst-opt", cl::desc("Enable the load/store pair"" optimization pass"), cl::init(true), cl::Hidden)
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
unsigned MaxPrivateElementSize
Primary interface to the complete machine description for the target machine.
unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const
StringRef - Represent a constant reference to a string, i.e.
std::pair< unsigned, unsigned > getFlatWorkGroupSizes(const Function &F) const
const BasicBlock * getParent() const
unsigned getAlignmentForImplicitArgPtr() const