38 assert(md &&
"Invalid mdnode for annotation");
39 assert((md->
getNumOperands() % 2) == 1 &&
"Invalid number of operands");
45 assert(prop &&
"Annotation property not a string");
49 assert(Val &&
"Value operand not a constant int");
52 if (retval.find(keyname) != retval.end())
55 std::vector<unsigned> tmp;
57 retval[keyname] = tmp;
84 if ((*annotationCache).find(m) != (*annotationCache).end())
89 (*annotationCache)[m] = tmp1;
96 if ((*annotationCache).find(m) == (*annotationCache).end())
100 if ((*
annotationCache)[m][gv].find(prop) == (*annotationCache)[m][gv].end())
102 retval = (*annotationCache)[m][gv][prop][0];
107 std::vector<unsigned> &retval) {
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];
120 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
125 assert((annot == 1) &&
"Unexpected annotation on a texture symbol");
133 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
138 assert((annot == 1) &&
"Unexpected annotation on a surface symbol");
146 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
151 assert((annot == 1) &&
"Unexpected annotation on a sampler symbol");
155 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
157 std::vector<unsigned> annot;
161 if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end())
169 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
171 std::vector<unsigned> annot;
176 if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end())
184 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
186 std::vector<unsigned> annot;
191 if (std::find(annot.begin(), annot.end(), arg->getArgNo()) != annot.end())
203 assert(val.
hasName() &&
"Found texture variable with no name");
208 assert(val.
hasName() &&
"Found surface variable with no name");
213 assert(val.
hasName() &&
"Found sampler variable with no name");
256 if (retval ==
false) {
267 std::vector<unsigned> Vs;
272 for (
int i = 0, e = Vs.size(); i < e; i++) {
274 if ((v >> 16) == index) {
284 for (
int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
286 dyn_cast<ConstantInt>(alignNode->getOperand(i))) {
287 unsigned v = CI->getZExtValue();
288 if ((v >> 16) == index) {
292 if ((v >> 16) > index) {
340 }
else if (ignore_GEP_indices)
341 if (
const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
356 if (processed.find(V) != processed.end())
361 if (V2 != V && processed.find(V2) != processed.end())
363 processed.insert(V2);
373 }
else if (
const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
376 }
else if (
const PHINode *PN = dyn_cast<PHINode>(V)) {
377 if (V != V2 && processed.find(V) != processed.end())
379 processed.insert(PN);
380 const Value *common = 0;
381 for (
unsigned i = 0; i != PN->getNumIncomingValues(); ++i) {
382 const Value *pv = PN->getIncomingValue(i);
387 else if (common != base)
407 return I->getParent();
417 return I->getParent()->getParent();
420 return B->getParent();
467 if (visited->find(
I) != visited->end())
472 for (
unsigned i = 0, e =
I->getNumOperands(); i != e; ++i)
481 std::set<Instruction *> visited;
491 I->getParent()->dump();
495 if (
BasicBlock *B = dyn_cast<BasicBlock>(v)) {
496 B->getParent()->dump();
500 if (
Function *
F = dyn_cast<Function>(v)) {
501 F->getParent()->dump();
const char PropertyAnnotationNames[PROPERTY_LAST+1][AnnotationNameLen+1]
int strcmp(const char *s1, const char *s2);
bool isMemorySpaceTransferIntrinsic(Intrinsic::ID id)
StringRef getString() const
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 &)
The main container class for the LLVM Intermediate Representation.
bool findOneNVVMAnnotation(const llvm::GlobalValue *, std::string, unsigned &)
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getNumOperands() const
getNumOperands - Return number of MDNode operands.
std::string str() const
str - Get the contents as an std::string.
bool isSurface(const llvm::Value &)
bool isKernelFunction(const llvm::Function &)
MDNode - a tuple of other values.
std::string getTextureName(const llvm::Value &)
CallingConv::ID getCallingConv() const
ManagedStatic< per_module_annot_t > annotationCache
StringRef getName() const
Value * getOperand(unsigned i) const LLVM_READONLY
getOperand - Return specified operand.
bool getMaxNTIDz(const llvm::Function &, unsigned &)
BasicBlock * getParentBlock(Value *v)
void dump() const
dump - Support for debugging, callable in GDB: V->dump()
Function * getParentFunction(Value *v)
inst_iterator inst_begin(Function *F)
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 zero extended value.
void dumpInst(Value *base, char *instName)
const char * data() const
void dumpParent(Value *v)
static void cacheAnnotationFromMD(const MDNode *md, key_val_pair_t &retval)
bool getMaxNTIDy(const llvm::Function &, unsigned &)
LLVM Basic Block Representation.
bool isImageWriteOnly(const llvm::Value &)
MDNode * getOperand(unsigned i) const
getOperand - Return specified operand.
void dumpInstRec(Value *v, std::set< Instruction * > *visited)
bool getReqNTIDz(const llvm::Function &, unsigned &)
bool isImageReadOnly(const llvm::Value &)
Class for constant integers.
Instruction * getInst(Value *base, char *instName)
MDNode * getMetadata(unsigned KindID) const
bool getAlign(const llvm::Function &, unsigned index, unsigned &)
Value * stripPointerCasts()
Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value...
static const char * NamedMDForAnnotations
bool getMinCTASm(const llvm::Function &, unsigned &)
bool isImage(const llvm::Value &)
bool isSampler(const llvm::Value &)
const Value * skipPointerTransfer(const Value *V, bool ignore_GEP_indices)
NamedMDNode * getNamedMetadata(const Twine &Name) const
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 > &)
LLVM Value Representation.
unsigned getNumOperands() const
getNumOperands - Return the number of NamedMDNode operands.
inst_iterator inst_end(Function *F)
bool getMaxNTIDx(const llvm::Function &, unsigned &)