LLVM: lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
20using namespace llvm;
21
22#define DEBUG_TYPE "asm-printer"
23
24
25#include "BPFGenAsmWriter.inc"
26
33
37 if (Op.isReg()) {
39 } else if (Op.isImm()) {
41 } else {
42 assert(Op.isExpr() && "Expected an expression");
43 MAI.printExpr(O, *Op.getExpr());
44 }
45}
46
49 const MCOperand &RegOp = MI->getOperand(OpNo);
51
52
53 assert(RegOp.isReg() && "Register operand not a register");
55
56
59 if (Imm >= 0)
61 else
63 } else {
64 assert(0 && "Expected an immediate");
65 }
66}
67
71 if (Op.isImm())
73 else if (Op.isExpr())
74 MAI.printExpr(O, *Op.getExpr());
75 else
76 O << Op;
77}
78
82 if (Op.isImm()) {
83 if (MI->getOpcode() == BPF::JMPL) {
84 int32_t Imm = Op.getImm();
85 O << ((Imm >= 0) ? "+" : "") << formatImm(Imm);
86 } else {
87 int16_t Imm = Op.getImm();
88 O << ((Imm >= 0) ? "+" : "") << formatImm(Imm);
89 }
90 } else if (Op.isExpr()) {
91 MAI.printExpr(O, *Op.getExpr());
92 } else {
93 O << Op;
94 }
95}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
std::pair< Instruction::BinaryOps, Value * > OffsetOp
Find all possible pairs (BinOp, RHS) that BinOp V, RHS can be simplified.
void printBrTargetOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Definition BPFInstPrinter.cpp:79
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
static const char * getRegisterName(MCRegister Reg)
void printImm64Operand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Definition BPFInstPrinter.cpp:68
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Definition BPFInstPrinter.cpp:34
void printMemOperand(const MCInst *MI, int OpNo, raw_ostream &O)
Definition BPFInstPrinter.cpp:47
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override
Print the specified MCInst to the specified raw_ostream.
Definition BPFInstPrinter.cpp:27
void printAnnotation(raw_ostream &OS, StringRef Annot)
Utility function for printing annotations.
format_object< int64_t > formatImm(int64_t Value) const
Utility function to print immediates in decimal or hex.
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.
Generic base class for all target subtargets.
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op