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