LLVM 17.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"
19#include "llvm/IR/Value.h"
20#include <cstdarg>
21#include <set>
22#include <string>
23#include <vector>
24
25namespace llvm {
26
27class TargetMachine;
28
29void clearAnnotationCache(const Module *);
30
31bool findOneNVVMAnnotation(const GlobalValue *, const std::string &,
32 unsigned &);
33bool findAllNVVMAnnotation(const GlobalValue *, const std::string &,
34 std::vector<unsigned> &);
35
36bool isTexture(const Value &);
37bool isSurface(const Value &);
38bool isSampler(const Value &);
39bool isImage(const Value &);
40bool isImageReadOnly(const Value &);
41bool isImageWriteOnly(const Value &);
42bool isImageReadWrite(const Value &);
43bool isManaged(const Value &);
44
45std::string getTextureName(const Value &);
46std::string getSurfaceName(const Value &);
47std::string getSamplerName(const Value &);
48
49bool getMaxNTIDx(const Function &, unsigned &);
50bool getMaxNTIDy(const Function &, unsigned &);
51bool getMaxNTIDz(const Function &, unsigned &);
52
53bool getReqNTIDx(const Function &, unsigned &);
54bool getReqNTIDy(const Function &, unsigned &);
55bool getReqNTIDz(const Function &, unsigned &);
56
57bool getMinCTASm(const Function &, unsigned &);
58bool getMaxNReg(const Function &, unsigned &);
59bool isKernelFunction(const Function &);
60
61bool getAlign(const Function &, unsigned index, unsigned &);
62bool getAlign(const CallInst &, unsigned index, unsigned &);
63Function *getMaybeBitcastedCallee(const CallBase *CB);
64
65// PTX ABI requires all scalar argument/return values to have
66// bit-size as a power of two of at least 32 bits.
67inline unsigned promoteScalarArgumentSize(unsigned size) {
68 if (size <= 32)
69 return 32;
70 else if (size <= 64)
71 return 64;
72 else
73 return size;
74}
75
76bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM);
77}
78
79#endif
Machine Check Debug Module
return ToRemove size() > 0
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)
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)