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