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.
39 // Not specified processor.
41
42#define R600_GPU(NAME, ENUM, FEATURES) ENUM,
43#define AMDGCN_GPU(NAME, ENUM, ISAVERSION, FEATURES) ENUM,
44#include "AMDGPUTargetParser.def"
45
46 GK_AMDGCN_GENERIC_FIRST = GK_GFX9_GENERIC,
47 GK_AMDGCN_GENERIC_LAST = GK_GFX12_5_GENERIC,
48};
49
50/// Instruction set architecture version.
51struct IsaVersion {
52 unsigned Major;
53 unsigned Minor;
54 unsigned Stepping;
55};
56
57// This isn't comprehensive for now, just things that are needed from the
58// frontend driver.
61
62 // These features only exist for r600, and are implied true for amdgcn.
63 FEATURE_FMA = 1 << 1,
64 FEATURE_LDEXP = 1 << 2,
65 FEATURE_FP64 = 1 << 3,
66
67 // Common features.
70
71 // Wavefront 32 is available.
73
74 // Xnack is available.
75 FEATURE_XNACK = 1 << 7,
76
77 // Sram-ecc is available.
79
80 // WGP mode is supported.
81 FEATURE_WGP = 1 << 9,
82
83 // Xnack is available by default
85};
86
92
94
101LLVM_ABI unsigned getArchAttrR600(GPUKind AK);
102
103LLVM_ABI void fillValidArchListAMDGCN(SmallVectorImpl<StringRef> &Values);
104LLVM_ABI void fillValidArchListR600(SmallVectorImpl<StringRef> &Values);
105
106LLVM_ABI IsaVersion getIsaVersion(StringRef GPU);
107
108/// Fills Features map with default values for given target GPU.
109/// \p Features contains overriding target features and this function returns
110/// default target features with entries overridden by \p Features.
111LLVM_ABI std::pair<FeatureError, StringRef>
112fillAMDGPUFeatureMap(StringRef GPU, const Triple &T, StringMap<bool> &Features);
113} // namespace AMDGPU
114
116 const char *Key; ///< K-V key string
117 unsigned Value; ///< K-V integer value
118 FeatureBitArray Implies; ///< K-V bit mask
119};
120
121/// Used to provide key value pairs for feature and CPU bit flags.
123 const char *Key; ///< K-V key string
124 FeatureBitArray Implies; ///< K-V bit mask
125
126 /// Compare routine for std::lower_bound
127 bool operator<(StringRef S) const { return StringRef(Key) < S; }
128
129 /// Compare routine for std::is_sorted.
131 return StringRef(Key) < StringRef(Other.Key);
132 }
133};
134
135LLVM_ABI std::optional<llvm::StringMap<bool>>
136getCPUDefaultTargetFeatures(StringRef CPU,
139} // namespace llvm
140
141#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...
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.