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