clang 23.0.0git
OffloadArch.h
Go to the documentation of this file.
1//===--- OffloadArch.h - Definition of offloading architectures --- 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_CLANG_BASIC_OFFLOADARCH_H
10#define LLVM_CLANG_BASIC_OFFLOADARCH_H
11
12#include "llvm/ADT/StringRef.h"
13#include <tuple>
14
15namespace llvm {
16class Triple;
17} // namespace llvm
18
19namespace clang {
20
21enum class OffloadArch {
24 // TODO: Deprecate and remove GPU architectures older than sm_52.
28 // This has a name conflict with sys/mac.h on AIX, rename it as a workaround.
128 Generic, // A processor model named 'generic' if the target backend defines a
129 // public one.
130 // Intel CPUs
132 // Intel GPUs
135
138};
139
140static inline bool IsNVIDIAOffloadArch(OffloadArch A) {
141 return A >= OffloadArch::SM_20 && A < OffloadArch::GFX600;
142}
143
144static inline bool IsAMDOffloadArch(OffloadArch A) {
145 // Generic processor model is for testing only.
146 return A >= OffloadArch::GFX600 && A < OffloadArch::Generic;
147}
148
152
156
160
161const char *OffloadArchToString(OffloadArch A);
162const char *OffloadArchToVirtualArchString(OffloadArch A);
163
164// Convert a string to an OffloadArch enum value. Returns
165// OffloadArch::Unknown if the string is not recognized.
166OffloadArch StringToOffloadArch(llvm::StringRef S);
167
168llvm::Triple OffloadArchToTriple(const llvm::Triple &DefaultToolchainTriple,
169 OffloadArch ID);
170
171/// Represents a bound architecture for offload / multiple architecture
172/// compilation.
173struct BoundArch {
174 llvm::StringRef ArchName;
175
176 /// The parsed offload architecture enum.
177 /// Will be OffloadArch::Unknown if ArchName not recognized.
179
180 BoundArch() = default;
181 explicit BoundArch(llvm::StringRef Name)
182 : ArchName(Name),
183 Arch(Name.empty() ? OffloadArch::Unknown : StringToOffloadArch(Name)) {}
184
185 BoundArch(llvm::StringRef Name, OffloadArch A) : ArchName(Name), Arch(A) {}
186
187 bool empty() const { return ArchName.empty(); }
188 explicit operator bool() const { return Arch != OffloadArch::Unused; }
189
190 bool operator==(const BoundArch &Other) const {
191 return Arch == Other.Arch && ArchName == Other.ArchName;
192 }
193
194 bool operator<(const BoundArch &Other) const {
195 return std::tie(Arch, ArchName) < std::tie(Other.Arch, Other.ArchName);
196 }
197};
198
199} // namespace clang
200
201#endif // LLVM_CLANG_BASIC_OFFLOADARCH_H
The JSON file list parser is used to communicate input to InstallAPI.
static bool IsIntelOffloadArch(OffloadArch Arch)
static bool IsIntelCPUOffloadArch(OffloadArch Arch)
static bool IsAMDOffloadArch(OffloadArch A)
static bool IsNVIDIAOffloadArch(OffloadArch A)
const char * OffloadArchToVirtualArchString(OffloadArch A)
OffloadArch StringToOffloadArch(llvm::StringRef S)
const char * OffloadArchToString(OffloadArch A)
static bool IsIntelGPUOffloadArch(OffloadArch Arch)
llvm::Triple OffloadArchToTriple(const llvm::Triple &DefaultToolchainTriple, OffloadArch ID)
@ Generic
not a target-specific vector type
Definition TypeBase.h:4200
@ Other
Other implicit parameter.
Definition Decl.h:1772
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
llvm::StringRef ArchName
bool empty() const
bool operator<(const BoundArch &Other) const
BoundArch(llvm::StringRef Name, OffloadArch A)
OffloadArch Arch
The parsed offload architecture enum.
BoundArch(llvm::StringRef Name)
BoundArch()=default
bool operator==(const BoundArch &Other) const