LLVM: lib/Target/AMDGPU/AMDGPUMachineFunction.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
19
20using namespace llvm;
21
24 const Module *M = F.getParent();
26 KernelDynLDSName += F.getName();
27 KernelDynLDSName += ".dynlds";
28 return M->getNamedGlobal(KernelDynLDSName);
29}
30
32 for (const Argument &Arg : F.args()) {
33 Type *ArgTy = Arg.getType();
36 return true;
37 }
38 }
39 return false;
40}
41
46 AMDGPU::isModuleEntryFunctionCC(F.getCallingConv())),
48
49
50
51
52 Attribute MemBoundAttr = F.getFnAttribute("amdgpu-memory-bound");
54
55 Attribute WaveLimitAttr = F.getFnAttribute("amdgpu-wave-limiter");
57
58
59
60 StringRef S = F.getFnAttribute("amdgpu-gds-size").getValueAsString();
63
64
66
67
68
69
71 F, "amdgpu-lds-size", {0, UINT32_MAX}, true);
72
73
74
75
76 LDSSize = LDSSizeRange.first;
78
82
83
84 Attribute NSZAttr = F.getFnAttribute("no-signed-zeros-fp-math");
86 NSZAttr.isStringAttribute() && NSZAttr.getValueAsString() == "true";
87
91}
92
96 auto Entry = LocalMemoryObjects.insert(std::pair(&GV, 0));
97 if (!Entry.second)
98 return Entry.first->second;
99
100 Align Alignment =
102
107 if (!BarAddr)
108 llvm_unreachable("named barrier should have an assigned address");
109 Entry.first->second = BarAddr.value();
110 unsigned BarCnt = DL.getTypeAllocSize(GV.getValueType()) / 16;
112 return BarAddr.value();
113 }
114
116 if (MaybeAbs) {
117
118
119
120
121
122
123
124 uint32_t ObjectStart = *MaybeAbs;
125
126 if (ObjectStart != alignTo(ObjectStart, Alignment)) {
127 report_fatal_error("Absolute address LDS variable inconsistent with "
128 "variable alignment");
129 }
130
132
133
134
135
136
137
139 ObjectStart + DL.getTypeAllocSize(GV.getValueType());
142 "Absolute address LDS variable outside of static frame");
143 }
144 }
145
146 Entry.first->second = ObjectStart;
147 return ObjectStart;
148 }
149
150
151
152
154
156
157
159 } else {
161 "expected region address space");
162
165
166
168 }
169
170 Entry.first->second = Offset;
172}
173
174std::optional<uint32_t>
176
177 MDNode *MD = F.getMetadata("llvm.amdgcn.lds.kernel.id");
181 uint64_t ZExt = KnownSize->getZExtValue();
182 if (ZExt <= UINT32_MAX) {
183 return ZExt;
184 }
185 }
186 }
187 return {};
188}
189
190std::optional<uint32_t>
193 return {};
194
196 if (!AbsSymRange)
197 return {};
198
199 if (const APInt *V = AbsSymRange->getSingleElement()) {
200 std::optional<uint64_t> ZExt = V->tryZExtValue();
201 if (ZExt && (*ZExt <= UINT32_MAX)) {
202 return *ZExt;
203 }
204 }
205
206 return {};
207}
208
211 const Module *M = F.getParent();
214
215 Align Alignment =
218 return;
219
222
223
224
225
226
228 if (Dyn) {
231 if (!Expect || (Offset != *Expect)) {
233 }
234 }
235}
236
240
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool hasLDSKernelArgument(const Function &F)
Definition AMDGPUMachineFunction.cpp:31
static const GlobalVariable * getKernelDynLDSGlobalFromFunction(const Function &F)
Definition AMDGPUMachineFunction.cpp:23
Base class for AMDGPU specific classes of TargetSubtarget.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
AMDGPUMachineFunction(const Function &F, const AMDGPUSubtarget &ST)
Definition AMDGPUMachineFunction.cpp:42
static std::optional< uint32_t > getLDSKernelIdMetadata(const Function &F)
Definition AMDGPUMachineFunction.cpp:175
Align DynLDSAlign
Align for dynamic shared memory if any.
bool isDynamicLDSUsed() const
Definition AMDGPUMachineFunction.cpp:241
void setUsesDynamicLDS(bool DynLDS)
Definition AMDGPUMachineFunction.cpp:237
uint32_t LDSSize
Number of bytes in the LDS that are being used.
void setDynLDSAlign(const Function &F, const GlobalVariable &GV)
Definition AMDGPUMachineFunction.cpp:209
static std::optional< uint32_t > getLDSAbsoluteAddress(const GlobalValue &GV)
Definition AMDGPUMachineFunction.cpp:191
uint64_t ExplicitKernArgSize
void recordNumNamedBarriers(uint32_t GVAddr, unsigned BarCnt)
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV)
bool isModuleEntryFunction() const
bool IsModuleEntryFunction
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.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI bool getValueAsBool() const
Return the attribute's value as a boolean.
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.
unsigned getAddressSpace() const
LLVM_ABI 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
MaybeAlign getAlign() const
Returns the alignment of the given variable.
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ REGION_ADDRESS
Address space for region memory. (GDS)
@ LOCAL_ADDRESS
Address space for local memory.
TargetExtType * isNamedBarrier(const GlobalVariable &GV)
std::pair< unsigned, unsigned > getIntegerPairAttribute(const Function &F, StringRef Name, std::pair< unsigned, unsigned > Default, bool OnlyFirstRequired)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ SPIR_KERNEL
Used for SPIR kernel functions.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
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.