Skip to content

Commit

Permalink
[PowerPC] XCOFF exception section support on the integrated assembler…
Browse files Browse the repository at this point in the history
… path

Continuation of https://reviews.llvm.org/D132146 (direct assembly path support, needs to merge first). Adds support to the integrated assembler path for emitting XCOFF exception sections. Both features need https://reviews.llvm.org/D133030 to merge first

Reviewed By: shchenz, DiggerLin

Differential Revision: https://reviews.llvm.org/D134195
  • Loading branch information
pscoro authored and chenzheng1030 committed Nov 21, 2022
1 parent 6bca3ad commit 2234098
Show file tree
Hide file tree
Showing 12 changed files with 612 additions and 26 deletions.
2 changes: 2 additions & 0 deletions llvm/include/llvm/BinaryFormat/XCOFF.h
Expand Up @@ -37,6 +37,8 @@ constexpr size_t SectionHeaderSize64 = 72;
constexpr size_t SymbolTableEntrySize = 18;
constexpr size_t RelocationSerializationSize32 = 10;
constexpr size_t RelocationSerializationSize64 = 14;
constexpr size_t ExceptionSectionEntrySize32 = 6;
constexpr size_t ExceptionSectionEntrySize64 = 10;
constexpr uint16_t RelocOverflow = 65535;
constexpr uint8_t AllocRegNo = 31;

Expand Down
5 changes: 5 additions & 0 deletions llvm/include/llvm/MC/MCObjectWriter.h
Expand Up @@ -105,6 +105,11 @@ 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");
}
/// Write the object file and returns the number of bytes written.
///
/// This routine is called by the assembler after layout and relaxation is
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/MC/MCStreamer.h
Expand Up @@ -634,7 +634,8 @@ class MCStreamer {
/// \param Symbol - The function containing the trap.
/// \param Lang - The language code for the exception entry.
/// \param Reason - The reason code for the exception entry.
virtual void emitXCOFFExceptDirective(const MCSymbol *Symbol, MCSymbol *Trap,
virtual void emitXCOFFExceptDirective(const MCSymbol *Symbol,
const MCSymbol *Trap,
unsigned Lang, unsigned Reason,
unsigned FunctionSize, bool hasDebug);

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/MC/MCXCOFFStreamer.h
Expand Up @@ -41,7 +41,7 @@ class MCXCOFFStreamer : public MCObjectStreamer {
report_fatal_error("emitXCOFFRenameDirective is not implemented yet on "
"object generation path");
}
void emitXCOFFExceptDirective(const MCSymbol *Symbol, MCSymbol *Trap,
void emitXCOFFExceptDirective(const MCSymbol *Symbol, const MCSymbol *Trap,
unsigned Lang, unsigned Reason,
unsigned FunctionSize, bool hasDebug) override;
};
Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/MC/MCAsmStreamer.cpp
Expand Up @@ -197,7 +197,8 @@ class MCAsmStreamer final : public MCStreamer {

void emitXCOFFRefDirective(StringRef Name) override;

void emitXCOFFExceptDirective(const MCSymbol *Symbol, MCSymbol *Trap,
void emitXCOFFExceptDirective(const MCSymbol *Symbol,
const MCSymbol *Trap,
unsigned Lang, unsigned Reason,
unsigned FunctionSize, bool hasDebug) override;

Expand Down Expand Up @@ -947,7 +948,8 @@ void MCAsmStreamer::emitXCOFFRefDirective(StringRef Name) {
}

void MCAsmStreamer::emitXCOFFExceptDirective(const MCSymbol *Symbol,
MCSymbol *Trap, unsigned Lang,
const MCSymbol *Trap,
unsigned Lang,
unsigned Reason,
unsigned FunctionSize,
bool hasDebug) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/MC/MCStreamer.cpp
Expand Up @@ -1192,8 +1192,8 @@ void MCStreamer::emitXCOFFRefDirective(StringRef Name) {
}

void MCStreamer::emitXCOFFExceptDirective(const MCSymbol *Symbol,
MCSymbol *Trap, unsigned Lang,
unsigned Reason,
const MCSymbol *Trap,
unsigned Lang, unsigned Reason,
unsigned FunctionSize,
bool hasDebug) {
report_fatal_error("emitXCOFFExceptDirective is only supported on "
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/MC/MCXCOFFStreamer.cpp
Expand Up @@ -82,13 +82,12 @@ void MCXCOFFStreamer::emitXCOFFSymbolLinkageWithVisibility(
}

void MCXCOFFStreamer::emitXCOFFExceptDirective(const MCSymbol *Symbol,
MCSymbol *Trap, unsigned Lang,
unsigned Reason,
const MCSymbol *Trap,
unsigned Lang, unsigned Reason,
unsigned FunctionSize,
bool hasDebug) {
report_fatal_error(
"emitXCOFFExceptDirective not yet supported for integrated "
"assembler path.");
getAssembler().getWriter().addExceptionEntry(Symbol, Trap, Lang, Reason,
FunctionSize, hasDebug);
}

void MCXCOFFStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Expand Down

0 comments on commit 2234098

Please sign in to comment.