TargetParser: FPU/ARCH/EXT parsing refactory - 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     INVALID_FPU = 0,
31     VFP,
32     VFPV2,
33     VFPV3,
34     VFPV3_D16,
35     VFPV4,
36     VFPV4_D16,
37     FPV5_D16,
38     FP_ARMV8,
39     NEON,
40     NEON_VFPV4,
41     NEON_FP_ARMV8,
42     CRYPTO_NEON_FP_ARMV8,
43     SOFTVFP,
44     LAST_FPU
45   };
46
47   // Arch names.
48   enum ArchKind {
49     INVALID_ARCH = 0,
50     ARMV2,
51     ARMV2A,
52     ARMV3,
53     ARMV3M,
54     ARMV4,
55     ARMV4T,
56     ARMV5,
57     ARMV5T,
58     ARMV5TE,
59     ARMV6,
60     ARMV6J,
61     ARMV6K,
62     ARMV6T2,
63     ARMV6Z,
64     ARMV6ZK,
65     ARMV6M,
66     ARMV7,
67     ARMV7A,
68     ARMV7R,
69     ARMV7M,
70     ARMV8A,
71     ARMV8_1A,
72     IWMMXT,
73     IWMMXT2,
74     LAST_ARCH
75   };
76
77   // Arch extension modifiers for CPUs.
78   enum ArchExtKind {
79     INVALID_ARCHEXT = 0,
80     CRC,
81     CRYPTO,
82     FP,
83     HWDIV,
84     MP,
85     SEC,
86     VIRT,
87     LAST_ARCHEXT
88   };
89
90 } // namespace ARM
91
92 // Target Parsers, one per architecture.
93 class ARMTargetParser {
94   static StringRef getFPUSynonym(StringRef FPU);
95   static StringRef getArchSynonym(StringRef Arch);
96
97 public:
98   // Information by ID
99   static const char * getFPUName(unsigned ID);
100   static const char * getArchName(unsigned ID);
101   static unsigned getArchDefaultCPUArch(unsigned ID);
102   static const char * getArchDefaultCPUName(unsigned ID);
103   static const char * getArchExtName(unsigned ID);
104
105   // Parser
106   static unsigned parseFPU(StringRef FPU);
107   static unsigned parseArch(StringRef Arch);
108   static unsigned parseArchExt(StringRef ArchExt);
109 };
110
111 } // namespace llvm
112
113 #endif