blob: 0c5792c6b51a656344cd0695f60cfd681905bd32 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//=- WebAssemblyInstPrinter.cpp - WebAssembly assembly instruction printing -=//
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 Print MCInst instructions to wasm format.
12///
13//===----------------------------------------------------------------------===//
14
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"
24#include <cctype>
25using namespace llvm;
26
27#define DEBUG_TYPE "asm-printer"
28
JF Bastienb9073fb2015-07-22 21:28:15 +000029#include "WebAssemblyGenAsmWriter.inc"
30
Dan Gohman10e730a2015-06-29 23:51:55 +000031WebAssemblyInstPrinter::WebAssemblyInstPrinter(const MCAsmInfo &MAI,
32 const MCInstrInfo &MII,
33 const MCRegisterInfo &MRI)
34 : MCInstPrinter(MAI, MII, MRI) {}
35
36void WebAssemblyInstPrinter::printRegName(raw_ostream &OS,
37 unsigned RegNo) const {
JF Bastienb9073fb2015-07-22 21:28:15 +000038 OS << getRegisterName(RegNo);
Dan Gohman10e730a2015-06-29 23:51:55 +000039}
40
41void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
42 StringRef Annot,
43 const MCSubtargetInfo &STI) {
JF Bastienb9073fb2015-07-22 21:28:15 +000044 printInstruction(MI, OS);
45 printAnnotation(OS, Annot);
Dan Gohman10e730a2015-06-29 23:51:55 +000046}