33 typedef std::map<std::string, std::vector<unsigned> > key_val_pair_t;
34 typedef std::map<const GlobalValue *, key_val_pair_t> global_val_annot_t;
35 typedef std::map<const Module *, global_val_annot_t> per_module_annot_t;
42 std::lock_guard<sys::Mutex> Guard(Lock);
43 annotationCache->erase(Mod);
47 std::lock_guard<sys::Mutex> Guard(Lock);
48 assert(md &&
"Invalid mdnode for annotation");
55 assert(prop &&
"Annotation property not a string");
59 assert(Val &&
"Value operand not a constant int");
62 if (retval.find(keyname) != retval.end())
65 std::vector<unsigned> tmp;
67 retval[keyname] = tmp;
73 std::lock_guard<sys::Mutex> Guard(Lock);
82 mdconst::dyn_extract_or_null<GlobalValue>(elem->
getOperand(0));
96 if ((*annotationCache).find(m) != (*annotationCache).end())
97 (*annotationCache)[m][gv] = std::move(tmp);
99 global_val_annot_t tmp1;
100 tmp1[gv] = std::move(tmp);
101 (*annotationCache)[m] = std::move(tmp1);
107 std::lock_guard<sys::Mutex> Guard(Lock);
109 if ((*annotationCache).find(m) == (*annotationCache).end())
111 else if ((*annotationCache)[m].find(gv) == (*annotationCache)[m].end())
113 if ((*annotationCache)[m][gv].find(prop) == (*annotationCache)[m][gv].end())
115 retval = (*annotationCache)[m][gv][prop][0];
120 std::vector<unsigned> &retval) {
121 std::lock_guard<sys::Mutex> Guard(Lock);
123 if ((*annotationCache).find(m) == (*annotationCache).end())
125 else if ((*annotationCache)[m].find(gv) == (*annotationCache)[m].end())
127 if ((*annotationCache)[m][gv].find(prop) == (*annotationCache)[m][gv].end())
129 retval = (*annotationCache)[m][gv][prop];
134 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
137 assert((annot == 1) &&
"Unexpected annotation on a texture symbol");
145 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
148 assert((annot == 1) &&
"Unexpected annotation on a surface symbol");
156 const char *AnnotationName =
"sampler";
158 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
161 assert((annot == 1) &&
"Unexpected annotation on a sampler symbol");
165 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
167 std::vector<unsigned> annot;
177 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
179 std::vector<unsigned> annot;
189 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
191 std::vector<unsigned> annot;
201 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
203 std::vector<unsigned> annot;
217 if(
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
220 assert((annot == 1) &&
"Unexpected annotation on a managed symbol");
228 assert(val.
hasName() &&
"Found texture variable with no name");
233 assert(val.
hasName() &&
"Found surface variable with no name");
238 assert(val.
hasName() &&
"Found sampler variable with no name");
285 std::vector<unsigned> Vs;
289 for (
int i = 0,
e = Vs.size(); i <
e; i++) {
291 if ((v >> 16) == index) {
301 for (
int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
303 mdconst::dyn_extract<ConstantInt>(alignNode->getOperand(i))) {
304 unsigned v = CI->getZExtValue();
305 if ((v >> 16) == index) {
309 if ((v >> 16) > index) {
This class represents an incoming formal argument to a Function.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
bool getAlign(const Function &F, unsigned index, unsigned &align)
MDNode * getOperand(unsigned i) const
This class represents lattice values for constants.
bool getMaxNReg(const Function &F, unsigned &x)
bool findOneNVVMAnnotation(const GlobalValue *gv, const std::string &prop, unsigned &retval)
A Module instance is used to store all the information related to an LLVM module. ...
bool findAllNVVMAnnotation(const GlobalValue *gv, const std::string &prop, std::vector< unsigned > &retval)
bool isTexture(const Value &val)
This class represents a function call, abstracting a target machine's calling convention.
const MDOperand & getOperand(unsigned I) const
void clearAnnotationCache(const Module *Mod)
unsigned getNumOperands() const
bool getMaxNTIDz(const Function &F, unsigned &z)
bool isKernelFunction(const Function &F)
bool isSurface(const Value &val)
bool getMaxNTIDx(const Function &F, unsigned &x)
std::string getTextureName(const Value &val)
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
PTX_Kernel - Call to a PTX kernel.
bool isSampler(const Value &val)
StringRef getString() const
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool getMaxNTIDy(const Function &F, unsigned &y)
bool getReqNTIDx(const Function &F, unsigned &x)
bool isImage(const Value &val)
bool getReqNTIDz(const Function &F, unsigned &z)
This is the shared class of boolean and integer constants.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Module.h This file contains the declarations for the Module class.
bool isImageReadWrite(const Value &val)
std::string getSurfaceName(const Value &val)
std::string getSamplerName(const Value &val)
bool isManaged(const Value &val)
bool getReqNTIDy(const Function &F, unsigned &y)
bool isImageReadOnly(const Value &val)
static void cacheAnnotationFromMD(const MDNode *md, key_val_pair_t &retval)
static ManagedStatic< per_module_annot_t > annotationCache
StringRef getName() const
Return a constant reference to the value's name.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
bool getMinCTASm(const Function &F, unsigned &x)
unsigned getNumOperands() const
Return number of MDNode operands.
bool isImageWriteOnly(const Value &val)
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.