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

Daniel Dunbar daniel at zuster.org
Sat Aug 22 01:27:58 PDT 2009


Author: ddunbar
Date: Sat Aug 22 03:27:54 2009
New Revision: 79734

URL: http://llvm.org/viewvc/llvm-project?rev=79734&view=rev
Log:
llvm-mc: Rename / redefine MCFragment::FileOffset to MCFragment::Offset (the
section offset).

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=79734&r1=79733&r2=79734&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Sat Aug 22 03:27:54 2009
@@ -43,12 +43,11 @@
   //
   // FIXME: This could all be kept private to the assembler implementation.
 
-  /// FileOffset - The offset of this section in the object file. This is ~0
-  /// until initialized.
-  uint64_t FileOffset;
-
-  /// FileSize - The size of this section in the object file. This is ~0 until
+  /// Offset - The offset of this fragment in its section. This is ~0 until
   /// initialized.
+  uint64_t Offset;
+
+  /// FileSize - The file size of this section. This is ~0 until initialized.
   uint64_t FileSize;
 
   /// @}
@@ -83,11 +82,11 @@
     FileSize = Value;
   }
 
-  uint64_t getFileOffset() const {
-    assert(FileOffset != ~UINT64_C(0) && "File offset not set!");
-    return FileOffset;
+  uint64_t getOffset() const {
+    assert(Offset != ~UINT64_C(0) && "File offset not set!");
+    return Offset;
   }
-  void setFileOffset(uint64_t Value) { FileOffset = Value; }
+  void setOffset(uint64_t Value) { Offset = Value; }
 
   /// @}
 

Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=79734&r1=79733&r2=79734&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Sat Aug 22 03:27:54 2009
@@ -202,7 +202,6 @@
 
 MCFragment::MCFragment(FragmentType _Kind, MCSectionData *SD)
   : Kind(_Kind),
-    FileOffset(~UINT64_C(0)),
     FileSize(~UINT64_C(0))
 {
   if (SD)
@@ -234,22 +233,20 @@
 }
 
 void MCAssembler::LayoutSection(MCSectionData &SD) {
-  uint64_t FileOffset = SD.getFileOffset();
-  uint64_t SectionOffset = 0;
+  uint64_t Offset = 0;
 
   for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
     MCFragment &F = *it;
 
-    F.setFileOffset(FileOffset);
+    F.setOffset(Offset);
 
     // Evaluate fragment size.
     switch (F.getKind()) {
     case MCFragment::FT_Align: {
       MCAlignFragment &AF = cast<MCAlignFragment>(F);
       
-      uint64_t AlignedOffset =
-        RoundUpToAlignment(SectionOffset, AF.getAlignment());
-      uint64_t PaddingBytes = AlignedOffset - SectionOffset;
+      uint64_t AlignedOffset = RoundUpToAlignment(Offset, AF.getAlignment());
+      uint64_t PaddingBytes = AlignedOffset - Offset;
 
       if (PaddingBytes > AF.getMaxBytesToEmit())
         AF.setFileSize(0);
@@ -271,21 +268,20 @@
       uint64_t OrgOffset = OF.getOffset().getConstant();
 
       // FIXME: We need a way to communicate this error.
-      if (OrgOffset < SectionOffset)
+      if (OrgOffset < Offset)
         llvm_report_error("invalid .org offset '" + Twine(OrgOffset) + 
-                          "' (section offset '" + Twine(SectionOffset) + "'");
+                          "' (section offset '" + Twine(Offset) + "'");
         
-      F.setFileSize(OrgOffset - SectionOffset);
+      F.setFileSize(OrgOffset - Offset);
       break;
     }      
     }
 
-    FileOffset += F.getFileSize();
-    SectionOffset += F.getFileSize();
+    Offset += F.getFileSize();
   }
 
   // FIXME: Pad section?
-  SD.setFileSize(FileOffset - SD.getFileOffset());
+  SD.setFileSize(Offset);
 }
 
 /// WriteFileData - Write the \arg F data to the output file.
@@ -294,8 +290,6 @@
   uint64_t Start = OS.tell();
   (void) Start;
     
-  assert(F.getFileOffset() == Start && "Invalid file offset!");
-
   // FIXME: Embed in fragments instead?
   switch (F.getKind()) {
   case MCFragment::FT_Align: {





More information about the llvm-commits mailing list