1//===-- WebAssemblyMCInstLower.h - Lower MachineInstr to MCInst -*- 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 file declares the class to lower WebAssembly MachineInstrs to
11/// their corresponding MCInst records.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYMCINSTLOWER_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYMCINSTLOWER_H
17
18#include "llvm/BinaryFormat/Wasm.h"
19#include "llvm/MC/MCInst.h"
20#include "llvm/Support/Compiler.h"
21
22namespace llvm {
23class WebAssemblyAsmPrinter;
24class DebugLoc;
25class GlobalValue;
26class MCContext;
27class MCSymbol;
28class MachineInstr;
29class MachineOperand;
30
31/// This class is used to lower an MachineInstr into an MCInst.
32class LLVM_LIBRARY_VISIBILITY WebAssemblyMCInstLower {
33 MCContext &Ctx;
34 WebAssemblyAsmPrinter &Printer;
35
36 MCSymbol *GetGlobalAddressSymbol(const GlobalValue &Global,
37 const DebugLoc &DL) const;
38 MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
39 MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
40 MCOperand lowerTypeIndexOperand(SmallVectorImpl<wasm::ValType> &&,
41 SmallVectorImpl<wasm::ValType> &&) const;
42 MCOperand lowerEncodedFunctionSignature(const APInt &Sig) const;
43
44public:
45 WebAssemblyMCInstLower(MCContext &ctx, WebAssemblyAsmPrinter &printer)
46 : Ctx(ctx), Printer(printer) {}
47 void lower(const MachineInstr *MI, MCInst &OutMI) const;
48};
49} // end namespace llvm
50
51#endif
52