MC: Use accessors for access to MCAsmFixup.
[oota-llvm.git] / include / llvm / MC / MCAssembler.h
index 8918dbbb3c3d02ea344b0447f3327aa30fec5e4d..c34042bd5221f1712fee8025b5a69fbcd1e2526a 100644 (file)
@@ -42,7 +42,6 @@ class TargetAsmBackend;
 //
 // FIXME: This should probably just be merged with MCFixup.
 class MCAsmFixup {
-public:
   /// Offset - The offset inside the fragment which needs to be rewritten.
   uint64_t Offset;
 
@@ -55,6 +54,13 @@ public:
 public:
   MCAsmFixup(uint64_t _Offset, const MCExpr &_Value, MCFixupKind _Kind)
     : Offset(_Offset), Value(&_Value), Kind(_Kind) {}
+
+  MCFixupKind getKind() const { return MCFixupKind(Kind); }
+
+  uint64_t getOffset() const { return Offset; }
+  void setOffset(uint64_t Value) { Offset = Value; }
+
+  const MCExpr *getValue() const { return Value; }
 };
 
 class MCFragment : public ilist_node<MCFragment> {
@@ -96,9 +102,9 @@ private:
   /// 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;
 
   /// @}
 
@@ -108,7 +114,6 @@ protected:
 public:
   // Only for sentinel.
   MCFragment();
-  virtual ~MCFragment();
 
   FragmentType getKind() const { return Kind; }
 
@@ -118,12 +123,12 @@ public:
   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; }
 
-  virtual void dump();
+  void dump();
 };
 
 class MCDataFragment : public MCFragment {
@@ -151,7 +156,7 @@ public:
 
   void addFixup(MCAsmFixup Fixup) {
     // Enforce invariant that fixups are in offset order.
-    assert((Fixups.empty() || Fixup.Offset > Fixups.back().Offset) &&
+    assert((Fixups.empty() || Fixup.getOffset() > Fixups.back().getOffset()) &&
            "Fixups must be added in order!");
     Fixups.push_back(Fixup);
   }
@@ -173,8 +178,6 @@ public:
     return F->getKind() == MCFragment::FT_Data;
   }
   static bool classof(const MCDataFragment *) { return true; }
-
-  virtual void dump();
 };
 
 // FIXME: This current incarnation of MCInstFragment doesn't make much sense, as
@@ -235,8 +238,6 @@ public:
     return F->getKind() == MCFragment::FT_Inst;
   }
   static bool classof(const MCInstFragment *) { return true; }
-
-  virtual void dump();
 };
 
 class MCAlignFragment : public MCFragment {
@@ -295,8 +296,6 @@ public:
     return F->getKind() == MCFragment::FT_Align;
   }
   static bool classof(const MCAlignFragment *) { return true; }
-
-  virtual void dump();
 };
 
 class MCFillFragment : public MCFragment {
@@ -334,8 +333,6 @@ public:
     return F->getKind() == MCFragment::FT_Fill;
   }
   static bool classof(const MCFillFragment *) { return true; }
-
-  virtual void dump();
 };
 
 class MCOrgFragment : public MCFragment {
@@ -363,8 +360,6 @@ public:
     return F->getKind() == MCFragment::FT_Org;
   }
   static bool classof(const MCOrgFragment *) { return true; }
-
-  virtual void dump();
 };
 
 // FIXME: Should this be a separate class, or just merged into MCSection? Since
@@ -392,6 +387,9 @@ private:
   /// Ordinal - The section index in the assemblers section list.
   unsigned Ordinal;
 
+  /// LayoutOrder - The index of this section in the layout order.
+  unsigned LayoutOrder;
+
   /// Alignment - The maximum alignment seen in this section.
   unsigned Alignment;
 
@@ -404,17 +402,6 @@ private:
   /// initialized.
   uint64_t Address;
 
-  /// Size - The logical size of this section. This is ~0 until initialized.
-  uint64_t Size;
-
-  /// AddressSize - The address space size used by this section. This is ~0
-  /// until initialized.
-  uint64_t AddressSize;
-
-  /// FileSize - The size of this section in the object file. This is ~0 until
-  /// initialized.
-  uint64_t FileSize;
-
   /// HasInstructions - Whether this section has had instructions emitted into
   /// it.
   unsigned HasInstructions : 1;
@@ -437,6 +424,9 @@ public:
   unsigned getOrdinal() const { return Ordinal; }
   void setOrdinal(unsigned Value) { Ordinal = Value; }
 
+  unsigned getLayoutOrder() const { return LayoutOrder; }
+  void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
+
   /// @name Fragment Access
   /// @{
 
@@ -655,15 +645,11 @@ private:
   bool FragmentNeedsRelaxation(const MCInstFragment *IF,
                                const MCAsmLayout &Layout) const;
 
-  /// LayoutFragment - Performs layout of the given \arg Fragment; assuming that
-  /// the previous fragment has already been layed out correctly, and the parent
-  /// section has been initialized.
-  void LayoutFragment(MCAsmLayout &Layout, MCFragment &Fragment);
-
-  /// LayoutSection - Performs layout of the section referenced by the given
-  /// \arg SectionOrderIndex. The layout assumes that the previous section has
-  /// already been layed out correctly.
-  void LayoutSection(MCAsmLayout &Layout, unsigned SectionOrderIndex);
+  /// Compute the effective fragment size assuming it is layed out at the given
+  /// \arg SectionAddress and \arg FragmentOffset.
+  uint64_t ComputeFragmentSize(MCAsmLayout &Layout, const MCFragment &F,
+                               uint64_t SectionAddress,
+                               uint64_t FragmentOffset) const;
 
   /// LayoutOnce - Perform one layout iteration and return true if any offsets
   /// were adjusted.