mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 21:32:39 +00:00
Some first rudimentary support for ARM EHABI: print exception table in "text mode".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127099 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6dd97471c4
commit
b5e16af9ea
@ -26,7 +26,7 @@ namespace llvm {
|
|||||||
/// MCAsmInfo - This class is intended to be used as a base class for asm
|
/// MCAsmInfo - This class is intended to be used as a base class for asm
|
||||||
/// properties and features specific to the target.
|
/// properties and features specific to the target.
|
||||||
namespace ExceptionHandling {
|
namespace ExceptionHandling {
|
||||||
enum ExceptionsType { None, DwarfTable, DwarfCFI, SjLj };
|
enum ExceptionsType { None, DwarfTable, DwarfCFI, SjLj, ARM };
|
||||||
}
|
}
|
||||||
|
|
||||||
class MCAsmInfo {
|
class MCAsmInfo {
|
||||||
@ -451,7 +451,8 @@ namespace llvm {
|
|||||||
bool isExceptionHandlingDwarf() const {
|
bool isExceptionHandlingDwarf() const {
|
||||||
return
|
return
|
||||||
(ExceptionsType == ExceptionHandling::DwarfTable ||
|
(ExceptionsType == ExceptionHandling::DwarfTable ||
|
||||||
ExceptionsType == ExceptionHandling::DwarfCFI);
|
ExceptionsType == ExceptionHandling::DwarfCFI ||
|
||||||
|
ExceptionsType == ExceptionHandling::ARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doesDwarfRequireFrameSection() const {
|
bool doesDwarfRequireFrameSection() const {
|
||||||
|
@ -457,6 +457,15 @@ namespace llvm {
|
|||||||
virtual void EmitRawText(StringRef String);
|
virtual void EmitRawText(StringRef String);
|
||||||
void EmitRawText(const Twine &String);
|
void EmitRawText(const Twine &String);
|
||||||
|
|
||||||
|
/// ARM-related methods.
|
||||||
|
/// FIXME: Eventually we should have some "target MC streamer" and move
|
||||||
|
/// these methods there.
|
||||||
|
virtual void EmitFnStart();
|
||||||
|
virtual void EmitFnEnd();
|
||||||
|
virtual void EmitCantUnwind();
|
||||||
|
virtual void EmitPersonality(const MCSymbol *Personality);
|
||||||
|
virtual void EmitHandlerData();
|
||||||
|
|
||||||
/// Finish - Finish emission of machine code.
|
/// Finish - Finish emission of machine code.
|
||||||
virtual void Finish() = 0;
|
virtual void Finish() = 0;
|
||||||
};
|
};
|
||||||
|
87
lib/CodeGen/AsmPrinter/ARMException.cpp
Normal file
87
lib/CodeGen/AsmPrinter/ARMException.cpp
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
//===-- CodeGen/AsmPrinter/ARMException.cpp - ARM EHABI Exception Impl ----===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file contains support for writing DWARF exception info into asm files.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "DwarfException.h"
|
||||||
|
#include "llvm/Module.h"
|
||||||
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
|
#include "llvm/CodeGen/MachineLocation.h"
|
||||||
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
|
#include "llvm/MC/MCContext.h"
|
||||||
|
#include "llvm/MC/MCExpr.h"
|
||||||
|
#include "llvm/MC/MCSection.h"
|
||||||
|
#include "llvm/MC/MCStreamer.h"
|
||||||
|
#include "llvm/MC/MCSymbol.h"
|
||||||
|
#include "llvm/Target/Mangler.h"
|
||||||
|
#include "llvm/Target/TargetData.h"
|
||||||
|
#include "llvm/Target/TargetFrameLowering.h"
|
||||||
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||||
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
#include "llvm/Target/TargetOptions.h"
|
||||||
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
|
#include "llvm/Support/Dwarf.h"
|
||||||
|
#include "llvm/Support/FormattedStream.h"
|
||||||
|
#include "llvm/ADT/SmallString.h"
|
||||||
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
#include "llvm/ADT/Twine.h"
|
||||||
|
using namespace llvm;
|
||||||
|
|
||||||
|
ARMException::ARMException(AsmPrinter *A)
|
||||||
|
: DwarfException(A),
|
||||||
|
shouldEmitTable(false), shouldEmitMoves(false), shouldEmitTableModule(false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
ARMException::~ARMException() {}
|
||||||
|
|
||||||
|
void ARMException::EndModule() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// BeginFunction - Gather pre-function exception information. Assumes it's
|
||||||
|
/// being emitted immediately after the function entry point.
|
||||||
|
void ARMException::BeginFunction(const MachineFunction *MF) {
|
||||||
|
Asm->OutStreamer.EmitFnStart();
|
||||||
|
if (!Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory)
|
||||||
|
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
|
||||||
|
Asm->getFunctionNumber()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// EndFunction - Gather and emit post-function exception information.
|
||||||
|
///
|
||||||
|
void ARMException::EndFunction() {
|
||||||
|
if (Asm->MF->getFunction()->doesNotThrow() && !UnwindTablesMandatory)
|
||||||
|
Asm->OutStreamer.EmitCantUnwind();
|
||||||
|
else {
|
||||||
|
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
|
||||||
|
Asm->getFunctionNumber()));
|
||||||
|
|
||||||
|
// Emit references to personality.
|
||||||
|
if (const Function * Personality =
|
||||||
|
MMI->getPersonalities()[MMI->getPersonalityIndex()]) {
|
||||||
|
MCSymbol *PerSym = Asm->Mang->getSymbol(Personality);
|
||||||
|
Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global);
|
||||||
|
Asm->OutStreamer.EmitPersonality(PerSym);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map all labels and get rid of any dead landing pads.
|
||||||
|
MMI->TidyLandingPads();
|
||||||
|
|
||||||
|
Asm->OutStreamer.EmitHandlerData();
|
||||||
|
|
||||||
|
// Emit actual exception table
|
||||||
|
EmitExceptionTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
Asm->OutStreamer.EmitFnEnd();
|
||||||
|
}
|
@ -196,6 +196,9 @@ bool AsmPrinter::doInitialization(Module &M) {
|
|||||||
case ExceptionHandling::DwarfCFI:
|
case ExceptionHandling::DwarfCFI:
|
||||||
DE = new DwarfCFIException(this);
|
DE = new DwarfCFIException(this);
|
||||||
break;
|
break;
|
||||||
|
case ExceptionHandling::ARM:
|
||||||
|
DE = new ARMException(this);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -237,6 +237,38 @@ public:
|
|||||||
virtual void EndFunction();
|
virtual void EndFunction();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ARMException : public DwarfException {
|
||||||
|
/// shouldEmitTable - Per-function flag to indicate if EH tables should
|
||||||
|
/// be emitted.
|
||||||
|
bool shouldEmitTable;
|
||||||
|
|
||||||
|
/// shouldEmitMoves - Per-function flag to indicate if frame moves info
|
||||||
|
/// should be emitted.
|
||||||
|
bool shouldEmitMoves;
|
||||||
|
|
||||||
|
/// shouldEmitTableModule - Per-module flag to indicate if EH tables
|
||||||
|
/// should be emitted.
|
||||||
|
bool shouldEmitTableModule;
|
||||||
|
public:
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// Main entry points.
|
||||||
|
//
|
||||||
|
ARMException(AsmPrinter *A);
|
||||||
|
virtual ~ARMException();
|
||||||
|
|
||||||
|
/// EndModule - Emit all exception information that should come after the
|
||||||
|
/// content.
|
||||||
|
virtual void EndModule();
|
||||||
|
|
||||||
|
/// BeginFunction - Gather pre-function exception information. Assumes being
|
||||||
|
/// emitted immediately after the function entry point.
|
||||||
|
virtual void BeginFunction(const MachineFunction *MF);
|
||||||
|
|
||||||
|
/// EndFunction - Gather and emit post-function exception information.
|
||||||
|
virtual void EndFunction();
|
||||||
|
};
|
||||||
|
|
||||||
} // End of namespace llvm
|
} // End of namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -292,6 +292,7 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,
|
|||||||
// FALLTHROUGH
|
// FALLTHROUGH
|
||||||
case ExceptionHandling::DwarfCFI:
|
case ExceptionHandling::DwarfCFI:
|
||||||
case ExceptionHandling::DwarfTable:
|
case ExceptionHandling::DwarfTable:
|
||||||
|
case ExceptionHandling::ARM:
|
||||||
PM.add(createDwarfEHPass(this));
|
PM.add(createDwarfEHPass(this));
|
||||||
break;
|
break;
|
||||||
case ExceptionHandling::None:
|
case ExceptionHandling::None:
|
||||||
|
@ -192,6 +192,12 @@ public:
|
|||||||
virtual bool EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
|
virtual bool EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding);
|
||||||
virtual bool EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
|
virtual bool EmitCFILsda(const MCSymbol *Sym, unsigned Encoding);
|
||||||
|
|
||||||
|
virtual void EmitFnStart();
|
||||||
|
virtual void EmitFnEnd();
|
||||||
|
virtual void EmitCantUnwind();
|
||||||
|
virtual void EmitPersonality(const MCSymbol *Personality);
|
||||||
|
virtual void EmitHandlerData();
|
||||||
|
|
||||||
virtual void EmitInstruction(const MCInst &Inst);
|
virtual void EmitInstruction(const MCInst &Inst);
|
||||||
|
|
||||||
/// EmitRawText - If this file is backed by an assembly streamer, this dumps
|
/// EmitRawText - If this file is backed by an assembly streamer, this dumps
|
||||||
@ -859,6 +865,31 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EmitFnStart() {
|
||||||
|
OS << "\t.fnstart";
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EmitFnEnd() {
|
||||||
|
OS << "\t.fnend";
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EmitCantUnwind() {
|
||||||
|
OS << "\t.cantunwind";
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EmitHandlerData() {
|
||||||
|
OS << "\t.handlerdata";
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCAsmStreamer::EmitPersonality(const MCSymbol *Personality) {
|
||||||
|
OS << "\t.personality " << Personality->getName();
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
|
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
|
||||||
assert(getCurrentSection() && "Cannot emit contents before setting section!");
|
assert(getCurrentSection() && "Cannot emit contents before setting section!");
|
||||||
|
|
||||||
|
@ -259,6 +259,31 @@ bool MCStreamer::EmitCFIRestoreState() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCStreamer::EmitFnStart() {
|
||||||
|
errs() << "Not implemented yet\n";
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCStreamer::EmitFnEnd() {
|
||||||
|
errs() << "Not implemented yet\n";
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCStreamer::EmitCantUnwind() {
|
||||||
|
errs() << "Not implemented yet\n";
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCStreamer::EmitHandlerData() {
|
||||||
|
errs() << "Not implemented yet\n";
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCStreamer::EmitPersonality(const MCSymbol *Personality) {
|
||||||
|
errs() << "Not implemented yet\n";
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
/// EmitRawText - If this file is backed by an assembly streamer, this dumps
|
/// EmitRawText - If this file is backed by an assembly streamer, this dumps
|
||||||
/// the specified string in the output .s file. This capability is
|
/// the specified string in the output .s file. This capability is
|
||||||
/// indicated by the hasRawTextSupport() predicate.
|
/// indicated by the hasRawTextSupport() predicate.
|
||||||
|
@ -12,8 +12,16 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "ARMMCAsmInfo.h"
|
#include "ARMMCAsmInfo.h"
|
||||||
|
#include "llvm/Support/CommandLine.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
EnableARMEHABI("arm-enable-ehabi", cl::Hidden,
|
||||||
|
cl::desc("Generate ARM EHABI tables"),
|
||||||
|
cl::init(false));
|
||||||
|
|
||||||
|
|
||||||
static const char *const arm_asm_table[] = {
|
static const char *const arm_asm_table[] = {
|
||||||
"{r0}", "r0",
|
"{r0}", "r0",
|
||||||
"{r1}", "r1",
|
"{r1}", "r1",
|
||||||
@ -65,4 +73,8 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
|
|||||||
DwarfRequiresFrameSection = false;
|
DwarfRequiresFrameSection = false;
|
||||||
|
|
||||||
SupportsDebugInformation = true;
|
SupportsDebugInformation = true;
|
||||||
|
|
||||||
|
// Exceptions handling
|
||||||
|
if (EnableARMEHABI)
|
||||||
|
ExceptionsType = ExceptionHandling::ARM;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ void ARMElfTargetObjectFile::Initialize(MCContext &Ctx,
|
|||||||
ELF::SHF_WRITE |
|
ELF::SHF_WRITE |
|
||||||
ELF::SHF_ALLOC,
|
ELF::SHF_ALLOC,
|
||||||
SectionKind::getDataRel());
|
SectionKind::getDataRel());
|
||||||
|
LSDASection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributesSection =
|
AttributesSection =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user