LLVM 19.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
17#include "llvm/IR/Function.h"
20#include "llvm/IR/Value.h"
21#include <cstdarg>
22#include <set>
23#include <string>
24#include <vector>
25
26namespace llvm {
27
28class TargetMachine;
29
30void clearAnnotationCache(const Module *);
31
32bool findOneNVVMAnnotation(const GlobalValue *, const std::string &,
33 unsigned &);
34bool findAllNVVMAnnotation(const GlobalValue *, const std::string &,
35 std::vector<unsigned> &);
36
37bool isTexture(const Value &);
38bool isSurface(const Value &);
39bool isSampler(const Value &);
40bool isImage(const Value &);
41bool isImageReadOnly(const Value &);
42bool isImageWriteOnly(const Value &);
43bool isImageReadWrite(const Value &);
44bool isManaged(const Value &);
45
46std::string getTextureName(const Value &);
47std::string getSurfaceName(const Value &);
48std::string getSamplerName(const Value &);
49
50bool getMaxNTIDx(const Function &, unsigned &);
51bool getMaxNTIDy(const Function &, unsigned &);
52bool getMaxNTIDz(const Function &, unsigned &);
53
54bool getReqNTIDx(const Function &, unsigned &);
55bool getReqNTIDy(const Function &, unsigned &);
56bool getReqNTIDz(const Function &, unsigned &);
57
58bool getMaxClusterRank(const Function &, unsigned &);
59bool getMinCTASm(const Function &, unsigned &);
60bool getMaxNReg(const Function &, unsigned &);
61bool isKernelFunction(const Function &);
62
63bool getAlign(const Function &, unsigned index, unsigned &);
64bool getAlign(const CallInst &, unsigned index, unsigned &);
65Function *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.
69inline 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
78bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM);
79
80bool Isv2x16VT(EVT VT);
81}
82
83#endif
Machine Check Debug Module
const char LLVMTargetMachineRef TM
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM)
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:1689
bool Isv2x16VT(EVT VT)
std::string getSamplerName(const Value &val)
bool getAlign(const Function &F, unsigned index, unsigned &align)
bool getMinCTASm(const Function &F, unsigned &x)
bool isImage(const Value &val)
bool isImageReadOnly(const Value &val)
bool getMaxNTIDz(const Function &F, unsigned &z)
bool isManaged(const Value &val)
unsigned promoteScalarArgumentSize(unsigned size)
bool isSurface(const Value &val)
bool findAllNVVMAnnotation(const GlobalValue *gv, const std::string &prop, std::vector< unsigned > &retval)
void clearAnnotationCache(const Module *Mod)
std::string getSurfaceName(const Value &val)
bool getReqNTIDx(const Function &F, unsigned &x)
bool getReqNTIDy(const Function &F, unsigned &y)
bool getMaxNReg(const Function &F, unsigned &x)
bool isTexture(const Value &val)
bool isImageWriteOnly(const Value &val)
bool isImageReadWrite(const Value &val)
std::string getTextureName(const Value &val)
bool isKernelFunction(const Function &F)
Function * getMaybeBitcastedCallee(const CallBase *CB)
bool getReqNTIDz(const Function &F, unsigned &z)
bool findOneNVVMAnnotation(const GlobalValue *gv, const std::string &prop, unsigned &retval)
bool getMaxNTIDx(const Function &F, unsigned &x)
bool getMaxNTIDy(const Function &F, unsigned &y)
bool isSampler(const Value &val)
bool getMaxClusterRank(const Function &F, unsigned &x)