LLVM  16.0.0git
NVPTXUtilities.h
Go to the documentation of this file.
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/IR/Function.h"
17 #include "llvm/IR/GlobalVariable.h"
18 #include "llvm/IR/IntrinsicInst.h"
19 #include "llvm/IR/Value.h"
20 #include <cstdarg>
21 #include <set>
22 #include <string>
23 #include <vector>
24 
25 namespace llvm {
26 
27 void clearAnnotationCache(const Module *);
28 
29 bool findOneNVVMAnnotation(const GlobalValue *, const std::string &,
30  unsigned &);
31 bool findAllNVVMAnnotation(const GlobalValue *, const std::string &,
32  std::vector<unsigned> &);
33 
34 bool isTexture(const Value &);
35 bool isSurface(const Value &);
36 bool isSampler(const Value &);
37 bool isImage(const Value &);
38 bool isImageReadOnly(const Value &);
39 bool isImageWriteOnly(const Value &);
40 bool isImageReadWrite(const Value &);
41 bool isManaged(const Value &);
42 
43 std::string getTextureName(const Value &);
44 std::string getSurfaceName(const Value &);
45 std::string getSamplerName(const Value &);
46 
47 bool getMaxNTIDx(const Function &, unsigned &);
48 bool getMaxNTIDy(const Function &, unsigned &);
49 bool getMaxNTIDz(const Function &, unsigned &);
50 
51 bool getReqNTIDx(const Function &, unsigned &);
52 bool getReqNTIDy(const Function &, unsigned &);
53 bool getReqNTIDz(const Function &, unsigned &);
54 
55 bool getMinCTASm(const Function &, unsigned &);
56 bool getMaxNReg(const Function &, unsigned &);
57 bool isKernelFunction(const Function &);
58 
59 bool getAlign(const Function &, unsigned index, unsigned &);
60 bool getAlign(const CallInst &, unsigned index, unsigned &);
61 
62 // PTX ABI requires all scalar argument/return values to have
63 // bit-size as a power of two of at least 32 bits.
64 inline unsigned promoteScalarArgumentSize(unsigned size) {
65  if (size <= 32)
66  return 32;
67  else if (size <= 64)
68  return 64;
69  else
70  return size;
71 }
72 }
73 
74 #endif
llvm::getReqNTIDx
bool getReqNTIDx(const Function &F, unsigned &x)
Definition: NVPTXUtilities.cpp:264
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
IntrinsicInst.h
llvm::isImageReadWrite
bool isImageReadWrite(const Value &val)
Definition: NVPTXUtilities.cpp:210
llvm::getMinCTASm
bool getMinCTASm(const Function &F, unsigned &x)
Definition: NVPTXUtilities.cpp:276
llvm::isImage
bool isImage(const Value &val)
Definition: NVPTXUtilities.cpp:222
llvm::isTexture
bool isTexture(const Value &val)
Definition: NVPTXUtilities.cpp:143
llvm::isSampler
bool isSampler(const Value &val)
Definition: NVPTXUtilities.cpp:165
llvm::getReqNTIDy
bool getReqNTIDy(const Function &F, unsigned &y)
Definition: NVPTXUtilities.cpp:268
llvm::getSamplerName
std::string getSamplerName(const Value &val)
Definition: NVPTXUtilities.cpp:247
llvm::getReqNTIDz
bool getReqNTIDz(const Function &F, unsigned &z)
Definition: NVPTXUtilities.cpp:272
llvm::promoteScalarArgumentSize
unsigned promoteScalarArgumentSize(unsigned size)
Definition: NVPTXUtilities.h:64
llvm::isKernelFunction
bool isKernelFunction(const Function &F)
Definition: NVPTXUtilities.cpp:284
llvm::findOneNVVMAnnotation
bool findOneNVVMAnnotation(const GlobalValue *gv, const std::string &prop, unsigned &retval)
Definition: NVPTXUtilities.cpp:113
index
splat index
Definition: README_ALTIVEC.txt:181
llvm::isImageReadOnly
bool isImageReadOnly(const Value &val)
Definition: NVPTXUtilities.cpp:186
llvm::size
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1571
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::getMaxNTIDz
bool getMaxNTIDz(const Function &F, unsigned &z)
Definition: NVPTXUtilities.cpp:260
GlobalVariable.h
llvm::isSurface
bool isSurface(const Value &val)
Definition: NVPTXUtilities.cpp:154
Function.h
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::getAlign
bool getAlign(const Function &F, unsigned index, unsigned &align)
Definition: NVPTXUtilities.cpp:294
llvm::getSurfaceName
std::string getSurfaceName(const Value &val)
Definition: NVPTXUtilities.cpp:242
llvm::getMaxNTIDy
bool getMaxNTIDy(const Function &F, unsigned &y)
Definition: NVPTXUtilities.cpp:256
llvm::isImageWriteOnly
bool isImageWriteOnly(const Value &val)
Definition: NVPTXUtilities.cpp:198
llvm::clearAnnotationCache
void clearAnnotationCache(const Module *Mod)
Definition: NVPTXUtilities.cpp:46
llvm::getMaxNTIDx
bool getMaxNTIDx(const Function &F, unsigned &x)
Definition: NVPTXUtilities.cpp:252
llvm::getTextureName
std::string getTextureName(const Value &val)
Definition: NVPTXUtilities.cpp:237
llvm::getMaxNReg
bool getMaxNReg(const Function &F, unsigned &x)
Definition: NVPTXUtilities.cpp:280
Value.h
llvm::isManaged
bool isManaged(const Value &val)
Definition: NVPTXUtilities.cpp:226
llvm::findAllNVVMAnnotation
bool findAllNVVMAnnotation(const GlobalValue *gv, const std::string &prop, std::vector< unsigned > &retval)
Definition: NVPTXUtilities.cpp:128