llvm.org GIT mirror llvm / 28c85a8
Rename createCodeEmitter to createMCCodeEmitter; createObjectStreamer to createMCObjectStreamer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136031 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 9 years ago
7 changed file(s) with 107 addition(s) and 105 deletion(s). Raw diff Collapse all Expand all
9595 typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,
9696 unsigned SyntaxVariant,
9797 const MCAsmInfo &MAI);
98 typedef MCCodeEmitter *(*CodeEmitterCtorTy)(const MCInstrInfo &II,
99 const MCSubtargetInfo &STI,
100 MCContext &Ctx);
101 typedef MCStreamer *(*ObjectStreamerCtorTy)(const Target &T,
102 const std::string &TT,
103 MCContext &Ctx,
104 MCAsmBackend &TAB,
105 raw_ostream &_OS,
106 MCCodeEmitter *_Emitter,
107 bool RelaxAll,
108 bool NoExecStack);
98 typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
99 const MCSubtargetInfo &STI,
100 MCContext &Ctx);
101 typedef MCStreamer *(*MCObjectStreamerCtorTy)(const Target &T,
102 StringRef TT,
103 MCContext &Ctx,
104 MCAsmBackend &TAB,
105 raw_ostream &_OS,
106 MCCodeEmitter *_Emitter,
107 bool RelaxAll,
108 bool NoExecStack);
109109 typedef MCStreamer *(*AsmStreamerCtorTy)(MCContext &Ctx,
110110 formatted_raw_ostream &OS,
111111 bool isVerboseAsm,
182182 /// MCInstPrinter, if registered.
183183 MCInstPrinterCtorTy MCInstPrinterCtorFn;
184184
185 /// CodeEmitterCtorFn - Construction function for this target's CodeEmitter,
186 /// if registered.
187 CodeEmitterCtorTy CodeEmitterCtorFn;
188
189 /// ObjectStreamerCtorFn - Construction function for this target's
190 /// ObjectStreamer, if registered.
191 ObjectStreamerCtorTy ObjectStreamerCtorFn;
185 /// MCCodeEmitterCtorFn - Construction function for this target's
186 /// CodeEmitter, if registered.
187 MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
188
189 /// MCObjectStreamerCtorFn - Construction function for this target's
190 /// MCObjectStreamer, if registered.
191 MCObjectStreamerCtorTy MCObjectStreamerCtorFn;
192192
193193 /// AsmStreamerCtorFn - Construction function for this target's
194194 /// AsmStreamer, if registered (default = llvm::createAsmStreamer).
237237 /// hasMCInstPrinter - Check if this target has an instruction printer.
238238 bool hasMCInstPrinter() const { return MCInstPrinterCtorFn != 0; }
239239
240 /// hasCodeEmitter - Check if this target supports instruction encoding.
241 bool hasCodeEmitter() const { return CodeEmitterCtorFn != 0; }
242
243 /// hasObjectStreamer - Check if this target supports streaming to files.
244 bool hasObjectStreamer() const { return ObjectStreamerCtorFn != 0; }
240 /// hasMCCodeEmitter - Check if this target supports instruction encoding.
241 bool hasMCCodeEmitter() const { return MCCodeEmitterCtorFn != 0; }
242
243 /// hasMCObjectStreamer - Check if this target supports streaming to files.
244 bool hasMCObjectStreamer() const { return MCObjectStreamerCtorFn != 0; }
245245
246246 /// hasAsmStreamer - Check if this target supports streaming to files.
247247 bool hasAsmStreamer() const { return AsmStreamerCtorFn != 0; }
372372 }
373373
374374
375 /// createCodeEmitter - Create a target specific code emitter.
376 MCCodeEmitter *createCodeEmitter(const MCInstrInfo &II,
377 const MCSubtargetInfo &STI,
378 MCContext &Ctx) const {
379 if (!CodeEmitterCtorFn)
380 return 0;
381 return CodeEmitterCtorFn(II, STI, Ctx);
382 }
383
384 /// createObjectStreamer - Create a target specific MCStreamer.
375 /// createMCCodeEmitter - Create a target specific code emitter.
376 MCCodeEmitter *createMCCodeEmitter(const MCInstrInfo &II,
377 const MCSubtargetInfo &STI,
378 MCContext &Ctx) const {
379 if (!MCCodeEmitterCtorFn)
380 return 0;
381 return MCCodeEmitterCtorFn(II, STI, Ctx);
382 }
383
384 /// createMCObjectStreamer - Create a target specific MCStreamer.
385385 ///
386386 /// \arg TT - The target triple.
387387 /// \arg Ctx - The target context.
390390 /// \arg _Emitter - The target independent assembler object.Takes ownership.
391391 /// \arg RelaxAll - Relax all fixups?
392392 /// \arg NoExecStack - Mark file as not needing a executable stack.
393 MCStreamer *createObjectStreamer(const std::string &TT, MCContext &Ctx,
394 MCAsmBackend &TAB,
395 raw_ostream &_OS,
396 MCCodeEmitter *_Emitter,
397 bool RelaxAll,
398 bool NoExecStack) const {
399 if (!ObjectStreamerCtorFn)
400 return 0;
401 return ObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, RelaxAll,
402 NoExecStack);
393 MCStreamer *createMCObjectStreamer(StringRef TT, MCContext &Ctx,
394 MCAsmBackend &TAB,
395 raw_ostream &_OS,
396 MCCodeEmitter *_Emitter,
397 bool RelaxAll,
398 bool NoExecStack) const {
399 if (!MCObjectStreamerCtorFn)
400 return 0;
401 return MCObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter,
402 RelaxAll, NoExecStack);
403403 }
404404
405405 /// createAsmStreamer - Create a target specific MCStreamer.
690690 T.MCInstPrinterCtorFn = Fn;
691691 }
692692
693 /// RegisterCodeEmitter - Register a MCCodeEmitter implementation for the
693 /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the
694694 /// given target.
695695 ///
696696 /// Clients are responsible for ensuring that registration doesn't occur
699699 ///
700700 /// @param T - The target being registered.
701701 /// @param Fn - A function to construct an MCCodeEmitter for the target.
702 static void RegisterCodeEmitter(Target &T, Target::CodeEmitterCtorTy Fn) {
703 if (!T.CodeEmitterCtorFn)
704 T.CodeEmitterCtorFn = Fn;
705 }
706
707 /// RegisterObjectStreamer - Register a object code MCStreamer implementation
708 /// for the given target.
702 static void RegisterMCCodeEmitter(Target &T,
703 Target::MCCodeEmitterCtorTy Fn) {
704 if (!T.MCCodeEmitterCtorFn)
705 T.MCCodeEmitterCtorFn = Fn;
706 }
707
708 /// RegisterMCObjectStreamer - Register a object code MCStreamer
709 /// implementation for the given target.
709710 ///
710711 /// Clients are responsible for ensuring that registration doesn't occur
711712 /// while another thread is attempting to access the registry. Typically
713714 ///
714715 /// @param T - The target being registered.
715716 /// @param Fn - A function to construct an MCStreamer for the target.
716 static void RegisterObjectStreamer(Target &T, Target::ObjectStreamerCtorTy Fn) {
717 if (!T.ObjectStreamerCtorFn)
718 T.ObjectStreamerCtorFn = Fn;
717 static void RegisterMCObjectStreamer(Target &T,
718 Target::MCObjectStreamerCtorTy Fn) {
719 if (!T.MCObjectStreamerCtorFn)
720 T.MCObjectStreamerCtorFn = Fn;
719721 }
720722
721723 /// RegisterAsmStreamer - Register an assembly MCStreamer implementation
10351037 }
10361038 };
10371039
1038 /// RegisterCodeEmitter - Helper template for registering a target specific
1040 /// RegisterMCCodeEmitter - Helper template for registering a target specific
10391041 /// machine code emitter, for use in the target initialization
10401042 /// function. Usage:
10411043 ///
1042 /// extern "C" void LLVMInitializeFooCodeEmitter() {
1043 /// extern Target TheFooTarget;
1044 /// RegisterCodeEmitter X(TheFooTarget);
1045 /// }
1046 template
1047 struct RegisterCodeEmitter {
1048 RegisterCodeEmitter(Target &T) {
1049 TargetRegistry::RegisterCodeEmitter(T, &Allocator);
1044 /// extern "C" void LLVMInitializeFooMCCodeEmitter() {
1045 /// extern Target TheFooTarget;
1046 /// RegisterMCCodeEmitter X(TheFooTarget);
1047 /// }
1048 template
1049 struct RegisterMCCodeEmitter {
1050 RegisterMCCodeEmitter(Target &T) {
1051 TargetRegistry::RegisterMCCodeEmitter(T, &Allocator);
10501052 }
10511053
10521054 private:
10531055 static MCCodeEmitter *Allocator(const MCInstrInfo &II,
10541056 const MCSubtargetInfo &STI,
10551057 MCContext &Ctx) {
1056 return new CodeEmitterImpl();
1058 return new MCCodeEmitterImpl();
10571059 }
10581060 };
10591061
139139 MCAsmBackend *MAB = 0;
140140 if (ShowMCEncoding) {
141141 const MCSubtargetInfo &STI = getSubtarget();
142 MCE = getTarget().createCodeEmitter(*getInstrInfo(), STI, *Context);
142 MCE = getTarget().createMCCodeEmitter(*getInstrInfo(), STI, *Context);
143143 MAB = getTarget().createMCAsmBackend(getTargetTriple());
144144 }
145145
157157 // Create the code emitter for the target if it exists. If not, .o file
158158 // emission fails.
159159 const MCSubtargetInfo &STI = getSubtarget();
160 MCCodeEmitter *MCE = getTarget().createCodeEmitter(*getInstrInfo(), STI,
161 *Context);
160 MCCodeEmitter *MCE = getTarget().createMCCodeEmitter(*getInstrInfo(), STI,
161 *Context);
162162 MCAsmBackend *MAB = getTarget().createMCAsmBackend(getTargetTriple());
163163 if (MCE == 0 || MAB == 0)
164164 return true;
165165
166 AsmStreamer.reset(getTarget().createObjectStreamer(getTargetTriple(),
167 *Context, *MAB, Out, MCE,
168 hasMCRelaxAll(),
169 hasMCNoExecStack()));
166 AsmStreamer.reset(getTarget().createMCObjectStreamer(getTargetTriple(),
167 *Context, *MAB, Out,
168 MCE, hasMCRelaxAll(),
169 hasMCNoExecStack()));
170170 AsmStreamer.get()->InitSections();
171171 break;
172172 }
235235 // Create the code emitter for the target if it exists. If not, .o file
236236 // emission fails.
237237 const MCSubtargetInfo &STI = getSubtarget();
238 MCCodeEmitter *MCE = getTarget().createCodeEmitter(*getInstrInfo(),STI, *Ctx);
238 MCCodeEmitter *MCE = getTarget().createMCCodeEmitter(*getInstrInfo(),STI, *Ctx);
239239 MCAsmBackend *MAB = getTarget().createMCAsmBackend(getTargetTriple());
240240 if (MCE == 0 || MAB == 0)
241241 return true;
242242
243243 OwningPtr AsmStreamer;
244 AsmStreamer.reset(getTarget().createObjectStreamer(getTargetTriple(), *Ctx,
245 *MAB, Out, MCE,
246 hasMCRelaxAll(),
247 hasMCNoExecStack()));
244 AsmStreamer.reset(getTarget().createMCObjectStreamer(getTargetTriple(), *Ctx,
245 *MAB, Out, MCE,
246 hasMCRelaxAll(),
247 hasMCNoExecStack()));
248248 AsmStreamer.get()->InitSections();
249249
250250 // Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
131131 }
132132
133133 // This is duplicated code. Refactor this.
134 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
134 static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
135135 MCContext &Ctx, MCAsmBackend &MAB,
136136 raw_ostream &OS,
137137 MCCodeEmitter *Emitter,
184184 ARM_MC::createARMMCSubtargetInfo);
185185
186186 // Register the MC Code Emitter
187 TargetRegistry::RegisterCodeEmitter(TheARMTarget, createARMMCCodeEmitter);
188 TargetRegistry::RegisterCodeEmitter(TheThumbTarget, createARMMCCodeEmitter);
187 TargetRegistry::RegisterMCCodeEmitter(TheARMTarget, createARMMCCodeEmitter);
188 TargetRegistry::RegisterMCCodeEmitter(TheThumbTarget, createARMMCCodeEmitter);
189189
190190 // Register the asm backend.
191191 TargetRegistry::RegisterMCAsmBackend(TheARMTarget, createARMAsmBackend);
192192 TargetRegistry::RegisterMCAsmBackend(TheThumbTarget, createARMAsmBackend);
193193
194194 // Register the object streamer.
195 TargetRegistry::RegisterObjectStreamer(TheARMTarget, createMCStreamer);
196 TargetRegistry::RegisterObjectStreamer(TheThumbTarget, createMCStreamer);
195 TargetRegistry::RegisterMCObjectStreamer(TheARMTarget, createMCStreamer);
196 TargetRegistry::RegisterMCObjectStreamer(TheThumbTarget, createMCStreamer);
197197
198198 // Register the MCInstPrinter.
199199 TargetRegistry::RegisterMCInstPrinter(TheARMTarget, createARMMCInstPrinter);
7070 return X;
7171 }
7272
73 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
73 static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
7474 MCContext &Ctx, MCAsmBackend &MAB,
7575 raw_ostream &_OS,
7676 MCCodeEmitter *_Emitter,
120120 createMBlazeMCSubtargetInfo);
121121
122122 // Register the MC code emitter
123 TargetRegistry::RegisterCodeEmitter(TheMBlazeTarget,
124 llvm::createMBlazeMCCodeEmitter);
123 TargetRegistry::RegisterMCCodeEmitter(TheMBlazeTarget,
124 llvm::createMBlazeMCCodeEmitter);
125125
126126 // Register the asm backend
127127 TargetRegistry::RegisterMCAsmBackend(TheMBlazeTarget,
128128 createMBlazeAsmBackend);
129129
130130 // Register the object streamer
131 TargetRegistry::RegisterObjectStreamer(TheMBlazeTarget,
132 createMCStreamer);
131 TargetRegistry::RegisterMCObjectStreamer(TheMBlazeTarget,
132 createMCStreamer);
133133
134134 // Register the MCInstPrinter.
135135 TargetRegistry::RegisterMCInstPrinter(TheMBlazeTarget,
8989 }
9090
9191 // This is duplicated code. Refactor this.
92 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
92 static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
9393 MCContext &Ctx, MCAsmBackend &MAB,
9494 raw_ostream &OS,
9595 MCCodeEmitter *Emitter,
131131 createPPCMCSubtargetInfo);
132132
133133 // Register the MC Code Emitter
134 TargetRegistry::RegisterCodeEmitter(ThePPC32Target, createPPCMCCodeEmitter);
135 TargetRegistry::RegisterCodeEmitter(ThePPC64Target, createPPCMCCodeEmitter);
134 TargetRegistry::RegisterMCCodeEmitter(ThePPC32Target, createPPCMCCodeEmitter);
135 TargetRegistry::RegisterMCCodeEmitter(ThePPC64Target, createPPCMCCodeEmitter);
136136
137137 // Register the asm backend.
138138 TargetRegistry::RegisterMCAsmBackend(ThePPC32Target, createPPCAsmBackend);
139139 TargetRegistry::RegisterMCAsmBackend(ThePPC64Target, createPPCAsmBackend);
140140
141141 // Register the object streamer.
142 TargetRegistry::RegisterObjectStreamer(ThePPC32Target, createMCStreamer);
143 TargetRegistry::RegisterObjectStreamer(ThePPC64Target, createMCStreamer);
142 TargetRegistry::RegisterMCObjectStreamer(ThePPC32Target, createMCStreamer);
143 TargetRegistry::RegisterMCObjectStreamer(ThePPC64Target, createMCStreamer);
144144
145145 // Register the MCInstPrinter.
146146 TargetRegistry::RegisterMCInstPrinter(ThePPC32Target, createPPCMCInstPrinter);
365365 return X;
366366 }
367367
368 static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
368 static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
369369 MCContext &Ctx, MCAsmBackend &MAB,
370370 raw_ostream &_OS,
371371 MCCodeEmitter *_Emitter,
417417 X86_MC::createX86MCSubtargetInfo);
418418
419419 // Register the code emitter.
420 TargetRegistry::RegisterCodeEmitter(TheX86_32Target,
421 createX86MCCodeEmitter);
422 TargetRegistry::RegisterCodeEmitter(TheX86_64Target,
423 createX86MCCodeEmitter);
420 TargetRegistry::RegisterMCCodeEmitter(TheX86_32Target,
421 createX86MCCodeEmitter);
422 TargetRegistry::RegisterMCCodeEmitter(TheX86_64Target,
423 createX86MCCodeEmitter);
424424
425425 // Register the asm backend.
426426 TargetRegistry::RegisterMCAsmBackend(TheX86_32Target,
429429 createX86_64AsmBackend);
430430
431431 // Register the object streamer.
432 TargetRegistry::RegisterObjectStreamer(TheX86_32Target,
433 createMCStreamer);
434 TargetRegistry::RegisterObjectStreamer(TheX86_64Target,
435 createMCStreamer);
432 TargetRegistry::RegisterMCObjectStreamer(TheX86_32Target,
433 createMCStreamer);
434 TargetRegistry::RegisterMCObjectStreamer(TheX86_64Target,
435 createMCStreamer);
436436
437437 // Register the MCInstPrinter.
438438 TargetRegistry::RegisterMCInstPrinter(TheX86_32Target,
369369 MCCodeEmitter *CE = 0;
370370 MCAsmBackend *MAB = 0;
371371 if (ShowEncoding) {
372 CE = TheTarget->createCodeEmitter(*MCII, *STI, Ctx);
372 CE = TheTarget->createMCCodeEmitter(*MCII, *STI, Ctx);
373373 MAB = TheTarget->createMCAsmBackend(TripleName);
374374 }
375375 Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true,
380380 Str.reset(createNullStreamer(Ctx));
381381 } else {
382382 assert(FileType == OFT_ObjectFile && "Invalid file type!");
383 MCCodeEmitter *CE = TheTarget->createCodeEmitter(*MCII, *STI, Ctx);
383 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *STI, Ctx);
384384 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(TripleName);
385 Str.reset(TheTarget->createObjectStreamer(TripleName, Ctx, *MAB,
386 FOS, CE, RelaxAll,
387 NoExecStack));
385 Str.reset(TheTarget->createMCObjectStreamer(TripleName, Ctx, *MAB,
386 FOS, CE, RelaxAll,
387 NoExecStack));
388388 }
389389
390390 if (EnableLogging) {