1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

Stop forwarding (get|set)Aligment from MCSectionData to MCSection.

llvm-svn: 237956
This commit is contained in:
Rafael Espindola 2015-05-21 21:02:35 +00:00
parent c4d3b538dd
commit e81026f8a7
11 changed files with 39 additions and 47 deletions

View File

@ -597,9 +597,6 @@ public:
MCSection &getSection() const { return *Section; }
unsigned getAlignment() const;
void setAlignment(unsigned Value);
bool hasInstructions() const { return HasInstructions; }
void setHasInstructions(bool Value) { HasInstructions = Value; }

View File

@ -1347,7 +1347,7 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
for (const MCSectionData &SD : Asm) {
MCSectionELF &Section = static_cast<MCSectionELF &>(SD.getSection());
uint64_t Padding = OffsetToAlignment(OS.tell(), SD.getAlignment());
uint64_t Padding = OffsetToAlignment(OS.tell(), Section.getAlignment());
WriteZeros(Padding);
// Remember the offset into the file for this section.

View File

@ -300,12 +300,6 @@ MCSectionData::MCSectionData(MCSection &Section, MCAssembler *A)
A->getSectionList().push_back(this);
}
unsigned MCSectionData::getAlignment() const { return Section->getAlignment(); }
void MCSectionData::setAlignment(unsigned Value) {
Section->setAlignment(Value);
}
MCSectionData::iterator
MCSectionData::getSubsectionInsertionPoint(unsigned Subsection) {
if (Subsection == 0 && SubsectionFragmentMap.empty())
@ -1259,8 +1253,7 @@ void MCSectionData::dump() {
raw_ostream &OS = llvm::errs();
OS << "<MCSectionData";
OS << " Alignment:" << getAlignment()
<< " Fragments:[\n ";
OS << " Fragments:[\n ";
for (iterator it = begin(), ie = end(); it != ie; ++it) {
if (it != begin()) OS << ",\n ";
it->dump();

View File

@ -135,10 +135,9 @@ void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
// needs to be aligned to at least the bundle size.
static void setSectionAlignmentForBundling(
const MCAssembler &Assembler, MCSectionData *Section) {
if (Assembler.isBundlingEnabled() && Section &&
Section->hasInstructions() &&
Section->getAlignment() < Assembler.getBundleAlignSize())
Section->setAlignment(Assembler.getBundleAlignSize());
if (Assembler.isBundlingEnabled() && Section && Section->hasInstructions() &&
Section->getSection().getAlignment() < Assembler.getBundleAlignSize())
Section->getSection().setAlignment(Assembler.getBundleAlignSize());
}
void MCELFStreamer::ChangeSection(MCSection *Section,
@ -642,8 +641,8 @@ void MCELFStreamer::Flush() {
Symbol.getData().setFragment(F);
// Update the maximum alignment of the section if necessary.
if (ByteAlignment > SectData.getAlignment())
SectData.setAlignment(ByteAlignment);
if (ByteAlignment > Section.getAlignment())
Section.setAlignment(ByteAlignment);
}
LocalCommons.clear();

View File

@ -426,8 +426,8 @@ void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
AssignSection(Symbol, Section);
// Update the maximum alignment on the zero fill section if necessary.
if (ByteAlignment > SectData.getAlignment())
SectData.setAlignment(ByteAlignment);
if (ByteAlignment > Section->getAlignment())
Section->setAlignment(ByteAlignment);
}
// This should always be called with the thread local bss section. Like the

View File

@ -380,8 +380,9 @@ void MCObjectStreamer::EmitValueToAlignment(unsigned ByteAlignment,
insert(new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit));
// Update the maximum alignment on the current section if necessary.
if (ByteAlignment > getCurrentSectionData()->getAlignment())
getCurrentSectionData()->setAlignment(ByteAlignment);
MCSection *CurSec = getCurrentSection().first;
if (ByteAlignment > CurSec->getAlignment())
CurSec->setAlignment(ByteAlignment);
}
void MCObjectStreamer::EmitCodeAlignment(unsigned ByteAlignment,

View File

@ -115,7 +115,7 @@ uint64_t MachObjectWriter::getPaddingSize(const MCSectionData *SD,
const MCSectionData &NextSD = *Layout.getSectionOrder()[Next];
if (NextSD.getSection().isVirtualSection())
return 0;
return OffsetToAlignment(EndAddr, NextSD.getAlignment());
return OffsetToAlignment(EndAddr, NextSD.getSection().getAlignment());
}
void MachObjectWriter::WriteHeader(unsigned NumLoadCommands,
@ -199,9 +199,10 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
uint64_t RelocationsStart,
unsigned NumRelocations) {
uint64_t SectionSize = Layout.getSectionAddressSize(&SD);
const MCSectionMachO &Section = cast<MCSectionMachO>(SD.getSection());
// The offset is unused for virtual sections.
if (SD.getSection().isVirtualSection()) {
if (Section.isVirtualSection()) {
assert(Layout.getSectionFileSize(&SD) == 0 && "Invalid file size!");
FileOffset = 0;
}
@ -212,7 +213,6 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
uint64_t Start = OS.tell();
(void) Start;
const MCSectionMachO &Section = cast<MCSectionMachO>(SD.getSection());
WriteBytes(Section.getSectionName(), 16);
WriteBytes(Section.getSegmentName(), 16);
if (is64Bit()) {
@ -228,8 +228,8 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
if (SD.hasInstructions())
Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
assert(isPowerOf2_32(SD.getAlignment()) && "Invalid alignment!");
Write32(Log2_32(SD.getAlignment()));
assert(isPowerOf2_32(Section.getAlignment()) && "Invalid alignment!");
Write32(Log2_32(Section.getAlignment()));
Write32(NumRelocations ? RelocationsStart : 0);
Write32(NumRelocations);
Write32(Flags);
@ -645,7 +645,8 @@ void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm,
const SmallVectorImpl<MCSectionData*> &Order = Layout.getSectionOrder();
for (int i = 0, n = Order.size(); i != n ; ++i) {
const MCSectionData *SD = Order[i];
StartAddress = RoundUpToAlignment(StartAddress, SD->getAlignment());
StartAddress =
RoundUpToAlignment(StartAddress, SD->getSection().getAlignment());
SectionAddress[SD] = StartAddress;
StartAddress += Layout.getSectionAddressSize(SD);

View File

@ -322,7 +322,7 @@ void WinCOFFObjectWriter::DefineSection(MCSectionData const &SectionData) {
coff_section->Header.Characteristics = Sec.getCharacteristics();
uint32_t &Characteristics = coff_section->Header.Characteristics;
switch (SectionData.getAlignment()) {
switch (Sec.getAlignment()) {
case 1: Characteristics |= COFF::IMAGE_SCN_ALIGN_1BYTES; break;
case 2: Characteristics |= COFF::IMAGE_SCN_ALIGN_2BYTES; break;
case 4: Characteristics |= COFF::IMAGE_SCN_ALIGN_4BYTES; break;

View File

@ -221,8 +221,8 @@ void MCWinCOFFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
MCSection *Section = getContext().getObjectFileInfo()->getBSSSection();
MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section);
if (SectionData.getAlignment() < ByteAlignment)
SectionData.setAlignment(ByteAlignment);
if (Section->getAlignment() < ByteAlignment)
Section->setAlignment(ByteAlignment);
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
SD.setExternal(false);

View File

@ -31,7 +31,8 @@ void MipsRegInfoRecord::EmitMipsOptionRecord() {
MCSectionELF *Sec =
Context.getELFSection(".MIPS.options", ELF::SHT_MIPS_OPTIONS,
ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, 1, "");
MCA.getOrCreateSectionData(*Sec).setAlignment(8);
MCA.getOrCreateSectionData(*Sec);
Sec->setAlignment(8);
Streamer->SwitchSection(Sec);
Streamer->EmitIntValue(ELF::ODK_REGINFO, 1); // kind
@ -48,8 +49,8 @@ void MipsRegInfoRecord::EmitMipsOptionRecord() {
} else {
MCSectionELF *Sec = Context.getELFSection(".reginfo", ELF::SHT_MIPS_REGINFO,
ELF::SHF_ALLOC, 24, "");
MCA.getOrCreateSectionData(*Sec)
.setAlignment(MTS->getABI().IsN32() ? 8 : 4);
MCA.getOrCreateSectionData(*Sec);
Sec->setAlignment(MTS->getABI().IsN32() ? 8 : 4);
Streamer->SwitchSection(Sec);
Streamer->EmitIntValue(ri_gprmask, 4);

View File

@ -459,16 +459,16 @@ void MipsTargetELFStreamer::finish() {
const MCObjectFileInfo &OFI = *MCA.getContext().getObjectFileInfo();
// .bss, .text and .data are always at least 16-byte aligned.
MCSectionData &TextSectionData =
MCA.getOrCreateSectionData(*OFI.getTextSection());
MCSectionData &DataSectionData =
MCA.getOrCreateSectionData(*OFI.getDataSection());
MCSectionData &BSSSectionData =
MCA.getOrCreateSectionData(*OFI.getBSSSection());
MCSection &TextSection = *OFI.getTextSection();
MCA.getOrCreateSectionData(TextSection);
MCSection &DataSection = *OFI.getDataSection();
MCA.getOrCreateSectionData(DataSection);
MCSection &BSSSection = *OFI.getBSSSection();
MCA.getOrCreateSectionData(BSSSection);
TextSectionData.setAlignment(std::max(16u, TextSectionData.getAlignment()));
DataSectionData.setAlignment(std::max(16u, DataSectionData.getAlignment()));
BSSSectionData.setAlignment(std::max(16u, BSSSectionData.getAlignment()));
TextSection.setAlignment(std::max(16u, TextSection.getAlignment()));
DataSection.setAlignment(std::max(16u, DataSection.getAlignment()));
BSSSection.setAlignment(std::max(16u, BSSSection.getAlignment()));
uint64_t Features = STI.getFeatureBits();
@ -570,8 +570,8 @@ void MipsTargetELFStreamer::emitDirectiveEnd(StringRef Name) {
const MCSymbolRefExpr *ExprRef =
MCSymbolRefExpr::Create(Name, MCSymbolRefExpr::VK_None, Context);
MCSectionData &SecData = MCA.getOrCreateSectionData(*Sec);
SecData.setAlignment(4);
MCA.getOrCreateSectionData(*Sec);
Sec->setAlignment(4);
OS.PushSection();
@ -788,8 +788,8 @@ void MipsTargetELFStreamer::emitMipsAbiFlags() {
MCStreamer &OS = getStreamer();
MCSectionELF *Sec = Context.getELFSection(
".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24, "");
MCSectionData &ABIShndxSD = MCA.getOrCreateSectionData(*Sec);
ABIShndxSD.setAlignment(8);
MCA.getOrCreateSectionData(*Sec);
Sec->setAlignment(8);
OS.SwitchSection(Sec);
OS << ABIFlagsSection;