MC: Add MCAsmLayout::FragmentReplaced() helper function.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 13 May 2010 08:43:31 +0000 (08:43 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 13 May 2010 08:43:31 +0000 (08:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103709 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAsmLayout.h
lib/MC/MCAssembler.cpp

index 8a382470025b7e6abc58f2bd415ca97d4b5256fc..f866aab95b502564ca66fa5b8ebbd5dddfd234ed 100644 (file)
@@ -47,6 +47,9 @@ public:
   /// the delta from the old size.
   void UpdateForSlide(MCFragment *F, int SlideAmount);
 
+  /// \brief Update the layout because a fragment has been replaced.
+  void FragmentReplaced(MCFragment *Src, MCFragment *Dst);
+
   /// @name Section Access (in layout order)
   /// @{
 
index e62296f35d10bf4646c1661ea9725686fd62853c..de36c52c6800ee51c3143f2c0a5ece4ddc6a35ad 100644 (file)
@@ -73,6 +73,11 @@ void MCAsmLayout::UpdateForSlide(MCFragment *F, int SlideAmount) {
     getAssembler().LayoutSection(*this, i);
 }
 
+void MCAsmLayout::FragmentReplaced(MCFragment *Src, MCFragment *Dst) {
+  Dst->Offset = Src->Offset;
+  Dst->EffectiveSize = Src->EffectiveSize;
+}
+
 uint64_t MCAsmLayout::getFragmentAddress(const MCFragment *F) const {
   assert(F->getParent() && "Missing section()!");
   return getSectionAddress(F->getParent()) + getFragmentOffset(F);
@@ -818,13 +823,10 @@ void MCAssembler::FinishLayout(MCAsmLayout &Layout) {
       SD.getFragmentList().insert(it2, DF);
 
       // Update the data fragments layout data.
-      //
-      // FIXME: Add MCAsmLayout utility for this.
       DF->setParent(IF->getParent());
       DF->setAtom(IF->getAtom());
       DF->setOrdinal(IF->getOrdinal());
-      Layout.setFragmentOffset(DF, Layout.getFragmentOffset(IF));
-      Layout.setFragmentEffectiveSize(DF, Layout.getFragmentEffectiveSize(IF));
+      Layout.FragmentReplaced(IF, DF);
 
       // Copy in the data and the fixups.
       DF->getContents().append(IF->getCode().begin(), IF->getCode().end());