Index: llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXBaseInfo.h =================================================================== --- llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXBaseInfo.h +++ llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXBaseInfo.h @@ -30,60 +30,6 @@ ADDRESS_SPACE_PARAM = 101 }; -enum PropertyAnnotation { - PROPERTY_MAXNTID_X = 0, - PROPERTY_MAXNTID_Y, - PROPERTY_MAXNTID_Z, - PROPERTY_REQNTID_X, - PROPERTY_REQNTID_Y, - PROPERTY_REQNTID_Z, - PROPERTY_MINNCTAPERSM, - PROPERTY_ISTEXTURE, - PROPERTY_ISSURFACE, - PROPERTY_ISSAMPLER, - PROPERTY_ISREADONLY_IMAGE_PARAM, - PROPERTY_ISWRITEONLY_IMAGE_PARAM, - PROPERTY_ISREADWRITE_IMAGE_PARAM, - PROPERTY_ISKERNEL_FUNCTION, - PROPERTY_ALIGN, - PROPERTY_MANAGED, - - // last property - PROPERTY_LAST -}; - -const unsigned AnnotationNameLen = 9; // length of each annotation name -const char PropertyAnnotationNames[PROPERTY_LAST + 1][AnnotationNameLen + 1] = { - "maxntidx", // PROPERTY_MAXNTID_X - "maxntidy", // PROPERTY_MAXNTID_Y - "maxntidz", // PROPERTY_MAXNTID_Z - "reqntidx", // PROPERTY_REQNTID_X - "reqntidy", // PROPERTY_REQNTID_Y - "reqntidz", // PROPERTY_REQNTID_Z - "minctasm", // PROPERTY_MINNCTAPERSM - "texture", // PROPERTY_ISTEXTURE - "surface", // PROPERTY_ISSURFACE - "sampler", // PROPERTY_ISSAMPLER - "rdoimage", // PROPERTY_ISREADONLY_IMAGE_PARAM - "wroimage", // PROPERTY_ISWRITEONLY_IMAGE_PARAM - "rdwrimage", // PROPERTY_ISREADWRITE_IMAGE_PARAM - "kernel", // PROPERTY_ISKERNEL_FUNCTION - "align", // PROPERTY_ALIGN - "managed", // PROPERTY_MANAGED - - // last property - "proplast", // PROPERTY_LAST -}; - -// name of named metadata used for global annotations -#if defined(__GNUC__) -// As this is declared to be static but some of the .cpp files that -// include NVVM.h do not use this array, gcc gives a warning when -// compiling those .cpp files, hence __attribute__((unused)). -__attribute__((unused)) -#endif - static const char *NamedMDForAnnotations = "nvvm.annotations"; - namespace NVPTXII { enum { // These must be kept in sync with TSFlags in NVPTXInstrFormats.td @@ -94,7 +40,7 @@ IsSurfTexQueryFlag = 0x800, IsTexModeUnifiedFlag = 0x1000 }; -} -} +} // namespace NVPTXII +} // namespace llvm #endif Index: llvm/lib/Target/NVPTX/NVPTXUtilities.cpp =================================================================== --- llvm/lib/Target/NVPTX/NVPTXUtilities.cpp +++ llvm/lib/Target/NVPTX/NVPTXUtilities.cpp @@ -68,7 +68,7 @@ static void cacheAnnotationFromMD(const Module *m, const GlobalValue *gv) { MutexGuard Guard(Lock); - NamedMDNode *NMD = m->getNamedMetadata(llvm::NamedMDForAnnotations); + NamedMDNode *NMD = m->getNamedMetadata("nvvm.annotations"); if (!NMD) return; key_val_pair_t tmp; @@ -130,9 +130,7 @@ bool llvm::isTexture(const llvm::Value &val) { if (const GlobalValue *gv = dyn_cast(&val)) { unsigned annot; - if (llvm::findOneNVVMAnnotation( - gv, llvm::PropertyAnnotationNames[llvm::PROPERTY_ISTEXTURE], - annot)) { + if (llvm::findOneNVVMAnnotation(gv, "texture", annot)) { assert((annot == 1) && "Unexpected annotation on a texture symbol"); return true; } @@ -143,9 +141,7 @@ bool llvm::isSurface(const llvm::Value &val) { if (const GlobalValue *gv = dyn_cast(&val)) { unsigned annot; - if (llvm::findOneNVVMAnnotation( - gv, llvm::PropertyAnnotationNames[llvm::PROPERTY_ISSURFACE], - annot)) { + if (llvm::findOneNVVMAnnotation(gv, "surface", annot)) { assert((annot == 1) && "Unexpected annotation on a surface symbol"); return true; } @@ -154,11 +150,11 @@ } bool llvm::isSampler(const llvm::Value &val) { + const char *AnnotationName = "sampler"; + if (const GlobalValue *gv = dyn_cast(&val)) { unsigned annot; - if (llvm::findOneNVVMAnnotation( - gv, llvm::PropertyAnnotationNames[llvm::PROPERTY_ISSAMPLER], - annot)) { + if (llvm::findOneNVVMAnnotation(gv, AnnotationName, annot)) { assert((annot == 1) && "Unexpected annotation on a sampler symbol"); return true; } @@ -166,9 +162,7 @@ if (const Argument *arg = dyn_cast(&val)) { const Function *func = arg->getParent(); std::vector annot; - if (llvm::findAllNVVMAnnotation( - func, llvm::PropertyAnnotationNames[llvm::PROPERTY_ISSAMPLER], - annot)) { + if (llvm::findAllNVVMAnnotation(func, AnnotationName, annot)) { if (is_contained(annot, arg->getArgNo())) return true; } @@ -180,10 +174,7 @@ if (const Argument *arg = dyn_cast(&val)) { const Function *func = arg->getParent(); std::vector annot; - if (llvm::findAllNVVMAnnotation(func, - llvm::PropertyAnnotationNames[ - llvm::PROPERTY_ISREADONLY_IMAGE_PARAM], - annot)) { + if (llvm::findAllNVVMAnnotation(func, "rdoimage", annot)) { if (is_contained(annot, arg->getArgNo())) return true; } @@ -195,10 +186,7 @@ if (const Argument *arg = dyn_cast(&val)) { const Function *func = arg->getParent(); std::vector annot; - if (llvm::findAllNVVMAnnotation(func, - llvm::PropertyAnnotationNames[ - llvm::PROPERTY_ISWRITEONLY_IMAGE_PARAM], - annot)) { + if (llvm::findAllNVVMAnnotation(func, "wroimage", annot)) { if (is_contained(annot, arg->getArgNo())) return true; } @@ -210,10 +198,7 @@ if (const Argument *arg = dyn_cast(&val)) { const Function *func = arg->getParent(); std::vector annot; - if (llvm::findAllNVVMAnnotation(func, - llvm::PropertyAnnotationNames[ - llvm::PROPERTY_ISREADWRITE_IMAGE_PARAM], - annot)) { + if (llvm::findAllNVVMAnnotation(func, "rdwrimage", annot)) { if (is_contained(annot, arg->getArgNo())) return true; } @@ -229,9 +214,7 @@ bool llvm::isManaged(const llvm::Value &val) { if(const GlobalValue *gv = dyn_cast(&val)) { unsigned annot; - if(llvm::findOneNVVMAnnotation(gv, - llvm::PropertyAnnotationNames[llvm::PROPERTY_MANAGED], - annot)) { + if (llvm::findOneNVVMAnnotation(gv, "managed", annot)) { assert((annot == 1) && "Unexpected annotation on a managed symbol"); return true; } @@ -255,44 +238,36 @@ } bool llvm::getMaxNTIDx(const Function &F, unsigned &x) { - return (llvm::findOneNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_MAXNTID_X], x)); + return llvm::findOneNVVMAnnotation(&F, "maxntidx", x); } bool llvm::getMaxNTIDy(const Function &F, unsigned &y) { - return (llvm::findOneNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_MAXNTID_Y], y)); + return llvm::findOneNVVMAnnotation(&F, "maxntidy", y); } bool llvm::getMaxNTIDz(const Function &F, unsigned &z) { - return (llvm::findOneNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_MAXNTID_Z], z)); + return llvm::findOneNVVMAnnotation(&F, "maxntidz", z); } bool llvm::getReqNTIDx(const Function &F, unsigned &x) { - return (llvm::findOneNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_REQNTID_X], x)); + return llvm::findOneNVVMAnnotation(&F, "reqntidx", x); } bool llvm::getReqNTIDy(const Function &F, unsigned &y) { - return (llvm::findOneNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_REQNTID_Y], y)); + return llvm::findOneNVVMAnnotation(&F, "reqntidy", y); } bool llvm::getReqNTIDz(const Function &F, unsigned &z) { - return (llvm::findOneNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_REQNTID_Z], z)); + return llvm::findOneNVVMAnnotation(&F, "reqntidz", z); } bool llvm::getMinCTASm(const Function &F, unsigned &x) { - return (llvm::findOneNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_MINNCTAPERSM], x)); + return llvm::findOneNVVMAnnotation(&F, "minctasm", x); } bool llvm::isKernelFunction(const Function &F) { unsigned x = 0; - bool retval = llvm::findOneNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_ISKERNEL_FUNCTION], x); + bool retval = llvm::findOneNVVMAnnotation(&F, "kernel", x); if (!retval) { // There is no NVVM metadata, check the calling convention return F.getCallingConv() == llvm::CallingConv::PTX_Kernel; @@ -302,8 +277,7 @@ bool llvm::getAlign(const Function &F, unsigned index, unsigned &align) { std::vector Vs; - bool retval = llvm::findAllNVVMAnnotation( - &F, llvm::PropertyAnnotationNames[llvm::PROPERTY_ALIGN], Vs); + bool retval = llvm::findAllNVVMAnnotation(&F, "align", Vs); if (!retval) return false; for (int i = 0, e = Vs.size(); i < e; i++) {