[llvm] 023c645 - MCObjectWriter: Remove XCOFF specific virtual functions
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 16:47:50 PDT 2024
Author: Fangrui Song
Date: 2024-07-22T16:47:45-07:00
New Revision: 023c6454971dc33e409ce9a1035b20bd0ff893f2
URL: https://github.com/llvm/llvm-project/commit/023c6454971dc33e409ce9a1035b20bd0ff893f2
DIFF: https://github.com/llvm/llvm-project/commit/023c6454971dc33e409ce9a1035b20bd0ff893f2.diff
LOG: MCObjectWriter: Remove XCOFF specific virtual functions
Add forwarders for now. XCOFFObjectWriter should eventually be exported
like Mach-O/COFF/ELF (commit 70c52b62c5669993e341664a63bfbe5245e32884).
Added:
Modified:
llvm/include/llvm/MC/MCObjectWriter.h
llvm/include/llvm/MC/MCXCOFFObjectWriter.h
llvm/lib/MC/MCXCOFFStreamer.cpp
llvm/lib/MC/XCOFFObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCObjectWriter.h b/llvm/include/llvm/MC/MCObjectWriter.h
index f207b823a3ef2..18a1acff558c6 100644
--- a/llvm/include/llvm/MC/MCObjectWriter.h
+++ b/llvm/include/llvm/MC/MCObjectWriter.h
@@ -94,14 +94,6 @@ class MCObjectWriter {
std::vector<const MCSymbol *> &getAddrsigSyms() { return AddrsigSyms; }
- virtual void addExceptionEntry(const MCSymbol *Symbol, const MCSymbol *Trap,
- unsigned LanguageCode, unsigned ReasonCode,
- unsigned FunctionSize, bool hasDebug) {
- report_fatal_error("addExceptionEntry is only supported on XCOFF targets");
- }
- virtual void addCInfoSymEntry(StringRef Name, StringRef Metadata) {
- report_fatal_error("addCInfoSymEntry is only supported on XCOFF targets");
- }
/// Write the object file and returns the number of bytes written.
///
/// This routine is called by the assembler after layout and relaxation is
diff --git a/llvm/include/llvm/MC/MCXCOFFObjectWriter.h b/llvm/include/llvm/MC/MCXCOFFObjectWriter.h
index faad2ceb26910..c0e32a70172d8 100644
--- a/llvm/include/llvm/MC/MCXCOFFObjectWriter.h
+++ b/llvm/include/llvm/MC/MCXCOFFObjectWriter.h
@@ -43,6 +43,15 @@ std::unique_ptr<MCObjectWriter>
createXCOFFObjectWriter(std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW,
raw_pwrite_stream &OS);
+namespace XCOFF {
+void addExceptionEntry(MCObjectWriter &Writer, const MCSymbol *Symbol,
+ const MCSymbol *Trap, unsigned LanguageCode,
+ unsigned ReasonCode, unsigned FunctionSize,
+ bool hasDebug);
+void addCInfoSymEntry(MCObjectWriter &Writer, StringRef Name,
+ StringRef Metadata);
+} // namespace XCOFF
+
} // end namespace llvm
#endif // LLVM_MC_MCXCOFFOBJECTWRITER_H
diff --git a/llvm/lib/MC/MCXCOFFStreamer.cpp b/llvm/lib/MC/MCXCOFFStreamer.cpp
index 9cd46e504b554..94aa1ebc8f9e1 100644
--- a/llvm/lib/MC/MCXCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCXCOFFStreamer.cpp
@@ -19,6 +19,7 @@
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSectionXCOFF.h"
#include "llvm/MC/MCSymbolXCOFF.h"
+#include "llvm/MC/MCXCOFFObjectWriter.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Casting.h"
@@ -108,12 +109,14 @@ void MCXCOFFStreamer::emitXCOFFExceptDirective(const MCSymbol *Symbol,
unsigned Lang, unsigned Reason,
unsigned FunctionSize,
bool hasDebug) {
- getAssembler().getWriter().addExceptionEntry(Symbol, Trap, Lang, Reason,
- FunctionSize, hasDebug);
+ // TODO: Export XCOFFObjectWriter to llvm/MC/MCXCOFFObjectWriter.h and access
+ // it from MCXCOFFStreamer.
+ XCOFF::addExceptionEntry(getAssembler().getWriter(), Symbol, Trap, Lang,
+ Reason, FunctionSize, hasDebug);
}
void MCXCOFFStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) {
- getAssembler().getWriter().addCInfoSymEntry(Name, Metadata);
+ XCOFF::addCInfoSymEntry(getAssembler().getWriter(), Name, Metadata);
}
void MCXCOFFStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index c6eb537d1d546..4c8a7dd0eceeb 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -422,16 +422,12 @@ class XCOFFObjectWriter : public MCObjectWriter {
void finalizeRelocationInfo(SectionEntry *Sec, uint64_t RelCount);
void calcOffsetToRelocations(SectionEntry *Sec, uint64_t &RawPointer);
- void addExceptionEntry(const MCSymbol *Symbol, const MCSymbol *Trap,
- unsigned LanguageCode, unsigned ReasonCode,
- unsigned FunctionSize, bool hasDebug) override;
bool hasExceptionSection() {
return !ExceptionSection.ExceptionTable.empty();
}
unsigned getExceptionSectionSize();
unsigned getExceptionOffset(const MCSymbol *Symbol);
- void addCInfoSymEntry(StringRef Name, StringRef Metadata) override;
size_t auxiliaryHeaderSize() const {
// 64-bit object files have no auxiliary header.
return HasVisibility && !is64Bit() ? XCOFF::AuxFileHeaderSizeShort : 0;
@@ -444,6 +440,11 @@ class XCOFFObjectWriter : public MCObjectWriter {
void writeWord(uint64_t Word) {
is64Bit() ? W.write<uint64_t>(Word) : W.write<uint32_t>(Word);
}
+
+ void addExceptionEntry(const MCSymbol *Symbol, const MCSymbol *Trap,
+ unsigned LanguageCode, unsigned ReasonCode,
+ unsigned FunctionSize, bool hasDebug);
+ void addCInfoSymEntry(StringRef Name, StringRef Metadata);
};
XCOFFObjectWriter::XCOFFObjectWriter(
@@ -1739,3 +1740,18 @@ llvm::createXCOFFObjectWriter(std::unique_ptr<MCXCOFFObjectTargetWriter> MOTW,
raw_pwrite_stream &OS) {
return std::make_unique<XCOFFObjectWriter>(std::move(MOTW), OS);
}
+
+// TODO: Export XCOFFObjectWriter to llvm/MC/MCXCOFFObjectWriter.h and remove
+// the forwarders.
+void XCOFF::addExceptionEntry(MCObjectWriter &Writer, const MCSymbol *Symbol,
+ const MCSymbol *Trap, unsigned LanguageCode,
+ unsigned ReasonCode, unsigned FunctionSize,
+ bool hasDebug) {
+ static_cast<XCOFFObjectWriter &>(Writer).addExceptionEntry(
+ Symbol, Trap, LanguageCode, ReasonCode, FunctionSize, hasDebug);
+}
+
+void XCOFF::addCInfoSymEntry(MCObjectWriter &Writer, StringRef Name,
+ StringRef Metadata) {
+ static_cast<XCOFFObjectWriter &>(Writer).addCInfoSymEntry(Name, Metadata);
+}
More information about the llvm-commits
mailing list