[Mlir-commits] [mlir] [MLIR][WASM] Control flow, conversion and comparison in Wasm importer (PR #154674)
Luc Forget
llvmlistbot at llvm.org
Wed Oct 1 21:48:43 PDT 2025
================
@@ -280,11 +308,102 @@ class ExpressionParser {
}
}
+ struct NestingContext {
+ NestingContext(ExpressionParser &parser, LabelLevelOpInterface levelOp)
+ : parser{parser} {
+ parser.addNestingContextLevel(levelOp);
+ }
+ NestingContext(NestingContext &&other) : parser{other.parser} {
+ other.shouldDropOnDestruct = false;
+ }
+ NestingContext(NestingContext const &) = delete;
+ ~NestingContext() {
+ if (shouldDropOnDestruct)
+ parser.dropNestingContextLevel();
+ }
+ ExpressionParser &parser;
+ bool shouldDropOnDestruct = true;
+ };
+
+ void addNestingContextLevel(LabelLevelOpInterface levelOp) {
+ valueStack.addLabelLevel(levelOp);
+ }
+
+ void dropNestingContextLevel() {
+ // Should always succeed as we are droping the frame that was previously
+ // created.
+ valueStack.dropLabelLevel();
+ }
+
+ llvm::FailureOr<FunctionType> getFuncTypeFor(OpBuilder &builder,
+ EmptyBlockMarker) {
+ return builder.getFunctionType({}, {});
+ }
+
+ llvm::FailureOr<FunctionType> getFuncTypeFor(OpBuilder &builder,
+ TypeIdxRecord type) {
+ if (type.id > symbols.moduleFuncTypes.size())
+ return emitError(*currentOpLoc,
+ "Type index references nonexistent type: ")
----------------
lforg37 wrote:
Changed it, and added a test for it.
https://github.com/llvm/llvm-project/pull/154674
More information about the Mlir-commits
mailing list