MC: Explicity track section and fragment ordinals.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99500 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-03-25 07:10:11 +00:00
parent b026d64bf2
commit 5a6e97a7e4
2 changed files with 28 additions and 0 deletions

View File

@ -91,6 +91,10 @@ private:
/// initialized. /// initialized.
uint64_t EffectiveSize; uint64_t EffectiveSize;
/// Ordinal - The global index of this fragment. This is the index across all
/// sections, not just the parent section.
unsigned Ordinal;
/// @} /// @}
protected: protected:
@ -106,6 +110,9 @@ public:
MCSectionData *getParent() const { return Parent; } MCSectionData *getParent() const { return Parent; }
void setParent(MCSectionData *Value) { Parent = Value; } void setParent(MCSectionData *Value) { Parent = Value; }
unsigned getOrdinal() const { return Ordinal; }
void setOrdinal(unsigned Value) { Ordinal = Value; }
static bool classof(const MCFragment *O) { return true; } static bool classof(const MCFragment *O) { return true; }
virtual void dump(); virtual void dump();
@ -390,6 +397,9 @@ private:
iplist<MCFragment> Fragments; iplist<MCFragment> Fragments;
const MCSection *Section; const MCSection *Section;
/// Ordinal - The section index in the assemblers section list.
unsigned Ordinal;
/// Alignment - The maximum alignment seen in this section. /// Alignment - The maximum alignment seen in this section.
unsigned Alignment; unsigned Alignment;
@ -428,6 +438,9 @@ public:
bool hasInstructions() const { return HasInstructions; } bool hasInstructions() const { return HasInstructions; }
void setHasInstructions(bool Value) { HasInstructions = Value; } void setHasInstructions(bool Value) { HasInstructions = Value; }
unsigned getOrdinal() const { return Ordinal; }
void setOrdinal(unsigned Value) { Ordinal = Value; }
/// @name Fragment Access /// @name Fragment Access
/// @{ /// @{
@ -451,6 +464,8 @@ public:
bool empty() const { return Fragments.empty(); } bool empty() const { return Fragments.empty(); }
void dump(); void dump();
/// @}
}; };
// FIXME: Same concerns as with SectionData. // FIXME: Same concerns as with SectionData.

View File

@ -568,6 +568,18 @@ void MCAssembler::Finish() {
llvm::errs() << "assembler backend - pre-layout\n--\n"; llvm::errs() << "assembler backend - pre-layout\n--\n";
dump(); }); dump(); });
// Assign section and fragment ordinals, all subsequent backend code is
// responsible for updating these in place.
unsigned SectionIndex = 0;
unsigned FragmentIndex = 0;
for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) {
it->setOrdinal(SectionIndex++);
for (MCSectionData::iterator it2 = it->begin(),
ie2 = it->end(); it2 != ie2; ++it2)
it2->setOrdinal(FragmentIndex++);
}
// Layout until everything fits. // Layout until everything fits.
MCAsmLayout Layout(*this); MCAsmLayout Layout(*this);
while (LayoutOnce(Layout)) while (LayoutOnce(Layout))
@ -781,6 +793,7 @@ void MCAssembler::FinishLayout(MCAsmLayout &Layout) {
// //
// FIXME: Add MCAsmLayout utility for this. // FIXME: Add MCAsmLayout utility for this.
DF->setParent(IF->getParent()); DF->setParent(IF->getParent());
DF->setOrdinal(IF->getOrdinal());
Layout.setFragmentOffset(DF, Layout.getFragmentOffset(IF)); Layout.setFragmentOffset(DF, Layout.getFragmentOffset(IF));
Layout.setFragmentEffectiveSize(DF, Layout.getFragmentEffectiveSize(IF)); Layout.setFragmentEffectiveSize(DF, Layout.getFragmentEffectiveSize(IF));