LCOV - code coverage report
Current view: top level - lib/MC - MCAsmStreamer.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 917 970 94.5 %
Date: 2018-06-17 00:07:59 Functions: 121 125 96.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output ----------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #include "llvm/ADT/Optional.h"
      11             : #include "llvm/ADT/STLExtras.h"
      12             : #include "llvm/ADT/SmallString.h"
      13             : #include "llvm/ADT/StringExtras.h"
      14             : #include "llvm/ADT/Twine.h"
      15             : #include "llvm/MC/MCAsmBackend.h"
      16             : #include "llvm/MC/MCAsmInfo.h"
      17             : #include "llvm/MC/MCAssembler.h"
      18             : #include "llvm/MC/MCCodeEmitter.h"
      19             : #include "llvm/MC/MCCodeView.h"
      20             : #include "llvm/MC/MCContext.h"
      21             : #include "llvm/MC/MCExpr.h"
      22             : #include "llvm/MC/MCFixupKindInfo.h"
      23             : #include "llvm/MC/MCInst.h"
      24             : #include "llvm/MC/MCInstPrinter.h"
      25             : #include "llvm/MC/MCObjectFileInfo.h"
      26             : #include "llvm/MC/MCObjectWriter.h"
      27             : #include "llvm/MC/MCRegisterInfo.h"
      28             : #include "llvm/MC/MCSectionMachO.h"
      29             : #include "llvm/MC/MCStreamer.h"
      30             : #include "llvm/Support/ErrorHandling.h"
      31             : #include "llvm/Support/Format.h"
      32             : #include "llvm/Support/FormattedStream.h"
      33             : #include "llvm/Support/LEB128.h"
      34             : #include "llvm/Support/MathExtras.h"
      35             : #include "llvm/Support/Path.h"
      36             : #include "llvm/Support/TargetRegistry.h"
      37             : #include <cctype>
      38             : 
      39             : using namespace llvm;
      40             : 
      41             : namespace {
      42             : 
      43       84944 : class MCAsmStreamer final : public MCStreamer {
      44             :   std::unique_ptr<formatted_raw_ostream> OSOwner;
      45             :   formatted_raw_ostream &OS;
      46             :   const MCAsmInfo *MAI;
      47             :   std::unique_ptr<MCInstPrinter> InstPrinter;
      48             :   std::unique_ptr<MCAssembler> Assembler;
      49             : 
      50             :   SmallString<128> ExplicitCommentToEmit;
      51             :   SmallString<128> CommentToEmit;
      52             :   raw_svector_ostream CommentStream;
      53             :   raw_null_ostream NullStream;
      54             : 
      55             :   unsigned IsVerboseAsm : 1;
      56             :   unsigned ShowInst : 1;
      57             :   unsigned UseDwarfDirectory : 1;
      58             : 
      59             :   void EmitRegisterName(int64_t Register);
      60             :   void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
      61             :   void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
      62             : 
      63             : public:
      64       21346 :   MCAsmStreamer(MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
      65             :                 bool isVerboseAsm, bool useDwarfDirectory,
      66             :                 MCInstPrinter *printer, std::unique_ptr<MCCodeEmitter> emitter,
      67             :                 std::unique_ptr<MCAsmBackend> asmbackend, bool showInst)
      68       21346 :       : MCStreamer(Context), OSOwner(std::move(os)), OS(*OSOwner),
      69       21346 :         MAI(Context.getAsmInfo()), InstPrinter(printer),
      70             :         Assembler(llvm::make_unique<MCAssembler>(
      71             :             Context, std::move(asmbackend), std::move(emitter),
      72       42692 :             (asmbackend) ? asmbackend->createObjectWriter(NullStream)
      73             :                          : nullptr)),
      74             :         CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
      75      128076 :         ShowInst(showInst), UseDwarfDirectory(useDwarfDirectory) {
      76             :     assert(InstPrinter);
      77       21346 :     if (IsVerboseAsm)
      78             :         InstPrinter->setCommentStream(CommentStream);
      79       21346 :   }
      80             : 
      81             :   MCAssembler &getAssembler() { return *Assembler; }
      82      330456 :   MCAssembler *getAssemblerPtr() override { return nullptr; }
      83             : 
      84     5181615 :   inline void EmitEOL() {
      85             :     // Dump Explicit Comments here.
      86     5181615 :     emitExplicitComments();
      87             :     // If we don't have any comments, just emit a \n.
      88     5181615 :     if (!IsVerboseAsm) {
      89       80439 :       OS << '\n';
      90             :       return;
      91             :     }
      92     5101176 :     EmitCommentsAndEOL();
      93             :   }
      94             : 
      95             :   void EmitSyntaxDirective() override;
      96             : 
      97             :   void EmitCommentsAndEOL();
      98             : 
      99             :   /// Return true if this streamer supports verbose assembly at all.
     100       59301 :   bool isVerboseAsm() const override { return IsVerboseAsm; }
     101             : 
     102             :   /// Do we support EmitRawText?
     103        3921 :   bool hasRawTextSupport() const override { return true; }
     104             : 
     105             :   /// Add a comment that can be emitted to the generated .s file to make the
     106             :   /// output of the compiler more readable. This only affects the MCAsmStreamer
     107             :   /// and only when verbose assembly output is enabled.
     108             :   void AddComment(const Twine &T, bool EOL = true) override;
     109             : 
     110             :   /// Add a comment showing the encoding of an instruction.
     111             :   /// If PrintSchedInfo is true, then the comment sched:[x:y] will be added to
     112             :   /// the output if supported by the target.
     113             :   void AddEncodingComment(const MCInst &Inst, const MCSubtargetInfo &,
     114             :                           bool PrintSchedInfo);
     115             : 
     116             :   /// Return a raw_ostream that comments can be written to.
     117             :   /// Unlike AddComment, you are required to terminate comments with \n if you
     118             :   /// use this method.
     119     2610023 :   raw_ostream &GetCommentOS() override {
     120     4754340 :     if (!IsVerboseAsm)
     121       34356 :       return nulls();  // Discard comments unless in verbose asm mode.
     122     4719984 :     return CommentStream;
     123             :   }
     124             : 
     125             :   void emitRawComment(const Twine &T, bool TabPrefix = true) override;
     126             : 
     127             :   void addExplicitComment(const Twine &T) override;
     128             :   void emitExplicitComments() override;
     129             : 
     130             :   /// Emit a blank line to a .s file to pretty it up.
     131      670524 :   void AddBlankLine() override {
     132      670524 :     EmitEOL();
     133      670524 :   }
     134             : 
     135             :   /// @name MCStreamer Interface
     136             :   /// @{
     137             : 
     138             :   void ChangeSection(MCSection *Section, const MCExpr *Subsection) override;
     139             : 
     140             :   void emitELFSymverDirective(StringRef AliasName,
     141             :                               const MCSymbol *Aliasee) override;
     142             : 
     143             :   void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override;
     144             :   void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
     145             : 
     146             :   void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
     147             :   void EmitLinkerOptions(ArrayRef<std::string> Options) override;
     148             :   void EmitDataRegion(MCDataRegionType Kind) override;
     149             :   void EmitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
     150             :                       unsigned Update) override;
     151             :   void EmitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor,
     152             :                         unsigned Update) override;
     153             :   void EmitThumbFunc(MCSymbol *Func) override;
     154             : 
     155             :   void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
     156             :   void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
     157             :   bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
     158             : 
     159             :   void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
     160             :   void BeginCOFFSymbolDef(const MCSymbol *Symbol) override;
     161             :   void EmitCOFFSymbolStorageClass(int StorageClass) override;
     162             :   void EmitCOFFSymbolType(int Type) override;
     163             :   void EndCOFFSymbolDef() override;
     164             :   void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
     165             :   void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override;
     166             :   void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
     167             :   void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
     168             :   void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
     169             :   void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
     170             :                         unsigned ByteAlignment) override;
     171             : 
     172             :   /// Emit a local common (.lcomm) symbol.
     173             :   ///
     174             :   /// @param Symbol - The common symbol to emit.
     175             :   /// @param Size - The size of the common symbol.
     176             :   /// @param ByteAlignment - The alignment of the common symbol in bytes.
     177             :   void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
     178             :                              unsigned ByteAlignment) override;
     179             : 
     180             :   void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
     181             :                     uint64_t Size = 0, unsigned ByteAlignment = 0) override;
     182             : 
     183             :   void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
     184             :                       unsigned ByteAlignment = 0) override;
     185             : 
     186             :   void EmitBinaryData(StringRef Data) override;
     187             : 
     188             :   void EmitBytes(StringRef Data) override;
     189             : 
     190             :   void EmitValueImpl(const MCExpr *Value, unsigned Size,
     191             :                      SMLoc Loc = SMLoc()) override;
     192             :   void EmitIntValue(uint64_t Value, unsigned Size) override;
     193             : 
     194             :   void EmitULEB128Value(const MCExpr *Value) override;
     195             : 
     196             :   void EmitSLEB128Value(const MCExpr *Value) override;
     197             : 
     198             :   void EmitDTPRel32Value(const MCExpr *Value) override;
     199             :   void EmitDTPRel64Value(const MCExpr *Value) override;
     200             :   void EmitTPRel32Value(const MCExpr *Value) override;
     201             :   void EmitTPRel64Value(const MCExpr *Value) override;
     202             : 
     203             :   void EmitGPRel64Value(const MCExpr *Value) override;
     204             : 
     205             :   void EmitGPRel32Value(const MCExpr *Value) override;
     206             : 
     207             :   void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
     208             :                 SMLoc Loc = SMLoc()) override;
     209             : 
     210             :   void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
     211             :                 SMLoc Loc = SMLoc()) override;
     212             : 
     213             :   void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
     214             :                             unsigned ValueSize = 1,
     215             :                             unsigned MaxBytesToEmit = 0) override;
     216             : 
     217             :   void EmitCodeAlignment(unsigned ByteAlignment,
     218             :                          unsigned MaxBytesToEmit = 0) override;
     219             : 
     220             :   void emitValueToOffset(const MCExpr *Offset,
     221             :                          unsigned char Value,
     222             :                          SMLoc Loc) override;
     223             : 
     224             :   void EmitFileDirective(StringRef Filename) override;
     225             :   Expected<unsigned> tryEmitDwarfFileDirective(unsigned FileNo,
     226             :                                                StringRef Directory,
     227             :                                                StringRef Filename,
     228             :                                                MD5::MD5Result *Checksum = 0,
     229             :                                                Optional<StringRef> Source = None,
     230             :                                                unsigned CUID = 0) override;
     231             :   void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
     232             :                                MD5::MD5Result *Checksum,
     233             :                                Optional<StringRef> Source,
     234             :                                unsigned CUID = 0) override;
     235             :   void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
     236             :                              unsigned Column, unsigned Flags,
     237             :                              unsigned Isa, unsigned Discriminator,
     238             :                              StringRef FileName) override;
     239             :   MCSymbol *getDwarfLineTableSymbol(unsigned CUID) override;
     240             : 
     241             :   bool EmitCVFileDirective(unsigned FileNo, StringRef Filename,
     242             :                            ArrayRef<uint8_t> Checksum,
     243             :                            unsigned ChecksumKind) override;
     244             :   bool EmitCVFuncIdDirective(unsigned FuncId) override;
     245             :   bool EmitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc,
     246             :                                    unsigned IAFile, unsigned IALine,
     247             :                                    unsigned IACol, SMLoc Loc) override;
     248             :   void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line,
     249             :                           unsigned Column, bool PrologueEnd, bool IsStmt,
     250             :                           StringRef FileName, SMLoc Loc) override;
     251             :   void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart,
     252             :                                 const MCSymbol *FnEnd) override;
     253             :   void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
     254             :                                       unsigned SourceFileId,
     255             :                                       unsigned SourceLineNum,
     256             :                                       const MCSymbol *FnStartSym,
     257             :                                       const MCSymbol *FnEndSym) override;
     258             :   void EmitCVDefRangeDirective(
     259             :       ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
     260             :       StringRef FixedSizePortion) override;
     261             :   void EmitCVStringTableDirective() override;
     262             :   void EmitCVFileChecksumsDirective() override;
     263             :   void EmitCVFileChecksumOffsetDirective(unsigned FileNo) override;
     264             :   void EmitCVFPOData(const MCSymbol *ProcSym, SMLoc L) override;
     265             : 
     266             :   void EmitIdent(StringRef IdentString) override;
     267             :   void EmitCFISections(bool EH, bool Debug) override;
     268             :   void EmitCFIDefCfa(int64_t Register, int64_t Offset) override;
     269             :   void EmitCFIDefCfaOffset(int64_t Offset) override;
     270             :   void EmitCFIDefCfaRegister(int64_t Register) override;
     271             :   void EmitCFIOffset(int64_t Register, int64_t Offset) override;
     272             :   void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding) override;
     273             :   void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) override;
     274             :   void EmitCFIRememberState() override;
     275             :   void EmitCFIRestoreState() override;
     276             :   void EmitCFIRestore(int64_t Register) override;
     277             :   void EmitCFISameValue(int64_t Register) override;
     278             :   void EmitCFIRelOffset(int64_t Register, int64_t Offset) override;
     279             :   void EmitCFIAdjustCfaOffset(int64_t Adjustment) override;
     280             :   void EmitCFIEscape(StringRef Values) override;
     281             :   void EmitCFIGnuArgsSize(int64_t Size) override;
     282             :   void EmitCFISignalFrame() override;
     283             :   void EmitCFIUndefined(int64_t Register) override;
     284             :   void EmitCFIRegister(int64_t Register1, int64_t Register2) override;
     285             :   void EmitCFIWindowSave() override;
     286             :   void EmitCFIReturnColumn(int64_t Register) override;
     287             : 
     288             :   void EmitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc) override;
     289             :   void EmitWinCFIEndProc(SMLoc Loc) override;
     290             :   void EmitWinCFIStartChained(SMLoc Loc) override;
     291             :   void EmitWinCFIEndChained(SMLoc Loc) override;
     292             :   void EmitWinCFIPushReg(unsigned Register, SMLoc Loc) override;
     293             :   void EmitWinCFISetFrame(unsigned Register, unsigned Offset,
     294             :                           SMLoc Loc) override;
     295             :   void EmitWinCFIAllocStack(unsigned Size, SMLoc Loc) override;
     296             :   void EmitWinCFISaveReg(unsigned Register, unsigned Offset,
     297             :                          SMLoc Loc) override;
     298             :   void EmitWinCFISaveXMM(unsigned Register, unsigned Offset,
     299             :                          SMLoc Loc) override;
     300             :   void EmitWinCFIPushFrame(bool Code, SMLoc Loc) override;
     301             :   void EmitWinCFIEndProlog(SMLoc Loc) override;
     302             : 
     303             :   void EmitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
     304             :                         SMLoc Loc) override;
     305             :   void EmitWinEHHandlerData(SMLoc Loc) override;
     306             : 
     307             :   void emitCGProfileEntry(const MCSymbolRefExpr *From,
     308             :                           const MCSymbolRefExpr *To, uint64_t Count) override;
     309             : 
     310             :   void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
     311             :                        bool PrintSchedInfo) override;
     312             : 
     313             :   void EmitBundleAlignMode(unsigned AlignPow2) override;
     314             :   void EmitBundleLock(bool AlignToEnd) override;
     315             :   void EmitBundleUnlock() override;
     316             : 
     317             :   bool EmitRelocDirective(const MCExpr &Offset, StringRef Name,
     318             :                           const MCExpr *Expr, SMLoc Loc,
     319             :                           const MCSubtargetInfo &STI) override;
     320             : 
     321             :   /// If this file is backed by an assembly streamer, this dumps the specified
     322             :   /// string in the output .s file. This capability is indicated by the
     323             :   /// hasRawTextSupport() predicate.
     324             :   void EmitRawTextImpl(StringRef String) override;
     325             : 
     326             :   void FinishImpl() override;
     327             : };
     328             : 
     329             : } // end anonymous namespace.
     330             : 
     331      101823 : void MCAsmStreamer::AddComment(const Twine &T, bool EOL) {
     332      101823 :   if (!IsVerboseAsm) return;
     333             : 
     334      100728 :   T.toVector(CommentToEmit);
     335             :  
     336      100728 :   if (EOL)
     337       94761 :     CommentToEmit.push_back('\n'); // Place comment in a new line.
     338             : }
     339             : 
     340     5101176 : void MCAsmStreamer::EmitCommentsAndEOL() {
     341     8710051 :   if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0) {
     342     3608875 :     OS << '\n';
     343     3608875 :     return;
     344             :   }
     345             : 
     346     1492301 :   StringRef Comments = CommentToEmit;
     347             : 
     348             :   assert(Comments.back() == '\n' &&
     349             :          "Comment array not newline terminated");
     350             :   do {
     351             :     // Emit a line of comments.
     352     1554389 :     OS.PadToColumn(MAI->getCommentColumn());
     353             :     size_t Position = Comments.find('\n');
     354     3108778 :     OS << MAI->getCommentString() << ' ' << Comments.substr(0, Position) <<'\n';
     355             : 
     356     3108778 :     Comments = Comments.substr(Position+1);
     357     1554389 :   } while (!Comments.empty());
     358             : 
     359             :   CommentToEmit.clear();
     360             : }
     361             : 
     362             : static inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
     363             :   assert(Bytes > 0 && Bytes <= 8 && "Invalid size!");
     364       92076 :   return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
     365             : }
     366             : 
     367      589094 : void MCAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) {
     368      589094 :   if (TabPrefix)
     369       36624 :     OS << '\t';
     370      589094 :   OS << MAI->getCommentString() << T;
     371      589094 :   EmitEOL();
     372      589094 : }
     373             : 
     374         186 : void MCAsmStreamer::addExplicitComment(const Twine &T) {
     375         186 :   StringRef c = T.getSingleStringRef();
     376         186 :   if (c.equals(StringRef(MAI->getSeparatorString())))
     377          32 :     return;
     378             :   if (c.startswith(StringRef("//"))) {
     379             :     ExplicitCommentToEmit.append("\t");
     380          17 :     ExplicitCommentToEmit.append(MAI->getCommentString());
     381             :     // drop //
     382          17 :     ExplicitCommentToEmit.append(c.slice(2, c.size()).str());
     383             :   } else if (c.startswith(StringRef("/*"))) {
     384          12 :     size_t p = 2, len = c.size() - 2;
     385             :     // emit each line in comment as separate newline.
     386             :     do {
     387          26 :       size_t newp = std::min(len, c.find_first_of("\r\n", p));
     388             :       ExplicitCommentToEmit.append("\t");
     389          13 :       ExplicitCommentToEmit.append(MAI->getCommentString());
     390          13 :       ExplicitCommentToEmit.append(c.slice(p, newp).str());
     391             :       // If we have another line in this comment add line
     392          13 :       if (newp < len)
     393             :         ExplicitCommentToEmit.append("\n");
     394          13 :       p = newp + 1;
     395          13 :     } while (p < len);
     396             :   } else if (c.startswith(StringRef(MAI->getCommentString()))) {
     397             :     ExplicitCommentToEmit.append("\t");
     398         109 :     ExplicitCommentToEmit.append(c.str());
     399          32 :   } else if (c.front() == '#') {
     400             : 
     401             :     ExplicitCommentToEmit.append("\t");
     402          16 :     ExplicitCommentToEmit.append(MAI->getCommentString());
     403          16 :     ExplicitCommentToEmit.append(c.slice(1, c.size()).str());
     404             :   } else
     405             :     assert(false && "Unexpected Assembly Comment");
     406             :   // full line comments immediately output
     407         154 :   if (c.back() == '\n')
     408         127 :     emitExplicitComments();
     409             : }
     410             : 
     411     5181742 : void MCAsmStreamer::emitExplicitComments() {
     412     5181742 :   StringRef Comments = ExplicitCommentToEmit;
     413     5181742 :   if (!Comments.empty())
     414         150 :     OS << Comments;
     415             :   ExplicitCommentToEmit.clear();
     416     5181742 : }
     417             : 
     418      148769 : void MCAsmStreamer::ChangeSection(MCSection *Section,
     419             :                                   const MCExpr *Subsection) {
     420             :   assert(Section && "Cannot switch to a null section!");
     421      148769 :   if (MCTargetStreamer *TS = getTargetStreamer()) {
     422      278108 :     TS->changeSection(getCurrentSectionOnly(), Section, Subsection, OS);
     423             :   } else {
     424       29145 :     Section->PrintSwitchToSection(
     425       29145 :         *MAI, getContext().getObjectFileInfo()->getTargetTriple(), OS,
     426        9715 :         Subsection);
     427             :   }
     428      148768 : }
     429             : 
     430           6 : void MCAsmStreamer::emitELFSymverDirective(StringRef AliasName,
     431             :                                            const MCSymbol *Aliasee) {
     432           6 :   OS << ".symver ";
     433           6 :   Aliasee->print(OS, MAI);
     434           6 :   OS << ", " << AliasName;
     435           6 :   EmitEOL();
     436           6 : }
     437             : 
     438      419833 : void MCAsmStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) {
     439      419833 :   MCStreamer::EmitLabel(Symbol, Loc);
     440             : 
     441      419832 :   Symbol->print(OS, MAI);
     442      419832 :   OS << MAI->getLabelSuffix();
     443             : 
     444      419832 :   EmitEOL();
     445      419832 : }
     446             : 
     447         238 : void MCAsmStreamer::EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {
     448         238 :   StringRef str = MCLOHIdToName(Kind);
     449             : 
     450             : #ifndef NDEBUG
     451             :   int NbArgs = MCLOHIdToNbArgs(Kind);
     452             :   assert(NbArgs != -1 && ((size_t)NbArgs) == Args.size() && "Malformed LOH!");
     453             :   assert(str != "" && "Invalid LOH name");
     454             : #endif
     455             : 
     456         238 :   OS << "\t" << MCLOHDirectiveName() << " " << str << "\t";
     457             :   bool IsFirst = true;
     458        1318 :   for (const MCSymbol *Arg : Args) {
     459         540 :     if (!IsFirst)
     460         302 :       OS << ", ";
     461             :     IsFirst = false;
     462         540 :     Arg->print(OS, MAI);
     463             :   }
     464         238 :   EmitEOL();
     465         238 : }
     466             : 
     467       18338 : void MCAsmStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
     468       18338 :   switch (Flag) {
     469        2583 :   case MCAF_SyntaxUnified:         OS << "\t.syntax unified"; break;
     470        2310 :   case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
     471       10932 :   case MCAF_Code16:                OS << '\t'<< MAI->getCode16Directive();break;
     472       15954 :   case MCAF_Code32:                OS << '\t'<< MAI->getCode32Directive();break;
     473           4 :   case MCAF_Code64:                OS << '\t'<< MAI->getCode64Directive();break;
     474             :   }
     475       18338 :   EmitEOL();
     476       18338 : }
     477             : 
     478           5 : void MCAsmStreamer::EmitLinkerOptions(ArrayRef<std::string> Options) {
     479             :   assert(!Options.empty() && "At least one option is required!");
     480           5 :   OS << "\t.linker_option \"" << Options[0] << '"';
     481           7 :   for (ArrayRef<std::string>::iterator it = Options.begin() + 1,
     482           7 :          ie = Options.end(); it != ie; ++it) {
     483           2 :     OS << ", " << '"' << *it << '"';
     484             :   }
     485           5 :   EmitEOL();
     486           5 : }
     487             : 
     488        3272 : void MCAsmStreamer::EmitDataRegion(MCDataRegionType Kind) {
     489        3272 :   if (!MAI->doesSupportDataRegionDirectives())
     490             :     return;
     491         842 :   switch (Kind) {
     492         371 :   case MCDR_DataRegion:            OS << "\t.data_region"; break;
     493          17 :   case MCDR_DataRegionJT8:         OS << "\t.data_region jt8"; break;
     494           0 :   case MCDR_DataRegionJT16:        OS << "\t.data_region jt16"; break;
     495          33 :   case MCDR_DataRegionJT32:        OS << "\t.data_region jt32"; break;
     496         421 :   case MCDR_DataRegionEnd:         OS << "\t.end_data_region"; break;
     497             :   }
     498         842 :   EmitEOL();
     499             : }
     500             : 
     501             : static const char *getVersionMinDirective(MCVersionMinType Type) {
     502         889 :   switch (Type) {
     503             :   case MCVM_WatchOSVersionMin: return ".watchos_version_min";
     504          18 :   case MCVM_TvOSVersionMin:    return ".tvos_version_min";
     505         186 :   case MCVM_IOSVersionMin:     return ".ios_version_min";
     506         659 :   case MCVM_OSXVersionMin:     return ".macosx_version_min";
     507             :   }
     508           0 :   llvm_unreachable("Invalid MC version min type");
     509             : }
     510             : 
     511         889 : void MCAsmStreamer::EmitVersionMin(MCVersionMinType Type, unsigned Major,
     512             :                                    unsigned Minor, unsigned Update) {
     513        2667 :   OS << '\t' << getVersionMinDirective(Type) << ' ' << Major << ", " << Minor;
     514         889 :   if (Update)
     515          43 :     OS << ", " << Update;
     516         889 :   EmitEOL();
     517         889 : }
     518             : 
     519             : static const char *getPlatformName(MachO::PlatformType Type) {
     520           8 :   switch (Type) {
     521             :   case MachO::PLATFORM_MACOS:    return "macos";
     522           1 :   case MachO::PLATFORM_IOS:      return "ios";
     523           2 :   case MachO::PLATFORM_TVOS:     return "tvos";
     524           1 :   case MachO::PLATFORM_WATCHOS:  return "watchos";
     525           0 :   case MachO::PLATFORM_BRIDGEOS: return "bridgeos";
     526             :   }
     527           0 :   llvm_unreachable("Invalid Mach-O platform type");
     528             : }
     529             : 
     530           8 : void MCAsmStreamer::EmitBuildVersion(unsigned Platform, unsigned Major,
     531             :                                      unsigned Minor, unsigned Update) {
     532             :   const char *PlatformName = getPlatformName((MachO::PlatformType)Platform);
     533          16 :   OS << "\t.build_version " << PlatformName << ", " << Major << ", " << Minor;
     534           8 :   if (Update)
     535           3 :     OS << ", " << Update;
     536           8 :   EmitEOL();
     537           8 : }
     538             : 
     539        5307 : void MCAsmStreamer::EmitThumbFunc(MCSymbol *Func) {
     540             :   // This needs to emit to a temporary string to get properly quoted
     541             :   // MCSymbols when they have spaces in them.
     542        5307 :   OS << "\t.thumb_func";
     543             :   // Only Mach-O hasSubsectionsViaSymbols()
     544        5307 :   if (MAI->hasSubsectionsViaSymbols()) {
     545        1264 :     OS << '\t';
     546        1264 :     Func->print(OS, MAI);
     547             :   }
     548        5307 :   EmitEOL();
     549        5307 : }
     550             : 
     551        1800 : void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
     552             :   // Do not emit a .set on inlined target assignments.
     553             :   bool EmitSet = true;
     554           2 :   if (auto *E = dyn_cast<MCTargetExpr>(Value))
     555           2 :     if (E->inlineAssignedExpr())
     556             :       EmitSet = false;
     557             :   if (EmitSet) {
     558        1798 :     OS << ".set ";
     559        1798 :     Symbol->print(OS, MAI);
     560        1798 :     OS << ", ";
     561        1798 :     Value->print(OS, MAI);
     562             : 
     563        1798 :     EmitEOL();
     564             :   }
     565             : 
     566        1800 :   MCStreamer::EmitAssignment(Symbol, Value);
     567        1800 : }
     568             : 
     569           0 : void MCAsmStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
     570           0 :   OS << ".weakref ";
     571           0 :   Alias->print(OS, MAI);
     572           0 :   OS << ", ";
     573           0 :   Symbol->print(OS, MAI);
     574           0 :   EmitEOL();
     575           0 : }
     576             : 
     577      358363 : bool MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
     578             :                                         MCSymbolAttr Attribute) {
     579      358363 :   switch (Attribute) {
     580           0 :   case MCSA_Invalid: llvm_unreachable("Invalid symbol attribute");
     581      168634 :   case MCSA_ELF_TypeFunction:    /// .type _foo, STT_FUNC  # aka @function
     582             :   case MCSA_ELF_TypeIndFunction: /// .type _foo, STT_GNU_IFUNC
     583             :   case MCSA_ELF_TypeObject:      /// .type _foo, STT_OBJECT  # aka @object
     584             :   case MCSA_ELF_TypeTLS:         /// .type _foo, STT_TLS     # aka @tls_object
     585             :   case MCSA_ELF_TypeCommon:      /// .type _foo, STT_COMMON  # aka @common
     586             :   case MCSA_ELF_TypeNoType:      /// .type _foo, STT_NOTYPE  # aka @notype
     587             :   case MCSA_ELF_TypeGnuUniqueObject:  /// .type _foo, @gnu_unique_object
     588      168634 :     if (!MAI->hasDotTypeDotSizeDirective())
     589             :       return false; // Symbol attribute not supported
     590      168566 :     OS << "\t.type\t";
     591      168566 :     Symbol->print(OS, MAI);
     592      505698 :     OS << ',' << ((MAI->getCommentString()[0] != '@') ? '@' : '%');
     593      168566 :     switch (Attribute) {
     594             :     default: return false;
     595      158084 :     case MCSA_ELF_TypeFunction:    OS << "function"; break;
     596           2 :     case MCSA_ELF_TypeIndFunction: OS << "gnu_indirect_function"; break;
     597       10474 :     case MCSA_ELF_TypeObject:      OS << "object"; break;
     598           1 :     case MCSA_ELF_TypeTLS:         OS << "tls_object"; break;
     599           1 :     case MCSA_ELF_TypeCommon:      OS << "common"; break;
     600           1 :     case MCSA_ELF_TypeNoType:      OS << "notype"; break;
     601           3 :     case MCSA_ELF_TypeGnuUniqueObject: OS << "gnu_unique_object"; break;
     602             :     }
     603      168566 :     EmitEOL();
     604      168566 :     return true;
     605      187382 :   case MCSA_Global: // .globl/.global
     606      187382 :     OS << MAI->getGlobalDirective();
     607      187382 :     break;
     608         473 :   case MCSA_Hidden:         OS << "\t.hidden\t";          break;
     609         653 :   case MCSA_IndirectSymbol: OS << "\t.indirect_symbol\t"; break;
     610           0 :   case MCSA_Internal:       OS << "\t.internal\t";        break;
     611           9 :   case MCSA_LazyReference:  OS << "\t.lazy_reference\t";  break;
     612         204 :   case MCSA_Local:          OS << "\t.local\t";           break;
     613         106 :   case MCSA_NoDeadStrip:
     614         106 :     if (!MAI->hasNoDeadStrip())
     615             :       return false;
     616          58 :     OS << "\t.no_dead_strip\t";
     617          58 :     break;
     618           4 :   case MCSA_SymbolResolver: OS << "\t.symbol_resolver\t"; break;
     619           8 :   case MCSA_AltEntry:       OS << "\t.alt_entry\t";       break;
     620          69 :   case MCSA_PrivateExtern:
     621          69 :     OS << "\t.private_extern\t";
     622          69 :     break;
     623          44 :   case MCSA_Protected:      OS << "\t.protected\t";       break;
     624           4 :   case MCSA_Reference:      OS << "\t.reference\t";       break;
     625         423 :   case MCSA_Weak:           OS << MAI->getWeakDirective(); break;
     626         187 :   case MCSA_WeakDefinition:
     627         187 :     OS << "\t.weak_definition\t";
     628         187 :     break;
     629             :       // .weak_reference
     630         148 :   case MCSA_WeakReference:  OS << MAI->getWeakRefDirective(); break;
     631          15 :   case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break;
     632             :   }
     633             : 
     634      189681 :   Symbol->print(OS, MAI);
     635      189681 :   EmitEOL();
     636             : 
     637      189681 :   return true;
     638             : }
     639             : 
     640           3 : void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
     641           3 :   OS << ".desc" << ' ';
     642           3 :   Symbol->print(OS, MAI);
     643           3 :   OS << ',' << DescValue;
     644           3 :   EmitEOL();
     645           3 : }
     646             : 
     647        6837 : void MCAsmStreamer::EmitSyntaxDirective() {
     648        6837 :   if (MAI->getAssemblerDialect() == 1) {
     649          23 :     OS << "\t.intel_syntax noprefix";
     650          23 :     EmitEOL();
     651             :   }
     652             :   // FIXME: Currently emit unprefix'ed registers.
     653             :   // The intel_syntax directive has one optional argument 
     654             :   // with may have a value of prefix or noprefix.
     655        6837 : }
     656             : 
     657        2817 : void MCAsmStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
     658        2817 :   OS << "\t.def\t ";
     659        2817 :   Symbol->print(OS, MAI);
     660        2817 :   OS << ';';
     661        2817 :   EmitEOL();
     662        2817 : }
     663             : 
     664        2817 : void MCAsmStreamer::EmitCOFFSymbolStorageClass (int StorageClass) {
     665        2817 :   OS << "\t.scl\t" << StorageClass << ';';
     666        2817 :   EmitEOL();
     667        2817 : }
     668             : 
     669        2817 : void MCAsmStreamer::EmitCOFFSymbolType (int Type) {
     670        2817 :   OS << "\t.type\t" << Type << ';';
     671        2817 :   EmitEOL();
     672        2817 : }
     673             : 
     674        2817 : void MCAsmStreamer::EndCOFFSymbolDef() {
     675        2817 :   OS << "\t.endef";
     676        2817 :   EmitEOL();
     677        2817 : }
     678             : 
     679          30 : void MCAsmStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
     680          30 :   OS << "\t.safeseh\t";
     681          30 :   Symbol->print(OS, MAI);
     682          30 :   EmitEOL();
     683          30 : }
     684             : 
     685           4 : void MCAsmStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {
     686           4 :   OS << "\t.symidx\t";
     687           4 :   Symbol->print(OS, MAI);
     688           4 :   EmitEOL();
     689           4 : }
     690             : 
     691         117 : void MCAsmStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
     692         117 :   OS << "\t.secidx\t";
     693         117 :   Symbol->print(OS, MAI);
     694         117 :   EmitEOL();
     695         117 : }
     696             : 
     697         310 : void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) {
     698         310 :   OS << "\t.secrel32\t";
     699         310 :   Symbol->print(OS, MAI);
     700         310 :   if (Offset != 0)
     701           4 :     OS << '+' << Offset;
     702         310 :   EmitEOL();
     703         310 : }
     704             : 
     705      166076 : void MCAsmStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
     706             :   assert(MAI->hasDotTypeDotSizeDirective());
     707      166076 :   OS << "\t.size\t";
     708      166076 :   Symbol->print(OS, MAI);
     709      166076 :   OS << ", ";
     710      166076 :   Value->print(OS, MAI);
     711      166076 :   EmitEOL();
     712      166076 : }
     713             : 
     714        2571 : void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
     715             :                                      unsigned ByteAlignment) {
     716        2571 :   OS << "\t.comm\t";
     717        2571 :   Symbol->print(OS, MAI);
     718        5142 :   OS << ',' << Size;
     719             : 
     720        2571 :   if (ByteAlignment != 0) {
     721        2440 :     if (MAI->getCOMMDirectiveAlignmentIsInBytes())
     722        2232 :       OS << ',' << ByteAlignment;
     723             :     else
     724         208 :       OS << ',' << Log2_32(ByteAlignment);
     725             :   }
     726        2571 :   EmitEOL();
     727        2571 : }
     728             : 
     729          40 : void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
     730             :                                           unsigned ByteAlign) {
     731          40 :   OS << "\t.lcomm\t";
     732          40 :   Symbol->print(OS, MAI);
     733          80 :   OS << ',' << Size;
     734             : 
     735          40 :   if (ByteAlign > 1) {
     736          30 :     switch (MAI->getLCOMMDirectiveAlignmentType()) {
     737           0 :     case LCOMM::NoAlignment:
     738           0 :       llvm_unreachable("alignment not supported on .lcomm!");
     739          29 :     case LCOMM::ByteAlignment:
     740          29 :       OS << ',' << ByteAlign;
     741             :       break;
     742           1 :     case LCOMM::Log2Alignment:
     743             :       assert(isPowerOf2_32(ByteAlign) && "alignment must be a power of 2");
     744           1 :       OS << ',' << Log2_32(ByteAlign);
     745             :       break;
     746             :     }
     747             :   }
     748          40 :   EmitEOL();
     749          40 : }
     750             : 
     751         281 : void MCAsmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
     752             :                                  uint64_t Size, unsigned ByteAlignment) {
     753         281 :   if (Symbol)
     754         560 :     AssignFragment(Symbol, &Section->getDummyFragment());
     755             : 
     756             :   // Note: a .zerofill directive does not switch sections.
     757         281 :   OS << ".zerofill ";
     758             : 
     759             :   // This is a mach-o specific directive.
     760             :   const MCSectionMachO *MOSection = ((const MCSectionMachO*)Section);
     761         843 :   OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
     762             : 
     763         281 :   if (Symbol) {
     764         280 :     OS << ',';
     765         280 :     Symbol->print(OS, MAI);
     766         560 :     OS << ',' << Size;
     767         280 :     if (ByteAlignment != 0)
     768         280 :       OS << ',' << Log2_32(ByteAlignment);
     769             :   }
     770         281 :   EmitEOL();
     771         281 : }
     772             : 
     773             : // .tbss sym, size, align
     774             : // This depends that the symbol has already been mangled from the original,
     775             : // e.g. _a.
     776          73 : void MCAsmStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
     777             :                                    uint64_t Size, unsigned ByteAlignment) {
     778         146 :   AssignFragment(Symbol, &Section->getDummyFragment());
     779             : 
     780             :   assert(Symbol && "Symbol shouldn't be NULL!");
     781             :   // Instead of using the Section we'll just use the shortcut.
     782             :   // This is a mach-o specific directive and section.
     783          73 :   OS << ".tbss ";
     784          73 :   Symbol->print(OS, MAI);
     785          73 :   OS << ", " << Size;
     786             : 
     787             :   // Output align if we have it.  We default to 1 so don't bother printing
     788             :   // that.
     789          73 :   if (ByteAlignment > 1) OS << ", " << Log2_32(ByteAlignment);
     790             : 
     791          73 :   EmitEOL();
     792          73 : }
     793             : 
     794        9300 : static inline char toOctal(int X) { return (X&7)+'0'; }
     795             : 
     796       20168 : static void PrintQuotedString(StringRef Data, raw_ostream &OS) {
     797             :   OS << '"';
     798             : 
     799      217395 :   for (unsigned i = 0, e = Data.size(); i != e; ++i) {
     800      394454 :     unsigned char C = Data[i];
     801      197488 :     if (C == '"' || C == '\\') {
     802             :       OS << '\\' << (char)C;
     803         261 :       continue;
     804             :     }
     805             : 
     806      390291 :     if (isprint((unsigned char)C)) {
     807             :       OS << (char)C;
     808      193325 :       continue;
     809             :     }
     810             : 
     811        3641 :     switch (C) {
     812          39 :       case '\b': OS << "\\b"; break;
     813          11 :       case '\f': OS << "\\f"; break;
     814         422 :       case '\n': OS << "\\n"; break;
     815           1 :       case '\r': OS << "\\r"; break;
     816          68 :       case '\t': OS << "\\t"; break;
     817             :       default:
     818             :         OS << '\\';
     819        3100 :         OS << toOctal(C >> 6);
     820        3100 :         OS << toOctal(C >> 3);
     821             :         OS << toOctal(C >> 0);
     822             :         break;
     823             :     }
     824             :   }
     825             : 
     826             :   OS << '"';
     827       20168 : }
     828             : 
     829       39444 : void MCAsmStreamer::EmitBytes(StringRef Data) {
     830             :   assert(getCurrentSectionOnly() &&
     831             :          "Cannot emit contents before setting section!");
     832       39444 :   if (Data.empty()) return;
     833             : 
     834             :   // If only single byte is provided or no ascii or asciz directives is
     835             :   // supported, emit as vector of 8bits data.
     836       45450 :   if (Data.size() == 1 ||
     837        6017 :       !(MAI->getAscizDirective() || MAI->getAsciiDirective())) {
     838       33449 :     const char *Directive = MAI->getData8bitsDirective();
     839      100369 :     for (const unsigned char C : Data.bytes()) {
     840       33460 :       OS << Directive << (unsigned)C;
     841       33460 :       EmitEOL();
     842             :     }
     843             :     return;
     844             :   }
     845             : 
     846             :   // If the data ends with 0 and the target supports .asciz, use it, otherwise
     847             :   // use .ascii
     848       11990 :   if (MAI->getAscizDirective() && Data.back() == 0) {
     849        4951 :     OS << MAI->getAscizDirective();
     850        4951 :     Data = Data.substr(0, Data.size()-1);
     851             :   } else {
     852        1044 :     OS << MAI->getAsciiDirective();
     853             :   }
     854             : 
     855        5995 :   PrintQuotedString(Data, OS);
     856        5995 :   EmitEOL();
     857             : }
     858             : 
     859         778 : void MCAsmStreamer::EmitBinaryData(StringRef Data) {
     860             :   // This is binary data. Print it in a grid of hex bytes for readability.
     861             :   const size_t Cols = 4;
     862        5252 :   for (size_t I = 0, EI = alignTo(Data.size(), Cols); I < EI; I += Cols) {
     863        4474 :     size_t J = I, EJ = std::min(I + Cols, Data.size());
     864             :     assert(EJ > 0);
     865        2237 :     OS << MAI->getData8bitsDirective();
     866       13285 :     for (; J < EJ - 1; ++J)
     867       16572 :       OS << format("0x%02x", uint8_t(Data[J])) << ", ";
     868        6711 :     OS << format("0x%02x", uint8_t(Data[J]));
     869        2237 :     EmitEOL();
     870             :   }
     871         778 : }
     872             : 
     873      422207 : void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
     874      422207 :   EmitValue(MCConstantExpr::create(Value, getContext()), Size);
     875      422207 : }
     876             : 
     877      446110 : void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
     878             :                                   SMLoc Loc) {
     879             :   assert(Size <= 8 && "Invalid size");
     880             :   assert(getCurrentSectionOnly() &&
     881             :          "Cannot emit contents before setting section!");
     882             :   const char *Directive = nullptr;
     883      446110 :   switch (Size) {
     884             :   default: break;
     885      130238 :   case 1: Directive = MAI->getData8bitsDirective();  break;
     886       38741 :   case 2: Directive = MAI->getData16bitsDirective(); break;
     887      239341 :   case 4: Directive = MAI->getData32bitsDirective(); break;
     888       37790 :   case 8: Directive = MAI->getData64bitsDirective(); break;
     889             :   }
     890             : 
     891      446110 :   if (!Directive) {
     892             :     int64_t IntValue;
     893         753 :     if (!Value->evaluateAsAbsolute(IntValue))
     894           0 :       report_fatal_error("Don't know how to emit this value.");
     895             : 
     896             :     // We couldn't handle the requested integer size so we fallback by breaking
     897             :     // the request down into several, smaller, integers.
     898             :     // Since sizes greater or equal to "Size" are invalid, we use the greatest
     899             :     // power of 2 that is less than "Size" as our largest piece of granularity.
     900         753 :     bool IsLittleEndian = MAI->isLittleEndian();
     901        3765 :     for (unsigned Emitted = 0; Emitted != Size;) {
     902        1506 :       unsigned Remaining = Size - Emitted;
     903             :       // The size of our partial emission must be a power of two less than
     904             :       // Size.
     905        4518 :       unsigned EmissionSize = PowerOf2Floor(std::min(Remaining, Size - 1));
     906             :       // Calculate the byte offset of our partial emission taking into account
     907             :       // the endianness of the target.
     908             :       unsigned ByteOffset =
     909        1506 :           IsLittleEndian ? Emitted : (Remaining - EmissionSize);
     910        1506 :       uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
     911             :       // We truncate our partial emission to fit within the bounds of the
     912             :       // emission domain.  This produces nicer output and silences potential
     913             :       // truncation warnings when round tripping through another assembler.
     914        1506 :       uint64_t Shift = 64 - EmissionSize * 8;
     915             :       assert(Shift < static_cast<uint64_t>(
     916             :                          std::numeric_limits<unsigned long long>::digits) &&
     917             :              "undefined behavior");
     918        1506 :       ValueToEmit &= ~0ULL >> Shift;
     919        1506 :       EmitIntValue(ValueToEmit, EmissionSize);
     920        1506 :       Emitted += EmissionSize;
     921             :     }
     922             :     return;
     923             :   }
     924             : 
     925             :   assert(Directive && "Invalid size for machine code value!");
     926      445357 :   OS << Directive;
     927      445357 :   if (MCTargetStreamer *TS = getTargetStreamer()) {
     928      429465 :     TS->emitValue(Value);
     929             :   } else {
     930       15892 :     Value->print(OS, MAI);
     931       15892 :     EmitEOL();
     932             :   }
     933             : }
     934             : 
     935        2033 : void MCAsmStreamer::EmitULEB128Value(const MCExpr *Value) {
     936             :   int64_t IntValue;
     937        2033 :   if (Value->evaluateAsAbsolute(IntValue)) {
     938           4 :     EmitULEB128IntValue(IntValue);
     939           4 :     return;
     940             :   }
     941        2029 :   OS << "\t.uleb128 ";
     942        2029 :   Value->print(OS, MAI);
     943        2029 :   EmitEOL();
     944             : }
     945             : 
     946           4 : void MCAsmStreamer::EmitSLEB128Value(const MCExpr *Value) {
     947             :   int64_t IntValue;
     948           4 :   if (Value->evaluateAsAbsolute(IntValue)) {
     949           4 :     EmitSLEB128IntValue(IntValue);
     950           4 :     return;
     951             :   }
     952           0 :   OS << "\t.sleb128 ";
     953           0 :   Value->print(OS, MAI);
     954           0 :   EmitEOL();
     955             : }
     956             : 
     957           3 : void MCAsmStreamer::EmitDTPRel64Value(const MCExpr *Value) {
     958             :   assert(MAI->getDTPRel64Directive() != nullptr);
     959           3 :   OS << MAI->getDTPRel64Directive();
     960           3 :   Value->print(OS, MAI);
     961           3 :   EmitEOL();
     962           3 : }
     963             : 
     964           3 : void MCAsmStreamer::EmitDTPRel32Value(const MCExpr *Value) {
     965             :   assert(MAI->getDTPRel32Directive() != nullptr);
     966           3 :   OS << MAI->getDTPRel32Directive();
     967           3 :   Value->print(OS, MAI);
     968           3 :   EmitEOL();
     969           3 : }
     970             : 
     971           2 : void MCAsmStreamer::EmitTPRel64Value(const MCExpr *Value) {
     972             :   assert(MAI->getTPRel64Directive() != nullptr);
     973           2 :   OS << MAI->getTPRel64Directive();
     974           2 :   Value->print(OS, MAI);
     975           2 :   EmitEOL();
     976           2 : }
     977             : 
     978           2 : void MCAsmStreamer::EmitTPRel32Value(const MCExpr *Value) {
     979             :   assert(MAI->getTPRel32Directive() != nullptr);
     980           2 :   OS << MAI->getTPRel32Directive();
     981           2 :   Value->print(OS, MAI);
     982           2 :   EmitEOL();
     983           2 : }
     984             : 
     985          33 : void MCAsmStreamer::EmitGPRel64Value(const MCExpr *Value) {
     986             :   assert(MAI->getGPRel64Directive() != nullptr);
     987          33 :   OS << MAI->getGPRel64Directive();
     988          33 :   Value->print(OS, MAI);
     989          33 :   EmitEOL();
     990          33 : }
     991             : 
     992          19 : void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
     993             :   assert(MAI->getGPRel32Directive() != nullptr);
     994          19 :   OS << MAI->getGPRel32Directive();
     995          19 :   Value->print(OS, MAI);
     996          19 :   EmitEOL();
     997          19 : }
     998             : 
     999       50430 : void MCAsmStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
    1000             :                              SMLoc Loc) {
    1001             :   int64_t IntNumBytes;
    1002       50430 :   if (NumBytes.evaluateAsAbsolute(IntNumBytes) && IntNumBytes == 0)
    1003       50430 :     return;
    1004             : 
    1005       16614 :   if (const char *ZeroDirective = MAI->getZeroDirective()) {
    1006             :     // FIXME: Emit location directives
    1007       16614 :     OS << ZeroDirective;
    1008       16614 :     NumBytes.print(OS, MAI);
    1009       16614 :     if (FillValue != 0)
    1010        3656 :       OS << ',' << (int)FillValue;
    1011       16614 :     EmitEOL();
    1012       16614 :     return;
    1013             :   }
    1014             : 
    1015           0 :   MCStreamer::emitFill(NumBytes, FillValue);
    1016             : }
    1017             : 
    1018          19 : void MCAsmStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
    1019             :                              int64_t Expr, SMLoc Loc) {
    1020             :   // FIXME: Emit location directives
    1021          19 :   OS << "\t.fill\t";
    1022          19 :   NumValues.print(OS, MAI);
    1023          19 :   OS << ", " << Size << ", 0x";
    1024          38 :   OS.write_hex(truncateToSize(Expr, 4));
    1025          19 :   EmitEOL();
    1026          19 : }
    1027             : 
    1028      206372 : void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
    1029             :                                          unsigned ValueSize,
    1030             :                                          unsigned MaxBytesToEmit) {
    1031             :   // Some assemblers don't support non-power of two alignments, so we always
    1032             :   // emit alignments as a power of two if possible.
    1033             :   if (isPowerOf2_32(ByteAlignment)) {
    1034      206370 :     switch (ValueSize) {
    1035           0 :     default:
    1036           0 :       llvm_unreachable("Invalid size for machine code value!");
    1037      206359 :     case 1:
    1038      206359 :       OS << "\t.p2align\t";
    1039      206359 :       break;
    1040           4 :     case 2:
    1041           4 :       OS << ".p2alignw ";
    1042           4 :       break;
    1043           7 :     case 4:
    1044           7 :       OS << ".p2alignl ";
    1045           7 :       break;
    1046           0 :     case 8:
    1047           0 :       llvm_unreachable("Unsupported alignment size!");
    1048             :     }
    1049             : 
    1050      206370 :     OS << Log2_32(ByteAlignment);
    1051             : 
    1052      206370 :     if (Value || MaxBytesToEmit) {
    1053       92055 :       OS << ", 0x";
    1054      184110 :       OS.write_hex(truncateToSize(Value, ValueSize));
    1055             : 
    1056       92055 :       if (MaxBytesToEmit)
    1057           1 :         OS << ", " << MaxBytesToEmit;
    1058             :     }
    1059      206370 :     EmitEOL();
    1060      206370 :     return;
    1061             :   }
    1062             : 
    1063             :   // Non-power of two alignment.  This is not widely supported by assemblers.
    1064             :   // FIXME: Parameterize this based on MAI.
    1065           2 :   switch (ValueSize) {
    1066           0 :   default: llvm_unreachable("Invalid size for machine code value!");
    1067           2 :   case 1: OS << ".balign";  break;
    1068           0 :   case 2: OS << ".balignw"; break;
    1069           0 :   case 4: OS << ".balignl"; break;
    1070           0 :   case 8: llvm_unreachable("Unsupported alignment size!");
    1071             :   }
    1072             : 
    1073           2 :   OS << ' ' << ByteAlignment;
    1074           4 :   OS << ", " << truncateToSize(Value, ValueSize);
    1075           2 :   if (MaxBytesToEmit)
    1076           0 :     OS << ", " << MaxBytesToEmit;
    1077           2 :   EmitEOL();
    1078             : }
    1079             : 
    1080      177285 : void MCAsmStreamer::EmitCodeAlignment(unsigned ByteAlignment,
    1081             :                                       unsigned MaxBytesToEmit) {
    1082             :   // Emit with a text fill value.
    1083      177285 :   EmitValueToAlignment(ByteAlignment, MAI->getTextAlignFillValue(),
    1084             :                        1, MaxBytesToEmit);
    1085      177285 : }
    1086             : 
    1087           9 : void MCAsmStreamer::emitValueToOffset(const MCExpr *Offset,
    1088             :                                       unsigned char Value,
    1089             :                                       SMLoc Loc) {
    1090             :   // FIXME: Verify that Offset is associated with the current section.
    1091           9 :   OS << ".org ";
    1092           9 :   Offset->print(OS, MAI);
    1093           9 :   OS << ", " << (unsigned)Value;
    1094           9 :   EmitEOL();
    1095           9 : }
    1096             : 
    1097       13201 : void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
    1098             :   assert(MAI->hasSingleParameterDotFile());
    1099       13201 :   OS << "\t.file\t";
    1100       13201 :   PrintQuotedString(Filename, OS);
    1101       13201 :   EmitEOL();
    1102       13201 : }
    1103             : 
    1104         368 : static void printDwarfFileDirective(unsigned FileNo, StringRef Directory,
    1105             :                                     StringRef Filename,
    1106             :                                     MD5::MD5Result *Checksum,
    1107             :                                     Optional<StringRef> Source,
    1108             :                                     bool UseDwarfDirectory,
    1109             :                                     raw_svector_ostream &OS) {
    1110             :   SmallString<128> FullPathName;
    1111             : 
    1112         368 :   if (!UseDwarfDirectory && !Directory.empty()) {
    1113         295 :     if (sys::path::is_absolute(Filename))
    1114             :       Directory = "";
    1115             :     else {
    1116             :       FullPathName = Directory;
    1117         248 :       sys::path::append(FullPathName, Filename);
    1118             :       Directory = "";
    1119         248 :       Filename = FullPathName;
    1120             :     }
    1121             :   }
    1122             : 
    1123         368 :   OS << "\t.file\t" << FileNo << ' ';
    1124         368 :   if (!Directory.empty()) {
    1125          36 :     PrintQuotedString(Directory, OS);
    1126             :     OS << ' ';
    1127             :   }
    1128         368 :   PrintQuotedString(Filename, OS);
    1129         368 :   if (Checksum)
    1130          12 :     OS << " md5 0x" << Checksum->digest();
    1131         368 :   if (Source) {
    1132           6 :     OS << " source ";
    1133           6 :     PrintQuotedString(*Source, OS);
    1134             :   }
    1135         368 : }
    1136             : 
    1137        3218 : Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
    1138             :     unsigned FileNo, StringRef Directory, StringRef Filename,
    1139             :     MD5::MD5Result *Checksum, Optional<StringRef> Source, unsigned CUID) {
    1140             :   assert(CUID == 0 && "multiple CUs not supported by MCAsmStreamer");
    1141             : 
    1142        3218 :   MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
    1143             :   unsigned NumFiles = Table.getMCDwarfFiles().size();
    1144             :   Expected<unsigned> FileNoOrErr =
    1145        3218 :       Table.tryGetFile(Directory, Filename, Checksum, Source, FileNo);
    1146        3218 :   if (!FileNoOrErr)
    1147             :     return FileNoOrErr.takeError();
    1148        3218 :   FileNo = FileNoOrErr.get();
    1149        3218 :   if (NumFiles == Table.getMCDwarfFiles().size())
    1150             :     return FileNo;
    1151             : 
    1152             :   SmallString<128> Str;
    1153             :   raw_svector_ostream OS1(Str);
    1154         730 :   printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source,
    1155         365 :                           UseDwarfDirectory, OS1);
    1156             : 
    1157         365 :   if (MCTargetStreamer *TS = getTargetStreamer())
    1158         722 :     TS->emitDwarfFileDirective(OS1.str());
    1159             :   else
    1160          12 :     EmitRawText(OS1.str());
    1161             : 
    1162             :   return FileNo;
    1163             : }
    1164             : 
    1165         282 : void MCAsmStreamer::emitDwarfFile0Directive(StringRef Directory,
    1166             :                                             StringRef Filename,
    1167             :                                             MD5::MD5Result *Checksum,
    1168             :                                             Optional<StringRef> Source,
    1169             :                                             unsigned CUID) {
    1170             :   assert(CUID == 0);
    1171             :   // .file 0 is new for DWARF v5.
    1172         282 :   if (getContext().getDwarfVersion() < 5)
    1173         279 :     return;
    1174             :   // Inform MCDwarf about the root file.
    1175           3 :   getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
    1176             :                                       Source);
    1177             : 
    1178             :   SmallString<128> Str;
    1179             :   raw_svector_ostream OS1(Str);
    1180           6 :   printDwarfFileDirective(0, Directory, Filename, Checksum, Source,
    1181           3 :                           UseDwarfDirectory, OS1);
    1182             : 
    1183           3 :   if (MCTargetStreamer *TS = getTargetStreamer())
    1184           6 :     TS->emitDwarfFileDirective(OS1.str());
    1185             :   else
    1186           0 :     EmitRawText(OS1.str());
    1187             : }
    1188             : 
    1189        1391 : void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
    1190             :                                           unsigned Column, unsigned Flags,
    1191             :                                           unsigned Isa,
    1192             :                                           unsigned Discriminator,
    1193             :                                           StringRef FileName) {
    1194        4173 :   OS << "\t.loc\t" << FileNo << " " << Line << " " << Column;
    1195        1391 :   if (MAI->supportsExtendedDwarfLocDirective()) {
    1196        1359 :     if (Flags & DWARF2_FLAG_BASIC_BLOCK)
    1197           0 :       OS << " basic_block";
    1198        1359 :     if (Flags & DWARF2_FLAG_PROLOGUE_END)
    1199         315 :       OS << " prologue_end";
    1200        1359 :     if (Flags & DWARF2_FLAG_EPILOGUE_BEGIN)
    1201           0 :       OS << " epilogue_begin";
    1202             : 
    1203        1359 :     unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
    1204        1359 :     if ((Flags & DWARF2_FLAG_IS_STMT) != (OldFlags & DWARF2_FLAG_IS_STMT)) {
    1205         293 :       OS << " is_stmt ";
    1206             : 
    1207         293 :       if (Flags & DWARF2_FLAG_IS_STMT)
    1208         125 :         OS << "1";
    1209             :       else
    1210         168 :         OS << "0";
    1211             :     }
    1212             : 
    1213        1359 :     if (Isa)
    1214           1 :       OS << " isa " << Isa;
    1215        1359 :     if (Discriminator)
    1216           6 :       OS << " discriminator " << Discriminator;
    1217             :   }
    1218             : 
    1219        1391 :   if (IsVerboseAsm) {
    1220        1257 :     OS.PadToColumn(MAI->getCommentColumn());
    1221        2514 :     OS << MAI->getCommentString() << ' ' << FileName << ':'
    1222             :        << Line << ':' << Column;
    1223             :   }
    1224        1391 :   EmitEOL();
    1225        1391 :   this->MCStreamer::EmitDwarfLocDirective(FileNo, Line, Column, Flags,
    1226             :                                           Isa, Discriminator, FileName);
    1227        1391 : }
    1228             : 
    1229         301 : MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(unsigned CUID) {
    1230             :   // Always use the zeroth line table, since asm syntax only supports one line
    1231             :   // table for now.
    1232         301 :   return MCStreamer::getDwarfLineTableSymbol(0);
    1233             : }
    1234             : 
    1235          66 : bool MCAsmStreamer::EmitCVFileDirective(unsigned FileNo, StringRef Filename,
    1236             :                                         ArrayRef<uint8_t> Checksum,
    1237             :                                         unsigned ChecksumKind) {
    1238          66 :   if (!getContext().getCVContext().addFile(*this, FileNo, Filename, Checksum,
    1239             :                                            ChecksumKind))
    1240             :     return false;
    1241             : 
    1242          66 :   OS << "\t.cv_file\t" << FileNo << ' ';
    1243          66 :   PrintQuotedString(Filename, OS);
    1244             : 
    1245          66 :   if (!ChecksumKind) {
    1246          27 :     EmitEOL();
    1247          27 :     return true;
    1248             :   }
    1249             : 
    1250          39 :   OS << ' ';
    1251         117 :   PrintQuotedString(toHex(Checksum), OS);
    1252          39 :   OS << ' ' << ChecksumKind;
    1253             : 
    1254          39 :   EmitEOL();
    1255          39 :   return true;
    1256             : }
    1257             : 
    1258         104 : bool MCAsmStreamer::EmitCVFuncIdDirective(unsigned FuncId) {
    1259         104 :   OS << "\t.cv_func_id " << FuncId << '\n';
    1260         104 :   return MCStreamer::EmitCVFuncIdDirective(FuncId);
    1261             : }
    1262             : 
    1263           9 : bool MCAsmStreamer::EmitCVInlineSiteIdDirective(unsigned FunctionId,
    1264             :                                                 unsigned IAFunc,
    1265             :                                                 unsigned IAFile,
    1266             :                                                 unsigned IALine, unsigned IACol,
    1267             :                                                 SMLoc Loc) {
    1268          18 :   OS << "\t.cv_inline_site_id " << FunctionId << " within " << IAFunc
    1269           9 :      << " inlined_at " << IAFile << ' ' << IALine << ' ' << IACol << '\n';
    1270           9 :   return MCStreamer::EmitCVInlineSiteIdDirective(FunctionId, IAFunc, IAFile,
    1271           9 :                                                  IALine, IACol, Loc);
    1272             : }
    1273             : 
    1274         416 : void MCAsmStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
    1275             :                                        unsigned Line, unsigned Column,
    1276             :                                        bool PrologueEnd, bool IsStmt,
    1277             :                                        StringRef FileName, SMLoc Loc) {
    1278        1664 :   OS << "\t.cv_loc\t" << FunctionId << " " << FileNo << " " << Line << " "
    1279             :      << Column;
    1280         416 :   if (PrologueEnd)
    1281           0 :     OS << " prologue_end";
    1282             : 
    1283         416 :   unsigned OldIsStmt = getContext().getCVContext().getCurrentCVLoc().isStmt();
    1284         416 :   if (IsStmt != OldIsStmt) {
    1285          59 :     OS << " is_stmt ";
    1286             : 
    1287          59 :     if (IsStmt)
    1288           0 :       OS << "1";
    1289             :     else
    1290          59 :       OS << "0";
    1291             :   }
    1292             : 
    1293         416 :   if (IsVerboseAsm) {
    1294         416 :     OS.PadToColumn(MAI->getCommentColumn());
    1295         832 :     OS << MAI->getCommentString() << ' ' << FileName << ':' << Line << ':'
    1296             :        << Column;
    1297             :   }
    1298         416 :   EmitEOL();
    1299         416 :   this->MCStreamer::EmitCVLocDirective(FunctionId, FileNo, Line, Column,
    1300             :                                        PrologueEnd, IsStmt, FileName, Loc);
    1301         416 : }
    1302             : 
    1303          98 : void MCAsmStreamer::EmitCVLinetableDirective(unsigned FunctionId,
    1304             :                                              const MCSymbol *FnStart,
    1305             :                                              const MCSymbol *FnEnd) {
    1306         196 :   OS << "\t.cv_linetable\t" << FunctionId << ", ";
    1307          98 :   FnStart->print(OS, MAI);
    1308          98 :   OS << ", ";
    1309          98 :   FnEnd->print(OS, MAI);
    1310          98 :   EmitEOL();
    1311          98 :   this->MCStreamer::EmitCVLinetableDirective(FunctionId, FnStart, FnEnd);
    1312          98 : }
    1313             : 
    1314           7 : void MCAsmStreamer::EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
    1315             :                                                    unsigned SourceFileId,
    1316             :                                                    unsigned SourceLineNum,
    1317             :                                                    const MCSymbol *FnStartSym,
    1318             :                                                    const MCSymbol *FnEndSym) {
    1319           7 :   OS << "\t.cv_inline_linetable\t" << PrimaryFunctionId << ' ' << SourceFileId
    1320             :      << ' ' << SourceLineNum << ' ';
    1321           7 :   FnStartSym->print(OS, MAI);
    1322           7 :   OS << ' ';
    1323           7 :   FnEndSym->print(OS, MAI);
    1324           7 :   EmitEOL();
    1325           7 :   this->MCStreamer::EmitCVInlineLinetableDirective(
    1326             :       PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
    1327           7 : }
    1328             : 
    1329         112 : void MCAsmStreamer::EmitCVDefRangeDirective(
    1330             :     ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
    1331             :     StringRef FixedSizePortion) {
    1332         112 :   OS << "\t.cv_def_range\t";
    1333         342 :   for (std::pair<const MCSymbol *, const MCSymbol *> Range : Ranges) {
    1334         115 :     OS << ' ';
    1335         115 :     Range.first->print(OS, MAI);
    1336         115 :     OS << ' ';
    1337         115 :     Range.second->print(OS, MAI);
    1338             :   }
    1339         112 :   OS << ", ";
    1340         112 :   PrintQuotedString(FixedSizePortion, OS);
    1341         112 :   EmitEOL();
    1342         112 :   this->MCStreamer::EmitCVDefRangeDirective(Ranges, FixedSizePortion);
    1343         112 : }
    1344             : 
    1345          63 : void MCAsmStreamer::EmitCVStringTableDirective() {
    1346          63 :   OS << "\t.cv_stringtable";
    1347          63 :   EmitEOL();
    1348          63 : }
    1349             : 
    1350          61 : void MCAsmStreamer::EmitCVFileChecksumsDirective() {
    1351          61 :   OS << "\t.cv_filechecksums";
    1352          61 :   EmitEOL();
    1353          61 : }
    1354             : 
    1355           6 : void MCAsmStreamer::EmitCVFileChecksumOffsetDirective(unsigned FileNo) {
    1356           6 :   OS << "\t.cv_filechecksumoffset\t" << FileNo;
    1357           6 :   EmitEOL();
    1358           6 : }
    1359             : 
    1360          64 : void MCAsmStreamer::EmitCVFPOData(const MCSymbol *ProcSym, SMLoc L) {
    1361          64 :   OS << "\t.cv_fpo_data\t";
    1362          64 :   ProcSym->print(OS, MAI);
    1363          64 :   EmitEOL();
    1364          64 : }
    1365             : 
    1366         345 : void MCAsmStreamer::EmitIdent(StringRef IdentString) {
    1367             :   assert(MAI->hasIdentDirective() && ".ident directive not supported");
    1368         345 :   OS << "\t.ident\t";
    1369         345 :   PrintQuotedString(IdentString, OS);
    1370         345 :   EmitEOL();
    1371         345 : }
    1372             : 
    1373         129 : void MCAsmStreamer::EmitCFISections(bool EH, bool Debug) {
    1374         129 :   MCStreamer::EmitCFISections(EH, Debug);
    1375         129 :   OS << "\t.cfi_sections ";
    1376         129 :   if (EH) {
    1377           0 :     OS << ".eh_frame";
    1378           0 :     if (Debug)
    1379           0 :       OS << ", .debug_frame";
    1380         129 :   } else if (Debug) {
    1381         129 :     OS << ".debug_frame";
    1382             :   }
    1383             : 
    1384         129 :   EmitEOL();
    1385         129 : }
    1386             : 
    1387      102926 : void MCAsmStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
    1388      102926 :   OS << "\t.cfi_startproc";
    1389      102926 :   if (Frame.IsSimple)
    1390           2 :     OS << " simple";
    1391      102926 :   EmitEOL();
    1392      102926 : }
    1393             : 
    1394      102924 : void MCAsmStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
    1395      102924 :   MCStreamer::EmitCFIEndProcImpl(Frame);
    1396      102924 :   OS << "\t.cfi_endproc";
    1397      102924 :   EmitEOL();
    1398      102924 : }
    1399             : 
    1400       21356 : void MCAsmStreamer::EmitRegisterName(int64_t Register) {
    1401       21356 :   if (!MAI->useDwarfRegNumForCFI()) {
    1402             :     // User .cfi_* directives can use arbitrary DWARF register numbers, not
    1403             :     // just ones that map to LLVM register numbers and have known names.
    1404             :     // Fall back to using the original number directly if no name is known.
    1405       18440 :     const MCRegisterInfo *MRI = getContext().getRegisterInfo();
    1406       18440 :     int LLVMRegister = MRI->getLLVMRegNumFromEH(Register);
    1407       18440 :     if (LLVMRegister != -1) {
    1408       18439 :       InstPrinter->printRegName(OS, LLVMRegister);
    1409       18439 :       return;
    1410             :     }
    1411             :   }
    1412        2917 :   OS << Register;
    1413             : }
    1414             : 
    1415        2216 : void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) {
    1416        2216 :   MCStreamer::EmitCFIDefCfa(Register, Offset);
    1417        2216 :   OS << "\t.cfi_def_cfa ";
    1418        2216 :   EmitRegisterName(Register);
    1419        2216 :   OS << ", " << Offset;
    1420        2216 :   EmitEOL();
    1421        2216 : }
    1422             : 
    1423       14497 : void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) {
    1424       14497 :   MCStreamer::EmitCFIDefCfaOffset(Offset);
    1425       14497 :   OS << "\t.cfi_def_cfa_offset " << Offset;
    1426       14497 :   EmitEOL();
    1427       14497 : }
    1428             : 
    1429          19 : static void PrintCFIEscape(llvm::formatted_raw_ostream &OS, StringRef Values) {
    1430          19 :   OS << "\t.cfi_escape ";
    1431          19 :   if (!Values.empty()) {
    1432          19 :     size_t e = Values.size() - 1;
    1433          57 :     for (size_t i = 0; i < e; ++i)
    1434          38 :       OS << format("0x%02x", uint8_t(Values[i])) << ", ";
    1435          38 :     OS << format("0x%02x", uint8_t(Values[e]));
    1436             :   }
    1437          19 : }
    1438             : 
    1439           0 : void MCAsmStreamer::EmitCFIEscape(StringRef Values) {
    1440           0 :   MCStreamer::EmitCFIEscape(Values);
    1441           0 :   PrintCFIEscape(OS, Values);
    1442           0 :   EmitEOL();
    1443           0 : }
    1444             : 
    1445          19 : void MCAsmStreamer::EmitCFIGnuArgsSize(int64_t Size) {
    1446          19 :   MCStreamer::EmitCFIGnuArgsSize(Size);
    1447             : 
    1448          19 :   uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
    1449          19 :   unsigned Len = encodeULEB128(Size, Buffer + 1) + 1;
    1450             : 
    1451          38 :   PrintCFIEscape(OS, StringRef((const char *)&Buffer[0], Len));
    1452          19 :   EmitEOL();
    1453          19 : }
    1454             : 
    1455        1407 : void MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) {
    1456        1407 :   MCStreamer::EmitCFIDefCfaRegister(Register);
    1457        1407 :   OS << "\t.cfi_def_cfa_register ";
    1458        1407 :   EmitRegisterName(Register);
    1459        1407 :   EmitEOL();
    1460        1407 : }
    1461             : 
    1462       17706 : void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
    1463       17706 :   this->MCStreamer::EmitCFIOffset(Register, Offset);
    1464       17706 :   OS << "\t.cfi_offset ";
    1465       17706 :   EmitRegisterName(Register);
    1466       17706 :   OS << ", " << Offset;
    1467       17706 :   EmitEOL();
    1468       17706 : }
    1469             : 
    1470         201 : void MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
    1471             :                                        unsigned Encoding) {
    1472         201 :   MCStreamer::EmitCFIPersonality(Sym, Encoding);
    1473         402 :   OS << "\t.cfi_personality " << Encoding << ", ";
    1474         201 :   Sym->print(OS, MAI);
    1475         201 :   EmitEOL();
    1476         201 : }
    1477             : 
    1478         201 : void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
    1479         201 :   MCStreamer::EmitCFILsda(Sym, Encoding);
    1480         402 :   OS << "\t.cfi_lsda " << Encoding << ", ";
    1481         201 :   Sym->print(OS, MAI);
    1482         201 :   EmitEOL();
    1483         201 : }
    1484             : 
    1485          28 : void MCAsmStreamer::EmitCFIRememberState() {
    1486          28 :   MCStreamer::EmitCFIRememberState();
    1487          28 :   OS << "\t.cfi_remember_state";
    1488          28 :   EmitEOL();
    1489          28 : }
    1490             : 
    1491          28 : void MCAsmStreamer::EmitCFIRestoreState() {
    1492          28 :   MCStreamer::EmitCFIRestoreState();
    1493          28 :   OS << "\t.cfi_restore_state";
    1494          28 :   EmitEOL();
    1495          28 : }
    1496             : 
    1497           4 : void MCAsmStreamer::EmitCFIRestore(int64_t Register) {
    1498           4 :   MCStreamer::EmitCFIRestore(Register);
    1499           4 :   OS << "\t.cfi_restore ";
    1500           4 :   EmitRegisterName(Register);
    1501           4 :   EmitEOL();
    1502           4 : }
    1503             : 
    1504           2 : void MCAsmStreamer::EmitCFISameValue(int64_t Register) {
    1505           2 :   MCStreamer::EmitCFISameValue(Register);
    1506           2 :   OS << "\t.cfi_same_value ";
    1507           2 :   EmitRegisterName(Register);
    1508           2 :   EmitEOL();
    1509           2 : }
    1510             : 
    1511          21 : void MCAsmStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) {
    1512          21 :   MCStreamer::EmitCFIRelOffset(Register, Offset);
    1513          21 :   OS << "\t.cfi_rel_offset ";
    1514          21 :   EmitRegisterName(Register);
    1515          21 :   OS << ", " << Offset;
    1516          21 :   EmitEOL();
    1517          21 : }
    1518             : 
    1519        1690 : void MCAsmStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) {
    1520        1690 :   MCStreamer::EmitCFIAdjustCfaOffset(Adjustment);
    1521        1690 :   OS << "\t.cfi_adjust_cfa_offset " << Adjustment;
    1522        1690 :   EmitEOL();
    1523        1690 : }
    1524             : 
    1525           0 : void MCAsmStreamer::EmitCFISignalFrame() {
    1526           0 :   MCStreamer::EmitCFISignalFrame();
    1527           0 :   OS << "\t.cfi_signal_frame";
    1528           0 :   EmitEOL();
    1529           0 : }
    1530             : 
    1531           0 : void MCAsmStreamer::EmitCFIUndefined(int64_t Register) {
    1532           0 :   MCStreamer::EmitCFIUndefined(Register);
    1533           0 :   OS << "\t.cfi_undefined " << Register;
    1534           0 :   EmitEOL();
    1535           0 : }
    1536             : 
    1537         384 : void MCAsmStreamer::EmitCFIRegister(int64_t Register1, int64_t Register2) {
    1538         384 :   MCStreamer::EmitCFIRegister(Register1, Register2);
    1539         384 :   OS << "\t.cfi_register " << Register1 << ", " << Register2;
    1540         384 :   EmitEOL();
    1541         384 : }
    1542             : 
    1543         383 : void MCAsmStreamer::EmitCFIWindowSave() {
    1544         383 :   MCStreamer::EmitCFIWindowSave();
    1545         383 :   OS << "\t.cfi_window_save";
    1546         383 :   EmitEOL();
    1547         383 : }
    1548             : 
    1549           3 : void MCAsmStreamer::EmitCFIReturnColumn(int64_t Register) {
    1550           3 :   MCStreamer::EmitCFIReturnColumn(Register);
    1551           3 :   OS << "\t.cfi_return_column " << Register;
    1552           3 :   EmitEOL();
    1553           3 : }
    1554             : 
    1555         452 : void MCAsmStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc) {
    1556         452 :   MCStreamer::EmitWinCFIStartProc(Symbol, Loc);
    1557             : 
    1558         452 :   OS << ".seh_proc ";
    1559         452 :   Symbol->print(OS, MAI);
    1560         452 :   EmitEOL();
    1561         452 : }
    1562             : 
    1563         451 : void MCAsmStreamer::EmitWinCFIEndProc(SMLoc Loc) {
    1564         451 :   MCStreamer::EmitWinCFIEndProc(Loc);
    1565             : 
    1566         451 :   OS << "\t.seh_endproc";
    1567         451 :   EmitEOL();
    1568         451 : }
    1569             : 
    1570           1 : void MCAsmStreamer::EmitWinCFIStartChained(SMLoc Loc) {
    1571           1 :   MCStreamer::EmitWinCFIStartChained(Loc);
    1572             : 
    1573           1 :   OS << "\t.seh_startchained";
    1574           1 :   EmitEOL();
    1575           1 : }
    1576             : 
    1577           1 : void MCAsmStreamer::EmitWinCFIEndChained(SMLoc Loc) {
    1578           1 :   MCStreamer::EmitWinCFIEndChained(Loc);
    1579             : 
    1580           1 :   OS << "\t.seh_endchained";
    1581           1 :   EmitEOL();
    1582           1 : }
    1583             : 
    1584         130 : void MCAsmStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind,
    1585             :                                      bool Except, SMLoc Loc) {
    1586         130 :   MCStreamer::EmitWinEHHandler(Sym, Unwind, Except, Loc);
    1587             : 
    1588         130 :   OS << "\t.seh_handler ";
    1589         130 :   Sym->print(OS, MAI);
    1590         130 :   if (Unwind)
    1591         129 :     OS << ", @unwind";
    1592         130 :   if (Except)
    1593         130 :     OS << ", @except";
    1594         130 :   EmitEOL();
    1595         130 : }
    1596             : 
    1597         451 : void MCAsmStreamer::EmitWinEHHandlerData(SMLoc Loc) {
    1598         451 :   MCStreamer::EmitWinEHHandlerData(Loc);
    1599             : 
    1600             :   // Switch sections. Don't call SwitchSection directly, because that will
    1601             :   // cause the section switch to be visible in the emitted assembly.
    1602             :   // We only do this so the section switch that terminates the handler
    1603             :   // data block is visible.
    1604         451 :   WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo();
    1605         451 :   MCSection *TextSec = &CurFrame->Function->getSection();
    1606         451 :   MCSection *XData = getAssociatedXDataSection(TextSec);
    1607             :   SwitchSectionNoChange(XData);
    1608             : 
    1609         451 :   OS << "\t.seh_handlerdata";
    1610         451 :   EmitEOL();
    1611         451 : }
    1612             : 
    1613         363 : void MCAsmStreamer::EmitWinCFIPushReg(unsigned Register, SMLoc Loc) {
    1614         363 :   MCStreamer::EmitWinCFIPushReg(Register, Loc);
    1615             : 
    1616         363 :   OS << "\t.seh_pushreg " << Register;
    1617         363 :   EmitEOL();
    1618         363 : }
    1619             : 
    1620          90 : void MCAsmStreamer::EmitWinCFISetFrame(unsigned Register, unsigned Offset,
    1621             :                                        SMLoc Loc) {
    1622          90 :   MCStreamer::EmitWinCFISetFrame(Register, Offset, Loc);
    1623             : 
    1624         180 :   OS << "\t.seh_setframe " << Register << ", " << Offset;
    1625          90 :   EmitEOL();
    1626          90 : }
    1627             : 
    1628         422 : void MCAsmStreamer::EmitWinCFIAllocStack(unsigned Size, SMLoc Loc) {
    1629         422 :   MCStreamer::EmitWinCFIAllocStack(Size, Loc);
    1630             : 
    1631         422 :   OS << "\t.seh_stackalloc " << Size;
    1632         422 :   EmitEOL();
    1633         422 : }
    1634             : 
    1635           1 : void MCAsmStreamer::EmitWinCFISaveReg(unsigned Register, unsigned Offset,
    1636             :                                       SMLoc Loc) {
    1637           1 :   MCStreamer::EmitWinCFISaveReg(Register, Offset, Loc);
    1638             : 
    1639           2 :   OS << "\t.seh_savereg " << Register << ", " << Offset;
    1640           1 :   EmitEOL();
    1641           1 : }
    1642             : 
    1643         142 : void MCAsmStreamer::EmitWinCFISaveXMM(unsigned Register, unsigned Offset,
    1644             :                                       SMLoc Loc) {
    1645         142 :   MCStreamer::EmitWinCFISaveXMM(Register, Offset, Loc);
    1646             : 
    1647         284 :   OS << "\t.seh_savexmm " << Register << ", " << Offset;
    1648         142 :   EmitEOL();
    1649         142 : }
    1650             : 
    1651           1 : void MCAsmStreamer::EmitWinCFIPushFrame(bool Code, SMLoc Loc) {
    1652           1 :   MCStreamer::EmitWinCFIPushFrame(Code, Loc);
    1653             : 
    1654           1 :   OS << "\t.seh_pushframe";
    1655           1 :   if (Code)
    1656           1 :     OS << " @code";
    1657           1 :   EmitEOL();
    1658           1 : }
    1659             : 
    1660         450 : void MCAsmStreamer::EmitWinCFIEndProlog(SMLoc Loc) {
    1661         450 :   MCStreamer::EmitWinCFIEndProlog(Loc);
    1662             : 
    1663         450 :   OS << "\t.seh_endprologue";
    1664         450 :   EmitEOL();
    1665         450 : }
    1666             : 
    1667           3 : void MCAsmStreamer::emitCGProfileEntry(const MCSymbolRefExpr *From,
    1668             :                                        const MCSymbolRefExpr *To,
    1669             :                                        uint64_t Count) {
    1670           3 :   OS << "\t.cg_profile ";
    1671           3 :   From->getSymbol().print(OS, MAI);
    1672           3 :   OS << ", ";
    1673           3 :   To->getSymbol().print(OS, MAI);
    1674           3 :   OS << ", " << Count;
    1675           3 :   EmitEOL();
    1676           3 : }
    1677             : 
    1678     1949293 : void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
    1679             :                                        const MCSubtargetInfo &STI,
    1680             :                                        bool PrintSchedInfo) {
    1681             :   raw_ostream &OS = GetCommentOS();
    1682             :   SmallString<256> Code;
    1683             :   SmallVector<MCFixup, 4> Fixups;
    1684             :   raw_svector_ostream VecOS(Code);
    1685             : 
    1686             :   // If we have no code emitter, don't emit code.
    1687     1949293 :   if (!getAssembler().getEmitterPtr())
    1688             :     return;
    1689             : 
    1690      434249 :   getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
    1691             : 
    1692             :   // If we are showing fixups, create symbolic markers in the encoded
    1693             :   // representation. We do this by making a per-bit map to the fixup item index,
    1694             :   // then trying to display it as nicely as possible.
    1695             :   SmallVector<uint8_t, 64> FixupMap;
    1696      434248 :   FixupMap.resize(Code.size() * 8);
    1697    22208392 :   for (unsigned i = 0, e = Code.size() * 8; i != e; ++i)
    1698    43548288 :     FixupMap[i] = 0;
    1699             : 
    1700      439881 :   for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
    1701        5633 :     MCFixup &F = Fixups[i];
    1702             :     const MCFixupKindInfo &Info =
    1703        5633 :         getAssembler().getBackend().getFixupKindInfo(F.getKind());
    1704      210115 :     for (unsigned j = 0; j != Info.TargetSize; ++j) {
    1705      102241 :       unsigned Index = F.getOffset() * 8 + Info.TargetOffset + j;
    1706             :       assert(Index < Code.size() * 8 && "Invalid offset in fixup!");
    1707      204482 :       FixupMap[Index] = 1 + i;
    1708             :     }
    1709             :   }
    1710             : 
    1711             :   // FIXME: Note the fixup comments for Thumb2 are completely bogus since the
    1712             :   // high order halfword of a 32-bit Thumb2 instruction is emitted first.
    1713      434248 :   OS << "encoding: [";
    1714     3156016 :   for (unsigned i = 0, e = Code.size(); i != e; ++i) {
    1715     2721768 :     if (i)
    1716             :       OS << ',';
    1717             : 
    1718             :     // See if all bits are the same map entry.
    1719     5443536 :     uint8_t MapEntry = FixupMap[i * 8 + 0];
    1720    40807650 :     for (unsigned j = 1; j != 8; ++j) {
    1721    38090534 :       if (FixupMap[i * 8 + j] == MapEntry)
    1722             :         continue;
    1723             : 
    1724             :       MapEntry = uint8_t(~0U);
    1725             :       break;
    1726             :     }
    1727             : 
    1728     2721768 :     if (MapEntry != uint8_t(~0U)) {
    1729     2719442 :       if (MapEntry == 0) {
    1730     8124342 :         OS << format("0x%02x", uint8_t(Code[i]));
    1731             :       } else {
    1732       22656 :         if (Code[i]) {
    1733             :           // FIXME: Some of the 8 bits require fix up.
    1734        1377 :           OS << format("0x%02x", uint8_t(Code[i])) << '\''
    1735         459 :              << char('A' + MapEntry - 1) << '\'';
    1736             :         } else
    1737       10869 :           OS << char('A' + MapEntry - 1);
    1738             :       }
    1739             :     } else {
    1740             :       // Otherwise, write out in binary.
    1741        2326 :       OS << "0b";
    1742       20934 :       for (unsigned j = 8; j--;) {
    1743       37216 :         unsigned Bit = (Code[i] >> j) & 1;
    1744             : 
    1745             :         unsigned FixupBit;
    1746       18608 :         if (MAI->isLittleEndian())
    1747        9968 :           FixupBit = i * 8 + j;
    1748             :         else
    1749        8640 :           FixupBit = i * 8 + (7-j);
    1750             : 
    1751       37216 :         if (uint8_t MapEntry = FixupMap[FixupBit]) {
    1752             :           assert(Bit == 0 && "Encoder wrote into fixed up bit!");
    1753       11617 :           OS << char('A' + MapEntry - 1);
    1754             :         } else
    1755             :           OS << Bit;
    1756             :       }
    1757             :     }
    1758             :   }
    1759      434248 :   OS << "]";
    1760             :   // If we are not going to add fixup or schedule comments after this point
    1761             :   // then we have to end the current comment line with "\n".
    1762      434248 :   if (Fixups.size() || !PrintSchedInfo)
    1763      434248 :     OS << "\n";
    1764             : 
    1765      439881 :   for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
    1766        5633 :     MCFixup &F = Fixups[i];
    1767             :     const MCFixupKindInfo &Info =
    1768        5633 :         getAssembler().getBackend().getFixupKindInfo(F.getKind());
    1769       11266 :     OS << "  fixup " << char('A' + i) << " - " << "offset: " << F.getOffset()
    1770       11266 :        << ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n";
    1771             :   }
    1772             : }
    1773             : 
    1774     1949293 : void MCAsmStreamer::EmitInstruction(const MCInst &Inst,
    1775             :                                     const MCSubtargetInfo &STI,
    1776             :                                     bool PrintSchedInfo) {
    1777             :   assert(getCurrentSectionOnly() &&
    1778             :          "Cannot emit contents before setting section!");
    1779             : 
    1780             :   // Show the encoding in a comment if we have a code emitter.
    1781     1949293 :   AddEncodingComment(Inst, STI, PrintSchedInfo);
    1782             : 
    1783             :   // Show the MCInst if enabled.
    1784     1949292 :   if (ShowInst) {
    1785        8592 :     if (PrintSchedInfo)
    1786           0 :       GetCommentOS() << "\n";
    1787        8592 :     Inst.dump_pretty(GetCommentOS(), InstPrinter.get(), "\n ");
    1788        8592 :     GetCommentOS() << "\n";
    1789             :   }
    1790             : 
    1791     1949292 :   if(getTargetStreamer())
    1792     3585368 :     getTargetStreamer()->prettyPrintAsm(*InstPrinter, OS, Inst, STI);
    1793             :   else
    1794      313216 :     InstPrinter->printInst(&Inst, OS, "", STI);
    1795             : 
    1796     1949292 :   if (PrintSchedInfo) {
    1797       63182 :     std::string SI = STI.getSchedInfoStr(Inst);
    1798       63182 :     if (!SI.empty())
    1799             :       GetCommentOS() << SI;
    1800             :   }
    1801             : 
    1802             :   StringRef Comments = CommentToEmit;
    1803     2558742 :   if (Comments.size() && Comments.back() != '\n')
    1804      117380 :     GetCommentOS() << "\n";
    1805             : 
    1806     1949292 :   EmitEOL();
    1807     1949292 : }
    1808             : 
    1809           1 : void MCAsmStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
    1810           1 :   OS << "\t.bundle_align_mode " << AlignPow2;
    1811           1 :   EmitEOL();
    1812           1 : }
    1813             : 
    1814           4 : void MCAsmStreamer::EmitBundleLock(bool AlignToEnd) {
    1815           4 :   OS << "\t.bundle_lock";
    1816           4 :   if (AlignToEnd)
    1817           3 :     OS << " align_to_end";
    1818           4 :   EmitEOL();
    1819           4 : }
    1820             : 
    1821           2 : void MCAsmStreamer::EmitBundleUnlock() {
    1822           2 :   OS << "\t.bundle_unlock";
    1823           2 :   EmitEOL();
    1824           2 : }
    1825             : 
    1826         102 : bool MCAsmStreamer::EmitRelocDirective(const MCExpr &Offset, StringRef Name,
    1827             :                                        const MCExpr *Expr, SMLoc,
    1828             :                                        const MCSubtargetInfo &STI) {
    1829         102 :   OS << "\t.reloc ";
    1830         102 :   Offset.print(OS, MAI);
    1831         102 :   OS << ", " << Name;
    1832         102 :   if (Expr) {
    1833          99 :     OS << ", ";
    1834          99 :     Expr->print(OS, MAI);
    1835             :   }
    1836         102 :   EmitEOL();
    1837         102 :   return false;
    1838             : }
    1839             : 
    1840             : /// EmitRawText - If this file is backed by an assembly streamer, this dumps
    1841             : /// the specified string in the output .s file.  This capability is
    1842             : /// indicated by the hasRawTextSupport() predicate.
    1843      440044 : void MCAsmStreamer::EmitRawTextImpl(StringRef String) {
    1844      878490 :   if (!String.empty() && String.back() == '\n')
    1845        8514 :     String = String.substr(0, String.size()-1);
    1846      440044 :   OS << String;
    1847      440044 :   EmitEOL();
    1848      440044 : }
    1849             : 
    1850       19624 : void MCAsmStreamer::FinishImpl() {
    1851             :   // If we are generating dwarf for assembly source files dump out the sections.
    1852       19624 :   if (getContext().getGenDwarfForAssembly())
    1853           5 :     MCGenDwarfInfo::Emit(this);
    1854             : 
    1855             :   // Emit the label for the line table, if requested - since the rest of the
    1856             :   // line table will be defined by .loc/.file directives, and not emitted
    1857             :   // directly, the label is the only work required here.
    1858       19624 :   auto &Tables = getContext().getMCDwarfLineTables();
    1859       19624 :   if (!Tables.empty()) {
    1860             :     assert(Tables.size() == 1 && "asm output only supports one line table");
    1861         302 :     if (auto *Label = Tables.begin()->second.getLabel()) {
    1862         292 :       SwitchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
    1863         292 :       EmitLabel(Label);
    1864             :     }
    1865             :   }
    1866       19624 : }
    1867             : 
    1868       21346 : MCStreamer *llvm::createAsmStreamer(MCContext &Context,
    1869             :                                     std::unique_ptr<formatted_raw_ostream> OS,
    1870             :                                     bool isVerboseAsm, bool useDwarfDirectory,
    1871             :                                     MCInstPrinter *IP,
    1872             :                                     std::unique_ptr<MCCodeEmitter> &&CE,
    1873             :                                     std::unique_ptr<MCAsmBackend> &&MAB,
    1874             :                                     bool ShowInst) {
    1875             :   return new MCAsmStreamer(Context, std::move(OS), isVerboseAsm,
    1876             :                            useDwarfDirectory, IP, std::move(CE), std::move(MAB),
    1877       85384 :                            ShowInst);
    1878             : }

Generated by: LCOV version 1.13