[llvm-commits] [llvm] r103750 - in /llvm/trunk: include/llvm/MC/MCAsmLayout.h lib/MC/MCAssembler.cpp

Daniel Dunbar daniel at zuster.org
Thu May 13 17:37:11 PDT 2010


Author: ddunbar
Date: Thu May 13 19:37:11 2010
New Revision: 103750

URL: http://llvm.org/viewvc/llvm-project?rev=103750&view=rev
Log:
MC: Change LayoutSection() to only do the section initializiation.

Also, elimminate MCAsmLayout::set*, which are no longer needed.

Modified:
    llvm/trunk/include/llvm/MC/MCAsmLayout.h
    llvm/trunk/lib/MC/MCAssembler.cpp

Modified: llvm/trunk/include/llvm/MC/MCAsmLayout.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLayout.h?rev=103750&r1=103749&r2=103750&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmLayout.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmLayout.h Thu May 13 19:37:11 2010
@@ -58,8 +58,9 @@
   /// been initialized.
   void LayoutFragment(MCFragment *Fragment);
 
-  /// \brief Performs layout for a single section, assuming that the previous
-  /// section has already been layed out correctly.
+  /// \brief Performs initial layout for a single section, assuming that the
+  /// previous section (including its fragments) has already been layed out
+  /// correctly.
   void LayoutSection(MCSectionData *SD);
 
   /// @name Section Access (in layout order)
@@ -80,15 +81,9 @@
   /// current layout.
   uint64_t getFragmentEffectiveSize(const MCFragment *F) const;
 
-  /// \brief Set the effective size of the given fragment.
-  void setFragmentEffectiveSize(MCFragment *F, uint64_t Value);
-
   /// \brief Get the offset of the given fragment inside its containing section.
   uint64_t getFragmentOffset(const MCFragment *F) const;
 
-  /// \brief Set the offset of the given fragment inside its containing section.
-  void setFragmentOffset(MCFragment *F, uint64_t Value);
-
   /// @}
   /// @name Section Layout Data
   /// @{
@@ -96,9 +91,6 @@
   /// \brief Get the computed address of the given section.
   uint64_t getSectionAddress(const MCSectionData *SD) const;
 
-  /// \brief Set the computed address of the given section.
-  void setSectionAddress(MCSectionData *SD, uint64_t Value);
-
   /// @}
   /// @name Utility Functions
   /// @{

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=103750&r1=103749&r2=103750&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu May 13 19:37:11 2010
@@ -87,19 +87,11 @@
   return F->EffectiveSize;
 }
 
-void MCAsmLayout::setFragmentEffectiveSize(MCFragment *F, uint64_t Value) {
-  F->EffectiveSize = Value;
-}
-
 uint64_t MCAsmLayout::getFragmentOffset(const MCFragment *F) const {
   assert(F->Offset != ~UINT64_C(0) && "Address not set!");
   return F->Offset;
 }
 
-void MCAsmLayout::setFragmentOffset(MCFragment *F, uint64_t Value) {
-  F->Offset = Value;
-}
-
 uint64_t MCAsmLayout::getSymbolAddress(const MCSymbolData *SD) const {
   assert(SD->getFragment() && "Invalid getAddress() on undefined symbol!");
   return getFragmentAddress(SD->getFragment()) + SD->getOffset();
@@ -110,12 +102,8 @@
   return SD->Address;
 }
 
-void MCAsmLayout::setSectionAddress(MCSectionData *SD, uint64_t Value) {
-  SD->Address = Value;
-}
-
 uint64_t MCAsmLayout::getSectionAddressSize(const MCSectionData *SD) const {
-  // Otherwise, the size is the last fragment's end offset.
+  // The size is the last fragment's end offset.
   const MCFragment &F = SD->getFragmentList().back();
   return getFragmentOffset(&F) + getFragmentEffectiveSize(&F);
 }
@@ -426,8 +414,14 @@
 }
 
 void MCAsmLayout::LayoutFile() {
-  for (unsigned i = 0, e = getSectionOrder().size(); i != e; ++i)
-    LayoutSection(getSectionOrder()[i]);
+  for (unsigned i = 0, e = getSectionOrder().size(); i != e; ++i) {
+    MCSectionData *SD = getSectionOrder()[i];
+
+    LayoutSection(SD);
+    for (MCSectionData::iterator it = SD->begin(),
+           ie = SD->end(); it != ie; ++it)
+      LayoutFragment(it);
+  }
 }
 
 void MCAsmLayout::LayoutFragment(MCFragment *F) {
@@ -443,12 +437,9 @@
   ++stats::FragmentLayouts;
 
   // Compute fragment offset and size.
-  uint64_t Offset = Address - StartAddress;
-  uint64_t EffectiveSize =
-    getAssembler().ComputeFragmentSize(*this, *F, StartAddress, Offset);
-
-  setFragmentOffset(F, Offset);
-  setFragmentEffectiveSize(F, EffectiveSize);
+  F->Offset = Address - StartAddress;
+  F->EffectiveSize = getAssembler().ComputeFragmentSize(*this, *F, StartAddress,
+                                                        F->Offset);
 }
 
 void MCAsmLayout::LayoutSection(MCSectionData *SD) {
@@ -467,10 +458,7 @@
   StartAddress = RoundUpToAlignment(StartAddress, SD->getAlignment());
 
   // Set the section address.
-  setSectionAddress(SD, StartAddress);
-
-  for (MCSectionData::iterator it = SD->begin(), ie = SD->end(); it != ie; ++it)
-    LayoutFragment(it);
+  SD->Address = StartAddress;
 }
 
 /// WriteFragmentData - Write the \arg F data to the output file.





More information about the llvm-commits mailing list