LLVM: lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

13#include

14

15using namespace llvm;

16

18

19 if (IsVerboseAsm)

21

22 std::istringstream Stream(Str);

24 std::string Line;

25 while (std::getline(Stream, Line, '\n'))

26 Lines.push_back(Line);

27

28 for (auto S : Lines) {

29 if (LLVM_LIKELY(S.length() < ContIndicatorColumn)) {

30 FOS << S;

31

32 FOS.PadToColumn(InstLimit);

33 FOS << "\n";

34 } else {

35

36

37

38

39

40

41 std::string TmpSubStr = S.substr(0, ContIndicatorColumn);

42 if (!TmpSubStr.compare(ContIndicatorColumn - 1, 1, " "))

43 TmpSubStr.replace(ContIndicatorColumn - 1, 1, "X");

44

45 FOS << TmpSubStr;

46 FOS.PadToColumn(InstLimit);

47 FOS << "\n";

48

49 size_t Emitted = ContIndicatorColumn - 1;

50

51 while (Emitted < S.length()) {

52 if ((S.length() - Emitted) < ContLen)

53 TmpSubStr = S.substr(Emitted, S.length());

54 else {

55 TmpSubStr = S.substr(Emitted, ContLen);

56 if (!TmpSubStr.compare(ContLen - 1, 1, " "))

57 TmpSubStr.replace(ContLen - 1, 1, "X");

58 }

59 FOS.PadToColumn(ContStartColumn);

60 FOS << TmpSubStr;

61 FOS.PadToColumn(InstLimit);

62 FOS << "\n";

63 Emitted += ContLen - 1;

64 }

65 }

66 }

67 Str.clear();

68}

69

72 MAI->printSwitchToSection(*Section, Subsection,

75}

76

78 std::optional<int64_t> Value,

79 unsigned ValueSize,

80 unsigned MaxBytesToEmit) {

83

84 OS << " DS 0";

85 switch (ValueSize) {

86 default:

88 case 1:

89 OS << "B";

90 break;

91 case 2:

92 OS << "H";

93 break;

94 case 4:

95 OS << "F";

96 break;

97 case 8:

98 OS << "D";

99 break;

100 case 16:

101 OS << "Q";

102 break;

103 }

104

106}

107

109 if (!IsVerboseAsm)

110 return;

111

112 T.toVector(CommentToEmit);

113

114 if (EOL)

115 CommentToEmit.push_back('\n');

116}

117

119 if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0)

120 return;

121

122 StringRef Comments = CommentToEmit;

123

124 assert(Comments.back() == '\n' && "Comment array not newline terminated");

125 do {

126

127 size_t Position = std::min(InstLimit - 2, Comments.find('\n'));

128 FOS << MAI->getCommentString() << ' ' << Comments.substr(0, Position)

129 << '\n';

130

131 if (Comments[Position] == '\n')

132 Position++;

133 Comments = Comments.substr(Position);

134 } while (!Comments.empty());

135

136 CommentToEmit.clear();

137}

138

140 int64_t Fill,

142 unsigned MaxBytesToEmit) {

144}

145

148 unsigned MaxBytesToEmit) {

149

150 if (MAI->getTextAlignFillValue())

152 MaxBytesToEmit);

153 else

155}

156

159 "Cannot emit contents before setting section!");

160 if (Data.empty())

161 return;

162

163 OS << " DC ";

164 size_t Len = Data.size();

167 OS << "XL" << Len;

170 Chars[Index] = C;

171 Index++;

172 }

173

174 OS << '\'' << toHex(Chars) << '\'';

175

177}

178

181

182 InstPrinter->printInst(&Inst, 0, "", STI, OS);

184}

185

187

189

190 Symbol->print(OS, MAI);

191

192 OS << " DS 0H";

193

194

195

197}

198

200 String.consume_back("\n");

203}

204

205

206

208 unsigned Size, bool Parens) {

209 switch (Value->getKind()) {

211 OS << "XL" << Size << '\'';

212 MAI->printExpr(OS, *Value);

213 OS << '\'';

214 return;

215 }

218 int64_t Const;

219

222 OS << ',';

224 return;

225 }

226

227 if (Parens)

228 OS << "A(";

230

234 OS << '/' << (1 << Const);

235 if (Parens)

236 OS << ')';

237 return;

238 }

240 OS << '+';

241 break;

243 OS << '/';

244 break;

246 OS << '*';

247 break;

249 OS << '-';

250 break;

251 default:

253 "Unrecognized HLASM arithmetic expression!");

254 }

256 if (Parens)

257 OS << ')';

258 return;

259 }

261 MAI->printExpr(OS, *Value);

262 return;

263 default:

264 if (Parens)

265 OS << "A(";

266 MAI->printExpr(OS, *Value);

267 if (Parens)

268 OS << ')';

269 return;

270 }

271}

272

277 "Cannot emit contents before setting section!");

278

279 OS << " DC ";

282}

283

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

#define LLVM_LIKELY(EXPR)

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.

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.

Definition SystemZHLASMAsmStreamer.cpp:146

void emitHLASMValueImpl(const MCExpr *Value, unsigned Size, bool Parens=false)

Definition SystemZHLASMAsmStreamer.cpp:207

void EmitComment()

Definition SystemZHLASMAsmStreamer.cpp:118

void emitRawTextImpl(StringRef String) override

EmitRawText - If this file is backed by an assembly streamer, this dumps the specified string in the ...

Definition SystemZHLASMAsmStreamer.cpp:199

void EmitEOL()

Definition SystemZHLASMAsmStreamer.cpp:17

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.

Definition SystemZHLASMAsmStreamer.cpp:273

void emitBytes(StringRef Data) override

Emit the bytes in Data into the output.

Definition SystemZHLASMAsmStreamer.cpp:157

void emitAlignmentDS(uint64_t ByteAlignment, std::optional< int64_t > Value, unsigned ValueSize, unsigned MaxBytesToEmit)

Definition SystemZHLASMAsmStreamer.cpp:77

void emitEnd()

Definition SystemZHLASMAsmStreamer.cpp:284

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...

Definition SystemZHLASMAsmStreamer.cpp:108

void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override

Emit the given Instruction into the current section.

Definition SystemZHLASMAsmStreamer.cpp:179

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.

Definition SystemZHLASMAsmStreamer.cpp:139

void changeSection(MCSection *Section, uint32_t Subsection) override

This is called by popSection and switchSection, if the current section changes.

Definition SystemZHLASMAsmStreamer.cpp:70

void emitLabel(MCSymbol *Symbol, SMLoc Loc) override

Emit a label for Symbol into the current section.

Definition SystemZHLASMAsmStreamer.cpp:186

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

LLVM Value Representation.

#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)

FunctionAddr VTableAddr uintptr_t uintptr_t Data

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 - Return the argument parameter cast to the specified type.

This struct is a compact representation of a valid (non-zero power of two) alignment.

constexpr uint64_t value() const

This is a hole in the type system and should not be abused.