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