MC: Clean up naming in MCObjectWriter. NFC.
[oota-llvm.git] / include / llvm / MC / MCMachObjectWriter.h
index 514700bce3599b05322d6acc2824e8d25666d015..712f81e8f61157b5920623d300ffabe3b13ef7a7 100644 (file)
 
 namespace llvm {
 
-class MCSectionData;
 class MachObjectWriter;
 
 class MCMachObjectTargetWriter {
   const unsigned Is64Bit : 1;
   const uint32_t CPUType;
   const uint32_t CPUSubtype;
-  // FIXME: Remove this, we should just always use it once we no longer care
-  // about Darwin 'as' compatibility.
-  const unsigned UseAggressiveSymbolFolding : 1;
   unsigned LocalDifference_RIT;
 
 protected:
   MCMachObjectTargetWriter(bool Is64Bit_, uint32_t CPUType_,
-                           uint32_t CPUSubtype_,
-                           bool UseAggressiveSymbolFolding_ = false);
+                           uint32_t CPUSubtype_);
 
   void setLocalDifferenceRelocationType(unsigned Type) {
     LocalDifference_RIT = Type;
@@ -45,18 +40,17 @@ protected:
 public:
   virtual ~MCMachObjectTargetWriter();
 
-  /// @name Lifetime Management
+  /// \name Lifetime Management
   /// @{
 
   virtual void reset() {};
 
   /// @}
 
-  /// @name Accessors
+  /// \name Accessors
   /// @{
 
   bool is64Bit() const { return Is64Bit; }
-  bool useAggressiveSymbolFolding() const { return UseAggressiveSymbolFolding; }
   uint32_t getCPUType() const { return CPUType; }
   uint32_t getCPUSubtype() const { return CPUSubtype; }
   unsigned getLocalDifferenceRelocationType() const {
@@ -65,10 +59,10 @@ public:
 
   /// @}
 
-  /// @name API
+  /// \name API
   /// @{
 
-  virtual void RecordRelocation(MachObjectWriter *Writer, MCAssembler &Asm,
+  virtual void recordRelocation(MachObjectWriter *Writer, MCAssembler &Asm,
                                 const MCAsmLayout &Layout,
                                 const MCFragment *Fragment,
                                 const MCFixup &Fixup, MCValue Target,
@@ -81,7 +75,7 @@ class MachObjectWriter : public MCObjectWriter {
   /// MachSymbolData - Helper struct for containing some precomputed information
   /// on symbols.
   struct MachSymbolData {
-    MCSymbolData *SymbolData;
+    const MCSymbol *Symbol;
     uint64_t StringIndex;
     uint8_t SectionIndex;
 
@@ -92,21 +86,21 @@ class MachObjectWriter : public MCObjectWriter {
   /// The target specific Mach-O writer instance.
   std::unique_ptr<MCMachObjectTargetWriter> TargetObjectWriter;
 
-  /// @name Relocation Data
+  /// \name Relocation Data
   /// @{
 
   struct RelAndSymbol {
-    const MCSymbolData *Sym;
+    const MCSymbol *Sym;
     MachO::any_relocation_info MRE;
-    RelAndSymbol(const MCSymbolData *Sym, const MachO::any_relocation_info &MRE)
+    RelAndSymbol(const MCSymbol *Sym, const MachO::any_relocation_info &MRE)
         : Sym(Sym), MRE(MRE) {}
   };
 
-  llvm::DenseMap<const MCSectionData *, std::vector<RelAndSymbol>> Relocations;
-  llvm::DenseMap<const MCSectionData*, unsigned> IndirectSymBase;
+  llvm::DenseMap<const MCSection *, std::vector<RelAndSymbol>> Relocations;
+  llvm::DenseMap<const MCSection *, unsigned> IndirectSymBase;
 
   /// @}
-  /// @name Symbol Table Data
+  /// \name Symbol Table Data
   /// @{
 
   StringTableBuilder StringTable;
@@ -119,18 +113,20 @@ class MachObjectWriter : public MCObjectWriter {
   MachSymbolData *findSymbolData(const MCSymbol &Sym);
 
 public:
-  MachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_ostream &OS,
+  MachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_pwrite_stream &OS,
                    bool IsLittleEndian)
       : MCObjectWriter(OS, IsLittleEndian), TargetObjectWriter(MOTW) {}
 
-  /// @name Lifetime management Methods
+  const MCSymbol &findAliasedSymbol(const MCSymbol &Sym) const;
+
+  /// \name Lifetime management Methods
   /// @{
 
   void reset() override;
 
   /// @}
 
-  /// @name Utility Methods
+  /// \name Utility Methods
   /// @{
 
   bool isFixupKindPCRel(const MCAssembler &Asm, unsigned Kind);
@@ -139,23 +135,21 @@ public:
 
   SectionAddrMap &getSectionAddressMap() { return SectionAddress; }
 
-  uint64_t getSectionAddress(const MCSectionData* SD) const {
-    return SectionAddress.lookup(SD);
+  uint64_t getSectionAddress(const MCSection *Sec) const {
+    return SectionAddress.lookup(Sec);
   }
-  uint64_t getSymbolAddress(const MCSymbolData* SD,
-                            const MCAsmLayout &Layout) const;
+  uint64_t getSymbolAddress(const MCSymbol &S, const MCAsmLayout &Layout) const;
 
   uint64_t getFragmentAddress(const MCFragment *Fragment,
                               const MCAsmLayout &Layout) const;
 
-  uint64_t getPaddingSize(const MCSectionData *SD,
-                          const MCAsmLayout &Layout) const;
+  uint64_t getPaddingSize(const MCSection *SD, const MCAsmLayout &Layout) const;
 
-  bool doesSymbolRequireExternRelocation(const MCSymbolData *SD);
+  bool doesSymbolRequireExternRelocation(const MCSymbol &S);
 
   /// @}
 
-  /// @name Target Writer Proxy Accessors
+  /// \name Target Writer Proxy Accessors
   /// @{
 
   bool is64Bit() const { return TargetObjectWriter->is64Bit(); }
@@ -179,7 +173,7 @@ public:
                                uint64_t SectionDataSize);
 
   void WriteSection(const MCAssembler &Asm, const MCAsmLayout &Layout,
-                    const MCSectionData &SD, uint64_t FileOffset,
+                    const MCSection &Sec, uint64_t FileOffset,
                     uint64_t RelocationsStart, unsigned NumRelocations);
 
   void WriteSymtabLoadCommand(uint32_t SymbolOffset, uint32_t NumSymbols,
@@ -221,10 +215,10 @@ public:
   // to a symbol it should be passed as \p RelSymbol so that it can be updated
   // afterwards. If the relocation doesn't refer to a symbol, nullptr should be
   // used.
-  void addRelocation(const MCSymbolData *RelSymbol, const MCSectionData *SD,
+  void addRelocation(const MCSymbol *RelSymbol, const MCSection *Sec,
                      MachO::any_relocation_info &MRE) {
     RelAndSymbol P(RelSymbol, MRE);
-    Relocations[SD].push_back(P);
+    Relocations[Sec].push_back(P);
   }
 
   void RecordScatteredRelocation(const MCAssembler &Asm,
@@ -240,7 +234,7 @@ public:
                             const MCFixup &Fixup, MCValue Target,
                             uint64_t &FixedValue);
 
-  void RecordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout,
+  void recordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout,
                         const MCFragment *Fragment, const MCFixup &Fixup,
                         MCValue Target, bool &IsPCRel,
                         uint64_t &FixedValue) override;
@@ -257,18 +251,15 @@ public:
   void computeSectionAddresses(const MCAssembler &Asm,
                                const MCAsmLayout &Layout);
 
-  void markAbsoluteVariableSymbols(MCAssembler &Asm,
-                                   const MCAsmLayout &Layout);
   void ExecutePostLayoutBinding(MCAssembler &Asm,
                                 const MCAsmLayout &Layout) override;
 
-  bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
-                                              const MCSymbolData &DataA,
-                                              const MCFragment &FB,
-                                              bool InSet,
+  bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
+                                              const MCSymbol &SymA,
+                                              const MCFragment &FB, bool InSet,
                                               bool IsPCRel) const override;
 
-  void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
+  void writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
 };
 
 
@@ -280,7 +271,8 @@ public:
 /// \param OS - The stream to write to.
 /// \returns The constructed object writer.
 MCObjectWriter *createMachObjectWriter(MCMachObjectTargetWriter *MOTW,
-                                       raw_ostream &OS, bool IsLittleEndian);
+                                       raw_pwrite_stream &OS,
+                                       bool IsLittleEndian);
 
 } // End llvm namespace