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
12#include "llvm/MC/MCExpr.h"
16#include "llvm/Support/Format.h"
18#include <sstream>
19
20using namespace llvm;
21
23 Assembler->registerSymbol(Sym);
24}
25
27 // Comments are emitted on a new line before the instruction.
28 if (IsVerboseAsm)
30
31 std::istringstream Stream(Str);
33 std::string Line;
34 while (std::getline(Stream, Line, '\n'))
35 Lines.push_back(Line);
36
37 for (auto S : Lines) {
38 if (LLVM_LIKELY(S.length() < ContIndicatorColumn)) {
39 FOS << S;
40 // Each line in HLASM must fill the full 80 characters.
41 FOS.PadToColumn(InstLimit);
42 FOS << "\n";
43 } else {
44 // If last character before end of the line is not a space
45 // we must insert an additional non-space character that
46 // is not part of the statement coding. We just reuse
47 // the existing character by making the new substring start
48 // 1 character sooner, thus "duplicating" that character
49 // If The last character is a space. We insert an X instead.
50 std::string TmpSubStr = S.substr(0, ContIndicatorColumn);
51 if (!TmpSubStr.compare(ContIndicatorColumn - 1, 1, " "))
52 TmpSubStr.replace(ContIndicatorColumn - 1, 1, "X");
53
54 FOS << TmpSubStr;
55 FOS.PadToColumn(InstLimit);
56 FOS << "\n";
57
58 size_t Emitted = ContIndicatorColumn - 1;
59
60 while (Emitted < S.length()) {
61 if ((S.length() - Emitted) < ContLen)
62 TmpSubStr = S.substr(Emitted, S.length());
63 else {
64 TmpSubStr = S.substr(Emitted, ContLen);
65 if (!TmpSubStr.compare(ContLen - 1, 1, " "))
66 TmpSubStr.replace(ContLen - 1, 1, "X");
67 }
68 FOS.PadToColumn(ContStartColumn);
69 FOS << TmpSubStr;
70 FOS.PadToColumn(InstLimit);
71 FOS << "\n";
72 Emitted += ContLen - 1;
73 }
74 }
75 }
76 Str.clear();
77}
78
79static void emitXATTR(raw_ostream &OS, StringRef Name, MCSectionGOFF *ADA,
80 bool IsIndirectReference, GOFF::ESDLinkageType Linkage,
81 GOFF::ESDExecutable Executable,
82 GOFF::ESDBindingScope BindingScope) {
83 llvm::ListSeparator Sep(",");
84 OS << Name << " XATTR ";
85 OS << Sep << "LINKAGE(" << (Linkage == GOFF::ESD_LT_OS ? "OS" : "XPLINK")
86 << ")";
87
88 const bool NotUnspecified = (Executable != GOFF::ESD_EXE_Unspecified);
89 if (NotUnspecified || IsIndirectReference) {
90 OS << Sep << "REFERENCE(";
91 llvm::ListSeparator SepRef(",");
92
93 if (NotUnspecified)
94 OS << SepRef << (Executable == GOFF::ESD_EXE_CODE ? "CODE" : "DATA");
95
96 if (IsIndirectReference)
97 OS << SepRef << "INDIRECT";
98
99 OS << ")";
100 }
101 // Emit PSECT only for code symbols.
102 if (ADA && Executable != GOFF::ESD_EXE_DATA)
103 OS << Sep << "PSECT(" << ADA->getName() << ")";
104 if (BindingScope != GOFF::ESD_BSC_Unspecified) {
105 OS << Sep << "SCOPE(";
106 switch (BindingScope) {
108 OS << "SECTION";
109 break;
111 OS << "MODULE";
112 break;
114 OS << "LIBRARY";
115 break;
117 OS << "EXPORT";
118 break;
119 default:
120 break;
121 }
122 OS << ')';
123 }
124}
125
126static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode,
127 GOFF::ESDAlignment Alignment,
128 GOFF::ESDLoadingBehavior LoadBehavior,
129 GOFF::ESDExecutable Executable, bool IsReadOnly,
130 uint32_t SortKey, uint8_t FillByteValue,
131 StringRef PartName) {
132 OS << Name << " CATTR ";
133 OS << "ALIGN(" << static_cast<unsigned>(Alignment) << "),"
134 << "FILL(" << static_cast<unsigned>(FillByteValue) << ")";
135 switch (LoadBehavior) {
137 OS << ",DEFLOAD";
138 break;
140 OS << ",NOLOAD";
141 break;
142 default:
143 break;
144 }
145 switch (Executable) {
147 OS << ",EXECUTABLE";
148 break;
150 OS << ",NOTEXECUTABLE";
151 break;
152 default:
153 break;
154 }
155 if (IsReadOnly)
156 OS << ",READONLY";
157 if (Rmode != GOFF::ESD_RMODE_None) {
158 OS << ',';
159 OS << "RMODE(";
160 switch (Rmode) {
164 OS << "24";
165 break;
167 OS << "31";
168 break;
170 OS << "64";
171 break;
172 }
173 OS << ')';
174 }
175 if (SortKey)
176 OS << ",PRIORITY(" << SortKey << ")";
177 if (!PartName.empty())
178 OS << ",PART(" << PartName << ")";
179 OS << '\n';
180}
181
182static void emitALIAS(raw_ostream &OS, StringRef Name, StringRef ExternalName) {
183 OS << Name << " ALIAS C'";
184 for (char C : ExternalName) {
185 if (C == '\'' || C == '&')
186 OS << C;
187 OS << C;
188 }
189 OS << "'\n";
190}
191
193 uint32_t Subsection) {
194 auto &Sec = *static_cast<MCSectionGOFF *>(Section);
195 auto EmitExternalName = [&Sec, this]() {
196 if (Sec.hasExternalName())
197 emitALIAS(OS, Sec.getName(), Sec.getExternalName());
198 };
199 switch (Sec.getSymbolType()) {
201 OS << Sec.getName() << " CSECT\n";
202 Sec.setEmitted();
203 EmitExternalName();
204 break;
205 }
207 changeSection(Sec.getParent(), Subsection);
208 if (!Sec.isEmitted()) {
209 GOFF::EDAttr ED = Sec.getEDAttributes();
210 emitCATTR(OS, Sec.getName(), ED.Rmode, Sec.getEDAlignment(),
213 if (auto *BeginSym = static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())) {
214 if (BeginSym->getADA()) {
215 emitXATTR(OS, BeginSym->getName(), BeginSym->getADA(),
216 /*IsIndirectReference=*/false, GOFF::ESD_LT_XPLink,
218 OS << '\n';
219 }
220 }
221 Sec.setEmitted();
222 EmitExternalName();
223 } else
224 OS << Sec.getName() << " CATTR\n";
225 break;
226 }
228 MCSectionGOFF *ED = Sec.getParent();
229 changeSection(ED->getParent(), Subsection);
230 if (!Sec.isEmitted()) {
231 GOFF::EDAttr EDAttr = ED->getEDAttributes();
232 GOFF::PRAttr PRAttr = Sec.getPRAttributes();
233 emitCATTR(OS, ED->getName(), EDAttr.Rmode, ED->getEDAlignment(),
234 EDAttr.LoadBehavior, PRAttr.Executable, EDAttr.IsReadOnly,
235 PRAttr.SortKey, EDAttr.FillByteValue, Sec.getName());
236 MCSectionGOFF *ADA =
237 Sec.getBeginSymbol() != nullptr
238 ? static_cast<MCSymbolGOFF *>(Sec.getBeginSymbol())->getADA()
239 : nullptr;
240 emitXATTR(OS, Sec.getName(), ADA, /*IsIndirectReference=*/false,
241 PRAttr.Linkage, PRAttr.Executable, PRAttr.BindingScope);
242 OS << '\n';
243 ED->setEmitted();
244 Sec.setEmitted();
245 EmitExternalName();
246 } else
247 OS << ED->getName() << " CATTR PART(" << Sec.getName() << ")\n";
248 break;
249 }
250 default:
251 llvm_unreachable("Wrong section type");
252 }
253 MCStreamer::changeSection(Section, Subsection);
254 EmitEOL();
255}
256
258 std::optional<int64_t> Value,
259 unsigned ValueSize,
260 unsigned MaxBytesToEmit) {
261 if (!isPowerOf2_64(ByteAlignment))
262 report_fatal_error("Only power-of-two alignments are supported ");
263
264 OS << " DS 0";
265 switch (ValueSize) {
266 default:
267 llvm_unreachable("Invalid size for machine code value!");
268 case 1:
269 OS << "B";
270 break;
271 case 2:
272 OS << "H";
273 break;
274 case 4:
275 OS << "F";
276 break;
277 case 8:
278 OS << "D";
279 break;
280 case 16:
281 OS << "Q";
282 break;
283 }
284
285 EmitEOL();
286}
287
288void SystemZHLASMAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) {
289 OS << MAI->getCommentString() << T;
290 EmitEOL();
291}
292
294 if (!IsVerboseAsm)
295 return;
296
297 T.toVector(CommentToEmit);
298
299 if (EOL)
300 CommentToEmit.push_back('\n'); // Place comment in a new line.
301}
302
304 if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0)
305 return;
306
307 StringRef Comments = CommentToEmit;
308
309 assert(Comments.back() == '\n' && "Comment array not newline terminated");
310 do {
311 // Emit a line of comments, but not exceeding 80 characters.
312 size_t Position = std::min(InstLimit - 2, Comments.find('\n'));
313 FOS << MAI->getCommentString() << ' ' << Comments.substr(0, Position)
314 << '\n';
315
316 if (Comments[Position] == '\n')
317 Position++;
318 Comments = Comments.substr(Position);
319 } while (!Comments.empty());
320
321 CommentToEmit.clear();
322}
323
325 int64_t Fill,
326 uint8_t FillLen,
327 unsigned MaxBytesToEmit) {
328 emitAlignmentDS(Alignment.value(), Fill, FillLen, MaxBytesToEmit);
329}
330
332 const MCSubtargetInfo &STI,
333 unsigned MaxBytesToEmit) {
334 // Emit with a text fill value.
335 if (MAI->getTextAlignFillValue())
336 emitAlignmentDS(Alignment.value(), MAI->getTextAlignFillValue(), 1,
337 MaxBytesToEmit);
338 else
339 emitAlignmentDS(Alignment.value(), std::nullopt, 1, MaxBytesToEmit);
340}
341
344 "Cannot emit contents before setting section!");
345 if (Data.empty())
346 return;
347
348 OS << " DC ";
349 size_t Len = Data.size();
351 Chars.resize(Len);
352 OS << "XL" << Len;
353 uint32_t Index = 0;
354 for (uint8_t C : Data) {
355 Chars[Index] = C;
356 Index++;
357 }
358
359 OS << '\'' << toHex(Chars) << '\'';
360
361 EmitEOL();
362}
363
365 uint64_t FillValue, SMLoc Loc) {
366 int64_t Count;
367 if (!NumBytes.evaluateAsAbsolute(Count)) {
368 getContext().reportError(Loc, "fill length must be absolute in HLASM");
369 return;
370 }
371 if (Count < 0) {
372 getContext().reportError(Loc, "invalid number of bytes");
373 return;
374 }
375 if (Count > 0x7FFFFFFF) {
376 getContext().reportError(Loc, "fill length too large for HLASM");
377 return;
378 }
379 if (Count == 0)
380 return;
381
382 OS << " DC " << Count << "XL1'"
383 << format_hex_no_prefix(FillValue & 0xff, 2, true) << '\'';
384 EmitEOL();
385}
386
388 const MCSubtargetInfo &STI) {
390 SmallString<256> Code;
392
393 // If we have no code emitter, don't emit code.
394 if (!getAssembler().getEmitterPtr())
395 return;
396
397 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
398
399 // If we are showing fixups, create symbolic markers in the encoded
400 // representation. We do this by making a per-bit map to the fixup item index,
401 // then trying to display it as nicely as possible.
403 FixupMap.resize(Code.size() * 8);
404 for (unsigned I = 0, E = Code.size() * 8; I != E; ++I)
405 FixupMap[I] = 0;
406
407 for (unsigned I = 0, E = Fixups.size(); I != E; ++I) {
408 MCFixup &F = Fixups[I];
409 MCFixupKindInfo Info =
411 for (unsigned J = 0; J != Info.TargetSize; ++J) {
412 unsigned Index = F.getOffset() * 8 + Info.TargetOffset + J;
413 assert(Index < Code.size() * 8 && "Invalid offset in fixup!");
414 FixupMap[Index] = 1 + I;
415 }
416 }
417
418 OS << "encoding: [";
419 for (unsigned I = 0, E = Code.size(); I != E; ++I) {
420 if (I)
421 OS << ',';
422
423 // See if all bits are the same map entry.
424 uint8_t MapEntry = FixupMap[I * 8 + 0];
425 for (unsigned J = 1; J != 8; ++J) {
426 if (FixupMap[I * 8 + J] == MapEntry)
427 continue;
428
429 MapEntry = uint8_t(~0U);
430 break;
431 }
432
433 if (MapEntry != uint8_t(~0U)) {
434 if (MapEntry == 0) {
435 OS << format("0x%02x", uint8_t(Code[I]));
436 } else {
437 if (Code[I]) {
438 // FIXME: Some of the 8 bits require fix up.
439 OS << format("0x%02x", uint8_t(Code[I])) << '\''
440 << char('A' + MapEntry - 1) << '\'';
441 } else
442 OS << char('A' + MapEntry - 1);
443 }
444 } else {
445 // Otherwise, write out in binary.
446 OS << "0b";
447 for (unsigned J = 8; J--;) {
448 unsigned Bit = (Code[I] >> J) & 1;
449 unsigned FixupBit = I * 8 + (7 - J);
450 if (uint8_t MapEntry = FixupMap[FixupBit]) {
451 assert(Bit == 0 && "Encoder wrote into fixed up bit!");
452 OS << char('A' + MapEntry - 1);
453 } else
454 OS << Bit;
455 }
456 }
457 }
458 OS << "]\n";
459
460 for (unsigned I = 0, E = Fixups.size(); I != E; ++I) {
461 MCFixup &F = Fixups[I];
462 OS << " fixup " << char('A' + I) << " - "
463 << "offset: " << F.getOffset() << ", value: ";
464 MAI->printExpr(OS, *F.getValue());
465 auto Kind = F.getKind();
466 if (mc::isRelocation(Kind))
467 OS << ", relocation type: " << Kind;
468 else {
469 OS << ", kind: ";
470 auto Info = getAssembler().getBackend().getFixupKindInfo(Kind);
471 if (F.isPCRel() && StringRef(Info.Name).starts_with("FK_Data_"))
472 OS << "FK_PCRel_" << (Info.TargetSize / 8);
473 else
474 OS << Info.Name;
475 }
476 OS << "\n";
477 }
478}
479
481 const MCSubtargetInfo &STI) {
482 // Show the encoding in a comment if we have a code emitter.
483 addEncodingComment(Inst, STI);
484 EmitEOL();
485
486 InstPrinter->printInst(&Inst, 0, "", STI, OS);
487 EmitEOL();
488}
489
491 MCSymbolGOFF *Sym = static_cast<MCSymbolGOFF *>(Symbol);
492
494
495 // Emit label and ENTRY statement only if not implied by CSECT. Do not emit a
496 // label if the symbol is on a PR section.
497 bool EmitLabelAndEntry =
498 !static_cast<MCSectionGOFF *>(getCurrentSectionOnly())->isPR();
499 if (!Sym->isTemporary() && Sym->isInEDSection()) {
500 EmitLabelAndEntry =
501 Sym->getName() !=
502 static_cast<MCSectionGOFF &>(Sym->getSection()).getParent()->getName();
503 if (EmitLabelAndEntry) {
504 OS << " ENTRY " << Sym->getName();
505 EmitEOL();
506 }
507
508 emitXATTR(OS, Sym->getName(), Sym->getADA(), Sym->isIndirect(),
509 Sym->getLinkage(), Sym->getCodeData(), Sym->getBindingScope());
510 EmitEOL();
511 if (Sym->hasExternalName())
512 emitALIAS(OS, Sym->getName(), Sym->getExternalName());
513 }
514
515 if (EmitLabelAndEntry) {
516 OS << Sym->getName() << " DS 0H";
517 EmitEOL();
518 }
519}
520
523 return static_cast<MCSymbolGOFF *>(Sym)->setSymbolAttribute(Attribute);
524}
525
527 Align ByteAlignment) {
528 auto *Symbol = static_cast<MCSymbolGOFF *>(S);
529 MCSectionGOFF *Section =
530 Symbol->getSectionForCommonSymbol(getContext(), ByteAlignment);
531 pushSection();
532 switchSection(Section);
533 emitLabel(Symbol, SMLoc());
535 popSection();
536}
537
539 String.consume_back("\n");
540 OS << String;
541 EmitEOL();
542}
543
544// Slight duplicate of MCExpr::print due to HLASM only recognizing limited
545// arithmetic operators (+-*/).
547 unsigned Size, bool Parens) {
548 switch (Value->getKind()) {
549 case MCExpr::Constant: {
550 int64_t Val = cast<MCConstantExpr>(Value)->getValue();
551 OS << "XL" << Size << '\''
552 << format_hex_no_prefix(Val, Size * 2, /*Upper=*/true) << '\'';
553 return;
554 }
555 case MCExpr::Binary: {
557 int64_t Const;
558 // Or is handled differently.
559 if (BE.getOpcode() == MCBinaryExpr::Or) {
560 emitHLASMValueImpl(BE.getLHS(), Size, true);
561 OS << ',';
562 emitHLASMValueImpl(BE.getRHS(), Size, true);
563 return;
564 }
565
566 if (Parens)
567 OS << "AD(";
569
570 switch (BE.getOpcode()) {
571 case MCBinaryExpr::LShr: {
572 Const = cast<MCConstantExpr>(BE.getRHS())->getValue();
573 OS << '/' << (1 << Const);
574 if (Parens)
575 OS << ')';
576 return;
577 }
579 OS << '+';
580 break;
582 OS << '/';
583 break;
585 OS << '*';
586 break;
588 OS << '-';
589 break;
590 default:
592 "Unrecognized HLASM arithmetic expression!");
593 }
595 if (Parens)
596 OS << ')';
597 return;
598 }
599 case MCExpr::Target:
600 MAI->printExpr(OS, *Value);
601 return;
602 default:
603 Parens &= isa<MCSymbolRefExpr>(Value);
604 if (Parens)
605 OS << "AD(";
606 MAI->printExpr(OS, *Value);
607 if (Parens)
608 OS << ')';
609 return;
610 }
611}
612
614 SMLoc Loc) {
615 assert(Size <= 8 && "Invalid size");
617 "Cannot emit contents before setting section!");
618
620 OS << " DC ";
622 EmitEOL();
623}
624
626 for (auto &Symbol : getAssembler().symbols()) {
627 if (Symbol.isTemporary() || !Symbol.isRegistered() || Symbol.isDefined())
628 continue;
629 auto &Sym = static_cast<MCSymbolGOFF &>(const_cast<MCSymbol &>(Symbol));
630 if (Sym.getCodeData() == GOFF::ESD_EXE_DATA) {
631 OS << Sym.getADA()->getParent()->getExternalName() << " CATTR PART("
632 << Sym.getName() << ")";
633 EmitEOL();
634 } else {
635 OS << " " << (Sym.isWeak() ? "WXTRN" : "EXTRN") << " " << Sym.getName();
636 EmitEOL();
637 }
638 emitXATTR(OS, Sym.getName(), Sym.getADA(), Sym.isIndirect(),
639 Sym.getLinkage(), Sym.getCodeData(), Sym.getBindingScope());
640 EmitEOL();
641 if (Sym.hasExternalName())
642 emitALIAS(OS, Sym.getName(), Sym.getExternalName());
643 }
644
645 // Finish the assembly output.
646 OS << " END";
647 EmitEOL();
648}
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
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 functions that are useful when dealing with strings.
static void emitCATTR(raw_ostream &OS, StringRef Name, GOFF::ESDRmode Rmode, GOFF::ESDAlignment Alignment, GOFF::ESDLoadingBehavior LoadBehavior, GOFF::ESDExecutable Executable, bool IsReadOnly, uint32_t SortKey, uint8_t FillByteValue, StringRef PartName)
static void emitALIAS(raw_ostream &OS, StringRef Name, StringRef ExternalName)
static void emitXATTR(raw_ostream &OS, StringRef Name, MCSectionGOFF *ADA, bool IsIndirectReference, GOFF::ESDLinkageType Linkage, GOFF::ESDExecutable Executable, GOFF::ESDBindingScope BindingScope)
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: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::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.
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:26
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
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:597
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
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 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.
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.
ESDLoadingBehavior
Definition GOFF.h:127
@ ESD_LB_Deferred
Definition GOFF.h:129
@ ESD_LB_NoLoad
Definition GOFF.h:130
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
@ 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.
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
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...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
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
Target independent information on a fixup kind.
const char * Name
A target specific name for the fixup kind.