22 std::istringstream Stream(Str);
25 while (std::getline(Stream, Line,
'\n'))
26 Lines.push_back(Line);
28 for (
auto S : Lines) {
29 if (
LLVM_LIKELY(S.length() < ContIndicatorColumn)) {
41 std::string TmpSubStr = S.substr(0, ContIndicatorColumn);
42 if (!TmpSubStr.compare(ContIndicatorColumn - 1, 1,
" "))
43 TmpSubStr.replace(ContIndicatorColumn - 1, 1,
"X");
49 size_t Emitted = ContIndicatorColumn - 1;
51 while (Emitted < S.length()) {
52 if ((S.length() - Emitted) < ContLen)
53 TmpSubStr = S.substr(Emitted, S.length());
55 TmpSubStr = S.substr(Emitted, ContLen);
56 if (!TmpSubStr.compare(ContLen - 1, 1,
" "))
57 TmpSubStr.replace(ContLen - 1, 1,
"X");
63 Emitted += ContLen - 1;
78 std::optional<int64_t>
Value,
80 unsigned MaxBytesToEmit) {
112 T.toVector(CommentToEmit);
124 assert(Comments.
back() ==
'\n' &&
"Comment array not newline terminated");
127 size_t Position = std::min(InstLimit - 2, Comments.
find(
'\n'));
131 if (Comments[Position] ==
'\n')
133 Comments = Comments.
substr(Position);
134 }
while (!Comments.
empty());
136 CommentToEmit.
clear();
142 unsigned MaxBytesToEmit) {
148 unsigned MaxBytesToEmit) {
159 "Cannot emit contents before setting section!");
164 size_t Len =
Data.size();
174 OS <<
'\'' << toHex(Chars) <<
'\'';
182 InstPrinter->printInst(&Inst, 0,
"", STI, OS);
190 Symbol->print(OS, MAI);
200 String.consume_back(
"\n");
208 unsigned Size,
bool Parens) {
209 switch (
Value->getKind()) {
211 OS <<
"XL" <<
Size <<
'\'';
233 Const = cast<MCConstantExpr>(BE.
getRHS())->getValue();
234 OS <<
'/' << (1 << Const);
253 "Unrecognized HLASM arithmetic expression!");
277 "Cannot emit contents before setting section!");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_LIKELY(EXPR)
unsigned getTextAlignFillValue() const
void printExpr(raw_ostream &, const MCExpr &) const
virtual void printSwitchToSection(const MCSection &, uint32_t Subsection, const Triple &, raw_ostream &) const
StringRef getCommentString() const
Binary assembler expressions.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Opcode getOpcode() const
Get the kind of this binary expression.
@ LShr
Logical shift right.
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
Base class for the full range of assembler expressions which are needed for parsing.
@ Constant
Constant expressions.
@ Target
Target specific expression.
@ Binary
Binary expressions.
Instances of this class represent a single low-level machine instruction.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
MCContext & getContext() const
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
MCSection * getCurrentSectionOnly() const
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.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Represents a location in source code.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
constexpr bool empty() const
empty - Check if the string is empty.
char back() const
back - Get the last character in the string.
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
void emitCodeAlignment(Align Alignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
void emitHLASMValueImpl(const MCExpr *Value, unsigned Size, bool Parens=false)
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 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 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 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 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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
size_t GetNumBytesInBuffer() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
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.)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t value() const
This is a hole in the type system and should not be abused.