LLVM 24.0.0git
SystemZHLASMAsmStreamer.cpp
Go to the documentation of this file.
1//===- SystemZHLASMAsmStreamer.cpp - HLASM Assembly Text Output -----------===//
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
10#include "llvm/ADT/STLExtras.h"
13#include "llvm/MC/MCExpr.h"
18#include "llvm/Support/Format.h"
21#include <tuple>
22
23using namespace llvm;
24
26 Assembler->registerSymbol(Sym);
27}
28
30 // Comments are emitted on a new line before the instruction.
31 if (IsVerboseAsm)
33
34 // The continuation character is repeated at the start of the next line.
35 // If the last character of a line that is continued is a letter or a digit or
36 // one of _$@#, we reuse it as the continuation character by making the next
37 // substring start 1 character sooner, thus "duplicating" that character.
38 // Otherwise, we use an X as the continuation character, and the next line
39 // starts with an X followed by the remaining characters. Returns true if
40 // an X was used.
41 auto EmitContinued = [this](StringRef Chunk) {
42 char C = Chunk.back();
43 bool IsValid = isAlnum(C) || C == '_' || C == '$' || C == '@' || C == '#';
44 FOS << Chunk.drop_back() << (IsValid ? C : 'X');
45 };
46
47 StringRef Remaining(Str);
48 while (!Remaining.empty()) {
49 StringRef S;
50 std::tie(S, Remaining) = Remaining.split('\n');
51 if (LLVM_LIKELY(S.size() < ContIndicatorColumn)) {
52 FOS << S << '\n';
53 continue;
54 }
55
56 EmitContinued(S.take_front(ContIndicatorColumn));
57 FOS << '\n';
58
59 size_t Emitted = ContIndicatorColumn - 1;
60 while (Emitted < S.size()) {
61 StringRef Chunk = S.substr(Emitted, ContLen);
62 FOS.PadToColumn(ContStartColumn);
63 if (Chunk.size() < ContLen)
64 FOS << Chunk;
65 else
66 EmitContinued(Chunk);
67 FOS << '\n';
68 Emitted += ContLen - 1;
69 }
70 }
71 Str.clear();
72}
73
74static void emitXATTR(raw_ostream &OS, StringRef Name, MCSectionGOFF *ADA,
75 bool IsIndirectReference, GOFF::ESDLinkageType Linkage,
76 GOFF::ESDExecutable Executable,
77 GOFF::ESDBindingScope BindingScope) {
78 llvm::ListSeparator Sep(",");
79 OS << Name << " XATTR ";
80 OS << Sep << "LINKAGE(" << (Linkage == GOFF::ESD_LT_OS ? "OS" : "XPLINK")
81 << ")";
82
83 const bool NotUnspecified = (Executable != GOFF::ESD_EXE_Unspecified);
84 if (NotUnspecified || IsIndirectReference) {
85 OS << Sep << "REFERENCE(";
86 llvm::ListSeparator SepRef(",");
87
88 if (NotUnspecified)
89 OS << SepRef << (Executable == GOFF::ESD_EXE_CODE ? "CODE" : "DATA");
90
91 if (IsIndirectReference)
92 OS << SepRef << "INDIRECT";
93
94 OS << ")";
95 }
96 // Emit PSECT only for code symbols.
97 if (ADA && Executable != GOFF::ESD_EXE_DATA)
98 OS << Sep << "PSECT(" << ADA->getName() << ")";
99 if (BindingScope != GOFF::ESD_BSC_Unspecified) {
100 OS << Sep << "SCOPE(";
101 switch (BindingScope) {
103 OS << "SECTION";
104 break;
106 OS << "MODULE";
107 break;
109 OS << "LIBRARY";
110 break;
112 OS << "EXPORT";
113 break;
114 default:
115 break;
116 }
117 OS << ')';
118 }
119}
120
121static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode,
122 GOFF::ESDAlignment Alignment,
123 GOFF::ESDLoadingBehavior LoadBehavior,
124 GOFF::ESDTaskingBehavior TaskingBehavior,
125 GOFF::ESDExecutable Executable, bool IsReadOnly,
126 bool IsRemovable, uint32_t SortKey, uint8_t FillByteValue,
127 StringRef PartName) {
128 OS << Name << " CATTR ";
129 OS << "ALIGN(" << static_cast<unsigned>(Alignment) << "),"
130 << "FILL(" << static_cast<unsigned>(FillByteValue) << ")";
131 switch (LoadBehavior) {
133 OS << ",DEFLOAD";
134 break;
136 OS << ",NOLOAD";
137 break;
138 default:
139 break;
140 }
141 switch (TaskingBehavior) {
143 OS << ",NOTREUS";
144 break;
146 OS << ",REUS";
147 break;
149 OS << ",RENT";
150 break;
151 default:
152 break;
153 }
154 switch (Executable) {
156 OS << ",EXECUTABLE";
157 break;
159 OS << ",NOTEXECUTABLE";
160 break;
161 default:
162 break;
163 }
164 if (IsReadOnly)
165 OS << ",READONLY";
166 if (IsRemovable)
167 OS << ",REMOVABLE";
168 if (Rmode != GOFF::ESD_RMODE_None) {
169 OS << ',';
170 OS << "RMODE(";
171 switch (Rmode) {
175 OS << "24";
176 break;
178 OS << "31";
179 break;
181 OS << "64";
182 break;
183 }
184 OS << ')';
185 }
186 if (SortKey)
187 OS << ",PRIORITY(" << SortKey << ")";
188 if (!PartName.empty())
189 OS << ",PART(" << PartName << ")";
190 OS << '\n';
191}
192
193static void emitALIAS(raw_ostream &OS, StringRef Name, StringRef ExternalName) {
194 OS << Name << " ALIAS C'";
195 for (char C : ExternalName) {
196 if (C == '\'' || C == '&')
197 OS << C;
198 OS << C;
199 }
200 OS << "'\n";
201}
202
204 uint32_t Subsection) {
205 auto &Sec = *static_cast<MCSectionGOFF *>(Section);
206 auto EmitExternalName = [&Sec, this]() {
207 if (Sec.hasExternalName())
208 emitALIAS(OS, Sec.getName(), Sec.getExternalName());
209 };
210 switch (Sec.getSymbolType()) {
212 OS << Sec.getName() << " CSECT\n";
213 Sec.setEmitted();
214 EmitExternalName();
215 break;
216 }
218 changeSection(Sec.getParent(), Subsection);
219 if (!Sec.isEmitted()) {
220 GOFF::EDAttr ED = Sec.getEDAttributes();
221 GOFF::ESDTaskingBehavior TaskingBehavior =
222 static_cast<MCSectionGOFF *>(Sec.getParent())
225 emitCATTR(OS, Sec.getName(), ED.Rmode, Sec.getEDAlignment(),
226 ED.LoadBehavior, TaskingBehavior, GOFF::ESD_EXE_Unspecified,
228 StringRef());
229 if (auto *BeginSym = static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())) {
230 if (BeginSym->getADA()) {
231 emitXATTR(OS, BeginSym->getName(), BeginSym->getADA(),
232 /*IsIndirectReference=*/false, GOFF::ESD_LT_XPLink,
234 OS << '\n';
235 }
236 }
237 Sec.setEmitted();
238 EmitExternalName();
239 } else
240 OS << Sec.getName() << " CATTR\n";
241 break;
242 }
244 MCSectionGOFF *ED = Sec.getParent();
245 changeSection(ED->getParent(), Subsection);
246 if (!Sec.isEmitted()) {
247 GOFF::ESDTaskingBehavior TaskingBehavior =
248 static_cast<MCSectionGOFF *>(ED->getParent())
251 GOFF::EDAttr EDAttr = ED->getEDAttributes();
252 GOFF::PRAttr PRAttr = Sec.getPRAttributes();
253 emitCATTR(OS, ED->getName(), EDAttr.Rmode, ED->getEDAlignment(),
254 EDAttr.LoadBehavior, TaskingBehavior, PRAttr.Executable,
255 EDAttr.IsReadOnly, EDAttr.IsRemovable, PRAttr.SortKey,
256 EDAttr.FillByteValue, Sec.getName());
257 MCSectionGOFF *ADA =
258 Sec.getBeginSymbol() != nullptr
259 ? static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())->getADA()
260 : nullptr;
261 emitXATTR(OS, Sec.getName(), ADA, /*IsIndirectReference=*/false,
262 PRAttr.Linkage, PRAttr.Executable, PRAttr.BindingScope);
263 OS << '\n';
264 ED->setEmitted();
265 Sec.setEmitted();
266 EmitExternalName();
267 } else
268 OS << ED->getName() << " CATTR PART(" << Sec.getName() << ")\n";
269 break;
270 }
271 default:
272 llvm_unreachable("Wrong section type");
273 }
274 MCStreamer::changeSection(Section, Subsection);
275 EmitEOL();
276}
277
279 std::optional<int64_t> Value,
280 unsigned ValueSize,
281 unsigned MaxBytesToEmit) {
282 if (!isPowerOf2_64(ByteAlignment))
283 report_fatal_error("Only power-of-two alignments are supported ");
284
285 OS.indent(Indent) << "DS 0";
286 switch (ValueSize) {
287 default:
288 llvm_unreachable("Invalid size for machine code value!");
289 case 1:
290 OS << "B";
291 break;
292 case 2:
293 OS << "H";
294 break;
295 case 4:
296 OS << "F";
297 break;
298 case 8:
299 OS << "D";
300 break;
301 case 16:
302 OS << "Q";
303 break;
304 }
305
306 EmitEOL();
307}
308
309void SystemZHLASMAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) {
310 OS << MAI->getCommentString() << T;
311 EmitEOL();
312}
313
315 if (!IsVerboseAsm)
316 return;
317
318 T.toVector(CommentToEmit);
319
320 if (EOL)
321 CommentToEmit.push_back('\n'); // Place comment in a new line.
322}
323
325 if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0)
326 return;
327
328 StringRef Comments = CommentToEmit;
329
330 assert(Comments.back() == '\n' && "Comment array not newline terminated");
331 do {
332 // Emit a line of comments, but not exceeding 80 characters.
333 size_t Position = std::min(InstLimit - 2, Comments.find('\n'));
334 FOS << MAI->getCommentString() << ' ' << Comments.substr(0, Position)
335 << '\n';
336
337 if (Comments[Position] == '\n')
338 Position++;
339 Comments = Comments.substr(Position);
340 } while (!Comments.empty());
341
342 CommentToEmit.clear();
343}
344
346 int64_t Fill,
347 uint8_t FillLen,
348 unsigned MaxBytesToEmit) {
349 emitAlignmentDS(Alignment.value(), Fill, FillLen, MaxBytesToEmit);
350}
351
353 const MCSubtargetInfo &STI,
354 unsigned MaxBytesToEmit) {
355 // Emit with a text fill value.
356 if (MAI->getTextAlignFillValue())
357 emitAlignmentDS(Alignment.value(), MAI->getTextAlignFillValue(), 1,
358 MaxBytesToEmit);
359 else
360 emitAlignmentDS(Alignment.value(), std::nullopt, 1, MaxBytesToEmit);
361}
362
364 return all_of(Text, [](char C) { return isPrint(C); });
365}
366
367// Emit Text inside a character constant, doubling the characters that HLASM
368// would otherwise treat as the delimiter or as a variable substitution.
370 for (char C : Text) {
371 if (C == '\'' || C == '&')
372 OS << C;
373 OS << C;
374 }
375}
376
379 "Cannot emit contents before setting section!");
380
381 // Printable text is emitted as a character constant: CE for EBCDIC-1047
382 // (converted to ASCII for the output) or CA for ASCII.
383 auto EmitAsString = [this](StringRef Data) {
384 SmallString<MaxXLLen> EBCDICText;
386 if (isPrintableText(EBCDICText)) {
387 OS.indent(Indent) << "DC CE'";
388 emitQuotedText(OS, EBCDICText);
389 OS << '\'';
390 return true;
391 }
392 if (isPrintableText(Data)) {
393 OS.indent(Indent) << "DC CA'";
394 emitQuotedText(OS, Data);
395 OS << '\'';
396 return true;
397 }
398 return false;
399 };
400
401 for (size_t I = 0, E = Data.size(); I < E; I += MaxXLLen) {
402 StringRef Chunk = Data.substr(I, MaxXLLen);
403 if (!(MayBeString && Chunk.size() > 1 && EmitAsString(Chunk)))
404 OS.indent(Indent) << "DC XL" << Chunk.size() << '\'' << toHex(Chunk)
405 << '\'';
406 EmitEOL();
407 }
408}
409
411 emitBytes(Data, /*MayBeString=*/true);
412}
413
415 emitBytes(Data, /*MayBeString=*/false);
416}
417
419 assert(1 <= Size && Size <= 8 && "Invalid size");
420 assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
421 "Invalid size");
422 OS.indent(Indent) << "DC XL" << Size << '\''
423 << format_hex_no_prefix(Value, Size * 2, /*Upper=*/true)
424 << '\'';
425 EmitEOL();
426}
427
429 uint64_t FillValue, SMLoc Loc) {
430 int64_t Count;
431 if (!NumBytes.evaluateAsAbsolute(Count)) {
432 getContext().reportError(Loc, "fill length must be absolute in HLASM");
433 return;
434 }
435 if (Count < 0) {
436 getContext().reportError(Loc, "invalid number of bytes");
437 return;
438 }
439 if (Count > 0x7FFFFFFF) {
440 getContext().reportError(Loc, "fill length too large for HLASM");
441 return;
442 }
443 if (Count == 0)
444 return;
445
446 OS.indent(Indent) << "DC " << Count << "XL1'"
447 << format_hex_no_prefix(FillValue & 0xff, 2, true) << '\'';
448 EmitEOL();
449}
450
452 const MCSubtargetInfo &STI) {
454 SmallString<256> Code;
456
457 // If we have no code emitter, don't emit code.
458 if (!getAssembler().getEmitterPtr())
459 return;
460
461 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
462
463 // If we are showing fixups, create symbolic markers in the encoded
464 // representation. We do this by making a per-bit map to the fixup item index,
465 // then trying to display it as nicely as possible.
467 FixupMap.resize(Code.size() * 8);
468 for (unsigned I = 0, E = Code.size() * 8; I != E; ++I)
469 FixupMap[I] = 0;
470
471 for (unsigned I = 0, E = Fixups.size(); I != E; ++I) {
472 MCFixup &F = Fixups[I];
473 MCFixupKindInfo Info =
475 for (unsigned J = 0; J != Info.TargetSize; ++J) {
476 unsigned Index = F.getOffset() * 8 + Info.TargetOffset + J;
477 assert(Index < Code.size() * 8 && "Invalid offset in fixup!");
478 FixupMap[Index] = 1 + I;
479 }
480 }
481
482 OS << "encoding: [";
483 for (unsigned I = 0, E = Code.size(); I != E; ++I) {
484 if (I)
485 OS << ',';
486
487 // See if all bits are the same map entry.
488 uint8_t MapEntry = FixupMap[I * 8 + 0];
489 for (unsigned J = 1; J != 8; ++J) {
490 if (FixupMap[I * 8 + J] == MapEntry)
491 continue;
492
493 MapEntry = uint8_t(~0U);
494 break;
495 }
496
497 if (MapEntry != uint8_t(~0U)) {
498 if (MapEntry == 0) {
499 OS << format("0x%02x", uint8_t(Code[I]));
500 } else {
501 if (Code[I]) {
502 // FIXME: Some of the 8 bits require fix up.
503 OS << format("0x%02x", uint8_t(Code[I])) << '\''
504 << char('A' + MapEntry - 1) << '\'';
505 } else
506 OS << char('A' + MapEntry - 1);
507 }
508 } else {
509 // Otherwise, write out in binary.
510 OS << "0b";
511 for (unsigned J = 8; J--;) {
512 unsigned Bit = (Code[I] >> J) & 1;
513 unsigned FixupBit = I * 8 + (7 - J);
514 if (uint8_t MapEntry = FixupMap[FixupBit]) {
515 assert(Bit == 0 && "Encoder wrote into fixed up bit!");
516 OS << char('A' + MapEntry - 1);
517 } else
518 OS << Bit;
519 }
520 }
521 }
522 OS << "]\n";
523
524 for (unsigned I = 0, E = Fixups.size(); I != E; ++I) {
525 MCFixup &F = Fixups[I];
526 OS << " fixup " << char('A' + I) << " - "
527 << "offset: " << F.getOffset() << ", value: ";
528 MAI->printExpr(OS, *F.getValue());
529 auto Kind = F.getKind();
530 if (mc::isRelocation(Kind))
531 OS << ", relocation type: " << Kind;
532 else {
533 OS << ", kind: ";
534 auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
535 if (F.isPCRel() && StringRef(Info.Name).starts_with("FK_Data_"))
536 OS << "FK_PCRel_" << (Info.TargetSize / 8);
537 else
538 OS << Info.Name;
539 }
540 OS << "\n";
541 }
542}
543
545 const MCSubtargetInfo &STI) {
546 // Show the encoding in a comment if we have a code emitter.
547 addEncodingComment(Inst, STI);
548 EmitEOL();
549
550 // The instruction printer emits a single leading blank.
551 OS.indent(Indent - 1);
552 InstPrinter->printInst(&Inst, 0, "", STI, OS);
553 EmitEOL();
554}
555
557 MCSymbolGOFF *Sym = static_cast<MCSymbolGOFF *>(Symbol);
558
560
561 // Emit label and ENTRY statement only if not implied by CSECT. Do not emit a
562 // label if the symbol is on a PR section.
563 bool EmitLabelAndEntry =
564 !static_cast<MCSectionGOFF *>(getCurrentSectionOnly())->isPR();
565 if (!Sym->isTemporary() && Sym->isInEDSection()) {
566 EmitLabelAndEntry =
567 Sym->getName() !=
568 static_cast<MCSectionGOFF &>(Sym->getSection()).getParent()->getName();
569 if (EmitLabelAndEntry) {
570 OS.indent(Indent) << "ENTRY " << Sym->getName();
571 EmitEOL();
572 }
573
574 emitXATTR(OS, Sym->getName(), Sym->getADA(), Sym->isIndirect(),
575 Sym->getLinkage(), Sym->getCodeData(), Sym->getBindingScope());
576 EmitEOL();
577 if (Sym->hasExternalName())
578 emitALIAS(OS, Sym->getName(), Sym->getExternalName());
579 }
580
581 if (EmitLabelAndEntry) {
582 OS << Sym->getName() << " DS 0H";
583 EmitEOL();
584 }
585}
586
587// Print the HLASM address constant type for a value of the given size:
588// A(...) is a fullword, AD(...) a doubleword, AL<n>(...) any other length.
589static void printAddrConstPrefix(raw_ostream &OS, unsigned Size) {
590 if (Size == 4)
591 OS << "A(";
592 else if (Size == 8)
593 OS << "AD(";
594 else
595 OS << "AL" << Size << '(';
596}
597
600 return static_cast<MCSymbolGOFF *>(Sym)->setSymbolAttribute(Attribute);
601}
602
604 Align ByteAlignment) {
605 auto *Symbol = static_cast<MCSymbolGOFF *>(S);
606 MCSectionGOFF *Section =
607 Symbol->getSectionForCommonSymbol(getContext(), ByteAlignment);
608 pushSection();
609 switchSection(Section);
610 emitLabel(Symbol, SMLoc());
612 popSection();
613}
614
616 String.consume_back("\n");
617 OS << String;
618 EmitEOL();
619}
620
621// Slight duplicate of MCExpr::print due to HLASM only recognizing limited
622// arithmetic operators (+-*/).
624 unsigned Size, bool Parens) {
625 switch (Value->getKind()) {
626 case MCExpr::Constant: {
627 int64_t Val = cast<MCConstantExpr>(Value)->getValue();
628 OS << "XL" << Size << '\''
629 << format_hex_no_prefix(Val, Size * 2, /*Upper=*/true) << '\'';
630 return;
631 }
632 case MCExpr::Binary: {
634 int64_t Const;
635 // Or is handled differently.
636 if (BE.getOpcode() == MCBinaryExpr::Or) {
637 emitHLASMValueImpl(BE.getLHS(), Size, true);
638 OS << ',';
639 emitHLASMValueImpl(BE.getRHS(), Size, true);
640 return;
641 }
642
643 if (Parens)
646
647 switch (BE.getOpcode()) {
648 case MCBinaryExpr::LShr: {
649 Const = cast<MCConstantExpr>(BE.getRHS())->getValue();
650 OS << '/' << (1 << Const);
651 if (Parens)
652 OS << ')';
653 return;
654 }
656 OS << '+';
657 break;
659 OS << '/';
660 break;
662 OS << '*';
663 break;
665 OS << '-';
666 break;
667 default:
669 "Unrecognized HLASM arithmetic expression!");
670 }
672 if (Parens)
673 OS << ')';
674 return;
675 }
676 case MCExpr::Target:
677 MAI->printExpr(OS, *Value);
678 return;
679 default:
680 Parens &= isa<MCSymbolRefExpr>(Value);
681 if (Parens)
683 MAI->printExpr(OS, *Value);
684 if (Parens)
685 OS << ')';
686 return;
687 }
688}
689
691 SMLoc Loc) {
692 assert(Size <= 8 && "Invalid size");
694 "Cannot emit contents before setting section!");
695
696 int64_t AbsValue;
697 const auto *Sec = static_cast<const MCSectionGOFF *>(getCurrentSectionOnly());
698 if (!Value->evaluateAsAbsolute(AbsValue, getAssemblerPtr()) && Size != 8 &&
699 Sec->getParent() && Sec->getParent()->getName() == GOFF::CLASS_WSA) {
700 getContext().reportError(Loc, "address constant in C_WSA64 must be 8 bytes "
701 "(z/OS binder restriction IEW2572E)");
702 return;
703 }
704
706 OS.indent(Indent) << "DC ";
708 EmitEOL();
709}
710
712 for (auto &Symbol : getAssembler().symbols()) {
713 if (Symbol.isTemporary() || !Symbol.isRegistered() || Symbol.isDefined())
714 continue;
715 auto &Sym = static_cast<MCSymbolGOFF &>(const_cast<MCSymbol &>(Symbol));
716 if (Sym.getCodeData() == GOFF::ESD_EXE_DATA) {
717 OS << Sym.getADA()->getParent()->getExternalName() << " CATTR PART("
718 << Sym.getName() << ")";
719 EmitEOL();
720 } else {
721 OS.indent(Indent) << (Sym.isWeak() ? "WXTRN" : "EXTRN") << " "
722 << Sym.getName();
723 EmitEOL();
724 }
725 emitXATTR(OS, Sym.getName(), Sym.getADA(), Sym.isIndirect(),
726 Sym.getLinkage(), Sym.getCodeData(), Sym.getBindingScope());
727 EmitEOL();
728 if (Sym.hasExternalName())
729 emitALIAS(OS, Sym.getName(), Sym.getExternalName());
730 }
731
732 // Finish the assembly output.
733 OS.indent(Indent) << "END";
734 EmitEOL();
735}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_LIKELY(EXPR)
Definition Compiler.h:347
This file provides utility functions for converting between EBCDIC-1047 and UTF-8.
DXIL Finalize Linkage
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
This file contains the MCSymbolGOFF class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define T
This file contains some templates that are useful if you are working with the STL at all.
This file contains some functions that are useful when dealing with strings.
static void emitALIAS(raw_ostream &OS, StringRef Name, StringRef ExternalName)
static void emitQuotedText(raw_ostream &OS, StringRef Text)
static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode, GOFF::ESDAlignment Alignment, GOFF::ESDLoadingBehavior LoadBehavior, GOFF::ESDTaskingBehavior TaskingBehavior, GOFF::ESDExecutable Executable, bool IsReadOnly, bool IsRemovable, uint32_t SortKey, uint8_t FillByteValue, StringRef PartName)
static bool isPrintableText(StringRef Text)
static void emitXATTR(raw_ostream &OS, StringRef Name, MCSectionGOFF *ADA, bool IsIndirectReference, GOFF::ESDLinkageType Linkage, GOFF::ESDExecutable Executable, GOFF::ESDBindingScope BindingScope)
static void printAddrConstPrefix(raw_ostream &OS, unsigned Size)
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:106
A helper class to return the specified delimiter string after the first invocation of operator String...
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
std::unique_ptr< MCAssembler > Assembler
SmallString< 128 > CommentToEmit
MCAssembler & getAssembler()
raw_ostream & getCommentOS() override
Return a raw_ostream that comments can be written to.
raw_svector_ostream CommentStream
MCCodeEmitter & getEmitter() const
MCAsmBackend & getBackend() const
Binary assembler expressions.
Definition MCExpr.h:295
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition MCExpr.h:442
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition MCExpr.h:445
Opcode getOpcode() const
Get the kind of this binary expression.
Definition MCExpr.h:439
@ Div
Signed division.
Definition MCExpr.h:300
@ LShr
Logical shift right.
Definition MCExpr.h:319
@ Sub
Subtraction.
Definition MCExpr.h:320
@ Mul
Multiplication.
Definition MCExpr.h:313
@ Or
Bitwise or.
Definition MCExpr.h:315
@ Add
Addition.
Definition MCExpr.h:298
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
Encode the given Inst to bytes and append to CB.
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:31
@ Constant
Constant expressions.
Definition MCExpr.h:39
@ Target
Target specific expression.
Definition MCExpr.h:43
@ Binary
Binary expressions.
Definition MCExpr.h:38
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:65
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:187
GOFF::SDAttr getSDAttributes() const
GOFF::EDAttr getEDAttributes() const
void setEmitted() const
GOFF::ESDAlignment getEDAlignment() const
MCSectionGOFF * getParent() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:577
StringRef getName() const
Definition MCSection.h:647
MCSymbol * getBeginSymbol()
Definition MCSection.h:650
virtual bool popSection()
Restore the current and previous section from the section stack.
virtual MCAssembler * getAssemblerPtr()
Definition MCStreamer.h:330
MCContext & getContext() const
Definition MCStreamer.h:325
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
void pushSection()
Save the current and previous section on the section stack.
Definition MCStreamer.h:459
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
MCSection * getCurrentSectionOnly() const
Definition MCStreamer.h:437
virtual void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
virtual void changeSection(MCSection *, uint32_t)
This is called by popSection and switchSection, if the current section changes.
Generic base class for all target subtargets.
StringRef getExternalName() const
GOFF::ESDExecutable getCodeData() const
bool hasExternalName() const
bool isInEDSection() const
GOFF::ESDBindingScope getBindingScope() const
bool isIndirect() const
GOFF::ESDLinkageType getLinkage() const
MCSectionGOFF * getADA() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
StringRef getName() const
getName - Get the symbol name.
Definition MCSymbol.h:188
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition MCSymbol.h:251
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition MCSymbol.h:205
Represents a location in source code.
Definition SMLoc.h:22
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:28
void resize(size_type N)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition StringRef.h:728
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:589
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:258
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
char back() const
Get the last character in the string.
Definition StringRef.h:153
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
Definition StringRef.h:598
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition StringRef.h:290
void emitHLASMValueImpl(const MCExpr *Value, unsigned Size, bool Parens=false)
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc=SMLoc()) override
Emit Size bytes worth of the value specified by FillValue.
void emitRawTextImpl(StringRef String) override
EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...
void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override
Emit the expression Value into the output as a native integer of the given Size bytes.
void addEncodingComment(const MCInst &Inst, const MCSubtargetInfo &STI)
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void emitAlignmentDS(uint64_t ByteAlignment, std::optional< int64_t > Value, unsigned ValueSize, unsigned MaxBytesToEmit)
void emitIntValue(uint64_t Value, unsigned Size) override
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
void finishImpl() override
Streamer specific finalization.
void visitUsedSymbol(const MCSymbol &Sym) override
void AddComment(const Twine &T, bool EOL=true) override
Add a comment that can be emitted to the generated .s file to make the output of the compiler more re...
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override
Emit a common symbol.
void emitValueToAlignment(Align Alignment, int64_t Fill, uint8_t FillLen, unsigned MaxBytesToEmit) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
void emitRawComment(const Twine &T, bool TabPrefix=false) override
Print T and prefix it with the comment string (normally #) and optionally a tab.
void emitCodeAlignment(Align Alignment, const MCSubtargetInfo &STI, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
void changeSection(MCSection *Section, uint32_t Subsection) override
This is called by popSection and switchSection, if the current section changes.
void emitLabel(MCSymbol *Symbol, SMLoc Loc) override
Emit a label for Symbol into the current section.
void emitBinaryData(StringRef Data) override
Functionally identical to EmitBytes.
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI void convertToUTF8(StringRef Source, SmallVectorImpl< char > &Result)
ESDLoadingBehavior
Definition GOFF.h:127
@ ESD_LB_Deferred
Definition GOFF.h:129
@ ESD_LB_NoLoad
Definition GOFF.h:130
constexpr StringLiteral CLASS_WSA
ESDExecutable
Definition GOFF.h:109
@ ESD_EXE_Unspecified
Definition GOFF.h:110
@ ESD_EXE_CODE
Definition GOFF.h:112
@ ESD_EXE_DATA
Definition GOFF.h:111
ESDAlignment
Definition GOFF.h:144
ESDBindingScope
Definition GOFF.h:134
@ ESD_BSC_Library
Definition GOFF.h:138
@ ESD_BSC_Module
Definition GOFF.h:137
@ ESD_BSC_Unspecified
Definition GOFF.h:135
@ ESD_BSC_ImportExport
Definition GOFF.h:139
@ ESD_BSC_Section
Definition GOFF.h:136
ESDLinkageType
Definition GOFF.h:142
@ ESD_LT_OS
Definition GOFF.h:142
@ ESD_LT_XPLink
Definition GOFF.h:142
@ ESD_ST_PartReference
Definition GOFF.h:57
@ ESD_ST_ElementDefinition
Definition GOFF.h:55
@ ESD_ST_SectionDefinition
Definition GOFF.h:54
ESDTaskingBehavior
Definition GOFF.h:102
@ ESD_TA_Reus
Definition GOFF.h:105
@ ESD_TA_NonReus
Definition GOFF.h:104
@ ESD_TA_Rent
Definition GOFF.h:106
@ ESD_RMODE_31
Definition GOFF.h:87
@ ESD_RMODE_None
Definition GOFF.h:85
@ ESD_RMODE_64
Definition GOFF.h:88
@ ESD_RMODE_24
Definition GOFF.h:86
bool isRelocation(MCFixupKind FixupKind)
Definition MCFixup.h:134
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1755
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition MathExtras.h:244
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Definition MathExtras.h:285
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
bool isAlnum(char C)
Checks whether character C is either a decimal digit or an uppercase or lowercase letter as classifie...
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
Definition Format.h:177
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition Format.h:102
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
void toHex(ArrayRef< uint8_t > Input, bool LowerCase, SmallVectorImpl< char > &Output)
Convert buffer Input to its hexadecimal representation. The returned string is double the size of Inp...
bool isPrint(char C)
Checks whether character C is printable.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Definition MathExtras.h:249
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
GOFF::ESDRmode Rmode
GOFF::ESDLoadingBehavior LoadBehavior
GOFF::ESDLinkageType Linkage
GOFF::ESDBindingScope BindingScope
GOFF::ESDExecutable Executable
GOFF::ESDTaskingBehavior TaskingBehavior
Target independent information on a fixup kind.
const char * Name
A target specific name for the fixup kind.