LLVM  14.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/SmallVector.h"
18 #include "llvm/ADT/StringRef.h"
20 #include <vector>
21 
22 // FIXME:This should be made into class design,to avoid dupplication.
23 namespace llvm {
24 
25 class Triple;
26 
27 namespace AArch64 {
28 
29 // Arch extension modifiers for CPUs.
32  AEK_NONE = 1,
33  AEK_CRC = 1 << 1,
34  AEK_CRYPTO = 1 << 2,
35  AEK_FP = 1 << 3,
36  AEK_SIMD = 1 << 4,
37  AEK_FP16 = 1 << 5,
38  AEK_PROFILE = 1 << 6,
39  AEK_RAS = 1 << 7,
40  AEK_LSE = 1 << 8,
41  AEK_SVE = 1 << 9,
42  AEK_DOTPROD = 1 << 10,
43  AEK_RCPC = 1 << 11,
44  AEK_RDM = 1 << 12,
45  AEK_SM4 = 1 << 13,
46  AEK_SHA3 = 1 << 14,
47  AEK_SHA2 = 1 << 15,
48  AEK_AES = 1 << 16,
49  AEK_FP16FML = 1 << 17,
50  AEK_RAND = 1 << 18,
51  AEK_MTE = 1 << 19,
52  AEK_SSBS = 1 << 20,
53  AEK_SB = 1 << 21,
54  AEK_PREDRES = 1 << 22,
55  AEK_SVE2 = 1 << 23,
56  AEK_SVE2AES = 1 << 24,
57  AEK_SVE2SM4 = 1 << 25,
58  AEK_SVE2SHA3 = 1 << 26,
59  AEK_SVE2BITPERM = 1 << 27,
60  AEK_TME = 1 << 28,
61  AEK_BF16 = 1 << 29,
62  AEK_I8MM = 1 << 30,
63  AEK_F32MM = 1ULL << 31,
64  AEK_F64MM = 1ULL << 32,
65  AEK_LS64 = 1ULL << 33,
66  AEK_BRBE = 1ULL << 34,
67  AEK_PAUTH = 1ULL << 35,
68  AEK_FLAGM = 1ULL << 36,
69  AEK_SME = 1ULL << 37,
70  AEK_SMEF64 = 1ULL << 38,
71  AEK_SMEI64 = 1ULL << 39,
72 };
73 
74 enum class ArchKind {
75 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
76 #include "AArch64TargetParser.def"
77 };
78 
80 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, \
81  ARCH_BASE_EXT) \
82  {NAME, \
83  sizeof(NAME) - 1, \
84  CPU_ATTR, \
85  sizeof(CPU_ATTR) - 1, \
86  SUB_ARCH, \
87  sizeof(SUB_ARCH) - 1, \
88  ARM::FPUKind::ARCH_FPU, \
89  ARCH_BASE_EXT, \
90  AArch64::ArchKind::ID, \
91  ARCH_ATTR},
92 #include "AArch64TargetParser.def"
93 };
94 
96 #define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
97  {NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE},
98 #include "AArch64TargetParser.def"
99 };
100 
102 #define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
103  {NAME, sizeof(NAME) - 1, AArch64::ArchKind::ID, IS_DEFAULT, DEFAULT_EXT},
104 #include "AArch64TargetParser.def"
105 };
106 
107 const ArchKind ArchKinds[] = {
108 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) \
109  ArchKind::ID,
110 #include "AArch64TargetParser.def"
111 };
112 
113 // FIXME: These should be moved to TargetTuple once it exists
114 bool getExtensionFeatures(uint64_t Extensions,
115  std::vector<StringRef> &Features);
116 bool getArchFeatures(ArchKind AK, std::vector<StringRef> &Features);
117 
119 unsigned getArchAttr(ArchKind AK);
124 
125 // Information by Name
126 unsigned getDefaultFPU(StringRef CPU, ArchKind AK);
130 
131 // Parser
135 // Used by target parser tests
137 
138 bool isX18ReservedByDefault(const Triple &TT);
139 
140 } // namespace AArch64
141 } // namespace llvm
142 
143 #endif
llvm::AArch64::getArchFeatures
bool getArchFeatures(ArchKind AK, std::vector< StringRef > &Features)
Definition: AArch64TargetParser.cpp:121
llvm::AArch64::AEK_NONE
@ AEK_NONE
Definition: AArch64TargetParser.h:32
llvm::AArch64::AEK_F64MM
@ AEK_F64MM
Definition: AArch64TargetParser.h:64
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
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::AEK_SIMD
@ AEK_SIMD
Definition: AArch64TargetParser.h:36
llvm::AArch64::AEK_SMEF64
@ AEK_SMEF64
Definition: AArch64TargetParser.h:70
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:62
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::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::AArch64::getCPUAttr
StringRef getCPUAttr(ArchKind AK)
Definition: AArch64TargetParser.cpp:155
llvm::AArch64::AEK_FP16
@ AEK_FP16
Definition: AArch64TargetParser.h:37
llvm::AArch64::parseArchExt
ArchExtKind parseArchExt(StringRef ArchExt)
Definition: AArch64TargetParser.cpp:229
llvm::AArch64::AEK_SVE2SM4
@ AEK_SVE2SM4
Definition: AArch64TargetParser.h:57
llvm::AArch64::getArchExtName
StringRef getArchExtName(unsigned ArchExtKind)
Definition: AArch64TargetParser.cpp:167
llvm::AArch64::getDefaultExtensions
uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK)
Definition: AArch64TargetParser.cpp:38
llvm::AArch64::getDefaultCPU
StringRef getDefaultCPU(StringRef Arch)
Definition: AArch64TargetParser.cpp:189
llvm::AArch64::getArchAttr
unsigned getArchAttr(ArchKind AK)
Definition: AArch64TargetParser.cpp:163
llvm::AArch64::AEK_DOTPROD
@ AEK_DOTPROD
Definition: AArch64TargetParser.h:42
llvm::AArch64::getArchExtFeature
StringRef getArchExtFeature(StringRef ArchExt)
Definition: AArch64TargetParser.cpp:174
llvm::AArch64::AArch64CPUNames
const ARM::CpuNames< ArchKind > AArch64CPUNames[]
Definition: AArch64TargetParser.h:101
llvm::AArch64::AEK_INVALID
@ AEK_INVALID
Definition: AArch64TargetParser.h:31
llvm::AArch64::AEK_SVE2AES
@ AEK_SVE2AES
Definition: AArch64TargetParser.h:56
llvm::AArch64::AEK_SMEI64
@ AEK_SMEI64
Definition: AArch64TargetParser.h:71
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::ARM::ExtName
Definition: ARMTargetParser.h:73
llvm::AArch64::AEK_SME
@ AEK_SME
Definition: AArch64TargetParser.h:69
llvm::AArch64::isX18ReservedByDefault
bool isX18ReservedByDefault(const Triple &TT)
Definition: AArch64TargetParser.cpp:210
llvm::AArch64::getDefaultFPU
unsigned getDefaultFPU(StringRef CPU, ArchKind AK)
Definition: AArch64TargetParser.cpp:27
llvm::AArch64::AEK_SVE
@ AEK_SVE
Definition: AArch64TargetParser.h:41
llvm::AArch64::AEK_SHA2
@ AEK_SHA2
Definition: AArch64TargetParser.h:47
uint64_t
llvm::AArch64::AEK_CRC
@ AEK_CRC
Definition: AArch64TargetParser.h:33
llvm::AArch64::getArchName
StringRef getArchName(ArchKind AK)
Definition: AArch64TargetParser.cpp:151
llvm::AArch64::ArchKinds
const ArchKind ArchKinds[]
Definition: AArch64TargetParser.h:107
ARMTargetParser.h
llvm::ARM::CpuNames
Definition: ARMTargetParser.h:114
llvm::AArch64::AEK_RDM
@ AEK_RDM
Definition: AArch64TargetParser.h:44
llvm::AArch64::AArch64ARCHNames
const ARM::ArchNames< ArchKind > AArch64ARCHNames[]
Definition: AArch64TargetParser.h:79
llvm::AArch64::AEK_BF16
@ AEK_BF16
Definition: AArch64TargetParser.h:61
llvm::AArch64::fillValidCPUArchList
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)
Definition: AArch64TargetParser.cpp:203
llvm::AArch64::parseCPUArch
ArchKind parseCPUArch(StringRef CPU)
Definition: AArch64TargetParser.cpp:237
llvm::AArch64::AEK_BRBE
@ AEK_BRBE
Definition: AArch64TargetParser.h:66
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:216
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::AArch64::AArch64ARCHExtNames
const ARM::ExtName AArch64ARCHExtNames[]
Definition: AArch64TargetParser.h:95
llvm::AArch64::AEK_PAUTH
@ AEK_PAUTH
Definition: AArch64TargetParser.h:67
llvm::AArch64::AEK_PROFILE
@ AEK_PROFILE
Definition: AArch64TargetParser.h:38
llvm::AArch64::AEK_SHA3
@ AEK_SHA3
Definition: AArch64TargetParser.h:46
llvm::AArch64::AEK_SVE2BITPERM
@ AEK_SVE2BITPERM
Definition: AArch64TargetParser.h:59
llvm::AArch64::getSubArch
StringRef getSubArch(ArchKind AK)
Definition: AArch64TargetParser.cpp:159
llvm::AArch64::AEK_FLAGM
@ AEK_FLAGM
Definition: AArch64TargetParser.h:68
llvm::ARM::ArchNames
Definition: ARMTargetParser.h:202
llvm::AArch64::AEK_I8MM
@ AEK_I8MM
Definition: AArch64TargetParser.h:62
llvm::AArch64::getCPUArchKind
ArchKind getCPUArchKind(StringRef CPU)
Definition: AArch64TargetParser.cpp:51
SmallVector.h
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:74
llvm::SmallVectorImpl< StringRef >
llvm::AArch64::AEK_FP16FML
@ AEK_FP16FML
Definition: AArch64TargetParser.h:49
llvm::AArch64::AEK_AES
@ AEK_AES
Definition: AArch64TargetParser.h:48
llvm::AArch64::AEK_MTE
@ AEK_MTE
Definition: AArch64TargetParser.h:51