blob: 159bac4f996ed7605b9474ff71d5b05737388522 [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
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000018#include "llvm/MC/MCInst.h"
Dan Gohmane9361d52015-11-05 19:28:16 +000019#include "llvm/Support/Compiler.h"
20
21namespace llvm {
Dan Gohmand934cb82017-02-24 23:18:00 +000022class WebAssemblyAsmPrinter;
Dan Gohmane9361d52015-11-05 19:28:16 +000023class MCContext;
Dan Gohmane9361d52015-11-05 19:28:16 +000024class MCSymbol;
25class MachineInstr;
Dan Gohmane9361d52015-11-05 19:28:16 +000026class MachineOperand;
Dan Gohmane9361d52015-11-05 19:28:16 +000027
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000028/// This class is used to lower an MachineInstr into an MCInst.
Dan Gohmane9361d52015-11-05 19:28:16 +000029class LLVM_LIBRARY_VISIBILITY WebAssemblyMCInstLower {
30 MCContext &Ctx;
Dan Gohmand934cb82017-02-24 23:18:00 +000031 WebAssemblyAsmPrinter &Printer;
Dan Gohmane9361d52015-11-05 19:28:16 +000032
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000033 MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
34 MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
Heejin Ahnf208f632018-09-05 01:27:38 +000035 MCOperand LowerSymbolOperand(MCSymbol *Sym, int64_t Offset, bool IsFunc,
Heejin Ahnda419bd2018-11-14 02:46:21 +000036 bool IsGlob, bool IsEvent) const;
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000037
Dan Gohmane9361d52015-11-05 19:28:16 +000038public:
Dan Gohmand934cb82017-02-24 23:18:00 +000039 WebAssemblyMCInstLower(MCContext &ctx, WebAssemblyAsmPrinter &printer)
Dan Gohmane9361d52015-11-05 19:28:16 +000040 : Ctx(ctx), Printer(printer) {}
41 void Lower(const MachineInstr *MI, MCInst &OutMI) const;
Dan Gohmane9361d52015-11-05 19:28:16 +000042};
Dan Gohmand9b4cdb2015-12-21 17:19:31 +000043} // end namespace llvm
Dan Gohmane9361d52015-11-05 19:28:16 +000044
45#endif