WebAssemblyInstPrinter.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_INSTPRINTER_WEBASSEMBLYINSTPRINTER_H
  14. #define LLVM_LIB_TARGET_WEBASSEMBLY_INSTPRINTER_WEBASSEMBLYINSTPRINTER_H
  15. #include "llvm/ADT/SmallVector.h"
  16. #include "llvm/BinaryFormat/Wasm.h"
  17. #include "llvm/MC/MCInstPrinter.h"
  18. #include "llvm/Support/MachineValueType.h"
  19. namespace llvm {
  20. class MCSubtargetInfo;
  21. class WebAssemblyInstPrinter final : public MCInstPrinter {
  22. uint64_t ControlFlowCounter = 0;
  23. SmallVector<std::pair<uint64_t, bool>, 4> ControlFlowStack;
  24. SmallVector<uint64_t, 4> TryStack;
  25. enum EHInstKind { TRY, CATCH, CATCH_ALL };
  26. SmallVector<EHInstKind, 4> EHInstStack;
  27. public:
  28. WebAssemblyInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
  29. const MCRegisterInfo &MRI);
  30. void printRegName(raw_ostream &OS, MCRegister Reg) const override;
  31. void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
  32. const MCSubtargetInfo &STI, raw_ostream &OS) override;
  33. // Used by tblegen code.
  34. void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O,
  35. bool IsVariadicDef = false);
  36. void printBrList(const MCInst *MI, unsigned OpNo, raw_ostream &O);
  37. void printWebAssemblyP2AlignOperand(const MCInst *MI, unsigned OpNo,
  38. raw_ostream &O);
  39. void printWebAssemblySignatureOperand(const MCInst *MI, unsigned OpNo,
  40. raw_ostream &O);
  41. // Autogenerated by tblgen.
  42. std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
  43. void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
  44. static const char *getRegisterName(MCRegister Reg);
  45. };
  46. } // end namespace llvm
  47. #endif