blob: 3c8a2cdbc3aaea1fb8cc2fe51d24b45983c64311 [file] [log] [blame]
Jason Liu0dc05722019-11-08 09:26:28 -05001//===-- 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"
Simon Pilgrim7c5fc402020-04-23 13:10:55 +010010#include "llvm/ADT/StringRef.h"
Jason Liu0dc05722019-11-08 09:26:28 -050011
12using namespace llvm;
13
diggerlina26a4412020-04-06 10:09:12 -040014#define SMC_CASE(A) \
15 case XCOFF::XMC_##A: \
16 return #A;
Jason Liu0dc05722019-11-08 09:26:28 -050017StringRef XCOFF::getMappingClassString(XCOFF::StorageMappingClass SMC) {
18 switch (SMC) {
diggerlina26a4412020-04-06 10:09:12 -040019 SMC_CASE(PR)
20 SMC_CASE(RO)
21 SMC_CASE(DB)
22 SMC_CASE(GL)
23 SMC_CASE(XO)
24 SMC_CASE(SV)
25 SMC_CASE(SV64)
26 SMC_CASE(SV3264)
27 SMC_CASE(TI)
28 SMC_CASE(TB)
29 SMC_CASE(RW)
30 SMC_CASE(TC0)
31 SMC_CASE(TC)
32 SMC_CASE(TD)
33 SMC_CASE(DS)
34 SMC_CASE(UA)
35 SMC_CASE(BS)
36 SMC_CASE(UC)
37 SMC_CASE(TL)
38 SMC_CASE(UL)
39 SMC_CASE(TE)
40#undef SMC_CASE
Jason Liu0dc05722019-11-08 09:26:28 -050041 }
diggerlina26a4412020-04-06 10:09:12 -040042
43 // TODO: need to add a test case for "Unknown" and other SMC.
44 return "Unknown";
Jason Liu0dc05722019-11-08 09:26:28 -050045}
jasonliud60d7d692020-03-27 16:02:27 +000046
47#define RELOC_CASE(A) \
48 case XCOFF::A: \
49 return #A;
50StringRef XCOFF::getRelocationTypeString(XCOFF::RelocationType Type) {
51 switch (Type) {
52 RELOC_CASE(R_POS)
53 RELOC_CASE(R_RL)
54 RELOC_CASE(R_RLA)
55 RELOC_CASE(R_NEG)
56 RELOC_CASE(R_REL)
57 RELOC_CASE(R_TOC)
58 RELOC_CASE(R_TRL)
59 RELOC_CASE(R_TRLA)
60 RELOC_CASE(R_GL)
61 RELOC_CASE(R_TCL)
62 RELOC_CASE(R_REF)
63 RELOC_CASE(R_BA)
64 RELOC_CASE(R_BR)
65 RELOC_CASE(R_RBA)
66 RELOC_CASE(R_RBR)
67 RELOC_CASE(R_TLS)
68 RELOC_CASE(R_TLS_IE)
69 RELOC_CASE(R_TLS_LD)
70 RELOC_CASE(R_TLS_LE)
71 RELOC_CASE(R_TLSM)
72 RELOC_CASE(R_TLSML)
73 RELOC_CASE(R_TOCU)
74 RELOC_CASE(R_TOCL)
75 }
76 return "Unknown";
77}
78#undef RELOC_CASE