33 #define DEBUG_TYPE "wasm-disassembler" 37 #include "WebAssemblyGenDisassemblerTables.inc" 41 std::unique_ptr<const MCInstrInfo> MCII;
50 std::unique_ptr<const MCInstrInfo> MCII)
59 return new WebAssemblyDisassembler(STI, Ctx, std::move(MCII));
71 if (Size >= Bytes.
size())
81 const char *
Error =
nullptr;
84 : static_cast<int64_t>(
96 if (Size +
sizeof(
T) > Bytes.
size())
99 memcpy(&Val, Bytes.
data() +
Size,
sizeof(
T));
100 support::endian::byte_swap<T, support::endianness::little>(Val);
114 const auto *WasmInst = &InstructionTable0[Opc];
116 if (WasmInst->ET == ET_Prefix) {
119 for (
auto PT = PrefixTable; PT->Table; PT++) {
120 if (PT->Prefix == Opc) {
121 WasmInst = PT->Table;
132 if (WasmInst->ET == ET_Unused)
135 assert(WasmInst->ET == ET_Instruction);
138 for (uint8_t OPI = 0; OPI < WasmInst->NumOperands; OPI++) {
139 switch (WasmInst->Operands[OPI]) {
163 if (!parseFPImmediate<float>(MI,
Size, Bytes))
168 if (!parseFPImmediate<double>(MI,
Size, Bytes))
32-bit floating-point immediates.
Compute iterated dominance frontiers using a linear time algorithm.
void LLVMInitializeWebAssemblyDisassembler()
32-bit integer immediates.
DecodeStatus
Ternary decode status.
Superclass for all disassemblers.
32-bit unsigned memory offsets.
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
Basic block label in a branch construct.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
signature immediate for block/loop.
static MCOperand createReg(unsigned Reg)
int64_t decodeSLEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a SLEB128 value.
Context object for machine code objects.
static int nextByte(ArrayRef< uint8_t > Bytes, uint64_t &Size)
Instances of this class represent a single low-level machine instruction.
64-bit integer immediates.
size_t size() const
size - Get the array size.
This file provides WebAssembly-specific target descriptions.
uint64_t decodeULEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a ULEB128 value.
type signature immediate for call_indirect.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setOpcode(unsigned Op)
static MCOperand createFPImm(double Val)
Target - Wrapper for Target specific information.
bool parseFPImmediate(MCInst &MI, uint64_t &Size, ArrayRef< uint8_t > Bytes)
64-bit floating-point immediates.
32-bit unsigned function indices.
static MCDisassembler * createWebAssemblyDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
p2align immediate for load and store address alignment.
Generic base class for all target subtargets.
static bool parseLEBImmediate(MCInst &MI, uint64_t &Size, ArrayRef< uint8_t > Bytes, bool Signed)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Lightweight error class with error context and mandatory checking.
This class implements an extremely fast bulk output stream that can only output to a stream...
void addOperand(const MCOperand &Op)
Target & getTheWebAssemblyTarget32()
Target & getTheWebAssemblyTarget64()
static MCOperand createImm(int64_t Val)