LLVM  13.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 // FIXME: vector is used because that's what clang uses for subtarget feature
18 // lists, but SmallVector would probably be better
19 #include "llvm/ADT/Triple.h"
22 #include <vector>
23 
24 namespace llvm {
25 class StringRef;
26 
27 // Target specific information in their own namespaces.
28 // (ARM/AArch64/X86 are declared in ARM/AArch64/X86TargetParser.h)
29 // These should be generated from TableGen because the information is already
30 // there, and there is where new information about targets will be added.
31 // FIXME: To TableGen this we need to make some table generated files available
32 // even if the back-end is not compiled with LLVM, plus we need to create a new
33 // back-end to TableGen to create these clean tables.
34 namespace AMDGPU {
35 
36 /// GPU kinds supported by the AMDGPU target.
37 enum GPUKind : uint32_t {
38  // Not specified processor.
39  GK_NONE = 0,
40 
41  // R600-based processors.
42  GK_R600 = 1,
43  GK_R630 = 2,
44  GK_RS880 = 3,
45  GK_RV670 = 4,
46  GK_RV710 = 5,
47  GK_RV730 = 6,
48  GK_RV770 = 7,
49  GK_CEDAR = 8,
51  GK_JUNIPER = 10,
52  GK_REDWOOD = 11,
53  GK_SUMO = 12,
54  GK_BARTS = 13,
55  GK_CAICOS = 14,
56  GK_CAYMAN = 15,
57  GK_TURKS = 16,
58 
61 
62  // AMDGCN-based processors.
63  GK_GFX600 = 32,
64  GK_GFX601 = 33,
65  GK_GFX602 = 34,
66 
67  GK_GFX700 = 40,
68  GK_GFX701 = 41,
69  GK_GFX702 = 42,
70  GK_GFX703 = 43,
71  GK_GFX704 = 44,
72  GK_GFX705 = 45,
73 
74  GK_GFX801 = 50,
75  GK_GFX802 = 51,
76  GK_GFX803 = 52,
77  GK_GFX805 = 53,
78  GK_GFX810 = 54,
79 
80  GK_GFX900 = 60,
81  GK_GFX902 = 61,
82  GK_GFX904 = 62,
83  GK_GFX906 = 63,
84  GK_GFX908 = 64,
85  GK_GFX909 = 65,
86  GK_GFX90A = 66,
87  GK_GFX90C = 67,
88 
89  GK_GFX1010 = 71,
90  GK_GFX1011 = 72,
91  GK_GFX1012 = 73,
92  GK_GFX1030 = 75,
93  GK_GFX1031 = 76,
94  GK_GFX1032 = 77,
95  GK_GFX1033 = 78,
96 
99 };
100 
101 /// Instruction set architecture version.
102 struct IsaVersion {
103  unsigned Major;
104  unsigned Minor;
105  unsigned Stepping;
106 };
107 
108 // This isn't comprehensive for now, just things that are needed from the
109 // frontend driver.
112 
113  // These features only exist for r600, and are implied true for amdgcn.
114  FEATURE_FMA = 1 << 1,
115  FEATURE_LDEXP = 1 << 2,
116  FEATURE_FP64 = 1 << 3,
117 
118  // Common features.
121 
122  // Wavefront 32 is available.
123  FEATURE_WAVE32 = 1 << 6,
124 
125  // Xnack is available.
126  FEATURE_XNACK = 1 << 7,
127 
128  // Sram-ecc is available.
129  FEATURE_SRAMECC = 1 << 8,
130 };
131 
137 unsigned getArchAttrAMDGCN(GPUKind AK);
138 unsigned getArchAttrR600(GPUKind AK);
139 
142 
143 IsaVersion getIsaVersion(StringRef GPU);
144 
145 } // namespace AMDGPU
146 
147 namespace RISCV {
148 
149 enum CPUKind : unsigned {
150 #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
151 #include "RISCVTargetParser.def"
152 };
153 
154 enum FeatureKind : unsigned {
156  FK_NONE = 1,
157  FK_STDEXTM = 1 << 2,
158  FK_STDEXTA = 1 << 3,
159  FK_STDEXTF = 1 << 4,
160  FK_STDEXTD = 1 << 5,
161  FK_STDEXTC = 1 << 6,
162  FK_64BIT = 1 << 7,
163 };
164 
165 bool checkCPUKind(CPUKind Kind, bool IsRV64);
166 bool checkTuneCPUKind(CPUKind Kind, bool IsRV64);
168 CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64);
170 void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
171 void fillValidTuneCPUArchList(SmallVectorImpl<StringRef> &Values, bool IsRV64);
172 bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector<StringRef> &Features);
173 StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64);
174 
175 } // namespace RISCV
176 
177 } // namespace llvm
178 
179 #endif
llvm::AMDGPU::GK_GFX802
@ GK_GFX802
Definition: TargetParser.h:75
llvm::AMDGPU::GK_GFX703
@ GK_GFX703
Definition: TargetParser.h:70
llvm::AMDGPU::IsaVersion::Stepping
unsigned Stepping
Definition: TargetParser.h:105
llvm::AMDGPU::FEATURE_LDEXP
@ FEATURE_LDEXP
Definition: TargetParser.h:115
llvm
Definition: AllocatorList.h:23
llvm::AMDGPU::GK_AMDGCN_FIRST
@ GK_AMDGCN_FIRST
Definition: TargetParser.h:97
llvm::AMDGPU::GK_GFX801
@ GK_GFX801
Definition: TargetParser.h:74
llvm::AMDGPU::GPUKind
GPUKind
GPU kinds supported by the AMDGPU target.
Definition: TargetParser.h:37
llvm::AMDGPU::GK_CAYMAN
@ GK_CAYMAN
Definition: TargetParser.h:56
llvm::AMDGPU::GK_RV670
@ GK_RV670
Definition: TargetParser.h:45
llvm::AMDGPU::GK_RV730
@ GK_RV730
Definition: TargetParser.h:47
llvm::AMDGPU::getArchAttrR600
unsigned getArchAttrR600(GPUKind AK)
Definition: TargetParser.cpp:169
AArch64TargetParser.h
llvm::AMDGPU::getIsaVersion
IsaVersion getIsaVersion(StringRef GPU)
Definition: TargetParser.cpp:186
llvm::AMDGPU::GK_GFX900
@ GK_GFX900
Definition: TargetParser.h:80
llvm::RISCV::CPUKind
CPUKind
Definition: TargetParser.h:149
llvm::AMDGPU::GK_R600
@ GK_R600
Definition: TargetParser.h:42
llvm::RISCV::FK_STDEXTC
@ FK_STDEXTC
Definition: TargetParser.h:161
llvm::AMDGPU::parseArchR600
GPUKind parseArchR600(StringRef CPU)
Definition: TargetParser.cpp:154
llvm::RISCV::FK_STDEXTD
@ FK_STDEXTD
Definition: TargetParser.h:160
llvm::AMDGPU::GK_GFX810
@ GK_GFX810
Definition: TargetParser.h:78
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::AMDGPU::GK_GFX700
@ GK_GFX700
Definition: TargetParser.h:67
llvm::AMDGPU::GK_GFX803
@ GK_GFX803
Definition: TargetParser.h:76
llvm::RISCV::resolveTuneCPUAlias
StringRef resolveTuneCPUAlias(StringRef TuneCPU, bool IsRV64)
Definition: TargetParser.cpp:275
llvm::RISCV::FK_NONE
@ FK_NONE
Definition: TargetParser.h:156
llvm::AMDGPU::GK_CEDAR
@ GK_CEDAR
Definition: TargetParser.h:49
llvm::AMDGPU::GK_GFX90C
@ GK_GFX90C
Definition: TargetParser.h:87
llvm::AMDGPU::GK_GFX602
@ GK_GFX602
Definition: TargetParser.h:65
llvm::AMDGPU::GK_CAICOS
@ GK_CAICOS
Definition: TargetParser.h:55
llvm::AMDGPU::IsaVersion::Major
unsigned Major
Definition: TargetParser.h:103
llvm::AMDGPU::GK_RV770
@ GK_RV770
Definition: TargetParser.h:48
llvm::AMDGPU::GK_RS880
@ GK_RS880
Definition: TargetParser.h:44
llvm::AMDGPU::GK_GFX702
@ GK_GFX702
Definition: TargetParser.h:69
llvm::AMDGPU::IsaVersion
Instruction set architecture version.
Definition: TargetParser.h:102
llvm::AMDGPU::getCanonicalArchName
StringRef getCanonicalArchName(const Triple &T, StringRef Arch)
Definition: TargetParser.cpp:230
llvm::RISCV::checkTuneCPUKind
bool checkTuneCPUKind(CPUKind Kind, bool IsRV64)
Definition: TargetParser.cpp:262
llvm::AMDGPU::GK_CYPRESS
@ GK_CYPRESS
Definition: TargetParser.h:50
llvm::AMDGPU::GK_GFX1012
@ GK_GFX1012
Definition: TargetParser.h:91
llvm::AMDGPU::GK_GFX1032
@ GK_GFX1032
Definition: TargetParser.h:94
llvm::RISCV::getMArchFromMcpu
StringRef getMArchFromMcpu(StringRef CPU)
Definition: TargetParser.cpp:291
llvm::AMDGPU::FEATURE_XNACK
@ FEATURE_XNACK
Definition: TargetParser.h:126
llvm::AMDGPU::GK_GFX909
@ GK_GFX909
Definition: TargetParser.h:85
llvm::AMDGPU::GK_GFX805
@ GK_GFX805
Definition: TargetParser.h:77
llvm::AMDGPU::GK_GFX906
@ GK_GFX906
Definition: TargetParser.h:83
llvm::AMDGPU::GK_R600_LAST
@ GK_R600_LAST
Definition: TargetParser.h:60
llvm::RISCV::FK_STDEXTM
@ FK_STDEXTM
Definition: TargetParser.h:157
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::AMDGPU::GK_BARTS
@ GK_BARTS
Definition: TargetParser.h:54
llvm::AMDGPU::ArchFeatureKind
ArchFeatureKind
Definition: TargetParser.h:110
llvm::AMDGPU::FEATURE_FP64
@ FEATURE_FP64
Definition: TargetParser.h:116
llvm::AMDGPU::FEATURE_FMA
@ FEATURE_FMA
Definition: TargetParser.h:114
llvm::RISCV::parseCPUKind
CPUKind parseCPUKind(StringRef CPU)
Definition: TargetParser.cpp:268
llvm::AMDGPU::FEATURE_WAVE32
@ FEATURE_WAVE32
Definition: TargetParser.h:123
llvm::RISCV::FK_STDEXTF
@ FK_STDEXTF
Definition: TargetParser.h:159
llvm::AMDGPU::GK_GFX904
@ GK_GFX904
Definition: TargetParser.h:82
llvm::AMDGPU::GK_GFX704
@ GK_GFX704
Definition: TargetParser.h:71
llvm::AMDGPU::GK_GFX701
@ GK_GFX701
Definition: TargetParser.h:68
ARMTargetParser.h
llvm::AMDGPU::GK_TURKS
@ GK_TURKS
Definition: TargetParser.h:57
llvm::AMDGPU::getArchNameAMDGCN
StringRef getArchNameAMDGCN(GPUKind AK)
Definition: TargetParser.cpp:133
llvm::AMDGPU::IsaVersion::Minor
unsigned Minor
Definition: TargetParser.h:104
llvm::AMDGPU::GK_GFX705
@ GK_GFX705
Definition: TargetParser.h:72
llvm::RISCV::fillValidCPUArchList
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values, bool IsRV64)
Provide a list of valid CPU names.
Definition: TargetParser.cpp:296
llvm::AMDGPU::FEATURE_SRAMECC
@ FEATURE_SRAMECC
Definition: TargetParser.h:129
Triple.h
llvm::AMDGPU::GK_GFX1030
@ GK_GFX1030
Definition: TargetParser.h:92
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
uint32_t
llvm::AMDGPU::GK_GFX908
@ GK_GFX908
Definition: TargetParser.h:84
llvm::AMDGPU::FEATURE_FAST_FMA_F32
@ FEATURE_FAST_FMA_F32
Definition: TargetParser.h:119
llvm::AMDGPU::GK_AMDGCN_LAST
@ GK_AMDGCN_LAST
Definition: TargetParser.h:98
llvm::AMDGPU::getArchNameR600
StringRef getArchNameR600(GPUKind AK)
Definition: TargetParser.cpp:139
llvm::AMDGPU::fillValidArchListR600
void fillValidArchListR600(SmallVectorImpl< StringRef > &Values)
Definition: TargetParser.cpp:181
llvm::AMDGPU::GK_R630
@ GK_R630
Definition: TargetParser.h:43
llvm::RISCV::fillValidTuneCPUArchList
void fillValidTuneCPUArchList(SmallVectorImpl< StringRef > &Values, bool IsRV64)
Definition: TargetParser.cpp:303
llvm::AMDGPU::GK_GFX1031
@ GK_GFX1031
Definition: TargetParser.h:93
llvm::AMDGPU::FEATURE_NONE
@ FEATURE_NONE
Definition: TargetParser.h:111
llvm::RISCV::FK_64BIT
@ FK_64BIT
Definition: TargetParser.h:162
llvm::AMDGPU::GK_GFX1010
@ GK_GFX1010
Definition: TargetParser.h:89
llvm::RISCV::FK_INVALID
@ FK_INVALID
Definition: TargetParser.h:155
llvm::AMDGPU::GK_JUNIPER
@ GK_JUNIPER
Definition: TargetParser.h:51
llvm::AMDGPU::GK_GFX1011
@ GK_GFX1011
Definition: TargetParser.h:90
llvm::AMDGPU::GK_RV710
@ GK_RV710
Definition: TargetParser.h:46
llvm::AMDGPU::GK_GFX600
@ GK_GFX600
Definition: TargetParser.h:63
llvm::AMDGPU::parseArchAMDGCN
GPUKind parseArchAMDGCN(StringRef CPU)
Definition: TargetParser.cpp:145
llvm::AMDGPU::getArchAttrAMDGCN
unsigned getArchAttrAMDGCN(GPUKind AK)
Definition: TargetParser.cpp:163
llvm::RISCV::FeatureKind
FeatureKind
Definition: TargetParser.h:154
llvm::RISCV::checkCPUKind
bool checkCPUKind(CPUKind Kind, bool IsRV64)
Definition: TargetParser.cpp:256
llvm::AMDGPU::GK_REDWOOD
@ GK_REDWOOD
Definition: TargetParser.h:52
llvm::AMDGPU::GK_NONE
@ GK_NONE
Definition: TargetParser.h:39
llvm::AMDGPU::GK_GFX902
@ GK_GFX902
Definition: TargetParser.h:81
llvm::AMDGPU::GK_SUMO
@ GK_SUMO
Definition: TargetParser.h:53
llvm::SmallVectorImpl< StringRef >
llvm::AMDGPU::GK_GFX601
@ GK_GFX601
Definition: TargetParser.h:64
llvm::AMDGPU::FEATURE_FAST_DENORMAL_F32
@ FEATURE_FAST_DENORMAL_F32
Definition: TargetParser.h:120
llvm::AMDGPU::GK_GFX1033
@ GK_GFX1033
Definition: TargetParser.h:95
llvm::RISCV::getCPUFeaturesExceptStdExt
bool getCPUFeaturesExceptStdExt(CPUKind Kind, std::vector< StringRef > &Features)
Definition: TargetParser.cpp:313
llvm::AMDGPU::GK_GFX90A
@ GK_GFX90A
Definition: TargetParser.h:86
llvm::RISCV::FK_STDEXTA
@ FK_STDEXTA
Definition: TargetParser.h:158
llvm::AMDGPU::fillValidArchListAMDGCN
void fillValidArchListAMDGCN(SmallVectorImpl< StringRef > &Values)
Definition: TargetParser.cpp:175
llvm::RISCV::parseTuneCPUKind
CPUKind parseTuneCPUKind(StringRef CPU, bool IsRV64)
Definition: TargetParser.cpp:282
llvm::AMDGPU::GK_R600_FIRST
@ GK_R600_FIRST
Definition: TargetParser.h:59