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