mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Introduce Target::createNullTargetStreamer and use it from IRObjectFile.
A null MCTargetStreamer allows IRObjectFile to ignore target-specific directives. Previously we were crashing. Differential Revision: http://reviews.llvm.org/D7711 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229797 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8915e014e0
commit
99a5e24d34
@ -47,6 +47,7 @@ namespace llvm {
|
|||||||
class MCRelocationInfo;
|
class MCRelocationInfo;
|
||||||
class MCTargetAsmParser;
|
class MCTargetAsmParser;
|
||||||
class MCTargetOptions;
|
class MCTargetOptions;
|
||||||
|
class MCTargetStreamer;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class TargetOptions;
|
class TargetOptions;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
@ -139,6 +140,7 @@ namespace llvm {
|
|||||||
MCAsmBackend *TAB,
|
MCAsmBackend *TAB,
|
||||||
bool ShowInst);
|
bool ShowInst);
|
||||||
typedef MCStreamer *(*NullStreamerCtorTy)(MCContext &Ctx);
|
typedef MCStreamer *(*NullStreamerCtorTy)(MCContext &Ctx);
|
||||||
|
typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
|
||||||
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
|
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
|
||||||
MCContext &Ctx);
|
MCContext &Ctx);
|
||||||
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
|
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
|
||||||
@ -227,6 +229,10 @@ namespace llvm {
|
|||||||
/// (default = llvm::createNullStreamer).
|
/// (default = llvm::createNullStreamer).
|
||||||
NullStreamerCtorTy NullStreamerCtorFn;
|
NullStreamerCtorTy NullStreamerCtorFn;
|
||||||
|
|
||||||
|
/// Construction function for this target's null TargetStreamer, if
|
||||||
|
/// registered (default = nullptr).
|
||||||
|
NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
|
||||||
|
|
||||||
/// MCRelocationInfoCtorFn - Construction function for this target's
|
/// MCRelocationInfoCtorFn - Construction function for this target's
|
||||||
/// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
|
/// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
|
||||||
MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
|
MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
|
||||||
@ -453,6 +459,12 @@ namespace llvm {
|
|||||||
return llvm::createNullStreamer(Ctx);
|
return llvm::createNullStreamer(Ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) const {
|
||||||
|
if (NullTargetStreamerCtorFn)
|
||||||
|
return NullTargetStreamerCtorFn(S);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/// createMCRelocationInfo - Create a target specific MCRelocationInfo.
|
/// createMCRelocationInfo - Create a target specific MCRelocationInfo.
|
||||||
///
|
///
|
||||||
/// \param TT The target triple.
|
/// \param TT The target triple.
|
||||||
@ -783,6 +795,11 @@ namespace llvm {
|
|||||||
T.NullStreamerCtorFn = Fn;
|
T.NullStreamerCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn) {
|
||||||
|
T.NullTargetStreamerCtorFn = Fn;
|
||||||
|
}
|
||||||
|
|
||||||
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
||||||
/// implementation for the given target.
|
/// implementation for the given target.
|
||||||
///
|
///
|
||||||
|
@ -73,6 +73,7 @@ IRObjectFile::IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> Mod)
|
|||||||
MCContext MCCtx(MAI.get(), MRI.get(), &MOFI);
|
MCContext MCCtx(MAI.get(), MRI.get(), &MOFI);
|
||||||
MOFI.InitMCObjectFileInfo(Triple, Reloc::Default, CodeModel::Default, MCCtx);
|
MOFI.InitMCObjectFileInfo(Triple, Reloc::Default, CodeModel::Default, MCCtx);
|
||||||
std::unique_ptr<RecordStreamer> Streamer(new RecordStreamer(MCCtx));
|
std::unique_ptr<RecordStreamer> Streamer(new RecordStreamer(MCCtx));
|
||||||
|
T->createNullTargetStreamer(*Streamer);
|
||||||
|
|
||||||
std::unique_ptr<MemoryBuffer> Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
|
std::unique_ptr<MemoryBuffer> Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
|
||||||
SourceMgr SrcMgr;
|
SourceMgr SrcMgr;
|
||||||
|
@ -1360,6 +1360,10 @@ MCStreamer *createARMNullStreamer(MCContext &Ctx) {
|
|||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S) {
|
||||||
|
return new ARMTargetStreamer(S);
|
||||||
|
}
|
||||||
|
|
||||||
MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
||||||
raw_ostream &OS, MCCodeEmitter *Emitter,
|
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||||
bool RelaxAll, bool IsThumb) {
|
bool RelaxAll, bool IsThumb) {
|
||||||
|
@ -461,6 +461,16 @@ extern "C" void LLVMInitializeARMTargetMC() {
|
|||||||
TargetRegistry::RegisterNullStreamer(TheThumbLETarget, createARMNullStreamer);
|
TargetRegistry::RegisterNullStreamer(TheThumbLETarget, createARMNullStreamer);
|
||||||
TargetRegistry::RegisterNullStreamer(TheThumbBETarget, createARMNullStreamer);
|
TargetRegistry::RegisterNullStreamer(TheThumbBETarget, createARMNullStreamer);
|
||||||
|
|
||||||
|
// Register the null TargetStreamer.
|
||||||
|
TargetRegistry::RegisterNullTargetStreamer(TheARMLETarget,
|
||||||
|
createARMNullTargetStreamer);
|
||||||
|
TargetRegistry::RegisterNullTargetStreamer(TheARMBETarget,
|
||||||
|
createARMNullTargetStreamer);
|
||||||
|
TargetRegistry::RegisterNullTargetStreamer(TheThumbLETarget,
|
||||||
|
createARMNullTargetStreamer);
|
||||||
|
TargetRegistry::RegisterNullTargetStreamer(TheThumbBETarget,
|
||||||
|
createARMNullTargetStreamer);
|
||||||
|
|
||||||
// Register the MCInstPrinter.
|
// Register the MCInstPrinter.
|
||||||
TargetRegistry::RegisterMCInstPrinter(TheARMLETarget, createARMMCInstPrinter);
|
TargetRegistry::RegisterMCInstPrinter(TheARMLETarget, createARMMCInstPrinter);
|
||||||
TargetRegistry::RegisterMCInstPrinter(TheARMBETarget, createARMMCInstPrinter);
|
TargetRegistry::RegisterMCInstPrinter(TheARMBETarget, createARMMCInstPrinter);
|
||||||
|
@ -29,6 +29,7 @@ class MCRegisterInfo;
|
|||||||
class MCSubtargetInfo;
|
class MCSubtargetInfo;
|
||||||
class MCStreamer;
|
class MCStreamer;
|
||||||
class MCRelocationInfo;
|
class MCRelocationInfo;
|
||||||
|
class MCTargetStreamer;
|
||||||
class StringRef;
|
class StringRef;
|
||||||
class Target;
|
class Target;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
@ -53,6 +54,8 @@ MCStreamer *createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
|||||||
|
|
||||||
MCStreamer *createARMNullStreamer(MCContext &Ctx);
|
MCStreamer *createARMNullStreamer(MCContext &Ctx);
|
||||||
|
|
||||||
|
MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S);
|
||||||
|
|
||||||
MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
|
MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
|
||||||
const MCRegisterInfo &MRI,
|
const MCRegisterInfo &MRI,
|
||||||
const MCSubtargetInfo &STI,
|
const MCSubtargetInfo &STI,
|
||||||
|
9
test/LTO/ARM/inline-asm.ll
Normal file
9
test/LTO/ARM/inline-asm.ll
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
; Check that we don't crash on target-specific inline asm directives.
|
||||||
|
;
|
||||||
|
; RUN: llvm-as < %s > %t
|
||||||
|
; RUN: llvm-lto -o /dev/null %t -mcpu armv4t
|
||||||
|
|
||||||
|
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||||
|
target triple = "armv4t-unknown-linux"
|
||||||
|
|
||||||
|
module asm ".fnstart"
|
Loading…
Reference in New Issue
Block a user