xref: /freebsd/contrib/llvm-project/llvm/lib/Target/NVPTX/NVPTXUtilities.h (revision a8089ea5aee578e08acab2438e82fc9a9ae50ed8)
1 //===-- NVPTXUtilities - Utilities -----------------------------*- C++ -*-====//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the NVVM specific utility functions.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
14 #define LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
15 
16 #include "llvm/CodeGen/ValueTypes.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"
21 #include <cstdarg>
22 #include <set>
23 #include <string>
24 #include <vector>
25 
26 namespace llvm {
27 
28 class TargetMachine;
29 
30 void clearAnnotationCache(const Module *);
31 
32 bool findOneNVVMAnnotation(const GlobalValue *, const std::string &,
33                            unsigned &);
34 bool findAllNVVMAnnotation(const GlobalValue *, const std::string &,
35                            std::vector<unsigned> &);
36 
37 bool isTexture(const Value &);
38 bool isSurface(const Value &);
39 bool isSampler(const Value &);
40 bool isImage(const Value &);
41 bool isImageReadOnly(const Value &);
42 bool isImageWriteOnly(const Value &);
43 bool isImageReadWrite(const Value &);
44 bool isManaged(const Value &);
45 
46 std::string getTextureName(const Value &);
47 std::string getSurfaceName(const Value &);
48 std::string getSamplerName(const Value &);
49 
50 bool getMaxNTIDx(const Function &, unsigned &);
51 bool getMaxNTIDy(const Function &, unsigned &);
52 bool getMaxNTIDz(const Function &, unsigned &);
53 
54 bool getReqNTIDx(const Function &, unsigned &);
55 bool getReqNTIDy(const Function &, unsigned &);
56 bool getReqNTIDz(const Function &, unsigned &);
57 
58 bool getMaxClusterRank(const Function &, unsigned &);
59 bool getMinCTASm(const Function &, unsigned &);
60 bool getMaxNReg(const Function &, unsigned &);
61 bool isKernelFunction(const Function &);
62 
63 bool getAlign(const Function &, unsigned index, unsigned &);
64 bool getAlign(const CallInst &, unsigned index, unsigned &);
65 Function *getMaybeBitcastedCallee(const CallBase *CB);
66 
67 // PTX ABI requires all scalar argument/return values to have
68 // bit-size as a power of two of at least 32 bits.
69 inline unsigned promoteScalarArgumentSize(unsigned size) {
70   if (size <= 32)
71     return 32;
72   else if (size <= 64)
73     return 64;
74   else
75     return size;
76 }
77 
78 bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM);
79 
80 bool Isv2x16VT(EVT VT);
81 }
82 
83 #endif
84