[Triple] Use clang-format to normalize the formatting of the ARM target
[oota-llvm.git] / include / llvm / Support / TargetParser.h
1 //===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_SUPPORT_TARGETPARSER_H
16 #define LLVM_SUPPORT_TARGETPARSER_H
17
18 // FIXME: vector is used because that's what clang uses for subtarget feature
19 // lists, but SmallVector would probably be better
20 #include <vector>
21
22 namespace llvm {
23 class StringRef;
24
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.
31 namespace ARM {
32
33 // FPU names.
34 enum FPUKind {
35   FK_INVALID = 0,
36   FK_NONE,
37   FK_VFP,
38   FK_VFPV2,
39   FK_VFPV3,
40   FK_VFPV3_FP16,
41   FK_VFPV3_D16,
42   FK_VFPV3_D16_FP16,
43   FK_VFPV3XD,
44   FK_VFPV3XD_FP16,
45   FK_VFPV4,
46   FK_VFPV4_D16,
47   FK_FPV4_SP_D16,
48   FK_FPV5_D16,
49   FK_FPV5_SP_D16,
50   FK_FP_ARMV8,
51   FK_NEON,
52   FK_NEON_FP16,
53   FK_NEON_VFPV4,
54   FK_NEON_FP_ARMV8,
55   FK_CRYPTO_NEON_FP_ARMV8,
56   FK_SOFTVFP,
57   FK_LAST
58 };
59
60 // FPU Version
61 enum FPUVersion {
62   FV_NONE = 0,
63   FV_VFPV2,
64   FV_VFPV3,
65   FV_VFPV3_FP16,
66   FV_VFPV4,
67   FV_VFPV5
68 };
69
70 // An FPU name implies one of three levels of Neon support:
71 enum NeonSupportLevel {
72   NS_None = 0, ///< No Neon
73   NS_Neon,     ///< Neon
74   NS_Crypto    ///< Neon with Crypto
75 };
76
77 // An FPU name restricts the FPU in one of three ways:
78 enum FPURestriction {
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
82 };
83
84 // Arch names.
85 enum ArchKind {
86   AK_INVALID = 0,
87   AK_ARMV2,
88   AK_ARMV2A,
89   AK_ARMV3,
90   AK_ARMV3M,
91   AK_ARMV4,
92   AK_ARMV4T,
93   AK_ARMV5T,
94   AK_ARMV5TE,
95   AK_ARMV5TEJ,
96   AK_ARMV6,
97   AK_ARMV6K,
98   AK_ARMV6T2,
99   AK_ARMV6Z,
100   AK_ARMV6ZK,
101   AK_ARMV6M,
102   AK_ARMV6SM,
103   AK_ARMV7A,
104   AK_ARMV7R,
105   AK_ARMV7M,
106   AK_ARMV7EM,
107   AK_ARMV8A,
108   AK_ARMV8_1A,
109   // Non-standard Arch names.
110   AK_IWMMXT,
111   AK_IWMMXT2,
112   AK_XSCALE,
113   AK_ARMV5,
114   AK_ARMV5E,
115   AK_ARMV6J,
116   AK_ARMV6HL,
117   AK_ARMV7,
118   AK_ARMV7L,
119   AK_ARMV7HL,
120   AK_ARMV7S,
121   AK_ARMV7K,
122   AK_LAST
123 };
124
125 // Arch extension modifiers for CPUs.
126 enum ArchExtKind : unsigned {
127   AEK_INVALID = 0x0,
128   AEK_NONE = 0x1,
129   AEK_CRC = 0x2,
130   AEK_CRYPTO = 0x4,
131   AEK_FP = 0x8,
132   AEK_HWDIV = 0x10,
133   AEK_HWDIVARM = 0x20,
134   AEK_MP = 0x40,
135   AEK_SIMD = 0x80,
136   AEK_SEC = 0x100,
137   AEK_VIRT = 0x200,
138   // Unsupported extensions.
139   AEK_OS = 0x8000000,
140   AEK_IWMMXT = 0x10000000,
141   AEK_IWMMXT2 = 0x20000000,
142   AEK_MAVERICK = 0x40000000,
143   AEK_XSCALE = 0x80000000,
144 };
145
146 // ISA kinds.
147 enum ISAKind { IK_INVALID = 0, IK_ARM, IK_THUMB, IK_AARCH64 };
148
149 // Endianness
150 // FIXME: BE8 vs. BE32?
151 enum EndianKind { EK_INVALID = 0, EK_LITTLE, EK_BIG };
152
153 // v6/v7/v8 Profile
154 enum ProfileKind { PK_INVALID = 0, PK_A, PK_R, PK_M };
155
156 StringRef getCanonicalArchName(StringRef Arch);
157
158 // Information by ID
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);
174
175 // Parser
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);
185
186 } // namespace ARM
187 } // namespace llvm
188
189 #endif