summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp13
-rw-r--r--llvm/lib/MC/MCContext.cpp10
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp32
-rw-r--r--llvm/lib/MC/MCWasmStreamer.cpp2
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp17
-rw-r--r--llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp8
6 files changed, 41 insertions, 41 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index f1fbc7f9700..e45cdee4368 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -168,8 +168,7 @@ const MCExpr *TargetLoweringObjectFileELF::getTTypeGlobalReference(
MMI, Streamer);
}
-static SectionKind
-getELFKindForNamedSection(StringRef Name, SectionKind K) {
+static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
// N.B.: The defaults used in here are no the same ones used in MC.
// We follow gcc, MC follows gas. For example, given ".section .eh_frame",
// both gas and MC will produce a section with no flags. Given
@@ -1249,7 +1248,7 @@ static const Comdat *getWasmComdat(const GlobalValue *GV) {
MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
StringRef Name = GO->getSection();
- return getContext().getWasmSection(Name, wasm::WASM_SEC_DATA);
+ return getContext().getWasmSection(Name, SectionKind::getData());
}
static MCSectionWasm *selectWasmSectionForGlobal(
@@ -1262,12 +1261,10 @@ static MCSectionWasm *selectWasmSectionForGlobal(
bool UniqueSectionNames = TM.getUniqueSectionNames();
SmallString<128> Name = getSectionPrefixForGlobal(Kind);
- uint32_t Type = wasm::WASM_SEC_DATA;
if (const auto *F = dyn_cast<Function>(GO)) {
const auto &OptionalPrefix = F->getSectionPrefix();
if (OptionalPrefix)
Name += *OptionalPrefix;
- Type = wasm::WASM_SEC_CODE;
}
if (EmitUniqueSection && UniqueSectionNames) {
@@ -1279,7 +1276,7 @@ static MCSectionWasm *selectWasmSectionForGlobal(
UniqueID = *NextUniqueID;
(*NextUniqueID)++;
}
- return Ctx.getWasmSection(Name, Type, Group, UniqueID);
+ return Ctx.getWasmSection(Name, Kind, Group, UniqueID);
}
MCSection *TargetLoweringObjectFileWasm::SelectSectionForGlobal(
@@ -1330,7 +1327,7 @@ const MCExpr *TargetLoweringObjectFileWasm::lowerRelativeReference(
void TargetLoweringObjectFileWasm::InitializeWasm() {
StaticCtorSection =
- getContext().getWasmSection(".init_array", wasm::WASM_SEC_DATA);
+ getContext().getWasmSection(".init_array", SectionKind::getData());
StaticDtorSection =
- getContext().getWasmSection(".fini_array", wasm::WASM_SEC_DATA);
+ getContext().getWasmSection(".fini_array", SectionKind::getData());
}
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index e7bd045c757..5c25e902bbe 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -486,17 +486,17 @@ MCSectionCOFF *MCContext::getAssociativeCOFFSection(MCSectionCOFF *Sec,
"", 0, UniqueID);
}
-MCSectionWasm *MCContext::getWasmSection(const Twine &Section, unsigned Type,
+MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind K,
const Twine &Group, unsigned UniqueID,
const char *BeginSymName) {
MCSymbolWasm *GroupSym = nullptr;
if (!Group.isTriviallyEmpty() && !Group.str().empty())
GroupSym = cast<MCSymbolWasm>(getOrCreateSymbol(Group));
- return getWasmSection(Section, Type, GroupSym, UniqueID, BeginSymName);
+ return getWasmSection(Section, K, GroupSym, UniqueID, BeginSymName);
}
-MCSectionWasm *MCContext::getWasmSection(const Twine &Section, unsigned Type,
+MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind,
const MCSymbolWasm *GroupSym,
unsigned UniqueID,
const char *BeginSymName) {
@@ -512,14 +512,12 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, unsigned Type,
StringRef CachedName = Entry.first.SectionName;
- SectionKind Kind = SectionKind::getText();
-
MCSymbol *Begin = nullptr;
if (BeginSymName)
Begin = createTempSymbol(BeginSymName, false);
MCSectionWasm *Result = new (WasmAllocator.Allocate())
- MCSectionWasm(CachedName, Type, Kind, GroupSym, UniqueID, Begin);
+ MCSectionWasm(CachedName, Kind, GroupSym, UniqueID, Begin);
Entry.second = Result;
return Result;
}
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index e162e954687..d8077df1469 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -824,24 +824,24 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
// TODO: Set the section types and flags.
- TextSection = Ctx->getWasmSection(".text", wasm::WASM_SEC_CODE);
- DataSection = Ctx->getWasmSection(".data", wasm::WASM_SEC_DATA);
+ TextSection = Ctx->getWasmSection(".text", SectionKind::getText());
+ DataSection = Ctx->getWasmSection(".data", SectionKind::getData());
// TODO: Set the section types and flags.
- DwarfLineSection = Ctx->getWasmSection(".debug_line", wasm::WASM_SEC_DATA);
- DwarfStrSection = Ctx->getWasmSection(".debug_str", wasm::WASM_SEC_DATA);
- DwarfLocSection = Ctx->getWasmSection(".debug_loc", wasm::WASM_SEC_DATA);
- DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", wasm::WASM_SEC_DATA, "section_abbrev");
- DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", wasm::WASM_SEC_DATA);
- DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", wasm::WASM_SEC_DATA, "debug_range");
- DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", wasm::WASM_SEC_DATA, "debug_macinfo");
- DwarfAddrSection = Ctx->getWasmSection(".debug_addr", wasm::WASM_SEC_DATA);
- DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", wasm::WASM_SEC_DATA);
- DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", wasm::WASM_SEC_DATA);
- DwarfInfoSection = Ctx->getWasmSection(".debug_info", wasm::WASM_SEC_DATA, "section_info");
- DwarfFrameSection = Ctx->getWasmSection(".debug_frame", wasm::WASM_SEC_DATA);
- DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", wasm::WASM_SEC_DATA);
- DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", wasm::WASM_SEC_DATA);
+ DwarfLineSection = Ctx->getWasmSection(".debug_line", SectionKind::getMetadata());
+ DwarfStrSection = Ctx->getWasmSection(".debug_str", SectionKind::getMetadata());
+ DwarfLocSection = Ctx->getWasmSection(".debug_loc", SectionKind::getMetadata());
+ DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata(), "section_abbrev");
+ DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", SectionKind::getMetadata());
+ DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata(), "debug_range");
+ DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata(), "debug_macinfo");
+ DwarfAddrSection = Ctx->getWasmSection(".debug_addr", SectionKind::getMetadata());
+ DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata());
+ DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata());
+ DwarfInfoSection = Ctx->getWasmSection(".debug_info", SectionKind::getMetadata(), "section_info");
+ DwarfFrameSection = Ctx->getWasmSection(".debug_frame", SectionKind::getMetadata());
+ DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata());
+ DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata());
// TODO: Define more sections.
}
diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp
index 5399f4ae58e..287b7cf7b23 100644
--- a/llvm/lib/MC/MCWasmStreamer.cpp
+++ b/llvm/lib/MC/MCWasmStreamer.cpp
@@ -157,7 +157,7 @@ void MCWasmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
void MCWasmStreamer::EmitIdent(StringRef IdentString) {
MCSection *Comment = getAssembler().getContext().getWasmSection(
- ".comment", wasm::WASM_SEC_DATA);
+ ".comment", SectionKind::getMetadata());
PushSection();
SwitchSection(Comment);
if (!SeenIdent) {
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 55e7c93c87e..44f2ba6ed7d 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -437,10 +437,13 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm,
WasmRelocationEntry Rec(FixupOffset, SymA, C, Type, &FixupSection);
DEBUG(dbgs() << "WasmReloc: " << Rec << "\n");
- if (FixupSection.hasInstructions())
- CodeRelocations.push_back(Rec);
- else
+ if (FixupSection.isWasmData())
DataRelocations.push_back(Rec);
+ else if (FixupSection.getKind().isText())
+ CodeRelocations.push_back(Rec);
+ else if (!FixupSection.getKind().isMetadata())
+ // TODO(sbc): Add support for debug sections.
+ llvm_unreachable("unexpected section type");
}
// Write X as an (unsigned) LEB value at offset Offset in Stream, padded
@@ -1060,7 +1063,8 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
// In the special .global_variables section, we've encoded global
// variables used by the function. Translate them into the Globals
// list.
- MCSectionWasm *GlobalVars = Ctx.getWasmSection(".global_variables", wasm::WASM_SEC_DATA);
+ MCSectionWasm *GlobalVars =
+ Ctx.getWasmSection(".global_variables", SectionKind::getMetadata());
if (!GlobalVars->getFragmentList().empty()) {
if (GlobalVars->getFragmentList().size() != 1)
report_fatal_error("only one .global_variables fragment supported");
@@ -1116,7 +1120,8 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
// In the special .stack_pointer section, we've encoded the stack pointer
// index.
- MCSectionWasm *StackPtr = Ctx.getWasmSection(".stack_pointer", wasm::WASM_SEC_DATA);
+ MCSectionWasm *StackPtr =
+ Ctx.getWasmSection(".stack_pointer", SectionKind::getMetadata());
if (!StackPtr->getFragmentList().empty()) {
if (StackPtr->getFragmentList().size() != 1)
report_fatal_error("only one .stack_pointer fragment supported");
@@ -1135,7 +1140,7 @@ void WasmObjectWriter::writeObject(MCAssembler &Asm,
for (MCSection &Sec : Asm) {
auto &Section = static_cast<MCSectionWasm &>(Sec);
- if (Section.getType() != wasm::WASM_SEC_DATA)
+ if (!Section.isWasmData())
continue;
DataSize = alignTo(DataSize, Section.getAlignment());
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
index 00bf02469bd..c82a64d5824 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
@@ -219,8 +219,8 @@ void WebAssemblyTargetWasmStreamer::emitGlobal(
// section. This will later be decoded and turned into contents for the
// Globals Section.
Streamer.PushSection();
- Streamer.SwitchSection(Streamer.getContext()
- .getWasmSection(".global_variables", 0, 0));
+ Streamer.SwitchSection(Streamer.getContext().getWasmSection(
+ ".global_variables", SectionKind::getMetadata()));
for (const wasm::Global &G : Globals) {
Streamer.EmitIntValue(int32_t(G.Type), 1);
Streamer.EmitIntValue(G.Mutable, 1);
@@ -240,8 +240,8 @@ void WebAssemblyTargetWasmStreamer::emitGlobal(
void WebAssemblyTargetWasmStreamer::emitStackPointer(uint32_t Index) {
Streamer.PushSection();
- Streamer.SwitchSection(Streamer.getContext()
- .getWasmSection(".stack_pointer", 0, 0));
+ Streamer.SwitchSection(Streamer.getContext().getWasmSection(
+ ".stack_pointer", SectionKind::getMetadata()));
Streamer.EmitIntValue(Index, 4);
Streamer.PopSection();
}
OpenPOWER on IntegriCloud