1 //===-- TargetParser - Parser for target 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 hardware features such as
11 // FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SUPPORT_TARGETPARSER_H
16 #define LLVM_SUPPORT_TARGETPARSER_H
18 // FIXME: vector is used because that's what clang uses for subtarget feature
19 // lists, but SmallVector would probably be better
25 // Target specific information into their own namespaces. These should be
26 // generated from TableGen because the information is already there, and there
27 // is where new information about targets will be added.
28 // FIXME: To TableGen this we need to make some table generated files available
29 // even if the back-end is not compiled with LLVM, plus we need to create a new
30 // back-end to TableGen to create these clean tables.
35 #define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION) KIND,
36 #include "ARMTargetParser.def"
50 // An FPU name implies one of three levels of Neon support:
51 enum NeonSupportLevel {
52 NS_None = 0, ///< No Neon
54 NS_Crypto ///< Neon with Crypto
57 // An FPU name restricts the FPU in one of three ways:
59 FR_None = 0, ///< No restriction
60 FR_D16, ///< Only 16 D registers
61 FR_SP_D16 ///< Only single-precision instructions, with 16 D registers
66 #define ARM_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
67 #include "ARMTargetParser.def"
71 // Arch extension modifiers for CPUs.
72 enum ArchExtKind : unsigned {
87 // Unsupported extensions.
89 AEK_IWMMXT = 0x10000000,
90 AEK_IWMMXT2 = 0x20000000,
91 AEK_MAVERICK = 0x40000000,
92 AEK_XSCALE = 0x80000000,
96 enum ISAKind { IK_INVALID = 0, IK_ARM, IK_THUMB, IK_AARCH64 };
99 // FIXME: BE8 vs. BE32?
100 enum EndianKind { EK_INVALID = 0, EK_LITTLE, EK_BIG };
103 enum ProfileKind { PK_INVALID = 0, PK_A, PK_R, PK_M };
105 StringRef getCanonicalArchName(StringRef Arch);
108 StringRef getFPUName(unsigned FPUKind);
109 unsigned getFPUVersion(unsigned FPUKind);
110 unsigned getFPUNeonSupportLevel(unsigned FPUKind);
111 unsigned getFPURestriction(unsigned FPUKind);
113 // FIXME: These should be moved to TargetTuple once it exists
114 bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
115 bool getHWDivFeatures(unsigned HWDivKind, std::vector<StringRef> &Features);
116 bool getExtensionFeatures(unsigned Extensions,
117 std::vector<StringRef> &Features);
119 StringRef getArchName(unsigned ArchKind);
120 unsigned getArchAttr(unsigned ArchKind);
121 StringRef getCPUAttr(unsigned ArchKind);
122 StringRef getSubArch(unsigned ArchKind);
123 StringRef getArchExtName(unsigned ArchExtKind);
124 StringRef getArchExtFeature(StringRef ArchExt);
125 StringRef getHWDivName(unsigned HWDivKind);
127 // Information by Name
128 unsigned getDefaultFPU(StringRef CPU, unsigned ArchKind);
129 unsigned getDefaultExtensions(StringRef CPU, unsigned ArchKind);
130 StringRef getDefaultCPU(StringRef Arch);
133 unsigned parseHWDiv(StringRef HWDiv);
134 unsigned parseFPU(StringRef FPU);
135 unsigned parseArch(StringRef Arch);
136 unsigned parseArchExt(StringRef ArchExt);
137 unsigned parseCPUArch(StringRef CPU);
138 unsigned parseArchISA(StringRef Arch);
139 unsigned parseArchEndian(StringRef Arch);
140 unsigned parseArchProfile(StringRef Arch);
141 unsigned parseArchVersion(StringRef Arch);
145 // FIXME:This should be made into class design,to avoid dupplication.
149 enum class ArchKind {
150 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
151 #include "AArch64TargetParser.def"
155 // Arch extension modifiers for CPUs.
156 enum ArchExtKind : unsigned {
169 StringRef getCanonicalArchName(StringRef Arch);
172 StringRef getFPUName(unsigned FPUKind);
173 unsigned getFPUVersion(unsigned FPUKind);
174 unsigned getFPUNeonSupportLevel(unsigned FPUKind);
175 unsigned getFPURestriction(unsigned FPUKind);
177 // FIXME: These should be moved to TargetTuple once it exists
178 bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
179 bool getExtensionFeatures(unsigned Extensions,
180 std::vector<StringRef> &Features);
181 bool getArchFeatures(unsigned ArchKind, std::vector<StringRef> &Features);
183 StringRef getArchName(unsigned ArchKind);
184 unsigned getArchAttr(unsigned ArchKind);
185 StringRef getCPUAttr(unsigned ArchKind);
186 StringRef getSubArch(unsigned ArchKind);
187 StringRef getArchExtName(unsigned ArchExtKind);
188 StringRef getArchExtFeature(StringRef ArchExt);
189 unsigned checkArchVersion(StringRef Arch);
191 // Information by Name
192 unsigned getDefaultFPU(StringRef CPU, unsigned ArchKind);
193 unsigned getDefaultExtensions(StringRef CPU, unsigned ArchKind);
194 StringRef getDefaultCPU(StringRef Arch);
197 unsigned parseFPU(StringRef FPU);
198 unsigned parseArch(StringRef Arch);
199 unsigned parseArchExt(StringRef ArchExt);
200 unsigned parseCPUArch(StringRef CPU);
201 unsigned parseArchISA(StringRef Arch);
202 unsigned parseArchEndian(StringRef Arch);
203 unsigned parseArchProfile(StringRef Arch);
204 unsigned parseArchVersion(StringRef Arch);
206 } // namespace AArch64