1 //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCStreamer.h"
11 #include "llvm/ADT/SmallString.h"
12 #include "llvm/ADT/StringExtras.h"
13 #include "llvm/ADT/Twine.h"
14 #include "llvm/MC/MCAsmBackend.h"
15 #include "llvm/MC/MCAsmInfo.h"
16 #include "llvm/MC/MCCodeEmitter.h"
17 #include "llvm/MC/MCContext.h"
18 #include "llvm/MC/MCExpr.h"
19 #include "llvm/MC/MCFixupKindInfo.h"
20 #include "llvm/MC/MCInst.h"
21 #include "llvm/MC/MCInstPrinter.h"
22 #include "llvm/MC/MCObjectFileInfo.h"
23 #include "llvm/MC/MCRegisterInfo.h"
24 #include "llvm/MC/MCSectionCOFF.h"
25 #include "llvm/MC/MCSectionMachO.h"
26 #include "llvm/MC/MCSymbol.h"
27 #include "llvm/Support/CommandLine.h"
28 #include "llvm/Support/ErrorHandling.h"
29 #include "llvm/Support/Format.h"
30 #include "llvm/Support/FormattedStream.h"
31 #include "llvm/Support/MathExtras.h"
32 #include "llvm/Support/Path.h"
38 class MCAsmStreamer : public MCStreamer {
40 formatted_raw_ostream &OS;
43 std::unique_ptr<MCInstPrinter> InstPrinter;
44 std::unique_ptr<MCCodeEmitter> Emitter;
45 std::unique_ptr<MCAsmBackend> AsmBackend;
47 SmallString<128> CommentToEmit;
48 raw_svector_ostream CommentStream;
50 unsigned IsVerboseAsm : 1;
51 unsigned ShowInst : 1;
53 unsigned UseDwarfDirectory : 1;
55 enum EHSymbolFlags { EHGlobal = 1,
56 EHWeakDefinition = 1 << 1,
57 EHPrivateExtern = 1 << 2 };
58 DenseMap<const MCSymbol*, unsigned> FlagMap;
60 DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
62 void EmitRegisterName(int64_t Register);
63 void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
64 void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
67 MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
68 bool isVerboseAsm, bool useCFI, bool useDwarfDirectory,
69 MCInstPrinter *printer, MCCodeEmitter *emitter,
70 MCAsmBackend *asmbackend, bool showInst)
71 : MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
72 InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend),
73 CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
74 ShowInst(showInst), UseCFI(useCFI),
75 UseDwarfDirectory(useDwarfDirectory) {
76 if (InstPrinter && IsVerboseAsm)
77 InstPrinter->setCommentStream(CommentStream);
81 inline void EmitEOL() {
82 // If we don't have any comments, just emit a \n.
89 void EmitCommentsAndEOL();
91 /// isVerboseAsm - Return true if this streamer supports verbose assembly at
93 bool isVerboseAsm() const override { return IsVerboseAsm; }
95 /// hasRawTextSupport - We support EmitRawText.
96 bool hasRawTextSupport() const override { return true; }
98 /// AddComment - Add a comment that can be emitted to the generated .s
99 /// file if applicable as a QoI issue to make the output of the compiler
100 /// more readable. This only affects the MCAsmStreamer, and only when
101 /// verbose assembly output is enabled.
102 void AddComment(const Twine &T) override;
104 /// AddEncodingComment - Add a comment showing the encoding of an instruction.
105 void AddEncodingComment(const MCInst &Inst, const MCSubtargetInfo &);
107 /// GetCommentOS - Return a raw_ostream that comments can be written to.
108 /// Unlike AddComment, you are required to terminate comments with \n if you
110 raw_ostream &GetCommentOS() override {
112 return nulls(); // Discard comments unless in verbose asm mode.
113 return CommentStream;
116 void emitRawComment(const Twine &T, bool TabPrefix = true) override;
118 /// AddBlankLine - Emit a blank line to a .s file to pretty it up.
119 void AddBlankLine() override {
123 /// @name MCStreamer Interface
126 void ChangeSection(const MCSection *Section,
127 const MCExpr *Subsection) override;
129 void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override;
130 void EmitLabel(MCSymbol *Symbol) override;
131 void EmitDebugLabel(MCSymbol *Symbol) override;
133 void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
134 void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
135 void EmitLinkerOptions(ArrayRef<std::string> Options) override;
136 void EmitDataRegion(MCDataRegionType Kind) override;
137 void EmitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
138 unsigned Update) override;
139 void EmitThumbFunc(MCSymbol *Func) override;
141 void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
142 void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
143 void EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel,
144 const MCSymbol *Label,
145 unsigned PointerSize) override;
146 void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
147 const MCSymbol *Label) override;
149 bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
151 void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
152 void BeginCOFFSymbolDef(const MCSymbol *Symbol) override;
153 void EmitCOFFSymbolStorageClass(int StorageClass) override;
154 void EmitCOFFSymbolType(int Type) override;
155 void EndCOFFSymbolDef() override;
156 void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
157 void EmitCOFFSecRel32(MCSymbol const *Symbol) override;
158 void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
159 void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
160 unsigned ByteAlignment) override;
162 /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
164 /// @param Symbol - The common symbol to emit.
165 /// @param Size - The size of the common symbol.
166 /// @param ByteAlignment - The alignment of the common symbol in bytes.
167 void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
168 unsigned ByteAlignment) override;
170 void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
171 uint64_t Size = 0, unsigned ByteAlignment = 0) override;
173 void EmitTBSSSymbol (const MCSection *Section, MCSymbol *Symbol,
174 uint64_t Size, unsigned ByteAlignment = 0) override;
176 void EmitBytes(StringRef Data) override;
178 void EmitValueImpl(const MCExpr *Value, unsigned Size) override;
179 void EmitIntValue(uint64_t Value, unsigned Size) override;
181 void EmitULEB128Value(const MCExpr *Value) override;
183 void EmitSLEB128Value(const MCExpr *Value) override;
185 void EmitGPRel64Value(const MCExpr *Value) override;
187 void EmitGPRel32Value(const MCExpr *Value) override;
190 void EmitFill(uint64_t NumBytes, uint8_t FillValue) override;
192 void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
193 unsigned ValueSize = 1,
194 unsigned MaxBytesToEmit = 0) override;
196 void EmitCodeAlignment(unsigned ByteAlignment,
197 unsigned MaxBytesToEmit = 0) override;
199 bool EmitValueToOffset(const MCExpr *Offset,
200 unsigned char Value = 0) override;
202 void EmitFileDirective(StringRef Filename) override;
203 unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
205 unsigned CUID = 0) override;
206 void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
207 unsigned Column, unsigned Flags,
208 unsigned Isa, unsigned Discriminator,
209 StringRef FileName) override;
211 void EmitIdent(StringRef IdentString) override;
212 void EmitCFISections(bool EH, bool Debug) override;
213 void EmitCFIDefCfa(int64_t Register, int64_t Offset) override;
214 void EmitCFIDefCfaOffset(int64_t Offset) override;
215 void EmitCFIDefCfaRegister(int64_t Register) override;
216 void EmitCFIOffset(int64_t Register, int64_t Offset) override;
217 void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding) override;
218 void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) override;
219 void EmitCFIRememberState() override;
220 void EmitCFIRestoreState() override;
221 void EmitCFISameValue(int64_t Register) override;
222 void EmitCFIRelOffset(int64_t Register, int64_t Offset) override;
223 void EmitCFIAdjustCfaOffset(int64_t Adjustment) override;
224 void EmitCFISignalFrame() override;
225 void EmitCFIUndefined(int64_t Register) override;
226 void EmitCFIRegister(int64_t Register1, int64_t Register2) override;
227 void EmitCFIWindowSave() override;
229 void EmitWin64EHStartProc(const MCSymbol *Symbol) override;
230 void EmitWin64EHEndProc() override;
231 void EmitWin64EHStartChained() override;
232 void EmitWin64EHEndChained() override;
233 void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind,
234 bool Except) override;
235 void EmitWin64EHHandlerData() override;
236 void EmitWin64EHPushReg(unsigned Register) override;
237 void EmitWin64EHSetFrame(unsigned Register, unsigned Offset) override;
238 void EmitWin64EHAllocStack(unsigned Size) override;
239 void EmitWin64EHSaveReg(unsigned Register, unsigned Offset) override;
240 void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset) override;
241 void EmitWin64EHPushFrame(bool Code) override;
242 void EmitWin64EHEndProlog() override;
244 void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
246 void EmitBundleAlignMode(unsigned AlignPow2) override;
247 void EmitBundleLock(bool AlignToEnd) override;
248 void EmitBundleUnlock() override;
250 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
251 /// the specified string in the output .s file. This capability is
252 /// indicated by the hasRawTextSupport() predicate.
253 void EmitRawTextImpl(StringRef String) override;
255 void FinishImpl() override;
257 virtual MCSymbolData &getOrCreateSymbolData(const MCSymbol *Symbol) override;
260 } // end anonymous namespace.
262 /// AddComment - Add a comment that can be emitted to the generated .s
263 /// file if applicable as a QoI issue to make the output of the compiler
264 /// more readable. This only affects the MCAsmStreamer, and only when
265 /// verbose assembly output is enabled.
266 void MCAsmStreamer::AddComment(const Twine &T) {
267 if (!IsVerboseAsm) return;
269 // Make sure that CommentStream is flushed.
270 CommentStream.flush();
272 T.toVector(CommentToEmit);
273 // Each comment goes on its own line.
274 CommentToEmit.push_back('\n');
276 // Tell the comment stream that the vector changed underneath it.
277 CommentStream.resync();
280 void MCAsmStreamer::EmitCommentsAndEOL() {
281 if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0) {
286 CommentStream.flush();
287 StringRef Comments = CommentToEmit.str();
289 assert(Comments.back() == '\n' &&
290 "Comment array not newline terminated");
292 // Emit a line of comments.
293 OS.PadToColumn(MAI->getCommentColumn());
294 size_t Position = Comments.find('\n');
295 OS << MAI->getCommentString() << ' ' << Comments.substr(0, Position) <<'\n';
297 Comments = Comments.substr(Position+1);
298 } while (!Comments.empty());
300 CommentToEmit.clear();
301 // Tell the comment stream that the vector changed underneath it.
302 CommentStream.resync();
305 static inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
306 assert(Bytes && "Invalid size!");
307 return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
310 void MCAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) {
313 OS << MAI->getCommentString() << T;
317 void MCAsmStreamer::ChangeSection(const MCSection *Section,
318 const MCExpr *Subsection) {
319 assert(Section && "Cannot switch to a null section!");
320 Section->PrintSwitchToSection(*MAI, OS, Subsection);
323 void MCAsmStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
324 MCSymbol *EHSymbol) {
328 unsigned Flags = FlagMap.lookup(Symbol);
330 if (Flags & EHGlobal)
331 EmitSymbolAttribute(EHSymbol, MCSA_Global);
332 if (Flags & EHWeakDefinition)
333 EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
334 if (Flags & EHPrivateExtern)
335 EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
338 void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
339 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
340 MCStreamer::EmitLabel(Symbol);
342 OS << *Symbol << MAI->getLabelSuffix();
346 void MCAsmStreamer::EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {
347 StringRef str = MCLOHIdToName(Kind);
350 int NbArgs = MCLOHIdToNbArgs(Kind);
351 assert(NbArgs != -1 && ((size_t)NbArgs) == Args.size() && "Malformed LOH!");
352 assert(str != "" && "Invalid LOH name");
355 OS << "\t" << MCLOHDirectiveName() << " " << str << "\t";
357 for (MCLOHArgs::const_iterator It = Args.begin(), EndIt = Args.end();
367 void MCAsmStreamer::EmitDebugLabel(MCSymbol *Symbol) {
368 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
369 MCStreamer::EmitDebugLabel(Symbol);
371 OS << *Symbol << MAI->getDebugLabelSuffix();
375 void MCAsmStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
377 case MCAF_SyntaxUnified: OS << "\t.syntax unified"; break;
378 case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
379 case MCAF_Code16: OS << '\t'<< MAI->getCode16Directive();break;
380 case MCAF_Code32: OS << '\t'<< MAI->getCode32Directive();break;
381 case MCAF_Code64: OS << '\t'<< MAI->getCode64Directive();break;
386 void MCAsmStreamer::EmitLinkerOptions(ArrayRef<std::string> Options) {
387 assert(!Options.empty() && "At least one option is required!");
388 OS << "\t.linker_option \"" << Options[0] << '"';
389 for (ArrayRef<std::string>::iterator it = Options.begin() + 1,
390 ie = Options.end(); it != ie; ++it) {
391 OS << ", " << '"' << *it << '"';
396 void MCAsmStreamer::EmitDataRegion(MCDataRegionType Kind) {
397 if (!MAI->doesSupportDataRegionDirectives())
400 case MCDR_DataRegion: OS << "\t.data_region"; break;
401 case MCDR_DataRegionJT8: OS << "\t.data_region jt8"; break;
402 case MCDR_DataRegionJT16: OS << "\t.data_region jt16"; break;
403 case MCDR_DataRegionJT32: OS << "\t.data_region jt32"; break;
404 case MCDR_DataRegionEnd: OS << "\t.end_data_region"; break;
409 void MCAsmStreamer::EmitVersionMin(MCVersionMinType Kind, unsigned Major,
410 unsigned Minor, unsigned Update) {
412 case MCVM_IOSVersionMin: OS << "\t.ios_version_min"; break;
413 case MCVM_OSXVersionMin: OS << "\t.macosx_version_min"; break;
415 OS << " " << Major << ", " << Minor;
417 OS << ", " << Update;
421 void MCAsmStreamer::EmitThumbFunc(MCSymbol *Func) {
422 // This needs to emit to a temporary string to get properly quoted
423 // MCSymbols when they have spaces in them.
424 OS << "\t.thumb_func";
425 // Only Mach-O hasSubsectionsViaSymbols()
426 if (MAI->hasSubsectionsViaSymbols())
431 void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
432 OS << *Symbol << " = " << *Value;
435 MCStreamer::EmitAssignment(Symbol, Value);
438 void MCAsmStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
439 OS << ".weakref " << *Alias << ", " << *Symbol;
443 void MCAsmStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta,
444 const MCSymbol *LastLabel,
445 const MCSymbol *Label,
446 unsigned PointerSize) {
447 EmitDwarfSetLineAddr(LineDelta, Label, PointerSize);
450 void MCAsmStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
451 const MCSymbol *Label) {
452 EmitIntValue(dwarf::DW_CFA_advance_loc4, 1);
453 const MCExpr *AddrDelta = BuildSymbolDiff(getContext(), Label, LastLabel);
454 AddrDelta = ForceExpAbs(AddrDelta);
455 EmitValue(AddrDelta, 4);
459 bool MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
460 MCSymbolAttr Attribute) {
462 case MCSA_Invalid: llvm_unreachable("Invalid symbol attribute");
463 case MCSA_ELF_TypeFunction: /// .type _foo, STT_FUNC # aka @function
464 case MCSA_ELF_TypeIndFunction: /// .type _foo, STT_GNU_IFUNC
465 case MCSA_ELF_TypeObject: /// .type _foo, STT_OBJECT # aka @object
466 case MCSA_ELF_TypeTLS: /// .type _foo, STT_TLS # aka @tls_object
467 case MCSA_ELF_TypeCommon: /// .type _foo, STT_COMMON # aka @common
468 case MCSA_ELF_TypeNoType: /// .type _foo, STT_NOTYPE # aka @notype
469 case MCSA_ELF_TypeGnuUniqueObject: /// .type _foo, @gnu_unique_object
470 if (!MAI->hasDotTypeDotSizeDirective())
471 return false; // Symbol attribute not supported
472 OS << "\t.type\t" << *Symbol << ','
473 << ((MAI->getCommentString()[0] != '@') ? '@' : '%');
475 default: return false;
476 case MCSA_ELF_TypeFunction: OS << "function"; break;
477 case MCSA_ELF_TypeIndFunction: OS << "gnu_indirect_function"; break;
478 case MCSA_ELF_TypeObject: OS << "object"; break;
479 case MCSA_ELF_TypeTLS: OS << "tls_object"; break;
480 case MCSA_ELF_TypeCommon: OS << "common"; break;
481 case MCSA_ELF_TypeNoType: OS << "no_type"; break;
482 case MCSA_ELF_TypeGnuUniqueObject: OS << "gnu_unique_object"; break;
486 case MCSA_Global: // .globl/.global
487 OS << MAI->getGlobalDirective();
488 FlagMap[Symbol] |= EHGlobal;
490 case MCSA_Hidden: OS << "\t.hidden\t"; break;
491 case MCSA_IndirectSymbol: OS << "\t.indirect_symbol\t"; break;
492 case MCSA_Internal: OS << "\t.internal\t"; break;
493 case MCSA_LazyReference: OS << "\t.lazy_reference\t"; break;
494 case MCSA_Local: OS << "\t.local\t"; break;
495 case MCSA_NoDeadStrip: OS << "\t.no_dead_strip\t"; break;
496 case MCSA_SymbolResolver: OS << "\t.symbol_resolver\t"; break;
497 case MCSA_PrivateExtern:
498 OS << "\t.private_extern\t";
499 FlagMap[Symbol] |= EHPrivateExtern;
501 case MCSA_Protected: OS << "\t.protected\t"; break;
502 case MCSA_Reference: OS << "\t.reference\t"; break;
503 case MCSA_Weak: OS << "\t.weak\t"; break;
504 case MCSA_WeakDefinition:
505 OS << "\t.weak_definition\t";
506 FlagMap[Symbol] |= EHWeakDefinition;
509 case MCSA_WeakReference: OS << MAI->getWeakRefDirective(); break;
510 case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break;
519 void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
520 OS << ".desc" << ' ' << *Symbol << ',' << DescValue;
524 void MCAsmStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
525 OS << "\t.def\t " << *Symbol << ';';
529 void MCAsmStreamer::EmitCOFFSymbolStorageClass (int StorageClass) {
530 OS << "\t.scl\t" << StorageClass << ';';
534 void MCAsmStreamer::EmitCOFFSymbolType (int Type) {
535 OS << "\t.type\t" << Type << ';';
539 void MCAsmStreamer::EndCOFFSymbolDef() {
544 void MCAsmStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
545 OS << "\t.secidx\t" << *Symbol;
549 void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {
550 OS << "\t.secrel32\t" << *Symbol;
554 void MCAsmStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
555 assert(MAI->hasDotTypeDotSizeDirective());
556 OS << "\t.size\t" << *Symbol << ", " << *Value << '\n';
559 void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
560 unsigned ByteAlignment) {
561 // Common symbols do not belong to any actual section.
562 AssignSection(Symbol, NULL);
564 OS << "\t.comm\t" << *Symbol << ',' << Size;
565 if (ByteAlignment != 0) {
566 if (MAI->getCOMMDirectiveAlignmentIsInBytes())
567 OS << ',' << ByteAlignment;
569 OS << ',' << Log2_32(ByteAlignment);
574 /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
576 /// @param Symbol - The common symbol to emit.
577 /// @param Size - The size of the common symbol.
578 void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
579 unsigned ByteAlign) {
580 // Common symbols do not belong to any actual section.
581 AssignSection(Symbol, NULL);
583 OS << "\t.lcomm\t" << *Symbol << ',' << Size;
585 switch (MAI->getLCOMMDirectiveAlignmentType()) {
586 case LCOMM::NoAlignment:
587 llvm_unreachable("alignment not supported on .lcomm!");
588 case LCOMM::ByteAlignment:
589 OS << ',' << ByteAlign;
591 case LCOMM::Log2Alignment:
592 assert(isPowerOf2_32(ByteAlign) && "alignment must be a power of 2");
593 OS << ',' << Log2_32(ByteAlign);
600 void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
601 uint64_t Size, unsigned ByteAlignment) {
603 AssignSection(Symbol, Section);
605 // Note: a .zerofill directive does not switch sections.
608 // This is a mach-o specific directive.
609 const MCSectionMachO *MOSection = ((const MCSectionMachO*)Section);
610 OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
612 if (Symbol != NULL) {
613 OS << ',' << *Symbol << ',' << Size;
614 if (ByteAlignment != 0)
615 OS << ',' << Log2_32(ByteAlignment);
620 // .tbss sym, size, align
621 // This depends that the symbol has already been mangled from the original,
623 void MCAsmStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
624 uint64_t Size, unsigned ByteAlignment) {
625 AssignSection(Symbol, Section);
627 assert(Symbol != NULL && "Symbol shouldn't be NULL!");
628 // Instead of using the Section we'll just use the shortcut.
629 // This is a mach-o specific directive and section.
630 OS << ".tbss " << *Symbol << ", " << Size;
632 // Output align if we have it. We default to 1 so don't bother printing
634 if (ByteAlignment > 1) OS << ", " << Log2_32(ByteAlignment);
639 static inline char toOctal(int X) { return (X&7)+'0'; }
641 static void PrintQuotedString(StringRef Data, raw_ostream &OS) {
644 for (unsigned i = 0, e = Data.size(); i != e; ++i) {
645 unsigned char C = Data[i];
646 if (C == '"' || C == '\\') {
647 OS << '\\' << (char)C;
651 if (isprint((unsigned char)C)) {
657 case '\b': OS << "\\b"; break;
658 case '\f': OS << "\\f"; break;
659 case '\n': OS << "\\n"; break;
660 case '\r': OS << "\\r"; break;
661 case '\t': OS << "\\t"; break;
664 OS << toOctal(C >> 6);
665 OS << toOctal(C >> 3);
666 OS << toOctal(C >> 0);
675 void MCAsmStreamer::EmitBytes(StringRef Data) {
676 assert(getCurrentSection().first &&
677 "Cannot emit contents before setting section!");
678 if (Data.empty()) return;
680 if (Data.size() == 1) {
681 OS << MAI->getData8bitsDirective();
682 OS << (unsigned)(unsigned char)Data[0];
687 // If the data ends with 0 and the target supports .asciz, use it, otherwise
689 if (MAI->getAscizDirective() && Data.back() == 0) {
690 OS << MAI->getAscizDirective();
691 Data = Data.substr(0, Data.size()-1);
693 OS << MAI->getAsciiDirective();
696 PrintQuotedString(Data, OS);
700 void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
701 EmitValue(MCConstantExpr::Create(Value, getContext()), Size);
704 void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size) {
705 assert(Size <= 8 && "Invalid size");
706 assert(getCurrentSection().first &&
707 "Cannot emit contents before setting section!");
708 const char *Directive = 0;
711 case 1: Directive = MAI->getData8bitsDirective(); break;
712 case 2: Directive = MAI->getData16bitsDirective(); break;
713 case 4: Directive = MAI->getData32bitsDirective(); break;
714 case 8: Directive = MAI->getData64bitsDirective(); break;
719 if (!Value->EvaluateAsAbsolute(IntValue))
720 report_fatal_error("Don't know how to emit this value.");
722 // We couldn't handle the requested integer size so we fallback by breaking
723 // the request down into several, smaller, integers. Since sizes greater
724 // than eight are invalid and size equivalent to eight should have been
725 // handled earlier, we use four bytes as our largest piece of granularity.
726 bool IsLittleEndian = MAI->isLittleEndian();
727 for (unsigned Emitted = 0; Emitted != Size;) {
728 unsigned Remaining = Size - Emitted;
729 // The size of our partial emission must be a power of two less than
731 unsigned EmissionSize = PowerOf2Floor(Remaining);
732 if (EmissionSize > 4)
734 // Calculate the byte offset of our partial emission taking into account
735 // the endianness of the target.
736 unsigned ByteOffset =
737 IsLittleEndian ? Emitted : (Remaining - EmissionSize);
738 uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
739 // We truncate our partial emission to fit within the bounds of the
740 // emission domain. This produces nicer output and silences potential
741 // truncation warnings when round tripping through another assembler.
742 ValueToEmit &= ~0ULL >> (64 - EmissionSize * 8);
743 EmitIntValue(ValueToEmit, EmissionSize);
744 Emitted += EmissionSize;
749 assert(Directive && "Invalid size for machine code value!");
750 OS << Directive << *Value;
754 void MCAsmStreamer::EmitULEB128Value(const MCExpr *Value) {
756 if (Value->EvaluateAsAbsolute(IntValue)) {
757 EmitULEB128IntValue(IntValue);
760 assert(MAI->hasLEB128() && "Cannot print a .uleb");
761 OS << ".uleb128 " << *Value;
765 void MCAsmStreamer::EmitSLEB128Value(const MCExpr *Value) {
767 if (Value->EvaluateAsAbsolute(IntValue)) {
768 EmitSLEB128IntValue(IntValue);
771 assert(MAI->hasLEB128() && "Cannot print a .sleb");
772 OS << ".sleb128 " << *Value;
776 void MCAsmStreamer::EmitGPRel64Value(const MCExpr *Value) {
777 assert(MAI->getGPRel64Directive() != 0);
778 OS << MAI->getGPRel64Directive() << *Value;
782 void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
783 assert(MAI->getGPRel32Directive() != 0);
784 OS << MAI->getGPRel32Directive() << *Value;
789 /// EmitFill - Emit NumBytes bytes worth of the value specified by
790 /// FillValue. This implements directives such as '.space'.
791 void MCAsmStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
792 if (NumBytes == 0) return;
794 if (const char *ZeroDirective = MAI->getZeroDirective()) {
795 OS << ZeroDirective << NumBytes;
797 OS << ',' << (int)FillValue;
802 // Emit a byte at a time.
803 MCStreamer::EmitFill(NumBytes, FillValue);
806 void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
808 unsigned MaxBytesToEmit) {
809 // Some assemblers don't support non-power of two alignments, so we always
810 // emit alignments as a power of two if possible.
811 if (isPowerOf2_32(ByteAlignment)) {
814 llvm_unreachable("Invalid size for machine code value!");
825 llvm_unreachable("Unsupported alignment size!");
828 if (MAI->getAlignmentIsInBytes())
831 OS << Log2_32(ByteAlignment);
833 if (Value || MaxBytesToEmit) {
835 OS.write_hex(truncateToSize(Value, ValueSize));
838 OS << ", " << MaxBytesToEmit;
844 // Non-power of two alignment. This is not widely supported by assemblers.
845 // FIXME: Parameterize this based on MAI.
847 default: llvm_unreachable("Invalid size for machine code value!");
848 case 1: OS << ".balign"; break;
849 case 2: OS << ".balignw"; break;
850 case 4: OS << ".balignl"; break;
851 case 8: llvm_unreachable("Unsupported alignment size!");
854 OS << ' ' << ByteAlignment;
855 OS << ", " << truncateToSize(Value, ValueSize);
857 OS << ", " << MaxBytesToEmit;
861 void MCAsmStreamer::EmitCodeAlignment(unsigned ByteAlignment,
862 unsigned MaxBytesToEmit) {
863 // Emit with a text fill value.
864 EmitValueToAlignment(ByteAlignment, MAI->getTextAlignFillValue(),
868 bool MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
869 unsigned char Value) {
870 // FIXME: Verify that Offset is associated with the current section.
871 OS << ".org " << *Offset << ", " << (unsigned) Value;
877 void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
878 assert(MAI->hasSingleParameterDotFile());
880 PrintQuotedString(Filename, OS);
884 unsigned MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo,
890 MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
891 unsigned NumFiles = Table.getMCDwarfFiles().size();
892 FileNo = Table.getFile(Directory, Filename, FileNo);
895 if (NumFiles == Table.getMCDwarfFiles().size())
898 SmallString<128> FullPathName;
900 if (!UseDwarfDirectory && !Directory.empty()) {
901 if (sys::path::is_absolute(Filename))
904 FullPathName = Directory;
905 sys::path::append(FullPathName, Filename);
907 Filename = FullPathName;
911 OS << "\t.file\t" << FileNo << ' ';
912 if (!Directory.empty()) {
913 PrintQuotedString(Directory, OS);
916 PrintQuotedString(Filename, OS);
922 void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
923 unsigned Column, unsigned Flags,
925 unsigned Discriminator,
926 StringRef FileName) {
927 this->MCStreamer::EmitDwarfLocDirective(FileNo, Line, Column, Flags,
928 Isa, Discriminator, FileName);
929 OS << "\t.loc\t" << FileNo << " " << Line << " " << Column;
930 if (Flags & DWARF2_FLAG_BASIC_BLOCK)
931 OS << " basic_block";
932 if (Flags & DWARF2_FLAG_PROLOGUE_END)
933 OS << " prologue_end";
934 if (Flags & DWARF2_FLAG_EPILOGUE_BEGIN)
935 OS << " epilogue_begin";
937 unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
938 if ((Flags & DWARF2_FLAG_IS_STMT) != (OldFlags & DWARF2_FLAG_IS_STMT)) {
941 if (Flags & DWARF2_FLAG_IS_STMT)
948 OS << " isa " << Isa;
950 OS << " discriminator " << Discriminator;
953 OS.PadToColumn(MAI->getCommentColumn());
954 OS << MAI->getCommentString() << ' ' << FileName << ':'
955 << Line << ':' << Column;
960 void MCAsmStreamer::EmitIdent(StringRef IdentString) {
961 assert(MAI->hasIdentDirective() && ".ident directive not supported");
963 PrintQuotedString(IdentString, OS);
967 void MCAsmStreamer::EmitCFISections(bool EH, bool Debug) {
968 MCStreamer::EmitCFISections(EH, Debug);
973 OS << "\t.cfi_sections ";
977 OS << ", .debug_frame";
979 OS << ".debug_frame";
985 void MCAsmStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
987 RecordProcStart(Frame);
991 OS << "\t.cfi_startproc";
997 void MCAsmStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
999 RecordProcEnd(Frame);
1003 // Put a dummy non-null value in Frame.End to mark that this frame has been
1005 Frame.End = (MCSymbol *) 1;
1007 OS << "\t.cfi_endproc";
1011 void MCAsmStreamer::EmitRegisterName(int64_t Register) {
1012 if (InstPrinter && !MAI->useDwarfRegNumForCFI()) {
1013 const MCRegisterInfo *MRI = getContext().getRegisterInfo();
1014 unsigned LLVMRegister = MRI->getLLVMRegNum(Register, true);
1015 InstPrinter->printRegName(OS, LLVMRegister);
1021 void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
1022 MCStreamer::EmitCFIDefCfa(Register, Offset);
1027 OS << "\t.cfi_def_cfa ";
1028 EmitRegisterName(Register);
1029 OS << ", " << Offset;
1033 void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
1034 MCStreamer::EmitCFIDefCfaOffset(Offset);
1039 OS << "\t.cfi_def_cfa_offset " << Offset;
1043 void MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) {
1044 MCStreamer::EmitCFIDefCfaRegister(Register);
1049 OS << "\t.cfi_def_cfa_register ";
1050 EmitRegisterName(Register);
1054 void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
1055 this->MCStreamer::EmitCFIOffset(Register, Offset);
1060 OS << "\t.cfi_offset ";
1061 EmitRegisterName(Register);
1062 OS << ", " << Offset;
1066 void MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
1067 unsigned Encoding) {
1068 MCStreamer::EmitCFIPersonality(Sym, Encoding);
1073 OS << "\t.cfi_personality " << Encoding << ", " << *Sym;
1077 void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
1078 MCStreamer::EmitCFILsda(Sym, Encoding);
1083 OS << "\t.cfi_lsda " << Encoding << ", " << *Sym;
1087 void MCAsmStreamer::EmitCFIRememberState() {
1088 MCStreamer::EmitCFIRememberState();
1093 OS << "\t.cfi_remember_state";
1097 void MCAsmStreamer::EmitCFIRestoreState() {
1098 MCStreamer::EmitCFIRestoreState();
1103 OS << "\t.cfi_restore_state";
1107 void MCAsmStreamer::EmitCFISameValue(int64_t Register) {
1108 MCStreamer::EmitCFISameValue(Register);
1113 OS << "\t.cfi_same_value ";
1114 EmitRegisterName(Register);
1118 void MCAsmStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
1119 MCStreamer::EmitCFIRelOffset(Register, Offset);
1124 OS << "\t.cfi_rel_offset ";
1125 EmitRegisterName(Register);
1126 OS << ", " << Offset;
1130 void MCAsmStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
1131 MCStreamer::EmitCFIAdjustCfaOffset(Adjustment);
1136 OS << "\t.cfi_adjust_cfa_offset " << Adjustment;
1140 void MCAsmStreamer::EmitCFISignalFrame() {
1141 MCStreamer::EmitCFISignalFrame();
1146 OS << "\t.cfi_signal_frame";
1150 void MCAsmStreamer::EmitCFIUndefined(int64_t Register) {
1151 MCStreamer::EmitCFIUndefined(Register);
1156 OS << "\t.cfi_undefined " << Register;
1160 void MCAsmStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
1161 MCStreamer::EmitCFIRegister(Register1, Register2);
1166 OS << "\t.cfi_register " << Register1 << ", " << Register2;
1170 void MCAsmStreamer::EmitCFIWindowSave() {
1171 MCStreamer::EmitCFIWindowSave();
1176 OS << "\t.cfi_window_save";
1180 void MCAsmStreamer::EmitWin64EHStartProc(const MCSymbol *Symbol) {
1181 MCStreamer::EmitWin64EHStartProc(Symbol);
1183 OS << ".seh_proc " << *Symbol;
1187 void MCAsmStreamer::EmitWin64EHEndProc() {
1188 MCStreamer::EmitWin64EHEndProc();
1190 OS << "\t.seh_endproc";
1194 void MCAsmStreamer::EmitWin64EHStartChained() {
1195 MCStreamer::EmitWin64EHStartChained();
1197 OS << "\t.seh_startchained";
1201 void MCAsmStreamer::EmitWin64EHEndChained() {
1202 MCStreamer::EmitWin64EHEndChained();
1204 OS << "\t.seh_endchained";
1208 void MCAsmStreamer::EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind,
1210 MCStreamer::EmitWin64EHHandler(Sym, Unwind, Except);
1212 OS << "\t.seh_handler " << *Sym;
1220 static const MCSection *getWin64EHTableSection(StringRef suffix,
1221 MCContext &context) {
1222 // FIXME: This doesn't belong in MCObjectFileInfo. However,
1223 /// this duplicate code in MCWin64EH.cpp.
1225 return context.getObjectFileInfo()->getXDataSection();
1226 return context.getCOFFSection((".xdata"+suffix).str(),
1227 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
1228 COFF::IMAGE_SCN_MEM_READ |
1229 COFF::IMAGE_SCN_MEM_WRITE,
1230 SectionKind::getDataRel());
1233 void MCAsmStreamer::EmitWin64EHHandlerData() {
1234 MCStreamer::EmitWin64EHHandlerData();
1236 // Switch sections. Don't call SwitchSection directly, because that will
1237 // cause the section switch to be visible in the emitted assembly.
1238 // We only do this so the section switch that terminates the handler
1239 // data block is visible.
1240 MCWin64EHUnwindInfo *CurFrame = getCurrentW64UnwindInfo();
1241 StringRef suffix=MCWin64EHUnwindEmitter::GetSectionSuffix(CurFrame->Function);
1242 const MCSection *xdataSect = getWin64EHTableSection(suffix, getContext());
1244 SwitchSectionNoChange(xdataSect);
1246 OS << "\t.seh_handlerdata";
1250 void MCAsmStreamer::EmitWin64EHPushReg(unsigned Register) {
1251 MCStreamer::EmitWin64EHPushReg(Register);
1253 OS << "\t.seh_pushreg " << Register;
1257 void MCAsmStreamer::EmitWin64EHSetFrame(unsigned Register, unsigned Offset) {
1258 MCStreamer::EmitWin64EHSetFrame(Register, Offset);
1260 OS << "\t.seh_setframe " << Register << ", " << Offset;
1264 void MCAsmStreamer::EmitWin64EHAllocStack(unsigned Size) {
1265 MCStreamer::EmitWin64EHAllocStack(Size);
1267 OS << "\t.seh_stackalloc " << Size;
1271 void MCAsmStreamer::EmitWin64EHSaveReg(unsigned Register, unsigned Offset) {
1272 MCStreamer::EmitWin64EHSaveReg(Register, Offset);
1274 OS << "\t.seh_savereg " << Register << ", " << Offset;
1278 void MCAsmStreamer::EmitWin64EHSaveXMM(unsigned Register, unsigned Offset) {
1279 MCStreamer::EmitWin64EHSaveXMM(Register, Offset);
1281 OS << "\t.seh_savexmm " << Register << ", " << Offset;
1285 void MCAsmStreamer::EmitWin64EHPushFrame(bool Code) {
1286 MCStreamer::EmitWin64EHPushFrame(Code);
1288 OS << "\t.seh_pushframe";
1294 void MCAsmStreamer::EmitWin64EHEndProlog(void) {
1295 MCStreamer::EmitWin64EHEndProlog();
1297 OS << "\t.seh_endprologue";
1301 void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
1302 const MCSubtargetInfo &STI) {
1303 raw_ostream &OS = GetCommentOS();
1304 SmallString<256> Code;
1305 SmallVector<MCFixup, 4> Fixups;
1306 raw_svector_ostream VecOS(Code);
1307 Emitter->EncodeInstruction(Inst, VecOS, Fixups, STI);
1310 // If we are showing fixups, create symbolic markers in the encoded
1311 // representation. We do this by making a per-bit map to the fixup item index,
1312 // then trying to display it as nicely as possible.
1313 SmallVector<uint8_t, 64> FixupMap;
1314 FixupMap.resize(Code.size() * 8);
1315 for (unsigned i = 0, e = Code.size() * 8; i != e; ++i)
1318 for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
1319 MCFixup &F = Fixups[i];
1320 const MCFixupKindInfo &Info = AsmBackend->getFixupKindInfo(F.getKind());
1321 for (unsigned j = 0; j != Info.TargetSize; ++j) {
1322 unsigned Index = F.getOffset() * 8 + Info.TargetOffset + j;
1323 assert(Index < Code.size() * 8 && "Invalid offset in fixup!");
1324 FixupMap[Index] = 1 + i;
1328 // FIXME: Note the fixup comments for Thumb2 are completely bogus since the
1329 // high order halfword of a 32-bit Thumb2 instruction is emitted first.
1330 OS << "encoding: [";
1331 for (unsigned i = 0, e = Code.size(); i != e; ++i) {
1335 // See if all bits are the same map entry.
1336 uint8_t MapEntry = FixupMap[i * 8 + 0];
1337 for (unsigned j = 1; j != 8; ++j) {
1338 if (FixupMap[i * 8 + j] == MapEntry)
1341 MapEntry = uint8_t(~0U);
1345 if (MapEntry != uint8_t(~0U)) {
1346 if (MapEntry == 0) {
1347 OS << format("0x%02x", uint8_t(Code[i]));
1350 // FIXME: Some of the 8 bits require fix up.
1351 OS << format("0x%02x", uint8_t(Code[i])) << '\''
1352 << char('A' + MapEntry - 1) << '\'';
1354 OS << char('A' + MapEntry - 1);
1357 // Otherwise, write out in binary.
1359 for (unsigned j = 8; j--;) {
1360 unsigned Bit = (Code[i] >> j) & 1;
1363 if (MAI->isLittleEndian())
1364 FixupBit = i * 8 + j;
1366 FixupBit = i * 8 + (7-j);
1368 if (uint8_t MapEntry = FixupMap[FixupBit]) {
1369 assert(Bit == 0 && "Encoder wrote into fixed up bit!");
1370 OS << char('A' + MapEntry - 1);
1378 for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
1379 MCFixup &F = Fixups[i];
1380 const MCFixupKindInfo &Info = AsmBackend->getFixupKindInfo(F.getKind());
1381 OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset()
1382 << ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n";
1386 void MCAsmStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) {
1387 assert(getCurrentSection().first &&
1388 "Cannot emit contents before setting section!");
1390 // Show the encoding in a comment if we have a code emitter.
1392 AddEncodingComment(Inst, STI);
1394 // Show the MCInst if enabled.
1396 Inst.dump_pretty(GetCommentOS(), MAI, InstPrinter.get(), "\n ");
1397 GetCommentOS() << "\n";
1400 // If we have an AsmPrinter, use that to print, otherwise print the MCInst.
1402 InstPrinter->printInst(&Inst, OS, "");
1404 Inst.print(OS, MAI);
1408 void MCAsmStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
1409 OS << "\t.bundle_align_mode " << AlignPow2;
1413 void MCAsmStreamer::EmitBundleLock(bool AlignToEnd) {
1414 OS << "\t.bundle_lock";
1416 OS << " align_to_end";
1420 void MCAsmStreamer::EmitBundleUnlock() {
1421 OS << "\t.bundle_unlock";
1425 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
1426 /// the specified string in the output .s file. This capability is
1427 /// indicated by the hasRawTextSupport() predicate.
1428 void MCAsmStreamer::EmitRawTextImpl(StringRef String) {
1429 if (!String.empty() && String.back() == '\n')
1430 String = String.substr(0, String.size()-1);
1435 void MCAsmStreamer::FinishImpl() {
1436 // If we are generating dwarf for assembly source files dump out the sections.
1437 if (getContext().getGenDwarfForAssembly())
1438 MCGenDwarfInfo::Emit(this);
1440 // Emit the label for the line table, if requested - since the rest of the
1441 // line table will be defined by .loc/.file directives, and not emitted
1442 // directly, the label is the only work required here.
1443 auto &Tables = getContext().getMCDwarfLineTables();
1444 if (!Tables.empty()) {
1445 // FIXME: assert Tables.size() == 1 here, except that's not currently true
1446 // due to DwarfUnit.cpp:2074.
1447 if (auto *Label = Tables.begin()->second.getLabel()) {
1448 SwitchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
1454 EmitFrames(AsmBackend.get(), false);
1457 MCSymbolData &MCAsmStreamer::getOrCreateSymbolData(const MCSymbol *Symbol) {
1458 MCSymbolData *&Entry = SymbolMap[Symbol];
1461 Entry = new MCSymbolData(*Symbol, 0, 0, 0);
1466 MCStreamer *llvm::createAsmStreamer(MCContext &Context,
1467 formatted_raw_ostream &OS,
1468 bool isVerboseAsm, bool useCFI,
1469 bool useDwarfDirectory, MCInstPrinter *IP,
1470 MCCodeEmitter *CE, MCAsmBackend *MAB,
1472 return new MCAsmStreamer(Context, OS, isVerboseAsm, useCFI, useDwarfDirectory,
1473 IP, CE, MAB, ShowInst);