summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-12 17:56:47 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-12 17:56:47 +0000
commitd13a0caf726e05c9bd939d752ef371d6d467ef28 (patch)
tree1bfb82f96164582416f1d2920c4ab2b919af3f91 /lib
parent473a09d80a8d3ecb37ac0d01289c79f7cc4fc645 (diff)
downloadllvm-d13a0caf726e05c9bd939d752ef371d6d467ef28.tar.gz
llvm-d13a0caf726e05c9bd939d752ef371d6d467ef28.tar.bz2
llvm-d13a0caf726e05c9bd939d752ef371d6d467ef28.tar.xz
MC: Simplify LayoutSection to just take the index of the section to layout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103627 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCAssembler.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 60349e69aa..aefe2c4294 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -68,12 +68,9 @@ void MCAsmLayout::UpdateForSlide(MCFragment *F, int SlideAmount) {
//
// FIXME-PERF: This is O(N^2), but will be eliminated once we get smarter.
- // Layout the concrete sections and fragments.
- uint64_t Address = 0;
- for (iterator it = begin(), ie = end(); it != ie; ++it) {
- // Layout the section fragments and its size.
- Address = getAssembler().LayoutSection(**it, *this, Address);
- }
+ // Layout the sections in order.
+ for (unsigned i = 0, e = getSectionOrder().size(); i != e; ++i)
+ getAssembler().LayoutSection(*this, i);
}
uint64_t MCAsmLayout::getFragmentAddress(const MCFragment *F) const {
@@ -365,13 +362,20 @@ bool MCAssembler::EvaluateFixup(const MCAsmLayout &Layout,
return IsResolved;
}
-uint64_t MCAssembler::LayoutSection(MCSectionData &SD,
- MCAsmLayout &Layout,
- uint64_t StartAddress) {
+void MCAssembler::LayoutSection(MCAsmLayout &Layout,
+ unsigned SectionOrderIndex) {
+ MCSectionData &SD = *Layout.getSectionOrder()[SectionOrderIndex];
bool IsVirtual = getBackend().isVirtualSection(SD.getSection());
++stats::SectionLayouts;
+ // Get the section start address.
+ uint64_t StartAddress = 0;
+ if (SectionOrderIndex) {
+ MCSectionData *Prev = Layout.getSectionOrder()[SectionOrderIndex - 1];
+ StartAddress = Layout.getSectionAddress(Prev) + Layout.getSectionSize(Prev);
+ }
+
// Align this section if necessary by adding padding bytes to the previous
// section. It is safe to adjust this out-of-band, because no symbol or
// fragment is allowed to point past the end of the section at any time.
@@ -469,8 +473,6 @@ uint64_t MCAssembler::LayoutSection(MCSectionData &SD,
Layout.setSectionFileSize(&SD, 0);
else
Layout.setSectionFileSize(&SD, Address - StartAddress);
-
- return Address;
}
/// WriteFragmentData - Write the \arg F data to the output file.
@@ -705,13 +707,9 @@ bool MCAssembler::FragmentNeedsRelaxation(const MCInstFragment *IF,
bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) {
++stats::RelaxationSteps;
- // Layout the concrete sections and fragments.
- uint64_t Address = 0;
- for (MCAsmLayout::iterator it = Layout.begin(),
- ie = Layout.end(); it != ie; ++it) {
- // Layout the section fragments and its size.
- Address = LayoutSection(**it, Layout, Address);
- }
+ // Layout the sections in order.
+ for (unsigned i = 0, e = Layout.getSectionOrder().size(); i != e; ++i)
+ LayoutSection(Layout, i);
// Scan for fragments that need relaxation.
bool WasRelaxed = false;