]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Support/TargetParser.h
MFV r322221: 7910 l2arc_write_buffers() may write beyond target_sz
[FreeBSD/FreeBSD.git] / contrib / llvm / 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 "llvm/ADT/Triple.h"
21 #include <vector>
22
23 namespace llvm {
24 class StringRef;
25
26 // Target specific information into their own namespaces. These should be
27 // generated from TableGen because the information is already there, and there
28 // is where new information about targets will be added.
29 // FIXME: To TableGen this we need to make some table generated files available
30 // even if the back-end is not compiled with LLVM, plus we need to create a new
31 // back-end to TableGen to create these clean tables.
32 namespace ARM {
33
34 // FPU names.
35 enum FPUKind {
36 #define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION) KIND,
37 #include "ARMTargetParser.def"
38   FK_LAST
39 };
40
41 // FPU Version
42 enum FPUVersion {
43   FV_NONE = 0,
44   FV_VFPV2,
45   FV_VFPV3,
46   FV_VFPV3_FP16,
47   FV_VFPV4,
48   FV_VFPV5
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 #define ARM_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
68 #include "ARMTargetParser.def"
69   AK_LAST
70 };
71
72 // Arch extension modifiers for CPUs.
73 enum ArchExtKind : unsigned {
74   AEK_INVALID = 0x0,
75   AEK_NONE = 0x1,
76   AEK_CRC = 0x2,
77   AEK_CRYPTO = 0x4,
78   AEK_FP = 0x8,
79   AEK_HWDIVTHUMB = 0x10,
80   AEK_HWDIVARM = 0x20,
81   AEK_MP = 0x40,
82   AEK_SIMD = 0x80,
83   AEK_SEC = 0x100,
84   AEK_VIRT = 0x200,
85   AEK_DSP = 0x400,
86   AEK_FP16 = 0x800,
87   AEK_RAS = 0x1000,
88   AEK_SVE = 0x2000,
89   // Unsupported extensions.
90   AEK_OS = 0x8000000,
91   AEK_IWMMXT = 0x10000000,
92   AEK_IWMMXT2 = 0x20000000,
93   AEK_MAVERICK = 0x40000000,
94   AEK_XSCALE = 0x80000000,
95 };
96
97 // ISA kinds.
98 enum ISAKind { IK_INVALID = 0, IK_ARM, IK_THUMB, IK_AARCH64 };
99
100 // Endianness
101 // FIXME: BE8 vs. BE32?
102 enum EndianKind { EK_INVALID = 0, EK_LITTLE, EK_BIG };
103
104 // v6/v7/v8 Profile
105 enum ProfileKind { PK_INVALID = 0, PK_A, PK_R, PK_M };
106
107 StringRef getCanonicalArchName(StringRef Arch);
108
109 // Information by ID
110 StringRef getFPUName(unsigned FPUKind);
111 unsigned getFPUVersion(unsigned FPUKind);
112 unsigned getFPUNeonSupportLevel(unsigned FPUKind);
113 unsigned getFPURestriction(unsigned FPUKind);
114
115 // FIXME: These should be moved to TargetTuple once it exists
116 bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
117 bool getHWDivFeatures(unsigned HWDivKind, std::vector<StringRef> &Features);
118 bool getExtensionFeatures(unsigned Extensions,
119                           std::vector<StringRef> &Features);
120
121 StringRef getArchName(unsigned ArchKind);
122 unsigned getArchAttr(unsigned ArchKind);
123 StringRef getCPUAttr(unsigned ArchKind);
124 StringRef getSubArch(unsigned ArchKind);
125 StringRef getArchExtName(unsigned ArchExtKind);
126 StringRef getArchExtFeature(StringRef ArchExt);
127 StringRef getHWDivName(unsigned HWDivKind);
128
129 // Information by Name
130 unsigned  getDefaultFPU(StringRef CPU, unsigned ArchKind);
131 unsigned  getDefaultExtensions(StringRef CPU, unsigned ArchKind);
132 StringRef getDefaultCPU(StringRef Arch);
133
134 // Parser
135 unsigned parseHWDiv(StringRef HWDiv);
136 unsigned parseFPU(StringRef FPU);
137 unsigned parseArch(StringRef Arch);
138 unsigned parseArchExt(StringRef ArchExt);
139 unsigned parseCPUArch(StringRef CPU);
140 unsigned parseArchISA(StringRef Arch);
141 unsigned parseArchEndian(StringRef Arch);
142 unsigned parseArchProfile(StringRef Arch);
143 unsigned parseArchVersion(StringRef Arch);
144
145 StringRef computeDefaultTargetABI(const Triple &TT, StringRef CPU);
146
147 } // namespace ARM
148
149 // FIXME:This should be made into class design,to avoid dupplication.
150 namespace AArch64 {
151
152 // Arch names.
153 enum class ArchKind {
154 #define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
155 #include "AArch64TargetParser.def"
156   AK_LAST
157 };
158
159 // Arch extension modifiers for CPUs.
160 enum ArchExtKind : unsigned {
161   AEK_INVALID = 0x0,
162   AEK_NONE = 0x1,
163   AEK_CRC = 0x2,
164   AEK_CRYPTO = 0x4,
165   AEK_FP = 0x8,
166   AEK_SIMD = 0x10,
167   AEK_FP16 = 0x20,
168   AEK_PROFILE = 0x40,
169   AEK_RAS = 0x80,
170   AEK_LSE = 0x100,
171   AEK_SVE = 0x200
172 };
173
174 StringRef getCanonicalArchName(StringRef Arch);
175
176 // Information by ID
177 StringRef getFPUName(unsigned FPUKind);
178 unsigned getFPUVersion(unsigned FPUKind);
179 unsigned getFPUNeonSupportLevel(unsigned FPUKind);
180 unsigned getFPURestriction(unsigned FPUKind);
181
182 // FIXME: These should be moved to TargetTuple once it exists
183 bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
184 bool getExtensionFeatures(unsigned Extensions,
185                                    std::vector<StringRef> &Features);
186 bool getArchFeatures(unsigned ArchKind, std::vector<StringRef> &Features);
187
188 StringRef getArchName(unsigned ArchKind);
189 unsigned getArchAttr(unsigned ArchKind);
190 StringRef getCPUAttr(unsigned ArchKind);
191 StringRef getSubArch(unsigned ArchKind);
192 StringRef getArchExtName(unsigned ArchExtKind);
193 StringRef getArchExtFeature(StringRef ArchExt);
194 unsigned checkArchVersion(StringRef Arch);
195
196 // Information by Name
197 unsigned  getDefaultFPU(StringRef CPU, unsigned ArchKind);
198 unsigned  getDefaultExtensions(StringRef CPU, unsigned ArchKind);
199 StringRef getDefaultCPU(StringRef Arch);
200
201 // Parser
202 unsigned parseFPU(StringRef FPU);
203 unsigned parseArch(StringRef Arch);
204 unsigned parseArchExt(StringRef ArchExt);
205 unsigned parseCPUArch(StringRef CPU);
206 unsigned parseArchISA(StringRef Arch);
207 unsigned parseArchEndian(StringRef Arch);
208 unsigned parseArchProfile(StringRef Arch);
209 unsigned parseArchVersion(StringRef Arch);
210
211 } // namespace AArch64
212 } // namespace llvm
213
214 #endif