llvm.org GIT mirror llvm / aa75693
Construct the MCStreamer before constructing the MCTargetStreamer. This has a few advantages: * Only targets that use a MCTargetStreamer have to worry about it. * There is never a MCTargetStreamer without a MCStreamer, so we can use a reference. * A MCTargetStreamer can talk to the MCStreamer in its constructor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200129 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
26 changed file(s) with 138 addition(s) and 119 deletion(s). Raw diff Collapse all Expand all
2828
2929 class MCELFStreamer : public MCObjectStreamer {
3030 public:
31 MCELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
32 MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter)
33 : MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter),
34 SeenIdent(false) {}
31 MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
32 MCCodeEmitter *Emitter)
33 : MCObjectStreamer(Context, TAB, OS, Emitter),
34 SeenIdent(false) {}
3535
36 MCELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
37 MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter,
38 MCAssembler *Assembler)
39 : MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter, Assembler),
40 SeenIdent(false) {}
36 MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
37 MCCodeEmitter *Emitter, MCAssembler *Assembler)
38 : MCObjectStreamer(Context, TAB, OS, Emitter, Assembler),
39 SeenIdent(false) {}
4140
4241 virtual ~MCELFStreamer();
4342
3939 virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame);
4040
4141 protected:
42 MCObjectStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
43 MCAsmBackend &TAB, raw_ostream &_OS,
42 MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS,
4443 MCCodeEmitter *_Emitter);
45 MCObjectStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
46 MCAsmBackend &TAB, raw_ostream &_OS, MCCodeEmitter *_Emitter,
47 MCAssembler *_Assembler);
44 MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS,
45 MCCodeEmitter *_Emitter, MCAssembler *_Assembler);
4846 ~MCObjectStreamer();
4947
5048 public:
6666 /// be treated differently. Callers should always talk to a FooTargetStreamer.
6767 class MCTargetStreamer {
6868 protected:
69 MCStreamer *Streamer;
69 MCStreamer &Streamer;
7070
7171 public:
72 MCTargetStreamer(MCStreamer &S);
7273 virtual ~MCTargetStreamer();
73 void setStreamer(MCStreamer *S) { Streamer = S; }
7474
7575 // Allow a target to add behavior to the EmitLabel of MCStreamer.
7676 virtual void emitLabel(MCSymbol *Symbol);
8181 class ARMTargetStreamer : public MCTargetStreamer {
8282 virtual void anchor();
8383 public:
84 ARMTargetStreamer(MCStreamer &S);
85
8486 virtual void emitFnStart() = 0;
8587 virtual void emitFnEnd() = 0;
8688 virtual void emitCantUnwind() = 0;
146148 SmallVector, 4> SectionStack;
147149
148150 protected:
149 MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer);
151 MCStreamer(MCContext &Ctx);
150152
151153 const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A,
152154 const MCSymbol *B);
168170
169171 public:
170172 virtual ~MCStreamer();
173
174 void setTargetStreamer(MCTargetStreamer *TS) {
175 TargetStreamer.reset(TS);
176 }
171177
172178 /// State management
173179 ///
707713 ///
708714 /// \param ShowInst - Whether to show the MCInst representation inline with
709715 /// the assembly.
710 MCStreamer *createAsmStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer,
711 formatted_raw_ostream &OS, bool isVerboseAsm,
712 bool useLoc, bool useCFI, bool useDwarfDirectory,
716 MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
717 bool isVerboseAsm, bool useLoc, bool useCFI,
718 bool useDwarfDirectory,
713719 MCInstPrinter *InstPrint = 0,
714720 MCCodeEmitter *CE = 0, MCAsmBackend *TAB = 0,
715721 bool ShowInst = false);
732738
733739 /// createELFStreamer - Create a machine code streamer which will generate
734740 /// ELF format object files.
735 MCStreamer *createELFStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer,
736 MCAsmBackend &TAB, raw_ostream &OS,
737 MCCodeEmitter *CE, bool RelaxAll,
741 MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB,
742 raw_ostream &OS, MCCodeEmitter *CE, bool RelaxAll,
738743 bool NoExecStack);
739744
740745 /// createPureStreamer - Create a machine code streamer which will generate
4545 class MCRelocationInfo;
4646 class MCTargetAsmParser;
4747 class TargetMachine;
48 class MCTargetStreamer;
4948 class TargetOptions;
5049 class raw_ostream;
5150 class formatted_raw_ostream;
5251
5352 MCStreamer *createAsmStreamer(MCContext &Ctx,
54 MCTargetStreamer *TargetStreamer,
5553 formatted_raw_ostream &OS, bool isVerboseAsm,
5654 bool useLoc, bool useCFI,
5755 bool useDwarfDirectory,
442440 return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI,
443441 useDwarfDirectory, InstPrint, CE, TAB,
444442 ShowInst);
445 return llvm::createAsmStreamer(Ctx, 0, OS, isVerboseAsm, useLoc, useCFI,
443 return llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
446444 useDwarfDirectory, InstPrint, CE, TAB,
447445 ShowInst);
448446 }
622622 return Symbols.end();
623623 }
624624
625 RecordStreamer(MCContext &Context) : MCStreamer(Context, 0) {}
625 RecordStreamer(MCContext &Context) : MCStreamer(Context) {}
626626
627627 virtual void EmitInstruction(const MCInst &Inst) {
628628 // Scan for values.
6565 virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame);
6666
6767 public:
68 MCAsmStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
69 formatted_raw_ostream &os, bool isVerboseAsm, bool useLoc,
70 bool useCFI, bool useDwarfDirectory, MCInstPrinter *printer,
68 MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
69 bool isVerboseAsm, bool useLoc, bool useCFI,
70 bool useDwarfDirectory, MCInstPrinter *printer,
7171 MCCodeEmitter *emitter, MCAsmBackend *asmbackend, bool showInst)
72 : MCStreamer(Context, TargetStreamer), OS(os), MAI(Context.getAsmInfo()),
72 : MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
7373 InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend),
7474 CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
7575 ShowInst(showInst), UseLoc(useLoc), UseCFI(useCFI),
13801380 }
13811381
13821382 MCStreamer *llvm::createAsmStreamer(MCContext &Context,
1383 MCTargetStreamer *TargetStreamer,
13841383 formatted_raw_ostream &OS,
13851384 bool isVerboseAsm, bool useLoc, bool useCFI,
13861385 bool useDwarfDirectory, MCInstPrinter *IP,
13871386 MCCodeEmitter *CE, MCAsmBackend *MAB,
13881387 bool ShowInst) {
1389 return new MCAsmStreamer(Context, TargetStreamer, OS, isVerboseAsm, useLoc,
1388 return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc,
13901389 useCFI, useDwarfDirectory, IP, CE, MAB, ShowInst);
13911390 }
542542 this->MCObjectStreamer::FinishImpl();
543543 }
544544
545 MCStreamer *llvm::createELFStreamer(MCContext &Context,
546 MCTargetStreamer *Streamer,
547 MCAsmBackend &MAB, raw_ostream &OS,
548 MCCodeEmitter *CE, bool RelaxAll,
549 bool NoExecStack) {
550 MCELFStreamer *S = new MCELFStreamer(Context, Streamer, MAB, OS, CE);
545 MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
546 raw_ostream &OS, MCCodeEmitter *CE,
547 bool RelaxAll, bool NoExecStack) {
548 MCELFStreamer *S = new MCELFStreamer(Context, MAB, OS, CE);
551549 if (RelaxAll)
552550 S->getAssembler().setRelaxAll(true);
553551 if (NoExecStack)
3737 public:
3838 MCMachOStreamer(MCContext &Context, MCAsmBackend &MAB, raw_ostream &OS,
3939 MCCodeEmitter *Emitter)
40 : MCObjectStreamer(Context, 0, MAB, OS, Emitter) {}
40 : MCObjectStreamer(Context, MAB, OS, Emitter) {}
4141
4242 /// @name MCStreamer Interface
4343 /// @{
1818
1919 class MCNullStreamer : public MCStreamer {
2020 public:
21 MCNullStreamer(MCContext &Context) : MCStreamer(Context, 0) {}
21 MCNullStreamer(MCContext &Context) : MCStreamer(Context) {}
2222
2323 /// @name MCStreamer Interface
2424 /// @{
2121 #include "llvm/Support/ErrorHandling.h"
2222 using namespace llvm;
2323
24 MCObjectStreamer::MCObjectStreamer(MCContext &Context,
25 MCTargetStreamer *TargetStreamer,
26 MCAsmBackend &TAB, raw_ostream &OS,
27 MCCodeEmitter *Emitter_)
28 : MCStreamer(Context, TargetStreamer),
24 MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
25 raw_ostream &OS, MCCodeEmitter *Emitter_)
26 : MCStreamer(Context),
2927 Assembler(new MCAssembler(Context, TAB, *Emitter_,
3028 *TAB.createObjectWriter(OS), OS)),
3129 CurSectionData(0) {}
3230
33 MCObjectStreamer::MCObjectStreamer(MCContext &Context,
34 MCTargetStreamer *TargetStreamer,
35 MCAsmBackend &TAB, raw_ostream &OS,
36 MCCodeEmitter *Emitter_,
31 MCObjectStreamer::MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB,
32 raw_ostream &OS, MCCodeEmitter *Emitter_,
3733 MCAssembler *_Assembler)
38 : MCStreamer(Context, TargetStreamer), Assembler(_Assembler),
39 CurSectionData(0) {}
34 : MCStreamer(Context), Assembler(_Assembler), CurSectionData(0) {}
4035
4136 MCObjectStreamer::~MCObjectStreamer() {
4237 delete &Assembler->getBackend();
2828 public:
2929 MCPureStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
3030 MCCodeEmitter *Emitter)
31 : MCObjectStreamer(Context, 0, TAB, OS, Emitter) {}
31 : MCObjectStreamer(Context, TAB, OS, Emitter) {}
3232
3333 /// @name MCStreamer Interface
3434 /// @{
2424
2525 // Pin the vtables to this file.
2626 MCTargetStreamer::~MCTargetStreamer() {}
27
28 MCTargetStreamer::MCTargetStreamer(MCStreamer &S) : Streamer(S) {
29 S.setTargetStreamer(this);
30 }
31
2732 void MCTargetStreamer::emitLabel(MCSymbol *Symbol) {}
2833
29 MCStreamer::MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer)
30 : Context(Ctx), TargetStreamer(TargetStreamer), EmitEHFrame(true),
31 EmitDebugFrame(false), CurrentW64UnwindInfo(0), LastSymbol(0) {
34 MCStreamer::MCStreamer(MCContext &Ctx)
35 : Context(Ctx), EmitEHFrame(true), EmitDebugFrame(false),
36 CurrentW64UnwindInfo(0), LastSymbol(0) {
3237 SectionStack.push_back(std::pair());
33 if (TargetStreamer)
34 TargetStreamer->setStreamer(this);
3538 }
3639
3740 MCStreamer::~MCStreamer() {
9898
9999 WinCOFFStreamer::WinCOFFStreamer(MCContext &Context, MCAsmBackend &MAB,
100100 MCCodeEmitter &CE, raw_ostream &OS)
101 : MCObjectStreamer(Context, 0, MAB, OS, &CE), CurSymbol(NULL) {}
101 : MCObjectStreamer(Context, MAB, OS, &CE), CurSymbol(NULL) {}
102102
103103 void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size,
104104 unsigned ByteAlignment, bool External) {
5656 public:
5757 AArch64ELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
5858 MCCodeEmitter *Emitter)
59 : MCELFStreamer(Context, 0, TAB, OS, Emitter), MappingSymbolCounter(0),
59 : MCELFStreamer(Context, TAB, OS, Emitter), MappingSymbolCounter(0),
6060 LastEMS(EMS_None) {}
6161
6262 ~AArch64ELFStreamer() {}
104104 }
105105
106106 void ARMTargetStreamer::anchor() {}
107 ARMTargetStreamer::ARMTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
107108
108109 namespace {
109110
138139 virtual void finishAttributeSection();
139140
140141 public:
141 ARMTargetAsmStreamer(formatted_raw_ostream &OS, MCInstPrinter &InstPrinter,
142 bool VerboseAsm);
142 ARMTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS,
143 MCInstPrinter &InstPrinter, bool VerboseAsm);
143144 };
144145
145 ARMTargetAsmStreamer::ARMTargetAsmStreamer(formatted_raw_ostream &OS,
146 ARMTargetAsmStreamer::ARMTargetAsmStreamer(MCStreamer &S,
147 formatted_raw_ostream &OS,
146148 MCInstPrinter &InstPrinter,
147149 bool VerboseAsm)
148 : OS(OS), InstPrinter(InstPrinter), IsVerboseAsm(VerboseAsm) {}
150 : ARMTargetStreamer(S), OS(OS), InstPrinter(InstPrinter),
151 IsVerboseAsm(VerboseAsm) {}
149152 void ARMTargetAsmStreamer::emitFnStart() { OS << "\t.fnstart\n"; }
150153 void ARMTargetAsmStreamer::emitFnEnd() { OS << "\t.fnend\n"; }
151154 void ARMTargetAsmStreamer::emitCantUnwind() { OS << "\t.cantunwind\n"; }
396399 size_t calculateContentSize() const;
397400
398401 public:
399 ARMTargetELFStreamer()
400 : ARMTargetStreamer(), CurrentVendor("aeabi"), FPU(ARM::INVALID_FPU),
401 Arch(ARM::INVALID_ARCH), AttributeSection(0) {
402 }
402 ARMTargetELFStreamer(MCStreamer &S)
403 : ARMTargetStreamer(S), CurrentVendor("aeabi"), FPU(ARM::INVALID_FPU),
404 Arch(ARM::INVALID_ARCH), AttributeSection(0) {}
403405 };
404406
405407 /// Extend the generic ELFStreamer class so that it can emit mapping symbols at
418420 public:
419421 friend class ARMTargetELFStreamer;
420422
421 ARMELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer,
422 MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter,
423 bool IsThumb)
424 : MCELFStreamer(Context, TargetStreamer, TAB, OS, Emitter),
425 IsThumb(IsThumb), MappingSymbolCounter(0), LastEMS(EMS_None) {
423 ARMELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
424 MCCodeEmitter *Emitter, bool IsThumb)
425 : MCELFStreamer(Context, TAB, OS, Emitter), IsThumb(IsThumb),
426 MappingSymbolCounter(0), LastEMS(EMS_None) {
426427 Reset();
427428 }
428429
626627 } // end anonymous namespace
627628
628629 ARMELFStreamer &ARMTargetELFStreamer::getStreamer() {
629 ARMELFStreamer *S = static_cast(Streamer);
630 return *S;
630 return static_cast(Streamer);
631631 }
632632
633633 void ARMTargetELFStreamer::emitFnStart() { getStreamer().emitFnStart(); }
12361236 bool useDwarfDirectory,
12371237 MCInstPrinter *InstPrint, MCCodeEmitter *CE,
12381238 MCAsmBackend *TAB, bool ShowInst) {
1239 ARMTargetAsmStreamer *S = new ARMTargetAsmStreamer(OS, *InstPrint,
1240 isVerboseAsm);
1241
1242 return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI,
1243 useDwarfDirectory, InstPrint, CE, TAB,
1244 ShowInst);
1239 MCStreamer *S =
1240 llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
1241 useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
1242 new ARMTargetAsmStreamer(*S, OS, *InstPrint, isVerboseAsm);
1243 return S;
12451244 }
12461245
12471246 MCELFStreamer* createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
12481247 raw_ostream &OS, MCCodeEmitter *Emitter,
12491248 bool RelaxAll, bool NoExecStack,
12501249 bool IsThumb) {
1251 ARMTargetELFStreamer *TS = new ARMTargetELFStreamer();
1252 ARMELFStreamer *S =
1253 new ARMELFStreamer(Context, TS, TAB, OS, Emitter, IsThumb);
1250 ARMELFStreamer *S = new ARMELFStreamer(Context, TAB, OS, Emitter, IsThumb);
1251 new ARMTargetELFStreamer(*S);
12541252 // FIXME: This should eventually end up somewhere else where more
12551253 // intelligent flag decisions can be made. For now we are just maintaining
12561254 // the status quo for ARM and setting EF_ARM_EABI_VER5 as the default.
130130 MCContext &Context, MCAsmBackend &MAB,
131131 raw_ostream &OS, MCCodeEmitter *Emitter,
132132 bool RelaxAll, bool NoExecStack) {
133 MipsTargetELFStreamer *S = new MipsTargetELFStreamer();
134 return createELFStreamer(Context, S, MAB, OS, Emitter, RelaxAll, NoExecStack);
133 MCStreamer *S =
134 createELFStreamer(Context, MAB, OS, Emitter, RelaxAll, NoExecStack);
135 new MipsTargetELFStreamer(*S);
136 return S;
135137 }
136138
137139 static MCStreamer *
139141 bool isVerboseAsm, bool useLoc, bool useCFI,
140142 bool useDwarfDirectory, MCInstPrinter *InstPrint,
141143 MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) {
142 MipsTargetAsmStreamer *S = new MipsTargetAsmStreamer(OS);
143
144 return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI,
145 useDwarfDirectory, InstPrint, CE, TAB,
146 ShowInst);
144 MCStreamer *S =
145 llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
146 useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
147 new MipsTargetAsmStreamer(*S, OS);
148 return S;
147149 }
148150
149151 extern "C" void LLVMInitializeMipsTargetMC() {
2626 // Pin vtable to this file.
2727 void MipsTargetStreamer::anchor() {}
2828
29 MipsTargetAsmStreamer::MipsTargetAsmStreamer(formatted_raw_ostream &OS)
30 : OS(OS) {}
29 MipsTargetStreamer::MipsTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
30
31 MipsTargetAsmStreamer::MipsTargetAsmStreamer(MCStreamer &S,
32 formatted_raw_ostream &OS)
33 : MipsTargetStreamer(S), OS(OS) {}
3134
3235 void MipsTargetAsmStreamer::emitMipsHackELFFlags(unsigned Flags) {
3336 if (!PrintHackDirectives)
9295 }
9396
9497 // This part is for ELF object output.
95 MipsTargetELFStreamer::MipsTargetELFStreamer() : MicroMipsEnabled(false) {}
98 MipsTargetELFStreamer::MipsTargetELFStreamer(MCStreamer &S)
99 : MipsTargetStreamer(S), MicroMipsEnabled(false) {}
96100
97101 void MipsTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
98102 if (!isMicroMipsEnabled())
109113 }
110114
111115 MCELFStreamer &MipsTargetELFStreamer::getStreamer() {
112 return static_cast(*Streamer);
116 return static_cast(Streamer);
113117 }
114118
115119 void MipsTargetELFStreamer::emitMipsHackELFFlags(unsigned Flags) {
1717 virtual void anchor();
1818
1919 public:
20 MipsTargetStreamer(MCStreamer &S);
2021 virtual void emitMipsHackELFFlags(unsigned Flags) = 0;
2122 virtual void emitDirectiveSetMicroMips() = 0;
2223 virtual void emitDirectiveSetNoMicroMips() = 0;
4142 formatted_raw_ostream &OS;
4243
4344 public:
44 MipsTargetAsmStreamer(formatted_raw_ostream &OS);
45 MipsTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
4546 virtual void emitMipsHackELFFlags(unsigned Flags);
4647 virtual void emitDirectiveSetMicroMips();
4748 virtual void emitDirectiveSetNoMicroMips();
6869 public:
6970 bool isMicroMipsEnabled() const { return MicroMipsEnabled; }
7071 MCELFStreamer &getStreamer();
71 MipsTargetELFStreamer();
72 MipsTargetELFStreamer(MCStreamer &S);
7273
7374 virtual void emitLabel(MCSymbol *Symbol) LLVM_OVERRIDE;
7475
3838
3939 // Pin the vtable to this file.
4040 PPCTargetStreamer::~PPCTargetStreamer() {}
41 PPCTargetStreamer::PPCTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
4142
4243 static MCInstrInfo *createPPCMCInstrInfo() {
4344 MCInstrInfo *X = new MCInstrInfo();
111112 formatted_raw_ostream &OS;
112113
113114 public:
114 PPCTargetAsmStreamer(formatted_raw_ostream &OS) : OS(OS) {}
115 PPCTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS)
116 : PPCTargetStreamer(S), OS(OS) {}
115117 virtual void emitTCEntry(const MCSymbol &S) {
116118 OS << "\t.tc ";
117119 OS << S.getName();
125127 };
126128
127129 class PPCTargetELFStreamer : public PPCTargetStreamer {
130 public:
131 PPCTargetELFStreamer(MCStreamer &S) : PPCTargetStreamer(S) {}
128132 virtual void emitTCEntry(const MCSymbol &S) {
129133 // Creates a R_PPC64_TOC relocation
130 Streamer->EmitSymbolValue(&S, 8);
134 Streamer.EmitSymbolValue(&S, 8);
131135 }
132136 virtual void emitMachine(StringRef CPU) {
133137 // FIXME: Is there anything to do in here or does this directive only
146150 if (Triple(TT).isOSDarwin())
147151 return createMachOStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
148152
149 PPCTargetStreamer *S = new PPCTargetELFStreamer();
150 return createELFStreamer(Ctx, S, MAB, OS, Emitter, RelaxAll, NoExecStack);
153 MCStreamer *S =
154 createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll, NoExecStack);
155 new PPCTargetELFStreamer(*S);
156 return S;
151157 }
152158
153159 static MCStreamer *
155161 bool isVerboseAsm, bool useLoc, bool useCFI,
156162 bool useDwarfDirectory, MCInstPrinter *InstPrint,
157163 MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) {
158 PPCTargetStreamer *S = new PPCTargetAsmStreamer(OS);
159
160 return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI,
161 useDwarfDirectory, InstPrint, CE, TAB,
162 ShowInst);
164
165 MCStreamer *S =
166 llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
167 useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
168 new PPCTargetAsmStreamer(*S, OS);
169 return S;
163170 }
164171
165172 static MCInstPrinter *createPPCMCInstPrinter(const Target &T,
1414 namespace llvm {
1515 class PPCTargetStreamer : public MCTargetStreamer {
1616 public:
17 PPCTargetStreamer(MCStreamer &S);
1718 virtual ~PPCTargetStreamer();
1819 virtual void emitTCEntry(const MCSymbol &S) = 0;
1920 virtual void emitMachine(StringRef CPU) = 0;
8787 MCCodeEmitter *_Emitter,
8888 bool RelaxAll,
8989 bool NoExecStack) {
90 return createELFStreamer(Ctx, 0, MAB, _OS, _Emitter, false, false);
90 return createELFStreamer(Ctx, MAB, _OS, _Emitter, false, false);
9191 }
9292
9393 extern "C" void LLVMInitializeR600TargetMC() {
104104 MCContext &Context, MCAsmBackend &MAB,
105105 raw_ostream &OS, MCCodeEmitter *Emitter,
106106 bool RelaxAll, bool NoExecStack) {
107 SparcTargetELFStreamer *S = new SparcTargetELFStreamer();
108 return createELFStreamer(Context, S, MAB, OS, Emitter, RelaxAll, NoExecStack);
107 MCStreamer *S =
108 createELFStreamer(Context, MAB, OS, Emitter, RelaxAll, NoExecStack);
109 new SparcTargetELFStreamer(*S);
110 return S;
109111 }
110112
111113 static MCStreamer *
113115 bool isVerboseAsm, bool useLoc, bool useCFI,
114116 bool useDwarfDirectory, MCInstPrinter *InstPrint,
115117 MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) {
116 SparcTargetAsmStreamer *S = new SparcTargetAsmStreamer(OS);
117118
118 return llvm::createAsmStreamer(Ctx, S, OS, isVerboseAsm, useLoc, useCFI,
119 useDwarfDirectory, InstPrint, CE, TAB,
120 ShowInst);
119 MCStreamer *S =
120 llvm::createAsmStreamer(Ctx, OS, isVerboseAsm, useLoc, useCFI,
121 useDwarfDirectory, InstPrint, CE, TAB, ShowInst);
122 new SparcTargetAsmStreamer(*S, OS);
123 return S;
121124 }
122125
123126 static MCInstPrinter *createSparcMCInstPrinter(const Target &T,
1717 using namespace llvm;
1818
1919 // pin vtable to this file
20 SparcTargetStreamer::SparcTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
21
2022 void SparcTargetStreamer::anchor() {}
2123
22 SparcTargetAsmStreamer::SparcTargetAsmStreamer(formatted_raw_ostream &OS)
23 : OS(OS) {}
24 SparcTargetAsmStreamer::SparcTargetAsmStreamer(MCStreamer &S,
25 formatted_raw_ostream &OS)
26 : SparcTargetStreamer(S), OS(OS) {}
2427
2528 void SparcTargetAsmStreamer::emitSparcRegisterIgnore(unsigned reg) {
2629 OS << "\t.register "
3437 << ", #scratch\n";
3538 }
3639
40 SparcTargetELFStreamer::SparcTargetELFStreamer(MCStreamer &S)
41 : SparcTargetStreamer(S) {}
42
3743 MCELFStreamer &SparcTargetELFStreamer::getStreamer() {
38 return static_cast(*Streamer);
44 return static_cast(Streamer);
3945 }
1717 virtual void anchor();
1818
1919 public:
20 SparcTargetStreamer(MCStreamer &S);
2021 /// Emit ".register , #ignore".
2122 virtual void emitSparcRegisterIgnore(unsigned reg) = 0;
2223 /// Emit ".register , #scratch".
2829 formatted_raw_ostream &OS;
2930
3031 public:
31 SparcTargetAsmStreamer(formatted_raw_ostream &OS);
32 SparcTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
3233 virtual void emitSparcRegisterIgnore(unsigned reg);
3334 virtual void emitSparcRegisterScratch(unsigned reg);
3435
3738 // This part is for ELF object output
3839 class SparcTargetELFStreamer : public SparcTargetStreamer {
3940 public:
41 SparcTargetELFStreamer(MCStreamer &S);
4042 MCELFStreamer &getStreamer();
4143 virtual void emitSparcRegisterIgnore(unsigned reg) {}
4244 virtual void emitSparcRegisterScratch(unsigned reg) {}
186186 MCCodeEmitter *Emitter,
187187 bool RelaxAll,
188188 bool NoExecStack) {
189 return createELFStreamer(Ctx, 0, MAB, OS, Emitter, RelaxAll, NoExecStack);
189 return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll, NoExecStack);
190190 }
191191
192192 extern "C" void LLVMInitializeSystemZTargetMC() {
370370 if (TheTriple.isOSWindows() && TheTriple.getEnvironment() != Triple::ELF)
371371 return createWinCOFFStreamer(Ctx, MAB, *_Emitter, _OS, RelaxAll);
372372
373 return createELFStreamer(Ctx, 0, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
373 return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
374374 }
375375
376376 static MCInstPrinter *createX86MCInstPrinter(const Target &T,