Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 1 | //===-- WebAssemblyMCInstLower.h - Lower MachineInstr to MCInst -*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// |
| 9 | /// \file |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 10 | /// This file declares the class to lower WebAssembly MachineInstrs to |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 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 | |
Thomas Lively | 2cb2707 | 2019-10-15 18:28:22 +0000 | [diff] [blame] | 18 | #include "llvm/BinaryFormat/Wasm.h" |
Dan Gohman | d9b4cdb | 2015-12-21 17:19:31 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCInst.h" |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 20 | #include "llvm/Support/Compiler.h" |
| 21 | |
| 22 | namespace llvm { |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 23 | class WebAssemblyAsmPrinter; |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 24 | class MCContext; |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 25 | class MCSymbol; |
| 26 | class MachineInstr; |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 27 | class MachineOperand; |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 28 | |
Dan Gohman | d9b4cdb | 2015-12-21 17:19:31 +0000 | [diff] [blame] | 29 | /// This class is used to lower an MachineInstr into an MCInst. |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 30 | class LLVM_LIBRARY_VISIBILITY WebAssemblyMCInstLower { |
| 31 | MCContext &Ctx; |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 32 | WebAssemblyAsmPrinter &Printer; |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 33 | |
Dan Gohman | d9b4cdb | 2015-12-21 17:19:31 +0000 | [diff] [blame] | 34 | MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const; |
| 35 | MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const; |
Sam Clegg | ef4c66c | 2019-04-03 00:17:29 +0000 | [diff] [blame] | 36 | MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const; |
Thomas Lively | 2cb2707 | 2019-10-15 18:28:22 +0000 | [diff] [blame] | 37 | MCOperand lowerTypeIndexOperand(SmallVector<wasm::ValType, 1> &&, |
| 38 | SmallVector<wasm::ValType, 4> &&) const; |
Dan Gohman | d9b4cdb | 2015-12-21 17:19:31 +0000 | [diff] [blame] | 39 | |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 40 | public: |
Dan Gohman | d934cb8 | 2017-02-24 23:18:00 +0000 | [diff] [blame] | 41 | WebAssemblyMCInstLower(MCContext &ctx, WebAssemblyAsmPrinter &printer) |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 42 | : Ctx(ctx), Printer(printer) {} |
Heejin Ahn | 18c56a0 | 2019-02-04 19:13:39 +0000 | [diff] [blame] | 43 | void lower(const MachineInstr *MI, MCInst &OutMI) const; |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 44 | }; |
Dan Gohman | d9b4cdb | 2015-12-21 17:19:31 +0000 | [diff] [blame] | 45 | } // end namespace llvm |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 46 | |
| 47 | #endif |