[llvm] r238160 - Store a MCSection in MCFragment.
Rafael Espindola
rafael.espindola at gmail.com
Mon May 25 16:48:23 PDT 2015
Author: rafael
Date: Mon May 25 18:48:22 2015
New Revision: 238160
URL: http://llvm.org/viewvc/llvm-project?rev=238160&view=rev
Log:
Store a MCSection in MCFragment.
Part of the work to merge MCSectionData into MCSection.
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/include/llvm/MC/MCObjectStreamer.h
llvm/trunk/lib/MC/MCAssembler.cpp
llvm/trunk/lib/MC/MCELFStreamer.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/MC/WinCOFFStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=238160&r1=238159&r2=238160&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Mon May 25 18:48:22 2015
@@ -67,8 +67,8 @@ public:
private:
FragmentType Kind;
- /// Parent - The data for the section this fragment is in.
- MCSectionData *Parent;
+ /// The data for the section this fragment is in.
+ MCSection *Parent;
/// Atom - The atom this fragment is in, as represented by it's defining
/// symbol.
@@ -89,7 +89,7 @@ private:
/// @}
protected:
- MCFragment(FragmentType Kind, MCSectionData *Parent = nullptr);
+ MCFragment(FragmentType Kind, MCSection *Parent = nullptr);
public:
// Only for sentinel.
@@ -98,8 +98,10 @@ public:
FragmentType getKind() const { return Kind; }
- MCSectionData *getParent() const { return Parent; }
- void setParent(MCSectionData *Value) { Parent = Value; }
+ MCSectionData *getParent() const {
+ return &Parent->getSectionData();
+ }
+ void setParent(MCSection *Value) { Parent = Value; }
const MCSymbol *getAtom() const { return Atom; }
void setAtom(const MCSymbol *Value) { Atom = Value; }
@@ -138,8 +140,8 @@ class MCEncodedFragment : public MCFragm
uint8_t BundlePadding;
public:
- MCEncodedFragment(MCFragment::FragmentType FType, MCSectionData *SD = nullptr)
- : MCFragment(FType, SD), BundlePadding(0) {}
+ MCEncodedFragment(MCFragment::FragmentType FType, MCSection *Sec = nullptr)
+ : MCFragment(FType, Sec), BundlePadding(0) {}
~MCEncodedFragment() override;
virtual SmallVectorImpl<char> &getContents() = 0;
@@ -170,8 +172,8 @@ class MCEncodedFragmentWithFixups : publ
public:
MCEncodedFragmentWithFixups(MCFragment::FragmentType FType,
- MCSectionData *SD = nullptr)
- : MCEncodedFragment(FType, SD) {}
+ MCSection *Sec = nullptr)
+ : MCEncodedFragment(FType, Sec) {}
~MCEncodedFragmentWithFixups() override;
@@ -209,8 +211,8 @@ class MCDataFragment : public MCEncodedF
SmallVector<MCFixup, 4> Fixups;
public:
- MCDataFragment(MCSectionData *SD = nullptr)
- : MCEncodedFragmentWithFixups(FT_Data, SD), HasInstructions(false),
+ MCDataFragment(MCSection *Sec = nullptr)
+ : MCEncodedFragmentWithFixups(FT_Data, Sec), HasInstructions(false),
AlignToBundleEnd(false) {}
SmallVectorImpl<char> &getContents() override { return Contents; }
@@ -251,8 +253,9 @@ class MCCompactEncodedInstFragment : pub
SmallVector<char, 4> Contents;
public:
- MCCompactEncodedInstFragment(MCSectionData *SD = nullptr)
- : MCEncodedFragment(FT_CompactEncodedInst, SD), AlignToBundleEnd(false) {}
+ MCCompactEncodedInstFragment(MCSection *Sec = nullptr)
+ : MCEncodedFragment(FT_CompactEncodedInst, Sec), AlignToBundleEnd(false) {
+ }
bool hasInstructions() const override { return true; }
@@ -289,8 +292,8 @@ class MCRelaxableFragment : public MCEnc
public:
MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI,
- MCSectionData *SD = nullptr)
- : MCEncodedFragmentWithFixups(FT_Relaxable, SD), Inst(Inst), STI(STI) {}
+ MCSection *Sec = nullptr)
+ : MCEncodedFragmentWithFixups(FT_Relaxable, Sec), Inst(Inst), STI(STI) {}
SmallVectorImpl<char> &getContents() override { return Contents; }
const SmallVectorImpl<char> &getContents() const override { return Contents; }
@@ -340,8 +343,8 @@ class MCAlignFragment : public MCFragmen
public:
MCAlignFragment(unsigned Alignment, int64_t Value, unsigned ValueSize,
- unsigned MaxBytesToEmit, MCSectionData *SD = nullptr)
- : MCFragment(FT_Align, SD), Alignment(Alignment), Value(Value),
+ unsigned MaxBytesToEmit, MCSection *Sec = nullptr)
+ : MCFragment(FT_Align, Sec), Alignment(Alignment), Value(Value),
ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit), EmitNops(false) {}
/// \name Accessors
@@ -380,8 +383,8 @@ class MCFillFragment : public MCFragment
public:
MCFillFragment(int64_t Value, unsigned ValueSize, uint64_t Size,
- MCSectionData *SD = nullptr)
- : MCFragment(FT_Fill, SD), Value(Value), ValueSize(ValueSize),
+ MCSection *Sec = nullptr)
+ : MCFragment(FT_Fill, Sec), Value(Value), ValueSize(ValueSize),
Size(Size) {
assert((!ValueSize || (Size % ValueSize) == 0) &&
"Fill size must be a multiple of the value size!");
@@ -413,8 +416,8 @@ class MCOrgFragment : public MCFragment
int8_t Value;
public:
- MCOrgFragment(const MCExpr &Offset, int8_t Value, MCSectionData *SD = nullptr)
- : MCFragment(FT_Org, SD), Offset(&Offset), Value(Value) {}
+ MCOrgFragment(const MCExpr &Offset, int8_t Value, MCSection *Sec = nullptr)
+ : MCFragment(FT_Org, Sec), Offset(&Offset), Value(Value) {}
/// \name Accessors
/// @{
@@ -442,9 +445,8 @@ class MCLEBFragment : public MCFragment
SmallString<8> Contents;
public:
- MCLEBFragment(const MCExpr &Value_, bool IsSigned_,
- MCSectionData *SD = nullptr)
- : MCFragment(FT_LEB, SD), Value(&Value_), IsSigned(IsSigned_) {
+ MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSection *Sec = nullptr)
+ : MCFragment(FT_LEB, Sec), Value(&Value_), IsSigned(IsSigned_) {
Contents.push_back(0);
}
@@ -480,8 +482,8 @@ class MCDwarfLineAddrFragment : public M
public:
MCDwarfLineAddrFragment(int64_t LineDelta, const MCExpr &AddrDelta,
- MCSectionData *SD = nullptr)
- : MCFragment(FT_Dwarf, SD), LineDelta(LineDelta), AddrDelta(&AddrDelta) {
+ MCSection *Sec = nullptr)
+ : MCFragment(FT_Dwarf, Sec), LineDelta(LineDelta), AddrDelta(&AddrDelta) {
Contents.push_back(0);
}
@@ -512,8 +514,8 @@ class MCDwarfCallFrameFragment : public
SmallString<8> Contents;
public:
- MCDwarfCallFrameFragment(const MCExpr &AddrDelta, MCSectionData *SD = nullptr)
- : MCFragment(FT_DwarfFrame, SD), AddrDelta(&AddrDelta) {
+ MCDwarfCallFrameFragment(const MCExpr &AddrDelta, MCSection *Sec = nullptr)
+ : MCFragment(FT_DwarfFrame, Sec), AddrDelta(&AddrDelta) {
Contents.push_back(0);
}
Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=238160&r1=238159&r2=238160&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Mon May 25 18:48:22 2015
@@ -74,7 +74,7 @@ protected:
void insert(MCFragment *F) {
flushPendingLabels(F);
CurSectionData->getFragmentList().insert(CurInsertionPoint, F);
- F->setParent(CurSectionData);
+ F->setParent(&CurSectionData->getSection());
}
/// Get a data fragment to write into, creating a new one if the current
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=238160&r1=238159&r2=238160&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Mon May 25 18:48:22 2015
@@ -272,7 +272,7 @@ MCFragment::MCFragment() : Kind(Fragment
MCFragment::~MCFragment() {
}
-MCFragment::MCFragment(FragmentType Kind, MCSectionData *Parent)
+MCFragment::MCFragment(FragmentType Kind, MCSection *Parent)
: Kind(Kind), Parent(Parent), Atom(nullptr), Offset(~UINT64_C(0)) {
if (Parent)
Parent->getFragmentList().push_back(this);
@@ -317,7 +317,7 @@ MCSectionData::getSubsectionInsertionPoi
MCFragment *F = new MCDataFragment();
SubsectionFragmentMap.insert(MI, std::make_pair(Subsection, F));
getFragmentList().insert(IP, F);
- F->setParent(this);
+ F->setParent(&getSection());
}
return IP;
@@ -859,7 +859,7 @@ void MCAssembler::Finish() {
// Create dummy fragments to eliminate any empty sections, this simplifies
// layout.
if (it->getFragmentList().empty())
- new MCDataFragment(&it->getSectionData());
+ new MCDataFragment(&*it);
it->setOrdinal(SectionIndex++);
}
Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=238160&r1=238159&r2=238160&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Mon May 25 18:48:22 2015
@@ -644,9 +644,10 @@ void MCELFStreamer::Flush() {
MCSection &Section = Symbol.getSection();
MCSectionData &SectData = getAssembler().getOrCreateSectionData(Section);
- new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &SectData);
+ new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment,
+ &SectData.getSection());
- MCFragment *F = new MCFillFragment(0, 0, Size, &SectData);
+ MCFragment *F = new MCFillFragment(0, 0, Size, &SectData.getSection());
Symbol.getData().setFragment(F);
// Update the maximum alignment of the section if necessary.
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=238160&r1=238159&r2=238160&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Mon May 25 18:48:22 2015
@@ -418,9 +418,10 @@ void MCMachOStreamer::EmitZerofill(MCSec
// Emit an align fragment if necessary.
if (ByteAlignment != 1)
- new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, &SectData);
+ new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment,
+ &SectData.getSection());
- MCFragment *F = new MCFillFragment(0, 0, Size, &SectData);
+ MCFragment *F = new MCFillFragment(0, 0, Size, &SectData.getSection());
SD.setFragment(F);
AssignSection(Symbol, Section);
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=238160&r1=238159&r2=238160&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Mon May 25 18:48:22 2015
@@ -43,7 +43,7 @@ void MCObjectStreamer::flushPendingLabel
if (!F) {
F = new MCDataFragment();
CurSectionData->getFragmentList().insert(CurInsertionPoint, F);
- F->setParent(CurSectionData);
+ F->setParent(&CurSectionData->getSection());
}
for (MCSymbolData *SD : PendingLabels) {
SD->setFragment(F);
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=238160&r1=238159&r2=238160&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Mon May 25 18:48:22 2015
@@ -231,10 +231,10 @@ void MCWinCOFFStreamer::EmitLocalCommonS
if (ByteAlignment != 1)
new MCAlignFragment(ByteAlignment, /*Value=*/0, /*ValueSize=*/0,
- ByteAlignment, &SectionData);
+ ByteAlignment, &SectionData.getSection());
- MCFillFragment *Fragment =
- new MCFillFragment(/*Value=*/0, /*ValueSize=*/0, Size, &SectionData);
+ MCFillFragment *Fragment = new MCFillFragment(
+ /*Value=*/0, /*ValueSize=*/0, Size, &SectionData.getSection());
SD.setFragment(Fragment);
}
More information about the llvm-commits
mailing list