1 //===-- AArch64TargetParser - Parser for AArch64 features -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements a target parser to recognise AArch64 hardware features
11 // such as FPU/CPU/ARCH and extension names.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SUPPORT_AARCH64TARGETPARSERCOMMON_H
16 #define LLVM_SUPPORT_AARCH64TARGETPARSERCOMMON_H
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/Support/ARMTargetParser.h"
23 // FIXME:This should be made into class design,to avoid dupplication.
27 // Arch extension modifiers for CPUs.
28 enum ArchExtKind : unsigned {
40 AEK_DOTPROD = 1 << 10,
47 AEK_FP16FML = 1 << 17,
52 AEK_PREDRES = 1 << 22,
56 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
57 #include "AArch64TargetParser.def"
60 const ARM::ArchNames<ArchKind> AArch64ARCHNames[] = {
61 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, \
66 sizeof(CPU_ATTR) - 1, \
68 sizeof(SUB_ARCH) - 1, \
69 ARM::FPUKind::ARCH_FPU, \
71 AArch64::ArchKind::ID, \
73 #include "AArch64TargetParser.def"
76 const ARM::ExtName AArch64ARCHExtNames[] = {
77 #define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
78 {NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE},
79 #include "AArch64TargetParser.def"
82 const ARM::CpuNames<ArchKind> AArch64CPUNames[] = {
83 #define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
84 {NAME, sizeof(NAME) - 1, AArch64::ArchKind::ID, IS_DEFAULT, DEFAULT_EXT},
85 #include "AArch64TargetParser.def"
88 const ArchKind ArchKinds[] = {
89 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) \
91 #include "AArch64TargetParser.def"
94 // FIXME: These should be moved to TargetTuple once it exists
95 bool getExtensionFeatures(unsigned Extensions,
96 std::vector<StringRef> &Features);
97 bool getArchFeatures(ArchKind AK, std::vector<StringRef> &Features);
99 StringRef getArchName(ArchKind AK);
100 unsigned getArchAttr(ArchKind AK);
101 StringRef getCPUAttr(ArchKind AK);
102 StringRef getSubArch(ArchKind AK);
103 StringRef getArchExtName(unsigned ArchExtKind);
104 StringRef getArchExtFeature(StringRef ArchExt);
106 // Information by Name
107 unsigned getDefaultFPU(StringRef CPU, ArchKind AK);
108 unsigned getDefaultExtensions(StringRef CPU, ArchKind AK);
109 StringRef getDefaultCPU(StringRef Arch);
110 ArchKind getCPUArchKind(StringRef CPU);
113 ArchKind parseArch(StringRef Arch);
114 ArchExtKind parseArchExt(StringRef ArchExt);
115 ArchKind parseCPUArch(StringRef CPU);
116 // Used by target parser tests
117 void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
119 bool isX18ReservedByDefault(const Triple &TT);
121 } // namespace AArch64