33 #define DEBUG_TYPE "amdgpu-subtarget" 35 #define GET_SUBTARGETINFO_TARGET_DESC 36 #define GET_SUBTARGETINFO_CTOR 37 #define AMDGPUSubtarget GCNSubtarget 38 #include "AMDGPUGenSubtargetInfo.inc" 39 #define GET_SUBTARGETINFO_TARGET_DESC 40 #define GET_SUBTARGETINFO_CTOR 41 #undef AMDGPUSubtarget 42 #include "R600GenSubtargetInfo.inc" 81 FullFS +=
"+flat-address-space,+flat-for-global,+unaligned-buffer-access,+trap-handler,";
87 FullFS +=
"+fp64-fp16-denormals,";
89 FullFS +=
"-fp32-denormals,";
102 if (!hasAddr64() && !FS.
contains(
"flat-for-global")) {
103 FlatForGlobal =
true;
107 if (MaxPrivateElementSize == 0)
108 MaxPrivateElementSize = 4;
110 if (LDSBankCount == 0)
118 if (!HasMovrel && !HasVGPRIndexMode)
151 IsaVersion(ISAVersion0_0_0),
153 MaxPrivateElementSize(0),
156 HalfRate64Ops(
false),
158 FP64FP16Denormals(
false),
160 FlatForGlobal(
false),
161 AutoWaitcntBeforeBarrier(
false),
163 UnalignedScratchAccess(
false),
164 UnalignedBufferAccess(
false),
166 HasApertureRegs(
false),
169 DebuggerInsertNops(
false),
170 DebuggerEmitPrologue(
false),
172 EnableHugePrivateBuffer(
false),
173 EnableVGPRSpilling(
false),
175 EnableUnsafeDSOffsetFolding(
false),
176 EnableSIScheduler(
false),
185 HasSMemRealTime(
false),
187 HasFmaMixInsts(
false),
189 HasVGPRIndexMode(
false),
190 HasScalarStores(
false),
191 HasScalarAtomics(
false),
192 HasInv2PiInlineImm(
false),
194 HasSDWAScalar(
false),
197 HasSDWAOutModsVOPC(
false),
200 D16PreservesUnusedBits(
false),
201 FlatAddressSpace(
false),
202 FlatInstOffsets(
false),
203 FlatGlobalInsts(
false),
204 FlatScratchInsts(
false),
205 AddNoCarryInsts(
false),
206 HasUnpackedD16VMem(
false),
210 FeatureDisable(
false),
211 InstrInfo(initializeSubtargetDependencies(TT, GPU, FS)),
219 *
this, *static_cast<AMDGPURegisterBankInfo *>(RegBankInfo.get()), TM));
238 unsigned NumWaves = Limit / (Bytes ? Bytes : 1u);
239 NumWaves = std::min(NumWaves, MaxWaves);
250 std::pair<unsigned, unsigned>
273 std::pair<unsigned, unsigned>
Default =
279 F,
"amdgpu-max-work-group-size", Default.second);
280 Default.first = std::min(Default.first, Default.second);
284 F,
"amdgpu-flat-work-group-size", Default);
287 if (Requested.first > Requested.second)
311 unsigned MinImpliedByFlatWorkGroupSize =
313 bool RequestedFlatWorkGroupSize =
false;
319 Default.first = MinImpliedByFlatWorkGroupSize;
320 RequestedFlatWorkGroupSize =
true;
325 F,
"amdgpu-waves-per-eu", Default,
true);
328 if (Requested.second && Requested.first > Requested.second)
340 if (RequestedFlatWorkGroupSize &&
341 Requested.first < MinImpliedByFlatWorkGroupSize)
349 unsigned MinSize = 0;
351 bool IdQuery =
false;
354 if (
auto *CI = dyn_cast<CallInst>(I)) {
355 const Function *
F = CI->getCalledFunction();
357 unsigned Dim = UINT_MAX;
359 case Intrinsic::amdgcn_workitem_id_x:
360 case Intrinsic::r600_read_tidig_x:
363 case Intrinsic::r600_read_local_size_x:
366 case Intrinsic::amdgcn_workitem_id_y:
367 case Intrinsic::r600_read_tidig_y:
370 case Intrinsic::r600_read_local_size_y:
373 case Intrinsic::amdgcn_workitem_id_z:
374 case Intrinsic::r600_read_tidig_z:
377 case Intrinsic::r600_read_local_size_z:
384 if (
auto Node = Kernel->
getMetadata(
"reqd_work_group_size"))
385 if (Node->getNumOperands() == 3)
386 MinSize = MaxSize = mdconst::extract<ConstantInt>(
387 Node->getOperand(Dim))->getZExtValue();
403 MDNode *MaxWorkGroupSizeRange = MDB.createRange(
APInt(32, MinSize),
410 unsigned &MaxAlign)
const {
415 uint64_t ExplicitArgBytes = 0;
421 unsigned Align = DL.getABITypeAlignment(ArgTy);
422 uint64_t AllocSize = DL.getTypeAllocSize(ArgTy);
423 ExplicitArgBytes =
alignTo(ExplicitArgBytes, Align) + AllocSize;
424 MaxAlign =
std::max(MaxAlign, Align);
427 return ExplicitArgBytes;
431 unsigned &MaxAlign)
const {
436 uint64_t TotalSize = ExplicitOffset + ExplicitArgBytes;
438 if (ImplicitBytes != 0) {
440 TotalSize =
alignTo(ExplicitArgBytes, Alignment) + ImplicitBytes;
463 InstrItins(getInstrItineraryForCPU(GPU)),
467 unsigned NumRegionInstrs)
const {
479 if (!enableSIScheduler())
541 if (isXNACKEnabled())
552 std::pair<unsigned, unsigned> WavesPerEU = MFI.
getWavesPerEU();
554 unsigned MaxAddressableNumSGPRs =
getMaxNumSGPRs(WavesPerEU.first,
true);
560 F,
"amdgpu-num-sgpr", MaxNumSGPRs);
563 if (Requested && (Requested <= getReservedNumSGPRs(MF)))
574 if (Requested && Requested < InputNumSGPRs)
575 Requested = InputNumSGPRs;
579 if (Requested && Requested >
getMaxNumSGPRs(WavesPerEU.first,
false))
581 if (WavesPerEU.second &&
586 MaxNumSGPRs = Requested;
589 if (hasSGPRInitBug())
592 return std::min(MaxNumSGPRs - getReservedNumSGPRs(MF),
593 MaxAddressableNumSGPRs);
602 std::pair<unsigned, unsigned> WavesPerEU = MFI.
getWavesPerEU();
609 F,
"amdgpu-num-vgpr", MaxNumVGPRs);
615 if (WavesPerEU.second &&
620 MaxNumVGPRs = Requested;
635 SUnit *SUa =
nullptr;
655 (TII->
isDS(MI1) && TII->
isDS(MI2))) {
663 if (&SU != &DAG->
ExitSU) {
678 std::vector<std::unique_ptr<ScheduleDAGMutation>> &Mutations)
const {
679 Mutations.push_back(llvm::make_unique<MemOpClusterMutation>(&InstrInfo));
bool makeLIDRangeMetadata(Instruction *I) const
Creates value range metadata on an workitemid.* inrinsic call or load.
unsigned getMinNumVGPRs(const FeatureBitset &Features, unsigned WavesPerEU)
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Calling convention used for AMDPAL shader stage before geometry shader if geometry is in use...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This file declares the targeting of the RegisterBankInfo class for AMDGPU.
This class represents an incoming formal argument to a Function.
AMDGPU specific subclass of TargetSubtarget.
Compute iterated dominance frontiers using a linear time algorithm.
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.
unsigned getImplicitArgNumBytes(const Function &F) const
unsigned getOccupancyWithLocalMemSize(uint32_t Bytes, const Function &) const
Inverse of getMaxLocalMemWithWaveCount.
This file describes how to lower LLVM calls to machine code calls.
AMDGPUAS getAMDGPUAS(const Module &M)
std::pair< unsigned, unsigned > getDefaultFlatWorkGroupSize(CallingConv::ID CC) const
LLVMContext & getContext() const
All values hold a context through their type.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Mutate the DAG as a postpass after normal DAG building.
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...
block Block Frequency true
unsigned getMaxWavesPerEU() const
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
Generation getGeneration() const
static bool isSMRD(const MachineInstr &MI)
SmallVector< SDep, 4 > Preds
All sunit predecessors.
std::pair< int, int > getIntegerPairAttribute(const Function &F, StringRef Name, std::pair< int, int > Default, bool OnlyFirstRequired)
bool hasFlatScratchInit() const
Calling convention used for Mesa/AMDPAL pixel shaders.
static bool isDS(const MachineInstr &MI)
static const AMDGPUSubtarget & get(const MachineFunction &MF)
static bool isFLAT(const MachineInstr &MI)
This file declares the targeting of the InstructionSelector class for AMDGPU.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
const HexagonInstrInfo * TII
unsigned getMinFlatWorkGroupSize() const
int getLocalMemorySize() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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.
void apply(Opt *O, const Mod &M, const Mods &... Ms)
unsigned getMaxNumSGPRs(const FeatureBitset &Features, unsigned WavesPerEU, bool Addressable)
SPIR_KERNEL - Calling convention for SPIR kernel functions.
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)
Type * getType() const
All values are typed, get the type of this value.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
uint64_t getExplicitKernArgSize(const Function &F, unsigned &MaxAlign) const
unsigned getMaxWorkGroupsPerCU(unsigned FlatWorkGroupSize) const
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.
void overrideSchedPolicy(MachineSchedPolicy &Policy, unsigned NumRegionInstrs) const override
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
Container class for subtarget features.
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...
unsigned getReservedNumSGPRs(const MachineFunction &MF) const
unsigned getStackAlignment() const
void ParseSubtargetFeatures(StringRef CPU, StringRef FS)
R600Subtarget(const Triple &TT, StringRef CPU, StringRef FS, const TargetMachine &TM)
Calling convention used for AMDPAL vertex shader if tessellation is in use.
unsigned getMinNumSGPRs(const FeatureBitset &Features, unsigned WavesPerEU)
bool ShouldTrackLaneMasks
Track LaneMasks to allow reordering of independent subregister writes of the same vreg...
AMDGPUSubtarget(const Triple &TT, const FeatureBitset &FeatureBits)
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const Triple & getTargetTriple() const
std::pair< unsigned, unsigned > getWavesPerEU() const
The AMDGPU TargetMachine interface definition for hw codgen targets.
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 getKernArgSegmentSize(const Function &F, unsigned &MaxAlign) const
unsigned getWavefrontSize() const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
unsigned getExplicitKernelArgOffset(const Function &F) const
Returns the offset in bytes from the start of the input buffer of the first explicit kernel argument...
Information about stack frame layout on the target.
AMDGPUAS getAMDGPUAS() const
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...
unsigned getAlignmentForImplicitArgPtr() const
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...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool isVGPRSpillingEnabled(const Function &F) const
Class for arbitrary precision integers.
GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS, const GCNTargetMachine &TM)
Calling convention used for Mesa/AMDPAL compute shaders.
bool isShader(CallingConv::ID cc)
This file declares the targeting of the Machinelegalizer class for AMDGPU.
Calling convention for AMDGPU code object kernels.
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const
Return the maximum number of waves per SIMD for kernels using SGPRs SGPRs.
amdgpu Simplify well known AMD library false Value Value * Arg
Provides AMDGPU specific target descriptions.
A ScheduleDAG for scheduling lists of MachineInstr.
Define a generic scheduling policy for targets that don't provide their own MachineSchedStrategy.
Representation of each machine instruction.
SUnit ExitSU
Special node for the region exit.
Calling convention used for Mesa/AMDPAL geometry shaders.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
unsigned getMinWavesPerEU() const
unsigned getMaxFlatWorkGroupSize() const
const Function * getParent() const
Return the enclosing method, or null if none.
int getIntegerAttribute(const Function &F, StringRef Name, int Default)
static bool isVMEM(const MachineInstr &MI)
unsigned getMaxNumVGPRs(unsigned WavesPerEU) const
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
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...
Calling convention used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (ve...
SmallVector< SDep, 4 > Succs
All sunit successors.
unsigned getNumPreloadedSGPRs() const
Arbitrary strong DAG edge (no real dependence).
const FeatureBitset & SubtargetFeatureBits
GCNSubtarget & initializeSubtargetDependencies(const Triple &TT, StringRef GPU, StringRef FS)
Primary interface to the complete machine description for the target machine.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
StringRef - Represent a constant reference to a string, i.e.
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.
unsigned getMaxNumVGPRs(const FeatureBitset &Features, unsigned WavesPerEU)
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.
const SITargetLowering * getTargetLowering() const override
std::pair< unsigned, unsigned > getFlatWorkGroupSizes(const Function &F) const
R600Subtarget & initializeSubtargetDependencies(const Triple &TT, StringRef GPU, StringRef FS)
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
iterator_range< arg_iterator > args()
Scheduling unit. This is a node in the scheduling DAG.
const BasicBlock * getParent() const
const SIRegisterInfo * getRegisterInfo() const override