blob: d79c54097eb76a8cdc0525549f73178caa20087a [file] [log] [blame]
Dan Gohmane9361d52015-11-05 19:28:16 +00001//===-- WebAssemblyMCInstLower.h - Lower MachineInstr to MCInst -*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Dan Gohmane9361d52015-11-05 19:28:16 +00006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// This file declares the class to lower WebAssembly MachineInstrs to
Dan Gohmane9361d52015-11-05 19:28:16 +000011/// their corresponding MCInst records.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYMCINSTLOWER_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYMCINSTLOWER_H
17
Thomas Lively2cb27072019-10-15 18:28:22 +000018#include "llvm/BinaryFormat/Wasm.h"
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000019#include "llvm/MC/MCInst.h"
Dan Gohmane9361d52015-11-05 19:28:16 +000020#include "llvm/Support/Compiler.h"
21
22namespace llvm {
Dan Gohmand934cb82017-02-24 23:18:00 +000023class WebAssemblyAsmPrinter;
Dan Gohmane9361d52015-11-05 19:28:16 +000024class MCContext;
Dan Gohmane9361d52015-11-05 19:28:16 +000025class MCSymbol;
26class MachineInstr;
Dan Gohmane9361d52015-11-05 19:28:16 +000027class MachineOperand;
Dan Gohmane9361d52015-11-05 19:28:16 +000028
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000029/// This class is used to lower an MachineInstr into an MCInst.
Dan Gohmane9361d52015-11-05 19:28:16 +000030class LLVM_LIBRARY_VISIBILITY WebAssemblyMCInstLower {
31 MCContext &Ctx;
Dan Gohmand934cb82017-02-24 23:18:00 +000032 WebAssemblyAsmPrinter &Printer;
Dan Gohmane9361d52015-11-05 19:28:16 +000033
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000034 MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
35 MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
Sam Cleggef4c66c2019-04-03 00:17:29 +000036 MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
Thomas Lively2cb27072019-10-15 18:28:22 +000037 MCOperand lowerTypeIndexOperand(SmallVector<wasm::ValType, 1> &&,
38 SmallVector<wasm::ValType, 4> &&) const;
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000039
Dan Gohmane9361d52015-11-05 19:28:16 +000040public:
Dan Gohmand934cb82017-02-24 23:18:00 +000041 WebAssemblyMCInstLower(MCContext &ctx, WebAssemblyAsmPrinter &printer)
Dan Gohmane9361d52015-11-05 19:28:16 +000042 : Ctx(ctx), Printer(printer) {}
Heejin Ahn18c56a02019-02-04 19:13:39 +000043 void lower(const MachineInstr *MI, MCInst &OutMI) const;
Dan Gohmane9361d52015-11-05 19:28:16 +000044};
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000045} // end namespace llvm
Dan Gohmane9361d52015-11-05 19:28:16 +000046
47#endif