1 //===-- llvm/BinaryFormat/XCOFF.cpp - The XCOFF file format -----*- C++/-*-===//
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 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/BinaryFormat/XCOFF.h"
10 
11 using namespace llvm;
12 
13 #define SMC_CASE(A)                                                            \
14   case XCOFF::XMC_##A:                                                         \
15     return #A;
16 StringRef XCOFF::getMappingClassString(XCOFF::StorageMappingClass SMC) {
17   switch (SMC) {
18     SMC_CASE(PR)
19     SMC_CASE(RO)
20     SMC_CASE(DB)
21     SMC_CASE(GL)
22     SMC_CASE(XO)
23     SMC_CASE(SV)
24     SMC_CASE(SV64)
25     SMC_CASE(SV3264)
26     SMC_CASE(TI)
27     SMC_CASE(TB)
28     SMC_CASE(RW)
29     SMC_CASE(TC0)
30     SMC_CASE(TC)
31     SMC_CASE(TD)
32     SMC_CASE(DS)
33     SMC_CASE(UA)
34     SMC_CASE(BS)
35     SMC_CASE(UC)
36     SMC_CASE(TL)
37     SMC_CASE(UL)
38     SMC_CASE(TE)
39 #undef SMC_CASE
40   }
41 
42   // TODO: need to add a test case for "Unknown" and other SMC.
43   return "Unknown";
44 }
45 
46 #define RELOC_CASE(A)                                                          \
47   case XCOFF::A:                                                               \
48     return #A;
49 StringRef XCOFF::getRelocationTypeString(XCOFF::RelocationType Type) {
50   switch (Type) {
51     RELOC_CASE(R_POS)
52     RELOC_CASE(R_RL)
53     RELOC_CASE(R_RLA)
54     RELOC_CASE(R_NEG)
55     RELOC_CASE(R_REL)
56     RELOC_CASE(R_TOC)
57     RELOC_CASE(R_TRL)
58     RELOC_CASE(R_TRLA)
59     RELOC_CASE(R_GL)
60     RELOC_CASE(R_TCL)
61     RELOC_CASE(R_REF)
62     RELOC_CASE(R_BA)
63     RELOC_CASE(R_BR)
64     RELOC_CASE(R_RBA)
65     RELOC_CASE(R_RBR)
66     RELOC_CASE(R_TLS)
67     RELOC_CASE(R_TLS_IE)
68     RELOC_CASE(R_TLS_LD)
69     RELOC_CASE(R_TLS_LE)
70     RELOC_CASE(R_TLSM)
71     RELOC_CASE(R_TLSML)
72     RELOC_CASE(R_TOCU)
73     RELOC_CASE(R_TOCL)
74   }
75   return "Unknown";
76 }
77 #undef RELOC_CASE
78