Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / Target / NVPTX / NVPTXUtilities.h
blobc15ff6cae1f270aaa49ad90c50beb5424f70ea83
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.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
14 #define LLVM_LIB_TARGET_NVPTX_NVPTXUTILITIES_H
16 #include "llvm/CodeGen/ValueTypes.h"
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/GlobalVariable.h"
19 #include "llvm/IR/IntrinsicInst.h"
20 #include "llvm/IR/Value.h"
21 #include "llvm/Support/Alignment.h"
22 #include <cstdarg>
23 #include <set>
24 #include <string>
25 #include <vector>
27 namespace llvm {
29 class TargetMachine;
31 void clearAnnotationCache(const Module *);
33 bool findOneNVVMAnnotation(const GlobalValue *, const std::string &,
34 unsigned &);
35 bool findAllNVVMAnnotation(const GlobalValue *, const std::string &,
36 std::vector<unsigned> &);
38 bool isTexture(const Value &);
39 bool isSurface(const Value &);
40 bool isSampler(const Value &);
41 bool isImage(const Value &);
42 bool isImageReadOnly(const Value &);
43 bool isImageWriteOnly(const Value &);
44 bool isImageReadWrite(const Value &);
45 bool isManaged(const Value &);
47 std::string getTextureName(const Value &);
48 std::string getSurfaceName(const Value &);
49 std::string getSamplerName(const Value &);
51 std::optional<unsigned> getMaxNTIDx(const Function &);
52 std::optional<unsigned> getMaxNTIDy(const Function &);
53 std::optional<unsigned> getMaxNTIDz(const Function &);
54 std::optional<unsigned> getMaxNTID(const Function &F);
56 std::optional<unsigned> getReqNTIDx(const Function &);
57 std::optional<unsigned> getReqNTIDy(const Function &);
58 std::optional<unsigned> getReqNTIDz(const Function &);
59 std::optional<unsigned> getReqNTID(const Function &);
61 bool getMaxClusterRank(const Function &, unsigned &);
62 bool getMinCTASm(const Function &, unsigned &);
63 bool getMaxNReg(const Function &, unsigned &);
64 bool isKernelFunction(const Function &);
65 bool isParamGridConstant(const Value &);
67 MaybeAlign getAlign(const Function &, unsigned);
68 MaybeAlign getAlign(const CallInst &, unsigned);
69 Function *getMaybeBitcastedCallee(const CallBase *CB);
71 // PTX ABI requires all scalar argument/return values to have
72 // bit-size as a power of two of at least 32 bits.
73 inline unsigned promoteScalarArgumentSize(unsigned size) {
74 if (size <= 32)
75 return 32;
76 else if (size <= 64)
77 return 64;
78 else
79 return size;
82 bool shouldEmitPTXNoReturn(const Value *V, const TargetMachine &TM);
84 bool Isv2x16VT(EVT VT);
87 #endif