33typedef std::map<std::string, std::vector<unsigned> > key_val_pair_t;
34typedef std::map<const GlobalValue *, key_val_pair_t> global_val_annot_t;
36struct AnnotationCache {
38 std::map<const Module *, global_val_annot_t> Cache;
41AnnotationCache &getAnnotationCache() {
42 static AnnotationCache AC;
48 auto &AC = getAnnotationCache();
49 std::lock_guard<sys::Mutex> Guard(AC.Lock);
54 auto &AC = getAnnotationCache();
55 std::lock_guard<sys::Mutex> Guard(AC.Lock);
56 assert(md &&
"Invalid mdnode for annotation");
63 assert(prop &&
"Annotation property not a string");
67 assert(Val &&
"Value operand not a constant int");
70 if (retval.find(keyname) != retval.end())
73 std::vector<unsigned> tmp;
75 retval[keyname] = tmp;
81 auto &AC = getAnnotationCache();
82 std::lock_guard<sys::Mutex> Guard(AC.Lock);
91 mdconst::dyn_extract_or_null<GlobalValue>(elem->
getOperand(0));
105 if (AC.Cache.find(m) != AC.Cache.end())
106 AC.Cache[m][gv] = std::move(tmp);
108 global_val_annot_t tmp1;
109 tmp1[gv] = std::move(tmp);
110 AC.Cache[m] = std::move(tmp1);
116 auto &AC = getAnnotationCache();
117 std::lock_guard<sys::Mutex> Guard(AC.Lock);
119 if (AC.Cache.find(m) == AC.Cache.end())
121 else if (AC.Cache[m].find(gv) == AC.Cache[m].end())
123 if (AC.Cache[m][gv].find(prop) == AC.Cache[m][gv].end())
125 retval = AC.Cache[m][gv][prop][0];
130 std::vector<unsigned> &retval) {
131 auto &AC = getAnnotationCache();
132 std::lock_guard<sys::Mutex> Guard(AC.Lock);
134 if (AC.Cache.find(m) == AC.Cache.end())
136 else if (AC.Cache[m].find(gv) == AC.Cache[m].end())
138 if (AC.Cache[m][gv].find(prop) == AC.Cache[m][gv].end())
140 retval = AC.Cache[m][gv][prop];
145 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
148 assert((annot == 1) &&
"Unexpected annotation on a texture symbol");
156 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
159 assert((annot == 1) &&
"Unexpected annotation on a surface symbol");
167 const char *AnnotationName =
"sampler";
169 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
172 assert((annot == 1) &&
"Unexpected annotation on a sampler symbol");
176 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
178 std::vector<unsigned> annot;
188 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
190 std::vector<unsigned> annot;
200 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
202 std::vector<unsigned> annot;
212 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
214 std::vector<unsigned> annot;
228 if(
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
231 assert((annot == 1) &&
"Unexpected annotation on a managed symbol");
239 assert(val.
hasName() &&
"Found texture variable with no name");
240 return std::string(val.
getName());
244 assert(val.
hasName() &&
"Found surface variable with no name");
245 return std::string(val.
getName());
249 assert(val.
hasName() &&
"Found sampler variable with no name");
250 return std::string(val.
getName());
296 std::vector<unsigned> Vs;
300 for (
unsigned v : Vs) {
301 if ((v >> 16) == index) {
310 if (
MDNode *alignNode =
I.getMetadata(
"callalign")) {
311 for (
int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
313 mdconst::dyn_extract<ConstantInt>(alignNode->getOperand(i))) {
314 unsigned v = CI->getZExtValue();
315 if ((v >> 16) == index) {
319 if ((v >> 16) > index) {
335 if (!ST.hasNoReturn())
338 assert((isa<Function>(V) || isa<CallInst>(V)) &&
339 "Expect either a call instruction or a function");
341 if (
const CallInst *CallI = dyn_cast<CallInst>(V))
342 return CallI->doesNotReturn() &&
343 CallI->getFunctionType()->getReturnType()->isVoidTy();
346 return F->doesNotReturn() &&
347 F->getFunctionType()->getReturnType()->isVoidTy() &&
352 return (VT == MVT::v2f16 || VT == MVT::v2bf16 || VT == MVT::v2i16);
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.
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class represents an incoming formal argument to a Function.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Value * getCalledOperand() const
This class represents a function call, abstracting a target machine's calling convention.
This is the shared class of boolean and integer constants.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
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.
StringRef getString() const
A Module instance is used to store all the information related to an LLVM module.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
MDNode * getOperand(unsigned i) const
unsigned getNumOperands() const
std::string str() const
str - Get the contents as an std::string.
Primary interface to the complete machine description for the target machine.
LLVM Value Representation.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
StringRef getName() const
Return a constant reference to the value's name.
@ PTX_Kernel
Call to a PTX kernel. Passes all arguments in parameter space.
SmartMutex< false > Mutex
Mutex - A standard, always enforced mutex.
This is an optimization pass for GlobalISel generic memory operations.
bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM)
std::string getSamplerName(const Value &val)
bool getAlign(const Function &F, unsigned index, unsigned &align)
bool getMinCTASm(const Function &F, unsigned &x)
bool isImage(const Value &val)
bool isImageReadOnly(const Value &val)
bool getMaxNTIDz(const Function &F, unsigned &z)
bool isManaged(const Value &val)
bool isSurface(const Value &val)
bool findAllNVVMAnnotation(const GlobalValue *gv, const std::string &prop, std::vector< unsigned > &retval)
void clearAnnotationCache(const Module *Mod)
std::string getSurfaceName(const Value &val)
bool getReqNTIDx(const Function &F, unsigned &x)
bool getReqNTIDy(const Function &F, unsigned &y)
@ Mod
The access may modify the value stored in memory.
bool getMaxNReg(const Function &F, unsigned &x)
bool isTexture(const Value &val)
static void cacheAnnotationFromMD(const MDNode *md, key_val_pair_t &retval)
bool isImageWriteOnly(const Value &val)
bool isImageReadWrite(const Value &val)
std::string getTextureName(const Value &val)
bool isKernelFunction(const Function &F)
Function * getMaybeBitcastedCallee(const CallBase *CB)
bool getReqNTIDz(const Function &F, unsigned &z)
bool findOneNVVMAnnotation(const GlobalValue *gv, const std::string &prop, unsigned &retval)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool getMaxNTIDx(const Function &F, unsigned &x)
bool getMaxNTIDy(const Function &F, unsigned &y)
bool isSampler(const Value &val)