LLVM  16.0.0git
MCAsmStreamer.cpp
Go to the documentation of this file.
1 //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/ADT/Optional.h"
10 #include "llvm/ADT/SmallString.h"
11 #include "llvm/ADT/StringExtras.h"
12 #include "llvm/ADT/Twine.h"
14 #include "llvm/MC/MCAsmBackend.h"
15 #include "llvm/MC/MCAsmInfo.h"
16 #include "llvm/MC/MCAssembler.h"
17 #include "llvm/MC/MCCodeEmitter.h"
18 #include "llvm/MC/MCCodeView.h"
19 #include "llvm/MC/MCContext.h"
20 #include "llvm/MC/MCExpr.h"
22 #include "llvm/MC/MCInst.h"
23 #include "llvm/MC/MCInstPrinter.h"
25 #include "llvm/MC/MCObjectWriter.h"
26 #include "llvm/MC/MCPseudoProbe.h"
27 #include "llvm/MC/MCRegister.h"
28 #include "llvm/MC/MCRegisterInfo.h"
29 #include "llvm/MC/MCSectionMachO.h"
30 #include "llvm/MC/MCStreamer.h"
31 #include "llvm/MC/MCSymbolXCOFF.h"
32 #include "llvm/MC/TargetRegistry.h"
33 #include "llvm/Support/Casting.h"
35 #include "llvm/Support/Format.h"
37 #include "llvm/Support/LEB128.h"
39 #include "llvm/Support/Path.h"
40 
41 using namespace llvm;
42 
43 namespace {
44 
45 class MCAsmStreamer final : public MCStreamer {
46  std::unique_ptr<formatted_raw_ostream> OSOwner;
48  const MCAsmInfo *MAI;
49  std::unique_ptr<MCInstPrinter> InstPrinter;
50  std::unique_ptr<MCAssembler> Assembler;
51 
52  SmallString<128> ExplicitCommentToEmit;
53  SmallString<128> CommentToEmit;
54  raw_svector_ostream CommentStream;
55  raw_null_ostream NullStream;
56 
57  unsigned IsVerboseAsm : 1;
58  unsigned ShowInst : 1;
59  unsigned UseDwarfDirectory : 1;
60 
61  void EmitRegisterName(int64_t Register);
62  void PrintQuotedString(StringRef Data, raw_ostream &OS) const;
63  void printDwarfFileDirective(unsigned FileNo, StringRef Directory,
64  StringRef Filename,
65  Optional<MD5::MD5Result> Checksum,
67  bool UseDwarfDirectory,
68  raw_svector_ostream &OS) const;
69  void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
70  void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
71 
72 public:
73  MCAsmStreamer(MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
74  bool isVerboseAsm, bool useDwarfDirectory,
75  MCInstPrinter *printer, std::unique_ptr<MCCodeEmitter> emitter,
76  std::unique_ptr<MCAsmBackend> asmbackend, bool showInst)
77  : MCStreamer(Context), OSOwner(std::move(os)), OS(*OSOwner),
78  MAI(Context.getAsmInfo()), InstPrinter(printer),
79  Assembler(std::make_unique<MCAssembler>(
80  Context, std::move(asmbackend), std::move(emitter),
81  (asmbackend) ? asmbackend->createObjectWriter(NullStream)
82  : nullptr)),
83  CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
84  ShowInst(showInst), UseDwarfDirectory(useDwarfDirectory) {
85  assert(InstPrinter);
86  if (IsVerboseAsm)
87  InstPrinter->setCommentStream(CommentStream);
88  if (Assembler->getBackendPtr())
89  setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
90 
91  Context.setUseNamesOnTempLabels(true);
92  }
93 
94  MCAssembler &getAssembler() { return *Assembler; }
95  MCAssembler *getAssemblerPtr() override { return nullptr; }
96 
97  inline void EmitEOL() {
98  // Dump Explicit Comments here.
99  emitExplicitComments();
100  // If we don't have any comments, just emit a \n.
101  if (!IsVerboseAsm) {
102  OS << '\n';
103  return;
104  }
105  EmitCommentsAndEOL();
106  }
107 
108  void emitSyntaxDirective() override;
109 
110  void EmitCommentsAndEOL();
111 
112  /// Return true if this streamer supports verbose assembly at all.
113  bool isVerboseAsm() const override { return IsVerboseAsm; }
114 
115  /// Do we support EmitRawText?
116  bool hasRawTextSupport() const override { return true; }
117 
118  /// Add a comment that can be emitted to the generated .s file to make the
119  /// output of the compiler more readable. This only affects the MCAsmStreamer
120  /// and only when verbose assembly output is enabled.
121  void AddComment(const Twine &T, bool EOL = true) override;
122 
123  /// Add a comment showing the encoding of an instruction.
124  void AddEncodingComment(const MCInst &Inst, const MCSubtargetInfo &);
125 
126  /// Return a raw_ostream that comments can be written to.
127  /// Unlike AddComment, you are required to terminate comments with \n if you
128  /// use this method.
129  raw_ostream &getCommentOS() override {
130  if (!IsVerboseAsm)
131  return nulls(); // Discard comments unless in verbose asm mode.
132  return CommentStream;
133  }
134 
135  void emitRawComment(const Twine &T, bool TabPrefix = true) override;
136 
137  void addExplicitComment(const Twine &T) override;
138  void emitExplicitComments() override;
139 
140  /// Emit a blank line to a .s file to pretty it up.
141  void addBlankLine() override { EmitEOL(); }
142 
143  /// @name MCStreamer Interface
144  /// @{
145 
146  void changeSection(MCSection *Section, const MCExpr *Subsection) override;
147 
148  void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name,
149  bool KeepOriginalSym) override;
150 
151  void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override;
152 
153  void emitGNUAttribute(unsigned Tag, unsigned Value) override;
154 
155  StringRef getMnemonic(MCInst &MI) override {
156  return InstPrinter->getMnemonic(&MI).first;
157  }
158 
159  void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
160 
161  void emitAssemblerFlag(MCAssemblerFlag Flag) override;
162  void emitLinkerOptions(ArrayRef<std::string> Options) override;
163  void emitDataRegion(MCDataRegionType Kind) override;
164  void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
165  unsigned Update, VersionTuple SDKVersion) override;
166  void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor,
167  unsigned Update, VersionTuple SDKVersion) override;
168  void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major,
169  unsigned Minor, unsigned Update,
170  VersionTuple SDKVersion) override;
171  void emitThumbFunc(MCSymbol *Func) override;
172 
173  void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
174  void emitConditionalAssignment(MCSymbol *Symbol,
175  const MCExpr *Value) override;
176  void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
177  bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
178 
179  void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
180  void beginCOFFSymbolDef(const MCSymbol *Symbol) override;
181  void emitCOFFSymbolStorageClass(int StorageClass) override;
182  void emitCOFFSymbolType(int Type) override;
183  void endCOFFSymbolDef() override;
184  void emitCOFFSafeSEH(MCSymbol const *Symbol) override;
185  void emitCOFFSymbolIndex(MCSymbol const *Symbol) override;
186  void emitCOFFSectionIndex(MCSymbol const *Symbol) override;
187  void emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
188  void emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override;
189  void emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym, uint64_t Size,
190  MCSymbol *CsectSym, Align Alignment) override;
191  void emitXCOFFSymbolLinkageWithVisibility(MCSymbol *Symbol,
192  MCSymbolAttr Linakge,
193  MCSymbolAttr Visibility) override;
194  void emitXCOFFRenameDirective(const MCSymbol *Name,
195  StringRef Rename) override;
196 
197  void emitXCOFFRefDirective(StringRef Name) override;
198 
199  void emitXCOFFExceptDirective(const MCSymbol *Symbol,
200  const MCSymbol *Trap,
201  unsigned Lang, unsigned Reason,
202  unsigned FunctionSize, bool hasDebug) override;
203 
204  void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
205  void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
206  unsigned ByteAlignment) override;
207 
208  /// Emit a local common (.lcomm) symbol.
209  ///
210  /// @param Symbol - The common symbol to emit.
211  /// @param Size - The size of the common symbol.
212  /// @param ByteAlignment - The alignment of the common symbol in bytes.
213  void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
214  unsigned ByteAlignment) override;
215 
216  void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
217  uint64_t Size = 0, unsigned ByteAlignment = 0,
218  SMLoc Loc = SMLoc()) override;
219 
220  void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
221  unsigned ByteAlignment = 0) override;
222 
223  void emitBinaryData(StringRef Data) override;
224 
225  void emitBytes(StringRef Data) override;
226 
227  void emitValueImpl(const MCExpr *Value, unsigned Size,
228  SMLoc Loc = SMLoc()) override;
229  void emitIntValue(uint64_t Value, unsigned Size) override;
230  void emitIntValueInHex(uint64_t Value, unsigned Size) override;
231  void emitIntValueInHexWithPadding(uint64_t Value, unsigned Size) override;
232 
233  void emitULEB128Value(const MCExpr *Value) override;
234 
235  void emitSLEB128Value(const MCExpr *Value) override;
236 
237  void emitDTPRel32Value(const MCExpr *Value) override;
238  void emitDTPRel64Value(const MCExpr *Value) override;
239  void emitTPRel32Value(const MCExpr *Value) override;
240  void emitTPRel64Value(const MCExpr *Value) override;
241 
242  void emitGPRel64Value(const MCExpr *Value) override;
243 
244  void emitGPRel32Value(const MCExpr *Value) override;
245 
246  void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
247  SMLoc Loc = SMLoc()) override;
248 
249  void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
250  SMLoc Loc = SMLoc()) override;
251 
252  void emitAlignmentDirective(unsigned ByteAlignment, Optional<int64_t> Value,
253  unsigned ValueSize, unsigned MaxBytesToEmit);
254 
255  void emitValueToAlignment(Align Alignment, int64_t Value = 0,
256  unsigned ValueSize = 1,
257  unsigned MaxBytesToEmit = 0) override;
258 
259  void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI,
260  unsigned MaxBytesToEmit = 0) override;
261 
262  void emitValueToOffset(const MCExpr *Offset,
263  unsigned char Value,
264  SMLoc Loc) override;
265 
266  void emitFileDirective(StringRef Filename) override;
267  void emitFileDirective(StringRef Filename, StringRef CompilerVerion,
268  StringRef TimeStamp, StringRef Description) override;
269  Expected<unsigned> tryEmitDwarfFileDirective(unsigned FileNo,
270  StringRef Directory,
271  StringRef Filename,
272  Optional<MD5::MD5Result> Checksum = None,
274  unsigned CUID = 0) override;
275  void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
276  Optional<MD5::MD5Result> Checksum,
278  unsigned CUID = 0) override;
279  void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column,
280  unsigned Flags, unsigned Isa,
281  unsigned Discriminator,
282  StringRef FileName) override;
283  MCSymbol *getDwarfLineTableSymbol(unsigned CUID) override;
284 
285  bool emitCVFileDirective(unsigned FileNo, StringRef Filename,
286  ArrayRef<uint8_t> Checksum,
287  unsigned ChecksumKind) override;
288  bool emitCVFuncIdDirective(unsigned FuncId) override;
289  bool emitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc,
290  unsigned IAFile, unsigned IALine,
291  unsigned IACol, SMLoc Loc) override;
292  void emitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line,
293  unsigned Column, bool PrologueEnd, bool IsStmt,
294  StringRef FileName, SMLoc Loc) override;
295  void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart,
296  const MCSymbol *FnEnd) override;
297  void emitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
298  unsigned SourceFileId,
299  unsigned SourceLineNum,
300  const MCSymbol *FnStartSym,
301  const MCSymbol *FnEndSym) override;
302 
303  void PrintCVDefRangePrefix(
304  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges);
305 
306  void emitCVDefRangeDirective(
307  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
308  codeview::DefRangeRegisterRelHeader DRHdr) override;
309 
310  void emitCVDefRangeDirective(
311  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
313 
314  void emitCVDefRangeDirective(
315  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
316  codeview::DefRangeRegisterHeader DRHdr) override;
317 
318  void emitCVDefRangeDirective(
319  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
321 
322  void emitCVStringTableDirective() override;
323  void emitCVFileChecksumsDirective() override;
324  void emitCVFileChecksumOffsetDirective(unsigned FileNo) override;
325  void emitCVFPOData(const MCSymbol *ProcSym, SMLoc L) override;
326 
327  void emitIdent(StringRef IdentString) override;
328  void emitCFIBKeyFrame() override;
329  void emitCFIMTETaggedFrame() override;
330  void emitCFISections(bool EH, bool Debug) override;
331  void emitCFIDefCfa(int64_t Register, int64_t Offset) override;
332  void emitCFIDefCfaOffset(int64_t Offset) override;
333  void emitCFIDefCfaRegister(int64_t Register) override;
334  void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset,
335  int64_t AddressSpace) override;
336  void emitCFIOffset(int64_t Register, int64_t Offset) override;
337  void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding) override;
338  void emitCFILsda(const MCSymbol *Sym, unsigned Encoding) override;
339  void emitCFIRememberState() override;
340  void emitCFIRestoreState() override;
341  void emitCFIRestore(int64_t Register) override;
342  void emitCFISameValue(int64_t Register) override;
343  void emitCFIRelOffset(int64_t Register, int64_t Offset) override;
344  void emitCFIAdjustCfaOffset(int64_t Adjustment) override;
345  void emitCFIEscape(StringRef Values) override;
346  void emitCFIGnuArgsSize(int64_t Size) override;
347  void emitCFISignalFrame() override;
348  void emitCFIUndefined(int64_t Register) override;
349  void emitCFIRegister(int64_t Register1, int64_t Register2) override;
350  void emitCFIWindowSave() override;
351  void emitCFINegateRAState() override;
352  void emitCFIReturnColumn(int64_t Register) override;
353 
354  void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc) override;
355  void emitWinCFIEndProc(SMLoc Loc) override;
356  void emitWinCFIFuncletOrFuncEnd(SMLoc Loc) override;
357  void emitWinCFIStartChained(SMLoc Loc) override;
358  void emitWinCFIEndChained(SMLoc Loc) override;
359  void emitWinCFIPushReg(MCRegister Register, SMLoc Loc) override;
360  void emitWinCFISetFrame(MCRegister Register, unsigned Offset,
361  SMLoc Loc) override;
362  void emitWinCFIAllocStack(unsigned Size, SMLoc Loc) override;
363  void emitWinCFISaveReg(MCRegister Register, unsigned Offset,
364  SMLoc Loc) override;
365  void emitWinCFISaveXMM(MCRegister Register, unsigned Offset,
366  SMLoc Loc) override;
367  void emitWinCFIPushFrame(bool Code, SMLoc Loc) override;
368  void emitWinCFIEndProlog(SMLoc Loc) override;
369 
370  void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except,
371  SMLoc Loc) override;
372  void emitWinEHHandlerData(SMLoc Loc) override;
373 
374  void emitCGProfileEntry(const MCSymbolRefExpr *From,
375  const MCSymbolRefExpr *To, uint64_t Count) override;
376 
377  void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
378 
379  void emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type,
380  uint64_t Attr,
381  const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym) override;
382 
383  void emitBundleAlignMode(Align Alignment) override;
384  void emitBundleLock(bool AlignToEnd) override;
385  void emitBundleUnlock() override;
386 
388  emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr,
389  SMLoc Loc, const MCSubtargetInfo &STI) override;
390 
391  void emitAddrsig() override;
392  void emitAddrsigSym(const MCSymbol *Sym) override;
393 
394  /// If this file is backed by an assembly streamer, this dumps the specified
395  /// string in the output .s file. This capability is indicated by the
396  /// hasRawTextSupport() predicate.
397  void emitRawTextImpl(StringRef String) override;
398 
399  void finishImpl() override;
400 
401  void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) override;
402 
403  MCSymbol *emitDwarfUnitLength(const Twine &Prefix,
404  const Twine &Comment) override;
405 
406  void emitDwarfLineStartLabel(MCSymbol *StartSym) override;
407 
408  void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel) override;
409 
410  void emitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel,
411  const MCSymbol *Label,
412  unsigned PointerSize) override;
413 
414  void doFinalizationAtSectionEnd(MCSection *Section) override;
415 };
416 
417 } // end anonymous namespace.
418 
419 void MCAsmStreamer::AddComment(const Twine &T, bool EOL) {
420  if (!IsVerboseAsm) return;
421 
422  T.toVector(CommentToEmit);
423 
424  if (EOL)
425  CommentToEmit.push_back('\n'); // Place comment in a new line.
426 }
427 
428 void MCAsmStreamer::EmitCommentsAndEOL() {
429  if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0) {
430  OS << '\n';
431  return;
432  }
433 
434  StringRef Comments = CommentToEmit;
435 
436  assert(Comments.back() == '\n' &&
437  "Comment array not newline terminated");
438  do {
439  // Emit a line of comments.
440  OS.PadToColumn(MAI->getCommentColumn());
441  size_t Position = Comments.find('\n');
442  OS << MAI->getCommentString() << ' ' << Comments.substr(0, Position) <<'\n';
443 
444  Comments = Comments.substr(Position+1);
445  } while (!Comments.empty());
446 
447  CommentToEmit.clear();
448 }
449 
450 static inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
451  assert(Bytes > 0 && Bytes <= 8 && "Invalid size!");
452  return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
453 }
454 
455 void MCAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) {
456  if (TabPrefix)
457  OS << '\t';
458  OS << MAI->getCommentString() << T;
459  EmitEOL();
460 }
461 
462 void MCAsmStreamer::addExplicitComment(const Twine &T) {
463  StringRef c = T.getSingleStringRef();
464  if (c.equals(StringRef(MAI->getSeparatorString())))
465  return;
466  if (c.startswith(StringRef("//"))) {
467  ExplicitCommentToEmit.append("\t");
468  ExplicitCommentToEmit.append(MAI->getCommentString());
469  // drop //
470  ExplicitCommentToEmit.append(c.slice(2, c.size()).str());
471  } else if (c.startswith(StringRef("/*"))) {
472  size_t p = 2, len = c.size() - 2;
473  // emit each line in comment as separate newline.
474  do {
475  size_t newp = std::min(len, c.find_first_of("\r\n", p));
476  ExplicitCommentToEmit.append("\t");
477  ExplicitCommentToEmit.append(MAI->getCommentString());
478  ExplicitCommentToEmit.append(c.slice(p, newp).str());
479  // If we have another line in this comment add line
480  if (newp < len)
481  ExplicitCommentToEmit.append("\n");
482  p = newp + 1;
483  } while (p < len);
484  } else if (c.startswith(StringRef(MAI->getCommentString()))) {
485  ExplicitCommentToEmit.append("\t");
486  ExplicitCommentToEmit.append(c.str());
487  } else if (c.front() == '#') {
488 
489  ExplicitCommentToEmit.append("\t");
490  ExplicitCommentToEmit.append(MAI->getCommentString());
491  ExplicitCommentToEmit.append(c.slice(1, c.size()).str());
492  } else
493  assert(false && "Unexpected Assembly Comment");
494  // full line comments immediately output
495  if (c.back() == '\n')
496  emitExplicitComments();
497 }
498 
499 void MCAsmStreamer::emitExplicitComments() {
500  StringRef Comments = ExplicitCommentToEmit;
501  if (!Comments.empty())
502  OS << Comments;
503  ExplicitCommentToEmit.clear();
504 }
505 
506 void MCAsmStreamer::changeSection(MCSection *Section,
507  const MCExpr *Subsection) {
508  assert(Section && "Cannot switch to a null section!");
509  if (MCTargetStreamer *TS = getTargetStreamer()) {
510  TS->changeSection(getCurrentSectionOnly(), Section, Subsection, OS);
511  } else {
512  Section->printSwitchToSection(*MAI, getContext().getTargetTriple(), OS,
513  Subsection);
514  }
515 }
516 
517 void MCAsmStreamer::emitELFSymverDirective(const MCSymbol *OriginalSym,
518  StringRef Name,
519  bool KeepOriginalSym) {
520  OS << ".symver ";
521  OriginalSym->print(OS, MAI);
522  OS << ", " << Name;
523  if (!KeepOriginalSym && !Name.contains("@@@"))
524  OS << ", remove";
525  EmitEOL();
526 }
527 
528 void MCAsmStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
529  MCStreamer::emitLabel(Symbol, Loc);
530 
531  Symbol->print(OS, MAI);
532  OS << MAI->getLabelSuffix();
533 
534  EmitEOL();
535 }
536 
537 void MCAsmStreamer::emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {
538  StringRef str = MCLOHIdToName(Kind);
539 
540 #ifndef NDEBUG
541  int NbArgs = MCLOHIdToNbArgs(Kind);
542  assert(NbArgs != -1 && ((size_t)NbArgs) == Args.size() && "Malformed LOH!");
543  assert(str != "" && "Invalid LOH name");
544 #endif
545 
546  OS << "\t" << MCLOHDirectiveName() << " " << str << "\t";
547  bool IsFirst = true;
548  for (const MCSymbol *Arg : Args) {
549  if (!IsFirst)
550  OS << ", ";
551  IsFirst = false;
552  Arg->print(OS, MAI);
553  }
554  EmitEOL();
555 }
556 
557 void MCAsmStreamer::emitGNUAttribute(unsigned Tag, unsigned Value) {
558  OS << "\t.gnu_attribute " << Tag << ", " << Value << "\n";
559 }
560 
561 void MCAsmStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
562  switch (Flag) {
563  case MCAF_SyntaxUnified: OS << "\t.syntax unified"; break;
564  case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
565  case MCAF_Code16: OS << '\t'<< MAI->getCode16Directive();break;
566  case MCAF_Code32: OS << '\t'<< MAI->getCode32Directive();break;
567  case MCAF_Code64: OS << '\t'<< MAI->getCode64Directive();break;
568  }
569  EmitEOL();
570 }
571 
572 void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
573  assert(!Options.empty() && "At least one option is required!");
574  OS << "\t.linker_option \"" << Options[0] << '"';
575  for (const std::string &Opt : llvm::drop_begin(Options))
576  OS << ", " << '"' << Opt << '"';
577  EmitEOL();
578 }
579 
580 void MCAsmStreamer::emitDataRegion(MCDataRegionType Kind) {
582  return;
583  switch (Kind) {
584  case MCDR_DataRegion: OS << "\t.data_region"; break;
585  case MCDR_DataRegionJT8: OS << "\t.data_region jt8"; break;
586  case MCDR_DataRegionJT16: OS << "\t.data_region jt16"; break;
587  case MCDR_DataRegionJT32: OS << "\t.data_region jt32"; break;
588  case MCDR_DataRegionEnd: OS << "\t.end_data_region"; break;
589  }
590  EmitEOL();
591 }
592 
594  switch (Type) {
595  case MCVM_WatchOSVersionMin: return ".watchos_version_min";
596  case MCVM_TvOSVersionMin: return ".tvos_version_min";
597  case MCVM_IOSVersionMin: return ".ios_version_min";
598  case MCVM_OSXVersionMin: return ".macosx_version_min";
599  }
600  llvm_unreachable("Invalid MC version min type");
601 }
602 
604  const VersionTuple &SDKVersion) {
605  if (SDKVersion.empty())
606  return;
607  OS << '\t' << "sdk_version " << SDKVersion.getMajor();
608  if (auto Minor = SDKVersion.getMinor()) {
609  OS << ", " << *Minor;
610  if (auto Subminor = SDKVersion.getSubminor()) {
611  OS << ", " << *Subminor;
612  }
613  }
614 }
615 
616 void MCAsmStreamer::emitVersionMin(MCVersionMinType Type, unsigned Major,
617  unsigned Minor, unsigned Update,
618  VersionTuple SDKVersion) {
619  OS << '\t' << getVersionMinDirective(Type) << ' ' << Major << ", " << Minor;
620  if (Update)
621  OS << ", " << Update;
622  EmitSDKVersionSuffix(OS, SDKVersion);
623  EmitEOL();
624 }
625 
627  switch (Type) {
628  case MachO::PLATFORM_UNKNOWN: /* silence warning*/
629  break;
630  case MachO::PLATFORM_MACOS: return "macos";
631  case MachO::PLATFORM_IOS: return "ios";
632  case MachO::PLATFORM_TVOS: return "tvos";
633  case MachO::PLATFORM_WATCHOS: return "watchos";
634  case MachO::PLATFORM_BRIDGEOS: return "bridgeos";
635  case MachO::PLATFORM_MACCATALYST: return "macCatalyst";
636  case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator";
637  case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator";
638  case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator";
639  case MachO::PLATFORM_DRIVERKIT: return "driverkit";
640  }
641  llvm_unreachable("Invalid Mach-O platform type");
642 }
643 
644 void MCAsmStreamer::emitBuildVersion(unsigned Platform, unsigned Major,
645  unsigned Minor, unsigned Update,
646  VersionTuple SDKVersion) {
647  const char *PlatformName = getPlatformName((MachO::PlatformType)Platform);
648  OS << "\t.build_version " << PlatformName << ", " << Major << ", " << Minor;
649  if (Update)
650  OS << ", " << Update;
651  EmitSDKVersionSuffix(OS, SDKVersion);
652  EmitEOL();
653 }
654 
655 void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
656  unsigned Platform, unsigned Major, unsigned Minor, unsigned Update,
657  VersionTuple SDKVersion) {
658  emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
659 }
660 
661 void MCAsmStreamer::emitThumbFunc(MCSymbol *Func) {
662  // This needs to emit to a temporary string to get properly quoted
663  // MCSymbols when they have spaces in them.
664  OS << "\t.thumb_func";
665  // Only Mach-O hasSubsectionsViaSymbols()
666  if (MAI->hasSubsectionsViaSymbols()) {
667  OS << '\t';
668  Func->print(OS, MAI);
669  }
670  EmitEOL();
671 }
672 
673 void MCAsmStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
674  // Do not emit a .set on inlined target assignments.
675  bool EmitSet = true;
676  if (auto *E = dyn_cast<MCTargetExpr>(Value))
677  if (E->inlineAssignedExpr())
678  EmitSet = false;
679  if (EmitSet) {
680  OS << ".set ";
681  Symbol->print(OS, MAI);
682  OS << ", ";
683  Value->print(OS, MAI);
684 
685  EmitEOL();
686  }
687 
689 }
690 
691 void MCAsmStreamer::emitConditionalAssignment(MCSymbol *Symbol,
692  const MCExpr *Value) {
693  OS << ".lto_set_conditional ";
694  Symbol->print(OS, MAI);
695  OS << ", ";
696  Value->print(OS, MAI);
697  EmitEOL();
698 }
699 
700 void MCAsmStreamer::emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
701  OS << ".weakref ";
702  Alias->print(OS, MAI);
703  OS << ", ";
704  Symbol->print(OS, MAI);
705  EmitEOL();
706 }
707 
708 bool MCAsmStreamer::emitSymbolAttribute(MCSymbol *Symbol,
710  switch (Attribute) {
711  case MCSA_Invalid: llvm_unreachable("Invalid symbol attribute");
712  case MCSA_ELF_TypeFunction: /// .type _foo, STT_FUNC # aka @function
713  case MCSA_ELF_TypeIndFunction: /// .type _foo, STT_GNU_IFUNC
714  case MCSA_ELF_TypeObject: /// .type _foo, STT_OBJECT # aka @object
715  case MCSA_ELF_TypeTLS: /// .type _foo, STT_TLS # aka @tls_object
716  case MCSA_ELF_TypeCommon: /// .type _foo, STT_COMMON # aka @common
717  case MCSA_ELF_TypeNoType: /// .type _foo, STT_NOTYPE # aka @notype
718  case MCSA_ELF_TypeGnuUniqueObject: /// .type _foo, @gnu_unique_object
719  if (!MAI->hasDotTypeDotSizeDirective())
720  return false; // Symbol attribute not supported
721  OS << "\t.type\t";
722  Symbol->print(OS, MAI);
723  OS << ',' << ((MAI->getCommentString()[0] != '@') ? '@' : '%');
724  switch (Attribute) {
725  default: return false;
726  case MCSA_ELF_TypeFunction: OS << "function"; break;
727  case MCSA_ELF_TypeIndFunction: OS << "gnu_indirect_function"; break;
728  case MCSA_ELF_TypeObject: OS << "object"; break;
729  case MCSA_ELF_TypeTLS: OS << "tls_object"; break;
730  case MCSA_ELF_TypeCommon: OS << "common"; break;
731  case MCSA_ELF_TypeNoType: OS << "notype"; break;
732  case MCSA_ELF_TypeGnuUniqueObject: OS << "gnu_unique_object"; break;
733  }
734  EmitEOL();
735  return true;
736  case MCSA_Global: // .globl/.global
737  OS << MAI->getGlobalDirective();
738  break;
739  case MCSA_LGlobal: OS << "\t.lglobl\t"; break;
740  case MCSA_Hidden: OS << "\t.hidden\t"; break;
741  case MCSA_IndirectSymbol: OS << "\t.indirect_symbol\t"; break;
742  case MCSA_Internal: OS << "\t.internal\t"; break;
743  case MCSA_LazyReference: OS << "\t.lazy_reference\t"; break;
744  case MCSA_Local: OS << "\t.local\t"; break;
745  case MCSA_NoDeadStrip:
746  if (!MAI->hasNoDeadStrip())
747  return false;
748  OS << "\t.no_dead_strip\t";
749  break;
750  case MCSA_SymbolResolver: OS << "\t.symbol_resolver\t"; break;
751  case MCSA_AltEntry: OS << "\t.alt_entry\t"; break;
752  case MCSA_PrivateExtern:
753  OS << "\t.private_extern\t";
754  break;
755  case MCSA_Protected: OS << "\t.protected\t"; break;
756  case MCSA_Reference: OS << "\t.reference\t"; break;
757  case MCSA_Extern:
758  OS << "\t.extern\t";
759  break;
760  case MCSA_Weak: OS << MAI->getWeakDirective(); break;
761  case MCSA_WeakDefinition:
762  OS << "\t.weak_definition\t";
763  break;
764  // .weak_reference
765  case MCSA_WeakReference: OS << MAI->getWeakRefDirective(); break;
766  case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break;
767  case MCSA_Cold:
768  // Assemblers currently do not support a .cold directive.
769  case MCSA_Exported:
770  // Non-AIX assemblers currently do not support exported visibility.
771  return false;
772  }
773 
774  Symbol->print(OS, MAI);
775  EmitEOL();
776 
777  return true;
778 }
779 
780 void MCAsmStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
781  OS << ".desc" << ' ';
782  Symbol->print(OS, MAI);
783  OS << ',' << DescValue;
784  EmitEOL();
785 }
786 
787 void MCAsmStreamer::emitSyntaxDirective() {
788  if (MAI->getAssemblerDialect() == 1) {
789  OS << "\t.intel_syntax noprefix";
790  EmitEOL();
791  }
792  // FIXME: Currently emit unprefix'ed registers.
793  // The intel_syntax directive has one optional argument
794  // with may have a value of prefix or noprefix.
795 }
796 
797 void MCAsmStreamer::beginCOFFSymbolDef(const MCSymbol *Symbol) {
798  OS << "\t.def\t";
799  Symbol->print(OS, MAI);
800  OS << ';';
801  EmitEOL();
802 }
803 
804 void MCAsmStreamer::emitCOFFSymbolStorageClass(int StorageClass) {
805  OS << "\t.scl\t" << StorageClass << ';';
806  EmitEOL();
807 }
808 
809 void MCAsmStreamer::emitCOFFSymbolType(int Type) {
810  OS << "\t.type\t" << Type << ';';
811  EmitEOL();
812 }
813 
814 void MCAsmStreamer::endCOFFSymbolDef() {
815  OS << "\t.endef";
816  EmitEOL();
817 }
818 
819 void MCAsmStreamer::emitCOFFSafeSEH(MCSymbol const *Symbol) {
820  OS << "\t.safeseh\t";
821  Symbol->print(OS, MAI);
822  EmitEOL();
823 }
824 
825 void MCAsmStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {
826  OS << "\t.symidx\t";
827  Symbol->print(OS, MAI);
828  EmitEOL();
829 }
830 
831 void MCAsmStreamer::emitCOFFSectionIndex(MCSymbol const *Symbol) {
832  OS << "\t.secidx\t";
833  Symbol->print(OS, MAI);
834  EmitEOL();
835 }
836 
837 void MCAsmStreamer::emitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) {
838  OS << "\t.secrel32\t";
839  Symbol->print(OS, MAI);
840  if (Offset != 0)
841  OS << '+' << Offset;
842  EmitEOL();
843 }
844 
845 void MCAsmStreamer::emitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {
846  OS << "\t.rva\t";
847  Symbol->print(OS, MAI);
848  if (Offset > 0)
849  OS << '+' << Offset;
850  else if (Offset < 0)
851  OS << '-' << -Offset;
852  EmitEOL();
853 }
854 
855 // We need an XCOFF-specific version of this directive as the AIX syntax
856 // requires a QualName argument identifying the csect name and storage mapping
857 // class to appear before the alignment if we are specifying it.
858 void MCAsmStreamer::emitXCOFFLocalCommonSymbol(MCSymbol *LabelSym,
859  uint64_t Size,
860  MCSymbol *CsectSym,
861  Align Alignment) {
863  "We only support writing log base-2 alignment format with XCOFF.");
864 
865  OS << "\t.lcomm\t";
866  LabelSym->print(OS, MAI);
867  OS << ',' << Size << ',';
868  CsectSym->print(OS, MAI);
869  OS << ',' << Log2(Alignment);
870 
871  EmitEOL();
872 
873  // Print symbol's rename (original name contains invalid character(s)) if
874  // there is one.
875  MCSymbolXCOFF *XSym = cast<MCSymbolXCOFF>(CsectSym);
876  if (XSym->hasRename())
877  emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
878 }
879 
880 void MCAsmStreamer::emitXCOFFSymbolLinkageWithVisibility(
881  MCSymbol *Symbol, MCSymbolAttr Linkage, MCSymbolAttr Visibility) {
882 
883  switch (Linkage) {
884  case MCSA_Global:
885  OS << MAI->getGlobalDirective();
886  break;
887  case MCSA_Weak:
888  OS << MAI->getWeakDirective();
889  break;
890  case MCSA_Extern:
891  OS << "\t.extern\t";
892  break;
893  case MCSA_LGlobal:
894  OS << "\t.lglobl\t";
895  break;
896  default:
897  report_fatal_error("unhandled linkage type");
898  }
899 
900  Symbol->print(OS, MAI);
901 
902  switch (Visibility) {
903  case MCSA_Invalid:
904  // Nothing to do.
905  break;
906  case MCSA_Hidden:
907  OS << ",hidden";
908  break;
909  case MCSA_Protected:
910  OS << ",protected";
911  break;
912  case MCSA_Exported:
913  OS << ",exported";
914  break;
915  default:
916  report_fatal_error("unexpected value for Visibility type");
917  }
918  EmitEOL();
919 
920  // Print symbol's rename (original name contains invalid character(s)) if
921  // there is one.
922  if (cast<MCSymbolXCOFF>(Symbol)->hasRename())
923  emitXCOFFRenameDirective(Symbol,
924  cast<MCSymbolXCOFF>(Symbol)->getSymbolTableName());
925 }
926 
927 void MCAsmStreamer::emitXCOFFRenameDirective(const MCSymbol *Name,
928  StringRef Rename) {
929  OS << "\t.rename\t";
930  Name->print(OS, MAI);
931  const char DQ = '"';
932  OS << ',' << DQ;
933  for (char C : Rename) {
934  // To escape a double quote character, the character should be doubled.
935  if (C == DQ)
936  OS << DQ;
937  OS << C;
938  }
939  OS << DQ;
940  EmitEOL();
941 }
942 
943 void MCAsmStreamer::emitXCOFFRefDirective(StringRef Name) {
944  OS << "\t.ref " << Name;
945  EmitEOL();
946 }
947 
948 void MCAsmStreamer::emitXCOFFExceptDirective(const MCSymbol *Symbol,
949  const MCSymbol *Trap,
950  unsigned Lang,
951  unsigned Reason,
952  unsigned FunctionSize,
953  bool hasDebug) {
954  OS << "\t.except\t";
955  Symbol->print(OS, MAI);
956  OS << ", " << Lang << ", " << Reason;
957  EmitEOL();
958 }
959 
960 void MCAsmStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
962  OS << "\t.size\t";
963  Symbol->print(OS, MAI);
964  OS << ", ";
965  Value->print(OS, MAI);
966  EmitEOL();
967 }
968 
969 void MCAsmStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
970  unsigned ByteAlignment) {
971  OS << "\t.comm\t";
972  Symbol->print(OS, MAI);
973  OS << ',' << Size;
974 
975  if (ByteAlignment != 0) {
977  OS << ',' << ByteAlignment;
978  else
979  OS << ',' << Log2_32(ByteAlignment);
980  }
981  EmitEOL();
982 
983  // Print symbol's rename (original name contains invalid character(s)) if
984  // there is one.
985  MCSymbolXCOFF *XSym = dyn_cast<MCSymbolXCOFF>(Symbol);
986  if (XSym && XSym->hasRename())
987  emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
988 
989 }
990 
991 void MCAsmStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
992  unsigned ByteAlign) {
993  OS << "\t.lcomm\t";
994  Symbol->print(OS, MAI);
995  OS << ',' << Size;
996 
997  if (ByteAlign > 1) {
998  switch (MAI->getLCOMMDirectiveAlignmentType()) {
999  case LCOMM::NoAlignment:
1000  llvm_unreachable("alignment not supported on .lcomm!");
1001  case LCOMM::ByteAlignment:
1002  OS << ',' << ByteAlign;
1003  break;
1004  case LCOMM::Log2Alignment:
1005  assert(isPowerOf2_32(ByteAlign) && "alignment must be a power of 2");
1006  OS << ',' << Log2_32(ByteAlign);
1007  break;
1008  }
1009  }
1010  EmitEOL();
1011 }
1012 
1013 void MCAsmStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
1014  uint64_t Size, unsigned ByteAlignment,
1015  SMLoc Loc) {
1016  if (Symbol)
1017  assignFragment(Symbol, &Section->getDummyFragment());
1018 
1019  // Note: a .zerofill directive does not switch sections.
1020  OS << ".zerofill ";
1021 
1022  assert(Section->getVariant() == MCSection::SV_MachO &&
1023  ".zerofill is a Mach-O specific directive");
1024  // This is a mach-o specific directive.
1025 
1026  const MCSectionMachO *MOSection = ((const MCSectionMachO*)Section);
1027  OS << MOSection->getSegmentName() << "," << MOSection->getName();
1028 
1029  if (Symbol) {
1030  OS << ',';
1031  Symbol->print(OS, MAI);
1032  OS << ',' << Size;
1033  if (ByteAlignment != 0)
1034  OS << ',' << Log2_32(ByteAlignment);
1035  }
1036  EmitEOL();
1037 }
1038 
1039 // .tbss sym, size, align
1040 // This depends that the symbol has already been mangled from the original,
1041 // e.g. _a.
1042 void MCAsmStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
1043  uint64_t Size, unsigned ByteAlignment) {
1044  assignFragment(Symbol, &Section->getDummyFragment());
1045 
1046  assert(Symbol && "Symbol shouldn't be NULL!");
1047  // Instead of using the Section we'll just use the shortcut.
1048 
1049  assert(Section->getVariant() == MCSection::SV_MachO &&
1050  ".zerofill is a Mach-O specific directive");
1051  // This is a mach-o specific directive and section.
1052 
1053  OS << ".tbss ";
1054  Symbol->print(OS, MAI);
1055  OS << ", " << Size;
1056 
1057  // Output align if we have it. We default to 1 so don't bother printing
1058  // that.
1059  if (ByteAlignment > 1) OS << ", " << Log2_32(ByteAlignment);
1060 
1061  EmitEOL();
1062 }
1063 
1064 static inline bool isPrintableString(StringRef Data) {
1065  const auto BeginPtr = Data.begin(), EndPtr = Data.end();
1066  for (const unsigned char C : make_range(BeginPtr, EndPtr - 1)) {
1067  if (!isPrint(C))
1068  return false;
1069  }
1070  return isPrint(Data.back()) || Data.back() == 0;
1071 }
1072 
1073 static inline char toOctal(int X) { return (X&7)+'0'; }
1074 
1077  assert(!Data.empty() && "Cannot generate an empty list.");
1078  const auto printCharacterInOctal = [&OS](unsigned char C) {
1079  OS << '0';
1080  OS << toOctal(C >> 6);
1081  OS << toOctal(C >> 3);
1082  OS << toOctal(C >> 0);
1083  };
1084  const auto printOneCharacterFor = [printCharacterInOctal](
1085  auto printOnePrintingCharacter) {
1086  return [printCharacterInOctal, printOnePrintingCharacter](unsigned char C) {
1087  if (isPrint(C)) {
1088  printOnePrintingCharacter(static_cast<char>(C));
1089  return;
1090  }
1091  printCharacterInOctal(C);
1092  };
1093  };
1094  const auto printCharacterList = [Data, &OS](const auto &printOneCharacter) {
1095  const auto BeginPtr = Data.begin(), EndPtr = Data.end();
1096  for (const unsigned char C : make_range(BeginPtr, EndPtr - 1)) {
1097  printOneCharacter(C);
1098  OS << ',';
1099  }
1100  printOneCharacter(*(EndPtr - 1));
1101  };
1102  switch (ACLS) {
1104  printCharacterList(printCharacterInOctal);
1105  return;
1107  printCharacterList(printOneCharacterFor([&OS](char C) {
1108  const char AsmCharLitBuf[2] = {'\'', C};
1109  OS << StringRef(AsmCharLitBuf, sizeof(AsmCharLitBuf));
1110  }));
1111  return;
1112  }
1113  llvm_unreachable("Invalid AsmCharLiteralSyntax value!");
1114 }
1115 
1116 void MCAsmStreamer::PrintQuotedString(StringRef Data, raw_ostream &OS) const {
1117  OS << '"';
1118 
1120  for (unsigned char C : Data) {
1121  if (C == '"')
1122  OS << "\"\"";
1123  else
1124  OS << (char)C;
1125  }
1126  } else {
1127  for (unsigned char C : Data) {
1128  if (C == '"' || C == '\\') {
1129  OS << '\\' << (char)C;
1130  continue;
1131  }
1132 
1133  if (isPrint((unsigned char)C)) {
1134  OS << (char)C;
1135  continue;
1136  }
1137 
1138  switch (C) {
1139  case '\b':
1140  OS << "\\b";
1141  break;
1142  case '\f':
1143  OS << "\\f";
1144  break;
1145  case '\n':
1146  OS << "\\n";
1147  break;
1148  case '\r':
1149  OS << "\\r";
1150  break;
1151  case '\t':
1152  OS << "\\t";
1153  break;
1154  default:
1155  OS << '\\';
1156  OS << toOctal(C >> 6);
1157  OS << toOctal(C >> 3);
1158  OS << toOctal(C >> 0);
1159  break;
1160  }
1161  }
1162  }
1163 
1164  OS << '"';
1165 }
1166 
1167 void MCAsmStreamer::emitBytes(StringRef Data) {
1168  assert(getCurrentSectionOnly() &&
1169  "Cannot emit contents before setting section!");
1170  if (Data.empty()) return;
1171 
1172  const auto emitAsString = [this](StringRef Data) {
1173  // If the data ends with 0 and the target supports .asciz, use it, otherwise
1174  // use .ascii or a byte-list directive
1175  if (MAI->getAscizDirective() && Data.back() == 0) {
1176  OS << MAI->getAscizDirective();
1177  Data = Data.substr(0, Data.size() - 1);
1178  } else if (LLVM_LIKELY(MAI->getAsciiDirective())) {
1179  OS << MAI->getAsciiDirective();
1180  } else if (MAI->hasPairedDoubleQuoteStringConstants() &&
1182  // For target with DoubleQuoteString constants, .string and .byte are used
1183  // as replacement of .asciz and .ascii.
1185  "hasPairedDoubleQuoteStringConstants target must support "
1186  "PlainString Directive");
1187  assert(MAI->getByteListDirective() &&
1188  "hasPairedDoubleQuoteStringConstants target must support ByteList "
1189  "Directive");
1190  if (Data.back() == 0) {
1191  OS << MAI->getPlainStringDirective();
1192  Data = Data.substr(0, Data.size() - 1);
1193  } else {
1194  OS << MAI->getByteListDirective();
1195  }
1196  } else if (MAI->getByteListDirective()) {
1197  OS << MAI->getByteListDirective();
1199  EmitEOL();
1200  return true;
1201  } else {
1202  return false;
1203  }
1204 
1205  PrintQuotedString(Data, OS);
1206  EmitEOL();
1207  return true;
1208  };
1209 
1210  if (Data.size() != 1 && emitAsString(Data))
1211  return;
1212 
1213  // Only single byte is provided or no ascii, asciz, or byte-list directives
1214  // are applicable. Emit as vector of individual 8bits data elements.
1215  if (MCTargetStreamer *TS = getTargetStreamer()) {
1216  TS->emitRawBytes(Data);
1217  return;
1218  }
1219  const char *Directive = MAI->getData8bitsDirective();
1220  for (const unsigned char C : Data.bytes()) {
1221  OS << Directive << (unsigned)C;
1222  EmitEOL();
1223  }
1224 }
1225 
1226 void MCAsmStreamer::emitBinaryData(StringRef Data) {
1227  // This is binary data. Print it in a grid of hex bytes for readability.
1228  const size_t Cols = 4;
1229  for (size_t I = 0, EI = alignTo(Data.size(), Cols); I < EI; I += Cols) {
1230  size_t J = I, EJ = std::min(I + Cols, Data.size());
1231  assert(EJ > 0);
1232  OS << MAI->getData8bitsDirective();
1233  for (; J < EJ - 1; ++J)
1234  OS << format("0x%02x", uint8_t(Data[J])) << ", ";
1235  OS << format("0x%02x", uint8_t(Data[J]));
1236  EmitEOL();
1237  }
1238 }
1239 
1240 void MCAsmStreamer::emitIntValue(uint64_t Value, unsigned Size) {
1241  emitValue(MCConstantExpr::create(Value, getContext()), Size);
1242 }
1243 
1244 void MCAsmStreamer::emitIntValueInHex(uint64_t Value, unsigned Size) {
1245  emitValue(MCConstantExpr::create(Value, getContext(), true), Size);
1246 }
1247 
1248 void MCAsmStreamer::emitIntValueInHexWithPadding(uint64_t Value,
1249  unsigned Size) {
1250  emitValue(MCConstantExpr::create(Value, getContext(), true, Size), Size);
1251 }
1252 
1253 void MCAsmStreamer::emitValueImpl(const MCExpr *Value, unsigned Size,
1254  SMLoc Loc) {
1255  assert(Size <= 8 && "Invalid size");
1256  assert(getCurrentSectionOnly() &&
1257  "Cannot emit contents before setting section!");
1258  const char *Directive = nullptr;
1259  switch (Size) {
1260  default: break;
1261  case 1: Directive = MAI->getData8bitsDirective(); break;
1262  case 2: Directive = MAI->getData16bitsDirective(); break;
1263  case 4: Directive = MAI->getData32bitsDirective(); break;
1264  case 8: Directive = MAI->getData64bitsDirective(); break;
1265  }
1266 
1267  if (!Directive) {
1268  int64_t IntValue;
1269  if (!Value->evaluateAsAbsolute(IntValue))
1270  report_fatal_error("Don't know how to emit this value.");
1271 
1272  // We couldn't handle the requested integer size so we fallback by breaking
1273  // the request down into several, smaller, integers.
1274  // Since sizes greater or equal to "Size" are invalid, we use the greatest
1275  // power of 2 that is less than "Size" as our largest piece of granularity.
1276  bool IsLittleEndian = MAI->isLittleEndian();
1277  for (unsigned Emitted = 0; Emitted != Size;) {
1278  unsigned Remaining = Size - Emitted;
1279  // The size of our partial emission must be a power of two less than
1280  // Size.
1281  unsigned EmissionSize = PowerOf2Floor(std::min(Remaining, Size - 1));
1282  // Calculate the byte offset of our partial emission taking into account
1283  // the endianness of the target.
1284  unsigned ByteOffset =
1285  IsLittleEndian ? Emitted : (Remaining - EmissionSize);
1286  uint64_t ValueToEmit = IntValue >> (ByteOffset * 8);
1287  // We truncate our partial emission to fit within the bounds of the
1288  // emission domain. This produces nicer output and silences potential
1289  // truncation warnings when round tripping through another assembler.
1290  uint64_t Shift = 64 - EmissionSize * 8;
1291  assert(Shift < static_cast<uint64_t>(
1292  std::numeric_limits<unsigned long long>::digits) &&
1293  "undefined behavior");
1294  ValueToEmit &= ~0ULL >> Shift;
1295  emitIntValue(ValueToEmit, EmissionSize);
1296  Emitted += EmissionSize;
1297  }
1298  return;
1299  }
1300 
1301  assert(Directive && "Invalid size for machine code value!");
1302  OS << Directive;
1303  if (MCTargetStreamer *TS = getTargetStreamer()) {
1304  TS->emitValue(Value);
1305  } else {
1306  Value->print(OS, MAI);
1307  EmitEOL();
1308  }
1309 }
1310 
1311 void MCAsmStreamer::emitULEB128Value(const MCExpr *Value) {
1312  int64_t IntValue;
1313  if (Value->evaluateAsAbsolute(IntValue)) {
1314  emitULEB128IntValue(IntValue);
1315  return;
1316  }
1317  OS << "\t.uleb128 ";
1318  Value->print(OS, MAI);
1319  EmitEOL();
1320 }
1321 
1322 void MCAsmStreamer::emitSLEB128Value(const MCExpr *Value) {
1323  int64_t IntValue;
1324  if (Value->evaluateAsAbsolute(IntValue)) {
1325  emitSLEB128IntValue(IntValue);
1326  return;
1327  }
1328  OS << "\t.sleb128 ";
1329  Value->print(OS, MAI);
1330  EmitEOL();
1331 }
1332 
1333 void MCAsmStreamer::emitDTPRel64Value(const MCExpr *Value) {
1334  assert(MAI->getDTPRel64Directive() != nullptr);
1335  OS << MAI->getDTPRel64Directive();
1336  Value->print(OS, MAI);
1337  EmitEOL();
1338 }
1339 
1340 void MCAsmStreamer::emitDTPRel32Value(const MCExpr *Value) {
1341  assert(MAI->getDTPRel32Directive() != nullptr);
1342  OS << MAI->getDTPRel32Directive();
1343  Value->print(OS, MAI);
1344  EmitEOL();
1345 }
1346 
1347 void MCAsmStreamer::emitTPRel64Value(const MCExpr *Value) {
1348  assert(MAI->getTPRel64Directive() != nullptr);
1349  OS << MAI->getTPRel64Directive();
1350  Value->print(OS, MAI);
1351  EmitEOL();
1352 }
1353 
1354 void MCAsmStreamer::emitTPRel32Value(const MCExpr *Value) {
1355  assert(MAI->getTPRel32Directive() != nullptr);
1356  OS << MAI->getTPRel32Directive();
1357  Value->print(OS, MAI);
1358  EmitEOL();
1359 }
1360 
1361 void MCAsmStreamer::emitGPRel64Value(const MCExpr *Value) {
1362  assert(MAI->getGPRel64Directive() != nullptr);
1363  OS << MAI->getGPRel64Directive();
1364  Value->print(OS, MAI);
1365  EmitEOL();
1366 }
1367 
1368 void MCAsmStreamer::emitGPRel32Value(const MCExpr *Value) {
1369  assert(MAI->getGPRel32Directive() != nullptr);
1370  OS << MAI->getGPRel32Directive();
1371  Value->print(OS, MAI);
1372  EmitEOL();
1373 }
1374 
1375 void MCAsmStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
1376  SMLoc Loc) {
1377  int64_t IntNumBytes;
1378  const bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
1379  if (IsAbsolute && IntNumBytes == 0)
1380  return;
1381 
1382  if (const char *ZeroDirective = MAI->getZeroDirective()) {
1383  if (MAI->doesZeroDirectiveSupportNonZeroValue() || FillValue == 0) {
1384  // FIXME: Emit location directives
1385  OS << ZeroDirective;
1386  NumBytes.print(OS, MAI);
1387  if (FillValue != 0)
1388  OS << ',' << (int)FillValue;
1389  EmitEOL();
1390  } else {
1391  if (!IsAbsolute)
1393  "Cannot emit non-absolute expression lengths of fill.");
1394  for (int i = 0; i < IntNumBytes; ++i) {
1395  OS << MAI->getData8bitsDirective() << (int)FillValue;
1396  EmitEOL();
1397  }
1398  }
1399  return;
1400  }
1401 
1402  MCStreamer::emitFill(NumBytes, FillValue);
1403 }
1404 
1405 void MCAsmStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
1406  int64_t Expr, SMLoc Loc) {
1407  // FIXME: Emit location directives
1408  OS << "\t.fill\t";
1409  NumValues.print(OS, MAI);
1410  OS << ", " << Size << ", 0x";
1411  OS.write_hex(truncateToSize(Expr, 4));
1412  EmitEOL();
1413 }
1414 
1415 void MCAsmStreamer::emitAlignmentDirective(unsigned ByteAlignment,
1417  unsigned ValueSize,
1418  unsigned MaxBytesToEmit) {
1419  if (MAI->useDotAlignForAlignment()) {
1421  report_fatal_error("Only power-of-two alignments are supported "
1422  "with .align.");
1423  OS << "\t.align\t";
1424  OS << Log2_32(ByteAlignment);
1425  EmitEOL();
1426  return;
1427  }
1428 
1429  // Some assemblers don't support non-power of two alignments, so we always
1430  // emit alignments as a power of two if possible.
1432  switch (ValueSize) {
1433  default:
1434  llvm_unreachable("Invalid size for machine code value!");
1435  case 1:
1436  OS << "\t.p2align\t";
1437  break;
1438  case 2:
1439  OS << ".p2alignw ";
1440  break;
1441  case 4:
1442  OS << ".p2alignl ";
1443  break;
1444  case 8:
1445  llvm_unreachable("Unsupported alignment size!");
1446  }
1447 
1448  OS << Log2_32(ByteAlignment);
1449 
1450  if (Value.has_value() || MaxBytesToEmit) {
1451  if (Value.has_value()) {
1452  OS << ", 0x";
1453  OS.write_hex(truncateToSize(Value.value(), ValueSize));
1454  } else {
1455  OS << ", ";
1456  }
1457 
1458  if (MaxBytesToEmit)
1459  OS << ", " << MaxBytesToEmit;
1460  }
1461  EmitEOL();
1462  return;
1463  }
1464 
1465  // Non-power of two alignment. This is not widely supported by assemblers.
1466  // FIXME: Parameterize this based on MAI.
1467  switch (ValueSize) {
1468  default: llvm_unreachable("Invalid size for machine code value!");
1469  case 1: OS << ".balign"; break;
1470  case 2: OS << ".balignw"; break;
1471  case 4: OS << ".balignl"; break;
1472  case 8: llvm_unreachable("Unsupported alignment size!");
1473  }
1474 
1475  OS << ' ' << ByteAlignment;
1476  if (Value.has_value())
1477  OS << ", " << truncateToSize(Value.value(), ValueSize);
1478  else if (MaxBytesToEmit)
1479  OS << ", ";
1480  if (MaxBytesToEmit)
1481  OS << ", " << MaxBytesToEmit;
1482  EmitEOL();
1483 }
1484 
1485 void MCAsmStreamer::emitValueToAlignment(Align Alignment, int64_t Value,
1486  unsigned ValueSize,
1487  unsigned MaxBytesToEmit) {
1488  emitAlignmentDirective(Alignment.value(), Value, ValueSize, MaxBytesToEmit);
1489 }
1490 
1491 void MCAsmStreamer::emitCodeAlignment(Align Alignment,
1492  const MCSubtargetInfo *STI,
1493  unsigned MaxBytesToEmit) {
1494  // Emit with a text fill value.
1495  if (MAI->getTextAlignFillValue())
1496  emitAlignmentDirective(Alignment.value(), MAI->getTextAlignFillValue(), 1,
1497  MaxBytesToEmit);
1498  else
1499  emitAlignmentDirective(Alignment.value(), None, 1, MaxBytesToEmit);
1500 }
1501 
1502 void MCAsmStreamer::emitValueToOffset(const MCExpr *Offset,
1503  unsigned char Value,
1504  SMLoc Loc) {
1505  // FIXME: Verify that Offset is associated with the current section.
1506  OS << ".org ";
1507  Offset->print(OS, MAI);
1508  OS << ", " << (unsigned)Value;
1509  EmitEOL();
1510 }
1511 
1512 void MCAsmStreamer::emitFileDirective(StringRef Filename) {
1514  OS << "\t.file\t";
1515  PrintQuotedString(Filename, OS);
1516  EmitEOL();
1517 }
1518 
1519 void MCAsmStreamer::emitFileDirective(StringRef Filename,
1520  StringRef CompilerVerion,
1521  StringRef TimeStamp,
1522  StringRef Description) {
1523  assert(MAI->hasFourStringsDotFile());
1524  OS << "\t.file\t";
1525  PrintQuotedString(Filename, OS);
1526  OS << ",";
1527  if (!CompilerVerion.empty()) {
1528  PrintQuotedString(CompilerVerion, OS);
1529  }
1530  if (!TimeStamp.empty()) {
1531  OS << ",";
1532  PrintQuotedString(TimeStamp, OS);
1533  }
1534  if (!Description.empty()) {
1535  OS << ",";
1536  PrintQuotedString(Description, OS);
1537  }
1538  EmitEOL();
1539 }
1540 
1541 void MCAsmStreamer::printDwarfFileDirective(
1542  unsigned FileNo, StringRef Directory, StringRef Filename,
1544  bool UseDwarfDirectory, raw_svector_ostream &OS) const {
1545  SmallString<128> FullPathName;
1546 
1547  if (!UseDwarfDirectory && !Directory.empty()) {
1548  if (sys::path::is_absolute(Filename))
1549  Directory = "";
1550  else {
1551  FullPathName = Directory;
1552  sys::path::append(FullPathName, Filename);
1553  Directory = "";
1554  Filename = FullPathName;
1555  }
1556  }
1557 
1558  OS << "\t.file\t" << FileNo << ' ';
1559  if (!Directory.empty()) {
1560  PrintQuotedString(Directory, OS);
1561  OS << ' ';
1562  }
1563  PrintQuotedString(Filename, OS);
1564  if (Checksum)
1565  OS << " md5 0x" << Checksum->digest();
1566  if (Source) {
1567  OS << " source ";
1568  PrintQuotedString(*Source, OS);
1569  }
1570 }
1571 
1572 Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
1573  unsigned FileNo, StringRef Directory, StringRef Filename,
1574  Optional<MD5::MD5Result> Checksum, Optional<StringRef> Source, unsigned CUID) {
1575  assert(CUID == 0 && "multiple CUs not supported by MCAsmStreamer");
1576 
1577  MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
1578  unsigned NumFiles = Table.getMCDwarfFiles().size();
1579  Expected<unsigned> FileNoOrErr =
1580  Table.tryGetFile(Directory, Filename, Checksum, Source,
1581  getContext().getDwarfVersion(), FileNo);
1582  if (!FileNoOrErr)
1583  return FileNoOrErr.takeError();
1584  FileNo = FileNoOrErr.get();
1585 
1586  // Return early if this file is already emitted before or if target doesn't
1587  // support .file directive.
1588  if (NumFiles == Table.getMCDwarfFiles().size() ||
1590  return FileNo;
1591 
1592  SmallString<128> Str;
1593  raw_svector_ostream OS1(Str);
1594  printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source,
1595  UseDwarfDirectory, OS1);
1596 
1597  if (MCTargetStreamer *TS = getTargetStreamer())
1598  TS->emitDwarfFileDirective(OS1.str());
1599  else
1600  emitRawText(OS1.str());
1601 
1602  return FileNo;
1603 }
1604 
1605 void MCAsmStreamer::emitDwarfFile0Directive(StringRef Directory,
1606  StringRef Filename,
1607  Optional<MD5::MD5Result> Checksum,
1609  unsigned CUID) {
1610  assert(CUID == 0);
1611  // .file 0 is new for DWARF v5.
1612  if (getContext().getDwarfVersion() < 5)
1613  return;
1614  // Inform MCDwarf about the root file.
1615  getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
1616  Source);
1617 
1618  // Target doesn't support .loc/.file directives, return early.
1619  if (!MAI->usesDwarfFileAndLocDirectives())
1620  return;
1621 
1622  SmallString<128> Str;
1623  raw_svector_ostream OS1(Str);
1624  printDwarfFileDirective(0, Directory, Filename, Checksum, Source,
1625  UseDwarfDirectory, OS1);
1626 
1627  if (MCTargetStreamer *TS = getTargetStreamer())
1628  TS->emitDwarfFileDirective(OS1.str());
1629  else
1630  emitRawText(OS1.str());
1631 }
1632 
1633 void MCAsmStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
1634  unsigned Column, unsigned Flags,
1635  unsigned Isa, unsigned Discriminator,
1636  StringRef FileName) {
1637  // If target doesn't support .loc/.file directive, we need to record the lines
1638  // same way like we do in object mode.
1639  if (!MAI->usesDwarfFileAndLocDirectives()) {
1640  // In case we see two .loc directives in a row, make sure the
1641  // first one gets a line entry.
1642  MCDwarfLineEntry::make(this, getCurrentSectionOnly());
1643  this->MCStreamer::emitDwarfLocDirective(FileNo, Line, Column, Flags, Isa,
1644  Discriminator, FileName);
1645  return;
1646  }
1647 
1648  OS << "\t.loc\t" << FileNo << " " << Line << " " << Column;
1649  if (MAI->supportsExtendedDwarfLocDirective()) {
1650  if (Flags & DWARF2_FLAG_BASIC_BLOCK)
1651  OS << " basic_block";
1652  if (Flags & DWARF2_FLAG_PROLOGUE_END)
1653  OS << " prologue_end";
1654  if (Flags & DWARF2_FLAG_EPILOGUE_BEGIN)
1655  OS << " epilogue_begin";
1656 
1657  unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
1658  if ((Flags & DWARF2_FLAG_IS_STMT) != (OldFlags & DWARF2_FLAG_IS_STMT)) {
1659  OS << " is_stmt ";
1660 
1661  if (Flags & DWARF2_FLAG_IS_STMT)
1662  OS << "1";
1663  else
1664  OS << "0";
1665  }
1666 
1667  if (Isa)
1668  OS << " isa " << Isa;
1669  if (Discriminator)
1670  OS << " discriminator " << Discriminator;
1671  }
1672 
1673  if (IsVerboseAsm) {
1674  OS.PadToColumn(MAI->getCommentColumn());
1675  OS << MAI->getCommentString() << ' ' << FileName << ':'
1676  << Line << ':' << Column;
1677  }
1678  EmitEOL();
1679  this->MCStreamer::emitDwarfLocDirective(FileNo, Line, Column, Flags, Isa,
1680  Discriminator, FileName);
1681 }
1682 
1683 MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(unsigned CUID) {
1684  // Always use the zeroth line table, since asm syntax only supports one line
1685  // table for now.
1687 }
1688 
1689 bool MCAsmStreamer::emitCVFileDirective(unsigned FileNo, StringRef Filename,
1690  ArrayRef<uint8_t> Checksum,
1691  unsigned ChecksumKind) {
1692  if (!getContext().getCVContext().addFile(*this, FileNo, Filename, Checksum,
1693  ChecksumKind))
1694  return false;
1695 
1696  OS << "\t.cv_file\t" << FileNo << ' ';
1697  PrintQuotedString(Filename, OS);
1698 
1699  if (!ChecksumKind) {
1700  EmitEOL();
1701  return true;
1702  }
1703 
1704  OS << ' ';
1705  PrintQuotedString(toHex(Checksum), OS);
1706  OS << ' ' << ChecksumKind;
1707 
1708  EmitEOL();
1709  return true;
1710 }
1711 
1712 bool MCAsmStreamer::emitCVFuncIdDirective(unsigned FuncId) {
1713  OS << "\t.cv_func_id " << FuncId << '\n';
1715 }
1716 
1717 bool MCAsmStreamer::emitCVInlineSiteIdDirective(unsigned FunctionId,
1718  unsigned IAFunc,
1719  unsigned IAFile,
1720  unsigned IALine, unsigned IACol,
1721  SMLoc Loc) {
1722  OS << "\t.cv_inline_site_id " << FunctionId << " within " << IAFunc
1723  << " inlined_at " << IAFile << ' ' << IALine << ' ' << IACol << '\n';
1724  return MCStreamer::emitCVInlineSiteIdDirective(FunctionId, IAFunc, IAFile,
1725  IALine, IACol, Loc);
1726 }
1727 
1728 void MCAsmStreamer::emitCVLocDirective(unsigned FunctionId, unsigned FileNo,
1729  unsigned Line, unsigned Column,
1730  bool PrologueEnd, bool IsStmt,
1731  StringRef FileName, SMLoc Loc) {
1732  // Validate the directive.
1733  if (!checkCVLocSection(FunctionId, FileNo, Loc))
1734  return;
1735 
1736  OS << "\t.cv_loc\t" << FunctionId << " " << FileNo << " " << Line << " "
1737  << Column;
1738  if (PrologueEnd)
1739  OS << " prologue_end";
1740 
1741  if (IsStmt)
1742  OS << " is_stmt 1";
1743 
1744  if (IsVerboseAsm) {
1745  OS.PadToColumn(MAI->getCommentColumn());
1746  OS << MAI->getCommentString() << ' ' << FileName << ':' << Line << ':'
1747  << Column;
1748  }
1749  EmitEOL();
1750 }
1751 
1752 void MCAsmStreamer::emitCVLinetableDirective(unsigned FunctionId,
1753  const MCSymbol *FnStart,
1754  const MCSymbol *FnEnd) {
1755  OS << "\t.cv_linetable\t" << FunctionId << ", ";
1756  FnStart->print(OS, MAI);
1757  OS << ", ";
1758  FnEnd->print(OS, MAI);
1759  EmitEOL();
1760  this->MCStreamer::emitCVLinetableDirective(FunctionId, FnStart, FnEnd);
1761 }
1762 
1763 void MCAsmStreamer::emitCVInlineLinetableDirective(unsigned PrimaryFunctionId,
1764  unsigned SourceFileId,
1765  unsigned SourceLineNum,
1766  const MCSymbol *FnStartSym,
1767  const MCSymbol *FnEndSym) {
1768  OS << "\t.cv_inline_linetable\t" << PrimaryFunctionId << ' ' << SourceFileId
1769  << ' ' << SourceLineNum << ' ';
1770  FnStartSym->print(OS, MAI);
1771  OS << ' ';
1772  FnEndSym->print(OS, MAI);
1773  EmitEOL();
1775  PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
1776 }
1777 
1778 void MCAsmStreamer::PrintCVDefRangePrefix(
1779  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges) {
1780  OS << "\t.cv_def_range\t";
1781  for (std::pair<const MCSymbol *, const MCSymbol *> Range : Ranges) {
1782  OS << ' ';
1783  Range.first->print(OS, MAI);
1784  OS << ' ';
1785  Range.second->print(OS, MAI);
1786  }
1787 }
1788 
1789 void MCAsmStreamer::emitCVDefRangeDirective(
1790  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1792  PrintCVDefRangePrefix(Ranges);
1793  OS << ", reg_rel, ";
1794  OS << DRHdr.Register << ", " << DRHdr.Flags << ", "
1795  << DRHdr.BasePointerOffset;
1796  EmitEOL();
1797 }
1798 
1799 void MCAsmStreamer::emitCVDefRangeDirective(
1800  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1802  PrintCVDefRangePrefix(Ranges);
1803  OS << ", subfield_reg, ";
1804  OS << DRHdr.Register << ", " << DRHdr.OffsetInParent;
1805  EmitEOL();
1806 }
1807 
1808 void MCAsmStreamer::emitCVDefRangeDirective(
1809  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1811  PrintCVDefRangePrefix(Ranges);
1812  OS << ", reg, ";
1813  OS << DRHdr.Register;
1814  EmitEOL();
1815 }
1816 
1817 void MCAsmStreamer::emitCVDefRangeDirective(
1818  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
1820  PrintCVDefRangePrefix(Ranges);
1821  OS << ", frame_ptr_rel, ";
1822  OS << DRHdr.Offset;
1823  EmitEOL();
1824 }
1825 
1826 void MCAsmStreamer::emitCVStringTableDirective() {
1827  OS << "\t.cv_stringtable";
1828  EmitEOL();
1829 }
1830 
1831 void MCAsmStreamer::emitCVFileChecksumsDirective() {
1832  OS << "\t.cv_filechecksums";
1833  EmitEOL();
1834 }
1835 
1836 void MCAsmStreamer::emitCVFileChecksumOffsetDirective(unsigned FileNo) {
1837  OS << "\t.cv_filechecksumoffset\t" << FileNo;
1838  EmitEOL();
1839 }
1840 
1841 void MCAsmStreamer::emitCVFPOData(const MCSymbol *ProcSym, SMLoc L) {
1842  OS << "\t.cv_fpo_data\t";
1843  ProcSym->print(OS, MAI);
1844  EmitEOL();
1845 }
1846 
1847 void MCAsmStreamer::emitIdent(StringRef IdentString) {
1848  assert(MAI->hasIdentDirective() && ".ident directive not supported");
1849  OS << "\t.ident\t";
1850  PrintQuotedString(IdentString, OS);
1851  EmitEOL();
1852 }
1853 
1854 void MCAsmStreamer::emitCFISections(bool EH, bool Debug) {
1855  MCStreamer::emitCFISections(EH, Debug);
1856  OS << "\t.cfi_sections ";
1857  if (EH) {
1858  OS << ".eh_frame";
1859  if (Debug)
1860  OS << ", .debug_frame";
1861  } else if (Debug) {
1862  OS << ".debug_frame";
1863  }
1864 
1865  EmitEOL();
1866 }
1867 
1868 void MCAsmStreamer::emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
1869  OS << "\t.cfi_startproc";
1870  if (Frame.IsSimple)
1871  OS << " simple";
1872  EmitEOL();
1873 }
1874 
1875 void MCAsmStreamer::emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
1877  OS << "\t.cfi_endproc";
1878  EmitEOL();
1879 }
1880 
1881 void MCAsmStreamer::EmitRegisterName(int64_t Register) {
1882  if (!MAI->useDwarfRegNumForCFI()) {
1883  // User .cfi_* directives can use arbitrary DWARF register numbers, not
1884  // just ones that map to LLVM register numbers and have known names.
1885  // Fall back to using the original number directly if no name is known.
1886  const MCRegisterInfo *MRI = getContext().getRegisterInfo();
1887  if (Optional<unsigned> LLVMRegister = MRI->getLLVMRegNum(Register, true)) {
1888  InstPrinter->printRegName(OS, *LLVMRegister);
1889  return;
1890  }
1891  }
1892  OS << Register;
1893 }
1894 
1895 void MCAsmStreamer::emitCFIDefCfa(int64_t Register, int64_t Offset) {
1897  OS << "\t.cfi_def_cfa ";
1898  EmitRegisterName(Register);
1899  OS << ", " << Offset;
1900  EmitEOL();
1901 }
1902 
1903 void MCAsmStreamer::emitCFIDefCfaOffset(int64_t Offset) {
1905  OS << "\t.cfi_def_cfa_offset " << Offset;
1906  EmitEOL();
1907 }
1908 
1909 void MCAsmStreamer::emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset,
1910  int64_t AddressSpace) {
1912  OS << "\t.cfi_llvm_def_aspace_cfa ";
1913  EmitRegisterName(Register);
1914  OS << ", " << Offset;
1915  OS << ", " << AddressSpace;
1916  EmitEOL();
1917 }
1918 
1920  OS << "\t.cfi_escape ";
1921  if (!Values.empty()) {
1922  size_t e = Values.size() - 1;
1923  for (size_t i = 0; i < e; ++i)
1924  OS << format("0x%02x", uint8_t(Values[i])) << ", ";
1925  OS << format("0x%02x", uint8_t(Values[e]));
1926  }
1927 }
1928 
1929 void MCAsmStreamer::emitCFIEscape(StringRef Values) {
1930  MCStreamer::emitCFIEscape(Values);
1931  PrintCFIEscape(OS, Values);
1932  EmitEOL();
1933 }
1934 
1935 void MCAsmStreamer::emitCFIGnuArgsSize(int64_t Size) {
1937 
1938  uint8_t Buffer[16] = { dwarf::DW_CFA_GNU_args_size };
1939  unsigned Len = encodeULEB128(Size, Buffer + 1) + 1;
1940 
1941  PrintCFIEscape(OS, StringRef((const char *)&Buffer[0], Len));
1942  EmitEOL();
1943 }
1944 
1945 void MCAsmStreamer::emitCFIDefCfaRegister(int64_t Register) {
1947  OS << "\t.cfi_def_cfa_register ";
1948  EmitRegisterName(Register);
1949  EmitEOL();
1950 }
1951 
1952 void MCAsmStreamer::emitCFIOffset(int64_t Register, int64_t Offset) {
1953  this->MCStreamer::emitCFIOffset(Register, Offset);
1954  OS << "\t.cfi_offset ";
1955  EmitRegisterName(Register);
1956  OS << ", " << Offset;
1957  EmitEOL();
1958 }
1959 
1960 void MCAsmStreamer::emitCFIPersonality(const MCSymbol *Sym,
1961  unsigned Encoding) {
1962  MCStreamer::emitCFIPersonality(Sym, Encoding);
1963  OS << "\t.cfi_personality " << Encoding << ", ";
1964  Sym->print(OS, MAI);
1965  EmitEOL();
1966 }
1967 
1968 void MCAsmStreamer::emitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
1969  MCStreamer::emitCFILsda(Sym, Encoding);
1970  OS << "\t.cfi_lsda " << Encoding << ", ";
1971  Sym->print(OS, MAI);
1972  EmitEOL();
1973 }
1974 
1975 void MCAsmStreamer::emitCFIRememberState() {
1977  OS << "\t.cfi_remember_state";
1978  EmitEOL();
1979 }
1980 
1981 void MCAsmStreamer::emitCFIRestoreState() {
1983  OS << "\t.cfi_restore_state";
1984  EmitEOL();
1985 }
1986 
1987 void MCAsmStreamer::emitCFIRestore(int64_t Register) {
1989  OS << "\t.cfi_restore ";
1990  EmitRegisterName(Register);
1991  EmitEOL();
1992 }
1993 
1994 void MCAsmStreamer::emitCFISameValue(int64_t Register) {
1996  OS << "\t.cfi_same_value ";
1997  EmitRegisterName(Register);
1998  EmitEOL();
1999 }
2000 
2001 void MCAsmStreamer::emitCFIRelOffset(int64_t Register, int64_t Offset) {
2003  OS << "\t.cfi_rel_offset ";
2004  EmitRegisterName(Register);
2005  OS << ", " << Offset;
2006  EmitEOL();
2007 }
2008 
2009 void MCAsmStreamer::emitCFIAdjustCfaOffset(int64_t Adjustment) {
2011  OS << "\t.cfi_adjust_cfa_offset " << Adjustment;
2012  EmitEOL();
2013 }
2014 
2015 void MCAsmStreamer::emitCFISignalFrame() {
2017  OS << "\t.cfi_signal_frame";
2018  EmitEOL();
2019 }
2020 
2021 void MCAsmStreamer::emitCFIUndefined(int64_t Register) {
2023  OS << "\t.cfi_undefined ";
2024  EmitRegisterName(Register);
2025  EmitEOL();
2026 }
2027 
2028 void MCAsmStreamer::emitCFIRegister(int64_t Register1, int64_t Register2) {
2029  MCStreamer::emitCFIRegister(Register1, Register2);
2030  OS << "\t.cfi_register ";
2031  EmitRegisterName(Register1);
2032  OS << ", ";
2033  EmitRegisterName(Register2);
2034  EmitEOL();
2035 }
2036 
2037 void MCAsmStreamer::emitCFIWindowSave() {
2039  OS << "\t.cfi_window_save";
2040  EmitEOL();
2041 }
2042 
2043 void MCAsmStreamer::emitCFINegateRAState() {
2045  OS << "\t.cfi_negate_ra_state";
2046  EmitEOL();
2047 }
2048 
2049 void MCAsmStreamer::emitCFIReturnColumn(int64_t Register) {
2051  OS << "\t.cfi_return_column ";
2052  EmitRegisterName(Register);
2053  EmitEOL();
2054 }
2055 
2056 void MCAsmStreamer::emitCFIBKeyFrame() {
2058  OS << "\t.cfi_b_key_frame";
2059  EmitEOL();
2060 }
2061 
2062 void MCAsmStreamer::emitCFIMTETaggedFrame() {
2064  OS << "\t.cfi_mte_tagged_frame";
2065  EmitEOL();
2066 }
2067 
2068 void MCAsmStreamer::emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc) {
2069  MCStreamer::emitWinCFIStartProc(Symbol, Loc);
2070 
2071  OS << ".seh_proc ";
2072  Symbol->print(OS, MAI);
2073  EmitEOL();
2074 }
2075 
2076 void MCAsmStreamer::emitWinCFIEndProc(SMLoc Loc) {
2078 
2079  OS << "\t.seh_endproc";
2080  EmitEOL();
2081 }
2082 
2083 void MCAsmStreamer::emitWinCFIFuncletOrFuncEnd(SMLoc Loc) {
2085 
2086  OS << "\t.seh_endfunclet";
2087  EmitEOL();
2088 }
2089 
2090 void MCAsmStreamer::emitWinCFIStartChained(SMLoc Loc) {
2092 
2093  OS << "\t.seh_startchained";
2094  EmitEOL();
2095 }
2096 
2097 void MCAsmStreamer::emitWinCFIEndChained(SMLoc Loc) {
2099 
2100  OS << "\t.seh_endchained";
2101  EmitEOL();
2102 }
2103 
2104 void MCAsmStreamer::emitWinEHHandler(const MCSymbol *Sym, bool Unwind,
2105  bool Except, SMLoc Loc) {
2106  MCStreamer::emitWinEHHandler(Sym, Unwind, Except, Loc);
2107 
2108  OS << "\t.seh_handler ";
2109  Sym->print(OS, MAI);
2110  char Marker = '@';
2111  const Triple &T = getContext().getTargetTriple();
2112  if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)
2113  Marker = '%';
2114  if (Unwind)
2115  OS << ", " << Marker << "unwind";
2116  if (Except)
2117  OS << ", " << Marker << "except";
2118  EmitEOL();
2119 }
2120 
2121 void MCAsmStreamer::emitWinEHHandlerData(SMLoc Loc) {
2123 
2124  // Switch sections. Don't call switchSection directly, because that will
2125  // cause the section switch to be visible in the emitted assembly.
2126  // We only do this so the section switch that terminates the handler
2127  // data block is visible.
2128  WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo();
2129 
2130  // Do nothing if no frame is open. MCStreamer should've already reported an
2131  // error.
2132  if (!CurFrame)
2133  return;
2134 
2135  MCSection *TextSec = &CurFrame->Function->getSection();
2136  MCSection *XData = getAssociatedXDataSection(TextSec);
2137  switchSectionNoChange(XData);
2138 
2139  OS << "\t.seh_handlerdata";
2140  EmitEOL();
2141 }
2142 
2143 void MCAsmStreamer::emitWinCFIPushReg(MCRegister Register, SMLoc Loc) {
2145 
2146  OS << "\t.seh_pushreg ";
2147  InstPrinter->printRegName(OS, Register);
2148  EmitEOL();
2149 }
2150 
2151 void MCAsmStreamer::emitWinCFISetFrame(MCRegister Register, unsigned Offset,
2152  SMLoc Loc) {
2154 
2155  OS << "\t.seh_setframe ";
2156  InstPrinter->printRegName(OS, Register);
2157  OS << ", " << Offset;
2158  EmitEOL();
2159 }
2160 
2161 void MCAsmStreamer::emitWinCFIAllocStack(unsigned Size, SMLoc Loc) {
2163 
2164  OS << "\t.seh_stackalloc " << Size;
2165  EmitEOL();
2166 }
2167 
2168 void MCAsmStreamer::emitWinCFISaveReg(MCRegister Register, unsigned Offset,
2169  SMLoc Loc) {
2171 
2172  OS << "\t.seh_savereg ";
2173  InstPrinter->printRegName(OS, Register);
2174  OS << ", " << Offset;
2175  EmitEOL();
2176 }
2177 
2178 void MCAsmStreamer::emitWinCFISaveXMM(MCRegister Register, unsigned Offset,
2179  SMLoc Loc) {
2181 
2182  OS << "\t.seh_savexmm ";
2183  InstPrinter->printRegName(OS, Register);
2184  OS << ", " << Offset;
2185  EmitEOL();
2186 }
2187 
2188 void MCAsmStreamer::emitWinCFIPushFrame(bool Code, SMLoc Loc) {
2190 
2191  OS << "\t.seh_pushframe";
2192  if (Code)
2193  OS << " @code";
2194  EmitEOL();
2195 }
2196 
2197 void MCAsmStreamer::emitWinCFIEndProlog(SMLoc Loc) {
2199 
2200  OS << "\t.seh_endprologue";
2201  EmitEOL();
2202 }
2203 
2204 void MCAsmStreamer::emitCGProfileEntry(const MCSymbolRefExpr *From,
2205  const MCSymbolRefExpr *To,
2206  uint64_t Count) {
2207  OS << "\t.cg_profile ";
2208  From->getSymbol().print(OS, MAI);
2209  OS << ", ";
2210  To->getSymbol().print(OS, MAI);
2211  OS << ", " << Count;
2212  EmitEOL();
2213 }
2214 
2215 void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
2216  const MCSubtargetInfo &STI) {
2217  raw_ostream &OS = getCommentOS();
2220  raw_svector_ostream VecOS(Code);
2221 
2222  // If we have no code emitter, don't emit code.
2223  if (!getAssembler().getEmitterPtr())
2224  return;
2225 
2226  getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
2227 
2228  // If we are showing fixups, create symbolic markers in the encoded
2229  // representation. We do this by making a per-bit map to the fixup item index,
2230  // then trying to display it as nicely as possible.
2231  SmallVector<uint8_t, 64> FixupMap;
2232  FixupMap.resize(Code.size() * 8);
2233  for (unsigned i = 0, e = Code.size() * 8; i != e; ++i)
2234  FixupMap[i] = 0;
2235 
2236  for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
2237  MCFixup &F = Fixups[i];
2238  const MCFixupKindInfo &Info =
2239  getAssembler().getBackend().getFixupKindInfo(F.getKind());
2240  for (unsigned j = 0; j != Info.TargetSize; ++j) {
2241  unsigned Index = F.getOffset() * 8 + Info.TargetOffset + j;
2242  assert(Index < Code.size() * 8 && "Invalid offset in fixup!");
2243  FixupMap[Index] = 1 + i;
2244  }
2245  }
2246 
2247  // FIXME: Note the fixup comments for Thumb2 are completely bogus since the
2248  // high order halfword of a 32-bit Thumb2 instruction is emitted first.
2249  OS << "encoding: [";
2250  for (unsigned i = 0, e = Code.size(); i != e; ++i) {
2251  if (i)
2252  OS << ',';
2253 
2254  // See if all bits are the same map entry.
2255  uint8_t MapEntry = FixupMap[i * 8 + 0];
2256  for (unsigned j = 1; j != 8; ++j) {
2257  if (FixupMap[i * 8 + j] == MapEntry)
2258  continue;
2259 
2260  MapEntry = uint8_t(~0U);
2261  break;
2262  }
2263 
2264  if (MapEntry != uint8_t(~0U)) {
2265  if (MapEntry == 0) {
2266  OS << format("0x%02x", uint8_t(Code[i]));
2267  } else {
2268  if (Code[i]) {
2269  // FIXME: Some of the 8 bits require fix up.
2270  OS << format("0x%02x", uint8_t(Code[i])) << '\''
2271  << char('A' + MapEntry - 1) << '\'';
2272  } else
2273  OS << char('A' + MapEntry - 1);
2274  }
2275  } else {
2276  // Otherwise, write out in binary.
2277  OS << "0b";
2278  for (unsigned j = 8; j--;) {
2279  unsigned Bit = (Code[i] >> j) & 1;
2280 
2281  unsigned FixupBit;
2282  if (MAI->isLittleEndian())
2283  FixupBit = i * 8 + j;
2284  else
2285  FixupBit = i * 8 + (7-j);
2286 
2287  if (uint8_t MapEntry = FixupMap[FixupBit]) {
2288  assert(Bit == 0 && "Encoder wrote into fixed up bit!");
2289  OS << char('A' + MapEntry - 1);
2290  } else
2291  OS << Bit;
2292  }
2293  }
2294  }
2295  OS << "]\n";
2296 
2297  for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
2298  MCFixup &F = Fixups[i];
2299  const MCFixupKindInfo &Info =
2300  getAssembler().getBackend().getFixupKindInfo(F.getKind());
2301  OS << " fixup " << char('A' + i) << " - "
2302  << "offset: " << F.getOffset() << ", value: ";
2303  F.getValue()->print(OS, MAI);
2304  OS << ", kind: " << Info.Name << "\n";
2305  }
2306 }
2307 
2308 void MCAsmStreamer::emitInstruction(const MCInst &Inst,
2309  const MCSubtargetInfo &STI) {
2310  assert(getCurrentSectionOnly() &&
2311  "Cannot emit contents before setting section!");
2312 
2313  if (!MAI->usesDwarfFileAndLocDirectives())
2314  // Now that a machine instruction has been assembled into this section, make
2315  // a line entry for any .loc directive that has been seen.
2316  MCDwarfLineEntry::make(this, getCurrentSectionOnly());
2317 
2318  // Show the encoding in a comment if we have a code emitter.
2319  AddEncodingComment(Inst, STI);
2320 
2321  // Show the MCInst if enabled.
2322  if (ShowInst) {
2323  Inst.dump_pretty(getCommentOS(), InstPrinter.get(), "\n ");
2324  getCommentOS() << "\n";
2325  }
2326 
2327  if(getTargetStreamer())
2328  getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2329  else
2330  InstPrinter->printInst(&Inst, 0, "", STI, OS);
2331 
2332  StringRef Comments = CommentToEmit;
2333  if (Comments.size() && Comments.back() != '\n')
2334  getCommentOS() << "\n";
2335 
2336  EmitEOL();
2337 }
2338 
2339 void MCAsmStreamer::emitPseudoProbe(
2341  const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym) {
2342  OS << "\t.pseudoprobe\t" << Guid << " " << Index << " " << Type << " "
2343  << Attr;
2344  // Emit inline stack like
2345  // @ GUIDmain:3 @ GUIDCaller:1 @ GUIDDirectCaller:11
2346  for (const auto &Site : InlineStack)
2347  OS << " @ " << std::get<0>(Site) << ":" << std::get<1>(Site);
2348 
2349  OS << " " << FnSym->getName();
2350 
2351  EmitEOL();
2352 }
2353 
2354 void MCAsmStreamer::emitBundleAlignMode(Align Alignment) {
2355  OS << "\t.bundle_align_mode " << Log2(Alignment);
2356  EmitEOL();
2357 }
2358 
2359 void MCAsmStreamer::emitBundleLock(bool AlignToEnd) {
2360  OS << "\t.bundle_lock";
2361  if (AlignToEnd)
2362  OS << " align_to_end";
2363  EmitEOL();
2364 }
2365 
2366 void MCAsmStreamer::emitBundleUnlock() {
2367  OS << "\t.bundle_unlock";
2368  EmitEOL();
2369 }
2370 
2372 MCAsmStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
2373  const MCExpr *Expr, SMLoc,
2374  const MCSubtargetInfo &STI) {
2375  OS << "\t.reloc ";
2376  Offset.print(OS, MAI);
2377  OS << ", " << Name;
2378  if (Expr) {
2379  OS << ", ";
2380  Expr->print(OS, MAI);
2381  }
2382  EmitEOL();
2383  return None;
2384 }
2385 
2386 void MCAsmStreamer::emitAddrsig() {
2387  OS << "\t.addrsig";
2388  EmitEOL();
2389 }
2390 
2391 void MCAsmStreamer::emitAddrsigSym(const MCSymbol *Sym) {
2392  OS << "\t.addrsig_sym ";
2393  Sym->print(OS, MAI);
2394  EmitEOL();
2395 }
2396 
2397 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
2398 /// the specified string in the output .s file. This capability is
2399 /// indicated by the hasRawTextSupport() predicate.
2400 void MCAsmStreamer::emitRawTextImpl(StringRef String) {
2401  if (!String.empty() && String.back() == '\n')
2402  String = String.substr(0, String.size()-1);
2403  OS << String;
2404  EmitEOL();
2405 }
2406 
2407 void MCAsmStreamer::finishImpl() {
2408  // If we are generating dwarf for assembly source files dump out the sections.
2409  if (getContext().getGenDwarfForAssembly())
2410  MCGenDwarfInfo::Emit(this);
2411 
2412  // Now it is time to emit debug line sections if target doesn't support .loc
2413  // and .line directives.
2414  if (!MAI->usesDwarfFileAndLocDirectives()) {
2415  MCDwarfLineTable::emit(this, getAssembler().getDWARFLinetableParams());
2416  return;
2417  }
2418 
2419  // Emit the label for the line table, if requested - since the rest of the
2420  // line table will be defined by .loc/.file directives, and not emitted
2421  // directly, the label is the only work required here.
2422  const auto &Tables = getContext().getMCDwarfLineTables();
2423  if (!Tables.empty()) {
2424  assert(Tables.size() == 1 && "asm output only supports one line table");
2425  if (auto *Label = Tables.begin()->second.getLabel()) {
2426  switchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
2427  emitLabel(Label);
2428  }
2429  }
2430 }
2431 
2432 void MCAsmStreamer::emitDwarfUnitLength(uint64_t Length, const Twine &Comment) {
2433  // If the assembler on some target fills in the DWARF unit length, we
2434  // don't want to emit the length in the compiler. For example, the AIX
2435  // assembler requires the assembly file with the unit length omitted from
2436  // the debug section headers. In such cases, any label we placed occurs
2437  // after the implied length field. We need to adjust the reference here
2438  // to account for the offset introduced by the inserted length field.
2439  if (!MAI->needsDwarfSectionSizeInHeader())
2440  return;
2441  MCStreamer::emitDwarfUnitLength(Length, Comment);
2442 }
2443 
2444 MCSymbol *MCAsmStreamer::emitDwarfUnitLength(const Twine &Prefix,
2445  const Twine &Comment) {
2446  // If the assembler on some target fills in the DWARF unit length, we
2447  // don't want to emit the length in the compiler. For example, the AIX
2448  // assembler requires the assembly file with the unit length omitted from
2449  // the debug section headers. In such cases, any label we placed occurs
2450  // after the implied length field. We need to adjust the reference here
2451  // to account for the offset introduced by the inserted length field.
2452  if (!MAI->needsDwarfSectionSizeInHeader())
2453  return getContext().createTempSymbol(Prefix + "_end");
2454  return MCStreamer::emitDwarfUnitLength(Prefix, Comment);
2455 }
2456 
2457 void MCAsmStreamer::emitDwarfLineStartLabel(MCSymbol *StartSym) {
2458  // If the assembler on some target fills in the DWARF unit length, we
2459  // don't want to emit the length in the compiler. For example, the AIX
2460  // assembler requires the assembly file with the unit length omitted from
2461  // the debug section headers. In such cases, any label we placed occurs
2462  // after the implied length field. We need to adjust the reference here
2463  // to account for the offset introduced by the inserted length field.
2464  MCContext &Ctx = getContext();
2465  if (!MAI->needsDwarfSectionSizeInHeader()) {
2466  MCSymbol *DebugLineSymTmp = Ctx.createTempSymbol("debug_line_");
2467  // Emit the symbol which does not contain the unit length field.
2468  emitLabel(DebugLineSymTmp);
2469 
2470  // Adjust the outer reference to account for the offset introduced by the
2471  // inserted length field.
2472  unsigned LengthFieldSize =
2474  const MCExpr *EntrySize = MCConstantExpr::create(LengthFieldSize, Ctx);
2475  const MCExpr *OuterSym = MCBinaryExpr::createSub(
2476  MCSymbolRefExpr::create(DebugLineSymTmp, Ctx), EntrySize, Ctx);
2477 
2478  emitAssignment(StartSym, OuterSym);
2479  return;
2480  }
2482 }
2483 
2484 void MCAsmStreamer::emitDwarfLineEndEntry(MCSection *Section,
2485  MCSymbol *LastLabel) {
2486  // If the targets write the raw debug line data for assembly output (We can
2487  // not switch to Section and add the end symbol there for assembly output)
2488  // we currently use the .text end label as any section end. This will not
2489  // impact the debugability as we will jump to the caller of the last function
2490  // in the section before we come into the .text end address.
2492  ".loc should not be generated together with raw data!");
2493 
2494  MCContext &Ctx = getContext();
2495 
2496  // FIXME: use section end symbol as end of the Section. We need to consider
2497  // the explicit sections and -ffunction-sections when we try to generate or
2498  // find section end symbol for the Section.
2499  MCSection *TextSection = Ctx.getObjectFileInfo()->getTextSection();
2500  assert(TextSection->hasEnded() && ".text section is not end!");
2501 
2502  MCSymbol *SectionEnd = TextSection->getEndSymbol(Ctx);
2503  const MCAsmInfo *AsmInfo = Ctx.getAsmInfo();
2504  emitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, SectionEnd,
2505  AsmInfo->getCodePointerSize());
2506 }
2507 
2508 // Generate DWARF line sections for assembly mode without .loc/.file
2509 void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
2510  const MCSymbol *LastLabel,
2511  const MCSymbol *Label,
2512  unsigned PointerSize) {
2514  ".loc/.file don't need raw data in debug line section!");
2515 
2516  // Set to new address.
2517  AddComment("Set address to " + Label->getName());
2518  emitIntValue(dwarf::DW_LNS_extended_op, 1);
2519  emitULEB128IntValue(PointerSize + 1);
2520  emitIntValue(dwarf::DW_LNE_set_address, 1);
2521  emitSymbolValue(Label, PointerSize);
2522 
2523  if (!LastLabel) {
2524  // Emit the sequence for the LineDelta (from 1) and a zero address delta.
2525  AddComment("Start sequence");
2526  MCDwarfLineAddr::Emit(this, MCDwarfLineTableParams(), LineDelta, 0);
2527  return;
2528  }
2529 
2530  // INT64_MAX is a signal of the end of the section. Emit DW_LNE_end_sequence
2531  // for the end of the section.
2532  if (LineDelta == INT64_MAX) {
2533  AddComment("End sequence");
2534  emitIntValue(dwarf::DW_LNS_extended_op, 1);
2535  emitULEB128IntValue(1);
2536  emitIntValue(dwarf::DW_LNE_end_sequence, 1);
2537  return;
2538  }
2539 
2540  // Advance line.
2541  AddComment("Advance line " + Twine(LineDelta));
2542  emitIntValue(dwarf::DW_LNS_advance_line, 1);
2543  emitSLEB128IntValue(LineDelta);
2544  emitIntValue(dwarf::DW_LNS_copy, 1);
2545 }
2546 
2547 void MCAsmStreamer::doFinalizationAtSectionEnd(MCSection *Section) {
2548  // Emit section end. This is used to tell the debug line section where the end
2549  // is for a text section if we don't use .loc to represent the debug line.
2550  if (MAI->usesDwarfFileAndLocDirectives())
2551  return;
2552 
2553  switchSectionNoChange(Section);
2554 
2555  MCSymbol *Sym = getCurrentSectionOnly()->getEndSymbol(getContext());
2556 
2557  if (!Sym->isInSection())
2558  emitLabel(Sym);
2559 }
2560 
2562  std::unique_ptr<formatted_raw_ostream> OS,
2563  bool isVerboseAsm, bool useDwarfDirectory,
2564  MCInstPrinter *IP,
2565  std::unique_ptr<MCCodeEmitter> &&CE,
2566  std::unique_ptr<MCAsmBackend> &&MAB,
2567  bool ShowInst) {
2568  return new MCAsmStreamer(Context, std::move(OS), isVerboseAsm,
2569  useDwarfDirectory, IP, std::move(CE), std::move(MAB),
2570  ShowInst);
2571 }
llvm::Check::Size
@ Size
Definition: FileCheck.h:77
llvm::MCStreamer::emitCVInlineLinetableDirective
virtual void emitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
Definition: MCStreamer.cpp:350
i
i
Definition: README.txt:29
llvm::MCDwarfLineTable::tryGetFile
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition: MCDwarf.cpp:562
llvm::MCAsmInfo::hasSingleParameterDotFile
bool hasSingleParameterDotFile() const
Definition: MCAsmInfo.h:748
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:156
llvm::MCContext::getObjectFileInfo
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:451
llvm::MCAsmInfo::useDwarfRegNumForCFI
bool useDwarfRegNumForCFI() const
Definition: MCAsmInfo.h:804
llvm::MCStreamer::emitCVFuncIdDirective
virtual bool emitCVFuncIdDirective(unsigned FunctionId)
Introduces a function id for use with .cv_loc.
Definition: MCStreamer.cpp:301
llvm::MCStreamer::emitCFIDefCfaOffset
virtual void emitCFIDefCfaOffset(int64_t Offset)
Definition: MCStreamer.cpp:503
llvm::MCVersionMinType
MCVersionMinType
Definition: MCDirectives.h:67
llvm::MachO::PLATFORM_MACOS
@ PLATFORM_MACOS
Definition: MachO.h:499
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:108
MathExtras.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::MCAsmInfo::getCommentString
StringRef getCommentString() const
Definition: MCAsmInfo.h:653
llvm::MachO::PLATFORM_WATCHOSSIMULATOR
@ PLATFORM_WATCHOSSIMULATOR
Definition: MachO.h:507
llvm::MCDataRegionType
MCDataRegionType
Definition: MCDirectives.h:59
llvm::MCStreamer::emitCFILLVMDefAspaceCfa
virtual void emitCFILLVMDefAspaceCfa(int64_t Register, int64_t Offset, int64_t AddressSpace)
Definition: MCStreamer.cpp:534
llvm::MCStreamer::emitWinCFISetFrame
virtual void emitWinCFISetFrame(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:876
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::MCAsmInfo::getSeparatorString
const char * getSeparatorString() const
Definition: MCAsmInfo.h:647
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::drop_begin
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition: STLExtras.h:387
Optional.h
llvm::MCVM_WatchOSVersionMin
@ MCVM_WatchOSVersionMin
.watchos_version_min
Definition: MCDirectives.h:71
llvm::MCStreamer::emitCFIOffset
virtual void emitCFIOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:546
llvm::MCContext::getDwarfFormat
dwarf::DwarfFormat getDwarfFormat() const
Definition: MCContext.h:824
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:161
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:76
llvm::Attribute
Definition: Attributes.h:66
llvm::MCLOHType
MCLOHType
Linker Optimization Hint Type.
Definition: MCLinkerOptimizationHint.h:33
llvm::MCSymbolXCOFF::getSymbolTableName
StringRef getSymbolTableName() const
Definition: MCSymbolXCOFF.h:60
llvm::MCSA_ELF_TypeObject
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
Definition: MCDirectives.h:25
MCCodeEmitter.h
llvm::MCStreamer::emitCFISections
virtual void emitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:445
llvm::MCSA_Invalid
@ MCSA_Invalid
Not a valid directive.
Definition: MCDirectives.h:19
SymbolRecord.h
llvm::MCConstantExpr::create
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
truncateToSize
static int64_t truncateToSize(int64_t Value, unsigned Bytes)
Definition: MCAsmStreamer.cpp:450
llvm::MCStreamer::emitWinCFIAllocStack
virtual void emitWinCFIAllocStack(unsigned Size, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:898
llvm::codeview::DefRangeFramePointerRelHeader
Definition: SymbolRecord.h:525
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::tgtok::Code
@ Code
Definition: TGLexer.h:50
Path.h
llvm::sys::path::is_absolute
bool is_absolute(const Twine &path, Style style=Style::native)
Is path absolute?
Definition: Path.cpp:671
llvm::MCSection::SV_MachO
@ SV_MachO
Definition: MCSection.h:47
llvm::MCAsmInfo::useDotAlignForAlignment
bool useDotAlignForAlignment() const
Definition: MCAsmInfo.h:705
ErrorHandling.h
llvm::MCLOHDirectiveName
static StringRef MCLOHDirectiveName()
Definition: MCLinkerOptimizationHint.h:44
llvm::MCVM_IOSVersionMin
@ MCVM_IOSVersionMin
.ios_version_min
Definition: MCDirectives.h:68
llvm::MCStreamer::emitCFIRegister
virtual void emitCFIRegister(int64_t Register1, int64_t Register2)
Definition: MCStreamer.cpp:658
llvm::MCStreamer::emitWinCFISaveReg
virtual void emitWinCFISaveReg(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:915
llvm::logicalview::LVAttributeKind::Filename
@ Filename
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
MCAssembler.h
llvm::MachO::PLATFORM_IOS
@ PLATFORM_IOS
Definition: MachO.h:500
llvm::MCStreamer::emitCVLinetableDirective
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
Definition: MCStreamer.cpp:346
llvm::LCOMM::Log2Alignment
@ Log2Alignment
Definition: MCAsmInfo.h:50
MCObjectFileInfo.h
llvm::MachO::PLATFORM_MACCATALYST
@ PLATFORM_MACCATALYST
Definition: MachO.h:504
Shift
bool Shift
Definition: README.txt:468
llvm::MCStreamer::emitWinEHHandler
virtual void emitWinEHHandler(const MCSymbol *Sym, bool Unwind, bool Except, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:783
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::MCStreamer::emitCFISignalFrame
virtual void emitCFISignalFrame()
Definition: MCStreamer.cpp:641
MCPseudoProbe.h
llvm::MCVM_OSXVersionMin
@ MCVM_OSXVersionMin
.macosx_version_min
Definition: MCDirectives.h:69
llvm::MCAsmInfo::getCodePointerSize
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
Definition: MCAsmInfo.h:548
llvm::Optional
Definition: APInt.h:33
MCFixupKindInfo.h
llvm::StringRef::substr
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:564
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::MCSA_ELF_TypeNoType
@ MCSA_ELF_TypeNoType
.type _foo, STT_NOTYPE # aka @notype
Definition: MCDirectives.h:28
llvm::MCAsmInfo::getAssemblerDialect
unsigned getAssemblerDialect() const
Definition: MCAsmInfo.h:684
llvm::sys::locale::isPrint
bool isPrint(int c)
Definition: Locale.cpp:13
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::MCAssemblerFlag
MCAssemblerFlag
Definition: MCDirectives.h:51
llvm::isPowerOf2_32
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:458
llvm::MCAsmInfo::getData64bitsDirective
const char * getData64bitsDirective() const
Definition: MCAsmInfo.h:569
llvm::dwarf::Tag
Tag
Definition: Dwarf.h:105
Format.h
llvm::nulls
raw_ostream & nulls()
This returns a reference to a raw_ostream which simply discards output.
Definition: raw_ostream.cpp:898
llvm::MCLOHIdToName
static StringRef MCLOHIdToName(MCLOHType Kind)
Definition: MCLinkerOptimizationHint.h:67
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
p
the resulting code requires compare and branches when and if * p
Definition: README.txt:396
llvm::MCStreamer::emitDwarfUnitLength
virtual void emitDwarfUnitLength(uint64_t Length, const Twine &Comment)
Emit a unit length field.
Definition: MCStreamer.cpp:1023
llvm::MCAsmInfo::supportsExtendedDwarfLocDirective
bool supportsExtendedDwarfLocDirective() const
Definition: MCAsmInfo.h:809
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::MCStreamer::emitCFIDefCfaRegister
virtual void emitCFIDefCfaRegister(int64_t Register)
Definition: MCStreamer.cpp:523
llvm::MCStreamer::emitCFIAdjustCfaOffset
virtual void emitCFIAdjustCfaOffset(int64_t Adjustment)
Definition: MCStreamer.cpp:513
llvm::MCSymbolAttr
MCSymbolAttr
Definition: MCDirectives.h:18
llvm::MCSA_Cold
@ MCSA_Cold
.cold (MachO)
Definition: MCDirectives.h:22
llvm::MCDR_DataRegionJT16
@ MCDR_DataRegionJT16
.data_region jt16
Definition: MCDirectives.h:62
llvm::MCStreamer::emitCFIPersonality
virtual void emitCFIPersonality(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:566
llvm::VersionTuple::getMajor
unsigned getMajor() const
Retrieve the major version number.
Definition: VersionTuple.h:72
llvm::MCSA_Local
@ MCSA_Local
.local (ELF)
Definition: MCDirectives.h:38
llvm::MachO::PLATFORM_IOSSIMULATOR
@ PLATFORM_IOSSIMULATOR
Definition: MachO.h:505
llvm::sys::path::append
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
Definition: Path.cpp:456
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:82
llvm::MCSA_NoDeadStrip
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
Definition: MCDirectives.h:39
llvm::MCStreamer::emitCFIEndProcImpl
virtual void emitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame)
Definition: MCStreamer.cpp:480
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
FormattedStream.h
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:212
llvm::MachO::PLATFORM_UNKNOWN
@ PLATFORM_UNKNOWN
Definition: MachO.h:498
llvm::MCDR_DataRegion
@ MCDR_DataRegion
.data_region
Definition: MCDirectives.h:60
DWARF2_FLAG_IS_STMT
#define DWARF2_FLAG_IS_STMT
Definition: MCDwarf.h:113
llvm::MCGenDwarfInfo::Emit
static void Emit(MCStreamer *MCOS)
Definition: MCDwarf.cpp:1138
llvm::MCAsmInfo::hasFourStringsDotFile
bool hasFourStringsDotFile() const
Definition: MCAsmInfo.h:749
llvm::MCStreamer::emitCFIUndefined
virtual void emitCFIUndefined(int64_t Register)
Definition: MCStreamer.cpp:648
llvm::formatted_raw_ostream::PadToColumn
formatted_raw_ostream & PadToColumn(unsigned NewCol)
PadToColumn - Align the output to some column number.
Definition: FormattedStream.cpp:115
llvm::MCSymbol::getSection
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:262
MCAsmBackend.h
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::MCAsmInfo::getTextAlignFillValue
unsigned getTextAlignFillValue() const
Definition: MCAsmInfo.h:723
llvm::codeview::DefRangeRegisterRelHeader::BasePointerOffset
little32_t BasePointerOffset
Definition: SymbolRecord.h:554
llvm::MCStreamer::emitCFIRelOffset
virtual void emitCFIRelOffset(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:556
llvm::PowerOf2Floor
uint64_t PowerOf2Floor(uint64_t A)
Returns the power of two which is less than or equal to the given value.
Definition: MathExtras.h:623
llvm::MCStreamer::emitCFISameValue
virtual void emitCFISameValue(int64_t Register)
Definition: MCStreamer.cpp:602
PrintCFIEscape
static void PrintCFIEscape(llvm::formatted_raw_ostream &OS, StringRef Values)
Definition: MCAsmStreamer.cpp:1919
SmallString.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::createAsmStreamer
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, bool isVerboseAsm, bool useDwarfDirectory, MCInstPrinter *InstPrint, std::unique_ptr< MCCodeEmitter > &&CE, std::unique_ptr< MCAsmBackend > &&TAB, bool ShowInst)
Create a machine code streamer which will print out assembly for the native target,...
Definition: MCAsmStreamer.cpp:2561
llvm::MCAsmInfo::getAscizDirective
const char * getAscizDirective() const
Definition: MCAsmInfo.h:716
llvm::MCDwarfLineTableParams
Definition: MCDwarf.h:244
llvm::MCStreamer::emitWinCFISaveXMM
virtual void emitWinCFISaveXMM(MCRegister Register, unsigned Offset, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:932
llvm::MCSA_Extern
@ MCSA_Extern
.extern (XCOFF)
Definition: MCDirectives.h:32
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::MCSA_AltEntry
@ MCSA_AltEntry
.alt_entry (MachO)
Definition: MCDirectives.h:41
Twine.h
llvm::Log2
unsigned Log2(Align A)
Returns the log2 of the alignment.
Definition: Alignment.h:209
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
llvm::MCSA_Protected
@ MCSA_Protected
.protected (ELF)
Definition: MCDirectives.h:43
MCContext.h
llvm::MCAsmInfo::doesZeroDirectiveSupportNonZeroValue
bool doesZeroDirectiveSupportNonZeroValue() const
Definition: MCAsmInfo.h:712
MCSectionMachO.h
llvm::MCStreamer::emitLabel
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:423
llvm::MCSA_LazyReference
@ MCSA_LazyReference
.lazy_reference (MachO)
Definition: MCDirectives.h:37
llvm::MCSymbolXCOFF::hasRename
bool hasRename() const
Definition: MCSymbolXCOFF.h:56
llvm::MCSection::hasEnded
bool hasEnded() const
Definition: MCSection.cpp:35
llvm::MCSA_LGlobal
@ MCSA_LGlobal
.lglobl (XCOFF)
Definition: MCDirectives.h:31
IP
Definition: NVPTXLowerArgs.cpp:168
llvm::MCStreamer::emitWinCFIEndChained
virtual void emitWinCFIEndChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:769
llvm::MCAF_Code16
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:54
MCInst.h
toOctal
static char toOctal(int X)
Definition: MCAsmStreamer.cpp:1073
llvm::MCStreamer::emitWinEHHandlerData
virtual void emitWinEHHandlerData(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:800
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::Log2_32
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Definition: MathExtras.h:547
llvm::MCSA_ELF_TypeIndFunction
@ MCSA_ELF_TypeIndFunction
.type _foo, STT_GNU_IFUNC
Definition: MCDirectives.h:24
llvm::AArch64::Fixups
Fixups
Definition: AArch64FixupKinds.h:17
llvm::MCSA_Reference
@ MCSA_Reference
.reference (MachO)
Definition: MCDirectives.h:44
llvm::logicalview::LVSortMode::Line
@ Line
llvm::MCDwarfLineTable
Definition: MCDwarf.h:346
llvm::MCAsmInfo::doesSupportDataRegionDirectives
bool doesSupportDataRegionDirectives() const
Definition: MCAsmInfo.h:701
llvm::MCDwarfLineTable::emit
static void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
Definition: MCDwarf.cpp:256
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:147
llvm::MCStreamer::emitAssignment
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:1051
llvm::MCAsmInfo::needsDwarfSectionSizeInHeader
bool needsDwarfSectionSizeInHeader() const
Definition: MCAsmInfo.h:817
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::MachO::PlatformType
PlatformType
Definition: MachO.h:497
llvm::MCSymbolRefExpr::getSymbol
const MCSymbol & getSymbol() const
Definition: MCExpr.h:399
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition: SmallVector.h:642
llvm::MCAsmInfo::ACLS_SingleQuotePrefix
@ ACLS_SingleQuotePrefix
Unknown; character literals not used by LLVM for this target.
Definition: MCAsmInfo.h:62
INT64_MAX
#define INT64_MAX
Definition: DataTypes.h:71
llvm::VersionTuple
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:31
llvm::MCSA_Hidden
@ MCSA_Hidden
.hidden (ELF)
Definition: MCDirectives.h:33
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:93
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::MCSymbol::getName
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:198
llvm::MCAsmInfo::characterLiteralSyntax
AsmCharLiteralSyntax characterLiteralSyntax() const
Definition: MCAsmInfo.h:719
llvm::MCSA_ELF_TypeGnuUniqueObject
@ MCSA_ELF_TypeGnuUniqueObject
Definition: MCDirectives.h:29
llvm::raw_ostream::GetNumBytesInBuffer
size_t GetNumBytesInBuffer() const
Definition: raw_ostream.h:178
llvm::codeview::DefRangeRegisterHeader::Register
ulittle16_t Register
Definition: SymbolRecord.h:480
llvm::MCAsmInfo::getZeroDirective
const char * getZeroDirective() const
Definition: MCAsmInfo.h:711
llvm::MCAsmInfo::hasNoDeadStrip
bool hasNoDeadStrip() const
Definition: MCAsmInfo.h:751
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MCAsmInfo::getByteListDirective
const char * getByteListDirective() const
Definition: MCAsmInfo.h:717
llvm::MCObjectFileInfo::getTextSection
MCSection * getTextSection() const
Definition: MCObjectFileInfo.h:263
c
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
Definition: README.txt:418
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::MCSymbol::print
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition: MCSymbol.cpp:58
llvm::MCSection::getEndSymbol
MCSymbol * getEndSymbol(MCContext &Ctx)
Definition: MCSection.cpp:29
llvm::MCVM_TvOSVersionMin
@ MCVM_TvOSVersionMin
.tvos_version_min
Definition: MCDirectives.h:70
MCInstPrinter.h
llvm::MCStreamer::emitCVInlineSiteIdDirective
virtual bool emitCVInlineSiteIdDirective(unsigned FunctionId, unsigned IAFunc, unsigned IAFile, unsigned IALine, unsigned IACol, SMLoc Loc)
Introduces an inline call site id for use with .cv_loc.
Definition: MCStreamer.cpp:305
llvm::MCAsmInfo::getData8bitsDirective
const char * getData8bitsDirective() const
Definition: MCAsmInfo.h:566
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
MCRegister.h
llvm::omp::RTLDependInfoFields::Len
@ Len
llvm::SmallString< 128 >
llvm::WinEH::FrameInfo::Function
const MCSymbol * Function
Definition: MCWinEH.h:44
llvm::MCSA_Exported
@ MCSA_Exported
.globl _foo, exported (XCOFF)
Definition: MCDirectives.h:34
llvm::MCDR_DataRegionJT32
@ MCDR_DataRegionJT32
.data_region jt32
Definition: MCDirectives.h:63
llvm::MCAsmInfo::usesDwarfFileAndLocDirectives
bool usesDwarfFileAndLocDirectives() const
Definition: MCAsmInfo.h:813
llvm::MCAsmInfo::getAsciiDirective
const char * getAsciiDirective() const
Definition: MCAsmInfo.h:715
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
llvm::SmallString::append
void append(StringRef RHS)
Append from a StringRef.
Definition: SmallString.h:68
llvm::MCSA_WeakDefAutoPrivate
@ MCSA_WeakDefAutoPrivate
.weak_def_can_be_hidden (MachO)
Definition: MCDirectives.h:48
llvm::codeview::DefRangeSubfieldRegisterHeader
Definition: SymbolRecord.h:501
llvm::XCOFF::StorageClass
StorageClass
Definition: XCOFF.h:157
DWARF2_FLAG_BASIC_BLOCK
#define DWARF2_FLAG_BASIC_BLOCK
Definition: MCDwarf.h:114
llvm::codeview::DefRangeSubfieldRegisterHeader::Register
ulittle16_t Register
Definition: SymbolRecord.h:502
llvm::MCAssembler
Definition: MCAssembler.h:73
llvm::AMDGPU::Hwreg::Offset
Offset
Definition: SIDefines.h:416
llvm::MCAF_SubsectionsViaSymbols
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:53
Index
uint32_t Index
Definition: ELFObjHandler.cpp:83
uint64_t
llvm::MCContext::getAsmInfo
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:447
llvm::VersionTuple::getSubminor
Optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
Definition: VersionTuple.h:82
llvm::MCDwarfLineAddr::Emit
static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
Definition: MCDwarf.cpp:669
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:43
DWARF2_FLAG_EPILOGUE_BEGIN
#define DWARF2_FLAG_EPILOGUE_BEGIN
Definition: MCDwarf.h:116
llvm::MCStreamer::emitCFIBKeyFrame
virtual void emitCFIBKeyFrame()
Definition: MCStreamer.cpp:248
llvm::MCSA_WeakReference
@ MCSA_WeakReference
.weak_reference (MachO)
Definition: MCDirectives.h:47
LEB128.h
llvm::symbolize::toHex
static std::string toHex(uint64_t V)
Definition: DIPrinter.cpp:278
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:53
MCSymbolXCOFF.h
llvm::MCAsmInfo::getTPRel64Directive
const char * getTPRel64Directive() const
Definition: MCAsmInfo.h:575
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::MCAsmInfo::getTPRel32Directive
const char * getTPRel32Directive() const
Definition: MCAsmInfo.h:576
StringExtras.h
llvm::dwarf::getUnitLengthFieldByteSize
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
Definition: Dwarf.h:679
FuncId
Profile::FuncID FuncId
Definition: Profile.cpp:321
MCRegisterInfo.h
llvm::codeview::DefRangeRegisterHeader
Definition: SymbolRecord.h:479
llvm::Value::print
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Definition: AsmWriter.cpp:4676
llvm::MachO::PLATFORM_BRIDGEOS
@ PLATFORM_BRIDGEOS
Definition: MachO.h:503
llvm::mc::getDwarfVersion
int getDwarfVersion()
llvm::formatted_raw_ostream
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Definition: FormattedStream.h:30
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::VersionTuple::getMinor
Optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
Definition: VersionTuple.h:75
printer
dxil pretty printer
Definition: DXILPrettyPrinter.cpp:53
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1836
llvm::MCStreamer::emitCFIEscape
virtual void emitCFIEscape(StringRef Values)
Definition: MCStreamer.cpp:622
llvm::MCFixupKindInfo
Target independent information on a fixup kind.
Definition: MCFixupKindInfo.h:15
llvm::MCStreamer::emitCFIRestore
virtual void emitCFIRestore(int64_t Register)
Definition: MCStreamer.cpp:612
llvm::MCBinaryExpr::createSub
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:610
EmitSDKVersionSuffix
static void EmitSDKVersionSuffix(raw_ostream &OS, const VersionTuple &SDKVersion)
Definition: MCAsmStreamer.cpp:603
llvm::MCAsmInfo::getCode32Directive
const char * getCode32Directive() const
Definition: MCAsmInfo.h:682
llvm::MCDwarfLineTable::getMCDwarfFiles
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Definition: MCDwarf.h:412
llvm::MCSymbolRefExpr
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
llvm::raw_null_ostream
A raw_ostream that discards all output.
Definition: raw_ostream.h:692
llvm::MCAsmInfo::getGlobalDirective
const char * getGlobalDirective() const
Definition: MCAsmInfo.h:724
llvm::MCAsmInfo::ACLS_Unknown
@ ACLS_Unknown
Definition: MCAsmInfo.h:60
llvm::codeview::DefRangeRegisterRelHeader
Definition: SymbolRecord.h:551
llvm::logicalview::LVAttributeKind::Discriminator
@ Discriminator
llvm::MCAsmInfo::hasDotTypeDotSizeDirective
bool hasDotTypeDotSizeDirective() const
Definition: MCAsmInfo.h:747
llvm::MCLOHIdToNbArgs
static int MCLOHIdToNbArgs(MCLOHType Kind)
Definition: MCLinkerOptimizationHint.h:83
llvm::MCAsmInfo::getCode16Directive
const char * getCode16Directive() const
Definition: MCAsmInfo.h:681
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:99
llvm::ArrayRef< std::string >
llvm::Triple::arm
@ arm
Definition: Triple.h:49
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
MCAsmInfo.h
llvm::logicalview::LVAttributeKind::Range
@ Range
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::MCDwarfLineEntry::make
static void make(MCStreamer *MCOS, MCSection *Section)
Definition: MCDwarf.cpp:91
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::MCStreamer::emitWinCFIEndProlog
virtual void emitWinCFIEndProlog(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:961
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition: Error.h:566
llvm::MCStreamer::emitWinCFIStartChained
virtual void emitWinCFIStartChained(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:756
llvm::Triple::thumb
@ thumb
Definition: Triple.h:83
getPlatformName
static const char * getPlatformName(MachO::PlatformType Type)
Definition: MCAsmStreamer.cpp:626
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
llvm::MCAsmInfo::getLCOMMDirectiveAlignmentType
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
Definition: MCAsmInfo.h:736
llvm::MCStreamer::emitCFIGnuArgsSize
virtual void emitCFIGnuArgsSize(int64_t Size)
Definition: MCStreamer.cpp:631
llvm::MCSA_ELF_TypeTLS
@ MCSA_ELF_TypeTLS
.type _foo, STT_TLS # aka @tls_object
Definition: MCDirectives.h:26
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
llvm::MCStreamer::emitWinCFIFuncletOrFuncEnd
virtual void emitWinCFIFuncletOrFuncEnd(SMLoc Loc=SMLoc())
This is used on platforms, such as Windows on ARM64, that require function or funclet sizes to be emi...
Definition: MCStreamer.cpp:745
llvm::MCSA_IndirectSymbol
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
Definition: MCDirectives.h:35
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
llvm::MCStreamer::emitWinCFIPushFrame
virtual void emitWinCFIPushFrame(bool Code, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:947
llvm::ifs::IFSSymbolType::Func
@ Func
llvm::MCContext::createTempSymbol
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:318
PrintByteList
static void PrintByteList(StringRef Data, raw_ostream &OS, MCAsmInfo::AsmCharLiteralSyntax ACLS)
Definition: MCAsmStreamer.cpp:1075
isPrintableString
static bool isPrintableString(StringRef Data)
Definition: MCAsmStreamer.cpp:1064
llvm::MachO::PLATFORM_TVOS
@ PLATFORM_TVOS
Definition: MachO.h:501
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::MCSA_Internal
@ MCSA_Internal
.internal (ELF)
Definition: MCDirectives.h:36
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MCStreamer::emitCFIDefCfa
virtual void emitCFIDefCfa(int64_t Register, int64_t Offset)
Definition: MCStreamer.cpp:492
llvm::MCSection::getName
StringRef getName() const
Definition: MCSection.h:124
llvm::MCAF_Code32
@ MCAF_Code32
.code32 (X86) / .code 32 (ARM)
Definition: MCDirectives.h:55
llvm::MCSA_ELF_TypeCommon
@ MCSA_ELF_TypeCommon
.type _foo, STT_COMMON # aka @common
Definition: MCDirectives.h:27
llvm::StringRef::size
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
llvm::MCAF_Code64
@ MCAF_Code64
.code64 (X86)
Definition: MCDirectives.h:56
j
return j(j<< 16)
MCObjectWriter.h
llvm::MCStreamer::emitDwarfLineStartLabel
virtual void emitDwarfLineStartLabel(MCSymbol *StartSym)
Emit the debug line start label.
Definition: MCStreamer.cpp:1046
llvm::AArch64::Alias
StringRef Alias
Definition: AArch64TargetParser.h:136
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::MCAsmInfo::getPlainStringDirective
const char * getPlainStringDirective() const
Definition: MCAsmInfo.h:718
llvm::MCAsmInfo::getDTPRel64Directive
const char * getDTPRel64Directive() const
Definition: MCAsmInfo.h:573
llvm::MCAF_SyntaxUnified
@ MCAF_SyntaxUnified
.syntax (ARM/ELF)
Definition: MCDirectives.h:52
llvm::pdb::PDB_SymType::Label
@ Label
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
MCCodeView.h
std
Definition: BitVector.h:851
llvm::MCSA_SymbolResolver
@ MCSA_SymbolResolver
.symbol_resolver (MachO)
Definition: MCDirectives.h:40
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
llvm::MachO::PLATFORM_TVOSSIMULATOR
@ PLATFORM_TVOSSIMULATOR
Definition: MachO.h:506
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
llvm::codeview::DefRangeRegisterRelHeader::Flags
ulittle16_t Flags
Definition: SymbolRecord.h:553
llvm::MCSectionMachO
This represents a section on a Mach-O system (used by Mac OS X).
Definition: MCSectionMachO.h:24
llvm::MCAsmInfo::getGPRel64Directive
const char * getGPRel64Directive() const
Definition: MCAsmInfo.h:571
Casting.h
llvm::MCStreamer::emitCFIWindowSave
virtual void emitCFIWindowSave()
Definition: MCStreamer.cpp:668
llvm::MCStreamer::emitCFILsda
virtual void emitCFILsda(const MCSymbol *Sym, unsigned Encoding)
Definition: MCStreamer.cpp:575
llvm::MCAsmInfo::isLittleEndian
bool isLittleEndian() const
True if the target is little endian.
Definition: MCAsmInfo.h:557
llvm::MCSymbolRefExpr::create
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:386
llvm::MCSectionMachO::getSegmentName
StringRef getSegmentName() const
Definition: MCSectionMachO.h:40
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:614
llvm::MCAsmInfo::getWeakDirective
const char * getWeakDirective() const
Definition: MCAsmInfo.h:753
llvm::MCAsmInfo::hasIdentDirective
bool hasIdentDirective() const
Definition: MCAsmInfo.h:750
llvm::MCStreamer::emitCFIRememberState
virtual void emitCFIRememberState()
Definition: MCStreamer.cpp:583
llvm::MCSA_Global
@ MCSA_Global
.type _foo, @gnu_unique_object
Definition: MCDirectives.h:30
llvm::MCStreamer::emitWinCFIEndProc
virtual void emitWinCFIEndProc(SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:727
llvm::MCSA_WeakDefinition
@ MCSA_WeakDefinition
.weak_definition (MachO)
Definition: MCDirectives.h:46
llvm::LCOMM::ByteAlignment
@ ByteAlignment
Definition: MCAsmInfo.h:50
llvm::MachO::PLATFORM_WATCHOS
@ PLATFORM_WATCHOS
Definition: MachO.h:502
llvm::codeview::DefRangeSubfieldRegisterHeader::OffsetInParent
ulittle32_t OffsetInParent
Definition: SymbolRecord.h:504
llvm::MCSA_ELF_TypeFunction
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
Definition: MCDirectives.h:23
llvm::WinEH::FrameInfo
Definition: MCWinEH.h:39
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:83
llvm::MCAsmInfo::getData16bitsDirective
const char * getData16bitsDirective() const
Definition: MCAsmInfo.h:567
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:596
getVersionMinDirective
static const char * getVersionMinDirective(MCVersionMinType Type)
Definition: MCAsmStreamer.cpp:593
llvm::MCSA_Weak
@ MCSA_Weak
.weak
Definition: MCDirectives.h:45
llvm::MCAsmInfo::getDTPRel32Directive
const char * getDTPRel32Directive() const
Definition: MCAsmInfo.h:574
llvm::MCExpr::print
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
Definition: MCExpr.cpp:41
llvm::MCAsmInfo::getGPRel32Directive
const char * getGPRel32Directive() const
Definition: MCAsmInfo.h:572
llvm::MCAsmInfo::getCode64Directive
const char * getCode64Directive() const
Definition: MCAsmInfo.h:683
llvm::MCDR_DataRegionJT8
@ MCDR_DataRegionJT8
.data_region jt8
Definition: MCDirectives.h:61
llvm::MCStreamer::emitFill
void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
Definition: MCStreamer.cpp:219
llvm::MCSymbolXCOFF
Definition: MCSymbolXCOFF.h:20
llvm::MCAsmInfo::getLabelSuffix
const char * getLabelSuffix() const
Definition: MCAsmInfo.h:661
MCStreamer.h
llvm::MCSymbol::isInSection
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
Definition: MCSymbol.h:247
llvm::MCStreamer::emitCFIReturnColumn
virtual void emitCFIReturnColumn(int64_t Register)
Definition: MCStreamer.cpp:687
llvm::MachO::PLATFORM_DRIVERKIT
@ PLATFORM_DRIVERKIT
Definition: MachO.h:508
llvm::MCStreamer::emitDwarfLocDirective
virtual void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
Definition: MCStreamer.cpp:262
llvm::MCInst::dump_pretty
void dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer=nullptr, StringRef Separator=" ", const MCRegisterInfo *RegInfo=nullptr) const
Dump the MCInst as prettily as possible using the additional MC structures, if given.
Definition: MCInst.cpp:81
llvm::tgtok::Bit
@ Bit
Definition: TGLexer.h:50
LLVM_LIKELY
#define LLVM_LIKELY(EXPR)
Definition: Compiler.h:209
llvm::StringRef::back
char back() const
back - Get the last character in the string.
Definition: StringRef.h:146
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:659
llvm::encodeULEB128
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
Definition: LEB128.h:80
llvm::orc::SymbolState::Emitted
@ Emitted
Assigned address, still materializing.
llvm::VersionTuple::empty
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero).
Definition: VersionTuple.h:67
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::MCAsmInfo::hasPairedDoubleQuoteStringConstants
bool hasPairedDoubleQuoteStringConstants() const
Definition: MCAsmInfo.h:743
llvm::MCDwarfFrameInfo::IsSimple
bool IsSimple
Definition: MCDwarf.h:694
DWARF2_FLAG_PROLOGUE_END
#define DWARF2_FLAG_PROLOGUE_END
Definition: MCDwarf.h:115
llvm::MCSA_PrivateExtern
@ MCSA_PrivateExtern
.private_extern (MachO)
Definition: MCDirectives.h:42
llvm::StringRef::find
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:294
llvm::MCAsmInfo::getCommentColumn
unsigned getCommentColumn() const
This indicates the column (zero-based) at which asm comments should be printed.
Definition: MCAsmInfo.h:651
llvm::MCAsmInfo::AsmCharLiteralSyntax
AsmCharLiteralSyntax
Assembly character literal syntax types.
Definition: MCAsmInfo.h:59
llvm::MCAsmInfo::getWeakRefDirective
const char * getWeakRefDirective() const
Definition: MCAsmInfo.h:754
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::lltok::ChecksumKind
@ ChecksumKind
Definition: LLToken.h:454
llvm::MCAsmInfo::getCOMMDirectiveAlignmentIsInBytes
bool getCOMMDirectiveAlignmentIsInBytes() const
Definition: MCAsmInfo.h:732
llvm::pdb::String
@ String
Definition: PDBTypes.h:408
llvm::MCAsmInfo::hasSubsectionsViaSymbols
bool hasSubsectionsViaSymbols() const
Definition: MCAsmInfo.h:562
llvm::MCStreamer::getDwarfLineTableSymbol
virtual MCSymbol * getDwarfLineTableSymbol(unsigned CUID)
Definition: MCStreamer.cpp:270
llvm::MCDR_DataRegionEnd
@ MCDR_DataRegionEnd
.end_data_region
Definition: MCDirectives.h:64
TargetRegistry.h
llvm::MCStreamer::emitWinCFIPushReg
virtual void emitWinCFIPushReg(MCRegister Register, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:864
llvm::MCStreamer::emitCFIRestoreState
virtual void emitCFIRestoreState()
Definition: MCStreamer.cpp:592
llvm::MCDwarfFrameInfo
Definition: MCDwarf.h:681
llvm::codeview::DefRangeRegisterRelHeader::Register
ulittle16_t Register
Definition: SymbolRecord.h:552
MCExpr.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:76
llvm::MCFixup
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
llvm::codeview::DefRangeFramePointerRelHeader::Offset
little32_t Offset
Definition: SymbolRecord.h:526
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Directive
Definition: DirectiveEmitter.h:100
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::MCStreamer::emitWinCFIStartProc
virtual void emitWinCFIStartProc(const MCSymbol *Symbol, SMLoc Loc=SMLoc())
Definition: MCStreamer.cpp:709
llvm::MCStreamer::emitCFINegateRAState
virtual void emitCFINegateRAState()
Definition: MCStreamer.cpp:678
llvm::MCRegister
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:24
llvm::LCOMM::NoAlignment
@ NoAlignment
Definition: MCAsmInfo.h:50
llvm::MD5::MD5Result::digest
SmallString< 32 > digest() const
Definition: MD5.cpp:281
llvm::raw_ostream::write_hex
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
Definition: raw_ostream.cpp:138
llvm::MCAsmInfo::getData32bitsDirective
const char * getData32bitsDirective() const
Definition: MCAsmInfo.h:568
llvm::MCStreamer::emitCFIMTETaggedFrame
virtual void emitCFIMTETaggedFrame()
Definition: MCStreamer.cpp:255