45 assert(md &&
"Invalid mdnode for annotation");
46 assert((md->
getNumOperands() % 2) == 1 &&
"Invalid number of operands");
52 assert(prop &&
"Annotation property not a string");
56 assert(Val &&
"Value operand not a constant int");
59 if (retval.find(keyname) != retval.end())
62 std::vector<unsigned> tmp;
64 retval[keyname] = tmp;
79 mdconst::dyn_extract_or_null<GlobalValue>(elem->
getOperand(0));
93 if ((*annotationCache).find(m) != (*annotationCache).end())
97 tmp1[gv] = std::move(tmp);
98 (*annotationCache)[m] = std::move(tmp1);
106 if ((*annotationCache).find(m) == (*annotationCache).end())
108 else if ((*
annotationCache)[m].find(gv) == (*annotationCache)[m].end())
110 if ((*
annotationCache)[m][gv].find(prop) == (*annotationCache)[m][gv].end())
112 retval = (*annotationCache)[m][gv][prop][0];
117 std::vector<unsigned> &retval) {
120 if ((*annotationCache).find(m) == (*annotationCache).end())
122 else if ((*
annotationCache)[m].find(gv) == (*annotationCache)[m].end())
124 if ((*
annotationCache)[m][gv].find(prop) == (*annotationCache)[m][gv].end())
126 retval = (*annotationCache)[m][gv][prop];
131 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
136 assert((annot == 1) &&
"Unexpected annotation on a texture symbol");
144 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
149 assert((annot == 1) &&
"Unexpected annotation on a surface symbol");
157 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
162 assert((annot == 1) &&
"Unexpected annotation on a sampler symbol");
166 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
168 std::vector<unsigned> annot;
172 if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end())
180 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
182 std::vector<unsigned> annot;
187 if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end())
195 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
197 std::vector<unsigned> annot;
202 if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end())
210 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
212 std::vector<unsigned> annot;
217 if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end())
230 if(
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
235 assert((annot == 1) &&
"Unexpected annotation on a managed symbol");
243 assert(val.
hasName() &&
"Found texture variable with no name");
248 assert(val.
hasName() &&
"Found surface variable with no name");
253 assert(val.
hasName() &&
"Found sampler variable with no name");
304 std::vector<unsigned> Vs;
309 for (
int i = 0, e = Vs.size(); i < e; i++) {
311 if ((v >> 16) == index) {
321 for (
int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
323 mdconst::dyn_extract<ConstantInt>(alignNode->getOperand(i))) {
324 unsigned v = CI->getZExtValue();
325 if ((v >> 16) == index) {
329 if ((v >> 16) > index) {
339 if ((
id == Intrinsic::nvvm_barrier0) ||
340 (
id == Intrinsic::nvvm_barrier0_popc) ||
341 (
id == Intrinsic::nvvm_barrier0_and) ||
342 (
id == Intrinsic::nvvm_barrier0_or) ||
343 (
id == Intrinsic::cuda_syncthreads))
350 if (
id == Intrinsic::nvvm_ptr_local_to_gen ||
351 id == Intrinsic::nvvm_ptr_shared_to_gen ||
352 id == Intrinsic::nvvm_ptr_global_to_gen ||
353 id == Intrinsic::nvvm_ptr_constant_to_gen ||
354 id == Intrinsic::nvvm_ptr_gen_to_global ||
355 id == Intrinsic::nvvm_ptr_gen_to_shared ||
356 id == Intrinsic::nvvm_ptr_gen_to_local ||
357 id == Intrinsic::nvvm_ptr_gen_to_constant ||
358 id == Intrinsic::nvvm_ptr_gen_to_param) {
377 }
else if (ignore_GEP_indices)
379 V =
GEP->getPointerOperand()->stripPointerCasts();
393 if (processed.find(V) != processed.end())
398 if (V2 != V && processed.find(V2) != processed.end())
400 processed.insert(V2);
411 V =
GEP->getPointerOperand()->stripPointerCasts();
413 }
else if (
const PHINode *PN = dyn_cast<PHINode>(V)) {
414 if (V != V2 && processed.find(V) != processed.end())
416 processed.insert(PN);
417 const Value *common =
nullptr;
418 for (
unsigned i = 0; i != PN->getNumIncomingValues(); ++i) {
419 const Value *pv = PN->getIncomingValue(i);
424 else if (common != base)
444 return I->getParent();
454 return I->getParent()->getParent();
457 return B->getParent();
504 if (visited->find(
I) != visited->end())
509 for (
unsigned i = 0, e =
I->getNumOperands(); i != e; ++i)
518 std::set<Instruction *> visited;
528 I->getParent()->dump();
532 if (
BasicBlock *B = dyn_cast<BasicBlock>(v)) {
533 B->getParent()->dump();
537 if (
Function *
F = dyn_cast<Function>(v)) {
538 F->getParent()->dump();
const char PropertyAnnotationNames[PROPERTY_LAST+1][AnnotationNameLen+1]
bool isMemorySpaceTransferIntrinsic(Intrinsic::ID id)
LLVM Argument representation.
std::string getSurfaceName(const llvm::Value &)
std::map< const Module *, global_val_annot_t > per_module_annot_t
bool getReqNTIDy(const llvm::Function &, unsigned &)
A Module instance is used to store all the information related to an LLVM module. ...
bool findOneNVVMAnnotation(const llvm::GlobalValue *, std::string, unsigned &)
unsigned getNumOperands() const
Return number of MDNode operands.
CallInst - This class represents a function call, abstracting a target machine's calling convention...
std::string str() const
str - Get the contents as an std::string.
bool isSurface(const llvm::Value &)
bool isKernelFunction(const llvm::Function &)
std::string getTextureName(const llvm::Value &)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
ManagedStatic< per_module_annot_t > annotationCache
StringRef getName() const
Return a constant reference to the value's name.
bool getMaxNTIDz(const llvm::Function &, unsigned &)
BasicBlock * getParentBlock(Value *v)
Function * getParentFunction(Value *v)
inst_iterator inst_begin(Function *F)
bool isManaged(const llvm::Value &)
std::map< const GlobalValue *, key_val_pair_t > global_val_annot_t
bool getReqNTIDx(const llvm::Function &, unsigned &)
void dumpBlock(Value *v, char *blockName)
std::map< std::string, std::vector< unsigned > > key_val_pair_t
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
void dumpInst(Value *base, char *instName)
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
void dumpParent(Value *v)
PTX_Kernel - Call to a PTX kernel.
static void cacheAnnotationFromMD(const MDNode *md, key_val_pair_t &retval)
bool isImageReadWrite(const llvm::Value &)
void clearAnnotationCache(const llvm::Module *)
Instances of this class acquire a given Mutex Lock when constructed and hold that lock until destruct...
bool getMaxNTIDy(const llvm::Function &, unsigned &)
LLVM Basic Block Representation.
bool isImageWriteOnly(const llvm::Value &)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
MDNode * getOperand(unsigned i) const
void dumpInstRec(Value *v, std::set< Instruction * > *visited)
bool getReqNTIDz(const llvm::Function &, unsigned &)
bool isImageReadOnly(const llvm::Value &)
void dump() const
Support for debugging, callable in GDB: V->dump()
StringRef getString() const
const MDOperand & getOperand(unsigned I) const
This is the shared class of boolean and integer constants.
Instruction * getInst(Value *base, char *instName)
Module.h This file contains the declarations for the Module class.
MDNode * getMetadata(unsigned KindID) const
getMetadata - Get the metadata of given kind attached to this Instruction.
bool getAlign(const llvm::Function &, unsigned index, unsigned &)
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
static const char * NamedMDForAnnotations
bool getMinCTASm(const llvm::Function &, unsigned &)
bool isImage(const llvm::Value &)
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isSampler(const llvm::Value &)
const Value * skipPointerTransfer(const Value *V, bool ignore_GEP_indices)
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
bool isBarrierIntrinsic(llvm::Intrinsic::ID)
std::string getSamplerName(const llvm::Value &)
bool isTexture(const llvm::Value &)
bool findAllNVVMAnnotation(const llvm::GlobalValue *, std::string, std::vector< unsigned > &)
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
unsigned getNumOperands() const
inst_iterator inst_end(Function *F)
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
bool getMaxNTIDx(const llvm::Function &, unsigned &)
IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic functions.