blob: ec5bfc17afc7006ae3e86790cfe73fc9b657f7ab [file] [log] [blame]
Justin Holewinskiae556d32012-05-04 20:18:50 +00001//===-- 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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
15#define LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
Justin Holewinskiae556d32012-05-04 20:18:50 +000016
Chandler Carruth9fb823b2013-01-02 11:36:10 +000017#include "llvm/IR/Function.h"
18#include "llvm/IR/GlobalVariable.h"
19#include "llvm/IR/IntrinsicInst.h"
20#include "llvm/IR/Value.h"
Justin Holewinskiae556d32012-05-04 20:18:50 +000021#include <cstdarg>
22#include <set>
23#include <string>
24#include <vector>
25
Justin Holewinski0497ab12013-03-30 14:29:21 +000026namespace llvm {
Justin Holewinskiae556d32012-05-04 20:18:50 +000027
28#define NVCL_IMAGE2D_READONLY_FUNCNAME "__is_image2D_readonly"
29#define NVCL_IMAGE3D_READONLY_FUNCNAME "__is_image3D_readonly"
30
Justin Holewinski59596952014-04-09 15:38:52 +000031void clearAnnotationCache(const llvm::Module *);
32
Benjamin Kramerc321e532016-06-08 19:09:22 +000033bool findOneNVVMAnnotation(const llvm::GlobalValue *, const std::string &,
34 unsigned &);
35bool findAllNVVMAnnotation(const llvm::GlobalValue *, const std::string &,
Justin Holewinskiae556d32012-05-04 20:18:50 +000036 std::vector<unsigned> &);
37
38bool isTexture(const llvm::Value &);
39bool isSurface(const llvm::Value &);
40bool isSampler(const llvm::Value &);
41bool isImage(const llvm::Value &);
42bool isImageReadOnly(const llvm::Value &);
43bool isImageWriteOnly(const llvm::Value &);
Justin Holewinski59596952014-04-09 15:38:52 +000044bool isImageReadWrite(const llvm::Value &);
45bool isManaged(const llvm::Value &);
Justin Holewinskiae556d32012-05-04 20:18:50 +000046
47std::string getTextureName(const llvm::Value &);
48std::string getSurfaceName(const llvm::Value &);
49std::string getSamplerName(const llvm::Value &);
50
51bool getMaxNTIDx(const llvm::Function &, unsigned &);
52bool getMaxNTIDy(const llvm::Function &, unsigned &);
53bool getMaxNTIDz(const llvm::Function &, unsigned &);
54
55bool getReqNTIDx(const llvm::Function &, unsigned &);
56bool getReqNTIDy(const llvm::Function &, unsigned &);
57bool getReqNTIDz(const llvm::Function &, unsigned &);
58
59bool getMinCTASm(const llvm::Function &, unsigned &);
60bool isKernelFunction(const llvm::Function &);
61
62bool getAlign(const llvm::Function &, unsigned index, unsigned &);
63bool getAlign(const llvm::CallInst &, unsigned index, unsigned &);
64
Justin Holewinskiae556d32012-05-04 20:18:50 +000065BasicBlock *getParentBlock(Value *v);
66Function *getParentFunction(Value *v);
67void dumpBlock(Value *v, char *blockName);
68Instruction *getInst(Value *base, char *instName);
69void dumpInst(Value *base, char *instName);
70void dumpInstRec(Value *v, std::set<Instruction *> *visited);
71void dumpInstRec(Value *v);
72void dumpParent(Value *v);
73
Alexander Kornienkof00654e2015-06-23 09:49:53 +000074}
Justin Holewinskiae556d32012-05-04 20:18:50 +000075
76#endif