Add const. NFC.
[oota-llvm.git] / include / llvm / MC / MCMachObjectWriter.h
index ae3beb10c7b616b7e3d6be4f499acaefa8e15b7a..0c5aa8a180638d961a7b8521934f17641f4ce713 100644 (file)
 #define LLVM_MC_MCMACHOBJECTWRITER_H
 
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCObjectWriter.h"
+#include "llvm/MC/StringTableBuilder.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/MachO.h"
 #include <vector>
@@ -92,7 +92,7 @@ class MachObjectWriter : public MCObjectWriter {
   };
 
   /// The target specific Mach-O writer instance.
-  llvm::OwningPtr<MCMachObjectTargetWriter> TargetObjectWriter;
+  std::unique_ptr<MCMachObjectTargetWriter> TargetObjectWriter;
 
   /// @name Relocation Data
   /// @{
@@ -105,13 +105,15 @@ class MachObjectWriter : public MCObjectWriter {
   /// @name Symbol Table Data
   /// @{
 
-  SmallString<256> StringTable;
+  StringTableBuilder StringTable;
   std::vector<MachSymbolData> LocalSymbolData;
   std::vector<MachSymbolData> ExternalSymbolData;
   std::vector<MachSymbolData> UndefinedSymbolData;
 
   /// @}
 
+  MachSymbolData *findSymbolData(const MCSymbol &Sym);
+
 public:
   MachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_ostream &_OS,
                    bool _IsLittleEndian)
@@ -121,7 +123,7 @@ public:
   /// @name Lifetime management Methods
   /// @{
 
-  virtual void reset();
+  void reset() override;
 
   /// @}
 
@@ -154,9 +156,9 @@ public:
   /// @{
 
   bool is64Bit() const { return TargetObjectWriter->is64Bit(); }
-  bool isARM() const {
-    uint32_t CPUType = TargetObjectWriter->getCPUType() & ~MachO::CPU_ARCH_MASK;
-    return CPUType == MachO::CPU_TYPE_ARM;
+  bool isX86_64() const {
+    uint32_t CPUType = TargetObjectWriter->getCPUType();
+    return CPUType == MachO::CPU_TYPE_X86_64;
   }
 
   /// @}
@@ -211,20 +213,6 @@ public:
   //  - Input errors, where something cannot be correctly encoded. 'as' allows
   //    these through in many cases.
 
-  void addRelocation(const MCSectionData *SD,
-                     MachO::relocation_info &MRE) {
-    MachO::any_relocation_info AMRE;
-    memcpy(&AMRE, &MRE, sizeof(MRE));
-    Relocations[SD].push_back(AMRE);
-  }
-
-  void addRelocation(const MCSectionData *SD,
-                     MachO::scattered_relocation_info &SMRE) {
-    MachO::any_relocation_info MRE;
-    memcpy(&MRE, &SMRE, sizeof(MRE));
-    Relocations[SD].push_back(MRE);
-  }
-
   void addRelocation(const MCSectionData *SD,
                      MachO::any_relocation_info &MRE) {
     Relocations[SD].push_back(MRE);
@@ -245,14 +233,14 @@ public:
 
   void RecordRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout,
                         const MCFragment *Fragment, const MCFixup &Fixup,
-                        MCValue Target, uint64_t &FixedValue);
+                        MCValue Target, bool &IsPCRel,
+                        uint64_t &FixedValue) override;
 
   void BindIndirectSymbols(MCAssembler &Asm);
 
   /// ComputeSymbolTable - Compute the symbol table data
   ///
-  /// \param StringTable [out] - The string table data.
-  void ComputeSymbolTable(MCAssembler &Asm, SmallString<256> &StringTable,
+  void ComputeSymbolTable(MCAssembler &Asm,
                           std::vector<MachSymbolData> &LocalSymbolData,
                           std::vector<MachSymbolData> &ExternalSymbolData,
                           std::vector<MachSymbolData> &UndefinedSymbolData);
@@ -262,15 +250,16 @@ public:
 
   void markAbsoluteVariableSymbols(MCAssembler &Asm,
                                    const MCAsmLayout &Layout);
-  void ExecutePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout);
+  void ExecutePostLayoutBinding(MCAssembler &Asm,
+                                const MCAsmLayout &Layout) override;
 
-  virtual bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
-                                                      const MCSymbolData &DataA,
-                                                      const MCFragment &FB,
-                                                      bool InSet,
-                                                      bool IsPCRel) const;
+  bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
+                                              const MCSymbolData &DataA,
+                                              const MCFragment &FB,
+                                              bool InSet,
+                                              bool IsPCRel) const override;
 
-  void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout);
+  void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
 };