LLVM  16.0.0git
AArch64TargetParser.h
Go to the documentation of this file.
1 //===-- AArch64TargetParser - Parser for AArch64 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 AArch64 hardware features
10 // such as FPU/CPU/ARCH and extension names.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_SUPPORT_AARCH64TARGETPARSER_H
15 #define LLVM_SUPPORT_AARCH64TARGETPARSER_H
16 
17 #include "llvm/ADT/StringRef.h"
18 #include <vector>
19 
20 // FIXME:This should be made into class design,to avoid dupplication.
21 namespace llvm {
22 
23 class Triple;
24 
25 namespace AArch64 {
26 
27 // Arch extension modifiers for CPUs. These are labelled with their Arm ARM
28 // feature name (though the canonical reference for those is AArch64.td)
29 // clang-format off
32  AEK_NONE = 1,
33  AEK_CRC = 1 << 1, // FEAT_CRC32
34  AEK_CRYPTO = 1 << 2,
35  AEK_FP = 1 << 3, // FEAT_FP
36  AEK_SIMD = 1 << 4, // FEAT_AdvSIMD
37  AEK_FP16 = 1 << 5, // FEAT_FP16
38  AEK_PROFILE = 1 << 6, // FEAT_SPE
39  AEK_RAS = 1 << 7, // FEAT_RAS, FEAT_RASv1p1
40  AEK_LSE = 1 << 8, // FEAT_LSE
41  AEK_SVE = 1 << 9, // FEAT_SVE
42  AEK_DOTPROD = 1 << 10, // FEAT_DotProd
43  AEK_RCPC = 1 << 11, // FEAT_LRCPC
44  AEK_RDM = 1 << 12, // FEAT_RDM
45  AEK_SM4 = 1 << 13, // FEAT_SM4, FEAT_SM3
46  AEK_SHA3 = 1 << 14, // FEAT_SHA3, FEAT_SHA512
47  AEK_SHA2 = 1 << 15, // FEAT_SHA1, FEAT_SHA256
48  AEK_AES = 1 << 16, // FEAT_AES, FEAT_PMULL
49  AEK_FP16FML = 1 << 17, // FEAT_FHM
50  AEK_RAND = 1 << 18, // FEAT_RNG
51  AEK_MTE = 1 << 19, // FEAT_MTE, FEAT_MTE2
52  AEK_SSBS = 1 << 20, // FEAT_SSBS, FEAT_SSBS2
53  AEK_SB = 1 << 21, // FEAT_SB
54  AEK_PREDRES = 1 << 22, // FEAT_SPECRES
55  AEK_SVE2 = 1 << 23, // FEAT_SVE2
56  AEK_SVE2AES = 1 << 24, // FEAT_SVE_AES, FEAT_SVE_PMULL128
57  AEK_SVE2SM4 = 1 << 25, // FEAT_SVE_SM4
58  AEK_SVE2SHA3 = 1 << 26, // FEAT_SVE_SHA3
59  AEK_SVE2BITPERM = 1 << 27, // FEAT_SVE_BitPerm
60  AEK_TME = 1 << 28, // FEAT_TME
61  AEK_BF16 = 1 << 29, // FEAT_BF16
62  AEK_I8MM = 1 << 30, // FEAT_I8MM
63  AEK_F32MM = 1ULL << 31, // FEAT_F32MM
64  AEK_F64MM = 1ULL << 32, // FEAT_F64MM
65  AEK_LS64 = 1ULL << 33, // FEAT_LS64, FEAT_LS64_V, FEAT_LS64_ACCDATA
66  AEK_BRBE = 1ULL << 34, // FEAT_BRBE
67  AEK_PAUTH = 1ULL << 35, // FEAT_PAuth
68  AEK_FLAGM = 1ULL << 36, // FEAT_FlagM
69  AEK_SME = 1ULL << 37, // FEAT_SME
70  AEK_SMEF64F64 = 1ULL << 38, // FEAT_SME_F64F64
71  AEK_SMEI16I64 = 1ULL << 39, // FEAT_SME_I16I64
72  AEK_HBC = 1ULL << 40, // FEAT_HBC
73  AEK_MOPS = 1ULL << 41, // FEAT_MOPS
74  AEK_PERFMON = 1ULL << 42, // FEAT_PMUv3
75  AEK_SME2 = 1ULL << 43, // FEAT_SME2
76  AEK_SVE2p1 = 1ULL << 44, // FEAT_SVE2p1
77  AEK_SME2p1 = 1ULL << 45, // FEAT_SME2p1
78  AEK_B16B16 = 1ULL << 46, // FEAT_B16B16
79  AEK_SMEF16F16 = 1ULL << 47, // FEAT_SMEF16F16
80  AEK_CSSC = 1ULL << 48, // FEAT_CSSC
81  AEK_RCPC3 = 1ULL << 49, // FEAT_LRCPC3
82  AEK_THE = 1ULL << 50, // FEAT_THE
83  AEK_D128 = 1ULL << 51, // FEAT_D128
84  AEK_LSE128 = 1ULL << 52, // FEAT_LSE128
85 };
86 // clang-format on
87 
88 enum class ArchKind {
89 #define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT) ID,
90 #include "AArch64TargetParser.def"
91 };
92 
93 struct ArchNames {
98 
99  // Return ArchFeature without the leading "+".
100  StringRef getSubArch() const { return ArchFeature.substr(1); }
101 };
102 
104 #define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT) \
105  {NAME, ARCH_FEATURE, ARCH_BASE_EXT, AArch64::ArchKind::ID},
106 #include "AArch64TargetParser.def"
107 };
108 
109 // List of Arch Extension names.
110 struct ExtName {
115 };
116 
118 #define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
119  {NAME, ID, FEATURE, NEGFEATURE},
120 #include "AArch64TargetParser.def"
121 };
122 
123 // List of CPU names and their arches.
124 // The same CPU can have multiple arches and can be default on multiple arches.
125 // When finding the Arch for a CPU, first-found prevails. Sort them accordingly.
126 // When this becomes table-generated, we'd probably need two tables.
127 struct CpuNames {
131 };
132 
134 #define AARCH64_CPU_NAME(NAME, ID, DEFAULT_EXT) \
135  {NAME, AArch64::ArchKind::ID, DEFAULT_EXT},
136 #include "AArch64TargetParser.def"
137 };
138 
139 const struct {
142 } AArch64CPUAliases[] = {
143 #define AARCH64_CPU_ALIAS(ALIAS, NAME) {ALIAS, NAME},
144 #include "AArch64TargetParser.def"
145 };
146 
147 const ArchKind ArchKinds[] = {
148 #define AARCH64_ARCH(NAME, ID, ARCH_FEATURE, ARCH_BASE_EXT) ArchKind::ID,
149 #include "AArch64TargetParser.def"
150 };
151 
152 inline ArchKind &operator--(ArchKind &Kind) {
153  if ((Kind == ArchKind::INVALID) || (Kind == ArchKind::ARMV8A) ||
154  (Kind == ArchKind::ARMV9A) || (Kind == ArchKind::ARMV8R))
155  Kind = ArchKind::INVALID;
156  else {
157  unsigned KindAsInteger = static_cast<unsigned>(Kind);
158  Kind = static_cast<ArchKind>(--KindAsInteger);
159  }
160  return Kind;
161 }
162 
163 bool getExtensionFeatures(uint64_t Extensions,
164  std::vector<StringRef> &Features);
166 
173 
174 // Information by Name
178 
179 // Parser
183 // Used by target parser tests
185 
186 bool isX18ReservedByDefault(const Triple &TT);
187 
188 } // namespace AArch64
189 } // namespace llvm
190 
191 #endif
llvm::AArch64::getArchFeature
StringRef getArchFeature(ArchKind AK)
Definition: AArch64TargetParser.cpp:82
llvm::AArch64::AEK_NONE
@ AEK_NONE
Definition: AArch64TargetParser.h:32
llvm::AArch64::AEK_F64MM
@ AEK_F64MM
Definition: AArch64TargetParser.h:64
llvm::AArch64::CpuNames::ArchID
ArchKind ArchID
Definition: AArch64TargetParser.h:129
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::AArch64::ArchExtKind
ArchExtKind
Definition: AArch64TargetParser.h:30
llvm::AArch64::AEK_PREDRES
@ AEK_PREDRES
Definition: AArch64TargetParser.h:54
llvm::AArch64::AEK_RCPC
@ AEK_RCPC
Definition: AArch64TargetParser.h:43
llvm::AArch64::AEK_SVE2
@ AEK_SVE2
Definition: AArch64TargetParser.h:55
llvm::AArch64::ExtName
Definition: AArch64TargetParser.h:110
llvm::AArch64::AEK_SIMD
@ AEK_SIMD
Definition: AArch64TargetParser.h:36
StringRef.h
llvm::AArch64::AEK_CRYPTO
@ AEK_CRYPTO
Definition: AArch64TargetParser.h:34
llvm::AArch64::AEK_SSBS
@ AEK_SSBS
Definition: AArch64TargetParser.h:52
llvm::AArch64::getExtensionFeatures
bool getExtensionFeatures(uint64_t Extensions, std::vector< StringRef > &Features)
Definition: AArch64TargetParser.cpp:58
llvm::AArch64::AEK_TME
@ AEK_TME
Definition: AArch64TargetParser.h:60
llvm::AArch64::AEK_LS64
@ AEK_LS64
Definition: AArch64TargetParser.h:65
llvm::AArch64::AEK_RAND
@ AEK_RAND
Definition: AArch64TargetParser.h:50
llvm::AArch64::AEK_PERFMON
@ AEK_PERFMON
Definition: AArch64TargetParser.h:74
llvm::AArch64::AArch64ARCHExtNames
const ExtName AArch64ARCHExtNames[]
Definition: AArch64TargetParser.h:117
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::AArch64::AEK_FP16
@ AEK_FP16
Definition: AArch64TargetParser.h:37
llvm::AArch64::parseArchExt
ArchExtKind parseArchExt(StringRef ArchExt)
Definition: AArch64TargetParser.cpp:151
llvm::AArch64::operator--
ArchKind & operator--(ArchKind &Kind)
Definition: AArch64TargetParser.h:152
llvm::AArch64::AEK_SVE2SM4
@ AEK_SVE2SM4
Definition: AArch64TargetParser.h:57
llvm::AArch64::AEK_SMEI16I64
@ AEK_SMEI16I64
Definition: AArch64TargetParser.h:71
llvm::StringRef::substr
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:564
llvm::AArch64::getArchExtName
StringRef getArchExtName(unsigned ArchExtKind)
llvm::AArch64::getDefaultExtensions
uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK)
Definition: AArch64TargetParser.cpp:28
llvm::AArch64::AEK_THE
@ AEK_THE
Definition: AArch64TargetParser.h:82
llvm::AArch64::AEK_DOTPROD
@ AEK_DOTPROD
Definition: AArch64TargetParser.h:42
llvm::AArch64::getArchExtFeature
StringRef getArchExtFeature(StringRef ArchExt)
Definition: AArch64TargetParser.cpp:94
llvm::AArch64::AEK_MOPS
@ AEK_MOPS
Definition: AArch64TargetParser.h:73
llvm::AArch64::ExtName::ID
uint64_t ID
Definition: AArch64TargetParser.h:112
llvm::AArch64::ArchNames::ArchFeature
StringRef ArchFeature
Definition: AArch64TargetParser.h:95
llvm::AArch64::AEK_SME2p1
@ AEK_SME2p1
Definition: AArch64TargetParser.h:77
llvm::AArch64::AEK_INVALID
@ AEK_INVALID
Definition: AArch64TargetParser.h:31
llvm::AArch64::AEK_SVE2AES
@ AEK_SVE2AES
Definition: AArch64TargetParser.h:56
llvm::AArch64::AEK_SVE2SHA3
@ AEK_SVE2SHA3
Definition: AArch64TargetParser.h:58
llvm::AArch64::AEK_LSE
@ AEK_LSE
Definition: AArch64TargetParser.h:40
llvm::AArch64::AEK_SB
@ AEK_SB
Definition: AArch64TargetParser.h:53
llvm::AArch64::getSubArchArchKind
ArchKind getSubArchArchKind(StringRef SubArch)
Definition: AArch64TargetParser.cpp:51
llvm::AArch64::AEK_D128
@ AEK_D128
Definition: AArch64TargetParser.h:83
llvm::AArch64::CpuNames
Definition: AArch64TargetParser.h:127
llvm::AArch64::AEK_SME
@ AEK_SME
Definition: AArch64TargetParser.h:69
llvm::AArch64::ArchNames::getSubArch
StringRef getSubArch() const
Definition: AArch64TargetParser.h:100
llvm::AArch64::ExtName::Name
StringRef Name
Definition: AArch64TargetParser.h:111
llvm::AArch64::isX18ReservedByDefault
bool isX18ReservedByDefault(const Triple &TT)
Definition: AArch64TargetParser.cpp:132
llvm::AArch64::AEK_SVE
@ AEK_SVE
Definition: AArch64TargetParser.h:41
llvm::AArch64::AEK_SHA2
@ AEK_SHA2
Definition: AArch64TargetParser.h:47
llvm::AArch64::convertV9toV8
ArchKind convertV9toV8(ArchKind AK)
Definition: AArch64TargetParser.cpp:109
llvm::AArch64::AEK_SMEF16F16
@ AEK_SMEF16F16
Definition: AArch64TargetParser.h:79
llvm::AArch64::ArchNames::Name
StringRef Name
Definition: AArch64TargetParser.h:94
uint64_t
llvm::AArch64::AEK_CRC
@ AEK_CRC
Definition: AArch64TargetParser.h:33
llvm::AArch64::AEK_RCPC3
@ AEK_RCPC3
Definition: AArch64TargetParser.h:81
llvm::AArch64::ArchNames
Definition: AArch64TargetParser.h:93
llvm::AArch64::getArchName
StringRef getArchName(ArchKind AK)
Definition: AArch64TargetParser.cpp:86
llvm::AArch64::ArchKinds
const ArchKind ArchKinds[]
Definition: AArch64TargetParser.h:147
llvm::AArch64::ArchNames::ArchBaseExtensions
uint64_t ArchBaseExtensions
Definition: AArch64TargetParser.h:96
llvm::AArch64::AEK_RDM
@ AEK_RDM
Definition: AArch64TargetParser.h:44
llvm::AArch64::AArch64CPUAliases
const struct llvm::AArch64::@357 AArch64CPUAliases[]
llvm::AArch64::AEK_BF16
@ AEK_BF16
Definition: AArch64TargetParser.h:61
llvm::AArch64::fillValidCPUArchList
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)
Definition: AArch64TargetParser.cpp:122
llvm::AArch64::parseCPUArch
ArchKind parseCPUArch(StringRef CPU)
Definition: AArch64TargetParser.cpp:159
llvm::AArch64::AEK_BRBE
@ AEK_BRBE
Definition: AArch64TargetParser.h:66
llvm::AArch64::ExtName::NegFeature
StringRef NegFeature
Definition: AArch64TargetParser.h:114
llvm::AArch64::AEK_F32MM
@ AEK_F32MM
Definition: AArch64TargetParser.h:63
llvm::AArch64::AEK_RAS
@ AEK_RAS
Definition: AArch64TargetParser.h:39
llvm::AArch64::parseArch
ArchKind parseArch(StringRef Arch)
Definition: AArch64TargetParser.cpp:138
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::AArch64::AEK_PAUTH
@ AEK_PAUTH
Definition: AArch64TargetParser.h:67
llvm::AArch64::Name
StringRef Name
Definition: AArch64TargetParser.h:141
llvm::AArch64::AEK_PROFILE
@ AEK_PROFILE
Definition: AArch64TargetParser.h:38
llvm::AArch64::CpuNames::DefaultExtensions
uint64_t DefaultExtensions
Definition: AArch64TargetParser.h:130
llvm::AArch64::AEK_LSE128
@ AEK_LSE128
Definition: AArch64TargetParser.h:84
llvm::AArch64::Alias
StringRef Alias
Definition: AArch64TargetParser.h:140
llvm::AArch64::AEK_CSSC
@ AEK_CSSC
Definition: AArch64TargetParser.h:80
llvm::AArch64::ArchNames::ID
ArchKind ID
Definition: AArch64TargetParser.h:97
llvm::AArch64::AArch64CPUNames
const CpuNames AArch64CPUNames[]
Definition: AArch64TargetParser.h:133
llvm::AArch64::AEK_SHA3
@ AEK_SHA3
Definition: AArch64TargetParser.h:46
llvm::AArch64::AEK_SVE2p1
@ AEK_SVE2p1
Definition: AArch64TargetParser.h:76
llvm::AArch64::CpuNames::Name
StringRef Name
Definition: AArch64TargetParser.h:128
llvm::AArch64::AEK_SVE2BITPERM
@ AEK_SVE2BITPERM
Definition: AArch64TargetParser.h:59
llvm::AArch64::getSubArch
StringRef getSubArch(ArchKind AK)
Definition: AArch64TargetParser.cpp:90
llvm::AArch64::ExtName::Feature
StringRef Feature
Definition: AArch64TargetParser.h:113
llvm::AArch64::AEK_FLAGM
@ AEK_FLAGM
Definition: AArch64TargetParser.h:68
llvm::AArch64::AEK_I8MM
@ AEK_I8MM
Definition: AArch64TargetParser.h:62
llvm::AArch64::getCPUArchKind
ArchKind getCPUArchKind(StringRef CPU)
Definition: AArch64TargetParser.cpp:41
llvm::AArch64::AEK_SME2
@ AEK_SME2
Definition: AArch64TargetParser.h:75
llvm::AArch64::AEK_FP
@ AEK_FP
Definition: AArch64TargetParser.h:35
llvm::AArch64::AEK_SM4
@ AEK_SM4
Definition: AArch64TargetParser.h:45
llvm::AArch64::ArchKind
ArchKind
Definition: AArch64TargetParser.h:88
llvm::AArch64::AEK_B16B16
@ AEK_B16B16
Definition: AArch64TargetParser.h:78
llvm::AArch64::AEK_SMEF64F64
@ AEK_SMEF64F64
Definition: AArch64TargetParser.h:70
llvm::SmallVectorImpl< StringRef >
llvm::AArch64::resolveCPUAlias
StringRef resolveCPUAlias(StringRef CPU)
Definition: AArch64TargetParser.cpp:75
llvm::AArch64::AEK_FP16FML
@ AEK_FP16FML
Definition: AArch64TargetParser.h:49
llvm::AArch64::AArch64ARCHNames
const ArchNames AArch64ARCHNames[]
Definition: AArch64TargetParser.h:103
llvm::AArch64::AEK_HBC
@ AEK_HBC
Definition: AArch64TargetParser.h:72
llvm::AArch64::AEK_AES
@ AEK_AES
Definition: AArch64TargetParser.h:48
llvm::AArch64::AEK_MTE
@ AEK_MTE
Definition: AArch64TargetParser.h:51