IntEqClasses: Let join() return the new leader
[oota-llvm.git] / lib / Target / WebAssembly / MCTargetDesc / WebAssemblyMCCodeEmitter.cpp
1 //=- WebAssemblyMCCodeEmitter.cpp - Convert WebAssembly code to machine code -//
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 implements the WebAssemblyMCCodeEmitter class.
12 ///
13 //===----------------------------------------------------------------------===//
14
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"
25 using namespace llvm;
26
27 #define DEBUG_TYPE "mccodeemitter"
28
29 namespace {
30 class WebAssemblyMCCodeEmitter final : public MCCodeEmitter {
31 public:
32   WebAssemblyMCCodeEmitter(const MCInstrInfo &, MCContext &) {}
33
34   ~WebAssemblyMCCodeEmitter() override {}
35
36   /// TableGen'erated function for getting the binary encoding for an
37   /// instruction.
38   uint64_t getBinaryCodeForInstr(const MCInst &MI,
39                                  SmallVectorImpl<MCFixup> &Fixups,
40                                  const MCSubtargetInfo &STI) const;
41
42   /// Return binary encoding of operand. If the machine operand requires
43   /// relocation, record the relocation and return zero.
44   unsigned getMachineOpValue(const MCInst &MI, const MCOperand &MO,
45                              SmallVectorImpl<MCFixup> &Fixups,
46                              const MCSubtargetInfo &STI) const;
47
48   uint64_t getMemoryOpValue(const MCInst &MI, unsigned Op,
49                             SmallVectorImpl<MCFixup> &Fixups,
50                             const MCSubtargetInfo &STI) const;
51
52   void encodeInstruction(const MCInst &MI, raw_ostream &OS,
53                          SmallVectorImpl<MCFixup> &Fixups,
54                          const MCSubtargetInfo &STI) const override;
55 };
56 } // end anonymous namespace
57
58 MCCodeEmitter *llvm::createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII,
59                                                     MCContext &Ctx) {
60   return new WebAssemblyMCCodeEmitter(MCII, Ctx);
61 }
62
63 void WebAssemblyMCCodeEmitter::encodeInstruction(
64     const MCInst &MI, raw_ostream &OS, SmallVectorImpl<MCFixup> &Fixups,
65     const MCSubtargetInfo &STI) const {
66   assert(false && "FIXME: not implemented yet");
67 }
68
69 // Encode WebAssembly Memory Operand
70 uint64_t
71 WebAssemblyMCCodeEmitter::getMemoryOpValue(const MCInst &MI, unsigned Op,
72                                            SmallVectorImpl<MCFixup> &Fixups,
73                                            const MCSubtargetInfo &STI) const {
74   assert(false && "FIXME: not implemented yet");
75   return 0;
76 }
77
78 #include "WebAssemblyGenMCCodeEmitter.inc"