[PATCH] D21743: Convenience function for MCStreamer to get named sections when lowering.
Dean Michael Berris via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 18:02:41 PDT 2016
dberris updated this revision to Diff 62324.
dberris added a comment.
- Move API from MCStreamer to MCContext
http://reviews.llvm.org/D21743
Files:
include/llvm/MC/MCContext.h
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
lib/MC/MCContext.cpp
Index: lib/MC/MCContext.cpp
===================================================================
--- lib/MC/MCContext.cpp
+++ lib/MC/MCContext.cpp
@@ -322,6 +322,15 @@
EntrySize, Group, true, nullptr, Associated);
}
+MCSectionELF *MCContext::getELFNamedSection(StringRef Section, StringRef Group,
+ unsigned Type, unsigned Flags,
+ unsigned EntrySize) {
+ SmallString<64> FullName(Section);
+ FullName += ".";
+ FullName += Group;
+ return getELFSection(FullName, Type, Flags, EntrySize, Group);
+}
+
MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
StringRef Group, unsigned UniqueID,
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -69,11 +69,9 @@
cast<MCSymbolELF>(getContext().getOrCreateSymbol(NameData));
Streamer.EmitSymbolAttribute(Label, MCSA_Hidden);
Streamer.EmitSymbolAttribute(Label, MCSA_Weak);
- StringRef Prefix = ".data.";
- NameData.insert(NameData.begin(), Prefix.begin(), Prefix.end());
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP;
- MCSection *Sec = getContext().getELFSection(NameData, ELF::SHT_PROGBITS,
- Flags, 0, Label->getName());
+ MCSection *Sec = getContext().getELFNamedSection(".data", Label->getName(),
+ ELF::SHT_PROGBITS, Flags, 0);
unsigned Size = DL.getPointerSize();
Streamer.SwitchSection(Sec);
Streamer.EmitValueToAlignment(DL.getPointerABIAlignment());
Index: include/llvm/MC/MCContext.h
===================================================================
--- include/llvm/MC/MCContext.h
+++ include/llvm/MC/MCContext.h
@@ -380,6 +380,14 @@
const char *BeginSymName,
const MCSectionELF *Associated);
+ /// Get a section with the provided group identifier. This section is
+ /// named by concatenating \p Section with '.' then \p Group. The \p Type
+ /// describes the type of the section and \p Flags are used to further
+ /// configure this named section.
+ MCSectionELF *getELFNamedSection(StringRef Section, StringRef Group,
+ unsigned Type, unsigned Flags,
+ unsigned EntrySize = 0);
+
MCSectionELF *createELFRelSection(StringRef Name, unsigned Type,
unsigned Flags, unsigned EntrySize,
const MCSymbolELF *Group,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21743.62324.patch
Type: text/x-patch
Size: 2868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160630/2c5ee1b1/attachment.bin>
More information about the llvm-commits
mailing list