LLVM: lib/MC/MCInstPrinter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

20#include

21#include

22

23using namespace llvm;

24

26 static const char hex_rep[] = "0123456789abcdef";

27 bool First = true;

28 for (char i: bytes) {

31 else

32 OS << ' ';

33 OS << hex_rep[(i & 0xF0) >> 4];

34 OS << hex_rep[i & 0xF];

35 }

36}

37

39

40

41

43 return MII.getName(Opcode);

44}

45

49

51 if (!Annot.empty()) {

53 (*CommentStream) << Annot;

54

55

56 if (Annot.back() != '\n')

57 (*CommentStream) << '\n';

58 } else

59 OS << " " << MAI.getCommentString() << " " << Annot;

60 }

61}

62

67 bool &OrPredicateResult) {

68

73

74

75

78 return true;

79 }

82 return true;

83 }

85 bool Res = OrPredicateResult;

86 OrPredicateResult = false;

87 return Res;

88 }

89

90

93

94

95 switch (C.Kind) {

97

98 return Opnd.isImm() && Opnd.getImm() == int32_t(C.Value);

100

101 return Opnd.isReg() && Opnd.getReg() == C.Value;

103

104 return Opnd.isReg() && Opnd.getReg() == MI.getOperand(C.Value).getReg();

106

107 return Opnd.isReg() && MRI.getRegClass(C.Value).contains(Opnd.getReg());

109

110 return M.ValidateMCOperand(Opnd, *STI, C.Value);

112

113 return true;

120 }

122}

123

127

128

129 auto It = lower_bound(M.OpToPatterns, MI->getOpcode(),

131 return L.Opcode < Opcode;

132 });

133 if (It == M.OpToPatterns.end() || It->Opcode != MI->getOpcode())

134 return nullptr;

135

136

139 M.Patterns.slice(It->PatternStart, It->NumPatterns);

141

142 if (MI->getNumOperands() != P.NumOperands)

143 return nullptr;

144

145

147 M.PatternConds.slice(P.AliasCondStart, P.NumConds);

148 unsigned OpIdx = 0;

149 bool OrPredicateResult = false;

152 OrPredicateResult);

153 })) {

154

155 AsmStrOffset = P.AsmStrOffset;

156 break;

157 }

158 }

159

160

161 if (AsmStrOffset == ~0U)

162 return nullptr;

163

164

165

166

167 assert(AsmStrOffset < M.AsmStrings.size() &&

168 (AsmStrOffset == 0 || M.AsmStrings[AsmStrOffset - 1] == '\0') &&

169 "bad asm string offset");

170 return M.AsmStrings.data() + AsmStrOffset;

171}

172

173

175{

177 {

179 if (digit != 0)

180 return (digit >= 0xa);

182 }

183 return false;

184}

185

189

194 if (Value == std::numeric_limits<int64_t>::min())

197 }

201 if (Value == std::numeric_limits<int64_t>::min())

206 }

210 }

212}

213

226

230

232 Markup M, bool EnableMarkup,

233 bool EnableColor)

234 : IP(IP), OS(OS), EnableMarkup(EnableMarkup), EnableColor(EnableColor) {

235 if (EnableColor) {

237 switch (M) {

240 break;

243 break;

246 break;

249 break;

250 }

251 IP.ColorStack.push_back(Color);

252 OS.changeColor(Color);

253 }

254

255 if (EnableMarkup) {

256 switch (M) {

258 OS << "<imm:";

259 break;

261 OS << "<reg:";

262 break;

264 OS << "<target:";

265 break;

267 OS << "<mem:";

268 break;

269 }

270 }

271}

272

274 if (EnableMarkup)

275 OS << '>';

276 if (!EnableColor)

277 return;

278 IP.ColorStack.pop_back();

279 OS << IP.ColorStack.back();

280}

unsigned const MachineRegisterInfo * MRI

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

static bool needsLeadingZero(uint64_t Value)

Definition MCInstPrinter.cpp:174

static bool matchAliasCondition(const MCInst &MI, const MCSubtargetInfo *STI, const MCRegisterInfo &MRI, unsigned &OpIdx, const AliasMatchingData &M, const AliasPatternCond &C, bool &OrPredicateResult)

Definition MCInstPrinter.cpp:63

MachineInstr unsigned OpIdx

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

ArrayRef< T > slice(size_t N, size_t M) const

slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.

constexpr bool test(unsigned I) const

LLVM_ABI ~WithMarkup()

Definition MCInstPrinter.cpp:273

LLVM_CTOR_NODISCARD LLVM_ABI WithMarkup(MCInstPrinter &IP, raw_ostream &OS, Markup M, bool EnableMarkup, bool EnableColor)

Definition MCInstPrinter.cpp:231

WithMarkup markup(raw_ostream &OS, Markup M)

Definition MCInstPrinter.cpp:227

format_object< int64_t > formatHex(int64_t Value) const

Definition MCInstPrinter.cpp:190

raw_ostream * CommentStream

A stream that comments can be emitted to if desired.

StringRef getOpcodeName(unsigned Opcode) const

Return the name of the specified opcode enum (e.g.

Definition MCInstPrinter.cpp:42

format_object< int64_t > formatDec(int64_t Value) const

Utility functions to print decimal/hexadecimal values.

Definition MCInstPrinter.cpp:186

const MCRegisterInfo & MRI

void printAnnotation(raw_ostream &OS, StringRef Annot)

Utility function for printing annotations.

Definition MCInstPrinter.cpp:50

bool getUseMarkup() const

virtual void printRegName(raw_ostream &OS, MCRegister Reg)

Print the assembler register name.

Definition MCInstPrinter.cpp:46

const char * matchAliasPatterns(const MCInst *MI, const MCSubtargetInfo *STI, const AliasMatchingData &M)

Helper for matching MCInsts to alias patterns when printing instructions.

Definition MCInstPrinter.cpp:124

MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii, const MCRegisterInfo &mri)

HexStyle::Style PrintHexStyle

Which style to use for printing hexadecimal values.

Instances of this class represent a single low-level machine instruction.

Instances of this class represent operands of the MCInst class.

MCRegister getReg() const

Returns the register number.

MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...

Wrapper class representing physical registers. Should be passed by value.

Generic base class for all target subtargets.

const FeatureBitset & getFeatureBits() const

StringRef - Represent a constant reference to a string, i.e.

constexpr bool empty() const

empty - Check if the string is empty.

LLVM Value Representation.

This class implements an extremely fast bulk output stream that can only output to a stream.

static constexpr Colors GREEN

static constexpr Colors RED

static constexpr Colors YELLOW

static constexpr Colors CYAN

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

bool all_of(R &&range, UnaryPredicate P)

Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.

LLVM_ABI void dumpBytes(ArrayRef< uint8_t > Bytes, raw_ostream &OS)

Convert ‘Bytes’ to a hex string and output to ‘OS’.

Definition MCInstPrinter.cpp:25

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

@ First

Helpers to iterate all locations in the MemoryEffectsBase class.

auto lower_bound(R &&Range, T &&Value)

Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...

Tablegenerated data structures needed to match alias patterns.

Data for each alias pattern.

Map from opcode to pattern list by binary search.