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

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


Author: ddunbar
Date: Thu May 13 19:37:14 2010
New Revision: 103751

URL: http://llvm.org/viewvc/llvm-project?rev=103751&view=rev
Log:
MC: Switch MCFragment to storing the layout order index, not its index in the file.

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

Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=103751&r1=103750&r2=103751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Thu May 13 19:37:14 2010
@@ -96,9 +96,9 @@
   /// initialized.
   uint64_t EffectiveSize;
 
-  /// Ordinal - The global index of this fragment. This is the index across all
-  /// sections, not just the parent section.
-  unsigned Ordinal;
+  /// LayoutOrder - The global layout order of this fragment. This is the index
+  /// across all fragments in the file, not just within the section.
+  unsigned LayoutOrder;
 
   /// @}
 
@@ -118,8 +118,8 @@
   MCSymbolData *getAtom() const { return Atom; }
   void setAtom(MCSymbolData *Value) { Atom = Value; }
 
-  unsigned getOrdinal() const { return Ordinal; }
-  void setOrdinal(unsigned Value) { Ordinal = Value; }
+  unsigned getLayoutOrder() const { return LayoutOrder; }
+  void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
 
   static bool classof(const MCFragment *O) { return true; }
 

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=103751&r1=103750&r2=103751&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu May 13 19:37:14 2010
@@ -599,10 +599,6 @@
   // Create the layout object.
   MCAsmLayout Layout(*this);
 
-  // Assign layout order indices.
-  for (unsigned i = 0, e = Layout.getSectionOrder().size(); i != e; ++i)
-    Layout.getSectionOrder()[i]->setLayoutOrder(i);
-
   // Insert additional align fragments for concrete sections to explicitly pad
   // the previous section to match their alignment requirements. This is for
   // 'gas' compatibility, it shouldn't strictly be necessary.
@@ -627,10 +623,8 @@
     AF->setOnlyAlignAddress(true);
   }
 
-  // Assign section and fragment ordinals, all subsequent backend code is
-  // responsible for updating these in place.
+  // Create dummy fragments and assign section ordinals.
   unsigned SectionIndex = 0;
-  unsigned FragmentIndex = 0;
   for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) {
     // Create dummy fragments to eliminate any empty sections, this simplifies
     // layout.
@@ -642,10 +636,17 @@
     }
 
     it->setOrdinal(SectionIndex++);
+  }
 
-    for (MCSectionData::iterator it2 = it->begin(),
-           ie2 = it->end(); it2 != ie2; ++it2)
-      it2->setOrdinal(FragmentIndex++);
+  // Assign layout order indices to sections and fragments.
+  unsigned FragmentIndex = 0;
+  for (unsigned i = 0, e = Layout.getSectionOrder().size(); i != e; ++i) {
+    MCSectionData *SD = Layout.getSectionOrder()[i];
+    SD->setLayoutOrder(i);
+
+    for (MCSectionData::iterator it2 = SD->begin(),
+           ie2 = SD->end(); it2 != ie2; ++it2)
+      it2->setLayoutOrder(FragmentIndex++);
   }
 
   // Layout until everything fits.
@@ -827,7 +828,7 @@
       // Update the data fragments layout data.
       DF->setParent(IF->getParent());
       DF->setAtom(IF->getAtom());
-      DF->setOrdinal(IF->getOrdinal());
+      DF->setLayoutOrder(IF->getLayoutOrder());
       Layout.FragmentReplaced(IF, DF);
 
       // Copy in the data and the fixups.
@@ -857,8 +858,8 @@
 void MCFragment::dump() {
   raw_ostream &OS = llvm::errs();
 
-  OS << "<MCFragment " << (void*) this << " Offset:" << Offset
-     << " EffectiveSize:" << EffectiveSize << ">";
+  OS << "<MCFragment " << (void*) this << " LayoutOrder:" << LayoutOrder
+     << " Offset:" << Offset << " EffectiveSize:" << EffectiveSize << ">";
 }
 
 void MCAlignFragment::dump() {





More information about the llvm-commits mailing list