1 //===- EnumTables.cpp - Enum to string conversion tables ------------------===//
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 #include "llvm/DebugInfo/CodeView/EnumTables.h"
11 #include "llvm/Support/ScopedPrinter.h"
12 #include <type_traits>
13
14 using namespace llvm;
15 using namespace codeview;
16
17 #define CV_ENUM_CLASS_ENT(enum_class, enum) \
18 { #enum, std::underlying_type < enum_class > ::type(enum_class::enum) }
19
20 #define CV_ENUM_ENT(ns, enum) \
21 { #enum, ns::enum }
22
23 static const EnumEntry<SymbolKind> SymbolTypeNames[] = {
24 #define CV_SYMBOL(enum, val) {#enum, enum},
25 #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
26 #undef CV_SYMBOL
27 };
28
29 static const EnumEntry<TypeLeafKind> TypeLeafNames[] = {
30 #define CV_TYPE(name, val) {#name, name},
31 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
32 #undef CV_TYPE
33 };
34
35 static const EnumEntry<uint16_t> RegisterNames[] = {
36 #define CV_REGISTER(name, val) CV_ENUM_CLASS_ENT(RegisterId, name),
37 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
38 #undef CV_REGISTER
39 };
40
41 static const EnumEntry<uint32_t> PublicSymFlagNames[] = {
42 CV_ENUM_CLASS_ENT(PublicSymFlags, Code),
43 CV_ENUM_CLASS_ENT(PublicSymFlags, Function),
44 CV_ENUM_CLASS_ENT(PublicSymFlags, Managed),
45 CV_ENUM_CLASS_ENT(PublicSymFlags, MSIL),
46 };
47
48 static const EnumEntry<uint8_t> ProcSymFlagNames[] = {
49 CV_ENUM_CLASS_ENT(ProcSymFlags, HasFP),
50 CV_ENUM_CLASS_ENT(ProcSymFlags, HasIRET),
51 CV_ENUM_CLASS_ENT(ProcSymFlags, HasFRET),
52 CV_ENUM_CLASS_ENT(ProcSymFlags, IsNoReturn),
53 CV_ENUM_CLASS_ENT(ProcSymFlags, IsUnreachable),
54 CV_ENUM_CLASS_ENT(ProcSymFlags, HasCustomCallingConv),
55 CV_ENUM_CLASS_ENT(ProcSymFlags, IsNoInline),
56 CV_ENUM_CLASS_ENT(ProcSymFlags, HasOptimizedDebugInfo),
57 };
58
59 static const EnumEntry<uint16_t> LocalFlags[] = {
60 CV_ENUM_CLASS_ENT(LocalSymFlags, IsParameter),
61 CV_ENUM_CLASS_ENT(LocalSymFlags, IsAddressTaken),
62 CV_ENUM_CLASS_ENT(LocalSymFlags, IsCompilerGenerated),
63 CV_ENUM_CLASS_ENT(LocalSymFlags, IsAggregate),
64 CV_ENUM_CLASS_ENT(LocalSymFlags, IsAggregated),
65 CV_ENUM_CLASS_ENT(LocalSymFlags, IsAliased),
66 CV_ENUM_CLASS_ENT(LocalSymFlags, IsAlias),
67 CV_ENUM_CLASS_ENT(LocalSymFlags, IsReturnValue),
68 CV_ENUM_CLASS_ENT(LocalSymFlags, IsOptimizedOut),
69 CV_ENUM_CLASS_ENT(LocalSymFlags, IsEnregisteredGlobal),
70 CV_ENUM_CLASS_ENT(LocalSymFlags, IsEnregisteredStatic),
71 };
72
73 static const EnumEntry<uint8_t> FrameCookieKinds[] = {
74 CV_ENUM_CLASS_ENT(FrameCookieKind, Copy),
75 CV_ENUM_CLASS_ENT(FrameCookieKind, XorStackPointer),
76 CV_ENUM_CLASS_ENT(FrameCookieKind, XorFramePointer),
77 CV_ENUM_CLASS_ENT(FrameCookieKind, XorR13),
78 };
79
80 static const EnumEntry<codeview::SourceLanguage> SourceLanguages[] = {
81 CV_ENUM_ENT(SourceLanguage, C), CV_ENUM_ENT(SourceLanguage, Cpp),
82 CV_ENUM_ENT(SourceLanguage, Fortran), CV_ENUM_ENT(SourceLanguage, Masm),
83 CV_ENUM_ENT(SourceLanguage, Pascal), CV_ENUM_ENT(SourceLanguage, Basic),
84 CV_ENUM_ENT(SourceLanguage, Cobol), CV_ENUM_ENT(SourceLanguage, Link),
85 CV_ENUM_ENT(SourceLanguage, Cvtres), CV_ENUM_ENT(SourceLanguage, Cvtpgd),
86 CV_ENUM_ENT(SourceLanguage, CSharp), CV_ENUM_ENT(SourceLanguage, VB),
87 CV_ENUM_ENT(SourceLanguage, ILAsm), CV_ENUM_ENT(SourceLanguage, Java),
88 CV_ENUM_ENT(SourceLanguage, JScript), CV_ENUM_ENT(SourceLanguage, MSIL),
89 CV_ENUM_ENT(SourceLanguage, HLSL), CV_ENUM_ENT(SourceLanguage, D),
90 };
91
92 static const EnumEntry<uint32_t> CompileSym2FlagNames[] = {
93 CV_ENUM_CLASS_ENT(CompileSym2Flags, EC),
94 CV_ENUM_CLASS_ENT(CompileSym2Flags, NoDbgInfo),
95 CV_ENUM_CLASS_ENT(CompileSym2Flags, LTCG),
96 CV_ENUM_CLASS_ENT(CompileSym2Flags, NoDataAlign),
97 CV_ENUM_CLASS_ENT(CompileSym2Flags, ManagedPresent),
98 CV_ENUM_CLASS_ENT(CompileSym2Flags, SecurityChecks),
99 CV_ENUM_CLASS_ENT(CompileSym2Flags, HotPatch),
100 CV_ENUM_CLASS_ENT(CompileSym2Flags, CVTCIL),
101 CV_ENUM_CLASS_ENT(CompileSym2Flags, MSILModule),
102 };
103
104 static const EnumEntry<uint32_t> CompileSym3FlagNames[] = {
105 CV_ENUM_CLASS_ENT(CompileSym3Flags, EC),
106 CV_ENUM_CLASS_ENT(CompileSym3Flags, NoDbgInfo),
107 CV_ENUM_CLASS_ENT(CompileSym3Flags, LTCG),
108 CV_ENUM_CLASS_ENT(CompileSym3Flags, NoDataAlign),
109 CV_ENUM_CLASS_ENT(CompileSym3Flags, ManagedPresent),
110 CV_ENUM_CLASS_ENT(CompileSym3Flags, SecurityChecks),
111 CV_ENUM_CLASS_ENT(CompileSym3Flags, HotPatch),
112 CV_ENUM_CLASS_ENT(CompileSym3Flags, CVTCIL),
113 CV_ENUM_CLASS_ENT(CompileSym3Flags, MSILModule),
114 CV_ENUM_CLASS_ENT(CompileSym3Flags, Sdl),
115 CV_ENUM_CLASS_ENT(CompileSym3Flags, PGO),
116 CV_ENUM_CLASS_ENT(CompileSym3Flags, Exp),
117 };
118
119 static const EnumEntry<uint32_t> FileChecksumNames[] = {
120 CV_ENUM_CLASS_ENT(FileChecksumKind, None),
121 CV_ENUM_CLASS_ENT(FileChecksumKind, MD5),
122 CV_ENUM_CLASS_ENT(FileChecksumKind, SHA1),
123 CV_ENUM_CLASS_ENT(FileChecksumKind, SHA256),
124 };
125
126 static const EnumEntry<unsigned> CPUTypeNames[] = {
127 CV_ENUM_CLASS_ENT(CPUType, Intel8080),
128 CV_ENUM_CLASS_ENT(CPUType, Intel8086),
129 CV_ENUM_CLASS_ENT(CPUType, Intel80286),
130 CV_ENUM_CLASS_ENT(CPUType, Intel80386),
131 CV_ENUM_CLASS_ENT(CPUType, Intel80486),
132 CV_ENUM_CLASS_ENT(CPUType, Pentium),
133 CV_ENUM_CLASS_ENT(CPUType, PentiumPro),
134 CV_ENUM_CLASS_ENT(CPUType, Pentium3),
135 CV_ENUM_CLASS_ENT(CPUType, MIPS),
136 CV_ENUM_CLASS_ENT(CPUType, MIPS16),
137 CV_ENUM_CLASS_ENT(CPUType, MIPS32),
138 CV_ENUM_CLASS_ENT(CPUType, MIPS64),
139 CV_ENUM_CLASS_ENT(CPUType, MIPSI),
140 CV_ENUM_CLASS_ENT(CPUType, MIPSII),
141 CV_ENUM_CLASS_ENT(CPUType, MIPSIII),
142 CV_ENUM_CLASS_ENT(CPUType, MIPSIV),
143 CV_ENUM_CLASS_ENT(CPUType, MIPSV),
144 CV_ENUM_CLASS_ENT(CPUType, M68000),
145 CV_ENUM_CLASS_ENT(CPUType, M68010),
146 CV_ENUM_CLASS_ENT(CPUType, M68020),
147 CV_ENUM_CLASS_ENT(CPUType, M68030),
148 CV_ENUM_CLASS_ENT(CPUType, M68040),
149 CV_ENUM_CLASS_ENT(CPUType, Alpha),
150 CV_ENUM_CLASS_ENT(CPUType, Alpha21164),
151 CV_ENUM_CLASS_ENT(CPUType, Alpha21164A),
152 CV_ENUM_CLASS_ENT(CPUType, Alpha21264),
153 CV_ENUM_CLASS_ENT(CPUType, Alpha21364),
154 CV_ENUM_CLASS_ENT(CPUType, PPC601),
155 CV_ENUM_CLASS_ENT(CPUType, PPC603),
156 CV_ENUM_CLASS_ENT(CPUType, PPC604),
157 CV_ENUM_CLASS_ENT(CPUType, PPC620),
158 CV_ENUM_CLASS_ENT(CPUType, PPCFP),
159 CV_ENUM_CLASS_ENT(CPUType, PPCBE),
160 CV_ENUM_CLASS_ENT(CPUType, SH3),
161 CV_ENUM_CLASS_ENT(CPUType, SH3E),
162 CV_ENUM_CLASS_ENT(CPUType, SH3DSP),
163 CV_ENUM_CLASS_ENT(CPUType, SH4),
164 CV_ENUM_CLASS_ENT(CPUType, SHMedia),
165 CV_ENUM_CLASS_ENT(CPUType, ARM3),
166 CV_ENUM_CLASS_ENT(CPUType, ARM4),
167 CV_ENUM_CLASS_ENT(CPUType, ARM4T),
168 CV_ENUM_CLASS_ENT(CPUType, ARM5),
169 CV_ENUM_CLASS_ENT(CPUType, ARM5T),
170 CV_ENUM_CLASS_ENT(CPUType, ARM6),
171 CV_ENUM_CLASS_ENT(CPUType, ARM_XMAC),
172 CV_ENUM_CLASS_ENT(CPUType, ARM_WMMX),
173 CV_ENUM_CLASS_ENT(CPUType, ARM7),
174 CV_ENUM_CLASS_ENT(CPUType, Omni),
175 CV_ENUM_CLASS_ENT(CPUType, Ia64),
176 CV_ENUM_CLASS_ENT(CPUType, Ia64_2),
177 CV_ENUM_CLASS_ENT(CPUType, CEE),
178 CV_ENUM_CLASS_ENT(CPUType, AM33),
179 CV_ENUM_CLASS_ENT(CPUType, M32R),
180 CV_ENUM_CLASS_ENT(CPUType, TriCore),
181 CV_ENUM_CLASS_ENT(CPUType, X64),
182 CV_ENUM_CLASS_ENT(CPUType, EBC),
183 CV_ENUM_CLASS_ENT(CPUType, Thumb),
184 CV_ENUM_CLASS_ENT(CPUType, ARMNT),
185 CV_ENUM_CLASS_ENT(CPUType, D3D11_Shader),
186 };
187
188 static const EnumEntry<uint32_t> FrameProcSymFlagNames[] = {
189 CV_ENUM_CLASS_ENT(FrameProcedureOptions, HasAlloca),
190 CV_ENUM_CLASS_ENT(FrameProcedureOptions, HasSetJmp),
191 CV_ENUM_CLASS_ENT(FrameProcedureOptions, HasLongJmp),
192 CV_ENUM_CLASS_ENT(FrameProcedureOptions, HasInlineAssembly),
193 CV_ENUM_CLASS_ENT(FrameProcedureOptions, HasExceptionHandling),
194 CV_ENUM_CLASS_ENT(FrameProcedureOptions, MarkedInline),
195 CV_ENUM_CLASS_ENT(FrameProcedureOptions, HasStructuredExceptionHandling),
196 CV_ENUM_CLASS_ENT(FrameProcedureOptions, Naked),
197 CV_ENUM_CLASS_ENT(FrameProcedureOptions, SecurityChecks),
198 CV_ENUM_CLASS_ENT(FrameProcedureOptions, AsynchronousExceptionHandling),
199 CV_ENUM_CLASS_ENT(FrameProcedureOptions, NoStackOrderingForSecurityChecks),
200 CV_ENUM_CLASS_ENT(FrameProcedureOptions, Inlined),
201 CV_ENUM_CLASS_ENT(FrameProcedureOptions, StrictSecurityChecks),
202 CV_ENUM_CLASS_ENT(FrameProcedureOptions, SafeBuffers),
203 CV_ENUM_CLASS_ENT(FrameProcedureOptions, ProfileGuidedOptimization),
204 CV_ENUM_CLASS_ENT(FrameProcedureOptions, ValidProfileCounts),
205 CV_ENUM_CLASS_ENT(FrameProcedureOptions, OptimizedForSpeed),
206 CV_ENUM_CLASS_ENT(FrameProcedureOptions, GuardCfg),
207 CV_ENUM_CLASS_ENT(FrameProcedureOptions, GuardCfw),
208 };
209
210 static const EnumEntry<uint32_t> ModuleSubstreamKindNames[] = {
211 CV_ENUM_CLASS_ENT(DebugSubsectionKind, None),
212 CV_ENUM_CLASS_ENT(DebugSubsectionKind, Symbols),
213 CV_ENUM_CLASS_ENT(DebugSubsectionKind, Lines),
214 CV_ENUM_CLASS_ENT(DebugSubsectionKind, StringTable),
215 CV_ENUM_CLASS_ENT(DebugSubsectionKind, FileChecksums),
216 CV_ENUM_CLASS_ENT(DebugSubsectionKind, FrameData),
217 CV_ENUM_CLASS_ENT(DebugSubsectionKind, InlineeLines),
218 CV_ENUM_CLASS_ENT(DebugSubsectionKind, CrossScopeImports),
219 CV_ENUM_CLASS_ENT(DebugSubsectionKind, CrossScopeExports),
220 CV_ENUM_CLASS_ENT(DebugSubsectionKind, ILLines),
221 CV_ENUM_CLASS_ENT(DebugSubsectionKind, FuncMDTokenMap),
222 CV_ENUM_CLASS_ENT(DebugSubsectionKind, TypeMDTokenMap),
223 CV_ENUM_CLASS_ENT(DebugSubsectionKind, MergedAssemblyInput),
224 CV_ENUM_CLASS_ENT(DebugSubsectionKind, CoffSymbolRVA),
225 };
226
227 static const EnumEntry<uint16_t> ExportSymFlagNames[] = {
228 CV_ENUM_CLASS_ENT(ExportFlags, IsConstant),
229 CV_ENUM_CLASS_ENT(ExportFlags, IsData),
230 CV_ENUM_CLASS_ENT(ExportFlags, IsPrivate),
231 CV_ENUM_CLASS_ENT(ExportFlags, HasNoName),
232 CV_ENUM_CLASS_ENT(ExportFlags, HasExplicitOrdinal),
233 CV_ENUM_CLASS_ENT(ExportFlags, IsForwarder),
234 };
235
236 static const EnumEntry<uint8_t> ThunkOrdinalNames[] = {
237 CV_ENUM_CLASS_ENT(ThunkOrdinal, Standard),
238 CV_ENUM_CLASS_ENT(ThunkOrdinal, ThisAdjustor),
239 CV_ENUM_CLASS_ENT(ThunkOrdinal, Vcall),
240 CV_ENUM_CLASS_ENT(ThunkOrdinal, Pcode),
241 CV_ENUM_CLASS_ENT(ThunkOrdinal, UnknownLoad),
242 CV_ENUM_CLASS_ENT(ThunkOrdinal, TrampIncremental),
243 CV_ENUM_CLASS_ENT(ThunkOrdinal, BranchIsland),
244 };
245
246 static const EnumEntry<uint16_t> TrampolineNames[] = {
247 CV_ENUM_CLASS_ENT(TrampolineType, TrampIncremental),
248 CV_ENUM_CLASS_ENT(TrampolineType, BranchIsland),
249 };
250
251 static const EnumEntry<COFF::SectionCharacteristics>
252 ImageSectionCharacteristicNames[] = {
253 CV_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NOLOAD),
254 CV_ENUM_ENT(COFF, IMAGE_SCN_TYPE_NO_PAD),
255 CV_ENUM_ENT(COFF, IMAGE_SCN_CNT_CODE),
256 CV_ENUM_ENT(COFF, IMAGE_SCN_CNT_INITIALIZED_DATA),
257 CV_ENUM_ENT(COFF, IMAGE_SCN_CNT_UNINITIALIZED_DATA),
258 CV_ENUM_ENT(COFF, IMAGE_SCN_LNK_OTHER),
259 CV_ENUM_ENT(COFF, IMAGE_SCN_LNK_INFO),
260 CV_ENUM_ENT(COFF, IMAGE_SCN_LNK_REMOVE),
261 CV_ENUM_ENT(COFF, IMAGE_SCN_LNK_COMDAT),
262 CV_ENUM_ENT(COFF, IMAGE_SCN_GPREL),
263 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_PURGEABLE),
264 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_16BIT),
265 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_LOCKED),
266 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_PRELOAD),
267 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_1BYTES),
268 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_2BYTES),
269 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_4BYTES),
270 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_8BYTES),
271 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_16BYTES),
272 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_32BYTES),
273 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_64BYTES),
274 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_128BYTES),
275 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_256BYTES),
276 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_512BYTES),
277 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_1024BYTES),
278 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_2048BYTES),
279 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_4096BYTES),
280 CV_ENUM_ENT(COFF, IMAGE_SCN_ALIGN_8192BYTES),
281 CV_ENUM_ENT(COFF, IMAGE_SCN_LNK_NRELOC_OVFL),
282 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_DISCARDABLE),
283 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_NOT_CACHED),
284 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_NOT_PAGED),
285 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_SHARED),
286 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_EXECUTE),
287 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_READ),
288 CV_ENUM_ENT(COFF, IMAGE_SCN_MEM_WRITE)};
289
290 namespace llvm {
291 namespace codeview {
292
getSymbolTypeNames()293 ArrayRef<EnumEntry<SymbolKind>> getSymbolTypeNames() {
294 return makeArrayRef(SymbolTypeNames);
295 }
296
getTypeLeafNames()297 ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames() {
298 return makeArrayRef(TypeLeafNames);
299 }
300
getRegisterNames()301 ArrayRef<EnumEntry<uint16_t>> getRegisterNames() {
302 return makeArrayRef(RegisterNames);
303 }
304
getPublicSymFlagNames()305 ArrayRef<EnumEntry<uint32_t>> getPublicSymFlagNames() {
306 return makeArrayRef(PublicSymFlagNames);
307 }
308
getProcSymFlagNames()309 ArrayRef<EnumEntry<uint8_t>> getProcSymFlagNames() {
310 return makeArrayRef(ProcSymFlagNames);
311 }
312
getLocalFlagNames()313 ArrayRef<EnumEntry<uint16_t>> getLocalFlagNames() {
314 return makeArrayRef(LocalFlags);
315 }
316
getFrameCookieKindNames()317 ArrayRef<EnumEntry<uint8_t>> getFrameCookieKindNames() {
318 return makeArrayRef(FrameCookieKinds);
319 }
320
getSourceLanguageNames()321 ArrayRef<EnumEntry<SourceLanguage>> getSourceLanguageNames() {
322 return makeArrayRef(SourceLanguages);
323 }
324
getCompileSym2FlagNames()325 ArrayRef<EnumEntry<uint32_t>> getCompileSym2FlagNames() {
326 return makeArrayRef(CompileSym2FlagNames);
327 }
328
getCompileSym3FlagNames()329 ArrayRef<EnumEntry<uint32_t>> getCompileSym3FlagNames() {
330 return makeArrayRef(CompileSym3FlagNames);
331 }
332
getFileChecksumNames()333 ArrayRef<EnumEntry<uint32_t>> getFileChecksumNames() {
334 return makeArrayRef(FileChecksumNames);
335 }
336
getCPUTypeNames()337 ArrayRef<EnumEntry<unsigned>> getCPUTypeNames() {
338 return makeArrayRef(CPUTypeNames);
339 }
340
getFrameProcSymFlagNames()341 ArrayRef<EnumEntry<uint32_t>> getFrameProcSymFlagNames() {
342 return makeArrayRef(FrameProcSymFlagNames);
343 }
344
getExportSymFlagNames()345 ArrayRef<EnumEntry<uint16_t>> getExportSymFlagNames() {
346 return makeArrayRef(ExportSymFlagNames);
347 }
348
getModuleSubstreamKindNames()349 ArrayRef<EnumEntry<uint32_t>> getModuleSubstreamKindNames() {
350 return makeArrayRef(ModuleSubstreamKindNames);
351 }
352
getThunkOrdinalNames()353 ArrayRef<EnumEntry<uint8_t>> getThunkOrdinalNames() {
354 return makeArrayRef(ThunkOrdinalNames);
355 }
356
getTrampolineNames()357 ArrayRef<EnumEntry<uint16_t>> getTrampolineNames() {
358 return makeArrayRef(TrampolineNames);
359 }
360
361 ArrayRef<EnumEntry<COFF::SectionCharacteristics>>
getImageSectionCharacteristicNames()362 getImageSectionCharacteristicNames() {
363 return makeArrayRef(ImageSectionCharacteristicNames);
364 }
365
366 } // end namespace codeview
367 } // end namespace llvm
368