27 #define DEBUG_TYPE "bpf-disassembler" 66 ~BPFDisassembler()
override =
default;
73 uint8_t getInstClass(uint64_t Inst)
const {
return (Inst >> 56) & 0x7; };
74 uint8_t getInstSize(uint64_t Inst)
const {
return (Inst >> 59) & 0x3; };
75 uint8_t getInstMode(uint64_t Inst)
const {
return (Inst >> 61) & 0x7; };
83 return new BPFDisassembler(STI, Ctx);
99 BPF::R6, BPF::R7, BPF::R8, BPF::R9, BPF::R10, BPF::R11};
107 unsigned Reg = GPRDecoderTable[RegNo];
113 BPF::W0, BPF::W1, BPF::W2, BPF::W3, BPF::W4, BPF::W5,
114 BPF::W6, BPF::W7, BPF::W8, BPF::W9, BPF::W10, BPF::W11};
122 unsigned Reg = GPR32DecoderTable[RegNo];
128 uint64_t
Address,
const void *Decoder) {
129 unsigned Register = (Insn >> 16) & 0xf;
131 unsigned Offset = (Insn & 0xffff);
137 #include "BPFGenDisassemblerTables.inc" 139 uint64_t &
Size, uint64_t &Insn,
140 bool IsLittleEndian) {
143 if (Bytes.
size() < 8) {
149 if (IsLittleEndian) {
150 Hi = (Bytes[0] << 24) | (Bytes[1] << 16) | (Bytes[2] << 0) | (Bytes[3] << 8);
151 Lo = (Bytes[4] << 0) | (Bytes[5] << 8) | (Bytes[6] << 16) | (Bytes[7] << 24);
153 Hi = (Bytes[0] << 24) | ((Bytes[1] & 0x0F) << 20) | ((Bytes[1] & 0xF0) << 12) |
154 (Bytes[2] << 8) | (Bytes[3] << 0);
155 Lo = (Bytes[4] << 24) | (Bytes[5] << 16) | (Bytes[6] << 8) | (Bytes[7] << 0);
167 bool IsLittleEndian = getContext().getAsmInfo()->isLittleEndian();
174 uint8_t InstClass = getInstClass(Insn);
175 if ((InstClass == BPF_LDX || InstClass == BPF_STX) &&
176 getInstSize(Insn) != BPF_DW &&
177 getInstMode(Insn) == BPF_MEM &&
178 STI.getFeatureBits()[BPF::ALU32])
189 case BPF::LD_pseudo: {
190 if (Bytes.
size() < 16) {
196 Hi = (Bytes[12] << 0) | (Bytes[13] << 8) | (Bytes[14] << 16) | (Bytes[15] << 24);
198 Hi = (Bytes[12] << 24) | (Bytes[13] << 16) | (Bytes[14] << 8) | (Bytes[15] << 0);
208 case BPF::LD_IND_W: {
221 const void *Decoder);
This class represents lattice values for constants.
DecodeStatus(* DecodeFunc)(MCInst &MI, unsigned insn, uint64_t Address, const void *Decoder)
DecodeStatus
Ternary decode status.
Superclass for all disassemblers.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
static DecodeStatus readInstruction64(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint64_t &Insn, bool IsLittleEndian)
static MCOperand createReg(unsigned Reg)
Context object for machine code objects.
static DecodeStatus DecodeGPRRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t, const void *)
int decodeInstruction(InternalInstruction *insn, byteReader_t reader, const void *readerArg, dlog_t logger, void *loggerArg, const void *miiArg, uint64_t startLoc, DisassemblerMode mode)
Decode one instruction and store the decoding results in a buffer provided by the consumer...
static const unsigned GPRDecoderTable[]
Instances of this class represent a single low-level machine instruction.
size_t size() const
size - Get the array size.
static MCDisassembler * createBPFDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
const MCOperand & getOperand(unsigned i) const
Promote Memory to Register
void LLVMInitializeBPFDisassembler()
Target - Wrapper for Target specific information.
static DecodeStatus decodeMemoryOpValue(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
Generic base class for all target subtargets.
Target & getTheBPFleTarget()
static DecodeStatus DecodeGPR32RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t, const void *)
constexpr uint64_t Make_64(uint32_t High, uint32_t Low)
Make a 64-bit integer from a high / low pair of 32-bit integers.
This class implements an extremely fast bulk output stream that can only output to a stream...
void addOperand(const MCOperand &Op)
static const unsigned GPR32DecoderTable[]
Target & getTheBPFbeTarget()
unsigned getOpcode() const
MCDisassembler::DecodeStatus DecodeStatus
static MCOperand createImm(int64_t Val)
Target & getTheBPFTarget()