LLVM 22.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.
131
132/// Instruction set architecture version.
134 unsigned Major;
135 unsigned Minor;
136 unsigned Stepping;
137};
138
139// This isn't comprehensive for now, just things that are needed from the
140// frontend driver.
143
144 // These features only exist for r600, and are implied true for amdgcn.
145 FEATURE_FMA = 1 << 1,
147 FEATURE_FP64 = 1 << 3,
148
149 // Common features.
152
153 // Wavefront 32 is available.
155
156 // Xnack is available.
158
159 // Sram-ecc is available.
161
162 // WGP mode is supported.
163 FEATURE_WGP = 1 << 9,
164};
165
171
173
180LLVM_ABI unsigned getArchAttrR600(GPUKind AK);
181
184
185LLVM_ABI IsaVersion getIsaVersion(StringRef GPU);
186
187/// Fills Features map with default values for given target GPU.
188/// \p Features contains overriding target features and this function returns
189/// default target features with entries overridden by \p Features.
190LLVM_ABI std::pair<FeatureError, StringRef>
192} // namespace AMDGPU
193
195 const char *Key; ///< K-V key string
196 unsigned Value; ///< K-V integer value
197 FeatureBitArray Implies; ///< K-V bit mask
198};
199
200/// Used to provide key value pairs for feature and CPU bit flags.
202 const char *Key; ///< K-V key string
203 FeatureBitArray Implies; ///< K-V bit mask
204
205 /// Compare routine for std::lower_bound
206 bool operator<(StringRef S) const { return StringRef(Key) < S; }
207
208 /// Compare routine for std::is_sorted.
210 return StringRef(Key) < StringRef(Other.Key);
211 }
212};
213
214LLVM_ABI std::optional<llvm::StringMap<bool>>
215getCPUDefaultTargetFeatures(StringRef CPU,
218} // namespace llvm
219
220#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.
@ 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.