mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
AArch64/ARM64: port across stub handling for ELF C++ exceptions.
The most important part here is that we should actuall emit the stubs we refer to in the exception table, but as a side issue this uses more sensible & GCC compatible representations for some of the bits of information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206380 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fef8e383eb
commit
1a44333f0e
@ -289,8 +289,9 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
|
|||||||
TTypeEncoding = (CMModel == CodeModel::Small)
|
TTypeEncoding = (CMModel == CodeModel::Small)
|
||||||
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
|
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
|
||||||
}
|
}
|
||||||
} else if (T.getArch() == Triple::aarch64 ||
|
} else if (T.getArch() == Triple::aarch64 ||
|
||||||
T.getArch() == Triple::aarch64_be ) {
|
T.getArch() == Triple::aarch64_be ||
|
||||||
|
T.getArch() == Triple::arm64) {
|
||||||
// The small model guarantees static code/data size < 4GB, but not where it
|
// The small model guarantees static code/data size < 4GB, but not where it
|
||||||
// will be in memory. Most of these could end up >2GB away so even a signed
|
// will be in memory. Most of these could end up >2GB away so even a signed
|
||||||
// pc-relative 32-bit address is insufficient, theoretically.
|
// pc-relative 32-bit address is insufficient, theoretically.
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "ARM64MachineFunctionInfo.h"
|
#include "ARM64MachineFunctionInfo.h"
|
||||||
#include "ARM64MCInstLower.h"
|
#include "ARM64MCInstLower.h"
|
||||||
#include "ARM64RegisterInfo.h"
|
#include "ARM64RegisterInfo.h"
|
||||||
|
#include "ARM64Subtarget.h"
|
||||||
#include "InstPrinter/ARM64InstPrinter.h"
|
#include "InstPrinter/ARM64InstPrinter.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/StringSwitch.h"
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
@ -24,6 +25,8 @@
|
|||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/CodeGen/StackMaps.h"
|
#include "llvm/CodeGen/StackMaps.h"
|
||||||
|
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
|
||||||
|
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
@ -39,13 +42,18 @@ using namespace llvm;
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class ARM64AsmPrinter : public AsmPrinter {
|
class ARM64AsmPrinter : public AsmPrinter {
|
||||||
|
/// Subtarget - Keep a pointer to the ARM64Subtarget around so that we can
|
||||||
|
/// make the right decision when printing asm code for different targets.
|
||||||
|
const ARM64Subtarget *Subtarget;
|
||||||
|
|
||||||
ARM64MCInstLower MCInstLowering;
|
ARM64MCInstLower MCInstLowering;
|
||||||
StackMaps SM;
|
StackMaps SM;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ARM64AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
ARM64AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
|
||||||
: AsmPrinter(TM, Streamer), MCInstLowering(OutContext, *Mang, *this),
|
: AsmPrinter(TM, Streamer), Subtarget(&TM.getSubtarget<ARM64Subtarget>()),
|
||||||
SM(*this), ARM64FI(NULL), LOHLabelCounter(0) {}
|
MCInstLowering(OutContext, *Mang, *this), SM(*this), ARM64FI(NULL),
|
||||||
|
LOHLabelCounter(0) {}
|
||||||
|
|
||||||
virtual const char *getPassName() const { return "ARM64 Assembly Printer"; }
|
virtual const char *getPassName() const { return "ARM64 Assembly Printer"; }
|
||||||
|
|
||||||
@ -119,6 +127,29 @@ void ARM64AsmPrinter::EmitEndOfAsmFile(Module &M) {
|
|||||||
// generates code that does this, it is always safe to set.
|
// generates code that does this, it is always safe to set.
|
||||||
OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
|
OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
|
||||||
SM.serializeToStackMapSection();
|
SM.serializeToStackMapSection();
|
||||||
|
|
||||||
|
// Emit a .data.rel section containing any stubs that were created.
|
||||||
|
if (Subtarget->isTargetELF()) {
|
||||||
|
const TargetLoweringObjectFileELF &TLOFELF =
|
||||||
|
static_cast<const TargetLoweringObjectFileELF &>(getObjFileLowering());
|
||||||
|
|
||||||
|
MachineModuleInfoELF &MMIELF = MMI->getObjFileInfo<MachineModuleInfoELF>();
|
||||||
|
|
||||||
|
// Output stubs for external and common global variables.
|
||||||
|
MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
|
||||||
|
if (!Stubs.empty()) {
|
||||||
|
OutStreamer.SwitchSection(TLOFELF.getDataRelSection());
|
||||||
|
const DataLayout *TD = TM.getDataLayout();
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
|
||||||
|
OutStreamer.EmitLabel(Stubs[i].first);
|
||||||
|
OutStreamer.EmitSymbolValue(Stubs[i].second.getPointer(),
|
||||||
|
TD->getPointerSize(0));
|
||||||
|
}
|
||||||
|
Stubs.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineLocation
|
MachineLocation
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s
|
; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s
|
||||||
; RUN: llc -mtriple=aarch64_be-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s
|
; RUN: llc -mtriple=aarch64_be-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s
|
||||||
|
; RUN: llc -mtriple=arm64-none-linux-gnu -relocation-model=pic -o - %s | FileCheck %s
|
||||||
|
|
||||||
; Make sure exception-handling PIC code can be linked correctly. An alternative
|
; Make sure exception-handling PIC code can be linked correctly. An alternative
|
||||||
; to the sequence described below would have .gcc_except_table itself writable
|
; to the sequence described below would have .gcc_except_table itself writable
|
||||||
@ -11,8 +12,8 @@
|
|||||||
; ... referring indirectly to stubs for its typeinfo ...
|
; ... referring indirectly to stubs for its typeinfo ...
|
||||||
; CHECK: // @TType Encoding = indirect pcrel sdata8
|
; CHECK: // @TType Encoding = indirect pcrel sdata8
|
||||||
; ... one of which is "int"'s typeinfo
|
; ... one of which is "int"'s typeinfo
|
||||||
; CHECK: .Ltmp7:
|
; CHECK: [[TYPEINFO_LBL:.Ltmp[0-9]+]]: // TypeInfo 1
|
||||||
; CHECK-NEXT: .xword .L_ZTIi.DW.stub-.Ltmp7
|
; CHECK-NEXT: .xword .L_ZTIi.DW.stub-[[TYPEINFO_LBL]]
|
||||||
|
|
||||||
; .. and which is properly defined (in a writable section for the dynamic loader) later.
|
; .. and which is properly defined (in a writable section for the dynamic loader) later.
|
||||||
; CHECK: .section .data.rel,"aw"
|
; CHECK: .section .data.rel,"aw"
|
||||||
|
Loading…
Reference in New Issue
Block a user