Lines Matching +full:slice +full:- +full:per +full:- +full:line

1 //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output ----------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
81 (asmbackend) ? asmbackend->createObjectWriter(NullStream)
85 if (Assembler->getBackendPtr())
86 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
93 IsVerboseAsm = TO->AsmVerbose;
95 InstPrinter->setCommentStream(CommentStream);
96 ShowInst = TO->ShowMCInst;
97 switch (TO->MCUseDwarfDirectory) {
106 Context.getAsmInfo()->enableDwarfFileDirectoryDefault();
157 /// Emit a blank line to a .s file to pretty it up.
173 auto [Ptr, Bits] = InstPrinter->getMnemonic(&MI);
231 /// @param Symbol - The common symbol to emit.
232 /// @param Size - The size of the common symbol.
233 /// @param ByteAlignment - The alignment of the common symbol in bytes.
300 void emitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column,
313 void emitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line,
449 CommentToEmit.push_back('\n'); // Place comment in a new line.
463 // Emit a line of comments.
464 OS.PadToColumn(MAI->getCommentColumn());
466 OS << MAI->getCommentString() << ' ' << Comments.substr(0, Position) <<'\n';
476 return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
482 OS << MAI->getCommentString() << T;
488 if (c == MAI->getSeparatorString())
492 ExplicitCommentToEmit.append(MAI->getCommentString());
494 ExplicitCommentToEmit.append(c.slice(2, c.size()).str());
496 size_t p = 2, len = c.size() - 2;
497 // emit each line in comment as separate newline.
501 ExplicitCommentToEmit.append(MAI->getCommentString());
502 ExplicitCommentToEmit.append(c.slice(p, newp).str());
503 // If we have another line in this comment add line
508 } else if (c.starts_with(StringRef(MAI->getCommentString()))) {
514 ExplicitCommentToEmit.append(MAI->getCommentString());
515 ExplicitCommentToEmit.append(c.slice(1, c.size()).str());
518 // full line comments immediately output
532 TS->changeSection(getCurrentSection().first, Section, Subsection, OS);
534 Section->printSwitchToSection(*MAI, getContext().getTargetTriple(), OS,
544 OriginalSym->print(OS, MAI);
554 Symbol->print(OS, MAI);
555 OS << MAI->getLabelSuffix();
565 assert(NbArgs != -1 && ((size_t)NbArgs) == Args.size() && "Malformed LOH!");
575 Arg->print(OS, MAI);
588 case MCAF_Code16: OS << '\t'<< MAI->getCode16Directive();break;
589 case MCAF_Code32: OS << '\t'<< MAI->getCode32Directive();break;
590 case MCAF_Code64: OS << '\t'<< MAI->getCode64Directive();break;
604 if (!MAI->doesSupportDataRegionDirectives())
657 llvm_unreachable("Invalid Mach-O platform type");
681 // Only Mach-O hasSubsectionsViaSymbols()
682 if (MAI->hasSubsectionsViaSymbols()) {
684 Func->print(OS, MAI);
693 if (E->inlineAssignedExpr())
697 Symbol->print(OS, MAI);
699 Value->print(OS, MAI);
710 Symbol->print(OS, MAI);
712 Value->print(OS, MAI);
718 Alias->print(OS, MAI);
720 Symbol->print(OS, MAI);
735 if (!MAI->hasDotTypeDotSizeDirective())
738 Symbol->print(OS, MAI);
739 OS << ',' << ((MAI->getCommentString()[0] != '@') ? '@' : '%');
753 OS << MAI->getGlobalDirective();
762 if (!MAI->hasNoDeadStrip())
776 case MCSA_Weak: OS << MAI->getWeakDirective(); break;
781 case MCSA_WeakReference: OS << MAI->getWeakRefDirective(); break;
786 // Non-AIX assemblers currently do not support exported visibility.
796 Symbol->print(OS, MAI);
804 Symbol->print(OS, MAI);
810 if (MAI->getAssemblerDialect() == 1) {
821 Symbol->print(OS, MAI);
843 Symbol->print(OS, MAI);
849 Symbol->print(OS, MAI);
855 Symbol->print(OS, MAI);
861 Symbol->print(OS, MAI);
869 Symbol->print(OS, MAI);
873 OS << '-' << -Offset;
877 // We need an XCOFF-specific version of this directive as the AIX syntax
884 assert(MAI->getLCOMMDirectiveAlignmentType() == LCOMM::Log2Alignment &&
885 "We only support writing log base-2 alignment format with XCOFF.");
888 LabelSym->print(OS, MAI);
890 CsectSym->print(OS, MAI);
898 if (XSym->hasRename())
899 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
907 OS << MAI->getGlobalDirective();
910 OS << MAI->getWeakDirective();
922 Symbol->print(OS, MAI);
944 if (cast<MCSymbolXCOFF>(Symbol)->hasRename())
946 cast<MCSymbolXCOFF>(Symbol)->getSymbolTableName());
952 Name->print(OS, MAI);
967 Symbol->print(OS, MAI);
978 Symbol->print(OS, MAI);
988 // Start by emitting the .info pseudo-op and C_INFO symbol name.
995 // Emit the 4-byte length of the metadata.
1005 // assembly because the .info pseudo-op can only generate words of data. We
1010 uint32_t PaddingSize = PaddedSize - MetadataSize;
1015 // so we need multiple .info pseudo-ops. We choose a small number of words
1016 // per pseudo-op to keep the assembly readable.
1022 if (WordsBeforeNextDirective-- == 0) {
1039 assert(PaddedSize - Index == WordSize);
1041 ::memcpy(LastWord.data(), Metadata.data() + Index, MetadataSize - Index);
1048 assert(MAI->hasDotTypeDotSizeDirective());
1050 Symbol->print(OS, MAI);
1052 Value->print(OS, MAI);
1059 Symbol->print(OS, MAI);
1062 if (MAI->getCOMMDirectiveAlignmentIsInBytes())
1071 if (XSym && XSym->hasRename())
1072 emitXCOFFRenameDirective(XSym, XSym->getSymbolTableName());
1078 Symbol->print(OS, MAI);
1082 switch (MAI->getLCOMMDirectiveAlignmentType()) {
1100 Symbol->setFragment(&Section->getDummyFragment());
1105 assert(Section->getVariant() == MCSection::SV_MachO &&
1106 ".zerofill is a Mach-O specific directive");
1107 // This is a mach-o specific directive.
1110 OS << MOSection->getSegmentName() << "," << MOSection->getName();
1114 Symbol->print(OS, MAI);
1126 Symbol->setFragment(&Section->getDummyFragment());
1130 assert(Section->getVariant() == MCSection::SV_MachO &&
1131 ".zerofill is a Mach-O specific directive");
1132 // This is a mach-o specific directive and section.
1135 Symbol->print(OS, MAI);
1148 for (const unsigned char C : make_range(BeginPtr, EndPtr - 1)) {
1178 for (const unsigned char C : make_range(BeginPtr, EndPtr - 1)) {
1182 printOneCharacter(*(EndPtr - 1));
1201 if (MAI->hasPairedDoubleQuoteStringConstants()) {
1256 // use .ascii or a byte-list directive
1257 if (MAI->getAscizDirective() && Data.back() == 0) {
1258 OS << MAI->getAscizDirective();
1259 Data = Data.substr(0, Data.size() - 1);
1260 } else if (LLVM_LIKELY(MAI->getAsciiDirective())) {
1261 OS << MAI->getAsciiDirective();
1262 } else if (MAI->hasPairedDoubleQuoteStringConstants() &&
1266 assert(MAI->getPlainStringDirective() &&
1269 assert(MAI->getByteListDirective() &&
1273 OS << MAI->getPlainStringDirective();
1274 Data = Data.substr(0, Data.size() - 1);
1276 OS << MAI->getByteListDirective();
1278 } else if (MAI->getByteListDirective()) {
1279 OS << MAI->getByteListDirective();
1280 PrintByteList(Data, OS, MAI->characterLiteralSyntax());
1295 // Only single byte is provided or no ascii, asciz, or byte-list directives
1298 TS->emitRawBytes(Data);
1301 const char *Directive = MAI->getData8bitsDirective();
1314 OS << MAI->getData8bitsDirective();
1315 for (; J < EJ - 1; ++J)
1343 case 1: Directive = MAI->getData8bitsDirective(); break;
1344 case 2: Directive = MAI->getData16bitsDirective(); break;
1345 case 4: Directive = MAI->getData32bitsDirective(); break;
1346 case 8: Directive = MAI->getData64bitsDirective(); break;
1351 if (!Value->evaluateAsAbsolute(IntValue))
1358 bool IsLittleEndian = MAI->isLittleEndian();
1360 unsigned Remaining = Size - Emitted;
1363 unsigned EmissionSize = llvm::bit_floor(std::min(Remaining, Size - 1));
1367 IsLittleEndian ? Emitted : (Remaining - EmissionSize);
1372 uint64_t Shift = 64 - EmissionSize * 8;
1386 TS->emitValue(Value);
1388 Value->print(OS, MAI);
1395 if (Value->evaluateAsAbsolute(IntValue)) {
1400 Value->print(OS, MAI);
1406 if (Value->evaluateAsAbsolute(IntValue)) {
1411 Value->print(OS, MAI);
1416 assert(MAI->getDTPRel64Directive() != nullptr);
1417 OS << MAI->getDTPRel64Directive();
1418 Value->print(OS, MAI);
1423 assert(MAI->getDTPRel32Directive() != nullptr);
1424 OS << MAI->getDTPRel32Directive();
1425 Value->print(OS, MAI);
1430 assert(MAI->getTPRel64Directive() != nullptr);
1431 OS << MAI->getTPRel64Directive();
1432 Value->print(OS, MAI);
1437 assert(MAI->getTPRel32Directive() != nullptr);
1438 OS << MAI->getTPRel32Directive();
1439 Value->print(OS, MAI);
1444 assert(MAI->getGPRel64Directive() != nullptr);
1445 OS << MAI->getGPRel64Directive();
1446 Value->print(OS, MAI);
1451 assert(MAI->getGPRel32Directive() != nullptr);
1452 OS << MAI->getGPRel32Directive();
1453 Value->print(OS, MAI);
1464 if (const char *ZeroDirective = MAI->getZeroDirective()) {
1465 if (MAI->doesZeroDirectiveSupportNonZeroValue() || FillValue == 0) {
1475 "Cannot emit non-absolute expression lengths of fill.");
1477 OS << MAI->getData8bitsDirective() << (int)FillValue;
1501 if (MAI->useDotAlignForAlignment()) {
1503 report_fatal_error("Only power-of-two alignments are supported "
1511 // Some assemblers don't support non-power of two alignments, so we always
1547 // Non-power of two alignment. This is not widely supported by assemblers.
1577 if (MAI->getTextAlignFillValue())
1578 emitAlignmentDirective(Alignment.value(), MAI->getTextAlignFillValue(), 1,
1589 Offset->print(OS, MAI);
1595 assert(MAI->hasSingleParameterDotFile());
1605 assert(MAI->hasFourStringsDotFile());
1652 OS << " md5 0x" << Checksum->digest();
1677 !MAI->usesDwarfFileAndLocDirectives())
1686 TS->emitDwarfFileDirective(OS1.str());
1706 if (!MAI->usesDwarfFileAndLocDirectives())
1715 TS->emitDwarfFileDirective(OS1.str());
1720 void MCAsmStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
1726 if (!MAI->usesDwarfFileAndLocDirectives()) {
1728 // first one gets a line entry.
1730 this->MCStreamer::emitDwarfLocDirective(FileNo, Line, Column, Flags, Isa,
1735 OS << "\t.loc\t" << FileNo << " " << Line << " " << Column;
1736 if (MAI->supportsExtendedDwarfLocDirective()) {
1761 OS.PadToColumn(MAI->getCommentColumn());
1762 OS << MAI->getCommentString() << ' ' << FileName << ':'
1763 << Line << ':' << Column;
1766 this->MCStreamer::emitDwarfLocDirective(FileNo, Line, Column, Flags, Isa,
1771 // Always use the zeroth line table, since asm syntax only supports one line
1816 unsigned Line, unsigned Column,
1823 OS << "\t.cv_loc\t" << FunctionId << " " << FileNo << " " << Line << " "
1832 OS.PadToColumn(MAI->getCommentColumn());
1833 OS << MAI->getCommentString() << ' ' << FileName << ':' << Line << ':'
1843 FnStart->print(OS, MAI);
1845 FnEnd->print(OS, MAI);
1847 this->MCStreamer::emitCVLinetableDirective(FunctionId, FnStart, FnEnd);
1857 FnStartSym->print(OS, MAI);
1859 FnEndSym->print(OS, MAI);
1861 this->MCStreamer::emitCVInlineLinetableDirective(
1870 Range.first->print(OS, MAI);
1872 Range.second->print(OS, MAI);
1930 ProcSym->print(OS, MAI);
1935 assert(MAI->hasIdentDirective() && ".ident directive not supported");
1969 if (!MAI->useDwarfRegNumForCFI()) {
1975 MRI->getLLVMRegNum(Register, true)) {
1976 InstPrinter->printRegName(OS, *LLVMRegister);
2010 size_t e = Values.size() - 1;
2052 Sym->print(OS, MAI);
2059 Sym->print(OS, MAI);
2168 Symbol->print(OS, MAI);
2205 Sym->print(OS, MAI);
2231 MCSection *TextSec = &CurFrame->Function->getSection();
2243 InstPrinter->printRegName(OS, Register);
2252 InstPrinter->printRegName(OS, Register);
2269 InstPrinter->printRegName(OS, Register);
2279 InstPrinter->printRegName(OS, Register);
2304 From->getSymbol().print(OS, MAI);
2306 To->getSymbol().print(OS, MAI);
2324 // representation. We do this by making a per-bit map to the fixup item index,
2343 // high order halfword of a 32-bit Thumb2 instruction is emitted first.
2366 << char('A' + MapEntry - 1) << '\'';
2368 OS << char('A' + MapEntry - 1);
2373 for (unsigned j = 8; j--;) {
2377 if (MAI->isLittleEndian())
2380 FixupBit = i * 8 + (7-j);
2384 OS << char('A' + MapEntry - 1);
2396 OS << " fixup " << char('A' + i) << " - "
2398 F.getValue()->print(OS, MAI);
2408 if (!MAI->usesDwarfFileAndLocDirectives())
2410 // a line entry for any .loc directive that has been seen.
2423 getTargetStreamer()->prettyPrintAsm(*InstPrinter, 0, Inst, STI, OS);
2425 InstPrinter->printInst(&Inst, 0, "", STI, OS);
2447 OS << " " << FnSym->getName();
2478 Expr->print(OS, MAI);
2491 Sym->print(OS, MAI);
2495 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
2509 // Now it is time to emit debug line sections if target doesn't support .loc
2510 // and .line directives.
2511 if (!MAI->usesDwarfFileAndLocDirectives()) {
2516 // Emit the label for the line table, if requested - since the rest of the
2517 // line table will be defined by .loc/.file directives, and not emitted
2521 assert(Tables.size() == 1 && "asm output only supports one line table");
2522 if (auto *Label = Tables.begin()->second.getLabel()) {
2523 switchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
2536 if (!MAI->needsDwarfSectionSizeInHeader())
2549 if (!MAI->needsDwarfSectionSizeInHeader())
2562 if (!MAI->needsDwarfSectionSizeInHeader()) {
2583 // If the targets write the raw debug line data for assembly output (We can
2588 assert(!MAI->usesDwarfFileAndLocDirectives() &&
2594 // the explicit sections and -ffunction-sections when we try to generate or
2596 MCSection *TextSection = Ctx.getObjectFileInfo()->getTextSection();
2597 assert(TextSection->hasEnded() && ".text section is not end!");
2599 MCSymbol *SectionEnd = TextSection->getEndSymbol(Ctx);
2602 AsmInfo->getCodePointerSize());
2605 // Generate DWARF line sections for assembly mode without .loc/.file
2610 assert(!MAI->usesDwarfFileAndLocDirectives() &&
2611 ".loc/.file don't need raw data in debug line section!");
2614 AddComment("Set address to " + Label->getName());
2637 // Advance line.
2638 AddComment("Advance line " + Twine(LineDelta));
2645 // Emit section end. This is used to tell the debug line section where the end
2646 // is for a text section if we don't use .loc to represent the debug line.
2647 if (MAI->usesDwarfFileAndLocDirectives())
2652 MCSymbol *Sym = getCurrentSectionOnly()->getEndSymbol(getContext());
2654 if (!Sym->isInSection())