LLVM  14.0.0git
WebAssemblyInstPrinter.h
Go to the documentation of this file.
1 // WebAssemblyInstPrinter.h - Print wasm MCInst to assembly syntax -*- C++ -*-//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This class prints an WebAssembly MCInst to wasm file syntax.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_INSTPRINTER_WEBASSEMBLYINSTPRINTER_H
15 #define LLVM_LIB_TARGET_WEBASSEMBLY_INSTPRINTER_WEBASSEMBLYINSTPRINTER_H
16 
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/BinaryFormat/Wasm.h"
19 #include "llvm/MC/MCInstPrinter.h"
21 
22 namespace llvm {
23 
24 class MCSubtargetInfo;
25 
26 class WebAssemblyInstPrinter final : public MCInstPrinter {
27  uint64_t ControlFlowCounter = 0;
28  SmallVector<std::pair<uint64_t, bool>, 4> ControlFlowStack;
29  SmallVector<uint64_t, 4> TryStack;
30 
31  enum EHInstKind { TRY, CATCH, CATCH_ALL };
32  SmallVector<EHInstKind, 4> EHInstStack;
33 
34 public:
36  const MCRegisterInfo &MRI);
37 
38  void printRegName(raw_ostream &OS, unsigned RegNo) const override;
39  void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
40  const MCSubtargetInfo &STI, raw_ostream &OS) override;
41 
42  // Used by tblegen code.
43  void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
44  bool IsVariadicDef = false);
45  void printBrList(const MCInst *MI, unsigned OpNo, raw_ostream &O);
46  void printWebAssemblyP2AlignOperand(const MCInst *MI, unsigned OpNo,
47  raw_ostream &O);
48  void printWebAssemblySignatureOperand(const MCInst *MI, unsigned OpNo,
49  raw_ostream &O);
50  void printWebAssemblyHeapTypeOperand(const MCInst *MI, unsigned OpNo,
51  raw_ostream &O);
52 
53  // Autogenerated by tblgen.
54  std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
56  static const char *getRegisterName(unsigned RegNo);
57 };
58 
59 } // end namespace llvm
60 
61 #endif
llvm::MCInstPrinter::MII
const MCInstrInfo & MII
Definition: MCInstPrinter.h:50
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:103
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::WebAssemblyInstPrinter::printWebAssemblyHeapTypeOperand
void printWebAssemblyHeapTypeOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Definition: WebAssemblyInstPrinter.cpp:370
llvm::WebAssemblyInstPrinter::printOperand
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O, bool IsVariadicDef=false)
Definition: WebAssemblyInstPrinter.cpp:292
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
MachineValueType.h
llvm::MCInstPrinter::MRI
const MCRegisterInfo & MRI
Definition: MCInstPrinter.h:51
llvm::WebAssemblyInstPrinter::printRegName
void printRegName(raw_ostream &OS, unsigned RegNo) const override
Print the assembler register name.
Definition: WebAssemblyInstPrinter.cpp:41
llvm::WebAssemblyInstPrinter::printBrList
void printBrList(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Definition: WebAssemblyInstPrinter.cpp:330
llvm::WebAssemblyInstPrinter::printInst
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &OS) override
Print the specified MCInst to the specified raw_ostream.
Definition: WebAssemblyInstPrinter.cpp:48
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
MCInstPrinter.h
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:197
uint64_t
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:43
llvm::WebAssemblyInstPrinter::getRegisterName
static const char * getRegisterName(unsigned RegNo)
llvm::WebAssemblyInstPrinter::printInstruction
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O)
llvm::HighlightColor::Address
@ Address
llvm::WebAssemblyInstPrinter::WebAssemblyInstPrinter
WebAssemblyInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Definition: WebAssemblyInstPrinter.cpp:36
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
llvm::WebAssemblyInstPrinter
Definition: WebAssemblyInstPrinter.h:26
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:25
Wasm.h
llvm::WebAssemblyInstPrinter::getMnemonic
std::pair< const char *, uint64_t > getMnemonic(const MCInst *MI) override
Returns a pair containing the mnemonic for MI and the number of bits left for further processing by p...
llvm::MCInstPrinter::MAI
const MCAsmInfo & MAI
Definition: MCInstPrinter.h:49
SmallVector.h
llvm::WebAssemblyInstPrinter::printWebAssemblySignatureOperand
void printWebAssemblySignatureOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Definition: WebAssemblyInstPrinter.cpp:350
llvm::WebAssemblyInstPrinter::printWebAssemblyP2AlignOperand
void printWebAssemblyP2AlignOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O)
Definition: WebAssemblyInstPrinter.cpp:341
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75