1 //===-- AArch64TargetParser - Parser for AArch64 features -------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements a target parser to recognise AArch64 hardware features
10 // such as FPU/CPU/ARCH and extension names.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_AARCH64TARGETPARSERCOMMON_H
15 #define LLVM_SUPPORT_AARCH64TARGETPARSERCOMMON_H
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Support/ARMTargetParser.h"
22 // FIXME:This should be made into class design,to avoid dupplication.
26 // Arch extension modifiers for CPUs.
27 enum ArchExtKind
: unsigned {
39 AEK_DOTPROD
= 1 << 10,
46 AEK_FP16FML
= 1 << 17,
51 AEK_PREDRES
= 1 << 22,
53 AEK_SVE2AES
= 1 << 24,
54 AEK_SVE2SM4
= 1 << 25,
55 AEK_SVE2SHA3
= 1 << 26,
56 AEK_SVE2BITPERM
= 1 << 27,
61 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
62 #include "AArch64TargetParser.def"
65 const ARM::ArchNames
<ArchKind
> AArch64ARCHNames
[] = {
66 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, \
71 sizeof(CPU_ATTR) - 1, \
73 sizeof(SUB_ARCH) - 1, \
74 ARM::FPUKind::ARCH_FPU, \
76 AArch64::ArchKind::ID, \
78 #include "AArch64TargetParser.def"
81 const ARM::ExtName AArch64ARCHExtNames
[] = {
82 #define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
83 {NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE},
84 #include "AArch64TargetParser.def"
87 const ARM::CpuNames
<ArchKind
> AArch64CPUNames
[] = {
88 #define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
89 {NAME, sizeof(NAME) - 1, AArch64::ArchKind::ID, IS_DEFAULT, DEFAULT_EXT},
90 #include "AArch64TargetParser.def"
93 const ArchKind ArchKinds
[] = {
94 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) \
96 #include "AArch64TargetParser.def"
99 // FIXME: These should be moved to TargetTuple once it exists
100 bool getExtensionFeatures(unsigned Extensions
,
101 std::vector
<StringRef
> &Features
);
102 bool getArchFeatures(ArchKind AK
, std::vector
<StringRef
> &Features
);
104 StringRef
getArchName(ArchKind AK
);
105 unsigned getArchAttr(ArchKind AK
);
106 StringRef
getCPUAttr(ArchKind AK
);
107 StringRef
getSubArch(ArchKind AK
);
108 StringRef
getArchExtName(unsigned ArchExtKind
);
109 StringRef
getArchExtFeature(StringRef ArchExt
);
111 // Information by Name
112 unsigned getDefaultFPU(StringRef CPU
, ArchKind AK
);
113 unsigned getDefaultExtensions(StringRef CPU
, ArchKind AK
);
114 StringRef
getDefaultCPU(StringRef Arch
);
115 ArchKind
getCPUArchKind(StringRef CPU
);
118 ArchKind
parseArch(StringRef Arch
);
119 ArchExtKind
parseArchExt(StringRef ArchExt
);
120 ArchKind
parseCPUArch(StringRef CPU
);
121 // Used by target parser tests
122 void fillValidCPUArchList(SmallVectorImpl
<StringRef
> &Values
);
124 bool isX18ReservedByDefault(const Triple
&TT
);
126 } // namespace AArch64