llvm.org GIT mirror llvm / 99a5e24
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 Peter Collingbourne 5 years ago
6 changed file(s) with 44 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
4646 class MCRelocationInfo;
4747 class MCTargetAsmParser;
4848 class MCTargetOptions;
49 class MCTargetStreamer;
4950 class TargetMachine;
5051 class TargetOptions;
5152 class raw_ostream;
138139 MCAsmBackend *TAB,
139140 bool ShowInst);
140141 typedef MCStreamer *(*NullStreamerCtorTy)(MCContext &Ctx);
142 typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
141143 typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
142144 MCContext &Ctx);
143145 typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
225227 /// Construction function for this target's NullStreamer, if registered
226228 /// (default = llvm::createNullStreamer).
227229 NullStreamerCtorTy NullStreamerCtorFn;
230
231 /// Construction function for this target's null TargetStreamer, if
232 /// registered (default = nullptr).
233 NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
228234
229235 /// MCRelocationInfoCtorFn - Construction function for this target's
230236 /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
450456 if (NullStreamerCtorFn)
451457 return NullStreamerCtorFn(Ctx);
452458 return llvm::createNullStreamer(Ctx);
459 }
460
461 MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) const {
462 if (NullTargetStreamerCtorFn)
463 return NullTargetStreamerCtorFn(S);
464 return nullptr;
453465 }
454466
455467 /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
782794 T.NullStreamerCtorFn = Fn;
783795 }
784796
797 static void
798 RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn) {
799 T.NullTargetStreamerCtorFn = Fn;
800 }
801
785802 /// RegisterMCRelocationInfo - Register an MCRelocationInfo
786803 /// implementation for the given target.
787804 ///
7272 MCContext MCCtx(MAI.get(), MRI.get(), &MOFI);
7373 MOFI.InitMCObjectFileInfo(Triple, Reloc::Default, CodeModel::Default, MCCtx);
7474 std::unique_ptr Streamer(new RecordStreamer(MCCtx));
75 T->createNullTargetStreamer(*Streamer);
7576
7677 std::unique_ptr Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
7778 SourceMgr SrcMgr;
13591359 return S;
13601360 }
13611361
1362 MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S) {
1363 return new ARMTargetStreamer(S);
1364 }
1365
13621366 MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
13631367 raw_ostream &OS, MCCodeEmitter *Emitter,
13641368 bool RelaxAll, bool IsThumb) {
460460 TargetRegistry::RegisterNullStreamer(TheThumbLETarget, createARMNullStreamer);
461461 TargetRegistry::RegisterNullStreamer(TheThumbBETarget, createARMNullStreamer);
462462
463 // Register the null TargetStreamer.
464 TargetRegistry::RegisterNullTargetStreamer(TheARMLETarget,
465 createARMNullTargetStreamer);
466 TargetRegistry::RegisterNullTargetStreamer(TheARMBETarget,
467 createARMNullTargetStreamer);
468 TargetRegistry::RegisterNullTargetStreamer(TheThumbLETarget,
469 createARMNullTargetStreamer);
470 TargetRegistry::RegisterNullTargetStreamer(TheThumbBETarget,
471 createARMNullTargetStreamer);
472
463473 // Register the MCInstPrinter.
464474 TargetRegistry::RegisterMCInstPrinter(TheARMLETarget, createARMMCInstPrinter);
465475 TargetRegistry::RegisterMCInstPrinter(TheARMBETarget, createARMMCInstPrinter);
2828 class MCSubtargetInfo;
2929 class MCStreamer;
3030 class MCRelocationInfo;
31 class MCTargetStreamer;
3132 class StringRef;
3233 class Target;
3334 class raw_ostream;
5152 MCAsmBackend *TAB, bool ShowInst);
5253
5354 MCStreamer *createARMNullStreamer(MCContext &Ctx);
55
56 MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S);
5457
5558 MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
5659 const MCRegisterInfo &MRI,
0 ; Check that we don't crash on target-specific inline asm directives.
1 ;
2 ; RUN: llvm-as < %s > %t
3 ; RUN: llvm-lto -o /dev/null %t -mcpu armv4t
4
5 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
6 target triple = "armv4t-unknown-linux"
7
8 module asm ".fnstart"