LLVM  16.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_SUPPORT_TARGETPARSER_H
15 #define LLVM_SUPPORT_TARGETPARSER_H
16 
17 #include "llvm/ADT/StringRef.h"
18 #include <cstdint>
19 // FIXME: vector is used because that's what clang uses for subtarget feature
20 // lists, but SmallVector would probably be better
21 #include <vector>
22 
23 namespace llvm {
24 
25 template <typename T> class SmallVectorImpl;
26 class 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.
35 namespace AMDGPU {
36 
37 /// GPU kinds supported by the AMDGPU target.
38 enum GPUKind : uint32_t {
39  // Not specified processor.
40  GK_NONE = 0,
41 
42  // R600-based processors.
43  GK_R600 = 1,
44  GK_R630 = 2,
45  GK_RS880 = 3,
46  GK_RV670 = 4,
47  GK_RV710 = 5,
48  GK_RV730 = 6,
49  GK_RV770 = 7,
50  GK_CEDAR = 8,
52  GK_JUNIPER = 10,
53  GK_REDWOOD = 11,
54  GK_SUMO = 12,
55  GK_BARTS = 13,
56  GK_CAICOS = 14,
57  GK_CAYMAN = 15,
58  GK_TURKS = 16,
59 
62 
63  // AMDGCN-based processors.
64  GK_GFX600 = 32,
65  GK_GFX601 = 33,
66  GK_GFX602 = 34,
67 
68  GK_GFX700 = 40,
69  GK_GFX701 = 41,
70  GK_GFX702 = 42,
71  GK_GFX703 = 43,
72  GK_GFX704 = 44,
73  GK_GFX705 = 45,
74 
75  GK_GFX801 = 50,
76  GK_GFX802 = 51,
77  GK_GFX803 = 52,
78  GK_GFX805 = 53,
79  GK_GFX810 = 54,
80 
81  GK_GFX900 = 60,
82  GK_GFX902 = 61,
83  GK_GFX904 = 62,
84  GK_GFX906 = 63,
85  GK_GFX908 = 64,
86  GK_GFX909 = 65,
87  GK_GFX90A = 66,
88  GK_GFX90C = 67,
89  GK_GFX940 = 68,
90 
91  GK_GFX1010 = 71,
92  GK_GFX1011 = 72,
93  GK_GFX1012 = 73,
94  GK_GFX1013 = 74,
95  GK_GFX1030 = 75,
96  GK_GFX1031 = 76,
97  GK_GFX1032 = 77,
98  GK_GFX1033 = 78,
99  GK_GFX1034 = 79,
102 
107 
110 };
111 
112 /// Instruction set architecture version.
113 struct IsaVersion {
114  unsigned Major;
115  unsigned Minor;
116  unsigned Stepping;
117 };
118 
119 // This isn't comprehensive for now, just things that are needed from the
120 // frontend driver.
123 
124  // These features only exist for r600, and are implied true for amdgcn.
125  FEATURE_FMA = 1 << 1,
126  FEATURE_LDEXP = 1 << 2,
127  FEATURE_FP64 = 1 << 3,
128 
129  // Common features.
132 
133  // Wavefront 32 is available.
134  FEATURE_WAVE32 = 1 << 6,
135 
136  // Xnack is available.
137  FEATURE_XNACK = 1 << 7,
138 
139  // Sram-ecc is available.
140  FEATURE_SRAMECC = 1 << 8,
141 };
142 
148 unsigned getArchAttrAMDGCN(GPUKind AK);
149 unsigned getArchAttrR600(GPUKind AK);
150 
153 
154 IsaVersion getIsaVersion(StringRef GPU);
155 
156 } // namespace AMDGPU
157 
158 namespace RISCV {
159 
160 // We use 64 bits as the known part in the scalable vector types.
161 static constexpr unsigned RVVBitsPerBlock = 64;
162 
163 enum CPUKind : unsigned {
164 #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
165 #define TUNE_PROC(ENUM, NAME) CK_##ENUM,
166 #include "RISCVTargetParser.def"
167 };
168 
169 enum FeatureKind : unsigned {
171  FK_NONE = 1,
172  FK_64BIT = 1 << 2,
173 };
174 
175 bool checkCPUKind(CPUKind Kind, bool IsRV64);
176 bool checkTuneCPUKind(CPUKind Kind, bool IsRV64);
178 CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64);
180 void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
181 void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
182 bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector<StringRef> &Features);
183 
184 } // namespace RISCV
185 } // namespace llvm
186 
187 #endif
llvm::AMDGPU::GK_GFX802
@ GK_GFX802
Definition: TargetParser.h:76
llvm::AMDGPU::GK_GFX703
@ GK_GFX703
Definition: TargetParser.h:71
llvm::AMDGPU::IsaVersion::Stepping
unsigned Stepping
Definition: TargetParser.h:116
llvm::AMDGPU::FEATURE_LDEXP
@ FEATURE_LDEXP
Definition: TargetParser.h:126
llvm::AMDGPU::GK_GFX1034
@ GK_GFX1034
Definition: TargetParser.h:99
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::AMDGPU::GK_AMDGCN_FIRST
@ GK_AMDGCN_FIRST
Definition: TargetParser.h:108
llvm::AMDGPU::GK_GFX801
@ GK_GFX801
Definition: TargetParser.h:75
llvm::AMDGPU::GPUKind
GPUKind
GPU kinds supported by the AMDGPU target.
Definition: TargetParser.h:38
llvm::AMDGPU::GK_CAYMAN
@ GK_CAYMAN
Definition: TargetParser.h:57
llvm::AMDGPU::GK_RV670
@ GK_RV670
Definition: TargetParser.h:46
llvm::AMDGPU::GK_RV730
@ GK_RV730
Definition: TargetParser.h:48
llvm::AMDGPU::getArchAttrR600
unsigned getArchAttrR600(GPUKind AK)
Definition: TargetParser.cpp:176
llvm::AMDGPU::getIsaVersion
IsaVersion getIsaVersion(StringRef GPU)
Definition: TargetParser.cpp:193
llvm::AMDGPU::GK_GFX900
@ GK_GFX900
Definition: TargetParser.h:81
llvm::RISCV::CPUKind
CPUKind
Definition: TargetParser.h:163
StringRef.h
llvm::AMDGPU::GK_R600
@ GK_R600
Definition: TargetParser.h:43
llvm::AMDGPU::parseArchR600
GPUKind parseArchR600(StringRef CPU)
Definition: TargetParser.cpp:161
llvm::AMDGPU::GK_GFX1013
@ GK_GFX1013
Definition: TargetParser.h:94
llvm::AMDGPU::GK_GFX810
@ GK_GFX810
Definition: TargetParser.h:79
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::AMDGPU::GK_GFX700
@ GK_GFX700
Definition: TargetParser.h:68
llvm::AMDGPU::GK_GFX803
@ GK_GFX803
Definition: TargetParser.h:77
llvm::RISCV::FK_NONE
@ FK_NONE
Definition: TargetParser.h:171
llvm::AMDGPU::GK_CEDAR
@ GK_CEDAR
Definition: TargetParser.h:50
llvm::AMDGPU::GK_GFX90C
@ GK_GFX90C
Definition: TargetParser.h:88
llvm::AMDGPU::GK_GFX602
@ GK_GFX602
Definition: TargetParser.h:66
llvm::AMDGPU::GK_CAICOS
@ GK_CAICOS
Definition: TargetParser.h:56
llvm::AMDGPU::IsaVersion::Major
unsigned Major
Definition: TargetParser.h:114
llvm::AMDGPU::GK_RV770
@ GK_RV770
Definition: TargetParser.h:49
llvm::AMDGPU::GK_RS880
@ GK_RS880
Definition: TargetParser.h:45
llvm::AMDGPU::GK_GFX702
@ GK_GFX702
Definition: TargetParser.h:70
llvm::AMDGPU::IsaVersion
Instruction set architecture version.
Definition: TargetParser.h:113
llvm::AMDGPU::getCanonicalArchName
StringRef getCanonicalArchName(const Triple &T, StringRef Arch)
Definition: TargetParser.cpp:246
llvm::RISCV::checkTuneCPUKind
bool checkTuneCPUKind(CPUKind Kind, bool IsRV64)
Definition: TargetParser.cpp:278
llvm::AMDGPU::GK_GFX1100
@ GK_GFX1100
Definition: TargetParser.h:103
llvm::AMDGPU::GK_CYPRESS
@ GK_CYPRESS
Definition: TargetParser.h:51
llvm::AMDGPU::GK_GFX1012
@ GK_GFX1012
Definition: TargetParser.h:93
llvm::AMDGPU::GK_GFX1036
@ GK_GFX1036
Definition: TargetParser.h:101
llvm::AMDGPU::GK_GFX1032
@ GK_GFX1032
Definition: TargetParser.h:97
llvm::RISCV::getMArchFromMcpu
StringRef getMArchFromMcpu(StringRef CPU)
Definition: TargetParser.cpp:301
AMDGPU
Definition: AMDGPUReplaceLDSUseWithPointer.cpp:114
llvm::AMDGPU::FEATURE_XNACK
@ FEATURE_XNACK
Definition: TargetParser.h:137
llvm::AMDGPU::GK_GFX1102
@ GK_GFX1102
Definition: TargetParser.h:105
llvm::AMDGPU::GK_GFX909
@ GK_GFX909
Definition: TargetParser.h:86
llvm::AMDGPU::GK_GFX805
@ GK_GFX805
Definition: TargetParser.h:78
llvm::AMDGPU::GK_GFX906
@ GK_GFX906
Definition: TargetParser.h:84
llvm::AMDGPU::GK_R600_LAST
@ GK_R600_LAST
Definition: TargetParser.h:61
llvm::AMDGPU::GK_GFX940
@ GK_GFX940
Definition: TargetParser.h:89
llvm::AMDGPU::GK_BARTS
@ GK_BARTS
Definition: TargetParser.h:55
llvm::AMDGPU::ArchFeatureKind
ArchFeatureKind
Definition: TargetParser.h:121
llvm::RISCV::RVVBitsPerBlock
static constexpr unsigned RVVBitsPerBlock
Definition: TargetParser.h:161
llvm::AMDGPU::FEATURE_FP64
@ FEATURE_FP64
Definition: TargetParser.h:127
llvm::AMDGPU::FEATURE_FMA
@ FEATURE_FMA
Definition: TargetParser.h:125
llvm::RISCV::parseCPUKind
CPUKind parseCPUKind(StringRef CPU)
Definition: TargetParser.cpp:286
llvm::AMDGPU::FEATURE_WAVE32
@ FEATURE_WAVE32
Definition: TargetParser.h:134
llvm::AMDGPU::GK_GFX1035
@ GK_GFX1035
Definition: TargetParser.h:100
llvm::AMDGPU::GK_GFX904
@ GK_GFX904
Definition: TargetParser.h:83
llvm::AMDGPU::GK_GFX704
@ GK_GFX704
Definition: TargetParser.h:72
llvm::AMDGPU::GK_GFX701
@ GK_GFX701
Definition: TargetParser.h:69
llvm::AMDGPU::GK_TURKS
@ GK_TURKS
Definition: TargetParser.h:58
llvm::AMDGPU::getArchNameAMDGCN
StringRef getArchNameAMDGCN(GPUKind AK)
Definition: TargetParser.cpp:140
llvm::AMDGPU::IsaVersion::Minor
unsigned Minor
Definition: TargetParser.h:115
llvm::AMDGPU::GK_GFX705
@ GK_GFX705
Definition: TargetParser.h:73
llvm::RISCV::fillValidCPUArchList
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values, bool IsRV64)
Provide a list of valid CPU names.
Definition: TargetParser.cpp:306
llvm::AMDGPU::FEATURE_SRAMECC
@ FEATURE_SRAMECC
Definition: TargetParser.h:140
llvm::AMDGPU::GK_GFX1030
@ GK_GFX1030
Definition: TargetParser.h:95
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
uint32_t
llvm::AMDGPU::GK_GFX908
@ GK_GFX908
Definition: TargetParser.h:85
llvm::AMDGPU::FEATURE_FAST_FMA_F32
@ FEATURE_FAST_FMA_F32
Definition: TargetParser.h:130
llvm::AMDGPU::GK_AMDGCN_LAST
@ GK_AMDGCN_LAST
Definition: TargetParser.h:109
llvm::AMDGPU::getArchNameR600
StringRef getArchNameR600(GPUKind AK)
Definition: TargetParser.cpp:146
llvm::AMDGPU::GK_GFX1103
@ GK_GFX1103
Definition: TargetParser.h:106
llvm::AMDGPU::fillValidArchListR600
void fillValidArchListR600(SmallVectorImpl< StringRef > &Values)
Definition: TargetParser.cpp:188
llvm::AMDGPU::GK_R630
@ GK_R630
Definition: TargetParser.h:44
llvm::RISCV::fillValidTuneCPUArchList
void fillValidTuneCPUArchList(SmallVectorImpl< StringRef > &Values, bool IsRV64)
Definition: TargetParser.cpp:313
llvm::AMDGPU::GK_GFX1031
@ GK_GFX1031
Definition: TargetParser.h:96
llvm::AMDGPU::FEATURE_NONE
@ FEATURE_NONE
Definition: TargetParser.h:122
llvm::RISCV::FK_64BIT
@ FK_64BIT
Definition: TargetParser.h:172
llvm::AMDGPU::GK_GFX1010
@ GK_GFX1010
Definition: TargetParser.h:91
llvm::AMDGPU::GK_GFX1101
@ GK_GFX1101
Definition: TargetParser.h:104
llvm::RISCV::FK_INVALID
@ FK_INVALID
Definition: TargetParser.h:170
llvm::AMDGPU::GK_JUNIPER
@ GK_JUNIPER
Definition: TargetParser.h:52
llvm::AMDGPU::GK_GFX1011
@ GK_GFX1011
Definition: TargetParser.h:92
llvm::AMDGPU::GK_RV710
@ GK_RV710
Definition: TargetParser.h:47
llvm::AMDGPU::GK_GFX600
@ GK_GFX600
Definition: TargetParser.h:64
llvm::AMDGPU::parseArchAMDGCN
GPUKind parseArchAMDGCN(StringRef CPU)
Definition: TargetParser.cpp:152
llvm::AMDGPU::getArchAttrAMDGCN
unsigned getArchAttrAMDGCN(GPUKind AK)
Definition: TargetParser.cpp:170
llvm::RISCV::FeatureKind
FeatureKind
Definition: TargetParser.h:169
llvm::RISCV::checkCPUKind
bool checkCPUKind(CPUKind Kind, bool IsRV64)
Definition: TargetParser.cpp:272
llvm::AMDGPU::GK_REDWOOD
@ GK_REDWOOD
Definition: TargetParser.h:53
llvm::AMDGPU::GK_NONE
@ GK_NONE
Definition: TargetParser.h:40
llvm::AMDGPU::GK_GFX902
@ GK_GFX902
Definition: TargetParser.h:82
llvm::AMDGPU::GK_SUMO
@ GK_SUMO
Definition: TargetParser.h:54
llvm::SmallVectorImpl< StringRef >
llvm::AMDGPU::GK_GFX601
@ GK_GFX601
Definition: TargetParser.h:65
llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32
@ FEATURE_FAST_DENORMAL_F32
Definition: TargetParser.h:131
llvm::AMDGPU::GK_GFX1033
@ GK_GFX1033
Definition: TargetParser.h:98
llvm::RISCV::getCPUFeaturesExceptStdExt
bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector< StringRef > &Features)
Definition: TargetParser.cpp:323
llvm::AMDGPU::GK_GFX90A
@ GK_GFX90A
Definition: TargetParser.h:87
llvm::AMDGPU::fillValidArchListAMDGCN
void fillValidArchListAMDGCN(SmallVectorImpl< StringRef > &Values)
Definition: TargetParser.cpp:182
llvm::RISCV::parseTuneCPUKind
CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64)
Definition: TargetParser.cpp:293
llvm::AMDGPU::GK_R600_FIRST
@ GK_R600_FIRST
Definition: TargetParser.h:60