Adding profile and version parsers to ARMTargetParser
[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_ARMV5,
57     AK_ARMV5T,
58     AK_ARMV5TE,
59     AK_ARMV6,
60     AK_ARMV6J,
61     AK_ARMV6K,
62     AK_ARMV6T2,
63     AK_ARMV6Z,
64     AK_ARMV6ZK,
65     AK_ARMV6M,
66     AK_ARMV7,
67     AK_ARMV7A,
68     AK_ARMV7R,
69     AK_ARMV7M,
70     AK_ARMV8A,
71     AK_ARMV8_1A,
72     // Non-standard Arch names.
73     AK_IWMMXT,
74     AK_IWMMXT2,
75     AK_XSCALE,
76     AK_ARMV5E,
77     AK_ARMV5TEJ,
78     AK_ARMV6SM,
79     AK_ARMV6HL,
80     AK_ARMV7L,
81     AK_ARMV7HL,
82     AK_ARMV7S,
83     AK_ARMV7EM,
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_SEC,
96     AEK_VIRT,
97     AEK_LAST
98   };
99
100   // ISA kinds.
101   enum ISAKind {
102     IK_INVALID = 0,
103     IK_ARM,
104     IK_THUMB,
105     IK_AARCH64
106   };
107
108   // Endianness
109   // FIXME: BE8 vs. BE32?
110   enum EndianKind {
111     EK_INVALID = 0,
112     EK_LITTLE,
113     EK_BIG
114   };
115
116   // v6/v7/v8 Profile
117   enum ProfileKind {
118     PK_INVALID = 0,
119     PK_A,
120     PK_R,
121     PK_M
122   };
123 } // namespace ARM
124
125 // Target Parsers, one per architecture.
126 class ARMTargetParser {
127   static StringRef getFPUSynonym(StringRef FPU);
128   static StringRef getArchSynonym(StringRef Arch);
129
130 public:
131   static StringRef getCanonicalArchName(StringRef Arch);
132
133   // Information by ID
134   static const char * getFPUName(unsigned FPUKind);
135   static const char * getArchName(unsigned ArchKind);
136   static unsigned getArchDefaultCPUArch(unsigned ArchKind);
137   static const char * getArchDefaultCPUName(unsigned ArchKind);
138   static const char * getArchExtName(unsigned ArchExtKind);
139   static const char * getDefaultCPU(StringRef Arch);
140
141   // Parser
142   static unsigned parseFPU(StringRef FPU);
143   static unsigned parseArch(StringRef Arch);
144   static unsigned parseArchExt(StringRef ArchExt);
145   static unsigned parseCPUArch(StringRef CPU);
146   static unsigned parseArchISA(StringRef Arch);
147   static unsigned parseArchEndian(StringRef Arch);
148   static unsigned parseArchProfile(StringRef Arch);
149   static unsigned parseArchVersion(StringRef Arch);
150
151 };
152
153 } // namespace llvm
154
155 #endif