[Mlir-commits] [mlir] [MLIR][Wasm] Introduce the WasmSSA MLIR dialect (PR #149233)
Ferdinand Lemaire
llvmlistbot at llvm.org
Fri Jul 18 01:11:01 PDT 2025
================
@@ -0,0 +1,186 @@
+//===-- WebAssemblySSAInterfaces.td - WebAssemblySSA Interfaces -*- tablegen -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines interfaces for the WebAssemblySSA dialect in MLIR.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef WEBASSEMBLYSSA_INTERFACES
+#define WEBASSEMBLYSSA_INTERFACES
+
+include "mlir/IR/OpBase.td"
+include "mlir/IR/BuiltinAttributes.td"
+
+def WasmSSALabelLevelInterface : OpInterface<"WasmSSALabelLevelInterface"> {
+ let description = [{
+ Operation that defines one level of nesting for wasm branching.
+ These operation region can be targeted by branch instructions.
+ }];
+ let methods = [
+ InterfaceMethod<
+ /*desc=*/ "Returns the target block address",
+ /*returnType=*/ "::mlir::Block*",
+ /*methodName=*/ "getLabelTarget",
+ /*args=*/ (ins)
+ >
+ ];
+}
+
+def WasmSSALabelBranchingInterface : OpInterface<"WasmSSALabelBranchingInterface"> {
+ let description = [{
+ Wasm operation that targets a label for a jump.
+ }];
+ let methods = [
+ InterfaceMethod<
+ /*desc=*/ "Returns the number of context to break from",
+ /*returnType=*/ "size_t",
+ /*methodName=*/ "getExitLevel",
+ /*args=*/ (ins)
+ >,
----------------
flemairen6 wrote:
Yes, so for instance (taken from the tests on our fork) - the last exemple of https://github.com/lforg37/llvm-project/blob/wasm.renamed_upstream_base/mlir/test/Target/Wasm/if.mlir
We use the `block_return` terminator op at end of any nesting. Later on when we lower it to other dialects, we "flatten" the nestings with branching to their respective original targets, there are some examples in https://github.com/lforg37/llvm-project/blob/wasm.renamed_upstream_base/mlir/test/Conversion/RaiseWasm/wasm-blocks-to-cf.mlir
https://github.com/llvm/llvm-project/pull/149233
More information about the Mlir-commits
mailing list