1//===-- NVVMProperties - NVVM annotation 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 declarations for NVVM attribute and metadata query
10// utilities.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_NVPTX_NVVMPROPERTIES_H
15#define LLVM_LIB_TARGET_NVPTX_NVVMPROPERTIES_H
16
17#include "llvm/ADT/SmallVector.h"
18#include "llvm/IR/CallingConv.h"
19#include "llvm/IR/Function.h"
20#include "llvm/Support/Alignment.h"
21#include <cstdint>
22#include <optional>
23
24namespace llvm {
25
26class Argument;
27class CallInst;
28class GlobalVariable;
29class Module;
30class Value;
31
32void clearAnnotationCache(const Module *);
33
34inline bool isKernelFunction(const Function &F) {
35 return F.getCallingConv() == CallingConv::PTX_Kernel;
36}
37
38enum class PTXOpaqueType { None, Texture, Surface, Sampler };
39
40PTXOpaqueType getPTXOpaqueType(const GlobalVariable &);
41PTXOpaqueType getPTXOpaqueType(const Argument &);
42PTXOpaqueType getPTXOpaqueType(const Value &);
43
44bool isManaged(const Value &);
45
46SmallVector<unsigned, 3> getMaxNTID(const Function &);
47SmallVector<unsigned, 3> getReqNTID(const Function &);
48SmallVector<unsigned, 3> getClusterDim(const Function &);
49
50std::optional<uint64_t> getOverallMaxNTID(const Function &);
51std::optional<uint64_t> getOverallReqNTID(const Function &);
52std::optional<uint64_t> getOverallClusterRank(const Function &);
53
54std::optional<unsigned> getMaxClusterRank(const Function &);
55std::optional<unsigned> getMinCTASm(const Function &);
56std::optional<unsigned> getMaxNReg(const Function &);
57
58bool hasBlocksAreClusters(const Function &);
59
60bool isParamGridConstant(const Argument &);
61
62inline MaybeAlign getAlign(const Function &F, unsigned Index) {
63 return F.getAttributes().getAttributes(Index).getStackAlignment();
64}
65MaybeAlign getAlign(const CallInst &, unsigned);
66
67} // namespace llvm
68
69#endif
70