]> granicus.if.org Git - llvm/commitdiff
MC: De-duplicate the object streamer implementations of EmitFileDirective into MCObje...
authorPeter Collingbourne <peter@pcc.me.uk>
Fri, 3 Mar 2017 21:22:06 +0000 (21:22 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Fri, 3 Mar 2017 21:22:06 +0000 (21:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296912 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCELFStreamer.h
include/llvm/MC/MCObjectStreamer.h
include/llvm/MC/MCWasmStreamer.h
include/llvm/MC/MCWinCOFFStreamer.h
lib/MC/ELFObjectWriter.cpp
lib/MC/MCELFStreamer.cpp
lib/MC/MCMachOStreamer.cpp
lib/MC/MCObjectStreamer.cpp
lib/MC/MCWasmStreamer.cpp
lib/MC/WinCOFFStreamer.cpp

index 6552b52712aeb470c92f3ae24c316bca60b61feb..ea9ade459e07ea80dcf160a925e8f9fec0998d6d 100644 (file)
@@ -62,8 +62,6 @@ public:
   void EmitValueImpl(const MCExpr *Value, unsigned Size,
                      SMLoc Loc = SMLoc()) override;
 
-  void EmitFileDirective(StringRef Filename) override;
-
   void EmitIdent(StringRef IdentString) override;
 
   void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
index 94e8f177fff7c9eace326ab5a49dc1505ec8380a..978a240952673f088340ad8db355ec3eb3a5a3d0 100644 (file)
@@ -152,6 +152,7 @@ public:
                 SMLoc Loc = SMLoc()) override;
   void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
                 SMLoc Loc = SMLoc()) override;
+  void EmitFileDirective(StringRef Filename) override;
 
   void FinishImpl() override;
 
index 64d4fbee4b0efa4039e8f70ae54d2baedccd5f08..bdd6f103cd445beee9677f94b45a0cbf9ad3b797 100644 (file)
@@ -62,8 +62,6 @@ public:
   void EmitValueImpl(const MCExpr *Value, unsigned Size,
                      SMLoc Loc = SMLoc()) override;
 
-  void EmitFileDirective(StringRef Filename) override;
-
   void EmitIdent(StringRef IdentString) override;
 
   void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override;
index d7e6271de5fc3e91e85b003ea39fdfbd81975c12..84e60b85be6a46b268d7868c58d437a99d7699b8 100644 (file)
@@ -60,7 +60,6 @@ public:
                     unsigned ByteAlignment) override;
   void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
                       unsigned ByteAlignment) override;
-  void EmitFileDirective(StringRef Filename) override;
   void EmitIdent(StringRef IdentString) override;
   void EmitWinEHHandlerData() override;
   void FinishImpl() override;
index e56c9cb991e3b43aceddb98f76d520e64162910f..b84ae5bad1c683b3f5681c4a557d110b8173f817 100644 (file)
@@ -902,6 +902,8 @@ void ELFObjectWriter::computeSymbolTable(
 
   StrTabBuilder.finalize();
 
+  // File symbols are emitted first and handled separately from normal symbols,
+  // i.e. a non-STT_FILE symbol with the same name may appear.
   for (const std::string &Name : FileNames)
     Writer.writeSymbol(StrTabBuilder.getOffset(Name),
                        ELF::STT_FILE | ELF::STB_LOCAL, 0, 0, ELF::STV_DEFAULT,
index 172440080ea3dace5afbf1b5209a7824a9bb395f..0c786b2d0e9e944cfcda9c2046c5acaca5529fb4 100644 (file)
@@ -348,13 +348,6 @@ void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment,
                                          ValueSize, MaxBytesToEmit);
 }
 
-// Add a symbol for the file name of this module. They start after the
-// null symbol and don't count as normal symbol, i.e. a non-STT_FILE symbol
-// with the same name may appear.
-void MCELFStreamer::EmitFileDirective(StringRef Filename) {
-  getAssembler().addFileName(Filename);
-}
-
 void MCELFStreamer::EmitIdent(StringRef IdentString) {
   MCSection *Comment = getAssembler().getContext().getELFSection(
       ".comment", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
index 3ed89c4cccd3c8fda7cd7a5f88af111b1dbd3789..2001e3e3aeaa912bd94919a7876a0ede9733e110 100644 (file)
@@ -99,13 +99,6 @@ public:
   void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
                       unsigned ByteAlignment = 0) override;
 
-  void EmitFileDirective(StringRef Filename) override {
-    // FIXME: Just ignore the .file; it isn't important enough to fail the
-    // entire assembly.
-
-    // report_fatal_error("unsupported directive: '.file'");
-  }
-
   void EmitIdent(StringRef IdentString) override {
     llvm_unreachable("macho doesn't support this directive");
   }
index 19269f880a418498c7313e5ee3ca28b7e5a50eab..2b89407547a47cd65b30128badc71e70298b2ac0 100644 (file)
@@ -572,6 +572,10 @@ void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
   MCStreamer::emitFill(IntNumValues, Size, Expr);
 }
 
+void MCObjectStreamer::EmitFileDirective(StringRef Filename) {
+  getAssembler().addFileName(Filename);
+}
+
 void MCObjectStreamer::FinishImpl() {
   // If we are generating dwarf for assembly source files dump out the sections.
   if (getContext().getGenDwarfForAssembly())
index 708050b399b2383ba70b80ff61dc7b25454b5cd9..59b62b8d37c30447d1a1bc731dd7b7790aaa8e9f 100644 (file)
@@ -142,13 +142,6 @@ void MCWasmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
                                          MaxBytesToEmit);
 }
 
-// Add a symbol for the file name of this module. They start after the
-// null symbol and don't count as normal symbol, i.e. a non-STT_FILE symbol
-// with the same name may appear.
-void MCWasmStreamer::EmitFileDirective(StringRef Filename) {
-  getAssembler().addFileName(Filename);
-}
-
 void MCWasmStreamer::EmitIdent(StringRef IdentString) {
   MCSection *Comment = getAssembler().getContext().getWasmSection(
       ".comment", 0, 0);
index 2e75b5f131d5c5d097e18dcaa6613b9d3c82b223..c26d87f36f83d6edaa4f89b8347edad923976a76 100644 (file)
@@ -278,10 +278,6 @@ void MCWinCOFFStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
   llvm_unreachable("not implemented");
 }
 
-void MCWinCOFFStreamer::EmitFileDirective(StringRef Filename) {
-  getAssembler().addFileName(Filename);
-}
-
 // TODO: Implement this if you want to emit .comment section in COFF obj files.
 void MCWinCOFFStreamer::EmitIdent(StringRef IdentString) {
   llvm_unreachable("not implemented");