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.
55 FK_CRYPTO_NEON_FP_ARMV8,
70 // An FPU name implies one of three levels of Neon support:
71 enum NeonSupportLevel {
72 NS_None = 0, ///< No Neon
74 NS_Crypto ///< Neon with Crypto
77 // An FPU name restricts the FPU in one of three ways:
79 FR_None = 0, ///< No restriction
80 FR_D16, ///< Only 16 D registers
81 FR_SP_D16 ///< Only single-precision instructions, with 16 D registers
109 // Non-standard Arch names.
125 // Arch extension modifiers for CPUs.
126 enum ArchExtKind : unsigned {
138 // Unsupported extensions.
140 AEK_IWMMXT = 0x10000000,
141 AEK_IWMMXT2 = 0x20000000,
142 AEK_MAVERICK = 0x40000000,
143 AEK_XSCALE = 0x80000000,
147 enum ISAKind { IK_INVALID = 0, IK_ARM, IK_THUMB, IK_AARCH64 };
150 // FIXME: BE8 vs. BE32?
151 enum EndianKind { EK_INVALID = 0, EK_LITTLE, EK_BIG };
154 enum ProfileKind { PK_INVALID = 0, PK_A, PK_R, PK_M };
156 StringRef getCanonicalArchName(StringRef Arch);
159 const char *getFPUName(unsigned FPUKind);
160 unsigned getFPUVersion(unsigned FPUKind);
161 unsigned getFPUNeonSupportLevel(unsigned FPUKind);
162 unsigned getFPURestriction(unsigned FPUKind);
163 unsigned getDefaultFPU(StringRef CPU);
164 // FIXME: This should be moved to TargetTuple once it exists
165 bool getFPUFeatures(unsigned FPUKind, std::vector<const char *> &Features);
166 bool getHWDivFeatures(unsigned HWDivKind, std::vector<const char *> &Features);
167 const char *getArchName(unsigned ArchKind);
168 unsigned getArchAttr(unsigned ArchKind);
169 const char *getCPUAttr(unsigned ArchKind);
170 const char *getSubArch(unsigned ArchKind);
171 const char *getArchExtName(unsigned ArchExtKind);
172 const char *getHWDivName(unsigned HWDivKind);
173 const char *getDefaultCPU(StringRef Arch);
176 unsigned parseHWDiv(StringRef HWDiv);
177 unsigned parseFPU(StringRef FPU);
178 unsigned parseArch(StringRef Arch);
179 unsigned parseArchExt(StringRef ArchExt);
180 unsigned parseCPUArch(StringRef CPU);
181 unsigned parseArchISA(StringRef Arch);
182 unsigned parseArchEndian(StringRef Arch);
183 unsigned parseArchProfile(StringRef Arch);
184 unsigned parseArchVersion(StringRef Arch);