[ARM] Add support for -sp- FPUs and FPU none to TargetParser
[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   // FPU names.
33   enum FPUKind {
34     FK_INVALID = 0,
35     FK_NONE,
36     FK_VFP,
37     FK_VFPV2,
38     FK_VFPV3,
39     FK_VFPV3_D16,
40     FK_VFPV4,
41     FK_VFPV4_D16,
42     FK_FPV4_SP_D16,
43     FK_FPV5_D16,
44     FK_FPV5_SP_D16,
45     FK_FP_ARMV8,
46     FK_NEON,
47     FK_NEON_VFPV4,
48     FK_NEON_FP_ARMV8,
49     FK_CRYPTO_NEON_FP_ARMV8,
50     FK_SOFTVFP,
51     FK_LAST
52   };
53
54   // An FPU name implies one of three levels of Neon support:
55   enum NeonSupportLevel {
56     NS_None = 0, //< No Neon
57     NS_Neon,     //< Neon
58     NS_Crypto    //< Neon with Crypto
59   };
60
61   // An FPU name restricts the FPU in one of three ways:
62   enum FPURestriction {
63     FR_None = 0, //< No restriction
64     FR_D16,      //< Only 16 D registers
65     FR_SP_D16    //< Only single-precision instructions, with 16 D registers
66   };
67
68   // Arch names.
69   enum ArchKind {
70     AK_INVALID = 0,
71     AK_ARMV2,
72     AK_ARMV2A,
73     AK_ARMV3,
74     AK_ARMV3M,
75     AK_ARMV4,
76     AK_ARMV4T,
77     AK_ARMV5T,
78     AK_ARMV5TE,
79     AK_ARMV5TEJ,
80     AK_ARMV6,
81     AK_ARMV6K,
82     AK_ARMV6T2,
83     AK_ARMV6Z,
84     AK_ARMV6ZK,
85     AK_ARMV6M,
86     AK_ARMV6SM,
87     AK_ARMV7A,
88     AK_ARMV7R,
89     AK_ARMV7M,
90     AK_ARMV7EM,
91     AK_ARMV8A,
92     AK_ARMV8_1A,
93     // Non-standard Arch names.
94     AK_IWMMXT,
95     AK_IWMMXT2,
96     AK_XSCALE,
97     AK_ARMV5,
98     AK_ARMV5E,
99     AK_ARMV6J,
100     AK_ARMV6HL,
101     AK_ARMV7,
102     AK_ARMV7L,
103     AK_ARMV7HL,
104     AK_ARMV7S,
105     AK_LAST
106   };
107
108   // Arch extension modifiers for CPUs.
109   enum ArchExtKind {
110     AEK_INVALID = 0,
111     AEK_CRC,
112     AEK_CRYPTO,
113     AEK_FP,
114     AEK_HWDIV,
115     AEK_MP,
116     AEK_SIMD,
117     AEK_SEC,
118     AEK_VIRT,
119     // Unsupported extensions.
120     AEK_OS,
121     AEK_IWMMXT,
122     AEK_IWMMXT2,
123     AEK_MAVERICK,
124     AEK_XSCALE,
125     AEK_LAST
126   };
127
128   // ISA kinds.
129   enum ISAKind {
130     IK_INVALID = 0,
131     IK_ARM,
132     IK_THUMB,
133     IK_AARCH64
134   };
135
136   // Endianness
137   // FIXME: BE8 vs. BE32?
138   enum EndianKind {
139     EK_INVALID = 0,
140     EK_LITTLE,
141     EK_BIG
142   };
143
144   // v6/v7/v8 Profile
145   enum ProfileKind {
146     PK_INVALID = 0,
147     PK_A,
148     PK_R,
149     PK_M
150   };
151 } // namespace ARM
152
153 // Target Parsers, one per architecture.
154 class ARMTargetParser {
155   static StringRef getFPUSynonym(StringRef FPU);
156   static StringRef getArchSynonym(StringRef Arch);
157
158 public:
159   static StringRef getCanonicalArchName(StringRef Arch);
160
161   // Information by ID
162   static const char * getFPUName(unsigned FPUKind);
163   static     unsigned getFPUVersion(unsigned FPUKind);
164   static     unsigned getFPUNeonSupportLevel(unsigned FPUKind);
165   static     unsigned getFPURestriction(unsigned FPUKind);
166   // FIXME: This should be moved to TargetTuple once it exists
167   static       bool   getFPUFeatures(unsigned FPUKind,
168                                      std::vector<const char*> &Features);
169   static const char * getArchName(unsigned ArchKind);
170   static   unsigned   getArchAttr(unsigned ArchKind);
171   static const char * getCPUAttr(unsigned ArchKind);
172   static const char * getSubArch(unsigned ArchKind);
173   static const char * getArchExtName(unsigned ArchExtKind);
174   static const char * getDefaultCPU(StringRef Arch);
175
176   // Parser
177   static unsigned parseFPU(StringRef FPU);
178   static unsigned parseArch(StringRef Arch);
179   static unsigned parseArchExt(StringRef ArchExt);
180   static unsigned parseCPUArch(StringRef CPU);
181   static unsigned parseArchISA(StringRef Arch);
182   static unsigned parseArchEndian(StringRef Arch);
183   static unsigned parseArchProfile(StringRef Arch);
184   static unsigned parseArchVersion(StringRef Arch);
185
186 };
187
188 } // namespace llvm
189
190 #endif