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.
39 // Not specified processor.
41
42 // R600-based processors.
59
62
63 // AMDGCN-based processors.
67
74
80
91
103
112
116
119
126
129};
130
131/// Instruction set architecture version.
133 unsigned Major;
134 unsigned Minor;
135 unsigned Stepping;
136};
137
138// This isn't comprehensive for now, just things that are needed from the
139// frontend driver.
142
143 // These features only exist for r600, and are implied true for amdgcn.
144 FEATURE_FMA = 1 << 1,
146 FEATURE_FP64 = 1 << 3,
147
148 // Common features.
151
152 // Wavefront 32 is available.
154
155 // Xnack is available.
157
158 // Sram-ecc is available.
160
161 // WGP mode is supported.
162 FEATURE_WGP = 1 << 9,
163};
164
170
172
179LLVM_ABI unsigned getArchAttrR600(GPUKind AK);
180
183
184LLVM_ABI IsaVersion getIsaVersion(StringRef GPU);
185
186/// Fills Features map with default values for given target GPU.
187/// \p Features contains overriding target features and this function returns
188/// default target features with entries overridden by \p Features.
189LLVM_ABI std::pair<FeatureError, StringRef>
191} // namespace AMDGPU
192
194 const char *Key; ///< K-V key string
195 unsigned Value; ///< K-V integer value
196 FeatureBitArray Implies; ///< K-V bit mask
197};
198
199/// Used to provide key value pairs for feature and CPU bit flags.
201 const char *Key; ///< K-V key string
202 FeatureBitArray Implies; ///< K-V bit mask
203
204 /// Compare routine for std::lower_bound
205 bool operator<(StringRef S) const { return StringRef(Key) < S; }
206
207 /// Compare routine for std::is_sorted.
209 return StringRef(Key) < StringRef(Other.Key);
210 }
211};
212
213LLVM_ABI std::optional<llvm::StringMap<bool>>
214getCPUDefaultTargetFeatures(StringRef CPU,
215 ArrayRef<BasicSubtargetSubTypeKV> ProcDesc,
216 ArrayRef<BasicSubtargetFeatureKV> ProcFeatures);
217} // namespace llvm
218
219#endif
This file defines the StringMap class.
#define LLVM_ABI
Definition: Compiler.h:213
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...
Definition: SmallVector.h:574
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.
Definition: TargetParser.h:38
@ GK_AMDGCN_GENERIC_FIRST
Definition: TargetParser.h:127
@ GK_AMDGCN_GENERIC_LAST
Definition: TargetParser.h:128
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
Definition: TargetParser.h:168
@ INVALID_FEATURE_COMBINATION
Definition: TargetParser.h:167
@ FEATURE_FAST_DENORMAL_F32
Definition: TargetParser.h:150
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: AddressRanges.h:18
@ Other
Any other memory.
LLVM_ABI std::optional< llvm::StringMap< bool > > getCPUDefaultTargetFeatures(StringRef CPU, ArrayRef< BasicSubtargetSubTypeKV > ProcDesc, ArrayRef< BasicSubtargetFeatureKV > ProcFeatures)
Instruction set architecture version.
Definition: TargetParser.h:132
FeatureBitArray Implies
K-V bit mask.
Definition: TargetParser.h:196
const char * Key
K-V key string.
Definition: TargetParser.h:194
unsigned Value
K-V integer value.
Definition: TargetParser.h:195
Used to provide key value pairs for feature and CPU bit flags.
Definition: TargetParser.h:200
FeatureBitArray Implies
K-V bit mask.
Definition: TargetParser.h:202
bool operator<(const BasicSubtargetSubTypeKV &Other) const
Compare routine for std::is_sorted.
Definition: TargetParser.h:208
bool operator<(StringRef S) const
Compare routine for std::lower_bound.
Definition: TargetParser.h:205
const char * Key
K-V key string.
Definition: TargetParser.h:201