LLVM 24.0.0git
NVPTXTargetParser.cpp
Go to the documentation of this file.
1//===-- NVPTXTargetParser - 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// This file implements a target parser for the NVPTX (CUDA) GPU list.
10//
11//===----------------------------------------------------------------------===//
12
15
16using namespace llvm;
17using namespace NVPTX;
18
20 return StringSwitch<GPUKind>(CPU)
21#define NVPTX_GPU(NAME, KIND, VIRTUAL, SM_ID, MIN_VER, MAX_VER, SUFFIX) \
22 .Case(NAME, GK_##KIND)
23#include "llvm/TargetParser/NVPTXTargetParser.def"
25}
26
28 switch (Kind) {
29 case GK_NONE:
30 return "";
31#define NVPTX_GPU(NAME, KIND, VIRTUAL, SM_ID, MIN_VER, MAX_VER, SUFFIX) \
32 case GK_##KIND: \
33 return NAME;
34#include "llvm/TargetParser/NVPTXTargetParser.def"
35 }
36 llvm_unreachable("invalid NVPTX GPUKind");
37}
38
40 switch (Kind) {
41 case GK_NONE:
42 return "";
43#define NVPTX_GPU(NAME, KIND, VIRTUAL, SM_ID, MIN_VER, MAX_VER, SUFFIX) \
44 case GK_##KIND: \
45 return VIRTUAL;
46#include "llvm/TargetParser/NVPTXTargetParser.def"
47 }
48 llvm_unreachable("invalid NVPTX GPUKind");
49}
50
52 switch (Kind) {
53 case GK_NONE:
54 return 0;
55#define NVPTX_GPU(NAME, KIND, VIRTUAL, SM_ID, MIN_VER, MAX_VER, SUFFIX) \
56 case GK_##KIND: \
57 return SM_ID;
58#include "llvm/TargetParser/NVPTXTargetParser.def"
59 }
60 llvm_unreachable("invalid NVPTX GPUKind");
61}
62
64 switch (Kind) {
65 case GK_NONE:
66 return ArchSuffix::NONE;
67#define NVPTX_GPU(NAME, KIND, VIRTUAL, SM_ID, MIN_VER, MAX_VER, SUFFIX) \
68 case GK_##KIND: \
69 return ArchSuffix::SUFFIX;
70#include "llvm/TargetParser/NVPTXTargetParser.def"
71 }
72 llvm_unreachable("invalid NVPTX GPUKind");
73}
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
A switch()-like statement whose cases are string literals.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
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.
LLVM_ABI ArchSuffix getArchSuffix(GPUKind Kind)
Return the suffix class of Kind.
This is an optimization pass for GlobalISel generic memory operations.