[Mlir-commits] [mlir] [MLIR][WASM] Control flow, conversion and comparison in Wasm importer (PR #154674)
Jacques Pienaar
llvmlistbot at llvm.org
Wed Oct 1 08:08:44 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: ")
----------------
jpienaar wrote:
HereMLIR follows LLVM error convention (https://llvm.org/docs/CodingStandards.html#error-and-warning-messages), sentence fragments, starting with lower case and not ending in period (for this I'd make it parenthesis)
https://github.com/llvm/llvm-project/pull/154674
More information about the Mlir-commits
mailing list