1 //=- WebAssemblyInstPrinter.cpp - WebAssembly assembly instruction printing -=//
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 Print MCInst instructions to wasm format.
13 //===----------------------------------------------------------------------===//
15 #include "InstPrinter/WebAssemblyInstPrinter.h"
16 #include "WebAssembly.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCInst.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/MC/MCSubtargetInfo.h"
21 #include "llvm/MC/MCSymbol.h"
22 #include "llvm/Support/ErrorHandling.h"
23 #include "llvm/Support/FormattedStream.h"
27 #define DEBUG_TYPE "asm-printer"
29 #include "WebAssemblyGenAsmWriter.inc"
31 WebAssemblyInstPrinter::WebAssemblyInstPrinter(const MCAsmInfo &MAI,
32 const MCInstrInfo &MII,
33 const MCRegisterInfo &MRI)
34 : MCInstPrinter(MAI, MII, MRI) {}
36 void WebAssemblyInstPrinter::printRegName(raw_ostream &OS,
37 unsigned RegNo) const {
38 OS << getRegisterName(RegNo);
41 void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
43 const MCSubtargetInfo &STI) {
44 printInstruction(MI, OS);
45 printAnnotation(OS, Annot);