LLVM 24.0.0git
NVPTXTargetParser.h
Go to the documentation of this file.
1//===-- NVPTXTargetParser.h - Parser for NVPTX target ----------*- 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#ifndef LLVM_TARGETPARSER_NVPTXTARGETPARSER_H
10#define LLVM_TARGETPARSER_NVPTXTARGETPARSER_H
11
12#include "llvm/ADT/StringRef.h"
14#include <cstdint>
15
16namespace llvm {
17namespace NVPTX {
18
19/// GPU kinds supported by the NVPTX target.
22#define NVPTX_GPU(NAME, KIND, VIRTUAL, SM_ID, MIN_VER, MAX_VER, SUFFIX) \
23 GK_##KIND,
24#include "llvm/TargetParser/NVPTXTargetParser.def"
25
26 // Count the rows in NVPTXTargetParser.def by adding +1 for each entry to init
27 // GK_LAST as the final valid value without having to manually update it.
29#define NVPTX_GPU(NAME, KIND, VIRTUAL, SM_ID, MIN_VER, MAX_VER, SUFFIX) +1
30#include "llvm/TargetParser/NVPTXTargetParser.def"
31};
32
33/// Suffix class of an NVPTX architecture name. Enumerator spellings match the
34/// SUFFIX column tokens in NVPTXTargetParser.def.
36
37/// Parse \p CPU (e.g. "sm_90") into a GPUKind, or GK_NONE if unrecognized.
38LLVM_ABI GPUKind parseArch(StringRef CPU);
39
40/// Return the canonical processor name (e.g. "sm_90") for \p Kind, or "" if
41/// \p Kind is GK_NONE.
42LLVM_ABI StringRef getArchName(GPUKind Kind);
43
44/// Return the virtual (compute_) arch name (e.g. "compute_90") for \p Kind, or
45/// "" if \p Kind is GK_NONE.
47
48/// Return the numeric compute-capability id (e.g. sm_90 -> 900) for \p Kind, or
49/// 0 if \p Kind is GK_NONE.
50LLVM_ABI unsigned getSmVersion(GPUKind Kind);
51
52/// Return the suffix class of \p Kind.
54
55/// Whether \p Kind is an accelerated variant (e.g. sm_90a).
56inline bool isAcceleratedArch(GPUKind Kind) {
58}
59
60/// Whether \p Kind is a family-specific variant (e.g. sm_90f) or accelerated.
61inline bool isFamilySpecificArch(GPUKind Kind) {
62 ArchSuffix S = getArchSuffix(Kind);
64}
65
66/// Whether \p Kind supports unified addressing. Unified addressing was
67/// introduced with the Pascal generation (sm_60).
69 return getSmVersion(Kind) >= 600;
70}
71
72} // namespace NVPTX
73} // namespace llvm
74
75#endif // LLVM_TARGETPARSER_NVPTXTARGETPARSER_H
#define LLVM_ABI
Definition Compiler.h:211
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM_ABI GPUKind parseArch(StringRef CPU)
Parse CPU (e.g. "sm_90") into a GPUKind, or GK_NONE if unrecognized.
GPUKind
GPU kinds supported by the NVPTX target.
LLVM_ABI unsigned getSmVersion(GPUKind Kind)
Return the numeric compute-capability id (e.g.
ArchSuffix
Suffix class of an NVPTX architecture name.
bool isAcceleratedArch(GPUKind Kind)
Whether Kind is an accelerated variant (e.g. sm_90a).
LLVM_ABI StringRef getVirtualArch(GPUKind Kind)
Return the virtual (compute_) arch name (e.g.
LLVM_ABI StringRef getArchName(GPUKind Kind)
Return the canonical processor name (e.g.
bool isFamilySpecificArch(GPUKind Kind)
Whether Kind is a family-specific variant (e.g. sm_90f) or accelerated.
bool supportsUnifiedAddressing(GPUKind Kind)
Whether Kind supports unified addressing.
LLVM_ABI ArchSuffix getArchSuffix(GPUKind Kind)
Return the suffix class of Kind.
This is an optimization pass for GlobalISel generic memory operations.