]> git.proxmox.com Git - rustc.git/blame - src/llvm/lib/Target/NVPTX/NVPTXUtilities.h
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / lib / Target / NVPTX / NVPTXUtilities.h
CommitLineData
223e47cc
LB
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
1a4d82fc
JJ
14#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
15#define LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
223e47cc 16
970d7e83
LB
17#include "llvm/IR/Function.h"
18#include "llvm/IR/GlobalVariable.h"
19#include "llvm/IR/IntrinsicInst.h"
20#include "llvm/IR/Value.h"
223e47cc
LB
21#include <cstdarg>
22#include <set>
23#include <string>
24#include <vector>
25
1a4d82fc 26namespace llvm {
223e47cc
LB
27
28#define NVCL_IMAGE2D_READONLY_FUNCNAME "__is_image2D_readonly"
29#define NVCL_IMAGE3D_READONLY_FUNCNAME "__is_image3D_readonly"
30
1a4d82fc
JJ
31void clearAnnotationCache(const llvm::Module *);
32
223e47cc
LB
33bool findOneNVVMAnnotation(const llvm::GlobalValue *, std::string, unsigned &);
34bool findAllNVVMAnnotation(const llvm::GlobalValue *, std::string,
35 std::vector<unsigned> &);
36
37bool isTexture(const llvm::Value &);
38bool isSurface(const llvm::Value &);
39bool isSampler(const llvm::Value &);
40bool isImage(const llvm::Value &);
41bool isImageReadOnly(const llvm::Value &);
42bool isImageWriteOnly(const llvm::Value &);
1a4d82fc
JJ
43bool isImageReadWrite(const llvm::Value &);
44bool isManaged(const llvm::Value &);
223e47cc
LB
45
46std::string getTextureName(const llvm::Value &);
47std::string getSurfaceName(const llvm::Value &);
48std::string getSamplerName(const llvm::Value &);
49
50bool getMaxNTIDx(const llvm::Function &, unsigned &);
51bool getMaxNTIDy(const llvm::Function &, unsigned &);
52bool getMaxNTIDz(const llvm::Function &, unsigned &);
53
54bool getReqNTIDx(const llvm::Function &, unsigned &);
55bool getReqNTIDy(const llvm::Function &, unsigned &);
56bool getReqNTIDz(const llvm::Function &, unsigned &);
57
58bool getMinCTASm(const llvm::Function &, unsigned &);
59bool isKernelFunction(const llvm::Function &);
60
61bool getAlign(const llvm::Function &, unsigned index, unsigned &);
62bool getAlign(const llvm::CallInst &, unsigned index, unsigned &);
63
64bool isBarrierIntrinsic(llvm::Intrinsic::ID);
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///
1a4d82fc 70template <typename T> inline std::vector<T> make_vector(T A, ...) {
223e47cc
LB
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
81bool isMemorySpaceTransferIntrinsic(Intrinsic::ID id);
82const Value *skipPointerTransfer(const Value *V, bool ignore_GEP_indices);
1a4d82fc
JJ
83const Value *
84skipPointerTransfer(const Value *V, std::set<const Value *> &processed);
223e47cc
LB
85BasicBlock *getParentBlock(Value *v);
86Function *getParentFunction(Value *v);
87void dumpBlock(Value *v, char *blockName);
88Instruction *getInst(Value *base, char *instName);
89void dumpInst(Value *base, char *instName);
90void dumpInstRec(Value *v, std::set<Instruction *> *visited);
91void dumpInstRec(Value *v);
92void dumpParent(Value *v);
93
94}
95
96#endif