LLVM  3.7.0
NVPTXUtilities.h
Go to the documentation of this file.
1 //===-- NVPTXUtilities - Utilities -----------------------------*- C++ -*-====//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declaration of the NVVM specific utility functions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
16 
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/GlobalVariable.h"
19 #include "llvm/IR/IntrinsicInst.h"
20 #include "llvm/IR/Value.h"
21 #include <cstdarg>
22 #include <set>
23 #include <string>
24 #include <vector>
25 
26 namespace llvm {
27 
28 #define NVCL_IMAGE2D_READONLY_FUNCNAME "__is_image2D_readonly"
29 #define NVCL_IMAGE3D_READONLY_FUNCNAME "__is_image3D_readonly"
30 
32 
33 bool findOneNVVMAnnotation(const llvm::GlobalValue *, std::string, unsigned &);
34 bool findAllNVVMAnnotation(const llvm::GlobalValue *, std::string,
35  std::vector<unsigned> &);
36 
37 bool isTexture(const llvm::Value &);
38 bool isSurface(const llvm::Value &);
39 bool isSampler(const llvm::Value &);
40 bool isImage(const llvm::Value &);
41 bool isImageReadOnly(const llvm::Value &);
42 bool isImageWriteOnly(const llvm::Value &);
43 bool isImageReadWrite(const llvm::Value &);
44 bool isManaged(const llvm::Value &);
45 
46 std::string getTextureName(const llvm::Value &);
47 std::string getSurfaceName(const llvm::Value &);
48 std::string getSamplerName(const llvm::Value &);
49 
50 bool getMaxNTIDx(const llvm::Function &, unsigned &);
51 bool getMaxNTIDy(const llvm::Function &, unsigned &);
52 bool getMaxNTIDz(const llvm::Function &, unsigned &);
53 
54 bool getReqNTIDx(const llvm::Function &, unsigned &);
55 bool getReqNTIDy(const llvm::Function &, unsigned &);
56 bool getReqNTIDz(const llvm::Function &, unsigned &);
57 
58 bool getMinCTASm(const llvm::Function &, unsigned &);
59 bool isKernelFunction(const llvm::Function &);
60 
61 bool getAlign(const llvm::Function &, unsigned index, unsigned &);
62 bool getAlign(const llvm::CallInst &, unsigned index, unsigned &);
63 
65 
66 /// make_vector - Helper function which is useful for building temporary vectors
67 /// to pass into type construction of CallInst ctors. This turns a null
68 /// terminated list of pointers (or other value types) into a real live vector.
69 ///
70 template <typename T> inline std::vector<T> make_vector(T A, ...) {
71  va_list Args;
72  va_start(Args, A);
73  std::vector<T> Result;
74  Result.push_back(A);
75  while (T Val = va_arg(Args, T))
76  Result.push_back(Val);
77  va_end(Args);
78  return Result;
79 }
80 
82 const Value *skipPointerTransfer(const Value *V, bool ignore_GEP_indices);
83 const Value *
84 skipPointerTransfer(const Value *V, std::set<const Value *> &processed);
85 BasicBlock *getParentBlock(Value *v);
86 Function *getParentFunction(Value *v);
87 void dumpBlock(Value *v, char *blockName);
88 Instruction *getInst(Value *base, char *instName);
89 void dumpInst(Value *base, char *instName);
90 void dumpInstRec(Value *v, std::set<Instruction *> *visited);
91 void dumpInstRec(Value *v);
92 void dumpParent(Value *v);
93 
94 }
95 
96 #endif
bool isMemorySpaceTransferIntrinsic(Intrinsic::ID id)
std::string getSurfaceName(const llvm::Value &)
bool getReqNTIDy(const llvm::Function &, unsigned &)
Various leaf nodes.
Definition: ISDOpcodes.h:60
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
bool findOneNVVMAnnotation(const llvm::GlobalValue *, std::string, unsigned &)
CallInst - This class represents a function call, abstracting a target machine's calling convention...
bool isSurface(const llvm::Value &)
bool isKernelFunction(const llvm::Function &)
std::string getTextureName(const llvm::Value &)
bool getMaxNTIDz(const llvm::Function &, unsigned &)
BasicBlock * getParentBlock(Value *v)
Function * getParentFunction(Value *v)
bool isManaged(const llvm::Value &)
bool getReqNTIDx(const llvm::Function &, unsigned &)
void dumpBlock(Value *v, char *blockName)
void dumpInst(Value *base, char *instName)
void dumpParent(Value *v)
bool isImageReadWrite(const llvm::Value &)
void clearAnnotationCache(const llvm::Module *)
bool getMaxNTIDy(const llvm::Function &, unsigned &)
bool isImageWriteOnly(const llvm::Value &)
void dumpInstRec(Value *v, std::set< Instruction * > *visited)
bool getReqNTIDz(const llvm::Function &, unsigned &)
bool isImageReadOnly(const llvm::Value &)
std::vector< T > make_vector(T A,...)
make_vector - Helper function which is useful for building temporary vectors to pass into type constr...
Instruction * getInst(Value *base, char *instName)
bool getAlign(const llvm::Function &, unsigned index, unsigned &)
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)
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.
Definition: Value.h:69
bool getMaxNTIDx(const llvm::Function &, unsigned &)