1 //=- WebAssemblyMCCodeEmitter.cpp - Convert WebAssembly code to machine code -//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file implements the WebAssemblyMCCodeEmitter class.
13 //===----------------------------------------------------------------------===//
15 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
16 #include "llvm/ADT/Statistic.h"
17 #include "llvm/MC/MCCodeEmitter.h"
18 #include "llvm/MC/MCFixup.h"
19 #include "llvm/MC/MCInst.h"
20 #include "llvm/MC/MCInstrInfo.h"
21 #include "llvm/MC/MCRegisterInfo.h"
22 #include "llvm/MC/MCSubtargetInfo.h"
23 #include "llvm/MC/MCSymbol.h"
24 #include "llvm/Support/raw_ostream.h"
27 #define DEBUG_TYPE "mccodeemitter"
30 class WebAssemblyMCCodeEmitter final : public MCCodeEmitter {
32 WebAssemblyMCCodeEmitter(const MCInstrInfo &, MCContext &) {}
34 /// TableGen'erated function for getting the binary encoding for an
36 uint64_t getBinaryCodeForInstr(const MCInst &MI,
37 SmallVectorImpl<MCFixup> &Fixups,
38 const MCSubtargetInfo &STI) const;
40 /// Return binary encoding of operand. If the machine operand requires
41 /// relocation, record the relocation and return zero.
42 unsigned getMachineOpValue(const MCInst &MI, const MCOperand &MO,
43 SmallVectorImpl<MCFixup> &Fixups,
44 const MCSubtargetInfo &STI) const;
46 uint64_t getMemoryOpValue(const MCInst &MI, unsigned Op,
47 SmallVectorImpl<MCFixup> &Fixups,
48 const MCSubtargetInfo &STI) const;
50 void encodeInstruction(const MCInst &MI, raw_ostream &OS,
51 SmallVectorImpl<MCFixup> &Fixups,
52 const MCSubtargetInfo &STI) const override;
54 } // end anonymous namespace
56 MCCodeEmitter *llvm::createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII,
58 return new WebAssemblyMCCodeEmitter(MCII, Ctx);
61 void WebAssemblyMCCodeEmitter::encodeInstruction(
62 const MCInst &MI, raw_ostream &OS, SmallVectorImpl<MCFixup> &Fixups,
63 const MCSubtargetInfo &STI) const {
64 assert(false && "FIXME: not implemented yet");
67 // Encode WebAssembly Memory Operand
69 WebAssemblyMCCodeEmitter::getMemoryOpValue(const MCInst &MI, unsigned Op,
70 SmallVectorImpl<MCFixup> &Fixups,
71 const MCSubtargetInfo &STI) const {
72 assert(false && "FIXME: not implemented yet");
76 #include "WebAssemblyGenMCCodeEmitter.inc"