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 // Alias for the last GPUKind. Keep in sync with the final .def row.
27 // FIXME: Should be generated once the GPU list moves to TableGen.
28 GK_LAST = GK_SM_121f,
29};
30
31/// Suffix class of an NVPTX architecture name. Enumerator spellings match the
32/// SUFFIX column tokens in NVPTXTargetParser.def.
34
35/// Parse \p CPU (e.g. "sm_90") into a GPUKind, or GK_NONE if unrecognized.
36LLVM_ABI GPUKind parseArch(StringRef CPU);
37
38/// Return the canonical processor name (e.g. "sm_90") for \p Kind, or "" if
39/// \p Kind is GK_NONE.
40LLVM_ABI StringRef getArchName(GPUKind Kind);
41
42/// Return the virtual (compute_) arch name (e.g. "compute_90") for \p Kind, or
43/// "" if \p Kind is GK_NONE.
45
46/// Return the numeric compute-capability id (e.g. sm_90 -> 900) for \p Kind, or
47/// 0 if \p Kind is GK_NONE.
48LLVM_ABI unsigned getSmVersion(GPUKind Kind);
49
50/// Return the suffix class of \p Kind.
52
53/// Whether \p Kind is an accelerated variant (e.g. sm_90a).
54inline bool isAcceleratedArch(GPUKind Kind) {
56}
57
58/// Whether \p Kind is a family-specific variant (e.g. sm_90f) or accelerated.
59inline bool isFamilySpecificArch(GPUKind Kind) {
60 ArchSuffix S = getArchSuffix(Kind);
62}
63
64/// Whether \p Kind supports unified addressing. Unified addressing was
65/// introduced with the Pascal generation (sm_60).
67 return getSmVersion(Kind) >= 600;
68}
69
70} // namespace NVPTX
71} // namespace llvm
72
73#endif // LLVM_TARGETPARSER_NVPTXTARGETPARSER_H
#define LLVM_ABI
Definition Compiler.h:215
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.