[ARMTargetParser] Move IAS arch ext parser. NFC
[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 namespace llvm {
19   class StringRef;
20
21 // Target specific information into their own namespaces. These should be
22 // generated from TableGen because the information is already there, and there
23 // is where new information about targets will be added.
24 // FIXME: To TableGen this we need to make some table generated files available
25 // even if the back-end is not compiled with LLVM, plus we need to create a new
26 // back-end to TableGen to create these clean tables.
27 namespace ARM {
28   // FPU names.
29   enum FPUKind {
30     FK_INVALID = 0,
31     FK_VFP,
32     FK_VFPV2,
33     FK_VFPV3,
34     FK_VFPV3_D16,
35     FK_VFPV4,
36     FK_VFPV4_D16,
37     FK_FPV5_D16,
38     FK_FP_ARMV8,
39     FK_NEON,
40     FK_NEON_VFPV4,
41     FK_NEON_FP_ARMV8,
42     FK_CRYPTO_NEON_FP_ARMV8,
43     FK_SOFTVFP,
44     FK_LAST
45   };
46
47   // Arch names.
48   enum ArchKind {
49     AK_INVALID = 0,
50     AK_ARMV2,
51     AK_ARMV2A,
52     AK_ARMV3,
53     AK_ARMV3M,
54     AK_ARMV4,
55     AK_ARMV4T,
56     AK_ARMV5T,
57     AK_ARMV5TE,
58     AK_ARMV5TEJ,
59     AK_ARMV6,
60     AK_ARMV6K,
61     AK_ARMV6T2,
62     AK_ARMV6Z,
63     AK_ARMV6ZK,
64     AK_ARMV6M,
65     AK_ARMV6SM,
66     AK_ARMV7A,
67     AK_ARMV7R,
68     AK_ARMV7M,
69     AK_ARMV7EM,
70     AK_ARMV8A,
71     AK_ARMV8_1A,
72     // Non-standard Arch names.
73     AK_IWMMXT,
74     AK_IWMMXT2,
75     AK_XSCALE,
76     AK_ARMV5,
77     AK_ARMV5E,
78     AK_ARMV6J,
79     AK_ARMV6HL,
80     AK_ARMV7,
81     AK_ARMV7L,
82     AK_ARMV7HL,
83     AK_ARMV7S,
84     AK_LAST
85   };
86
87   // Arch extension modifiers for CPUs.
88   enum ArchExtKind {
89     AEK_INVALID = 0,
90     AEK_CRC,
91     AEK_CRYPTO,
92     AEK_FP,
93     AEK_HWDIV,
94     AEK_MP,
95     AEK_SIMD,
96     AEK_SEC,
97     AEK_VIRT,
98     // Unsupported extensions.
99     AEK_OS,
100     AEK_IWMMXT,
101     AEK_IWMMXT2,
102     AEK_MAVERICK,
103     AEK_XSCALE,
104     AEK_LAST
105   };
106
107   // ISA kinds.
108   enum ISAKind {
109     IK_INVALID = 0,
110     IK_ARM,
111     IK_THUMB,
112     IK_AARCH64
113   };
114
115   // Endianness
116   // FIXME: BE8 vs. BE32?
117   enum EndianKind {
118     EK_INVALID = 0,
119     EK_LITTLE,
120     EK_BIG
121   };
122
123   // v6/v7/v8 Profile
124   enum ProfileKind {
125     PK_INVALID = 0,
126     PK_A,
127     PK_R,
128     PK_M
129   };
130 } // namespace ARM
131
132 // Target Parsers, one per architecture.
133 class ARMTargetParser {
134   static StringRef getFPUSynonym(StringRef FPU);
135   static StringRef getArchSynonym(StringRef Arch);
136
137 public:
138   static StringRef getCanonicalArchName(StringRef Arch);
139
140   // Information by ID
141   static const char * getFPUName(unsigned FPUKind);
142   static const char * getArchName(unsigned ArchKind);
143   static   unsigned   getArchAttr(unsigned ArchKind);
144   static const char * getCPUAttr(unsigned ArchKind);
145   static const char * getSubArch(unsigned ArchKind);
146   static const char * getArchExtName(unsigned ArchExtKind);
147   static const char * getDefaultCPU(StringRef Arch);
148
149   // Parser
150   static unsigned parseFPU(StringRef FPU);
151   static unsigned parseArch(StringRef Arch);
152   static unsigned parseArchExt(StringRef ArchExt);
153   static unsigned parseCPUArch(StringRef CPU);
154   static unsigned parseArchISA(StringRef Arch);
155   static unsigned parseArchEndian(StringRef Arch);
156   static unsigned parseArchProfile(StringRef Arch);
157   static unsigned parseArchVersion(StringRef Arch);
158
159 };
160
161 } // namespace llvm
162
163 #endif