LLVM  12.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_AARCH64TARGETPARSERCOMMON_H
15 #define LLVM_SUPPORT_AARCH64TARGETPARSERCOMMON_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.
30 enum ArchExtKind : uint64_t {
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 };
66 
67 enum class ArchKind {
68 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
69 #include "AArch64TargetParser.def"
70 };
71 
73 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, \
74  ARCH_BASE_EXT) \
75  {NAME, \
76  sizeof(NAME) - 1, \
77  CPU_ATTR, \
78  sizeof(CPU_ATTR) - 1, \
79  SUB_ARCH, \
80  sizeof(SUB_ARCH) - 1, \
81  ARM::FPUKind::ARCH_FPU, \
82  ARCH_BASE_EXT, \
83  AArch64::ArchKind::ID, \
84  ARCH_ATTR},
85 #include "AArch64TargetParser.def"
86 };
87 
89 #define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
90  {NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE},
91 #include "AArch64TargetParser.def"
92 };
93 
95 #define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
96  {NAME, sizeof(NAME) - 1, AArch64::ArchKind::ID, IS_DEFAULT, DEFAULT_EXT},
97 #include "AArch64TargetParser.def"
98 };
99 
100 const ArchKind ArchKinds[] = {
101 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) \
102  ArchKind::ID,
103 #include "AArch64TargetParser.def"
104 };
105 
106 // FIXME: These should be moved to TargetTuple once it exists
107 bool getExtensionFeatures(unsigned Extensions,
108  std::vector<StringRef> &Features);
109 bool getArchFeatures(ArchKind AK, std::vector<StringRef> &Features);
110 
112 unsigned getArchAttr(ArchKind AK);
117 
118 // Information by Name
119 unsigned getDefaultFPU(StringRef CPU, ArchKind AK);
120 unsigned getDefaultExtensions(StringRef CPU, ArchKind AK);
123 
124 // Parser
126 ArchExtKind parseArchExt(StringRef ArchExt);
128 // Used by target parser tests
130 
131 bool isX18ReservedByDefault(const Triple &TT);
132 
137 };
138 
140  StringRef &Err);
141 
142 } // namespace AArch64
143 } // namespace llvm
144 
145 #endif
unsigned getArchAttr(ArchKind AK)
This class represents lattice values for constants.
Definition: AllocatorList.h:23
ArchKind getCPUArchKind(StringRef CPU)
StringRef getCPUAttr(ArchKind AK)
ArchExtKind parseArchExt(StringRef ArchExt)
StringRef getArchExtName(unsigned ArchExtKind)
unsigned getDefaultFPU(StringRef CPU, ArchKind AK)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
StringRef getArchExtFeature(StringRef ArchExt)
bool getExtensionFeatures(unsigned Extensions, std::vector< StringRef > &Features)
ArchKind parseArch(StringRef Arch)
StringRef getArchName(ArchKind AK)
bool parseBranchProtection(StringRef Spec, ParsedBranchProtection &PBP, StringRef &Err)
bool isX18ReservedByDefault(const Triple &TT)
const ARM::ExtName AArch64ARCHExtNames[]
const ARM::CpuNames< ArchKind > AArch64CPUNames[]
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
const ArchKind ArchKinds[]
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)
const ARM::ArchNames< ArchKind > AArch64ARCHNames[]
ArchKind parseCPUArch(StringRef CPU)
StringRef getSubArch(ArchKind AK)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
bool getArchFeatures(ArchKind AK, std::vector< StringRef > &Features)
StringRef getDefaultCPU(StringRef Arch)
unsigned getDefaultExtensions(StringRef CPU, ArchKind AK)