summaryrefslogtreecommitdiff
path: root/mlir/lib/Target/Wasm/TranslateRegistration.cpp
blob: 03b97846d45d3eb0eee9ad63d35433a5dac0ac13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//===- TranslateRegistration.cpp - Register translation -------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/WasmSSA/IR/WasmSSA.h"
#include "mlir/IR/DialectRegistry.h"
#include "mlir/IR/OwningOpRef.h"
#include "mlir/Target/Wasm/WasmImporter.h"
#include "mlir/Tools/mlir-translate/Translation.h"

using namespace mlir;

namespace mlir {
void registerFromWasmTranslation() {
  TranslateToMLIRRegistration registration{
      "import-wasm", "Translate WASM to MLIR",
      [](llvm::SourceMgr &sourceMgr,
         MLIRContext *context) -> OwningOpRef<Operation *> {
        return wasm::importWebAssemblyToModule(sourceMgr, context);
      },
      [](DialectRegistry &registry) {
        registry.insert<wasmssa::WasmSSADialect>();
      }};
}
} // namespace mlir