LLVM 23.0.0git
TargetParser.h
Go to the documentation of this file.
1//===-- TargetParser - Parser for target features ---------------*- 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 to recognise hardware features such as
10// FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TARGETPARSER_TARGETPARSER_H
15#define LLVM_TARGETPARSER_TARGETPARSER_H
16
17#include "SubtargetFeature.h"
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/StringMap.h"
20#include "llvm/ADT/StringRef.h"
22
23namespace llvm {
24
25template <typename T> class SmallVectorImpl;
26class Triple;
27
28// Target specific information in their own namespaces.
29// (ARM/AArch64/X86 are declared in ARM/AArch64/X86TargetParser.h)
30// These should be generated from TableGen because the information is already
31// there, and there is where new information about targets will be added.
32// FIXME: To TableGen this we need to make some table generated files available
33// even if the back-end is not compiled with LLVM, plus we need to create a new
34// back-end to TableGen to create these clean tables.
35namespace AMDGPU {
36
37/// GPU kinds supported by the AMDGPU target.
133
134/// Instruction set architecture version.
136 unsigned Major;
137 unsigned Minor;
138 unsigned Stepping;
139};
140
141// This isn't comprehensive for now, just things that are needed from the
142// frontend driver.
145
146 // These features only exist for r600, and are implied true for amdgcn.
147 FEATURE_FMA = 1 << 1,
149 FEATURE_FP64 = 1 << 3,
150
151 // Common features.
154
155 // Wavefront 32 is available.
157
158 // Xnack is available.
160
161 // Sram-ecc is available.
163
164 // WGP mode is supported.
165 FEATURE_WGP = 1 << 9,
166
167 // Xnack is available by default
169};
170
176
178
185LLVM_ABI unsigned getArchAttrR600(GPUKind AK);
186
189
190LLVM_ABI IsaVersion getIsaVersion(StringRef GPU);
191
192/// Fills Features map with default values for given target GPU.
193/// \p Features contains overriding target features and this function returns
194/// default target features with entries overridden by \p Features.
195LLVM_ABI std::pair<FeatureError, StringRef>
197} // namespace AMDGPU
198
200 const char *Key; ///< K-V key string
201 unsigned Value; ///< K-V integer value
202 FeatureBitArray Implies; ///< K-V bit mask
203};
204
205/// Used to provide key value pairs for feature and CPU bit flags.
207 const char *Key; ///< K-V key string
208 FeatureBitArray Implies; ///< K-V bit mask
209
210 /// Compare routine for std::lower_bound
211 bool operator<(StringRef S) const { return StringRef(Key) < S; }
212
213 /// Compare routine for std::is_sorted.
215 return StringRef(Key) < StringRef(Other.Key);
216 }
217};
218
219LLVM_ABI std::optional<llvm::StringMap<bool>>
220getCPUDefaultTargetFeatures(StringRef CPU,
223} // namespace llvm
224
225#endif
This file defines the StringMap class.
#define LLVM_ABI
Definition Compiler.h:213
#define T
Class used to store the subtarget bits in the tables created by tablegen.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM_ABI StringRef getArchNameR600(GPUKind AK)
GPUKind
GPU kinds supported by the AMDGPU target.
LLVM_ABI StringRef getCanonicalArchName(const Triple &T, StringRef Arch)
LLVM_ABI void fillValidArchListR600(SmallVectorImpl< StringRef > &Values)
LLVM_ABI StringRef getArchFamilyNameAMDGCN(GPUKind AK)
LLVM_ABI IsaVersion getIsaVersion(StringRef GPU)
LLVM_ABI void fillValidArchListAMDGCN(SmallVectorImpl< StringRef > &Values)
LLVM_ABI GPUKind parseArchAMDGCN(StringRef CPU)
@ UNSUPPORTED_TARGET_FEATURE
@ INVALID_FEATURE_COMBINATION
@ FEATURE_FAST_DENORMAL_F32
LLVM_ABI std::pair< FeatureError, StringRef > fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, StringMap< bool > &Features)
Fills Features map with default values for given target GPU.
LLVM_ABI StringRef getArchNameAMDGCN(GPUKind AK)
LLVM_ABI unsigned getArchAttrAMDGCN(GPUKind AK)
LLVM_ABI unsigned getArchAttrR600(GPUKind AK)
LLVM_ABI GPUKind parseArchR600(StringRef CPU)
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
@ Other
Any other memory.
Definition ModRef.h:68
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI std::optional< llvm::StringMap< bool > > getCPUDefaultTargetFeatures(StringRef CPU, ArrayRef< BasicSubtargetSubTypeKV > ProcDesc, ArrayRef< BasicSubtargetFeatureKV > ProcFeatures)
Instruction set architecture version.
FeatureBitArray Implies
K-V bit mask.
const char * Key
K-V key string.
unsigned Value
K-V integer value.
Used to provide key value pairs for feature and CPU bit flags.
FeatureBitArray Implies
K-V bit mask.
bool operator<(const BasicSubtargetSubTypeKV &Other) const
Compare routine for std::is_sorted.
bool operator<(StringRef S) const
Compare routine for std::lower_bound.
const char * Key
K-V key string.