LLVM API Documentation

NVPTXUtilities.h
Go to the documentation of this file.
00001 //===-- NVPTXUtilities - Utilities -----------------------------*- C++ -*-====//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the declaration of the NVVM specific utility functions.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
00015 #define LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
00016 
00017 #include "llvm/IR/Function.h"
00018 #include "llvm/IR/GlobalVariable.h"
00019 #include "llvm/IR/IntrinsicInst.h"
00020 #include "llvm/IR/Value.h"
00021 #include <cstdarg>
00022 #include <set>
00023 #include <string>
00024 #include <vector>
00025 
00026 namespace llvm {
00027 
00028 #define NVCL_IMAGE2D_READONLY_FUNCNAME "__is_image2D_readonly"
00029 #define NVCL_IMAGE3D_READONLY_FUNCNAME "__is_image3D_readonly"
00030 
00031 void clearAnnotationCache(const llvm::Module *);
00032 
00033 bool findOneNVVMAnnotation(const llvm::GlobalValue *, std::string, unsigned &);
00034 bool findAllNVVMAnnotation(const llvm::GlobalValue *, std::string,
00035                            std::vector<unsigned> &);
00036 
00037 bool isTexture(const llvm::Value &);
00038 bool isSurface(const llvm::Value &);
00039 bool isSampler(const llvm::Value &);
00040 bool isImage(const llvm::Value &);
00041 bool isImageReadOnly(const llvm::Value &);
00042 bool isImageWriteOnly(const llvm::Value &);
00043 bool isImageReadWrite(const llvm::Value &);
00044 bool isManaged(const llvm::Value &);
00045 
00046 std::string getTextureName(const llvm::Value &);
00047 std::string getSurfaceName(const llvm::Value &);
00048 std::string getSamplerName(const llvm::Value &);
00049 
00050 bool getMaxNTIDx(const llvm::Function &, unsigned &);
00051 bool getMaxNTIDy(const llvm::Function &, unsigned &);
00052 bool getMaxNTIDz(const llvm::Function &, unsigned &);
00053 
00054 bool getReqNTIDx(const llvm::Function &, unsigned &);
00055 bool getReqNTIDy(const llvm::Function &, unsigned &);
00056 bool getReqNTIDz(const llvm::Function &, unsigned &);
00057 
00058 bool getMinCTASm(const llvm::Function &, unsigned &);
00059 bool isKernelFunction(const llvm::Function &);
00060 
00061 bool getAlign(const llvm::Function &, unsigned index, unsigned &);
00062 bool getAlign(const llvm::CallInst &, unsigned index, unsigned &);
00063 
00064 bool isBarrierIntrinsic(llvm::Intrinsic::ID);
00065 
00066 /// make_vector - Helper function which is useful for building temporary vectors
00067 /// to pass into type construction of CallInst ctors.  This turns a null
00068 /// terminated list of pointers (or other value types) into a real live vector.
00069 ///
00070 template <typename T> inline std::vector<T> make_vector(T A, ...) {
00071   va_list Args;
00072   va_start(Args, A);
00073   std::vector<T> Result;
00074   Result.push_back(A);
00075   while (T Val = va_arg(Args, T))
00076     Result.push_back(Val);
00077   va_end(Args);
00078   return Result;
00079 }
00080 
00081 bool isMemorySpaceTransferIntrinsic(Intrinsic::ID id);
00082 const Value *skipPointerTransfer(const Value *V, bool ignore_GEP_indices);
00083 const Value *
00084 skipPointerTransfer(const Value *V, std::set<const Value *> &processed);
00085 BasicBlock *getParentBlock(Value *v);
00086 Function *getParentFunction(Value *v);
00087 void dumpBlock(Value *v, char *blockName);
00088 Instruction *getInst(Value *base, char *instName);
00089 void dumpInst(Value *base, char *instName);
00090 void dumpInstRec(Value *v, std::set<Instruction *> *visited);
00091 void dumpInstRec(Value *v);
00092 void dumpParent(Value *v);
00093 
00094 }
00095 
00096 #endif