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 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 (Rmode != GOFF::ESD_RMODE_None) {
167 OS << ',';
168 OS << "RMODE(";
169 switch (Rmode) {
173 OS << "24";
174 break;
176 OS << "31";
177 break;
179 OS << "64";
180 break;
181 }
182 OS << ')';
183 }
184 if (SortKey)
185 OS << ",PRIORITY(" << SortKey << ")";
186 if (!PartName.empty())
187 OS << ",PART(" << PartName << ")";
188 OS << '\n';
189}
190
191static void emitALIAS(raw_ostream &OS, StringRef Name, StringRef ExternalName) {
192 OS << Name << " ALIAS C'";
193 for (char C : ExternalName) {
194 if (C == '\'' || C == '&')
195 OS << C;
196 OS << C;
197 }
198 OS << "'\n";
199}
200
202 uint32_t Subsection) {
203 auto &Sec = *static_cast<MCSectionGOFF *>(Section);
204 auto EmitExternalName = [&Sec, this]() {
205 if (Sec.hasExternalName())
206 emitALIAS(OS, Sec.getName(), Sec.getExternalName());
207 };
208 switch (Sec.getSymbolType()) {
210 OS << Sec.getName() << " CSECT\n";
211 Sec.setEmitted();
212 EmitExternalName();
213 break;
214 }
216 changeSection(Sec.getParent(), Subsection);
217 if (!Sec.isEmitted()) {
218 GOFF::EDAttr ED = Sec.getEDAttributes();
219 GOFF::ESDTaskingBehavior TaskingBehavior =
220 static_cast<MCSectionGOFF *>(Sec.getParent())
223 emitCATTR(OS, Sec.getName(), ED.Rmode, Sec.getEDAlignment(),
224 ED.LoadBehavior, TaskingBehavior, GOFF::ESD_EXE_Unspecified,
225 ED.IsReadOnly, 0, ED.FillByteValue, StringRef());
226 if (auto *BeginSym = static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())) {
227 if (BeginSym->getADA()) {
228 emitXATTR(OS, BeginSym->getName(), BeginSym->getADA(),
229 /*IsIndirectReference=*/false, GOFF::ESD_LT_XPLink,
231 OS << '\n';
232 }
233 }
234 Sec.setEmitted();
235 EmitExternalName();
236 } else
237 OS << Sec.getName() << " CATTR\n";
238 break;
239 }
241 MCSectionGOFF *ED = Sec.getParent();
242 changeSection(ED->getParent(), Subsection);
243 if (!Sec.isEmitted()) {
244 GOFF::ESDTaskingBehavior TaskingBehavior =
245 static_cast<MCSectionGOFF *>(ED->getParent())
248 GOFF::EDAttr EDAttr = ED->getEDAttributes();
249 GOFF::PRAttr PRAttr = Sec.getPRAttributes();
250 emitCATTR(OS, ED->getName(), EDAttr.Rmode, ED->getEDAlignment(),
251 EDAttr.LoadBehavior, TaskingBehavior, PRAttr.Executable,
252 EDAttr.IsReadOnly, PRAttr.SortKey, EDAttr.FillByteValue,
253 Sec.getName());
254 MCSectionGOFF *ADA =
255 Sec.getBeginSymbol() != nullptr
256 ? static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())->getADA()
257 : nullptr;
258 emitXATTR(OS, Sec.getName(), ADA, /*IsIndirectReference=*/false,
259 PRAttr.Linkage, PRAttr.Executable, PRAttr.BindingScope);
260 OS << '\n';
261 ED->setEmitted();
262 Sec.setEmitted();
263 EmitExternalName();
264 } else
265 OS << ED->getName() << " CATTR PART(" << Sec.getName() << ")\n";
266 break;
267 }
268 default:
269 llvm_unreachable("Wrong section type");
270 }
271 MCStreamer::changeSection(Section, Subsection);
272 EmitEOL();
273}
274
276 std::optional<int64_t> Value,
277 unsigned ValueSize,
278 unsigned MaxBytesToEmit) {
279 if (!isPowerOf2_64(ByteAlignment))
280 report_fatal_error("Only power-of-two alignments are supported ");
281
282 OS.indent(Indent) << "DS 0";
283 switch (ValueSize) {
284 default:
285 llvm_unreachable("Invalid size for machine code value!");
286 case 1:
287 OS << "B";
288 break;
289 case 2:
290 OS << "H";
291 break;
292 case 4:
293 OS << "F";
294 break;
295 case 8:
296 OS << "D";
297 break;
298 case 16:
299 OS << "Q";
300 break;
301 }
302
303 EmitEOL();
304}
305
306void SystemZHLASMAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) {
307 OS << MAI->getCommentString() << T;
308 EmitEOL();
309}
310
312 if (!IsVerboseAsm)
313 return;
314
315 T.toVector(CommentToEmit);
316
317 if (EOL)
318 CommentToEmit.push_back('\n'); // Place comment in a new line.
319}
320
322 if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0)
323 return;
324
325 StringRef Comments = CommentToEmit;
326
327 assert(Comments.back() == '\n' && "Comment array not newline terminated");
328 do {
329 // Emit a line of comments, but not exceeding 80 characters.
330 size_t Position = std::min(InstLimit - 2, Comments.find('\n'));
331 FOS << MAI->getCommentString() << ' ' << Comments.substr(0, Position)
332 << '\n';
333
334 if (Comments[Position] == '\n')
335 Position++;
336 Comments = Comments.substr(Position);
337 } while (!Comments.empty());
338
339 CommentToEmit.clear();
340}
341
343 int64_t Fill,
344 uint8_t FillLen,
345 unsigned MaxBytesToEmit) {
346 emitAlignmentDS(Alignment.value(), Fill, FillLen, MaxBytesToEmit);
347}
348
350 const MCSubtargetInfo &STI,
351 unsigned MaxBytesToEmit) {
352 // Emit with a text fill value.
353 if (MAI->getTextAlignFillValue())
354 emitAlignmentDS(Alignment.value(), MAI->getTextAlignFillValue(), 1,
355 MaxBytesToEmit);
356 else
357 emitAlignmentDS(Alignment.value(), std::nullopt, 1, MaxBytesToEmit);
358}
359
361 return all_of(Text, [](char C) { return isPrint(C); });
362}
363
364// Emit Text inside a character constant, doubling the characters that HLASM
365// would otherwise treat as the delimiter or as a variable substitution.
367 for (char C : Text) {
368 if (C == '\'' || C == '&')
369 OS << C;
370 OS << C;
371 }
372}
373
376 "Cannot emit contents before setting section!");
377
378 // Printable text is emitted as a character constant: CE for EBCDIC-1047
379 // (converted to ASCII for the output) or CA for ASCII.
380 auto EmitAsString = [this](StringRef Data) {
381 SmallString<MaxXLLen> EBCDICText;
383 if (isPrintableText(EBCDICText)) {
384 OS.indent(Indent) << "DC CE'";
385 emitQuotedText(OS, EBCDICText);
386 OS << '\'';
387 return true;
388 }
389 if (isPrintableText(Data)) {
390 OS.indent(Indent) << "DC CA'";
391 emitQuotedText(OS, Data);
392 OS << '\'';
393 return true;
394 }
395 return false;
396 };
397
398 for (size_t I = 0, E = Data.size(); I < E; I += MaxXLLen) {
399 StringRef Chunk = Data.substr(I, MaxXLLen);
400 if (!(MayBeString && Chunk.size() > 1 && EmitAsString(Chunk)))
401 OS.indent(Indent) << "DC XL" << Chunk.size() << '\'' << toHex(Chunk)
402 << '\'';
403 EmitEOL();
404 }
405}
406
408 emitBytes(Data, /*MayBeString=*/true);
409}
410
412 emitBytes(Data, /*MayBeString=*/false);
413}
414
416 assert(1 <= Size && Size <= 8 && "Invalid size");
417 assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
418 "Invalid size");
419 OS.indent(Indent) << "DC XL" << Size << '\''
420 << format_hex_no_prefix(Value, Size * 2, /*Upper=*/true)
421 << '\'';
422 EmitEOL();
423}
424
426 uint64_t FillValue, SMLoc Loc) {
427 int64_t Count;
428 if (!NumBytes.evaluateAsAbsolute(Count)) {
429 getContext().reportError(Loc, "fill length must be absolute in HLASM");
430 return;
431 }
432 if (Count < 0) {
433 getContext().reportError(Loc, "invalid number of bytes");
434 return;
435 }
436 if (Count > 0x7FFFFFFF) {
437 getContext().reportError(Loc, "fill length too large for HLASM");
438 return;
439 }
440 if (Count == 0)
441 return;
442
443 OS.indent(Indent) << "DC " << Count << "XL1'"
444 << format_hex_no_prefix(FillValue & 0xff, 2, true) << '\'';
445 EmitEOL();
446}
447
449 const MCSubtargetInfo &STI) {
451 SmallString<256> Code;
453
454 // If we have no code emitter, don't emit code.
455 if (!getAssembler().getEmitterPtr())
456 return;
457
458 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
459
460 // If we are showing fixups, create symbolic markers in the encoded
461 // representation. We do this by making a per-bit map to the fixup item index,
462 // then trying to display it as nicely as possible.
464 FixupMap.resize(Code.size() * 8);
465 for (unsigned I = 0, E = Code.size() * 8; I != E; ++I)
466 FixupMap[I] = 0;
467
468 for (unsigned I = 0, E = Fixups.size(); I != E; ++I) {
469 MCFixup &F = Fixups[I];
470 MCFixupKindInfo Info =
472 for (unsigned J = 0; J != Info.TargetSize; ++J) {
473 unsigned Index = F.getOffset() * 8 + Info.TargetOffset + J;
474 assert(Index < Code.size() * 8 && "Invalid offset in fixup!");
475 FixupMap[Index] = 1 + I;
476 }
477 }
478
479 OS << "encoding: [";
480 for (unsigned I = 0, E = Code.size(); I != E; ++I) {
481 if (I)
482 OS << ',';
483
484 // See if all bits are the same map entry.
485 uint8_t MapEntry = FixupMap[I * 8 + 0];
486 for (unsigned J = 1; J != 8; ++J) {
487 if (FixupMap[I * 8 + J] == MapEntry)
488 continue;
489
490 MapEntry = uint8_t(~0U);
491 break;
492 }
493
494 if (MapEntry != uint8_t(~0U)) {
495 if (MapEntry == 0) {
496 OS << format("0x%02x", uint8_t(Code[I]));
497 } else {
498 if (Code[I]) {
499 // FIXME: Some of the 8 bits require fix up.
500 OS << format("0x%02x", uint8_t(Code[I])) << '\''
501 << char('A' + MapEntry - 1) << '\'';
502 } else
503 OS << char('A' + MapEntry - 1);
504 }
505 } else {
506 // Otherwise, write out in binary.
507 OS << "0b";
508 for (unsigned J = 8; J--;) {
509 unsigned Bit = (Code[I] >> J) & 1;
510 unsigned FixupBit = I * 8 + (7 - J);
511 if (uint8_t MapEntry = FixupMap[FixupBit]) {
512 assert(Bit == 0 && "Encoder wrote into fixed up bit!");
513 OS << char('A' + MapEntry - 1);
514 } else
515 OS << Bit;
516 }
517 }
518 }
519 OS << "]\n";
520
521 for (unsigned I = 0, E = Fixups.size(); I != E; ++I) {
522 MCFixup &F = Fixups[I];
523 OS << " fixup " << char('A' + I) << " - "
524 << "offset: " << F.getOffset() << ", value: ";
525 MAI->printExpr(OS, *F.getValue());
526 auto Kind = F.getKind();
527 if (mc::isRelocation(Kind))
528 OS << ", relocation type: " << Kind;
529 else {
530 OS << ", kind: ";
531 auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
532 if (F.isPCRel() && StringRef(Info.Name).starts_with("FK_Data_"))
533 OS << "FK_PCRel_" << (Info.TargetSize / 8);
534 else
535 OS << Info.Name;
536 }
537 OS << "\n";
538 }
539}
540
542 const MCSubtargetInfo &STI) {
543 // Show the encoding in a comment if we have a code emitter.
544 addEncodingComment(Inst, STI);
545 EmitEOL();
546
547 // The instruction printer emits a single leading blank.
548 OS.indent(Indent - 1);
549 InstPrinter->printInst(&Inst, 0, "", STI, OS);
550 EmitEOL();
551}
552
554 MCSymbolGOFF *Sym = static_cast<MCSymbolGOFF *>(Symbol);
555
557
558 // Emit label and ENTRY statement only if not implied by CSECT. Do not emit a
559 // label if the symbol is on a PR section.
560 bool EmitLabelAndEntry =
561 !static_cast<MCSectionGOFF *>(getCurrentSectionOnly())->isPR();
562 if (!Sym->isTemporary() && Sym->isInEDSection()) {
563 EmitLabelAndEntry =
564 Sym->getName() !=
565 static_cast<MCSectionGOFF &>(Sym->getSection()).getParent()->getName();
566 if (EmitLabelAndEntry) {
567 OS.indent(Indent) << "ENTRY " << Sym->getName();
568 EmitEOL();
569 }
570
571 emitXATTR(OS, Sym->getName(), Sym->getADA(), Sym->isIndirect(),
572 Sym->getLinkage(), Sym->getCodeData(), Sym->getBindingScope());
573 EmitEOL();
574 if (Sym->hasExternalName())
575 emitALIAS(OS, Sym->getName(), Sym->getExternalName());
576 }
577
578 if (EmitLabelAndEntry) {
579 OS << Sym->getName() << " DS 0H";
580 EmitEOL();
581 }
582}
583
584// Print the HLASM address constant type for a value of the given size:
585// A(...) is a fullword, AD(...) a doubleword, AL<n>(...) any other length.
586static void printAddrConstPrefix(raw_ostream &OS, unsigned Size) {
587 if (Size == 4)
588 OS << "A(";
589 else if (Size == 8)
590 OS << "AD(";
591 else
592 OS << "AL" << Size << '(';
593}
594
597 return static_cast<MCSymbolGOFF *>(Sym)->setSymbolAttribute(Attribute);
598}
599
601 Align ByteAlignment) {
602 auto *Symbol = static_cast<MCSymbolGOFF *>(S);
603 MCSectionGOFF *Section =
604 Symbol->getSectionForCommonSymbol(getContext(), ByteAlignment);
605 pushSection();
606 switchSection(Section);
607 emitLabel(Symbol, SMLoc());
609 popSection();
610}
611
613 String.consume_back("\n");
614 OS << String;
615 EmitEOL();
616}
617
618// Slight duplicate of MCExpr::print due to HLASM only recognizing limited
619// arithmetic operators (+-*/).
621 unsigned Size, bool Parens) {
622 switch (Value->getKind()) {
623 case MCExpr::Constant: {
624 int64_t Val = cast<MCConstantExpr>(Value)->getValue();
625 OS << "XL" << Size << '\''
626 << format_hex_no_prefix(Val, Size * 2, /*Upper=*/true) << '\'';
627 return;
628 }
629 case MCExpr::Binary: {
631 int64_t Const;
632 // Or is handled differently.
633 if (BE.getOpcode() == MCBinaryExpr::Or) {
634 emitHLASMValueImpl(BE.getLHS(), Size, true);
635 OS << ',';
636 emitHLASMValueImpl(BE.getRHS(), Size, true);
637 return;
638 }
639
640 if (Parens)
643
644 switch (BE.getOpcode()) {
645 case MCBinaryExpr::LShr: {
646 Const = cast<MCConstantExpr>(BE.getRHS())->getValue();
647 OS << '/' << (1 << Const);
648 if (Parens)
649 OS << ')';
650 return;
651 }
653 OS << '+';
654 break;
656 OS << '/';
657 break;
659 OS << '*';
660 break;
662 OS << '-';
663 break;
664 default:
666 "Unrecognized HLASM arithmetic expression!");
667 }
669 if (Parens)
670 OS << ')';
671 return;
672 }
673 case MCExpr::Target:
674 MAI->printExpr(OS, *Value);
675 return;
676 default:
677 Parens &= isa<MCSymbolRefExpr>(Value);
678 if (Parens)
680 MAI->printExpr(OS, *Value);
681 if (Parens)
682 OS << ')';
683 return;
684 }
685}
686
688 SMLoc Loc) {
689 assert(Size <= 8 && "Invalid size");
691 "Cannot emit contents before setting section!");
692
693 int64_t AbsValue;
694 const auto *Sec = static_cast<const MCSectionGOFF *>(getCurrentSectionOnly());
695 if (!Value->evaluateAsAbsolute(AbsValue, getAssemblerPtr()) && Size != 8 &&
696 Sec->getParent() && Sec->getParent()->getName() == GOFF::CLASS_WSA) {
697 getContext().reportError(Loc, "address constant in C_WSA64 must be 8 bytes "
698 "(z/OS binder restriction IEW2572E)");
699 return;
700 }
701
703 OS.indent(Indent) << "DC ";
705 EmitEOL();
706}
707
709 for (auto &Symbol : getAssembler().symbols()) {
710 if (Symbol.isTemporary() || !Symbol.isRegistered() || Symbol.isDefined())
711 continue;
712 auto &Sym = static_cast<MCSymbolGOFF &>(const_cast<MCSymbol &>(Symbol));
713 if (Sym.getCodeData() == GOFF::ESD_EXE_DATA) {
714 OS << Sym.getADA()->getParent()->getExternalName() << " CATTR PART("
715 << Sym.getName() << ")";
716 EmitEOL();
717 } else {
718 OS.indent(Indent) << (Sym.isWeak() ? "WXTRN" : "EXTRN") << " "
719 << Sym.getName();
720 EmitEOL();
721 }
722 emitXATTR(OS, Sym.getName(), Sym.getADA(), Sym.isIndirect(),
723 Sym.getLinkage(), Sym.getCodeData(), Sym.getBindingScope());
724 EmitEOL();
725 if (Sym.hasExternalName())
726 emitALIAS(OS, Sym.getName(), Sym.getExternalName());
727 }
728
729 // Finish the assembly output.
730 OS.indent(Indent) << "END";
731 EmitEOL();
732}
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 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 emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode, GOFF::ESDAlignment Alignment, GOFF::ESDLoadingBehavior LoadBehavior, GOFF::ESDTaskingBehavior TaskingBehavior, GOFF::ESDExecutable Executable, bool IsReadOnly, uint32_t SortKey, uint8_t FillByteValue, StringRef PartName)
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:107
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:298
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition MCExpr.h:445
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition MCExpr.h:448
Opcode getOpcode() const
Get the kind of this binary expression.
Definition MCExpr.h:442
@ Div
Signed division.
Definition MCExpr.h:303
@ LShr
Logical shift right.
Definition MCExpr.h:322
@ Sub
Subtraction.
Definition MCExpr.h:323
@ Mul
Multiplication.
Definition MCExpr.h:316
@ Or
Bitwise or.
Definition MCExpr.h:318
@ Add
Addition.
Definition MCExpr.h:301
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:34
@ Constant
Constant expressions.
Definition MCExpr.h:42
@ Target
Target specific expression.
Definition MCExpr.h:46
@ Binary
Binary expressions.
Definition MCExpr.h:41
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:188
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:580
StringRef getName() const
Definition MCSection.h:650
MCSymbol * getBeginSymbol()
Definition MCSection.h:653
virtual bool popSection()
Restore the current and previous section from the section stack.
virtual MCAssembler * getAssemblerPtr()
Definition MCStreamer.h:331
MCContext & getContext() const
Definition MCStreamer.h:326
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:460
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:438
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.