32 typedef std::map<std::string, std::vector<unsigned> > key_val_pair_t;
33 typedef std::map<const GlobalValue *, key_val_pair_t> global_val_annot_t;
34 typedef std::map<const Module *, global_val_annot_t> per_module_annot_t;
42 annotationCache->erase(Mod);
47 assert(md &&
"Invalid mdnode for annotation");
54 assert(prop &&
"Annotation property not a string");
58 assert(Val &&
"Value operand not a constant int");
61 if (retval.find(keyname) != retval.end())
64 std::vector<unsigned> tmp;
66 retval[keyname] = tmp;
81 mdconst::dyn_extract_or_null<GlobalValue>(elem->
getOperand(0));
95 if ((*annotationCache).find(m) != (*annotationCache).end())
96 (*annotationCache)[m][gv] = std::move(tmp);
98 global_val_annot_t tmp1;
99 tmp1[gv] = std::move(tmp);
100 (*annotationCache)[m] = std::move(tmp1);
108 if ((*annotationCache).find(m) == (*annotationCache).end())
110 else if ((*annotationCache)[m].find(gv) == (*annotationCache)[m].end())
112 if ((*annotationCache)[m][gv].find(prop) == (*annotationCache)[m][gv].end())
114 retval = (*annotationCache)[m][gv][prop][0];
119 std::vector<unsigned> &retval) {
122 if ((*annotationCache).find(m) == (*annotationCache).end())
124 else if ((*annotationCache)[m].find(gv) == (*annotationCache)[m].end())
126 if ((*annotationCache)[m][gv].find(prop) == (*annotationCache)[m][gv].end())
128 retval = (*annotationCache)[m][gv][prop];
133 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)) {
147 assert((annot == 1) &&
"Unexpected annotation on a surface symbol");
155 const char *AnnotationName =
"sampler";
157 if (
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
160 assert((annot == 1) &&
"Unexpected annotation on a sampler symbol");
164 if (
const Argument *arg = dyn_cast<Argument>(&val)) {
166 std::vector<unsigned> annot;
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;
216 if(
const GlobalValue *gv = dyn_cast<GlobalValue>(&val)) {
219 assert((annot == 1) &&
"Unexpected annotation on a managed symbol");
227 assert(val.
hasName() &&
"Found texture variable with no name");
232 assert(val.
hasName() &&
"Found surface variable with no name");
237 assert(val.
hasName() &&
"Found sampler variable with no name");
284 std::vector<unsigned> Vs;
288 for (
int i = 0, e = Vs.size(); i < e; i++) {
290 if ((v >> 16) == index) {
300 for (
int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
302 mdconst::dyn_extract<ConstantInt>(alignNode->getOperand(i))) {
303 unsigned v = CI->getZExtValue();
304 if ((v >> 16) == index) {
308 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.
bool isSampler(const Value &val)
StringRef getString() const
Instances of this class acquire a given Mutex Lock when constructed and hold that lock until destruct...
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...
PTX_Kernel - Call to a PTX kernel.
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.