24 const Module *M =
F.getParent();
26 KernelDynLDSName +=
F.getName();
27 KernelDynLDSName +=
".dynlds";
28 return M->getNamedGlobal(KernelDynLDSName);
33 Type *ArgTy = Arg.getType();
34 if (
auto PtrTy = dyn_cast<PointerType>(ArgTy)) {
44 : IsEntryFunction(AMDGPU::isEntryFunctionCC(
F.getCallingConv())),
45 IsModuleEntryFunction(
46 AMDGPU::isModuleEntryFunctionCC(
F.getCallingConv())),
47 IsChainFunction(AMDGPU::isChainCC(
F.getCallingConv())),
48 NoSignedZerosFPMath(
false) {
53 Attribute MemBoundAttr =
F.getFnAttribute(
"amdgpu-memory-bound");
56 Attribute WaveLimitAttr =
F.getFnAttribute(
"amdgpu-wave-limiter");
61 StringRef S =
F.getFnAttribute(
"amdgpu-gds-size").getValueAsString();
72 F,
"amdgpu-lds-size", {0, UINT32_MAX},
true);
85 Attribute NSZAttr =
F.getFnAttribute(
"no-signed-zeros-fp-math");
97 auto Entry = LocalMemoryObjects.insert(std::pair(&GV, 0));
99 return Entry.first->second;
118 if (ObjectStart !=
alignTo(ObjectStart, Alignment)) {
120 "variable alignment");
134 "Absolute address LDS variable outside of static frame");
138 Entry.first->second = ObjectStart;
153 "expected region address space");
162 Entry.first->second =
Offset;
166std::optional<uint32_t>
169 MDNode *MD =
F.getMetadata(
"llvm.amdgcn.lds.kernel.id");
172 mdconst::extract<ConstantInt>(MD->
getOperand(0))) {
173 uint64_t ZExt = KnownSize->getZExtValue();
174 if (ZExt <= UINT32_MAX) {
182std::optional<uint32_t>
191 if (
const APInt *V = AbsSymRange->getSingleElement()) {
192 std::optional<uint64_t> ZExt = V->tryZExtValue();
193 if (ZExt && (*ZExt <= UINT32_MAX)) {
203 const Module *M =
F.getParent();
223 if (!Expect || (
Offset != *Expect)) {
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool hasLDSKernelArgument(const Function &F)
static const GlobalVariable * getKernelDynLDSGlobalFromFunction(const Function &F)
Analyzes if a function potentially memory bound and if a kernel kernel may benefit from limiting numb...
Base class for AMDGPU specific classes of TargetSubtarget.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
AMDGPUMachineFunction(const Function &F, const AMDGPUSubtarget &ST)
static std::optional< uint32_t > getLDSKernelIdMetadata(const Function &F)
Align DynLDSAlign
Align for dynamic shared memory if any.
bool isDynamicLDSUsed() const
void setUsesDynamicLDS(bool DynLDS)
uint32_t LDSSize
Number of bytes in the LDS that are being used.
void setDynLDSAlign(const Function &F, const GlobalVariable &GV)
static std::optional< uint32_t > getLDSAbsoluteAddress(const GlobalValue &GV)
uint64_t ExplicitKernArgSize
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV)
bool isModuleEntryFunction() const
uint32_t StaticLDSSize
Number of bytes in the LDS allocated statically.
Class for arbitrary precision integers.
This class represents an incoming formal argument to a Function.
bool isStringAttribute() const
Return true if the attribute is a string (target-dependent) attribute.
bool getValueAsBool() const
Return the attribute's value as a boolean.
StringRef getValueAsString() const
Return the attribute's value as a string.
This is the shared class of boolean and integer constants.
A parsed version of the target data layout string in and methods for querying it.
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
unsigned getAddressSpace() const
std::optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns std::null...
Type * getValueType() const
const MDOperand & getOperand(unsigned I) const
unsigned getNumOperands() const
Return number of MDNode operands.
A Module instance is used to store all the information related to an LLVM module.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
bool consumeInteger(unsigned Radix, T &Result)
Parse the current string as an integer of the specified radix.
constexpr bool empty() const
empty - Check if the string is empty.
The instances of the Type class are immutable: once they are created, they are never changed.
@ REGION_ADDRESS
Address space for region memory. (GDS)
@ LOCAL_ADDRESS
Address space for local memory.
std::pair< unsigned, unsigned > getIntegerPairAttribute(const Function &F, StringRef Name, std::pair< unsigned, unsigned > Default, bool OnlyFirstRequired)
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ SPIR_KERNEL
Used for SPIR kernel functions.
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
This struct is a compact representation of a valid (non-zero power of two) alignment.