LLVM  5.0.0
WebAssemblyDisassembler.cpp
Go to the documentation of this file.
1 //==- WebAssemblyDisassembler.cpp - Disassembler for WebAssembly -*- C++ -*-==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file is part of the WebAssembly Disassembler.
12 ///
13 /// It contains code to translate the data produced by the decoder into
14 /// MCInsts.
15 ///
16 //===----------------------------------------------------------------------===//
17 
19 #include "WebAssembly.h"
20 #include "llvm/MC/MCContext.h"
22 #include "llvm/MC/MCInst.h"
23 #include "llvm/MC/MCInstrInfo.h"
25 #include "llvm/MC/MCSymbol.h"
26 #include "llvm/Support/Endian.h"
28 using namespace llvm;
29 
30 #define DEBUG_TYPE "wasm-disassembler"
31 
32 namespace {
33 class WebAssemblyDisassembler final : public MCDisassembler {
34  std::unique_ptr<const MCInstrInfo> MCII;
35 
36  DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
37  ArrayRef<uint8_t> Bytes, uint64_t Address,
38  raw_ostream &VStream,
39  raw_ostream &CStream) const override;
40 
41 public:
42  WebAssemblyDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx,
43  std::unique_ptr<const MCInstrInfo> MCII)
44  : MCDisassembler(STI, Ctx), MCII(std::move(MCII)) {}
45 };
46 } // end anonymous namespace
47 
49  const MCSubtargetInfo &STI,
50  MCContext &Ctx) {
51  std::unique_ptr<const MCInstrInfo> MCII(T.createMCInstrInfo());
52  return new WebAssemblyDisassembler(STI, Ctx, std::move(MCII));
53 }
54 
56  // Register the disassembler for each target.
61 }
62 
63 MCDisassembler::DecodeStatus WebAssemblyDisassembler::getInstruction(
64  MCInst &MI, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t /*Address*/,
65  raw_ostream &OS, raw_ostream &CS) const {
66 
67  // TODO: Implement disassembly.
68 
69  return MCDisassembler::Fail;
70 }
void LLVMInitializeWebAssemblyDisassembler()
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.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
Context object for machine code objects.
Definition: MCContext.h:59
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:159
This file provides WebAssembly-specific target descriptions.
Target - Wrapper for Target specific information.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static MCDisassembler * createWebAssemblyDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
MCSubtargetInfo - Generic base class for all target subtargets.
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
IRTranslator LLVM IR MI
Target & getTheWebAssemblyTarget32()
Target & getTheWebAssemblyTarget64()