1*9880d681SAndroid Build Coastguard Worker //===-- NVPTXUtilities - Utilities -----------------------------*- C++ -*-====// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file contains the declaration of the NVVM specific utility functions. 11*9880d681SAndroid Build Coastguard Worker // 12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H 15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/Function.h" 18*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/GlobalVariable.h" 19*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/IntrinsicInst.h" 20*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/Value.h" 21*9880d681SAndroid Build Coastguard Worker #include <cstdarg> 22*9880d681SAndroid Build Coastguard Worker #include <set> 23*9880d681SAndroid Build Coastguard Worker #include <string> 24*9880d681SAndroid Build Coastguard Worker #include <vector> 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker namespace llvm { 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker #define NVCL_IMAGE2D_READONLY_FUNCNAME "__is_image2D_readonly" 29*9880d681SAndroid Build Coastguard Worker #define NVCL_IMAGE3D_READONLY_FUNCNAME "__is_image3D_readonly" 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker void clearAnnotationCache(const llvm::Module *); 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Worker bool findOneNVVMAnnotation(const llvm::GlobalValue *, const std::string &, 34*9880d681SAndroid Build Coastguard Worker unsigned &); 35*9880d681SAndroid Build Coastguard Worker bool findAllNVVMAnnotation(const llvm::GlobalValue *, const std::string &, 36*9880d681SAndroid Build Coastguard Worker std::vector<unsigned> &); 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Worker bool isTexture(const llvm::Value &); 39*9880d681SAndroid Build Coastguard Worker bool isSurface(const llvm::Value &); 40*9880d681SAndroid Build Coastguard Worker bool isSampler(const llvm::Value &); 41*9880d681SAndroid Build Coastguard Worker bool isImage(const llvm::Value &); 42*9880d681SAndroid Build Coastguard Worker bool isImageReadOnly(const llvm::Value &); 43*9880d681SAndroid Build Coastguard Worker bool isImageWriteOnly(const llvm::Value &); 44*9880d681SAndroid Build Coastguard Worker bool isImageReadWrite(const llvm::Value &); 45*9880d681SAndroid Build Coastguard Worker bool isManaged(const llvm::Value &); 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Worker std::string getTextureName(const llvm::Value &); 48*9880d681SAndroid Build Coastguard Worker std::string getSurfaceName(const llvm::Value &); 49*9880d681SAndroid Build Coastguard Worker std::string getSamplerName(const llvm::Value &); 50*9880d681SAndroid Build Coastguard Worker 51*9880d681SAndroid Build Coastguard Worker bool getMaxNTIDx(const llvm::Function &, unsigned &); 52*9880d681SAndroid Build Coastguard Worker bool getMaxNTIDy(const llvm::Function &, unsigned &); 53*9880d681SAndroid Build Coastguard Worker bool getMaxNTIDz(const llvm::Function &, unsigned &); 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker bool getReqNTIDx(const llvm::Function &, unsigned &); 56*9880d681SAndroid Build Coastguard Worker bool getReqNTIDy(const llvm::Function &, unsigned &); 57*9880d681SAndroid Build Coastguard Worker bool getReqNTIDz(const llvm::Function &, unsigned &); 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker bool getMinCTASm(const llvm::Function &, unsigned &); 60*9880d681SAndroid Build Coastguard Worker bool isKernelFunction(const llvm::Function &); 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Worker bool getAlign(const llvm::Function &, unsigned index, unsigned &); 63*9880d681SAndroid Build Coastguard Worker bool getAlign(const llvm::CallInst &, unsigned index, unsigned &); 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Worker BasicBlock *getParentBlock(Value *v); 66*9880d681SAndroid Build Coastguard Worker Function *getParentFunction(Value *v); 67*9880d681SAndroid Build Coastguard Worker void dumpBlock(Value *v, char *blockName); 68*9880d681SAndroid Build Coastguard Worker Instruction *getInst(Value *base, char *instName); 69*9880d681SAndroid Build Coastguard Worker void dumpInst(Value *base, char *instName); 70*9880d681SAndroid Build Coastguard Worker void dumpInstRec(Value *v, std::set<Instruction *> *visited); 71*9880d681SAndroid Build Coastguard Worker void dumpInstRec(Value *v); 72*9880d681SAndroid Build Coastguard Worker void dumpParent(Value *v); 73*9880d681SAndroid Build Coastguard Worker 74*9880d681SAndroid Build Coastguard Worker } 75*9880d681SAndroid Build Coastguard Worker 76*9880d681SAndroid Build Coastguard Worker #endif 77