38using AnnotationValues = std::map<std::string, std::vector<unsigned>>;
39using AnnotationMap = std::map<const GlobalValue *, AnnotationValues>;
41struct AnnotationCache {
43 std::map<const Module *, AnnotationMap> Cache;
49 static AnnotationCache AC;
67 std::lock_guard<sys::Mutex> Guard(AC.Lock);
72 AnnotationValues &RetVal) {
74 std::lock_guard<sys::Mutex> Guard(AC.Lock);
75 assert(MetadataNode &&
"Invalid mdnode for annotation");
77 "Invalid number of operands");
82 assert(Prop &&
"Annotation property not a string");
87 RetVal[
Key].push_back(Val->getZExtValue());
96 std::lock_guard<sys::Mutex> Guard(AC.Lock);
97 NamedMDNode *NMD = M->getNamedMetadata(
"nvvm.annotations");
101 AnnotationValues Tmp;
107 if (!Entity || Entity != GV)
116 AC.Cache[M][GV] = std::move(Tmp);
122 std::lock_guard<sys::Mutex> Guard(AC.Lock);
124 auto ACIt = AC.Cache.find(M);
125 if (ACIt == AC.Cache.end())
127 else if (ACIt->second.find(GV) == ACIt->second.end())
130 auto &KVP = AC.Cache[M][GV];
131 auto It = KVP.find(Prop.
str());
134 return It->second[0];
138 std::vector<unsigned> &RetVal) {
140 std::lock_guard<sys::Mutex> Guard(AC.Lock);
142 auto ACIt = AC.Cache.find(M);
143 if (ACIt == AC.Cache.end())
145 else if (ACIt->second.find(GV) == ACIt->second.end())
148 auto &KVP = AC.Cache[M][GV];
149 auto It = KVP.find(Prop.
str());
159 assert((*Annot == 1) &&
"Unexpected annotation on a symbol");
168 std::vector<unsigned> Annot;
178 return F.hasFnAttribute(Attr)
179 ? std::optional(
F.getFnAttributeAsParsedInteger(Attr))
186 auto &Ctx =
F.getContext();
188 if (
F.hasFnAttribute(Attr)) {
191 StringRef S =
F.getFnAttribute(Attr).getValueAsString();
192 for (
unsigned I = 0;
I < 3 && !S.
empty();
I++) {
195 if (
First.trim().getAsInteger(0, IntVal))
196 Ctx.emitError(
"can't parse integer attribute " +
First +
" in " + Attr);
209 return std::accumulate(V.begin(), V.end(),
uint64_t(1),
210 std::multiplies<uint64_t>{});
300 "only kernel arguments can be grid_constant");
324 I.getAttributes().getAttributes(Index).getStackAlignment())
328 if (
MDNode *AlignNode =
I.getMetadata(
"callalign")) {
329 for (
int I = 0,
N = AlignNode->getNumOperands();
I <
N;
I++) {
332 unsigned V = CI->getZExtValue();
333 if ((V >> 16) == Index)
334 return Align(V & 0xFFFF);
335 if ((V >> 16) > Index)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
static void cacheAnnotationFromMD(const MDNode *MetadataNode, AnnotationValues &RetVal)
static AnnotationCache & getAnnotationCache()
static bool findAllNVVMAnnotation(const GlobalValue *GV, StringRef Prop, std::vector< unsigned > &RetVal)
static std::optional< unsigned > getFnAttrParsedInt(const Function &F, StringRef Attr)
static std::optional< unsigned > findOneNVVMAnnotation(const GlobalValue *GV, StringRef Prop)
static bool globalHasNVVMAnnotation(const Value &V, StringRef Prop)
static bool argHasNVVMAnnotation(const Value &Val, StringRef Annotation)
static std::optional< uint64_t > getVectorProduct(ArrayRef< unsigned > V)
static SmallVector< unsigned, 3 > getFnAttrParsedVector(const Function &F, StringRef Attr)
This class represents an incoming formal argument to a Function.
LLVM_ABI bool onlyReadsMemory() const
Return true if this argument has the readonly or readnone attribute.
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const
Check if an argument has a given attribute.
LLVM_ABI bool hasByValAttr() const
Return true if this argument has the byval attribute.
const Function * getParent() const
LLVM_ABI AttributeSet getAttributes() const
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM_ABI CaptureInfo getCaptureInfo() const
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
This is the shared class of boolean and integer constants.
Module * getParent()
Get the module that this global value is contained inside of...
const MDOperand & getOperand(unsigned I) const
unsigned getNumOperands() const
Return number of MDNode operands.
LLVM_ABI StringRef getString() const
A Module instance is used to store all the information related to an LLVM module.
LLVM_ABI MDNode * getOperand(unsigned i) const
LLVM_ABI unsigned getNumOperands() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
std::string str() const
Get the contents as an std::string.
constexpr bool empty() const
Check if the string is empty.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr StringLiteral GridConstant("nvvm.grid_constant")
constexpr StringLiteral MaxNTID("nvvm.maxntid")
constexpr StringLiteral MaxNReg("nvvm.maxnreg")
constexpr StringLiteral MinCTASm("nvvm.minctasm")
constexpr StringLiteral ReqNTID("nvvm.reqntid")
constexpr StringLiteral MaxClusterRank("nvvm.maxclusterrank")
constexpr StringLiteral ClusterDim("nvvm.cluster_dim")
constexpr StringLiteral BlocksAreClusters("nvvm.blocksareclusters")
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
SmartMutex< false > Mutex
Mutex - A standard, always enforced mutex.
This is an optimization pass for GlobalISel generic memory operations.
bool isManaged(const Value &)
SmallVector< unsigned, 3 > getReqNTID(const Function &)
bool hasBlocksAreClusters(const Function &)
SmallVector< unsigned, 3 > getClusterDim(const Function &)
bool capturesAddress(CaptureComponents CC)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
std::optional< unsigned > getMaxNReg(const Function &)
PTXOpaqueType getPTXOpaqueType(const GlobalVariable &)
std::optional< uint64_t > getOverallClusterRank(const Function &)
std::optional< unsigned > getMinCTASm(const Function &)
bool capturesFullProvenance(CaptureComponents CC)
SmallVector< unsigned, 3 > getMaxNTID(const Function &)
std::optional< unsigned > getMaxClusterRank(const Function &)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ Mod
The access may modify the value stored in memory.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
std::optional< uint64_t > getOverallReqNTID(const Function &)
bool isKernelFunction(const Function &F)
std::optional< uint64_t > getOverallMaxNTID(const Function &)
MaybeAlign getStackAlign(const Function &F, unsigned Index)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool isParamGridConstant(const Argument &)
void clearAnnotationCache(const Module *)
This struct is a compact representation of a valid (non-zero power of two) alignment.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.