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"
22#include <cstdarg>
23#include <set>
24#include <string>
25#include <vector>
26
27namespace llvm {
28
29class TargetMachine;
30
31void clearAnnotationCache(const Module *);
32
33bool findOneNVVMAnnotation(const GlobalValue *, const std::string &,
34 unsigned &);
35bool findAllNVVMAnnotation(const GlobalValue *, const std::string &,
36 std::vector<unsigned> &);
37
38bool isTexture(const Value &);
39bool isSurface(const Value &);
40bool isSampler(const Value &);
41bool isImage(const Value &);
42bool isImageReadOnly(const Value &);
43bool isImageWriteOnly(const Value &);
44bool isImageReadWrite(const Value &);
45bool isManaged(const Value &);
46
47std::string getTextureName(const Value &);
48std::string getSurfaceName(const Value &);
49std::string getSamplerName(const Value &);
50
51std::optional<unsigned> getMaxNTIDx(const Function &);
52std::optional<unsigned> getMaxNTIDy(const Function &);
53std::optional<unsigned> getMaxNTIDz(const Function &);
54std::optional<unsigned> getMaxNTID(const Function &F);
55
56std::optional<unsigned> getReqNTIDx(const Function &);
57std::optional<unsigned> getReqNTIDy(const Function &);
58std::optional<unsigned> getReqNTIDz(const Function &);
59std::optional<unsigned> getReqNTID(const Function &);
60
61bool getMaxClusterRank(const Function &, unsigned &);
62bool getMinCTASm(const Function &, unsigned &);
63bool getMaxNReg(const Function &, unsigned &);
64bool isKernelFunction(const Function &);
65
66MaybeAlign getAlign(const Function &, unsigned);
67MaybeAlign getAlign(const CallInst &, unsigned);
68Function *getMaybeBitcastedCallee(const CallBase *CB);
69
70// PTX ABI requires all scalar argument/return values to have
71// bit-size as a power of two of at least 32 bits.
72inline unsigned promoteScalarArgumentSize(unsigned size) {
73 if (size <= 32)
74 return 32;
75 else if (size <= 64)
76 return 64;
77 else
78 return size;
79}
80
81bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM);
82
83bool Isv2x16VT(EVT VT);
84}
85
86#endif
#define F(x, y, z)
Definition: MD5.cpp:55
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:1680
bool Isv2x16VT(EVT VT)
std::optional< unsigned > getMaxNTIDy(const Function &F)
std::string getSamplerName(const Value &val)
bool getMinCTASm(const Function &F, unsigned &x)
bool isImage(const Value &val)
std::optional< unsigned > getMaxNTIDz(const Function &F)
MaybeAlign getAlign(const Function &F, unsigned Index)
std::optional< unsigned > getMaxNTIDx(const Function &F)
bool isImageReadOnly(const Value &val)
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)
std::optional< unsigned > getReqNTIDy(const Function &F)
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 findOneNVVMAnnotation(const GlobalValue *gv, const std::string &prop, unsigned &retval)
std::optional< unsigned > getReqNTIDz(const Function &F)
std::optional< unsigned > getReqNTIDx(const Function &F)
bool isSampler(const Value &val)
bool getMaxClusterRank(const Function &F, unsigned &x)
std::optional< unsigned > getReqNTID(const Function &F)
std::optional< unsigned > getMaxNTID(const Function &F)