| 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 | |
| 24 | namespace llvm { |
| 25 | |
| 26 | class Argument; |
| 27 | class CallInst; |
| 28 | class GlobalVariable; |
| 29 | class Module; |
| 30 | class Value; |
| 31 | |
| 32 | void clearAnnotationCache(const Module *); |
| 33 | |
| 34 | inline bool isKernelFunction(const Function &F) { |
| 35 | return F.getCallingConv() == CallingConv::PTX_Kernel; |
| 36 | } |
| 37 | |
| 38 | enum class PTXOpaqueType { None, Texture, Surface, Sampler }; |
| 39 | |
| 40 | PTXOpaqueType getPTXOpaqueType(const GlobalVariable &); |
| 41 | PTXOpaqueType getPTXOpaqueType(const Argument &); |
| 42 | PTXOpaqueType getPTXOpaqueType(const Value &); |
| 43 | |
| 44 | bool isManaged(const Value &); |
| 45 | |
| 46 | SmallVector<unsigned, 3> getMaxNTID(const Function &); |
| 47 | SmallVector<unsigned, 3> getReqNTID(const Function &); |
| 48 | SmallVector<unsigned, 3> getClusterDim(const Function &); |
| 49 | |
| 50 | std::optional<uint64_t> getOverallMaxNTID(const Function &); |
| 51 | std::optional<uint64_t> getOverallReqNTID(const Function &); |
| 52 | std::optional<uint64_t> getOverallClusterRank(const Function &); |
| 53 | |
| 54 | std::optional<unsigned> getMaxClusterRank(const Function &); |
| 55 | std::optional<unsigned> getMinCTASm(const Function &); |
| 56 | std::optional<unsigned> getMaxNReg(const Function &); |
| 57 | |
| 58 | bool hasBlocksAreClusters(const Function &); |
| 59 | |
| 60 | bool isParamGridConstant(const Argument &); |
| 61 | |
| 62 | inline MaybeAlign getAlign(const Function &F, unsigned Index) { |
| 63 | return F.getAttributes().getAttributes(Index).getStackAlignment(); |
| 64 | } |
| 65 | MaybeAlign getAlign(const CallInst &, unsigned); |
| 66 | |
| 67 | } // namespace llvm |
| 68 | |
| 69 | #endif |
| 70 |