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