1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
//===- MCSectionGOFF.cpp - GOFF Code Section Representation ---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCSectionGOFF.h"
#include "llvm/BinaryFormat/GOFF.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode,
GOFF::ESDAlignment Alignment,
GOFF::ESDLoadingBehavior LoadBehavior,
GOFF::ESDExecutable Executable, bool IsReadOnly,
uint32_t SortKey, uint8_t FillByteValue,
StringRef PartName) {
OS << Name << " CATTR ";
OS << "ALIGN(" << static_cast<unsigned>(Alignment) << "),"
<< "FILL(" << static_cast<unsigned>(FillByteValue) << ")";
switch (LoadBehavior) {
case GOFF::ESD_LB_Deferred:
OS << ",DEFLOAD";
break;
case GOFF::ESD_LB_NoLoad:
OS << ",NOLOAD";
break;
default:
break;
}
switch (Executable) {
case GOFF::ESD_EXE_CODE:
OS << ",EXECUTABLE";
break;
case GOFF::ESD_EXE_DATA:
OS << ",NOTEXECUTABLE";
break;
default:
break;
}
if (IsReadOnly)
OS << ",READONLY";
if (Rmode != GOFF::ESD_RMODE_None) {
OS << ',';
OS << "RMODE(";
switch (Rmode) {
case GOFF::ESD_RMODE_24:
OS << "24";
break;
case GOFF::ESD_RMODE_31:
OS << "31";
break;
case GOFF::ESD_RMODE_64:
OS << "64";
break;
case GOFF::ESD_RMODE_None:
break;
}
OS << ')';
}
if (SortKey)
OS << ",PRIORITY(" << SortKey << ")";
if (!PartName.empty())
OS << ",PART(" << PartName << ")";
OS << '\n';
}
static void emitXATTR(raw_ostream &OS, StringRef Name,
GOFF::ESDLinkageType Linkage,
GOFF::ESDExecutable Executable,
GOFF::ESDBindingScope BindingScope) {
OS << Name << " XATTR ";
OS << "LINKAGE(" << (Linkage == GOFF::ESD_LT_OS ? "OS" : "XPLINK") << "),";
if (Executable != GOFF::ESD_EXE_Unspecified)
OS << "REFERENCE(" << (Executable == GOFF::ESD_EXE_CODE ? "CODE" : "DATA")
<< "),";
if (BindingScope != GOFF::ESD_BSC_Unspecified) {
OS << "SCOPE(";
switch (BindingScope) {
case GOFF::ESD_BSC_Section:
OS << "SECTION";
break;
case GOFF::ESD_BSC_Module:
OS << "MODULE";
break;
case GOFF::ESD_BSC_Library:
OS << "LIBRARY";
break;
case GOFF::ESD_BSC_ImportExport:
OS << "EXPORT";
break;
default:
break;
}
OS << ')';
}
OS << '\n';
}
void MCSectionGOFF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
raw_ostream &OS,
uint32_t Subsection) const {
switch (SymbolType) {
case GOFF::ESD_ST_SectionDefinition: {
OS << Name << " CSECT\n";
Emitted = true;
break;
}
case GOFF::ESD_ST_ElementDefinition: {
getParent()->printSwitchToSection(MAI, T, OS, Subsection);
if (!Emitted) {
emitCATTR(OS, Name, EDAttributes.Rmode, EDAttributes.Alignment,
EDAttributes.LoadBehavior, GOFF::ESD_EXE_Unspecified,
EDAttributes.IsReadOnly, 0, EDAttributes.FillByteValue,
StringRef());
Emitted = true;
} else
OS << Name << " CATTR\n";
break;
}
case GOFF::ESD_ST_PartReference: {
MCSectionGOFF *ED = getParent();
ED->getParent()->printSwitchToSection(MAI, T, OS, Subsection);
if (!Emitted) {
emitCATTR(OS, ED->getName(), ED->getEDAttributes().Rmode,
ED->EDAttributes.Alignment, ED->EDAttributes.LoadBehavior,
PRAttributes.Executable, ED->EDAttributes.IsReadOnly,
PRAttributes.SortKey, ED->EDAttributes.FillByteValue, Name);
emitXATTR(OS, Name, PRAttributes.Linkage, PRAttributes.Executable,
PRAttributes.BindingScope);
ED->Emitted = true;
Emitted = true;
} else
OS << ED->getName() << " CATTR PART(" << Name << ")\n";
break;
}
default:
llvm_unreachable("Wrong section type");
}
}
|